From d21e6b4b70b0b6baa0115c392eb94c2d207678e2 Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Thu, 18 Dec 2014 15:06:05 +0300 Subject: [PATCH 01/95] IGNITE-61 - Portable format in direct marshalling --- .../jobstealing/JobStealingRequest.java | 6 +- .../tcp/TcpCommunicationSpi.java | 108 +- .../GridClientConnectionManagerAdapter.java | 75 +- .../grid/kernal/GridJobCancelRequest.java | 14 +- .../grid/kernal/GridJobExecuteRequest.java | 102 +- .../grid/kernal/GridJobExecuteRequestV2.java | 6 +- .../grid/kernal/GridJobExecuteResponse.java | 30 +- .../grid/kernal/GridJobSiblingsRequest.java | 10 +- .../grid/kernal/GridJobSiblingsResponse.java | 6 +- .../grid/kernal/GridTaskCancelRequest.java | 6 +- .../grid/kernal/GridTaskSessionRequest.java | 14 +- .../checkpoint/GridCheckpointRequest.java | 14 +- .../managers/communication/GridIoMessage.java | 30 +- .../communication/GridIoUserMessage.java | 40 +- .../deployment/GridDeploymentInfoBean.java | 32 +- .../deployment/GridDeploymentRequest.java | 28 +- .../deployment/GridDeploymentResponse.java | 14 +- .../eventstorage/GridEventStorageMessage.java | 48 +- .../cache/GridCacheEvictionRequest.java | 14 +- .../cache/GridCacheEvictionResponse.java | 20 +- .../processors/cache/GridCacheMessage.java | 14 +- ...CacheOptimisticCheckPreparedTxRequest.java | 18 +- ...acheOptimisticCheckPreparedTxResponse.java | 14 +- ...chePessimisticCheckCommittedTxRequest.java | 26 +- ...hePessimisticCheckCommittedTxResponse.java | 14 +- .../GridDistributedBaseMessage.java | 34 +- .../GridDistributedLockRequest.java | 78 +- .../GridDistributedLockResponse.java | 20 +- .../GridDistributedTxFinishRequest.java | 62 +- .../GridDistributedTxFinishResponse.java | 10 +- .../GridDistributedTxPrepareRequest.java | 66 +- .../GridDistributedTxPrepareResponse.java | 10 +- .../GridDistributedUnlockRequest.java | 12 +- .../dht/GridDhtAffinityAssignmentRequest.java | 6 +- .../GridDhtAffinityAssignmentResponse.java | 10 +- .../distributed/dht/GridDhtLockRequest.java | 40 +- .../distributed/dht/GridDhtLockResponse.java | 36 +- .../dht/GridDhtTxFinishRequest.java | 58 +- .../dht/GridDhtTxFinishResponse.java | 6 +- .../dht/GridDhtTxPrepareRequest.java | 56 +- .../dht/GridDhtTxPrepareResponse.java | 40 +- .../distributed/dht/GridDhtUnlockRequest.java | 12 +- .../GridDhtAtomicDeferredUpdateResponse.java | 12 +- .../atomic/GridDhtAtomicUpdateRequest.java | 116 +- .../atomic/GridDhtAtomicUpdateResponse.java | 24 +- .../atomic/GridNearAtomicUpdateRequest.java | 98 +- .../atomic/GridNearAtomicUpdateResponse.java | 60 +- .../preloader/GridDhtForceKeysRequest.java | 24 +- .../preloader/GridDhtForceKeysResponse.java | 24 +- .../GridDhtPartitionDemandMessage.java | 32 +- .../GridDhtPartitionSupplyMessage.java | 38 +- .../GridDhtPartitionsAbstractMessage.java | 10 +- .../GridDhtPartitionsFullMessage.java | 14 +- .../GridDhtPartitionsSingleMessage.java | 6 +- .../GridDhtPartitionsSingleRequest.java | 2 +- .../distributed/near/GridNearGetRequest.java | 54 +- .../distributed/near/GridNearGetResponse.java | 36 +- .../distributed/near/GridNearLockRequest.java | 54 +- .../near/GridNearLockResponse.java | 40 +- .../near/GridNearTxFinishRequest.java | 22 +- .../near/GridNearTxFinishResponse.java | 14 +- .../near/GridNearTxPrepareRequest.java | 40 +- .../near/GridNearTxPrepareResponse.java | 44 +- .../near/GridNearUnlockRequest.java | 2 +- .../cache/query/GridCacheQueryRequest.java | 78 +- .../cache/query/GridCacheQueryResponse.java | 38 +- .../clock/GridClockDeltaSnapshotMessage.java | 20 +- .../continuous/GridContinuousMessage.java | 14 +- .../dataload/GridDataLoadRequest.java | 60 +- .../dataload/GridDataLoadResponse.java | 14 +- .../processors/ggfs/GridGgfsAckMessage.java | 14 +- .../processors/ggfs/GridGgfsBlockKey.java | 18 +- .../ggfs/GridGgfsBlocksMessage.java | 24 +- .../ggfs/GridGgfsCommunicationMessage.java | 2 +- .../ggfs/GridGgfsDeleteMessage.java | 10 +- .../ggfs/GridGgfsFileAffinityRange.java | 22 +- .../ggfs/GridGgfsFragmentizerRequest.java | 16 +- .../ggfs/GridGgfsFragmentizerResponse.java | 6 +- .../processors/ggfs/GridGgfsSyncMessage.java | 10 +- .../portable/GridPortableOutputStream.java | 7 - .../GridClientHandshakeRequestWrapper.java | 16 +- .../GridClientHandshakeResponseWrapper.java | 2 +- .../message/GridClientMessageWrapper.java | 38 +- .../message/GridClientPingPacketWrapper.java | 4 +- .../handlers/task/GridTaskResultRequest.java | 10 +- .../handlers/task/GridTaskResultResponse.java | 18 +- .../tcp/GridMemcachedMessageWrapper.java | 4 +- .../tcp/GridTcpRestDirectParser.java | 12 +- .../protocols/tcp/GridTcpRestProtocol.java | 57 +- .../streamer/GridStreamerCancelRequest.java | 6 +- .../GridStreamerExecutionRequest.java | 40 +- .../streamer/GridStreamerResponse.java | 10 +- .../org/gridgain/grid/util/GridLongList.java | 10 +- .../org/gridgain/grid/util/GridUtils.java | 34 + .../direct/GridPortableByteBufferStream.java | 726 +++++++++ .../GridTcpCommunicationMessageAdapter.java | 22 - .../GridTcpCommunicationMessageState.java | 1321 +++++------------ .../grid/util/ipc/GridIpcToNioAdapter.java | 15 +- .../grid/util/nio/GridDirectParser.java | 11 +- .../grid/util/nio/GridNioMessageReader.java | 34 - .../grid/util/nio/GridNioMessageWriter.java | 41 - .../gridgain/grid/util/nio/GridNioServer.java | 39 +- .../nio/GridShmemCommunicationClient.java | 19 +- .../util/nio/GridTcpCommunicationClient.java | 9 +- .../spi/communication/GridTestMessage.java | 18 +- .../GridCommunicationSendMessageSelfTest.java | 2 +- 106 files changed, 2373 insertions(+), 2523 deletions(-) create mode 100644 modules/core/src/main/java/org/gridgain/grid/util/direct/GridPortableByteBufferStream.java delete mode 100644 modules/core/src/main/java/org/gridgain/grid/util/nio/GridNioMessageReader.java delete mode 100644 modules/core/src/main/java/org/gridgain/grid/util/nio/GridNioMessageWriter.java diff --git a/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java b/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java index 4df54a2420415..6e43563e9dd5d 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java @@ -69,7 +69,7 @@ int delta() { commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -77,7 +77,7 @@ int delta() { switch (commState.idx) { case 0: - if (!commState.putInt(delta)) + if (!commState.putInt(null, delta)) return false; commState.idx++; @@ -97,7 +97,7 @@ int delta() { if (buf.remaining() < 4) return false; - delta = commState.getInt(); + delta = commState.getInt(null); commState.idx++; diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java index 9ba7c458afb5d..16d161c6d4d60 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java @@ -15,13 +15,12 @@ import org.apache.ignite.events.*; import org.apache.ignite.lang.*; import org.apache.ignite.marshaller.*; -import org.apache.ignite.product.*; import org.apache.ignite.resources.*; import org.apache.ignite.spi.*; +import org.apache.ignite.spi.communication.*; import org.apache.ignite.thread.*; import org.gridgain.grid.*; import org.gridgain.grid.kernal.managers.eventstorage.*; -import org.apache.ignite.spi.communication.*; import org.gridgain.grid.util.*; import org.gridgain.grid.util.direct.*; import org.gridgain.grid.util.future.*; @@ -324,13 +323,6 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter ClusterNode locNode = getSpiContext().localNode(); - IgniteProductVersion locVer = locNode.version(); - - IgniteProductVersion rmtVer = rmtNode.version(); - - if (!locVer.equals(rmtVer)) - ses.addMeta(GridNioServer.DIFF_VER_NODE_ID_META_KEY, sndId); - if (ses.remoteAddress() == null) return; @@ -790,87 +782,6 @@ class ConnectClosure implements IgniteInClosure { } }; - /** Message reader. */ - private final GridNioMessageReader msgReader = new GridNioMessageReader() { - /** */ - private GridTcpMessageFactory msgFactory; - - @Override public boolean read(@Nullable UUID nodeId, GridTcpCommunicationMessageAdapter msg, ByteBuffer buf) { - assert msg != null; - assert buf != null; - - msg.messageReader(this, nodeId); - - boolean finished = msg.readFrom(buf); - - if (finished && nodeId != null) - finished = getSpiContext().readDelta(nodeId, msg.getClass(), buf); - - return finished; - } - - @Nullable @Override public GridTcpMessageFactory messageFactory() { - if (msgFactory == null) - msgFactory = getSpiContext().messageFactory(); - - return msgFactory; - } - }; - - /** Message writer. */ - private final GridNioMessageWriter msgWriter = new GridNioMessageWriter() { - @Override public boolean write(@Nullable UUID nodeId, GridTcpCommunicationMessageAdapter msg, ByteBuffer buf) { - assert msg != null; - assert buf != null; - - msg.messageWriter(this, nodeId); - - boolean finished = msg.writeTo(buf); - - if (finished && nodeId != null) - finished = getSpiContext().writeDelta(nodeId, msg, buf); - - return finished; - } - - @Override public int writeFully(@Nullable UUID nodeId, GridTcpCommunicationMessageAdapter msg, OutputStream out, - ByteBuffer buf) throws IOException { - assert msg != null; - assert out != null; - assert buf != null; - assert buf.hasArray(); - - msg.messageWriter(this, nodeId); - - boolean finished = false; - int cnt = 0; - - while (!finished) { - finished = msg.writeTo(buf); - - out.write(buf.array(), 0, buf.position()); - - cnt += buf.position(); - - buf.clear(); - } - - if (nodeId != null) { - while (!finished) { - finished = getSpiContext().writeDelta(nodeId, msg.getClass(), buf); - - out.write(buf.array(), 0, buf.position()); - - cnt += buf.position(); - - buf.clear(); - } - } - - return cnt; - } - }; - /** * Sets address resolver. * @@ -1564,9 +1475,8 @@ private GridNioServer resetNioServer() throw .sendQueueLimit(msgQueueLimit) .directMode(true) .metricsListener(metricsLsnr) - .messageWriter(msgWriter) .writeTimeout(sockWriteTimeout) - .filters(new GridNioCodecFilter(new GridDirectParser(msgReader, this), log, true), + .filters(new GridNioCodecFilter(new GridDirectParser(this), log, true), new GridConnectionBytesVerifyFilter(log)) .build(); @@ -1925,7 +1835,7 @@ else if (log.isDebugEnabled()) GridCommunicationClient client; try { - client = new GridShmemCommunicationClient(metricsLsnr, port, connTimeout, log, msgWriter); + client = new GridShmemCommunicationClient(metricsLsnr, port, connTimeout, log); } catch (IgniteCheckedException e) { // Reconnect for the second time, if connection is not established. @@ -2066,19 +1976,10 @@ protected GridCommunicationClient createTcpClient(ClusterNode node) throws Ignit recoveryDesc.release(); } - UUID diffVerNodeId = null; - - IgniteProductVersion locVer = getSpiContext().localNode().version(); - IgniteProductVersion rmtVer = node.version(); - - if (!locVer.equals(rmtVer)) - diffVerNodeId = node.id(); - try { Map meta = new HashMap<>(); meta.put(NODE_ID_META, node.id()); - meta.put(GridNioServer.DIFF_VER_NODE_ID_META_KEY, diffVerNodeId); if (recoveryDesc != null) { recoveryDesc.onHandshake(rcvCnt); @@ -2502,9 +2403,8 @@ private ShmemWorker(GridIpcEndpoint endpoint) { metricsLsnr, log, endpoint, - msgWriter, srvLsnr, - new GridNioCodecFilter(new GridDirectParser(msgReader, TcpCommunicationSpi.this), log, true), + new GridNioCodecFilter(new GridDirectParser(TcpCommunicationSpi.this), log, true), new GridConnectionBytesVerifyFilter(log) ); diff --git a/modules/core/src/main/java/org/gridgain/client/impl/connection/GridClientConnectionManagerAdapter.java b/modules/core/src/main/java/org/gridgain/client/impl/connection/GridClientConnectionManagerAdapter.java index a5a27a6a1f64e..56700e7b8af43 100644 --- a/modules/core/src/main/java/org/gridgain/client/impl/connection/GridClientConnectionManagerAdapter.java +++ b/modules/core/src/main/java/org/gridgain/client/impl/connection/GridClientConnectionManagerAdapter.java @@ -11,12 +11,11 @@ import org.apache.ignite.*; import org.apache.ignite.logger.java.*; +import org.apache.ignite.plugin.security.*; import org.gridgain.client.*; import org.gridgain.client.impl.*; import org.gridgain.client.util.*; -import org.gridgain.grid.*; import org.gridgain.grid.kernal.processors.rest.client.message.*; -import org.apache.ignite.plugin.security.*; import org.gridgain.grid.util.direct.*; import org.gridgain.grid.util.nio.*; import org.gridgain.grid.util.nio.ssl.*; @@ -88,44 +87,6 @@ abstract class GridClientConnectionManagerAdapter implements GridClientConnectio /** Marshaller ID. */ private final Byte marshId; - /** Message writer. */ - @SuppressWarnings("FieldCanBeLocal") - private final GridNioMessageWriter msgWriter = new GridNioMessageWriter() { - @Override public boolean write(@Nullable UUID nodeId, GridTcpCommunicationMessageAdapter msg, ByteBuffer buf) { - assert msg != null; - assert buf != null; - - msg.messageWriter(this, nodeId); - - return msg.writeTo(buf); - } - - @Override public int writeFully(@Nullable UUID nodeId, GridTcpCommunicationMessageAdapter msg, OutputStream out, - ByteBuffer buf) throws IOException { - assert msg != null; - assert out != null; - assert buf != null; - assert buf.hasArray(); - - msg.messageWriter(this, nodeId); - - boolean finished = false; - int cnt = 0; - - while (!finished) { - finished = msg.writeTo(buf); - - out.write(buf.array(), 0, buf.position()); - - cnt += buf.position(); - - buf.clear(); - } - - return cnt; - } - }; - /** * @param clientId Client ID. * @param sslCtx SSL context to enable secured connection or {@code null} to use unsecured one. @@ -173,23 +134,7 @@ protected GridClientConnectionManagerAdapter(UUID clientId, GridNioFilter[] filters; - GridNioMessageReader msgReader = new GridNioMessageReader() { - @Override public boolean read(@Nullable UUID nodeId, GridTcpCommunicationMessageAdapter msg, - ByteBuffer buf) { - assert msg != null; - assert buf != null; - - msg.messageReader(this, nodeId); - - return msg.readFrom(buf); - } - - @Nullable @Override public GridTcpMessageFactory messageFactory() { - return null; - } - }; - - GridNioFilter codecFilter = new GridNioCodecFilter(new NioParser(msgReader), gridLog, true); + GridNioFilter codecFilter = new GridNioCodecFilter(new NioParser(), gridLog, true); if (sslCtx != null) { GridNioSslFilter sslFilter = new GridNioSslFilter(sslCtx, gridLog); @@ -217,7 +162,6 @@ protected GridClientConnectionManagerAdapter(UUID clientId, .socketSendBufferSize(0) .idleTimeout(Long.MAX_VALUE) .gridName("gridClient") - .messageWriter(msgWriter) .daemon(cfg.isDaemon()) .build(); @@ -702,18 +646,9 @@ private static class NioParser implements GridNioParser { /** Message metadata key. */ private static final int MSG_META_KEY = GridNioSessionMetaKey.nextUniqueKey(); - /** Message reader. */ - private final GridNioMessageReader msgReader; - - /** - * @param msgReader Message reader. - */ - NioParser(GridNioMessageReader msgReader) { - this.msgReader = msgReader; - } - /** {@inheritDoc} */ - @Nullable @Override public Object decode(GridNioSession ses, ByteBuffer buf) throws IOException, IgniteCheckedException { + @Nullable @Override public Object decode(GridNioSession ses, ByteBuffer buf) + throws IOException, IgniteCheckedException { GridClientFutureAdapter handshakeFut = ses.meta(GridClientNioTcpConnection.SES_META_HANDSHAKE); if (handshakeFut != null) { @@ -736,7 +671,7 @@ private static class NioParser implements GridNioParser { boolean finished = false; if (buf.hasRemaining()) - finished = msgReader.read(null, msg, buf); + finished = msg.readFrom(buf); if (finished) return msg; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobCancelRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobCancelRequest.java index 90dc740522617..1c0e1a4901a49 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobCancelRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobCancelRequest.java @@ -126,7 +126,7 @@ public boolean system() { commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -134,19 +134,19 @@ public boolean system() { switch (commState.idx) { case 0: - if (!commState.putGridUuid(jobId)) + if (!commState.putGridUuid(null, jobId)) return false; commState.idx++; case 1: - if (!commState.putGridUuid(sesId)) + if (!commState.putGridUuid(null, sesId)) return false; commState.idx++; case 2: - if (!commState.putBoolean(sys)) + if (!commState.putBoolean(null, sys)) return false; commState.idx++; @@ -163,7 +163,7 @@ public boolean system() { switch (commState.idx) { case 0: - IgniteUuid jobId0 = commState.getGridUuid(); + IgniteUuid jobId0 = commState.getGridUuid(null); if (jobId0 == GRID_UUID_NOT_READ) return false; @@ -173,7 +173,7 @@ public boolean system() { commState.idx++; case 1: - IgniteUuid sesId0 = commState.getGridUuid(); + IgniteUuid sesId0 = commState.getGridUuid(null); if (sesId0 == GRID_UUID_NOT_READ) return false; @@ -186,7 +186,7 @@ public boolean system() { if (buf.remaining() < 1) return false; - sys = commState.getBoolean(); + sys = commState.getBoolean(null); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobExecuteRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobExecuteRequest.java index 12f7d8f7f2dfe..2e3eba7cbdf71 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobExecuteRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobExecuteRequest.java @@ -449,7 +449,7 @@ public UUID getSubjectId() { commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -457,61 +457,61 @@ public UUID getSubjectId() { switch (commState.idx) { case 0: - if (!commState.putGridUuid(clsLdrId)) + if (!commState.putGridUuid(null, clsLdrId)) return false; commState.idx++; case 1: - if (!commState.putString(cpSpi)) + if (!commState.putString(null, cpSpi)) return false; commState.idx++; case 2: - if (!commState.putLong(createTime)) + if (!commState.putLong(null, createTime)) return false; commState.idx++; case 3: - if (!commState.putEnum(depMode)) + if (!commState.putEnum(null, depMode)) return false; commState.idx++; case 4: - if (!commState.putBoolean(dynamicSiblings)) + if (!commState.putBoolean(null, dynamicSiblings)) return false; commState.idx++; case 5: - if (!commState.putBoolean(forceLocDep)) + if (!commState.putBoolean(null, forceLocDep)) return false; commState.idx++; case 6: - if (!commState.putBoolean(internal)) + if (!commState.putBoolean(null, internal)) return false; commState.idx++; case 7: - if (!commState.putByteArray(jobAttrsBytes)) + if (!commState.putByteArray(null, jobAttrsBytes)) return false; commState.idx++; case 8: - if (!commState.putByteArray(jobBytes)) + if (!commState.putByteArray(null, jobBytes)) return false; commState.idx++; case 9: - if (!commState.putGridUuid(jobId)) + if (!commState.putGridUuid(null, jobId)) return false; commState.idx++; @@ -519,7 +519,7 @@ public UUID getSubjectId() { case 10: if (ldrParticipants != null) { if (commState.it == null) { - if (!commState.putInt(ldrParticipants.size())) + if (!commState.putInt(null, ldrParticipants.size())) return false; commState.it = ldrParticipants.entrySet().iterator(); @@ -532,13 +532,13 @@ public UUID getSubjectId() { Map.Entry e = (Map.Entry)commState.cur; if (!commState.keyDone) { - if (!commState.putUuid(e.getKey())) + if (!commState.putUuid(null, e.getKey())) return false; commState.keyDone = true; } - if (!commState.putGridUuid(e.getValue())) + if (!commState.putGridUuid(null, e.getValue())) return false; commState.keyDone = false; @@ -548,56 +548,56 @@ public UUID getSubjectId() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 11: - if (!commState.putByteArray(sesAttrsBytes)) + if (!commState.putByteArray(null, sesAttrsBytes)) return false; commState.idx++; case 12: - if (!commState.putBoolean(sesFullSup)) + if (!commState.putBoolean(null, sesFullSup)) return false; commState.idx++; case 13: - if (!commState.putGridUuid(sesId)) + if (!commState.putGridUuid(null, sesId)) return false; commState.idx++; case 14: - if (!commState.putByteArray(siblingsBytes)) + if (!commState.putByteArray(null, siblingsBytes)) return false; commState.idx++; case 15: - if (!commState.putLong(startTaskTime)) + if (!commState.putLong(null, startTaskTime)) return false; commState.idx++; case 16: - if (!commState.putString(taskClsName)) + if (!commState.putString(null, taskClsName)) return false; commState.idx++; case 17: - if (!commState.putString(taskName)) + if (!commState.putString(null, taskName)) return false; commState.idx++; case 18: - if (!commState.putLong(timeout)) + if (!commState.putLong(null, timeout)) return false; commState.idx++; @@ -605,7 +605,7 @@ public UUID getSubjectId() { case 19: if (top != null) { if (commState.it == null) { - if (!commState.putInt(top.size())) + if (!commState.putInt(null, top.size())) return false; commState.it = top.iterator(); @@ -615,7 +615,7 @@ public UUID getSubjectId() { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putUuid((UUID)commState.cur)) + if (!commState.putUuid(null, (UUID)commState.cur)) return false; commState.cur = NULL; @@ -623,14 +623,14 @@ public UUID getSubjectId() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 20: - if (!commState.putString(userVer)) + if (!commState.putString(null, userVer)) return false; commState.idx++; @@ -647,7 +647,7 @@ public UUID getSubjectId() { switch (commState.idx) { case 0: - IgniteUuid clsLdrId0 = commState.getGridUuid(); + IgniteUuid clsLdrId0 = commState.getGridUuid(null); if (clsLdrId0 == GRID_UUID_NOT_READ) return false; @@ -657,7 +657,7 @@ public UUID getSubjectId() { commState.idx++; case 1: - String cpSpi0 = commState.getString(); + String cpSpi0 = commState.getString(null); if (cpSpi0 == STR_NOT_READ) return false; @@ -670,7 +670,7 @@ public UUID getSubjectId() { if (buf.remaining() < 8) return false; - createTime = commState.getLong(); + createTime = commState.getLong(null); commState.idx++; @@ -678,7 +678,7 @@ public UUID getSubjectId() { if (buf.remaining() < 1) return false; - byte depMode0 = commState.getByte(); + byte depMode0 = commState.getByte(null); depMode = IgniteDeploymentMode.fromOrdinal(depMode0); @@ -688,7 +688,7 @@ public UUID getSubjectId() { if (buf.remaining() < 1) return false; - dynamicSiblings = commState.getBoolean(); + dynamicSiblings = commState.getBoolean(null); commState.idx++; @@ -696,7 +696,7 @@ public UUID getSubjectId() { if (buf.remaining() < 1) return false; - forceLocDep = commState.getBoolean(); + forceLocDep = commState.getBoolean(null); commState.idx++; @@ -704,12 +704,12 @@ public UUID getSubjectId() { if (buf.remaining() < 1) return false; - internal = commState.getBoolean(); + internal = commState.getBoolean(null); commState.idx++; case 7: - byte[] jobAttrsBytes0 = commState.getByteArray(); + byte[] jobAttrsBytes0 = commState.getByteArray(null); if (jobAttrsBytes0 == BYTE_ARR_NOT_READ) return false; @@ -719,7 +719,7 @@ public UUID getSubjectId() { commState.idx++; case 8: - byte[] jobBytes0 = commState.getByteArray(); + byte[] jobBytes0 = commState.getByteArray(null); if (jobBytes0 == BYTE_ARR_NOT_READ) return false; @@ -729,7 +729,7 @@ public UUID getSubjectId() { commState.idx++; case 9: - IgniteUuid jobId0 = commState.getGridUuid(); + IgniteUuid jobId0 = commState.getGridUuid(null); if (jobId0 == GRID_UUID_NOT_READ) return false; @@ -743,7 +743,7 @@ public UUID getSubjectId() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -752,7 +752,7 @@ public UUID getSubjectId() { for (int i = commState.readItems; i < commState.readSize; i++) { if (!commState.keyDone) { - UUID _val = commState.getUuid(); + UUID _val = commState.getUuid(null); if (_val == UUID_NOT_READ) return false; @@ -761,7 +761,7 @@ public UUID getSubjectId() { commState.keyDone = true; } - IgniteUuid _val = commState.getGridUuid(); + IgniteUuid _val = commState.getGridUuid(null); if (_val == GRID_UUID_NOT_READ) return false; @@ -781,7 +781,7 @@ public UUID getSubjectId() { commState.idx++; case 11: - byte[] sesAttrsBytes0 = commState.getByteArray(); + byte[] sesAttrsBytes0 = commState.getByteArray(null); if (sesAttrsBytes0 == BYTE_ARR_NOT_READ) return false; @@ -794,12 +794,12 @@ public UUID getSubjectId() { if (buf.remaining() < 1) return false; - sesFullSup = commState.getBoolean(); + sesFullSup = commState.getBoolean(null); commState.idx++; case 13: - IgniteUuid sesId0 = commState.getGridUuid(); + IgniteUuid sesId0 = commState.getGridUuid(null); if (sesId0 == GRID_UUID_NOT_READ) return false; @@ -809,7 +809,7 @@ public UUID getSubjectId() { commState.idx++; case 14: - byte[] siblingsBytes0 = commState.getByteArray(); + byte[] siblingsBytes0 = commState.getByteArray(null); if (siblingsBytes0 == BYTE_ARR_NOT_READ) return false; @@ -822,12 +822,12 @@ public UUID getSubjectId() { if (buf.remaining() < 8) return false; - startTaskTime = commState.getLong(); + startTaskTime = commState.getLong(null); commState.idx++; case 16: - String taskClsName0 = commState.getString(); + String taskClsName0 = commState.getString(null); if (taskClsName0 == STR_NOT_READ) return false; @@ -837,7 +837,7 @@ public UUID getSubjectId() { commState.idx++; case 17: - String taskName0 = commState.getString(); + String taskName0 = commState.getString(null); if (taskName0 == STR_NOT_READ) return false; @@ -850,7 +850,7 @@ public UUID getSubjectId() { if (buf.remaining() < 8) return false; - timeout = commState.getLong(); + timeout = commState.getLong(null); commState.idx++; @@ -859,7 +859,7 @@ public UUID getSubjectId() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -867,7 +867,7 @@ public UUID getSubjectId() { top = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - UUID _val = commState.getUuid(); + UUID _val = commState.getUuid(null); if (_val == UUID_NOT_READ) return false; @@ -884,7 +884,7 @@ public UUID getSubjectId() { commState.idx++; case 20: - String userVer0 = commState.getString(); + String userVer0 = commState.getString(null); if (userVer0 == STR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobExecuteRequestV2.java b/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobExecuteRequestV2.java index 77932245dddd5..cf708427ebcfb 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobExecuteRequestV2.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobExecuteRequestV2.java @@ -129,7 +129,7 @@ public GridJobExecuteRequestV2( return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -137,7 +137,7 @@ public GridJobExecuteRequestV2( switch (commState.idx) { case 21: - if (!commState.putUuid(subjId)) + if (!commState.putUuid(null, subjId)) return false; commState.idx++; @@ -156,7 +156,7 @@ public GridJobExecuteRequestV2( switch (commState.idx) { case 21: - UUID subjId0 = commState.getUuid(); + UUID subjId0 = commState.getUuid(null); if (subjId0 == UUID_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobExecuteResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobExecuteResponse.java index b605753d049b0..88e74831b0be2 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobExecuteResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobExecuteResponse.java @@ -221,7 +221,7 @@ public void setFakeException(IgniteCheckedException fakeEx) { commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -229,43 +229,43 @@ public void setFakeException(IgniteCheckedException fakeEx) { switch (commState.idx) { case 0: - if (!commState.putByteArray(gridExBytes)) + if (!commState.putByteArray(null, gridExBytes)) return false; commState.idx++; case 1: - if (!commState.putBoolean(isCancelled)) + if (!commState.putBoolean(null, isCancelled)) return false; commState.idx++; case 2: - if (!commState.putByteArray(jobAttrsBytes)) + if (!commState.putByteArray(null, jobAttrsBytes)) return false; commState.idx++; case 3: - if (!commState.putGridUuid(jobId)) + if (!commState.putGridUuid(null, jobId)) return false; commState.idx++; case 4: - if (!commState.putUuid(nodeId)) + if (!commState.putUuid(null, nodeId)) return false; commState.idx++; case 5: - if (!commState.putByteArray(resBytes)) + if (!commState.putByteArray(null, resBytes)) return false; commState.idx++; case 6: - if (!commState.putGridUuid(sesId)) + if (!commState.putGridUuid(null, sesId)) return false; commState.idx++; @@ -282,7 +282,7 @@ public void setFakeException(IgniteCheckedException fakeEx) { switch (commState.idx) { case 0: - byte[] gridExBytes0 = commState.getByteArray(); + byte[] gridExBytes0 = commState.getByteArray(null); if (gridExBytes0 == BYTE_ARR_NOT_READ) return false; @@ -295,12 +295,12 @@ public void setFakeException(IgniteCheckedException fakeEx) { if (buf.remaining() < 1) return false; - isCancelled = commState.getBoolean(); + isCancelled = commState.getBoolean(null); commState.idx++; case 2: - byte[] jobAttrsBytes0 = commState.getByteArray(); + byte[] jobAttrsBytes0 = commState.getByteArray(null); if (jobAttrsBytes0 == BYTE_ARR_NOT_READ) return false; @@ -310,7 +310,7 @@ public void setFakeException(IgniteCheckedException fakeEx) { commState.idx++; case 3: - IgniteUuid jobId0 = commState.getGridUuid(); + IgniteUuid jobId0 = commState.getGridUuid(null); if (jobId0 == GRID_UUID_NOT_READ) return false; @@ -320,7 +320,7 @@ public void setFakeException(IgniteCheckedException fakeEx) { commState.idx++; case 4: - UUID nodeId0 = commState.getUuid(); + UUID nodeId0 = commState.getUuid(null); if (nodeId0 == UUID_NOT_READ) return false; @@ -330,7 +330,7 @@ public void setFakeException(IgniteCheckedException fakeEx) { commState.idx++; case 5: - byte[] resBytes0 = commState.getByteArray(); + byte[] resBytes0 = commState.getByteArray(null); if (resBytes0 == BYTE_ARR_NOT_READ) return false; @@ -340,7 +340,7 @@ public void setFakeException(IgniteCheckedException fakeEx) { commState.idx++; case 6: - IgniteUuid sesId0 = commState.getGridUuid(); + IgniteUuid sesId0 = commState.getGridUuid(null); if (sesId0 == GRID_UUID_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobSiblingsRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobSiblingsRequest.java index 663a122e85e52..a852d23263bd6 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobSiblingsRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobSiblingsRequest.java @@ -100,7 +100,7 @@ public byte[] topicBytes() { commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -108,13 +108,13 @@ public byte[] topicBytes() { switch (commState.idx) { case 0: - if (!commState.putGridUuid(sesId)) + if (!commState.putGridUuid(null, sesId)) return false; commState.idx++; case 1: - if (!commState.putByteArray(topicBytes)) + if (!commState.putByteArray(null, topicBytes)) return false; commState.idx++; @@ -131,7 +131,7 @@ public byte[] topicBytes() { switch (commState.idx) { case 0: - IgniteUuid sesId0 = commState.getGridUuid(); + IgniteUuid sesId0 = commState.getGridUuid(null); if (sesId0 == GRID_UUID_NOT_READ) return false; @@ -141,7 +141,7 @@ public byte[] topicBytes() { commState.idx++; case 1: - byte[] topicBytes0 = commState.getByteArray(); + byte[] topicBytes0 = commState.getByteArray(null); if (topicBytes0 == BYTE_ARR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobSiblingsResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobSiblingsResponse.java index b72b03d22258e..55e17f53bf229 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobSiblingsResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobSiblingsResponse.java @@ -92,7 +92,7 @@ public void unmarshalSiblings(IgniteMarshaller marsh) throws IgniteCheckedExcept commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -100,7 +100,7 @@ public void unmarshalSiblings(IgniteMarshaller marsh) throws IgniteCheckedExcept switch (commState.idx) { case 0: - if (!commState.putByteArray(siblingsBytes)) + if (!commState.putByteArray(null, siblingsBytes)) return false; commState.idx++; @@ -117,7 +117,7 @@ public void unmarshalSiblings(IgniteMarshaller marsh) throws IgniteCheckedExcept switch (commState.idx) { case 0: - byte[] siblingsBytes0 = commState.getByteArray(); + byte[] siblingsBytes0 = commState.getByteArray(null); if (siblingsBytes0 == BYTE_ARR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/GridTaskCancelRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/GridTaskCancelRequest.java index 226ebc121d8bc..15ae1ad9ab59c 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/GridTaskCancelRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/GridTaskCancelRequest.java @@ -75,7 +75,7 @@ public IgniteUuid sessionId() { commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -83,7 +83,7 @@ public IgniteUuid sessionId() { switch (commState.idx) { case 0: - if (!commState.putGridUuid(sesId)) + if (!commState.putGridUuid(null, sesId)) return false; commState.idx++; @@ -100,7 +100,7 @@ public IgniteUuid sessionId() { switch (commState.idx) { case 0: - IgniteUuid sesId0 = commState.getGridUuid(); + IgniteUuid sesId0 = commState.getGridUuid(null); if (sesId0 == GRID_UUID_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/GridTaskSessionRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/GridTaskSessionRequest.java index f9f79e0a9fe58..86457da92a2ed 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/GridTaskSessionRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/GridTaskSessionRequest.java @@ -115,7 +115,7 @@ public IgniteUuid getJobId() { commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -123,19 +123,19 @@ public IgniteUuid getJobId() { switch (commState.idx) { case 0: - if (!commState.putByteArray(attrsBytes)) + if (!commState.putByteArray(null, attrsBytes)) return false; commState.idx++; case 1: - if (!commState.putGridUuid(jobId)) + if (!commState.putGridUuid(null, jobId)) return false; commState.idx++; case 2: - if (!commState.putGridUuid(sesId)) + if (!commState.putGridUuid(null, sesId)) return false; commState.idx++; @@ -152,7 +152,7 @@ public IgniteUuid getJobId() { switch (commState.idx) { case 0: - byte[] attrsBytes0 = commState.getByteArray(); + byte[] attrsBytes0 = commState.getByteArray(null); if (attrsBytes0 == BYTE_ARR_NOT_READ) return false; @@ -162,7 +162,7 @@ public IgniteUuid getJobId() { commState.idx++; case 1: - IgniteUuid jobId0 = commState.getGridUuid(); + IgniteUuid jobId0 = commState.getGridUuid(null); if (jobId0 == GRID_UUID_NOT_READ) return false; @@ -172,7 +172,7 @@ public IgniteUuid getJobId() { commState.idx++; case 2: - IgniteUuid sesId0 = commState.getGridUuid(); + IgniteUuid sesId0 = commState.getGridUuid(null); if (sesId0 == GRID_UUID_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/checkpoint/GridCheckpointRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/checkpoint/GridCheckpointRequest.java index d054a73ea35d2..c7ca93c3e4385 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/checkpoint/GridCheckpointRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/checkpoint/GridCheckpointRequest.java @@ -100,7 +100,7 @@ public String getCheckpointSpi() { commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -108,19 +108,19 @@ public String getCheckpointSpi() { switch (commState.idx) { case 0: - if (!commState.putString(cpSpi)) + if (!commState.putString(null, cpSpi)) return false; commState.idx++; case 1: - if (!commState.putString(key)) + if (!commState.putString(null, key)) return false; commState.idx++; case 2: - if (!commState.putGridUuid(sesId)) + if (!commState.putGridUuid(null, sesId)) return false; commState.idx++; @@ -137,7 +137,7 @@ public String getCheckpointSpi() { switch (commState.idx) { case 0: - String cpSpi0 = commState.getString(); + String cpSpi0 = commState.getString(null); if (cpSpi0 == STR_NOT_READ) return false; @@ -147,7 +147,7 @@ public String getCheckpointSpi() { commState.idx++; case 1: - String key0 = commState.getString(); + String key0 = commState.getString(null); if (key0 == STR_NOT_READ) return false; @@ -157,7 +157,7 @@ public String getCheckpointSpi() { commState.idx++; case 2: - IgniteUuid sesId0 = commState.getGridUuid(); + IgniteUuid sesId0 = commState.getGridUuid(null); if (sesId0 == GRID_UUID_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/communication/GridIoMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/communication/GridIoMessage.java index dc5c91c309372..d9c11a565d526 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/communication/GridIoMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/communication/GridIoMessage.java @@ -214,7 +214,7 @@ boolean isOrdered() { commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -222,43 +222,43 @@ boolean isOrdered() { switch (commState.idx) { case 0: - if (!commState.putMessage(msg)) + if (!commState.putMessage(null, msg)) return false; commState.idx++; case 1: - if (!commState.putLong(msgId)) + if (!commState.putLong(null, msgId)) return false; commState.idx++; case 2: - if (!commState.putEnum(plc)) + if (!commState.putEnum(null, plc)) return false; commState.idx++; case 3: - if (!commState.putBoolean(skipOnTimeout)) + if (!commState.putBoolean(null, skipOnTimeout)) return false; commState.idx++; case 4: - if (!commState.putLong(timeout)) + if (!commState.putLong(null, timeout)) return false; commState.idx++; case 5: - if (!commState.putByteArray(topicBytes)) + if (!commState.putByteArray(null, topicBytes)) return false; commState.idx++; case 6: - if (!commState.putInt(topicOrd)) + if (!commState.putInt(null, topicOrd)) return false; commState.idx++; @@ -275,7 +275,7 @@ boolean isOrdered() { switch (commState.idx) { case 0: - Object msg0 = commState.getMessage(); + Object msg0 = commState.getMessage(null); if (msg0 == MSG_NOT_READ) return false; @@ -288,7 +288,7 @@ boolean isOrdered() { if (buf.remaining() < 8) return false; - msgId = commState.getLong(); + msgId = commState.getLong(null); commState.idx++; @@ -296,7 +296,7 @@ boolean isOrdered() { if (buf.remaining() < 1) return false; - byte plc0 = commState.getByte(); + byte plc0 = commState.getByte(null); plc = GridIoPolicy.fromOrdinal(plc0); @@ -306,7 +306,7 @@ boolean isOrdered() { if (buf.remaining() < 1) return false; - skipOnTimeout = commState.getBoolean(); + skipOnTimeout = commState.getBoolean(null); commState.idx++; @@ -314,12 +314,12 @@ boolean isOrdered() { if (buf.remaining() < 8) return false; - timeout = commState.getLong(); + timeout = commState.getLong(null); commState.idx++; case 5: - byte[] topicBytes0 = commState.getByteArray(); + byte[] topicBytes0 = commState.getByteArray(null); if (topicBytes0 == BYTE_ARR_NOT_READ) return false; @@ -332,7 +332,7 @@ boolean isOrdered() { if (buf.remaining() < 4) return false; - topicOrd = commState.getInt(); + topicOrd = commState.getInt(null); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/communication/GridIoUserMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/communication/GridIoUserMessage.java index 4b497987b4ad0..28590167f711d 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/communication/GridIoUserMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/communication/GridIoUserMessage.java @@ -226,7 +226,7 @@ public void deployment(GridDeployment dep) { commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -234,25 +234,25 @@ public void deployment(GridDeployment dep) { switch (commState.idx) { case 0: - if (!commState.putByteArray(bodyBytes)) + if (!commState.putByteArray(null, bodyBytes)) return false; commState.idx++; case 1: - if (!commState.putGridUuid(clsLdrId)) + if (!commState.putGridUuid(null, clsLdrId)) return false; commState.idx++; case 2: - if (!commState.putString(depClsName)) + if (!commState.putString(null, depClsName)) return false; commState.idx++; case 3: - if (!commState.putEnum(depMode)) + if (!commState.putEnum(null, depMode)) return false; commState.idx++; @@ -260,7 +260,7 @@ public void deployment(GridDeployment dep) { case 4: if (ldrParties != null) { if (commState.it == null) { - if (!commState.putInt(ldrParties.size())) + if (!commState.putInt(null, ldrParties.size())) return false; commState.it = ldrParties.entrySet().iterator(); @@ -273,13 +273,13 @@ public void deployment(GridDeployment dep) { Map.Entry e = (Map.Entry)commState.cur; if (!commState.keyDone) { - if (!commState.putUuid(e.getKey())) + if (!commState.putUuid(null, e.getKey())) return false; commState.keyDone = true; } - if (!commState.putGridUuid(e.getValue())) + if (!commState.putGridUuid(null, e.getValue())) return false; commState.keyDone = false; @@ -289,20 +289,20 @@ public void deployment(GridDeployment dep) { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 5: - if (!commState.putByteArray(topicBytes)) + if (!commState.putByteArray(null, topicBytes)) return false; commState.idx++; case 6: - if (!commState.putString(userVer)) + if (!commState.putString(null, userVer)) return false; commState.idx++; @@ -319,7 +319,7 @@ public void deployment(GridDeployment dep) { switch (commState.idx) { case 0: - byte[] bodyBytes0 = commState.getByteArray(); + byte[] bodyBytes0 = commState.getByteArray(null); if (bodyBytes0 == BYTE_ARR_NOT_READ) return false; @@ -329,7 +329,7 @@ public void deployment(GridDeployment dep) { commState.idx++; case 1: - IgniteUuid clsLdrId0 = commState.getGridUuid(); + IgniteUuid clsLdrId0 = commState.getGridUuid(null); if (clsLdrId0 == GRID_UUID_NOT_READ) return false; @@ -339,7 +339,7 @@ public void deployment(GridDeployment dep) { commState.idx++; case 2: - String depClsName0 = commState.getString(); + String depClsName0 = commState.getString(null); if (depClsName0 == STR_NOT_READ) return false; @@ -352,7 +352,7 @@ public void deployment(GridDeployment dep) { if (buf.remaining() < 1) return false; - byte depMode0 = commState.getByte(); + byte depMode0 = commState.getByte(null); depMode = IgniteDeploymentMode.fromOrdinal(depMode0); @@ -363,7 +363,7 @@ public void deployment(GridDeployment dep) { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -372,7 +372,7 @@ public void deployment(GridDeployment dep) { for (int i = commState.readItems; i < commState.readSize; i++) { if (!commState.keyDone) { - UUID _val = commState.getUuid(); + UUID _val = commState.getUuid(null); if (_val == UUID_NOT_READ) return false; @@ -381,7 +381,7 @@ public void deployment(GridDeployment dep) { commState.keyDone = true; } - IgniteUuid _val = commState.getGridUuid(); + IgniteUuid _val = commState.getGridUuid(null); if (_val == GRID_UUID_NOT_READ) return false; @@ -401,7 +401,7 @@ public void deployment(GridDeployment dep) { commState.idx++; case 5: - byte[] topicBytes0 = commState.getByteArray(); + byte[] topicBytes0 = commState.getByteArray(null); if (topicBytes0 == BYTE_ARR_NOT_READ) return false; @@ -411,7 +411,7 @@ public void deployment(GridDeployment dep) { commState.idx++; case 6: - String userVer0 = commState.getString(); + String userVer0 = commState.getString(null); if (userVer0 == STR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/deployment/GridDeploymentInfoBean.java b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/deployment/GridDeploymentInfoBean.java index e978940a11c39..c294a8c94d887 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/deployment/GridDeploymentInfoBean.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/deployment/GridDeploymentInfoBean.java @@ -156,7 +156,7 @@ public void localDeploymentOwner(boolean locDepOwner) { commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -164,19 +164,19 @@ public void localDeploymentOwner(boolean locDepOwner) { switch (commState.idx) { case 0: - if (!commState.putGridUuid(clsLdrId)) + if (!commState.putGridUuid(null, clsLdrId)) return false; commState.idx++; case 1: - if (!commState.putEnum(depMode)) + if (!commState.putEnum(null, depMode)) return false; commState.idx++; case 2: - if (!commState.putBoolean(locDepOwner)) + if (!commState.putBoolean(null, locDepOwner)) return false; commState.idx++; @@ -184,7 +184,7 @@ public void localDeploymentOwner(boolean locDepOwner) { case 3: if (participants != null) { if (commState.it == null) { - if (!commState.putInt(participants.size())) + if (!commState.putInt(null, participants.size())) return false; commState.it = participants.entrySet().iterator(); @@ -197,13 +197,13 @@ public void localDeploymentOwner(boolean locDepOwner) { Map.Entry e = (Map.Entry)commState.cur; if (!commState.keyDone) { - if (!commState.putUuid(e.getKey())) + if (!commState.putUuid(null, e.getKey())) return false; commState.keyDone = true; } - if (!commState.putGridUuid(e.getValue())) + if (!commState.putGridUuid(null, e.getValue())) return false; commState.keyDone = false; @@ -213,14 +213,14 @@ public void localDeploymentOwner(boolean locDepOwner) { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 4: - if (!commState.putString(userVer)) + if (!commState.putString(null, userVer)) return false; commState.idx++; @@ -237,7 +237,7 @@ public void localDeploymentOwner(boolean locDepOwner) { switch (commState.idx) { case 0: - IgniteUuid clsLdrId0 = commState.getGridUuid(); + IgniteUuid clsLdrId0 = commState.getGridUuid(null); if (clsLdrId0 == GRID_UUID_NOT_READ) return false; @@ -250,7 +250,7 @@ public void localDeploymentOwner(boolean locDepOwner) { if (buf.remaining() < 1) return false; - byte depMode0 = commState.getByte(); + byte depMode0 = commState.getByte(null); depMode = IgniteDeploymentMode.fromOrdinal(depMode0); @@ -260,7 +260,7 @@ public void localDeploymentOwner(boolean locDepOwner) { if (buf.remaining() < 1) return false; - locDepOwner = commState.getBoolean(); + locDepOwner = commState.getBoolean(null); commState.idx++; @@ -269,7 +269,7 @@ public void localDeploymentOwner(boolean locDepOwner) { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -278,7 +278,7 @@ public void localDeploymentOwner(boolean locDepOwner) { for (int i = commState.readItems; i < commState.readSize; i++) { if (!commState.keyDone) { - UUID _val = commState.getUuid(); + UUID _val = commState.getUuid(null); if (_val == UUID_NOT_READ) return false; @@ -287,7 +287,7 @@ public void localDeploymentOwner(boolean locDepOwner) { commState.keyDone = true; } - IgniteUuid _val = commState.getGridUuid(); + IgniteUuid _val = commState.getGridUuid(null); if (_val == GRID_UUID_NOT_READ) return false; @@ -307,7 +307,7 @@ public void localDeploymentOwner(boolean locDepOwner) { commState.idx++; case 4: - String userVer0 = commState.getString(); + String userVer0 = commState.getString(null); if (userVer0 == STR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/deployment/GridDeploymentRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/deployment/GridDeploymentRequest.java index 6565ea0389074..ffcd80570a559 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/deployment/GridDeploymentRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/deployment/GridDeploymentRequest.java @@ -175,7 +175,7 @@ public void nodeIds(Collection nodeIds) { commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -183,13 +183,13 @@ public void nodeIds(Collection nodeIds) { switch (commState.idx) { case 0: - if (!commState.putBoolean(isUndeploy)) + if (!commState.putBoolean(null, isUndeploy)) return false; commState.idx++; case 1: - if (!commState.putGridUuid(ldrId)) + if (!commState.putGridUuid(null, ldrId)) return false; commState.idx++; @@ -197,7 +197,7 @@ public void nodeIds(Collection nodeIds) { case 2: if (nodeIds != null) { if (commState.it == null) { - if (!commState.putInt(nodeIds.size())) + if (!commState.putInt(null, nodeIds.size())) return false; commState.it = nodeIds.iterator(); @@ -207,7 +207,7 @@ public void nodeIds(Collection nodeIds) { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putUuid((UUID)commState.cur)) + if (!commState.putUuid(null, (UUID)commState.cur)) return false; commState.cur = NULL; @@ -215,20 +215,20 @@ public void nodeIds(Collection nodeIds) { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 3: - if (!commState.putByteArray(resTopicBytes)) + if (!commState.putByteArray(null, resTopicBytes)) return false; commState.idx++; case 4: - if (!commState.putString(rsrcName)) + if (!commState.putString(null, rsrcName)) return false; commState.idx++; @@ -248,12 +248,12 @@ public void nodeIds(Collection nodeIds) { if (buf.remaining() < 1) return false; - isUndeploy = commState.getBoolean(); + isUndeploy = commState.getBoolean(null); commState.idx++; case 1: - IgniteUuid ldrId0 = commState.getGridUuid(); + IgniteUuid ldrId0 = commState.getGridUuid(null); if (ldrId0 == GRID_UUID_NOT_READ) return false; @@ -267,7 +267,7 @@ public void nodeIds(Collection nodeIds) { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -275,7 +275,7 @@ public void nodeIds(Collection nodeIds) { nodeIds = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - UUID _val = commState.getUuid(); + UUID _val = commState.getUuid(null); if (_val == UUID_NOT_READ) return false; @@ -292,7 +292,7 @@ public void nodeIds(Collection nodeIds) { commState.idx++; case 3: - byte[] resTopicBytes0 = commState.getByteArray(); + byte[] resTopicBytes0 = commState.getByteArray(null); if (resTopicBytes0 == BYTE_ARR_NOT_READ) return false; @@ -302,7 +302,7 @@ public void nodeIds(Collection nodeIds) { commState.idx++; case 4: - String rsrcName0 = commState.getString(); + String rsrcName0 = commState.getString(null); if (rsrcName0 == STR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/deployment/GridDeploymentResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/deployment/GridDeploymentResponse.java index ea30da80f44e9..3d8e7acd386b2 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/deployment/GridDeploymentResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/deployment/GridDeploymentResponse.java @@ -123,7 +123,7 @@ void errorMessage(String errMsg) { commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -131,19 +131,19 @@ void errorMessage(String errMsg) { switch (commState.idx) { case 0: - if (!commState.putByteArrayList(byteSrc)) + if (!commState.putByteArrayList(null, byteSrc)) return false; commState.idx++; case 1: - if (!commState.putString(errMsg)) + if (!commState.putString(null, errMsg)) return false; commState.idx++; case 2: - if (!commState.putBoolean(success)) + if (!commState.putBoolean(null, success)) return false; commState.idx++; @@ -160,7 +160,7 @@ void errorMessage(String errMsg) { switch (commState.idx) { case 0: - GridByteArrayList byteSrc0 = commState.getByteArrayList(); + GridByteArrayList byteSrc0 = commState.getByteArrayList(null); if (byteSrc0 == BYTE_ARR_LIST_NOT_READ) return false; @@ -170,7 +170,7 @@ void errorMessage(String errMsg) { commState.idx++; case 1: - String errMsg0 = commState.getString(); + String errMsg0 = commState.getString(null); if (errMsg0 == STR_NOT_READ) return false; @@ -183,7 +183,7 @@ void errorMessage(String errMsg) { if (buf.remaining() < 1) return false; - success = commState.getBoolean(); + success = commState.getBoolean(null); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/eventstorage/GridEventStorageMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/eventstorage/GridEventStorageMessage.java index ae0436ae9df95..f80707a142d98 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/eventstorage/GridEventStorageMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/eventstorage/GridEventStorageMessage.java @@ -286,7 +286,7 @@ void exceptionBytes(byte[] exBytes) { commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -294,37 +294,37 @@ void exceptionBytes(byte[] exBytes) { switch (commState.idx) { case 0: - if (!commState.putGridUuid(clsLdrId)) + if (!commState.putGridUuid(null, clsLdrId)) return false; commState.idx++; case 1: - if (!commState.putEnum(depMode)) + if (!commState.putEnum(null, depMode)) return false; commState.idx++; case 2: - if (!commState.putByteArray(evtsBytes)) + if (!commState.putByteArray(null, evtsBytes)) return false; commState.idx++; case 3: - if (!commState.putByteArray(exBytes)) + if (!commState.putByteArray(null, exBytes)) return false; commState.idx++; case 4: - if (!commState.putByteArray(filter)) + if (!commState.putByteArray(null, filter)) return false; commState.idx++; case 5: - if (!commState.putString(filterClsName)) + if (!commState.putString(null, filterClsName)) return false; commState.idx++; @@ -332,7 +332,7 @@ void exceptionBytes(byte[] exBytes) { case 6: if (ldrParties != null) { if (commState.it == null) { - if (!commState.putInt(ldrParties.size())) + if (!commState.putInt(null, ldrParties.size())) return false; commState.it = ldrParties.entrySet().iterator(); @@ -345,13 +345,13 @@ void exceptionBytes(byte[] exBytes) { Map.Entry e = (Map.Entry)commState.cur; if (!commState.keyDone) { - if (!commState.putUuid(e.getKey())) + if (!commState.putUuid(null, e.getKey())) return false; commState.keyDone = true; } - if (!commState.putGridUuid(e.getValue())) + if (!commState.putGridUuid(null, e.getValue())) return false; commState.keyDone = false; @@ -361,20 +361,20 @@ void exceptionBytes(byte[] exBytes) { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 7: - if (!commState.putByteArray(resTopicBytes)) + if (!commState.putByteArray(null, resTopicBytes)) return false; commState.idx++; case 8: - if (!commState.putString(userVer)) + if (!commState.putString(null, userVer)) return false; commState.idx++; @@ -391,7 +391,7 @@ void exceptionBytes(byte[] exBytes) { switch (commState.idx) { case 0: - IgniteUuid clsLdrId0 = commState.getGridUuid(); + IgniteUuid clsLdrId0 = commState.getGridUuid(null); if (clsLdrId0 == GRID_UUID_NOT_READ) return false; @@ -404,14 +404,14 @@ void exceptionBytes(byte[] exBytes) { if (buf.remaining() < 1) return false; - byte depMode0 = commState.getByte(); + byte depMode0 = commState.getByte(null); depMode = IgniteDeploymentMode.fromOrdinal(depMode0); commState.idx++; case 2: - byte[] evtsBytes0 = commState.getByteArray(); + byte[] evtsBytes0 = commState.getByteArray(null); if (evtsBytes0 == BYTE_ARR_NOT_READ) return false; @@ -421,7 +421,7 @@ void exceptionBytes(byte[] exBytes) { commState.idx++; case 3: - byte[] exBytes0 = commState.getByteArray(); + byte[] exBytes0 = commState.getByteArray(null); if (exBytes0 == BYTE_ARR_NOT_READ) return false; @@ -431,7 +431,7 @@ void exceptionBytes(byte[] exBytes) { commState.idx++; case 4: - byte[] filter0 = commState.getByteArray(); + byte[] filter0 = commState.getByteArray(null); if (filter0 == BYTE_ARR_NOT_READ) return false; @@ -441,7 +441,7 @@ void exceptionBytes(byte[] exBytes) { commState.idx++; case 5: - String filterClsName0 = commState.getString(); + String filterClsName0 = commState.getString(null); if (filterClsName0 == STR_NOT_READ) return false; @@ -455,7 +455,7 @@ void exceptionBytes(byte[] exBytes) { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -464,7 +464,7 @@ void exceptionBytes(byte[] exBytes) { for (int i = commState.readItems; i < commState.readSize; i++) { if (!commState.keyDone) { - UUID _val = commState.getUuid(); + UUID _val = commState.getUuid(null); if (_val == UUID_NOT_READ) return false; @@ -473,7 +473,7 @@ void exceptionBytes(byte[] exBytes) { commState.keyDone = true; } - IgniteUuid _val = commState.getGridUuid(); + IgniteUuid _val = commState.getGridUuid(null); if (_val == GRID_UUID_NOT_READ) return false; @@ -493,7 +493,7 @@ void exceptionBytes(byte[] exBytes) { commState.idx++; case 7: - byte[] resTopicBytes0 = commState.getByteArray(); + byte[] resTopicBytes0 = commState.getByteArray(null); if (resTopicBytes0 == BYTE_ARR_NOT_READ) return false; @@ -503,7 +503,7 @@ void exceptionBytes(byte[] exBytes) { commState.idx++; case 8: - String userVer0 = commState.getString(); + String userVer0 = commState.getString(null); if (userVer0 == STR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEvictionRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEvictionRequest.java index fd36e156d0f2f..8a1f0b9d9d642 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEvictionRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEvictionRequest.java @@ -161,7 +161,7 @@ void addKey(K key, GridCacheVersion ver, boolean near) { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -169,19 +169,19 @@ void addKey(K key, GridCacheVersion ver, boolean near) { switch (commState.idx) { case 3: - if (!commState.putByteArray(entriesBytes)) + if (!commState.putByteArray(null, entriesBytes)) return false; commState.idx++; case 4: - if (!commState.putLong(futId)) + if (!commState.putLong(null, futId)) return false; commState.idx++; case 5: - if (!commState.putLong(topVer)) + if (!commState.putLong(null, topVer)) return false; commState.idx++; @@ -201,7 +201,7 @@ void addKey(K key, GridCacheVersion ver, boolean near) { switch (commState.idx) { case 3: - byte[] entriesBytes0 = commState.getByteArray(); + byte[] entriesBytes0 = commState.getByteArray(null); if (entriesBytes0 == BYTE_ARR_NOT_READ) return false; @@ -214,7 +214,7 @@ void addKey(K key, GridCacheVersion ver, boolean near) { if (buf.remaining() < 8) return false; - futId = commState.getLong(); + futId = commState.getLong(null); commState.idx++; @@ -222,7 +222,7 @@ void addKey(K key, GridCacheVersion ver, boolean near) { if (buf.remaining() < 8) return false; - topVer = commState.getLong(); + topVer = commState.getLong(null); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEvictionResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEvictionResponse.java index b241043b6067c..203b99d8396fc 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEvictionResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEvictionResponse.java @@ -151,7 +151,7 @@ boolean error() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -159,13 +159,13 @@ boolean error() { switch (commState.idx) { case 3: - if (!commState.putBoolean(err)) + if (!commState.putBoolean(null, err)) return false; commState.idx++; case 4: - if (!commState.putLong(futId)) + if (!commState.putLong(null, futId)) return false; commState.idx++; @@ -173,7 +173,7 @@ boolean error() { case 5: if (rejectedKeyBytes != null) { if (commState.it == null) { - if (!commState.putInt(rejectedKeyBytes.size())) + if (!commState.putInt(null, rejectedKeyBytes.size())) return false; commState.it = rejectedKeyBytes.iterator(); @@ -183,7 +183,7 @@ boolean error() { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putByteArray((byte[])commState.cur)) + if (!commState.putByteArray(null, (byte[])commState.cur)) return false; commState.cur = NULL; @@ -191,7 +191,7 @@ boolean error() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } @@ -215,7 +215,7 @@ boolean error() { if (buf.remaining() < 1) return false; - err = commState.getBoolean(); + err = commState.getBoolean(null); commState.idx++; @@ -223,7 +223,7 @@ boolean error() { if (buf.remaining() < 8) return false; - futId = commState.getLong(); + futId = commState.getLong(null); commState.idx++; @@ -232,7 +232,7 @@ boolean error() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -240,7 +240,7 @@ boolean error() { rejectedKeyBytes = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(); + byte[] _val = commState.getByteArray(null); if (_val == BYTE_ARR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMessage.java index 71eac41a6fd63..ea7987de5d858 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMessage.java @@ -586,7 +586,7 @@ protected final void unmarshalTx(Iterable> txEntries, boo commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -594,19 +594,19 @@ protected final void unmarshalTx(Iterable> txEntries, boo switch (commState.idx) { case 0: - if (!commState.putInt(cacheId)) + if (!commState.putInt(null, cacheId)) return false; commState.idx++; case 1: - if (!commState.putMessage(depInfo)) + if (!commState.putMessage(null, depInfo)) return false; commState.idx++; case 2: - if (!commState.putLong(msgId)) + if (!commState.putLong(null, msgId)) return false; commState.idx++; @@ -626,12 +626,12 @@ protected final void unmarshalTx(Iterable> txEntries, boo if (buf.remaining() < 4) return false; - cacheId = commState.getInt(); + cacheId = commState.getInt(null); commState.idx++; case 1: - Object depInfo0 = commState.getMessage(); + Object depInfo0 = commState.getMessage(null); if (depInfo0 == MSG_NOT_READ) return false; @@ -644,7 +644,7 @@ protected final void unmarshalTx(Iterable> txEntries, boo if (buf.remaining() < 8) return false; - msgId = commState.getLong(); + msgId = commState.getLong(null); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxRequest.java index 693f1ffaaa7cd..88c087fd6a33f 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxRequest.java @@ -118,7 +118,7 @@ public int transactions() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -126,25 +126,25 @@ public int transactions() { switch (commState.idx) { case 8: - if (!commState.putGridUuid(futId)) + if (!commState.putGridUuid(null, futId)) return false; commState.idx++; case 9: - if (!commState.putGridUuid(miniId)) + if (!commState.putGridUuid(null, miniId)) return false; commState.idx++; case 10: - if (!commState.putCacheVersion(nearXidVer)) + if (!commState.putCacheVersion(null, nearXidVer)) return false; commState.idx++; case 11: - if (!commState.putInt(txNum)) + if (!commState.putInt(null, txNum)) return false; commState.idx++; @@ -164,7 +164,7 @@ public int transactions() { switch (commState.idx) { case 8: - IgniteUuid futId0 = commState.getGridUuid(); + IgniteUuid futId0 = commState.getGridUuid(null); if (futId0 == GRID_UUID_NOT_READ) return false; @@ -174,7 +174,7 @@ public int transactions() { commState.idx++; case 9: - IgniteUuid miniId0 = commState.getGridUuid(); + IgniteUuid miniId0 = commState.getGridUuid(null); if (miniId0 == GRID_UUID_NOT_READ) return false; @@ -184,7 +184,7 @@ public int transactions() { commState.idx++; case 10: - GridCacheVersion nearXidVer0 = commState.getCacheVersion(); + GridCacheVersion nearXidVer0 = commState.getCacheVersion(null); if (nearXidVer0 == CACHE_VER_NOT_READ) return false; @@ -197,7 +197,7 @@ public int transactions() { if (buf.remaining() < 4) return false; - txNum = commState.getInt(); + txNum = commState.getInt(null); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxResponse.java index 21c2256ddf635..1baa17a275381 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxResponse.java @@ -106,7 +106,7 @@ public boolean success() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -114,19 +114,19 @@ public boolean success() { switch (commState.idx) { case 8: - if (!commState.putGridUuid(futId)) + if (!commState.putGridUuid(null, futId)) return false; commState.idx++; case 9: - if (!commState.putGridUuid(miniId)) + if (!commState.putGridUuid(null, miniId)) return false; commState.idx++; case 10: - if (!commState.putBoolean(success)) + if (!commState.putBoolean(null, success)) return false; commState.idx++; @@ -146,7 +146,7 @@ public boolean success() { switch (commState.idx) { case 8: - IgniteUuid futId0 = commState.getGridUuid(); + IgniteUuid futId0 = commState.getGridUuid(null); if (futId0 == GRID_UUID_NOT_READ) return false; @@ -156,7 +156,7 @@ public boolean success() { commState.idx++; case 9: - IgniteUuid miniId0 = commState.getGridUuid(); + IgniteUuid miniId0 = commState.getGridUuid(null); if (miniId0 == GRID_UUID_NOT_READ) return false; @@ -169,7 +169,7 @@ public boolean success() { if (buf.remaining() < 1) return false; - success = commState.getBoolean(); + success = commState.getBoolean(null); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxRequest.java index b7f8c2a59a102..89b1a4b92c08f 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxRequest.java @@ -153,7 +153,7 @@ public boolean nearOnlyCheck() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -161,37 +161,37 @@ public boolean nearOnlyCheck() { switch (commState.idx) { case 8: - if (!commState.putGridUuid(futId)) + if (!commState.putGridUuid(null, futId)) return false; commState.idx++; case 9: - if (!commState.putGridUuid(miniId)) + if (!commState.putGridUuid(null, miniId)) return false; commState.idx++; case 10: - if (!commState.putCacheVersion(nearXidVer)) + if (!commState.putCacheVersion(null, nearXidVer)) return false; commState.idx++; case 11: - if (!commState.putUuid(originatingNodeId)) + if (!commState.putUuid(null, originatingNodeId)) return false; commState.idx++; case 12: - if (!commState.putLong(originatingThreadId)) + if (!commState.putLong(null, originatingThreadId)) return false; commState.idx++; case 13: - if (!commState.putBoolean(nearOnlyCheck)) + if (!commState.putBoolean(null, nearOnlyCheck)) return false; commState.idx++; @@ -211,7 +211,7 @@ public boolean nearOnlyCheck() { switch (commState.idx) { case 8: - IgniteUuid futId0 = commState.getGridUuid(); + IgniteUuid futId0 = commState.getGridUuid(null); if (futId0 == GRID_UUID_NOT_READ) return false; @@ -221,7 +221,7 @@ public boolean nearOnlyCheck() { commState.idx++; case 9: - IgniteUuid miniId0 = commState.getGridUuid(); + IgniteUuid miniId0 = commState.getGridUuid(null); if (miniId0 == GRID_UUID_NOT_READ) return false; @@ -231,7 +231,7 @@ public boolean nearOnlyCheck() { commState.idx++; case 10: - GridCacheVersion nearXidVer0 = commState.getCacheVersion(); + GridCacheVersion nearXidVer0 = commState.getCacheVersion(null); if (nearXidVer0 == CACHE_VER_NOT_READ) return false; @@ -241,7 +241,7 @@ public boolean nearOnlyCheck() { commState.idx++; case 11: - UUID originatingNodeId0 = commState.getUuid(); + UUID originatingNodeId0 = commState.getUuid(null); if (originatingNodeId0 == UUID_NOT_READ) return false; @@ -254,7 +254,7 @@ public boolean nearOnlyCheck() { if (buf.remaining() < 8) return false; - originatingThreadId = commState.getLong(); + originatingThreadId = commState.getLong(null); commState.idx++; @@ -262,7 +262,7 @@ public boolean nearOnlyCheck() { if (buf.remaining() < 1) return false; - nearOnlyCheck = commState.getBoolean(); + nearOnlyCheck = commState.getBoolean(null); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxResponse.java index 529edcbb192f1..88f354bb4afa7 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxResponse.java @@ -137,7 +137,7 @@ public GridCacheCommittedTxInfo committedTxInfo() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -145,19 +145,19 @@ public GridCacheCommittedTxInfo committedTxInfo() { switch (commState.idx) { case 8: - if (!commState.putByteArray(committedTxInfoBytes)) + if (!commState.putByteArray(null, committedTxInfoBytes)) return false; commState.idx++; case 9: - if (!commState.putGridUuid(futId)) + if (!commState.putGridUuid(null, futId)) return false; commState.idx++; case 10: - if (!commState.putGridUuid(miniId)) + if (!commState.putGridUuid(null, miniId)) return false; commState.idx++; @@ -177,7 +177,7 @@ public GridCacheCommittedTxInfo committedTxInfo() { switch (commState.idx) { case 8: - byte[] committedTxInfoBytes0 = commState.getByteArray(); + byte[] committedTxInfoBytes0 = commState.getByteArray(null); if (committedTxInfoBytes0 == BYTE_ARR_NOT_READ) return false; @@ -187,7 +187,7 @@ public GridCacheCommittedTxInfo committedTxInfo() { commState.idx++; case 9: - IgniteUuid futId0 = commState.getGridUuid(); + IgniteUuid futId0 = commState.getGridUuid(null); if (futId0 == GRID_UUID_NOT_READ) return false; @@ -197,7 +197,7 @@ public GridCacheCommittedTxInfo committedTxInfo() { commState.idx++; case 10: - IgniteUuid miniId0 = commState.getGridUuid(); + IgniteUuid miniId0 = commState.getGridUuid(null); if (miniId0 == GRID_UUID_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedBaseMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedBaseMessage.java index fd96d329d14cd..3a0a86ff17b66 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedBaseMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedBaseMessage.java @@ -255,7 +255,7 @@ public int keysCount() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -263,13 +263,13 @@ public int keysCount() { switch (commState.idx) { case 3: - if (!commState.putByteArray(candsByIdxBytes)) + if (!commState.putByteArray(null, candsByIdxBytes)) return false; commState.idx++; case 4: - if (!commState.putByteArray(candsByKeyBytes)) + if (!commState.putByteArray(null, candsByKeyBytes)) return false; commState.idx++; @@ -277,7 +277,7 @@ public int keysCount() { case 5: if (committedVers != null) { if (commState.it == null) { - if (!commState.putInt(committedVers.size())) + if (!commState.putInt(null, committedVers.size())) return false; commState.it = committedVers.iterator(); @@ -287,7 +287,7 @@ public int keysCount() { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putCacheVersion((GridCacheVersion)commState.cur)) + if (!commState.putCacheVersion(null, (GridCacheVersion)commState.cur)) return false; commState.cur = NULL; @@ -295,7 +295,7 @@ public int keysCount() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } @@ -304,7 +304,7 @@ public int keysCount() { case 6: if (rolledbackVers != null) { if (commState.it == null) { - if (!commState.putInt(rolledbackVers.size())) + if (!commState.putInt(null, rolledbackVers.size())) return false; commState.it = rolledbackVers.iterator(); @@ -314,7 +314,7 @@ public int keysCount() { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putCacheVersion((GridCacheVersion)commState.cur)) + if (!commState.putCacheVersion(null, (GridCacheVersion)commState.cur)) return false; commState.cur = NULL; @@ -322,14 +322,14 @@ public int keysCount() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 7: - if (!commState.putCacheVersion(ver)) + if (!commState.putCacheVersion(null, ver)) return false; commState.idx++; @@ -349,7 +349,7 @@ public int keysCount() { switch (commState.idx) { case 3: - byte[] candsByIdxBytes0 = commState.getByteArray(); + byte[] candsByIdxBytes0 = commState.getByteArray(null); if (candsByIdxBytes0 == BYTE_ARR_NOT_READ) return false; @@ -359,7 +359,7 @@ public int keysCount() { commState.idx++; case 4: - byte[] candsByKeyBytes0 = commState.getByteArray(); + byte[] candsByKeyBytes0 = commState.getByteArray(null); if (candsByKeyBytes0 == BYTE_ARR_NOT_READ) return false; @@ -373,7 +373,7 @@ public int keysCount() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -381,7 +381,7 @@ public int keysCount() { committedVers = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheVersion _val = commState.getCacheVersion(); + GridCacheVersion _val = commState.getCacheVersion(null); if (_val == CACHE_VER_NOT_READ) return false; @@ -402,7 +402,7 @@ public int keysCount() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -410,7 +410,7 @@ public int keysCount() { rolledbackVers = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheVersion _val = commState.getCacheVersion(); + GridCacheVersion _val = commState.getCacheVersion(null); if (_val == CACHE_VER_NOT_READ) return false; @@ -427,7 +427,7 @@ public int keysCount() { commState.idx++; case 7: - GridCacheVersion ver0 = commState.getCacheVersion(); + GridCacheVersion ver0 = commState.getCacheVersion(null); if (ver0 == CACHE_VER_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedLockRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedLockRequest.java index 519c3b707800b..add0721cd7bea 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedLockRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedLockRequest.java @@ -463,7 +463,7 @@ public GridCacheVersion[] drVersions() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -473,7 +473,7 @@ public GridCacheVersion[] drVersions() { case 8: if (drVersByIdx != null) { if (commState.it == null) { - if (!commState.putInt(drVersByIdx.length)) + if (!commState.putInt(null, drVersByIdx.length)) return false; commState.it = arrayIterator(drVersByIdx); @@ -483,7 +483,7 @@ public GridCacheVersion[] drVersions() { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putCacheVersion((GridCacheVersion)commState.cur)) + if (!commState.putCacheVersion(null, (GridCacheVersion)commState.cur)) return false; commState.cur = NULL; @@ -491,44 +491,44 @@ public GridCacheVersion[] drVersions() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 9: - if (!commState.putGridUuid(futId)) + if (!commState.putGridUuid(null, futId)) return false; commState.idx++; case 10: - if (!commState.putByteArray(grpLockKeyBytes)) + if (!commState.putByteArray(null, grpLockKeyBytes)) return false; commState.idx++; case 11: - if (!commState.putBoolean(isInTx)) + if (!commState.putBoolean(null, isInTx)) return false; commState.idx++; case 12: - if (!commState.putBoolean(isInvalidate)) + if (!commState.putBoolean(null, isInvalidate)) return false; commState.idx++; case 13: - if (!commState.putBoolean(isRead)) + if (!commState.putBoolean(null, isRead)) return false; commState.idx++; case 14: - if (!commState.putEnum(isolation)) + if (!commState.putEnum(null, isolation)) return false; commState.idx++; @@ -536,7 +536,7 @@ public GridCacheVersion[] drVersions() { case 15: if (keyBytes != null) { if (commState.it == null) { - if (!commState.putInt(keyBytes.size())) + if (!commState.putInt(null, keyBytes.size())) return false; commState.it = keyBytes.iterator(); @@ -546,7 +546,7 @@ public GridCacheVersion[] drVersions() { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putByteArray((byte[])commState.cur)) + if (!commState.putByteArray(null, (byte[])commState.cur)) return false; commState.cur = NULL; @@ -554,56 +554,56 @@ public GridCacheVersion[] drVersions() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 16: - if (!commState.putCacheVersion(nearXidVer)) + if (!commState.putCacheVersion(null, nearXidVer)) return false; commState.idx++; case 17: - if (!commState.putUuid(nodeId)) + if (!commState.putUuid(null, nodeId)) return false; commState.idx++; case 18: - if (!commState.putBoolean(partLock)) + if (!commState.putBoolean(null, partLock)) return false; commState.idx++; case 19: - if (!commState.putBooleanArray(retVals)) + if (!commState.putBooleanArray(null, retVals)) return false; commState.idx++; case 20: - if (!commState.putLong(threadId)) + if (!commState.putLong(null, threadId)) return false; commState.idx++; case 21: - if (!commState.putLong(timeout)) + if (!commState.putLong(null, timeout)) return false; commState.idx++; case 22: - if (!commState.putInt(txSize)) + if (!commState.putInt(null, txSize)) return false; commState.idx++; case 23: - if (!commState.putByteArray(writeEntriesBytes)) + if (!commState.putByteArray(null, writeEntriesBytes)) return false; commState.idx++; @@ -627,7 +627,7 @@ public GridCacheVersion[] drVersions() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -635,7 +635,7 @@ public GridCacheVersion[] drVersions() { drVersByIdx = new GridCacheVersion[commState.readSize]; for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheVersion _val = commState.getCacheVersion(); + GridCacheVersion _val = commState.getCacheVersion(null); if (_val == CACHE_VER_NOT_READ) return false; @@ -652,7 +652,7 @@ public GridCacheVersion[] drVersions() { commState.idx++; case 9: - IgniteUuid futId0 = commState.getGridUuid(); + IgniteUuid futId0 = commState.getGridUuid(null); if (futId0 == GRID_UUID_NOT_READ) return false; @@ -662,7 +662,7 @@ public GridCacheVersion[] drVersions() { commState.idx++; case 10: - byte[] grpLockKeyBytes0 = commState.getByteArray(); + byte[] grpLockKeyBytes0 = commState.getByteArray(null); if (grpLockKeyBytes0 == BYTE_ARR_NOT_READ) return false; @@ -675,7 +675,7 @@ public GridCacheVersion[] drVersions() { if (buf.remaining() < 1) return false; - isInTx = commState.getBoolean(); + isInTx = commState.getBoolean(null); commState.idx++; @@ -683,7 +683,7 @@ public GridCacheVersion[] drVersions() { if (buf.remaining() < 1) return false; - isInvalidate = commState.getBoolean(); + isInvalidate = commState.getBoolean(null); commState.idx++; @@ -691,7 +691,7 @@ public GridCacheVersion[] drVersions() { if (buf.remaining() < 1) return false; - isRead = commState.getBoolean(); + isRead = commState.getBoolean(null); commState.idx++; @@ -699,7 +699,7 @@ public GridCacheVersion[] drVersions() { if (buf.remaining() < 1) return false; - byte isolation0 = commState.getByte(); + byte isolation0 = commState.getByte(null); isolation = GridCacheTxIsolation.fromOrdinal(isolation0); @@ -710,7 +710,7 @@ public GridCacheVersion[] drVersions() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -718,7 +718,7 @@ public GridCacheVersion[] drVersions() { keyBytes = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(); + byte[] _val = commState.getByteArray(null); if (_val == BYTE_ARR_NOT_READ) return false; @@ -735,7 +735,7 @@ public GridCacheVersion[] drVersions() { commState.idx++; case 16: - GridCacheVersion nearXidVer0 = commState.getCacheVersion(); + GridCacheVersion nearXidVer0 = commState.getCacheVersion(null); if (nearXidVer0 == CACHE_VER_NOT_READ) return false; @@ -745,7 +745,7 @@ public GridCacheVersion[] drVersions() { commState.idx++; case 17: - UUID nodeId0 = commState.getUuid(); + UUID nodeId0 = commState.getUuid(null); if (nodeId0 == UUID_NOT_READ) return false; @@ -758,12 +758,12 @@ public GridCacheVersion[] drVersions() { if (buf.remaining() < 1) return false; - partLock = commState.getBoolean(); + partLock = commState.getBoolean(null); commState.idx++; case 19: - boolean[] retVals0 = commState.getBooleanArray(); + boolean[] retVals0 = commState.getBooleanArray(null); if (retVals0 == BOOLEAN_ARR_NOT_READ) return false; @@ -776,7 +776,7 @@ public GridCacheVersion[] drVersions() { if (buf.remaining() < 8) return false; - threadId = commState.getLong(); + threadId = commState.getLong(null); commState.idx++; @@ -784,7 +784,7 @@ public GridCacheVersion[] drVersions() { if (buf.remaining() < 8) return false; - timeout = commState.getLong(); + timeout = commState.getLong(null); commState.idx++; @@ -792,12 +792,12 @@ public GridCacheVersion[] drVersions() { if (buf.remaining() < 4) return false; - txSize = commState.getInt(); + txSize = commState.getInt(null); commState.idx++; case 23: - byte[] writeEntriesBytes0 = commState.getByteArray(); + byte[] writeEntriesBytes0 = commState.getByteArray(null); if (writeEntriesBytes0 == BYTE_ARR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedLockResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedLockResponse.java index 8edfc7c72eb02..cf940597e2027 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedLockResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedLockResponse.java @@ -287,7 +287,7 @@ protected int valuesSize() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -295,13 +295,13 @@ protected int valuesSize() { switch (commState.idx) { case 8: - if (!commState.putByteArray(errBytes)) + if (!commState.putByteArray(null, errBytes)) return false; commState.idx++; case 9: - if (!commState.putGridUuid(futId)) + if (!commState.putGridUuid(null, futId)) return false; commState.idx++; @@ -309,7 +309,7 @@ protected int valuesSize() { case 10: if (valBytes != null) { if (commState.it == null) { - if (!commState.putInt(valBytes.size())) + if (!commState.putInt(null, valBytes.size())) return false; commState.it = valBytes.iterator(); @@ -319,7 +319,7 @@ protected int valuesSize() { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putValueBytes((GridCacheValueBytes)commState.cur)) + if (!commState.putValueBytes(null, (GridCacheValueBytes)commState.cur)) return false; commState.cur = NULL; @@ -327,7 +327,7 @@ protected int valuesSize() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } @@ -348,7 +348,7 @@ protected int valuesSize() { switch (commState.idx) { case 8: - byte[] errBytes0 = commState.getByteArray(); + byte[] errBytes0 = commState.getByteArray(null); if (errBytes0 == BYTE_ARR_NOT_READ) return false; @@ -358,7 +358,7 @@ protected int valuesSize() { commState.idx++; case 9: - IgniteUuid futId0 = commState.getGridUuid(); + IgniteUuid futId0 = commState.getGridUuid(null); if (futId0 == GRID_UUID_NOT_READ) return false; @@ -372,7 +372,7 @@ protected int valuesSize() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -380,7 +380,7 @@ protected int valuesSize() { valBytes = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheValueBytes _val = commState.getValueBytes(); + GridCacheValueBytes _val = commState.getValueBytes(null); if (_val == VAL_BYTES_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxFinishRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxFinishRequest.java index d2093c20b321c..8ffbc3dff2329 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxFinishRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxFinishRequest.java @@ -361,7 +361,7 @@ public boolean groupLock() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -369,49 +369,49 @@ public boolean groupLock() { switch (commState.idx) { case 8: - if (!commState.putCacheVersion(baseVer)) + if (!commState.putCacheVersion(null, baseVer)) return false; commState.idx++; case 9: - if (!commState.putBoolean(commit)) + if (!commState.putBoolean(null, commit)) return false; commState.idx++; case 10: - if (!commState.putCacheVersion(commitVer)) + if (!commState.putCacheVersion(null, commitVer)) return false; commState.idx++; case 11: - if (!commState.putGridUuid(futId)) + if (!commState.putGridUuid(null, futId)) return false; commState.idx++; case 12: - if (!commState.putByteArray(grpLockKeyBytes)) + if (!commState.putByteArray(null, grpLockKeyBytes)) return false; commState.idx++; case 13: - if (!commState.putBoolean(invalidate)) + if (!commState.putBoolean(null, invalidate)) return false; commState.idx++; case 14: - if (!commState.putBoolean(syncCommit)) + if (!commState.putBoolean(null, syncCommit)) return false; commState.idx++; case 15: - if (!commState.putBoolean(syncRollback)) + if (!commState.putBoolean(null, syncRollback)) return false; commState.idx++; @@ -419,7 +419,7 @@ public boolean groupLock() { case 16: if (recoveryWritesBytes != null) { if (commState.it == null) { - if (!commState.putInt(recoveryWritesBytes.size())) + if (!commState.putInt(null, recoveryWritesBytes.size())) return false; commState.it = recoveryWritesBytes.iterator(); @@ -429,7 +429,7 @@ public boolean groupLock() { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putByteArray((byte[])commState.cur)) + if (!commState.putByteArray(null, (byte[])commState.cur)) return false; commState.cur = NULL; @@ -437,20 +437,20 @@ public boolean groupLock() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 17: - if (!commState.putLong(threadId)) + if (!commState.putLong(null, threadId)) return false; commState.idx++; case 18: - if (!commState.putInt(txSize)) + if (!commState.putInt(null, txSize)) return false; commState.idx++; @@ -458,7 +458,7 @@ public boolean groupLock() { case 19: if (writeEntriesBytes != null) { if (commState.it == null) { - if (!commState.putInt(writeEntriesBytes.size())) + if (!commState.putInt(null, writeEntriesBytes.size())) return false; commState.it = writeEntriesBytes.iterator(); @@ -468,7 +468,7 @@ public boolean groupLock() { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putByteArray((byte[])commState.cur)) + if (!commState.putByteArray(null, (byte[])commState.cur)) return false; commState.cur = NULL; @@ -476,7 +476,7 @@ public boolean groupLock() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } @@ -497,7 +497,7 @@ public boolean groupLock() { switch (commState.idx) { case 8: - GridCacheVersion baseVer0 = commState.getCacheVersion(); + GridCacheVersion baseVer0 = commState.getCacheVersion(null); if (baseVer0 == CACHE_VER_NOT_READ) return false; @@ -510,12 +510,12 @@ public boolean groupLock() { if (buf.remaining() < 1) return false; - commit = commState.getBoolean(); + commit = commState.getBoolean(null); commState.idx++; case 10: - GridCacheVersion commitVer0 = commState.getCacheVersion(); + GridCacheVersion commitVer0 = commState.getCacheVersion(null); if (commitVer0 == CACHE_VER_NOT_READ) return false; @@ -525,7 +525,7 @@ public boolean groupLock() { commState.idx++; case 11: - IgniteUuid futId0 = commState.getGridUuid(); + IgniteUuid futId0 = commState.getGridUuid(null); if (futId0 == GRID_UUID_NOT_READ) return false; @@ -535,7 +535,7 @@ public boolean groupLock() { commState.idx++; case 12: - byte[] grpLockKeyBytes0 = commState.getByteArray(); + byte[] grpLockKeyBytes0 = commState.getByteArray(null); if (grpLockKeyBytes0 == BYTE_ARR_NOT_READ) return false; @@ -548,7 +548,7 @@ public boolean groupLock() { if (buf.remaining() < 1) return false; - invalidate = commState.getBoolean(); + invalidate = commState.getBoolean(null); commState.idx++; @@ -556,7 +556,7 @@ public boolean groupLock() { if (buf.remaining() < 1) return false; - syncCommit = commState.getBoolean(); + syncCommit = commState.getBoolean(null); commState.idx++; @@ -564,7 +564,7 @@ public boolean groupLock() { if (buf.remaining() < 1) return false; - syncRollback = commState.getBoolean(); + syncRollback = commState.getBoolean(null); commState.idx++; @@ -573,7 +573,7 @@ public boolean groupLock() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -581,7 +581,7 @@ public boolean groupLock() { recoveryWritesBytes = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(); + byte[] _val = commState.getByteArray(null); if (_val == BYTE_ARR_NOT_READ) return false; @@ -601,7 +601,7 @@ public boolean groupLock() { if (buf.remaining() < 8) return false; - threadId = commState.getLong(); + threadId = commState.getLong(null); commState.idx++; @@ -609,7 +609,7 @@ public boolean groupLock() { if (buf.remaining() < 4) return false; - txSize = commState.getInt(); + txSize = commState.getInt(null); commState.idx++; @@ -618,7 +618,7 @@ public boolean groupLock() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -626,7 +626,7 @@ public boolean groupLock() { writeEntriesBytes = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(); + byte[] _val = commState.getByteArray(null); if (_val == BYTE_ARR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxFinishResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxFinishResponse.java index 4481668c9c1ad..eb68e05a27c2d 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxFinishResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxFinishResponse.java @@ -94,7 +94,7 @@ public IgniteUuid futureId() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -102,13 +102,13 @@ public IgniteUuid futureId() { switch (commState.idx) { case 3: - if (!commState.putGridUuid(futId)) + if (!commState.putGridUuid(null, futId)) return false; commState.idx++; case 4: - if (!commState.putCacheVersion(txId)) + if (!commState.putCacheVersion(null, txId)) return false; commState.idx++; @@ -128,7 +128,7 @@ public IgniteUuid futureId() { switch (commState.idx) { case 3: - IgniteUuid futId0 = commState.getGridUuid(); + IgniteUuid futId0 = commState.getGridUuid(null); if (futId0 == GRID_UUID_NOT_READ) return false; @@ -138,7 +138,7 @@ public IgniteUuid futureId() { commState.idx++; case 4: - GridCacheVersion txId0 = commState.getCacheVersion(); + GridCacheVersion txId0 = commState.getCacheVersion(null); if (txId0 == CACHE_VER_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxPrepareRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxPrepareRequest.java index 791c4f796aea2..4aa4963494d96 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxPrepareRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxPrepareRequest.java @@ -426,7 +426,7 @@ private void writeCollection(ObjectOutput out, Collection return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -434,43 +434,43 @@ private void writeCollection(ObjectOutput out, Collection switch (commState.idx) { case 8: - if (!commState.putCacheVersion(commitVer)) + if (!commState.putCacheVersion(null, commitVer)) return false; commState.idx++; case 9: - if (!commState.putEnum(concurrency)) + if (!commState.putEnum(null, concurrency)) return false; commState.idx++; case 10: - if (!commState.putByteArray(dhtVersBytes)) + if (!commState.putByteArray(null, dhtVersBytes)) return false; commState.idx++; case 11: - if (!commState.putByteArray(grpLockKeyBytes)) + if (!commState.putByteArray(null, grpLockKeyBytes)) return false; commState.idx++; case 12: - if (!commState.putBoolean(invalidate)) + if (!commState.putBoolean(null, invalidate)) return false; commState.idx++; case 13: - if (!commState.putEnum(isolation)) + if (!commState.putEnum(null, isolation)) return false; commState.idx++; case 14: - if (!commState.putBoolean(partLock)) + if (!commState.putBoolean(null, partLock)) return false; commState.idx++; @@ -478,7 +478,7 @@ private void writeCollection(ObjectOutput out, Collection case 15: if (readsBytes != null) { if (commState.it == null) { - if (!commState.putInt(readsBytes.size())) + if (!commState.putInt(null, readsBytes.size())) return false; commState.it = readsBytes.iterator(); @@ -488,7 +488,7 @@ private void writeCollection(ObjectOutput out, Collection if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putByteArray((byte[])commState.cur)) + if (!commState.putByteArray(null, (byte[])commState.cur)) return false; commState.cur = NULL; @@ -496,32 +496,32 @@ private void writeCollection(ObjectOutput out, Collection commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 16: - if (!commState.putLong(threadId)) + if (!commState.putLong(null, threadId)) return false; commState.idx++; case 17: - if (!commState.putLong(timeout)) + if (!commState.putLong(null, timeout)) return false; commState.idx++; case 18: - if (!commState.putByteArray(txNodesBytes)) + if (!commState.putByteArray(null, txNodesBytes)) return false; commState.idx++; case 19: - if (!commState.putInt(txSize)) + if (!commState.putInt(null, txSize)) return false; commState.idx++; @@ -529,7 +529,7 @@ private void writeCollection(ObjectOutput out, Collection case 20: if (writesBytes != null) { if (commState.it == null) { - if (!commState.putInt(writesBytes.size())) + if (!commState.putInt(null, writesBytes.size())) return false; commState.it = writesBytes.iterator(); @@ -539,7 +539,7 @@ private void writeCollection(ObjectOutput out, Collection if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putByteArray((byte[])commState.cur)) + if (!commState.putByteArray(null, (byte[])commState.cur)) return false; commState.cur = NULL; @@ -547,7 +547,7 @@ private void writeCollection(ObjectOutput out, Collection commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } @@ -568,7 +568,7 @@ private void writeCollection(ObjectOutput out, Collection switch (commState.idx) { case 8: - GridCacheVersion commitVer0 = commState.getCacheVersion(); + GridCacheVersion commitVer0 = commState.getCacheVersion(null); if (commitVer0 == CACHE_VER_NOT_READ) return false; @@ -581,14 +581,14 @@ private void writeCollection(ObjectOutput out, Collection if (buf.remaining() < 1) return false; - byte concurrency0 = commState.getByte(); + byte concurrency0 = commState.getByte(null); concurrency = GridCacheTxConcurrency.fromOrdinal(concurrency0); commState.idx++; case 10: - byte[] dhtVersBytes0 = commState.getByteArray(); + byte[] dhtVersBytes0 = commState.getByteArray(null); if (dhtVersBytes0 == BYTE_ARR_NOT_READ) return false; @@ -598,7 +598,7 @@ private void writeCollection(ObjectOutput out, Collection commState.idx++; case 11: - byte[] grpLockKeyBytes0 = commState.getByteArray(); + byte[] grpLockKeyBytes0 = commState.getByteArray(null); if (grpLockKeyBytes0 == BYTE_ARR_NOT_READ) return false; @@ -611,7 +611,7 @@ private void writeCollection(ObjectOutput out, Collection if (buf.remaining() < 1) return false; - invalidate = commState.getBoolean(); + invalidate = commState.getBoolean(null); commState.idx++; @@ -619,7 +619,7 @@ private void writeCollection(ObjectOutput out, Collection if (buf.remaining() < 1) return false; - byte isolation0 = commState.getByte(); + byte isolation0 = commState.getByte(null); isolation = GridCacheTxIsolation.fromOrdinal(isolation0); @@ -629,7 +629,7 @@ private void writeCollection(ObjectOutput out, Collection if (buf.remaining() < 1) return false; - partLock = commState.getBoolean(); + partLock = commState.getBoolean(null); commState.idx++; @@ -638,7 +638,7 @@ private void writeCollection(ObjectOutput out, Collection if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -646,7 +646,7 @@ private void writeCollection(ObjectOutput out, Collection readsBytes = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(); + byte[] _val = commState.getByteArray(null); if (_val == BYTE_ARR_NOT_READ) return false; @@ -666,7 +666,7 @@ private void writeCollection(ObjectOutput out, Collection if (buf.remaining() < 8) return false; - threadId = commState.getLong(); + threadId = commState.getLong(null); commState.idx++; @@ -674,12 +674,12 @@ private void writeCollection(ObjectOutput out, Collection if (buf.remaining() < 8) return false; - timeout = commState.getLong(); + timeout = commState.getLong(null); commState.idx++; case 18: - byte[] txNodesBytes0 = commState.getByteArray(); + byte[] txNodesBytes0 = commState.getByteArray(null); if (txNodesBytes0 == BYTE_ARR_NOT_READ) return false; @@ -692,7 +692,7 @@ private void writeCollection(ObjectOutput out, Collection if (buf.remaining() < 4) return false; - txSize = commState.getInt(); + txSize = commState.getInt(null); commState.idx++; @@ -701,7 +701,7 @@ private void writeCollection(ObjectOutput out, Collection if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -709,7 +709,7 @@ private void writeCollection(ObjectOutput out, Collection writesBytes = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(); + byte[] _val = commState.getByteArray(null); if (_val == BYTE_ARR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxPrepareResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxPrepareResponse.java index 29873827554aa..2754c9e8d82a9 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxPrepareResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxPrepareResponse.java @@ -171,7 +171,7 @@ public void candidates(Map>> cands) { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -179,13 +179,13 @@ public void candidates(Map>> cands) { switch (commState.idx) { case 8: - if (!commState.putByteArray(candsBytes)) + if (!commState.putByteArray(null, candsBytes)) return false; commState.idx++; case 9: - if (!commState.putByteArray(errBytes)) + if (!commState.putByteArray(null, errBytes)) return false; commState.idx++; @@ -205,7 +205,7 @@ public void candidates(Map>> cands) { switch (commState.idx) { case 8: - byte[] candsBytes0 = commState.getByteArray(); + byte[] candsBytes0 = commState.getByteArray(null); if (candsBytes0 == BYTE_ARR_NOT_READ) return false; @@ -215,7 +215,7 @@ public void candidates(Map>> cands) { commState.idx++; case 9: - byte[] errBytes0 = commState.getByteArray(); + byte[] errBytes0 = commState.getByteArray(null); if (errBytes0 == BYTE_ARR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedUnlockRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedUnlockRequest.java index 93e3ccf74b90c..aa0772e4c4a15 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedUnlockRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedUnlockRequest.java @@ -136,7 +136,7 @@ public void addKey(K key, byte[] bytes, GridCacheContext ctx) throws Ignit return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -146,7 +146,7 @@ public void addKey(K key, byte[] bytes, GridCacheContext ctx) throws Ignit case 8: if (keyBytes != null) { if (commState.it == null) { - if (!commState.putInt(keyBytes.size())) + if (!commState.putInt(null, keyBytes.size())) return false; commState.it = keyBytes.iterator(); @@ -156,7 +156,7 @@ public void addKey(K key, byte[] bytes, GridCacheContext ctx) throws Ignit if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putByteArray((byte[])commState.cur)) + if (!commState.putByteArray(null, (byte[])commState.cur)) return false; commState.cur = NULL; @@ -164,7 +164,7 @@ public void addKey(K key, byte[] bytes, GridCacheContext ctx) throws Ignit commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } @@ -189,7 +189,7 @@ public void addKey(K key, byte[] bytes, GridCacheContext ctx) throws Ignit if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -197,7 +197,7 @@ public void addKey(K key, byte[] bytes, GridCacheContext ctx) throws Ignit keyBytes = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(); + byte[] _val = commState.getByteArray(null); if (_val == BYTE_ARR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java index fc580eac6b0b9..ef4e7bad28b97 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java @@ -85,7 +85,7 @@ public GridDhtAffinityAssignmentRequest(int cacheId, long topVer) { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -93,7 +93,7 @@ public GridDhtAffinityAssignmentRequest(int cacheId, long topVer) { switch (commState.idx) { case 3: - if (!commState.putLong(topVer)) + if (!commState.putLong(null, topVer)) return false; commState.idx++; @@ -115,7 +115,7 @@ public GridDhtAffinityAssignmentRequest(int cacheId, long topVer) { if (buf.remaining() < 8) return false; - topVer = commState.getLong(); + topVer = commState.getLong(null); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java index 62923cb88e7ee..24957637b47c8 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java @@ -126,7 +126,7 @@ public List> affinityAssignment() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -134,13 +134,13 @@ public List> affinityAssignment() { switch (commState.idx) { case 3: - if (!commState.putByteArray(affAssignmentBytes)) + if (!commState.putByteArray(null, affAssignmentBytes)) return false; commState.idx++; case 4: - if (!commState.putLong(topVer)) + if (!commState.putLong(null, topVer)) return false; commState.idx++; @@ -159,7 +159,7 @@ public List> affinityAssignment() { switch (commState.idx) { case 3: - byte[] affAssignmentBytes0 = commState.getByteArray(); + byte[] affAssignmentBytes0 = commState.getByteArray(null); if (affAssignmentBytes0 == BYTE_ARR_NOT_READ) return false; @@ -172,7 +172,7 @@ public List> affinityAssignment() { if (buf.remaining() < 8) return false; - topVer = commState.getLong(); + topVer = commState.getLong(null); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtLockRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtLockRequest.java index 0f115c1db7009..a78a6e363cbcc 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtLockRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtLockRequest.java @@ -340,7 +340,7 @@ public IgniteUuid miniId() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -348,13 +348,13 @@ public IgniteUuid miniId() { switch (commState.idx) { case 24: - if (!commState.putBitSet(invalidateEntries)) + if (!commState.putBitSet(null, invalidateEntries)) return false; commState.idx++; case 25: - if (!commState.putGridUuid(miniId)) + if (!commState.putGridUuid(null, miniId)) return false; commState.idx++; @@ -362,7 +362,7 @@ public IgniteUuid miniId() { case 26: if (nearKeyBytes != null) { if (commState.it == null) { - if (!commState.putInt(nearKeyBytes.size())) + if (!commState.putInt(null, nearKeyBytes.size())) return false; commState.it = nearKeyBytes.iterator(); @@ -372,7 +372,7 @@ public IgniteUuid miniId() { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putByteArray((byte[])commState.cur)) + if (!commState.putByteArray(null, (byte[])commState.cur)) return false; commState.cur = NULL; @@ -380,38 +380,38 @@ public IgniteUuid miniId() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 27: - if (!commState.putByteArray(ownedBytes)) + if (!commState.putByteArray(null, ownedBytes)) return false; commState.idx++; case 28: - if (!commState.putLong(topVer)) + if (!commState.putLong(null, topVer)) return false; commState.idx++; case 29: - if (!commState.putUuid(subjId)) + if (!commState.putUuid(null, subjId)) return false; commState.idx++; case 30: - if (!commState.putInt(taskNameHash)) + if (!commState.putInt(null, taskNameHash)) return false; commState.idx++; case 31: - if (!commState.putBitSet(preloadKeys)) + if (!commState.putBitSet(null, preloadKeys)) return false; commState.idx++; @@ -431,7 +431,7 @@ public IgniteUuid miniId() { switch (commState.idx) { case 24: - BitSet invalidateEntries0 = commState.getBitSet(); + BitSet invalidateEntries0 = commState.getBitSet(null); if (invalidateEntries0 == BIT_SET_NOT_READ) return false; @@ -441,7 +441,7 @@ public IgniteUuid miniId() { commState.idx++; case 25: - IgniteUuid miniId0 = commState.getGridUuid(); + IgniteUuid miniId0 = commState.getGridUuid(null); if (miniId0 == GRID_UUID_NOT_READ) return false; @@ -455,7 +455,7 @@ public IgniteUuid miniId() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -463,7 +463,7 @@ public IgniteUuid miniId() { nearKeyBytes = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(); + byte[] _val = commState.getByteArray(null); if (_val == BYTE_ARR_NOT_READ) return false; @@ -480,7 +480,7 @@ public IgniteUuid miniId() { commState.idx++; case 27: - byte[] ownedBytes0 = commState.getByteArray(); + byte[] ownedBytes0 = commState.getByteArray(null); if (ownedBytes0 == BYTE_ARR_NOT_READ) return false; @@ -493,12 +493,12 @@ public IgniteUuid miniId() { if (buf.remaining() < 8) return false; - topVer = commState.getLong(); + topVer = commState.getLong(null); commState.idx++; case 29: - UUID subjId0 = commState.getUuid(); + UUID subjId0 = commState.getUuid(null); if (subjId0 == UUID_NOT_READ) return false; @@ -511,12 +511,12 @@ public IgniteUuid miniId() { if (buf.remaining() < 4) return false; - taskNameHash = commState.getInt(); + taskNameHash = commState.getInt(null); commState.idx++; case 31: - BitSet preloadKeys0 = commState.getBitSet(); + BitSet preloadKeys0 = commState.getBitSet(null); if (preloadKeys0 == BIT_SET_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtLockResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtLockResponse.java index 3a86b4ee3d9af..2563a318b96bc 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtLockResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtLockResponse.java @@ -222,7 +222,7 @@ public Collection> preloadEntries() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -232,7 +232,7 @@ public Collection> preloadEntries() { case 11: if (invalidParts != null) { if (commState.it == null) { - if (!commState.putInt(invalidParts.size())) + if (!commState.putInt(null, invalidParts.size())) return false; commState.it = invalidParts.iterator(); @@ -242,7 +242,7 @@ public Collection> preloadEntries() { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putInt((int)commState.cur)) + if (!commState.putInt(null, (int)commState.cur)) return false; commState.cur = NULL; @@ -250,14 +250,14 @@ public Collection> preloadEntries() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 12: - if (!commState.putGridUuid(miniId)) + if (!commState.putGridUuid(null, miniId)) return false; commState.idx++; @@ -265,7 +265,7 @@ public Collection> preloadEntries() { case 13: if (nearEvictedBytes != null) { if (commState.it == null) { - if (!commState.putInt(nearEvictedBytes.size())) + if (!commState.putInt(null, nearEvictedBytes.size())) return false; commState.it = nearEvictedBytes.iterator(); @@ -275,7 +275,7 @@ public Collection> preloadEntries() { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putByteArray((byte[])commState.cur)) + if (!commState.putByteArray(null, (byte[])commState.cur)) return false; commState.cur = NULL; @@ -283,7 +283,7 @@ public Collection> preloadEntries() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } @@ -292,7 +292,7 @@ public Collection> preloadEntries() { case 14: if (preloadEntriesBytes != null) { if (commState.it == null) { - if (!commState.putInt(preloadEntriesBytes.size())) + if (!commState.putInt(null, preloadEntriesBytes.size())) return false; commState.it = preloadEntriesBytes.iterator(); @@ -302,7 +302,7 @@ public Collection> preloadEntries() { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putByteArray((byte[])commState.cur)) + if (!commState.putByteArray(null, (byte[])commState.cur)) return false; commState.cur = NULL; @@ -310,7 +310,7 @@ public Collection> preloadEntries() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } @@ -335,7 +335,7 @@ public Collection> preloadEntries() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -346,7 +346,7 @@ public Collection> preloadEntries() { if (buf.remaining() < 4) return false; - int _val = commState.getInt(); + int _val = commState.getInt(null); invalidParts.add((Integer)_val); @@ -360,7 +360,7 @@ public Collection> preloadEntries() { commState.idx++; case 12: - IgniteUuid miniId0 = commState.getGridUuid(); + IgniteUuid miniId0 = commState.getGridUuid(null); if (miniId0 == GRID_UUID_NOT_READ) return false; @@ -374,7 +374,7 @@ public Collection> preloadEntries() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -382,7 +382,7 @@ public Collection> preloadEntries() { nearEvictedBytes = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(); + byte[] _val = commState.getByteArray(null); if (_val == BYTE_ARR_NOT_READ) return false; @@ -403,7 +403,7 @@ public Collection> preloadEntries() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -411,7 +411,7 @@ public Collection> preloadEntries() { preloadEntriesBytes = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(); + byte[] _val = commState.getByteArray(null); if (_val == BYTE_ARR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java index c5db86267c4c9..105787f528514 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java @@ -315,7 +315,7 @@ public Collection pendingVersions() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -323,19 +323,19 @@ public Collection pendingVersions() { switch (commState.idx) { case 20: - if (!commState.putEnum(isolation)) + if (!commState.putEnum(null, isolation)) return false; commState.idx++; case 21: - if (!commState.putGridUuid(miniId)) + if (!commState.putGridUuid(null, miniId)) return false; commState.idx++; case 22: - if (!commState.putUuid(nearNodeId)) + if (!commState.putUuid(null, nearNodeId)) return false; commState.idx++; @@ -343,7 +343,7 @@ public Collection pendingVersions() { case 23: if (nearWritesBytes != null) { if (commState.it == null) { - if (!commState.putInt(nearWritesBytes.size())) + if (!commState.putInt(null, nearWritesBytes.size())) return false; commState.it = nearWritesBytes.iterator(); @@ -353,7 +353,7 @@ public Collection pendingVersions() { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putByteArray((byte[])commState.cur)) + if (!commState.putByteArray(null, (byte[])commState.cur)) return false; commState.cur = NULL; @@ -361,14 +361,14 @@ public Collection pendingVersions() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 24: - if (!commState.putBoolean(onePhaseCommit)) + if (!commState.putBoolean(null, onePhaseCommit)) return false; commState.idx++; @@ -376,7 +376,7 @@ public Collection pendingVersions() { case 25: if (pendingVers != null) { if (commState.it == null) { - if (!commState.putInt(pendingVers.size())) + if (!commState.putInt(null, pendingVers.size())) return false; commState.it = pendingVers.iterator(); @@ -386,7 +386,7 @@ public Collection pendingVersions() { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putCacheVersion((GridCacheVersion)commState.cur)) + if (!commState.putCacheVersion(null, (GridCacheVersion)commState.cur)) return false; commState.cur = NULL; @@ -394,38 +394,38 @@ public Collection pendingVersions() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 26: - if (!commState.putBoolean(sysInvalidate)) + if (!commState.putBoolean(null, sysInvalidate)) return false; commState.idx++; case 27: - if (!commState.putLong(topVer)) + if (!commState.putLong(null, topVer)) return false; commState.idx++; case 28: - if (!commState.putCacheVersion(writeVer)) + if (!commState.putCacheVersion(null, writeVer)) return false; commState.idx++; case 29: - if (!commState.putUuid(subjId)) + if (!commState.putUuid(null, subjId)) return false; commState.idx++; case 30: - if (!commState.putInt(taskNameHash)) + if (!commState.putInt(null, taskNameHash)) return false; commState.idx++; @@ -448,14 +448,14 @@ public Collection pendingVersions() { if (buf.remaining() < 1) return false; - byte isolation0 = commState.getByte(); + byte isolation0 = commState.getByte(null); isolation = GridCacheTxIsolation.fromOrdinal(isolation0); commState.idx++; case 21: - IgniteUuid miniId0 = commState.getGridUuid(); + IgniteUuid miniId0 = commState.getGridUuid(null); if (miniId0 == GRID_UUID_NOT_READ) return false; @@ -465,7 +465,7 @@ public Collection pendingVersions() { commState.idx++; case 22: - UUID nearNodeId0 = commState.getUuid(); + UUID nearNodeId0 = commState.getUuid(null); if (nearNodeId0 == UUID_NOT_READ) return false; @@ -479,7 +479,7 @@ public Collection pendingVersions() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -487,7 +487,7 @@ public Collection pendingVersions() { nearWritesBytes = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(); + byte[] _val = commState.getByteArray(null); if (_val == BYTE_ARR_NOT_READ) return false; @@ -507,7 +507,7 @@ public Collection pendingVersions() { if (buf.remaining() < 1) return false; - onePhaseCommit = commState.getBoolean(); + onePhaseCommit = commState.getBoolean(null); commState.idx++; @@ -516,7 +516,7 @@ public Collection pendingVersions() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -524,7 +524,7 @@ public Collection pendingVersions() { pendingVers = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheVersion _val = commState.getCacheVersion(); + GridCacheVersion _val = commState.getCacheVersion(null); if (_val == CACHE_VER_NOT_READ) return false; @@ -544,7 +544,7 @@ public Collection pendingVersions() { if (buf.remaining() < 1) return false; - sysInvalidate = commState.getBoolean(); + sysInvalidate = commState.getBoolean(null); commState.idx++; @@ -552,12 +552,12 @@ public Collection pendingVersions() { if (buf.remaining() < 8) return false; - topVer = commState.getLong(); + topVer = commState.getLong(null); commState.idx++; case 28: - GridCacheVersion writeVer0 = commState.getCacheVersion(); + GridCacheVersion writeVer0 = commState.getCacheVersion(null); if (writeVer0 == CACHE_VER_NOT_READ) return false; @@ -567,7 +567,7 @@ public Collection pendingVersions() { commState.idx++; case 29: - UUID subjId0 = commState.getUuid(); + UUID subjId0 = commState.getUuid(null); if (subjId0 == UUID_NOT_READ) return false; @@ -580,7 +580,7 @@ public Collection pendingVersions() { if (buf.remaining() < 4) return false; - taskNameHash = commState.getInt(); + taskNameHash = commState.getInt(null); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java index bab9219c2ab8d..b64e78056e8f6 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java @@ -88,7 +88,7 @@ public IgniteUuid miniId() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -96,7 +96,7 @@ public IgniteUuid miniId() { switch (commState.idx) { case 5: - if (!commState.putGridUuid(miniId)) + if (!commState.putGridUuid(null, miniId)) return false; commState.idx++; @@ -116,7 +116,7 @@ public IgniteUuid miniId() { switch (commState.idx) { case 5: - IgniteUuid miniId0 = commState.getGridUuid(); + IgniteUuid miniId0 = commState.getGridUuid(null); if (miniId0 == GRID_UUID_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java index 61dfe70b4bd1b..1455e5dd7b503 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java @@ -345,7 +345,7 @@ public Map, GridCacheVersion> owned() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -353,31 +353,31 @@ public Map, GridCacheVersion> owned() { switch (commState.idx) { case 21: - if (!commState.putGridUuid(futId)) + if (!commState.putGridUuid(null, futId)) return false; commState.idx++; case 22: - if (!commState.putBitSet(invalidateNearEntries)) + if (!commState.putBitSet(null, invalidateNearEntries)) return false; commState.idx++; case 23: - if (!commState.putBoolean(last)) + if (!commState.putBoolean(null, last)) return false; commState.idx++; case 24: - if (!commState.putGridUuid(miniId)) + if (!commState.putGridUuid(null, miniId)) return false; commState.idx++; case 25: - if (!commState.putUuid(nearNodeId)) + if (!commState.putUuid(null, nearNodeId)) return false; commState.idx++; @@ -385,7 +385,7 @@ public Map, GridCacheVersion> owned() { case 26: if (nearWritesBytes != null) { if (commState.it == null) { - if (!commState.putInt(nearWritesBytes.size())) + if (!commState.putInt(null, nearWritesBytes.size())) return false; commState.it = nearWritesBytes.iterator(); @@ -395,7 +395,7 @@ public Map, GridCacheVersion> owned() { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putByteArray((byte[])commState.cur)) + if (!commState.putByteArray(null, (byte[])commState.cur)) return false; commState.cur = NULL; @@ -403,44 +403,44 @@ public Map, GridCacheVersion> owned() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 27: - if (!commState.putCacheVersion(nearXidVer)) + if (!commState.putCacheVersion(null, nearXidVer)) return false; commState.idx++; case 28: - if (!commState.putByteArray(ownedBytes)) + if (!commState.putByteArray(null, ownedBytes)) return false; commState.idx++; case 29: - if (!commState.putLong(topVer)) + if (!commState.putLong(null, topVer)) return false; commState.idx++; case 30: - if (!commState.putUuid(subjId)) + if (!commState.putUuid(null, subjId)) return false; commState.idx++; case 31: - if (!commState.putInt(taskNameHash)) + if (!commState.putInt(null, taskNameHash)) return false; commState.idx++; case 32: - if (!commState.putBitSet(preloadKeys)) + if (!commState.putBitSet(null, preloadKeys)) return false; commState.idx++; @@ -460,7 +460,7 @@ public Map, GridCacheVersion> owned() { switch (commState.idx) { case 21: - IgniteUuid futId0 = commState.getGridUuid(); + IgniteUuid futId0 = commState.getGridUuid(null); if (futId0 == GRID_UUID_NOT_READ) return false; @@ -470,7 +470,7 @@ public Map, GridCacheVersion> owned() { commState.idx++; case 22: - BitSet invalidateNearEntries0 = commState.getBitSet(); + BitSet invalidateNearEntries0 = commState.getBitSet(null); if (invalidateNearEntries0 == BIT_SET_NOT_READ) return false; @@ -483,12 +483,12 @@ public Map, GridCacheVersion> owned() { if (buf.remaining() < 1) return false; - last = commState.getBoolean(); + last = commState.getBoolean(null); commState.idx++; case 24: - IgniteUuid miniId0 = commState.getGridUuid(); + IgniteUuid miniId0 = commState.getGridUuid(null); if (miniId0 == GRID_UUID_NOT_READ) return false; @@ -498,7 +498,7 @@ public Map, GridCacheVersion> owned() { commState.idx++; case 25: - UUID nearNodeId0 = commState.getUuid(); + UUID nearNodeId0 = commState.getUuid(null); if (nearNodeId0 == UUID_NOT_READ) return false; @@ -512,7 +512,7 @@ public Map, GridCacheVersion> owned() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -520,7 +520,7 @@ public Map, GridCacheVersion> owned() { nearWritesBytes = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(); + byte[] _val = commState.getByteArray(null); if (_val == BYTE_ARR_NOT_READ) return false; @@ -537,7 +537,7 @@ public Map, GridCacheVersion> owned() { commState.idx++; case 27: - GridCacheVersion nearXidVer0 = commState.getCacheVersion(); + GridCacheVersion nearXidVer0 = commState.getCacheVersion(null); if (nearXidVer0 == CACHE_VER_NOT_READ) return false; @@ -547,7 +547,7 @@ public Map, GridCacheVersion> owned() { commState.idx++; case 28: - byte[] ownedBytes0 = commState.getByteArray(); + byte[] ownedBytes0 = commState.getByteArray(null); if (ownedBytes0 == BYTE_ARR_NOT_READ) return false; @@ -560,12 +560,12 @@ public Map, GridCacheVersion> owned() { if (buf.remaining() < 8) return false; - topVer = commState.getLong(); + topVer = commState.getLong(null); commState.idx++; case 30: - UUID subjId0 = commState.getUuid(); + UUID subjId0 = commState.getUuid(null); if (subjId0 == UUID_NOT_READ) return false; @@ -578,12 +578,12 @@ public Map, GridCacheVersion> owned() { if (buf.remaining() < 4) return false; - taskNameHash = commState.getInt(); + taskNameHash = commState.getInt(null); commState.idx++; case 32: - BitSet preloadKeys0 = commState.getBitSet(); + BitSet preloadKeys0 = commState.getBitSet(null); if (preloadKeys0 == BIT_SET_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java index 1ada90907af13..d541b5812b986 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java @@ -229,7 +229,7 @@ public void addPreloadEntry(GridCacheEntryInfo info) { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -237,7 +237,7 @@ public void addPreloadEntry(GridCacheEntryInfo info) { switch (commState.idx) { case 10: - if (!commState.putGridUuid(futId)) + if (!commState.putGridUuid(null, futId)) return false; commState.idx++; @@ -245,7 +245,7 @@ public void addPreloadEntry(GridCacheEntryInfo info) { case 11: if (invalidParts != null) { if (commState.it == null) { - if (!commState.putInt(invalidParts.size())) + if (!commState.putInt(null, invalidParts.size())) return false; commState.it = invalidParts.iterator(); @@ -255,7 +255,7 @@ public void addPreloadEntry(GridCacheEntryInfo info) { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putInt((int)commState.cur)) + if (!commState.putInt(null, (int)commState.cur)) return false; commState.cur = NULL; @@ -263,14 +263,14 @@ public void addPreloadEntry(GridCacheEntryInfo info) { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 12: - if (!commState.putGridUuid(miniId)) + if (!commState.putGridUuid(null, miniId)) return false; commState.idx++; @@ -278,7 +278,7 @@ public void addPreloadEntry(GridCacheEntryInfo info) { case 13: if (nearEvictedBytes != null) { if (commState.it == null) { - if (!commState.putInt(nearEvictedBytes.size())) + if (!commState.putInt(null, nearEvictedBytes.size())) return false; commState.it = nearEvictedBytes.iterator(); @@ -288,7 +288,7 @@ public void addPreloadEntry(GridCacheEntryInfo info) { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putByteArray((byte[])commState.cur)) + if (!commState.putByteArray(null, (byte[])commState.cur)) return false; commState.cur = NULL; @@ -296,7 +296,7 @@ public void addPreloadEntry(GridCacheEntryInfo info) { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } @@ -305,7 +305,7 @@ public void addPreloadEntry(GridCacheEntryInfo info) { case 14: if (preloadEntriesBytes != null) { if (commState.it == null) { - if (!commState.putInt(preloadEntriesBytes.size())) + if (!commState.putInt(null, preloadEntriesBytes.size())) return false; commState.it = preloadEntriesBytes.iterator(); @@ -315,7 +315,7 @@ public void addPreloadEntry(GridCacheEntryInfo info) { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putByteArray((byte[])commState.cur)) + if (!commState.putByteArray(null, (byte[])commState.cur)) return false; commState.cur = NULL; @@ -323,7 +323,7 @@ public void addPreloadEntry(GridCacheEntryInfo info) { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } @@ -344,7 +344,7 @@ public void addPreloadEntry(GridCacheEntryInfo info) { switch (commState.idx) { case 10: - IgniteUuid futId0 = commState.getGridUuid(); + IgniteUuid futId0 = commState.getGridUuid(null); if (futId0 == GRID_UUID_NOT_READ) return false; @@ -358,7 +358,7 @@ public void addPreloadEntry(GridCacheEntryInfo info) { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -369,7 +369,7 @@ public void addPreloadEntry(GridCacheEntryInfo info) { if (buf.remaining() < 4) return false; - int _val = commState.getInt(); + int _val = commState.getInt(null); invalidParts.add((Integer)_val); @@ -383,7 +383,7 @@ public void addPreloadEntry(GridCacheEntryInfo info) { commState.idx++; case 12: - IgniteUuid miniId0 = commState.getGridUuid(); + IgniteUuid miniId0 = commState.getGridUuid(null); if (miniId0 == GRID_UUID_NOT_READ) return false; @@ -397,7 +397,7 @@ public void addPreloadEntry(GridCacheEntryInfo info) { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -405,7 +405,7 @@ public void addPreloadEntry(GridCacheEntryInfo info) { nearEvictedBytes = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(); + byte[] _val = commState.getByteArray(null); if (_val == BYTE_ARR_NOT_READ) return false; @@ -426,7 +426,7 @@ public void addPreloadEntry(GridCacheEntryInfo info) { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -434,7 +434,7 @@ public void addPreloadEntry(GridCacheEntryInfo info) { preloadEntriesBytes = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(); + byte[] _val = commState.getByteArray(null); if (_val == BYTE_ARR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtUnlockRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtUnlockRequest.java index 4a5a5a074623a..3a4c289e77ed9 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtUnlockRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtUnlockRequest.java @@ -124,7 +124,7 @@ public void addNearKey(K key, byte[] keyBytes, GridCacheSharedContext ctx) return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -134,7 +134,7 @@ public void addNearKey(K key, byte[] keyBytes, GridCacheSharedContext ctx) case 9: if (nearKeyBytes != null) { if (commState.it == null) { - if (!commState.putInt(nearKeyBytes.size())) + if (!commState.putInt(null, nearKeyBytes.size())) return false; commState.it = nearKeyBytes.iterator(); @@ -144,7 +144,7 @@ public void addNearKey(K key, byte[] keyBytes, GridCacheSharedContext ctx) if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putByteArray((byte[])commState.cur)) + if (!commState.putByteArray(null, (byte[])commState.cur)) return false; commState.cur = NULL; @@ -152,7 +152,7 @@ public void addNearKey(K key, byte[] keyBytes, GridCacheSharedContext ctx) commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } @@ -177,7 +177,7 @@ public void addNearKey(K key, byte[] keyBytes, GridCacheSharedContext ctx) if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -185,7 +185,7 @@ public void addNearKey(K key, byte[] keyBytes, GridCacheSharedContext ctx) nearKeyBytes = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(); + byte[] _val = commState.getByteArray(null); if (_val == BYTE_ARR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicDeferredUpdateResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicDeferredUpdateResponse.java index e04099c0ec1b2..f86a28c6297f3 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicDeferredUpdateResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicDeferredUpdateResponse.java @@ -91,7 +91,7 @@ public Collection futureVersions() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -101,7 +101,7 @@ public Collection futureVersions() { case 3: if (futVers != null) { if (commState.it == null) { - if (!commState.putInt(futVers.size())) + if (!commState.putInt(null, futVers.size())) return false; commState.it = futVers.iterator(); @@ -111,7 +111,7 @@ public Collection futureVersions() { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putCacheVersion((GridCacheVersion)commState.cur)) + if (!commState.putCacheVersion(null, (GridCacheVersion)commState.cur)) return false; commState.cur = NULL; @@ -119,7 +119,7 @@ public Collection futureVersions() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } @@ -144,7 +144,7 @@ public Collection futureVersions() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -152,7 +152,7 @@ public Collection futureVersions() { futVers = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheVersion _val = commState.getCacheVersion(); + GridCacheVersion _val = commState.getCacheVersion(null); if (_val == CACHE_VER_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java index ad3f8daf351ce..6e084f33056c6 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java @@ -644,7 +644,7 @@ public long drExpireTime(int idx) { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -652,13 +652,13 @@ public long drExpireTime(int idx) { switch (commState.idx) { case 3: - if (!commState.putLongList(drExpireTimes)) + if (!commState.putLongList(null, drExpireTimes)) return false; commState.idx++; case 4: - if (!commState.putLongList(drTtls)) + if (!commState.putLongList(null, drTtls)) return false; commState.idx++; @@ -666,7 +666,7 @@ public long drExpireTime(int idx) { case 5: if (drVers != null) { if (commState.it == null) { - if (!commState.putInt(drVers.size())) + if (!commState.putInt(null, drVers.size())) return false; commState.it = drVers.iterator(); @@ -676,7 +676,7 @@ public long drExpireTime(int idx) { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putCacheVersion((GridCacheVersion)commState.cur)) + if (!commState.putCacheVersion(null, (GridCacheVersion)commState.cur)) return false; commState.cur = NULL; @@ -684,14 +684,14 @@ public long drExpireTime(int idx) { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 6: - if (!commState.putCacheVersion(futVer)) + if (!commState.putCacheVersion(null, futVer)) return false; commState.idx++; @@ -699,7 +699,7 @@ public long drExpireTime(int idx) { case 7: if (keyBytes != null) { if (commState.it == null) { - if (!commState.putInt(keyBytes.size())) + if (!commState.putInt(null, keyBytes.size())) return false; commState.it = keyBytes.iterator(); @@ -709,7 +709,7 @@ public long drExpireTime(int idx) { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putByteArray((byte[])commState.cur)) + if (!commState.putByteArray(null, (byte[])commState.cur)) return false; commState.cur = NULL; @@ -717,32 +717,32 @@ public long drExpireTime(int idx) { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 8: - if (!commState.putUuid(nodeId)) + if (!commState.putUuid(null, nodeId)) return false; commState.idx++; case 9: - if (!commState.putEnum(syncMode)) + if (!commState.putEnum(null, syncMode)) return false; commState.idx++; case 10: - if (!commState.putLong(topVer)) + if (!commState.putLong(null, topVer)) return false; commState.idx++; case 11: - if (!commState.putLong(ttl)) + if (!commState.putLong(null, ttl)) return false; commState.idx++; @@ -750,7 +750,7 @@ public long drExpireTime(int idx) { case 12: if (valBytes != null) { if (commState.it == null) { - if (!commState.putInt(valBytes.size())) + if (!commState.putInt(null, valBytes.size())) return false; commState.it = valBytes.iterator(); @@ -760,7 +760,7 @@ public long drExpireTime(int idx) { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putValueBytes((GridCacheValueBytes)commState.cur)) + if (!commState.putValueBytes(null, (GridCacheValueBytes)commState.cur)) return false; commState.cur = NULL; @@ -768,14 +768,14 @@ public long drExpireTime(int idx) { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 13: - if (!commState.putCacheVersion(writeVer)) + if (!commState.putCacheVersion(null, writeVer)) return false; commState.idx++; @@ -783,7 +783,7 @@ public long drExpireTime(int idx) { case 14: if (nearKeyBytes != null) { if (commState.it == null) { - if (!commState.putInt(nearKeyBytes.size())) + if (!commState.putInt(null, nearKeyBytes.size())) return false; commState.it = nearKeyBytes.iterator(); @@ -793,7 +793,7 @@ public long drExpireTime(int idx) { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putByteArray((byte[])commState.cur)) + if (!commState.putByteArray(null, (byte[])commState.cur)) return false; commState.cur = NULL; @@ -801,7 +801,7 @@ public long drExpireTime(int idx) { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } @@ -810,7 +810,7 @@ public long drExpireTime(int idx) { case 15: if (nearValBytes != null) { if (commState.it == null) { - if (!commState.putInt(nearValBytes.size())) + if (!commState.putInt(null, nearValBytes.size())) return false; commState.it = nearValBytes.iterator(); @@ -820,7 +820,7 @@ public long drExpireTime(int idx) { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putValueBytes((GridCacheValueBytes)commState.cur)) + if (!commState.putValueBytes(null, (GridCacheValueBytes)commState.cur)) return false; commState.cur = NULL; @@ -828,14 +828,14 @@ public long drExpireTime(int idx) { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 16: - if (!commState.putBoolean(forceTransformBackups)) + if (!commState.putBoolean(null, forceTransformBackups)) return false; commState.idx++; @@ -843,7 +843,7 @@ public long drExpireTime(int idx) { case 17: if (nearTransformClosBytes != null) { if (commState.it == null) { - if (!commState.putInt(nearTransformClosBytes.size())) + if (!commState.putInt(null, nearTransformClosBytes.size())) return false; commState.it = nearTransformClosBytes.iterator(); @@ -853,7 +853,7 @@ public long drExpireTime(int idx) { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putByteArray((byte[])commState.cur)) + if (!commState.putByteArray(null, (byte[])commState.cur)) return false; commState.cur = NULL; @@ -861,7 +861,7 @@ public long drExpireTime(int idx) { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } @@ -870,7 +870,7 @@ public long drExpireTime(int idx) { case 18: if (transformClosBytes != null) { if (commState.it == null) { - if (!commState.putInt(transformClosBytes.size())) + if (!commState.putInt(null, transformClosBytes.size())) return false; commState.it = transformClosBytes.iterator(); @@ -880,7 +880,7 @@ public long drExpireTime(int idx) { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putByteArray((byte[])commState.cur)) + if (!commState.putByteArray(null, (byte[])commState.cur)) return false; commState.cur = NULL; @@ -888,20 +888,20 @@ public long drExpireTime(int idx) { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 19: - if (!commState.putUuid(subjId)) + if (!commState.putUuid(null, subjId)) return false; commState.idx++; case 20: - if (!commState.putInt(taskNameHash)) + if (!commState.putInt(null, taskNameHash)) return false; commState.idx++; @@ -921,7 +921,7 @@ public long drExpireTime(int idx) { switch (commState.idx) { case 3: - GridLongList drExpireTimes0 = commState.getLongList(); + GridLongList drExpireTimes0 = commState.getLongList(null); if (drExpireTimes0 == LONG_LIST_NOT_READ) return false; @@ -931,7 +931,7 @@ public long drExpireTime(int idx) { commState.idx++; case 4: - GridLongList drTtls0 = commState.getLongList(); + GridLongList drTtls0 = commState.getLongList(null); if (drTtls0 == LONG_LIST_NOT_READ) return false; @@ -945,7 +945,7 @@ public long drExpireTime(int idx) { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -953,7 +953,7 @@ public long drExpireTime(int idx) { drVers = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheVersion _val = commState.getCacheVersion(); + GridCacheVersion _val = commState.getCacheVersion(null); if (_val == CACHE_VER_NOT_READ) return false; @@ -970,7 +970,7 @@ public long drExpireTime(int idx) { commState.idx++; case 6: - GridCacheVersion futVer0 = commState.getCacheVersion(); + GridCacheVersion futVer0 = commState.getCacheVersion(null); if (futVer0 == CACHE_VER_NOT_READ) return false; @@ -984,7 +984,7 @@ public long drExpireTime(int idx) { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -992,7 +992,7 @@ public long drExpireTime(int idx) { keyBytes = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(); + byte[] _val = commState.getByteArray(null); if (_val == BYTE_ARR_NOT_READ) return false; @@ -1009,7 +1009,7 @@ public long drExpireTime(int idx) { commState.idx++; case 8: - UUID nodeId0 = commState.getUuid(); + UUID nodeId0 = commState.getUuid(null); if (nodeId0 == UUID_NOT_READ) return false; @@ -1022,7 +1022,7 @@ public long drExpireTime(int idx) { if (buf.remaining() < 1) return false; - byte syncMode0 = commState.getByte(); + byte syncMode0 = commState.getByte(null); syncMode = GridCacheWriteSynchronizationMode.fromOrdinal(syncMode0); @@ -1032,7 +1032,7 @@ public long drExpireTime(int idx) { if (buf.remaining() < 8) return false; - topVer = commState.getLong(); + topVer = commState.getLong(null); commState.idx++; @@ -1040,7 +1040,7 @@ public long drExpireTime(int idx) { if (buf.remaining() < 8) return false; - ttl = commState.getLong(); + ttl = commState.getLong(null); commState.idx++; @@ -1049,7 +1049,7 @@ public long drExpireTime(int idx) { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -1057,7 +1057,7 @@ public long drExpireTime(int idx) { valBytes = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheValueBytes _val = commState.getValueBytes(); + GridCacheValueBytes _val = commState.getValueBytes(null); if (_val == VAL_BYTES_NOT_READ) return false; @@ -1074,7 +1074,7 @@ public long drExpireTime(int idx) { commState.idx++; case 13: - GridCacheVersion writeVer0 = commState.getCacheVersion(); + GridCacheVersion writeVer0 = commState.getCacheVersion(null); if (writeVer0 == CACHE_VER_NOT_READ) return false; @@ -1088,7 +1088,7 @@ public long drExpireTime(int idx) { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -1096,7 +1096,7 @@ public long drExpireTime(int idx) { nearKeyBytes = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(); + byte[] _val = commState.getByteArray(null); if (_val == BYTE_ARR_NOT_READ) return false; @@ -1117,7 +1117,7 @@ public long drExpireTime(int idx) { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -1125,7 +1125,7 @@ public long drExpireTime(int idx) { nearValBytes = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheValueBytes _val = commState.getValueBytes(); + GridCacheValueBytes _val = commState.getValueBytes(null); if (_val == VAL_BYTES_NOT_READ) return false; @@ -1145,7 +1145,7 @@ public long drExpireTime(int idx) { if (buf.remaining() < 1) return false; - forceTransformBackups = commState.getBoolean(); + forceTransformBackups = commState.getBoolean(null); commState.idx++; @@ -1154,7 +1154,7 @@ public long drExpireTime(int idx) { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -1162,7 +1162,7 @@ public long drExpireTime(int idx) { nearTransformClosBytes = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(); + byte[] _val = commState.getByteArray(null); if (_val == BYTE_ARR_NOT_READ) return false; @@ -1183,7 +1183,7 @@ public long drExpireTime(int idx) { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -1191,7 +1191,7 @@ public long drExpireTime(int idx) { transformClosBytes = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(); + byte[] _val = commState.getByteArray(null); if (_val == BYTE_ARR_NOT_READ) return false; @@ -1208,7 +1208,7 @@ public long drExpireTime(int idx) { commState.idx++; case 19: - UUID subjId0 = commState.getUuid(); + UUID subjId0 = commState.getUuid(null); if (subjId0 == UUID_NOT_READ) return false; @@ -1221,7 +1221,7 @@ public long drExpireTime(int idx) { if (buf.remaining() < 4) return false; - taskNameHash = commState.getInt(); + taskNameHash = commState.getInt(null); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java index 81b0a896982c9..5d3ba598d1361 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java @@ -203,7 +203,7 @@ public void addNearEvicted(K key, @Nullable byte[] bytes) { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -211,19 +211,19 @@ public void addNearEvicted(K key, @Nullable byte[] bytes) { switch (commState.idx) { case 3: - if (!commState.putByteArray(errBytes)) + if (!commState.putByteArray(null, errBytes)) return false; commState.idx++; case 4: - if (!commState.putByteArray(failedKeysBytes)) + if (!commState.putByteArray(null, failedKeysBytes)) return false; commState.idx++; case 5: - if (!commState.putCacheVersion(futVer)) + if (!commState.putCacheVersion(null, futVer)) return false; commState.idx++; @@ -231,7 +231,7 @@ public void addNearEvicted(K key, @Nullable byte[] bytes) { case 6: if (nearEvictedBytes != null) { if (commState.it == null) { - if (!commState.putInt(nearEvictedBytes.size())) + if (!commState.putInt(null, nearEvictedBytes.size())) return false; commState.it = nearEvictedBytes.iterator(); @@ -241,7 +241,7 @@ public void addNearEvicted(K key, @Nullable byte[] bytes) { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putByteArray((byte[])commState.cur)) + if (!commState.putByteArray(null, (byte[])commState.cur)) return false; commState.cur = NULL; @@ -249,7 +249,7 @@ public void addNearEvicted(K key, @Nullable byte[] bytes) { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } @@ -270,7 +270,7 @@ public void addNearEvicted(K key, @Nullable byte[] bytes) { switch (commState.idx) { case 3: - byte[] errBytes0 = commState.getByteArray(); + byte[] errBytes0 = commState.getByteArray(null); if (errBytes0 == BYTE_ARR_NOT_READ) return false; @@ -280,7 +280,7 @@ public void addNearEvicted(K key, @Nullable byte[] bytes) { commState.idx++; case 4: - byte[] failedKeysBytes0 = commState.getByteArray(); + byte[] failedKeysBytes0 = commState.getByteArray(null); if (failedKeysBytes0 == BYTE_ARR_NOT_READ) return false; @@ -290,7 +290,7 @@ public void addNearEvicted(K key, @Nullable byte[] bytes) { commState.idx++; case 5: - GridCacheVersion futVer0 = commState.getCacheVersion(); + GridCacheVersion futVer0 = commState.getCacheVersion(null); if (futVer0 == CACHE_VER_NOT_READ) return false; @@ -304,7 +304,7 @@ public void addNearEvicted(K key, @Nullable byte[] bytes) { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -312,7 +312,7 @@ public void addNearEvicted(K key, @Nullable byte[] bytes) { nearEvictedBytes = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(); + byte[] _val = commState.getByteArray(null); if (_val == BYTE_ARR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java index 00512ff480eb5..446a52139e438 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java @@ -545,7 +545,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -553,13 +553,13 @@ public void forceTransformBackups(boolean forceTransformBackups) { switch (commState.idx) { case 3: - if (!commState.putLongList(drExpireTimes)) + if (!commState.putLongList(null, drExpireTimes)) return false; commState.idx++; case 4: - if (!commState.putLongList(drTtls)) + if (!commState.putLongList(null, drTtls)) return false; commState.idx++; @@ -567,7 +567,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { case 5: if (drVers != null) { if (commState.it == null) { - if (!commState.putInt(drVers.size())) + if (!commState.putInt(null, drVers.size())) return false; commState.it = drVers.iterator(); @@ -577,7 +577,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putCacheVersion((GridCacheVersion)commState.cur)) + if (!commState.putCacheVersion(null, (GridCacheVersion)commState.cur)) return false; commState.cur = NULL; @@ -585,14 +585,14 @@ public void forceTransformBackups(boolean forceTransformBackups) { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 6: - if (!commState.putBoolean(fastMap)) + if (!commState.putBoolean(null, fastMap)) return false; commState.idx++; @@ -600,7 +600,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { case 7: if (filterBytes != null) { if (commState.it == null) { - if (!commState.putInt(filterBytes.length)) + if (!commState.putInt(null, filterBytes.length)) return false; commState.it = arrayIterator(filterBytes); @@ -610,7 +610,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putByteArray((byte[])commState.cur)) + if (!commState.putByteArray(null, (byte[])commState.cur)) return false; commState.cur = NULL; @@ -618,20 +618,20 @@ public void forceTransformBackups(boolean forceTransformBackups) { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 8: - if (!commState.putCacheVersion(futVer)) + if (!commState.putCacheVersion(null, futVer)) return false; commState.idx++; case 9: - if (!commState.putBoolean(hasPrimary)) + if (!commState.putBoolean(null, hasPrimary)) return false; commState.idx++; @@ -639,7 +639,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { case 10: if (keyBytes != null) { if (commState.it == null) { - if (!commState.putInt(keyBytes.size())) + if (!commState.putInt(null, keyBytes.size())) return false; commState.it = keyBytes.iterator(); @@ -649,7 +649,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putByteArray((byte[])commState.cur)) + if (!commState.putByteArray(null, (byte[])commState.cur)) return false; commState.cur = NULL; @@ -657,44 +657,44 @@ public void forceTransformBackups(boolean forceTransformBackups) { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 11: - if (!commState.putEnum(op)) + if (!commState.putEnum(null, op)) return false; commState.idx++; case 12: - if (!commState.putBoolean(retval)) + if (!commState.putBoolean(null, retval)) return false; commState.idx++; case 13: - if (!commState.putEnum(syncMode)) + if (!commState.putEnum(null, syncMode)) return false; commState.idx++; case 14: - if (!commState.putLong(topVer)) + if (!commState.putLong(null, topVer)) return false; commState.idx++; case 15: - if (!commState.putLong(ttl)) + if (!commState.putLong(null, ttl)) return false; commState.idx++; case 16: - if (!commState.putCacheVersion(updateVer)) + if (!commState.putCacheVersion(null, updateVer)) return false; commState.idx++; @@ -702,7 +702,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { case 17: if (valBytes != null) { if (commState.it == null) { - if (!commState.putInt(valBytes.size())) + if (!commState.putInt(null, valBytes.size())) return false; commState.it = valBytes.iterator(); @@ -712,7 +712,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putValueBytes((GridCacheValueBytes)commState.cur)) + if (!commState.putValueBytes(null, (GridCacheValueBytes)commState.cur)) return false; commState.cur = NULL; @@ -720,26 +720,26 @@ public void forceTransformBackups(boolean forceTransformBackups) { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 18: - if (!commState.putBoolean(forceTransformBackups)) + if (!commState.putBoolean(null, forceTransformBackups)) return false; commState.idx++; case 19: - if (!commState.putUuid(subjId)) + if (!commState.putUuid(null, subjId)) return false; commState.idx++; case 20: - if (!commState.putInt(taskNameHash)) + if (!commState.putInt(null, taskNameHash)) return false; commState.idx++; @@ -759,7 +759,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { switch (commState.idx) { case 3: - GridLongList drExpireTimes0 = commState.getLongList(); + GridLongList drExpireTimes0 = commState.getLongList(null); if (drExpireTimes0 == LONG_LIST_NOT_READ) return false; @@ -769,7 +769,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { commState.idx++; case 4: - GridLongList drTtls0 = commState.getLongList(); + GridLongList drTtls0 = commState.getLongList(null); if (drTtls0 == LONG_LIST_NOT_READ) return false; @@ -783,7 +783,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -791,7 +791,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { drVers = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheVersion _val = commState.getCacheVersion(); + GridCacheVersion _val = commState.getCacheVersion(null); if (_val == CACHE_VER_NOT_READ) return false; @@ -811,7 +811,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { if (buf.remaining() < 1) return false; - fastMap = commState.getBoolean(); + fastMap = commState.getBoolean(null); commState.idx++; @@ -820,7 +820,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -828,7 +828,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { filterBytes = new byte[commState.readSize][]; for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(); + byte[] _val = commState.getByteArray(null); if (_val == BYTE_ARR_NOT_READ) return false; @@ -845,7 +845,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { commState.idx++; case 8: - GridCacheVersion futVer0 = commState.getCacheVersion(); + GridCacheVersion futVer0 = commState.getCacheVersion(null); if (futVer0 == CACHE_VER_NOT_READ) return false; @@ -858,7 +858,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { if (buf.remaining() < 1) return false; - hasPrimary = commState.getBoolean(); + hasPrimary = commState.getBoolean(null); commState.idx++; @@ -867,7 +867,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -875,7 +875,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { keyBytes = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(); + byte[] _val = commState.getByteArray(null); if (_val == BYTE_ARR_NOT_READ) return false; @@ -895,7 +895,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { if (buf.remaining() < 1) return false; - byte op0 = commState.getByte(); + byte op0 = commState.getByte(null); op = GridCacheOperation.fromOrdinal(op0); @@ -905,7 +905,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { if (buf.remaining() < 1) return false; - retval = commState.getBoolean(); + retval = commState.getBoolean(null); commState.idx++; @@ -913,7 +913,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { if (buf.remaining() < 1) return false; - byte syncMode0 = commState.getByte(); + byte syncMode0 = commState.getByte(null); syncMode = GridCacheWriteSynchronizationMode.fromOrdinal(syncMode0); @@ -923,7 +923,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { if (buf.remaining() < 8) return false; - topVer = commState.getLong(); + topVer = commState.getLong(null); commState.idx++; @@ -931,12 +931,12 @@ public void forceTransformBackups(boolean forceTransformBackups) { if (buf.remaining() < 8) return false; - ttl = commState.getLong(); + ttl = commState.getLong(null); commState.idx++; case 16: - GridCacheVersion updateVer0 = commState.getCacheVersion(); + GridCacheVersion updateVer0 = commState.getCacheVersion(null); if (updateVer0 == CACHE_VER_NOT_READ) return false; @@ -950,7 +950,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -958,7 +958,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { valBytes = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheValueBytes _val = commState.getValueBytes(); + GridCacheValueBytes _val = commState.getValueBytes(null); if (_val == VAL_BYTES_NOT_READ) return false; @@ -978,12 +978,12 @@ public void forceTransformBackups(boolean forceTransformBackups) { if (buf.remaining() < 1) return false; - forceTransformBackups = commState.getBoolean(); + forceTransformBackups = commState.getBoolean(null); commState.idx++; case 19: - UUID subjId0 = commState.getUuid(); + UUID subjId0 = commState.getUuid(null); if (subjId0 == UUID_NOT_READ) return false; @@ -996,7 +996,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { if (buf.remaining() < 4) return false; - taskNameHash = commState.getInt(); + taskNameHash = commState.getInt(null); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java index fe16214d796fc..ba683c3f2dddd 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java @@ -396,7 +396,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -404,31 +404,31 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { switch (commState.idx) { case 3: - if (!commState.putByteArray(errBytes)) + if (!commState.putByteArray(null, errBytes)) return false; commState.idx++; case 4: - if (!commState.putByteArray(failedKeysBytes)) + if (!commState.putByteArray(null, failedKeysBytes)) return false; commState.idx++; case 5: - if (!commState.putCacheVersion(futVer)) + if (!commState.putCacheVersion(null, futVer)) return false; commState.idx++; case 6: - if (!commState.putByteArray(remapKeysBytes)) + if (!commState.putByteArray(null, remapKeysBytes)) return false; commState.idx++; case 7: - if (!commState.putByteArray(retValBytes)) + if (!commState.putByteArray(null, retValBytes)) return false; commState.idx++; @@ -436,7 +436,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { case 8: if (nearSkipIdxs != null) { if (commState.it == null) { - if (!commState.putInt(nearSkipIdxs.size())) + if (!commState.putInt(null, nearSkipIdxs.size())) return false; commState.it = nearSkipIdxs.iterator(); @@ -446,7 +446,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putInt((int)commState.cur)) + if (!commState.putInt(null, (int)commState.cur)) return false; commState.cur = NULL; @@ -454,14 +454,14 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 9: - if (!commState.putLong(nearTtl)) + if (!commState.putLong(null, nearTtl)) return false; commState.idx++; @@ -469,7 +469,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { case 10: if (nearValBytes != null) { if (commState.it == null) { - if (!commState.putInt(nearValBytes.size())) + if (!commState.putInt(null, nearValBytes.size())) return false; commState.it = nearValBytes.iterator(); @@ -479,7 +479,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putValueBytes((GridCacheValueBytes)commState.cur)) + if (!commState.putValueBytes(null, (GridCacheValueBytes)commState.cur)) return false; commState.cur = NULL; @@ -487,7 +487,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } @@ -496,7 +496,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { case 11: if (nearValsIdxs != null) { if (commState.it == null) { - if (!commState.putInt(nearValsIdxs.size())) + if (!commState.putInt(null, nearValsIdxs.size())) return false; commState.it = nearValsIdxs.iterator(); @@ -506,7 +506,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putInt((int)commState.cur)) + if (!commState.putInt(null, (int)commState.cur)) return false; commState.cur = NULL; @@ -514,14 +514,14 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 12: - if (!commState.putCacheVersion(nearVer)) + if (!commState.putCacheVersion(null, nearVer)) return false; commState.idx++; @@ -541,7 +541,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { switch (commState.idx) { case 3: - byte[] errBytes0 = commState.getByteArray(); + byte[] errBytes0 = commState.getByteArray(null); if (errBytes0 == BYTE_ARR_NOT_READ) return false; @@ -551,7 +551,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { commState.idx++; case 4: - byte[] failedKeysBytes0 = commState.getByteArray(); + byte[] failedKeysBytes0 = commState.getByteArray(null); if (failedKeysBytes0 == BYTE_ARR_NOT_READ) return false; @@ -561,7 +561,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { commState.idx++; case 5: - GridCacheVersion futVer0 = commState.getCacheVersion(); + GridCacheVersion futVer0 = commState.getCacheVersion(null); if (futVer0 == CACHE_VER_NOT_READ) return false; @@ -571,7 +571,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { commState.idx++; case 6: - byte[] remapKeysBytes0 = commState.getByteArray(); + byte[] remapKeysBytes0 = commState.getByteArray(null); if (remapKeysBytes0 == BYTE_ARR_NOT_READ) return false; @@ -581,7 +581,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { commState.idx++; case 7: - byte[] retValBytes0 = commState.getByteArray(); + byte[] retValBytes0 = commState.getByteArray(null); if (retValBytes0 == BYTE_ARR_NOT_READ) return false; @@ -595,7 +595,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -606,7 +606,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { if (buf.remaining() < 4) return false; - int _val = commState.getInt(); + int _val = commState.getInt(null); nearSkipIdxs.add((Integer)_val); @@ -623,7 +623,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { if (buf.remaining() < 8) return false; - nearTtl = commState.getLong(); + nearTtl = commState.getLong(null); commState.idx++; @@ -632,7 +632,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -640,7 +640,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { nearValBytes = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheValueBytes _val = commState.getValueBytes(); + GridCacheValueBytes _val = commState.getValueBytes(null); if (_val == VAL_BYTES_NOT_READ) return false; @@ -661,7 +661,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -672,7 +672,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { if (buf.remaining() < 4) return false; - int _val = commState.getInt(); + int _val = commState.getInt(null); nearValsIdxs.add((Integer)_val); @@ -686,7 +686,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { commState.idx++; case 12: - GridCacheVersion nearVer0 = commState.getCacheVersion(); + GridCacheVersion nearVer0 = commState.getCacheVersion(null); if (nearVer0 == CACHE_VER_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java index 3bd7d5e40b6c5..30c18cc4904f3 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java @@ -185,7 +185,7 @@ private int keyCount() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -193,7 +193,7 @@ private int keyCount() { switch (commState.idx) { case 3: - if (!commState.putGridUuid(futId)) + if (!commState.putGridUuid(null, futId)) return false; commState.idx++; @@ -201,7 +201,7 @@ private int keyCount() { case 4: if (keyBytes != null) { if (commState.it == null) { - if (!commState.putInt(keyBytes.size())) + if (!commState.putInt(null, keyBytes.size())) return false; commState.it = keyBytes.iterator(); @@ -211,7 +211,7 @@ private int keyCount() { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putByteArray((byte[])commState.cur)) + if (!commState.putByteArray(null, (byte[])commState.cur)) return false; commState.cur = NULL; @@ -219,20 +219,20 @@ private int keyCount() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 5: - if (!commState.putGridUuid(miniId)) + if (!commState.putGridUuid(null, miniId)) return false; commState.idx++; case 6: - if (!commState.putLong(topVer)) + if (!commState.putLong(null, topVer)) return false; commState.idx++; @@ -252,7 +252,7 @@ private int keyCount() { switch (commState.idx) { case 3: - IgniteUuid futId0 = commState.getGridUuid(); + IgniteUuid futId0 = commState.getGridUuid(null); if (futId0 == GRID_UUID_NOT_READ) return false; @@ -266,7 +266,7 @@ private int keyCount() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -274,7 +274,7 @@ private int keyCount() { keyBytes = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(); + byte[] _val = commState.getByteArray(null); if (_val == BYTE_ARR_NOT_READ) return false; @@ -291,7 +291,7 @@ private int keyCount() { commState.idx++; case 5: - IgniteUuid miniId0 = commState.getGridUuid(); + IgniteUuid miniId0 = commState.getGridUuid(null); if (miniId0 == GRID_UUID_NOT_READ) return false; @@ -304,7 +304,7 @@ private int keyCount() { if (buf.remaining() < 8) return false; - topVer = commState.getLong(); + topVer = commState.getLong(null); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java index df1afece38465..e333a956bf57f 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java @@ -189,7 +189,7 @@ public void addInfo(GridCacheEntryInfo info) { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -197,19 +197,19 @@ public void addInfo(GridCacheEntryInfo info) { switch (commState.idx) { case 3: - if (!commState.putGridUuid(futId)) + if (!commState.putGridUuid(null, futId)) return false; commState.idx++; case 4: - if (!commState.putByteArray(infosBytes)) + if (!commState.putByteArray(null, infosBytes)) return false; commState.idx++; case 5: - if (!commState.putGridUuid(miniId)) + if (!commState.putGridUuid(null, miniId)) return false; commState.idx++; @@ -217,7 +217,7 @@ public void addInfo(GridCacheEntryInfo info) { case 6: if (missedKeyBytes != null) { if (commState.it == null) { - if (!commState.putInt(missedKeyBytes.size())) + if (!commState.putInt(null, missedKeyBytes.size())) return false; commState.it = missedKeyBytes.iterator(); @@ -227,7 +227,7 @@ public void addInfo(GridCacheEntryInfo info) { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putByteArray((byte[])commState.cur)) + if (!commState.putByteArray(null, (byte[])commState.cur)) return false; commState.cur = NULL; @@ -235,7 +235,7 @@ public void addInfo(GridCacheEntryInfo info) { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } @@ -256,7 +256,7 @@ public void addInfo(GridCacheEntryInfo info) { switch (commState.idx) { case 3: - IgniteUuid futId0 = commState.getGridUuid(); + IgniteUuid futId0 = commState.getGridUuid(null); if (futId0 == GRID_UUID_NOT_READ) return false; @@ -266,7 +266,7 @@ public void addInfo(GridCacheEntryInfo info) { commState.idx++; case 4: - byte[] infosBytes0 = commState.getByteArray(); + byte[] infosBytes0 = commState.getByteArray(null); if (infosBytes0 == BYTE_ARR_NOT_READ) return false; @@ -276,7 +276,7 @@ public void addInfo(GridCacheEntryInfo info) { commState.idx++; case 5: - IgniteUuid miniId0 = commState.getGridUuid(); + IgniteUuid miniId0 = commState.getGridUuid(null); if (miniId0 == GRID_UUID_NOT_READ) return false; @@ -290,7 +290,7 @@ public void addInfo(GridCacheEntryInfo info) { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -298,7 +298,7 @@ public void addInfo(GridCacheEntryInfo info) { missedKeyBytes = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(); + byte[] _val = commState.getByteArray(null); if (_val == BYTE_ARR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java index 01ceb9d75567b..f77adc5f716f4 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java @@ -215,7 +215,7 @@ void workerId(int workerId) { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -225,7 +225,7 @@ void workerId(int workerId) { case 3: if (parts != null) { if (commState.it == null) { - if (!commState.putInt(parts.size())) + if (!commState.putInt(null, parts.size())) return false; commState.it = parts.iterator(); @@ -235,7 +235,7 @@ void workerId(int workerId) { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putInt((int)commState.cur)) + if (!commState.putInt(null, (int)commState.cur)) return false; commState.cur = NULL; @@ -243,38 +243,38 @@ void workerId(int workerId) { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 4: - if (!commState.putLong(timeout)) + if (!commState.putLong(null, timeout)) return false; commState.idx++; case 5: - if (!commState.putLong(topVer)) + if (!commState.putLong(null, topVer)) return false; commState.idx++; case 6: - if (!commState.putByteArray(topicBytes)) + if (!commState.putByteArray(null, topicBytes)) return false; commState.idx++; case 7: - if (!commState.putLong(updateSeq)) + if (!commState.putLong(null, updateSeq)) return false; commState.idx++; case 8: - if (!commState.putInt(workerId)) + if (!commState.putInt(null, workerId)) return false; commState.idx++; @@ -298,7 +298,7 @@ void workerId(int workerId) { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -309,7 +309,7 @@ void workerId(int workerId) { if (buf.remaining() < 4) return false; - int _val = commState.getInt(); + int _val = commState.getInt(null); parts.add((Integer)_val); @@ -326,7 +326,7 @@ void workerId(int workerId) { if (buf.remaining() < 8) return false; - timeout = commState.getLong(); + timeout = commState.getLong(null); commState.idx++; @@ -334,12 +334,12 @@ void workerId(int workerId) { if (buf.remaining() < 8) return false; - topVer = commState.getLong(); + topVer = commState.getLong(null); commState.idx++; case 6: - byte[] topicBytes0 = commState.getByteArray(); + byte[] topicBytes0 = commState.getByteArray(null); if (topicBytes0 == BYTE_ARR_NOT_READ) return false; @@ -352,7 +352,7 @@ void workerId(int workerId) { if (buf.remaining() < 8) return false; - updateSeq = commState.getLong(); + updateSeq = commState.getLong(null); commState.idx++; @@ -360,7 +360,7 @@ void workerId(int workerId) { if (buf.remaining() < 4) return false; - workerId = commState.getInt(); + workerId = commState.getInt(null); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java index 57c8e525cdb19..bf3b606efe221 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java @@ -300,7 +300,7 @@ public int size() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -308,13 +308,13 @@ public int size() { switch (commState.idx) { case 3: - if (!commState.putBoolean(ack)) + if (!commState.putBoolean(null, ack)) return false; commState.idx++; case 4: - if (!commState.putByteArray(infoBytes)) + if (!commState.putByteArray(null, infoBytes)) return false; commState.idx++; @@ -322,7 +322,7 @@ public int size() { case 5: if (last != null) { if (commState.it == null) { - if (!commState.putInt(last.size())) + if (!commState.putInt(null, last.size())) return false; commState.it = last.iterator(); @@ -332,7 +332,7 @@ public int size() { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putInt((int)commState.cur)) + if (!commState.putInt(null, (int)commState.cur)) return false; commState.cur = NULL; @@ -340,7 +340,7 @@ public int size() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } @@ -349,7 +349,7 @@ public int size() { case 6: if (missed != null) { if (commState.it == null) { - if (!commState.putInt(missed.size())) + if (!commState.putInt(null, missed.size())) return false; commState.it = missed.iterator(); @@ -359,7 +359,7 @@ public int size() { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putInt((int)commState.cur)) + if (!commState.putInt(null, (int)commState.cur)) return false; commState.cur = NULL; @@ -367,20 +367,20 @@ public int size() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 7: - if (!commState.putLong(updateSeq)) + if (!commState.putLong(null, updateSeq)) return false; commState.idx++; case 8: - if (!commState.putInt(workerId)) + if (!commState.putInt(null, workerId)) return false; commState.idx++; @@ -403,12 +403,12 @@ public int size() { if (buf.remaining() < 1) return false; - ack = commState.getBoolean(); + ack = commState.getBoolean(null); commState.idx++; case 4: - byte[] infoBytes0 = commState.getByteArray(); + byte[] infoBytes0 = commState.getByteArray(null); if (infoBytes0 == BYTE_ARR_NOT_READ) return false; @@ -422,7 +422,7 @@ public int size() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -433,7 +433,7 @@ public int size() { if (buf.remaining() < 4) return false; - int _val = commState.getInt(); + int _val = commState.getInt(null); last.add((Integer)_val); @@ -451,7 +451,7 @@ public int size() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -462,7 +462,7 @@ public int size() { if (buf.remaining() < 4) return false; - int _val = commState.getInt(); + int _val = commState.getInt(null); missed.add((Integer)_val); @@ -479,7 +479,7 @@ public int size() { if (buf.remaining() < 8) return false; - updateSeq = commState.getLong(); + updateSeq = commState.getLong(null); commState.idx++; @@ -487,7 +487,7 @@ public int size() { if (buf.remaining() < 4) return false; - workerId = commState.getInt(); + workerId = commState.getInt(null); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsAbstractMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsAbstractMessage.java index 28cb6bb6e61a0..e275f1731e12e 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsAbstractMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsAbstractMessage.java @@ -84,7 +84,7 @@ public GridDhtPartitionExchangeId exchangeId() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -92,13 +92,13 @@ public GridDhtPartitionExchangeId exchangeId() { switch (commState.idx) { case 3: - if (!commState.putDhtPartitionExchangeId(exchId)) + if (!commState.putDhtPartitionExchangeId(null, exchId)) return false; commState.idx++; case 4: - if (!commState.putCacheVersion(lastVer)) + if (!commState.putCacheVersion(null, lastVer)) return false; commState.idx++; @@ -118,7 +118,7 @@ public GridDhtPartitionExchangeId exchangeId() { switch (commState.idx) { case 3: - GridDhtPartitionExchangeId exchId0 = commState.getDhtPartitionExchangeId(); + GridDhtPartitionExchangeId exchId0 = commState.getDhtPartitionExchangeId(null); if (exchId0 == DHT_PART_EXCHANGE_ID_NOT_READ) return false; @@ -128,7 +128,7 @@ public GridDhtPartitionExchangeId exchangeId() { commState.idx++; case 4: - GridCacheVersion lastVer0 = commState.getCacheVersion(); + GridCacheVersion lastVer0 = commState.getCacheVersion(null); if (lastVer0 == CACHE_VER_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java index 68ff1a490aecb..d4d4570ee52a9 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java @@ -165,7 +165,7 @@ public void affinityAssignment(List> affAssignment) { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -173,19 +173,19 @@ public void affinityAssignment(List> affAssignment) { switch (commState.idx) { case 5: - if (!commState.putByteArray(affAssignmentBytes)) + if (!commState.putByteArray(null, affAssignmentBytes)) return false; commState.idx++; case 6: - if (!commState.putByteArray(partsBytes)) + if (!commState.putByteArray(null, partsBytes)) return false; commState.idx++; case 7: - if (!commState.putLong(topVer)) + if (!commState.putLong(null, topVer)) return false; commState.idx++; @@ -205,7 +205,7 @@ public void affinityAssignment(List> affAssignment) { switch (commState.idx) { case 5: - byte[] affAssignmentBytes0 = commState.getByteArray(); + byte[] affAssignmentBytes0 = commState.getByteArray(null); if (affAssignmentBytes0 == BYTE_ARR_NOT_READ) return false; @@ -215,7 +215,7 @@ public void affinityAssignment(List> affAssignment) { commState.idx++; case 6: - byte[] partsBytes0 = commState.getByteArray(); + byte[] partsBytes0 = commState.getByteArray(null); if (partsBytes0 == BYTE_ARR_NOT_READ) return false; @@ -228,7 +228,7 @@ public void affinityAssignment(List> affAssignment) { if (buf.remaining() < 8) return false; - topVer = commState.getLong(); + topVer = commState.getLong(null); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java index 350da089d216f..0671800fad9ab 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java @@ -114,7 +114,7 @@ public Map partitions() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -122,7 +122,7 @@ public Map partitions() { switch (commState.idx) { case 5: - if (!commState.putByteArray(partsBytes)) + if (!commState.putByteArray(null, partsBytes)) return false; commState.idx++; @@ -142,7 +142,7 @@ public Map partitions() { switch (commState.idx) { case 5: - byte[] partsBytes0 = commState.getByteArray(); + byte[] partsBytes0 = commState.getByteArray(null); if (partsBytes0 == BYTE_ARR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleRequest.java index 20152255368d7..853cc513dee6f 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleRequest.java @@ -61,7 +61,7 @@ public GridDhtPartitionsSingleRequest() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearGetRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearGetRequest.java index 12aacb73eeeaf..61815b0d6593e 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearGetRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearGetRequest.java @@ -250,7 +250,7 @@ public IgnitePredicate>[] filter() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -260,7 +260,7 @@ public IgnitePredicate>[] filter() { case 3: if (filterBytes != null) { if (commState.it == null) { - if (!commState.putInt(filterBytes.length)) + if (!commState.putInt(null, filterBytes.length)) return false; commState.it = arrayIterator(filterBytes); @@ -270,7 +270,7 @@ public IgnitePredicate>[] filter() { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putByteArray((byte[])commState.cur)) + if (!commState.putByteArray(null, (byte[])commState.cur)) return false; commState.cur = NULL; @@ -278,14 +278,14 @@ public IgnitePredicate>[] filter() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 4: - if (!commState.putGridUuid(futId)) + if (!commState.putGridUuid(null, futId)) return false; commState.idx++; @@ -293,7 +293,7 @@ public IgnitePredicate>[] filter() { case 5: if (keyBytes != null) { if (commState.it == null) { - if (!commState.putInt(keyBytes.size())) + if (!commState.putInt(null, keyBytes.size())) return false; commState.it = keyBytes.entrySet().iterator(); @@ -306,13 +306,13 @@ public IgnitePredicate>[] filter() { Map.Entry e = (Map.Entry)commState.cur; if (!commState.keyDone) { - if (!commState.putByteArray(e.getKey())) + if (!commState.putByteArray(null, e.getKey())) return false; commState.keyDone = true; } - if (!commState.putBoolean(e.getValue())) + if (!commState.putBoolean(null, e.getValue())) return false; commState.keyDone = false; @@ -322,44 +322,44 @@ public IgnitePredicate>[] filter() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 6: - if (!commState.putGridUuid(miniId)) + if (!commState.putGridUuid(null, miniId)) return false; commState.idx++; case 7: - if (!commState.putBoolean(reload)) + if (!commState.putBoolean(null, reload)) return false; commState.idx++; case 8: - if (!commState.putLong(topVer)) + if (!commState.putLong(null, topVer)) return false; commState.idx++; case 9: - if (!commState.putCacheVersion(ver)) + if (!commState.putCacheVersion(null, ver)) return false; commState.idx++; case 10: - if (!commState.putUuid(subjId)) + if (!commState.putUuid(null, subjId)) return false; commState.idx++; case 11: - if (!commState.putInt(taskNameHash)) + if (!commState.putInt(null, taskNameHash)) return false; commState.idx++; @@ -383,7 +383,7 @@ public IgnitePredicate>[] filter() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -391,7 +391,7 @@ public IgnitePredicate>[] filter() { filterBytes = new byte[commState.readSize][]; for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(); + byte[] _val = commState.getByteArray(null); if (_val == BYTE_ARR_NOT_READ) return false; @@ -408,7 +408,7 @@ public IgnitePredicate>[] filter() { commState.idx++; case 4: - IgniteUuid futId0 = commState.getGridUuid(); + IgniteUuid futId0 = commState.getGridUuid(null); if (futId0 == GRID_UUID_NOT_READ) return false; @@ -422,7 +422,7 @@ public IgnitePredicate>[] filter() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -431,7 +431,7 @@ public IgnitePredicate>[] filter() { for (int i = commState.readItems; i < commState.readSize; i++) { if (!commState.keyDone) { - byte[] _val = commState.getByteArray(); + byte[] _val = commState.getByteArray(null); if (_val == BYTE_ARR_NOT_READ) return false; @@ -443,7 +443,7 @@ public IgnitePredicate>[] filter() { if (buf.remaining() < 1) return false; - boolean _val = commState.getBoolean(); + boolean _val = commState.getBoolean(null); keyBytes.put((byte[])commState.cur, _val); @@ -460,7 +460,7 @@ public IgnitePredicate>[] filter() { commState.idx++; case 6: - IgniteUuid miniId0 = commState.getGridUuid(); + IgniteUuid miniId0 = commState.getGridUuid(null); if (miniId0 == GRID_UUID_NOT_READ) return false; @@ -473,7 +473,7 @@ public IgnitePredicate>[] filter() { if (buf.remaining() < 1) return false; - reload = commState.getBoolean(); + reload = commState.getBoolean(null); commState.idx++; @@ -481,12 +481,12 @@ public IgnitePredicate>[] filter() { if (buf.remaining() < 8) return false; - topVer = commState.getLong(); + topVer = commState.getLong(null); commState.idx++; case 9: - GridCacheVersion ver0 = commState.getCacheVersion(); + GridCacheVersion ver0 = commState.getCacheVersion(null); if (ver0 == CACHE_VER_NOT_READ) return false; @@ -496,7 +496,7 @@ public IgnitePredicate>[] filter() { commState.idx++; case 10: - UUID subjId0 = commState.getUuid(); + UUID subjId0 = commState.getUuid(null); if (subjId0 == UUID_NOT_READ) return false; @@ -509,7 +509,7 @@ public IgnitePredicate>[] filter() { if (buf.remaining() < 4) return false; - taskNameHash = commState.getInt(); + taskNameHash = commState.getInt(null); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearGetResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearGetResponse.java index 5d171bc131301..1eba548208db0 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearGetResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearGetResponse.java @@ -226,7 +226,7 @@ public void error(Throwable err) { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -234,19 +234,19 @@ public void error(Throwable err) { switch (commState.idx) { case 3: - if (!commState.putByteArray(entriesBytes)) + if (!commState.putByteArray(null, entriesBytes)) return false; commState.idx++; case 4: - if (!commState.putByteArray(errBytes)) + if (!commState.putByteArray(null, errBytes)) return false; commState.idx++; case 5: - if (!commState.putGridUuid(futId)) + if (!commState.putGridUuid(null, futId)) return false; commState.idx++; @@ -254,7 +254,7 @@ public void error(Throwable err) { case 6: if (invalidParts != null) { if (commState.it == null) { - if (!commState.putInt(invalidParts.size())) + if (!commState.putInt(null, invalidParts.size())) return false; commState.it = invalidParts.iterator(); @@ -264,7 +264,7 @@ public void error(Throwable err) { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putInt((int)commState.cur)) + if (!commState.putInt(null, (int)commState.cur)) return false; commState.cur = NULL; @@ -272,26 +272,26 @@ public void error(Throwable err) { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 7: - if (!commState.putGridUuid(miniId)) + if (!commState.putGridUuid(null, miniId)) return false; commState.idx++; case 8: - if (!commState.putLong(topVer)) + if (!commState.putLong(null, topVer)) return false; commState.idx++; case 9: - if (!commState.putCacheVersion(ver)) + if (!commState.putCacheVersion(null, ver)) return false; commState.idx++; @@ -311,7 +311,7 @@ public void error(Throwable err) { switch (commState.idx) { case 3: - byte[] entriesBytes0 = commState.getByteArray(); + byte[] entriesBytes0 = commState.getByteArray(null); if (entriesBytes0 == BYTE_ARR_NOT_READ) return false; @@ -321,7 +321,7 @@ public void error(Throwable err) { commState.idx++; case 4: - byte[] errBytes0 = commState.getByteArray(); + byte[] errBytes0 = commState.getByteArray(null); if (errBytes0 == BYTE_ARR_NOT_READ) return false; @@ -331,7 +331,7 @@ public void error(Throwable err) { commState.idx++; case 5: - IgniteUuid futId0 = commState.getGridUuid(); + IgniteUuid futId0 = commState.getGridUuid(null); if (futId0 == GRID_UUID_NOT_READ) return false; @@ -345,7 +345,7 @@ public void error(Throwable err) { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -356,7 +356,7 @@ public void error(Throwable err) { if (buf.remaining() < 4) return false; - int _val = commState.getInt(); + int _val = commState.getInt(null); invalidParts.add((Integer)_val); @@ -370,7 +370,7 @@ public void error(Throwable err) { commState.idx++; case 7: - IgniteUuid miniId0 = commState.getGridUuid(); + IgniteUuid miniId0 = commState.getGridUuid(null); if (miniId0 == GRID_UUID_NOT_READ) return false; @@ -383,12 +383,12 @@ public void error(Throwable err) { if (buf.remaining() < 8) return false; - topVer = commState.getLong(); + topVer = commState.getLong(null); commState.idx++; case 9: - GridCacheVersion ver0 = commState.getCacheVersion(); + GridCacheVersion ver0 = commState.getCacheVersion(null); if (ver0 == CACHE_VER_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearLockRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearLockRequest.java index d9217d5c0face..6f80471b96a25 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearLockRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearLockRequest.java @@ -327,7 +327,7 @@ public GridCacheVersion dhtVersion(int idx) { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -337,7 +337,7 @@ public GridCacheVersion dhtVersion(int idx) { case 24: if (dhtVers != null) { if (commState.it == null) { - if (!commState.putInt(dhtVers.length)) + if (!commState.putInt(null, dhtVers.length)) return false; commState.it = arrayIterator(dhtVers); @@ -347,7 +347,7 @@ public GridCacheVersion dhtVersion(int idx) { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putCacheVersion((GridCacheVersion)commState.cur)) + if (!commState.putCacheVersion(null, (GridCacheVersion)commState.cur)) return false; commState.cur = NULL; @@ -355,7 +355,7 @@ public GridCacheVersion dhtVersion(int idx) { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } @@ -364,7 +364,7 @@ public GridCacheVersion dhtVersion(int idx) { case 25: if (filterBytes != null) { if (commState.it == null) { - if (!commState.putInt(filterBytes.length)) + if (!commState.putInt(null, filterBytes.length)) return false; commState.it = arrayIterator(filterBytes); @@ -374,7 +374,7 @@ public GridCacheVersion dhtVersion(int idx) { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putByteArray((byte[])commState.cur)) + if (!commState.putByteArray(null, (byte[])commState.cur)) return false; commState.cur = NULL; @@ -382,56 +382,56 @@ public GridCacheVersion dhtVersion(int idx) { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 26: - if (!commState.putBoolean(implicitSingleTx)) + if (!commState.putBoolean(null, implicitSingleTx)) return false; commState.idx++; case 27: - if (!commState.putBoolean(implicitTx)) + if (!commState.putBoolean(null, implicitTx)) return false; commState.idx++; case 28: - if (!commState.putGridUuid(miniId)) + if (!commState.putGridUuid(null, miniId)) return false; commState.idx++; case 29: - if (!commState.putBoolean(onePhaseCommit)) + if (!commState.putBoolean(null, onePhaseCommit)) return false; commState.idx++; case 30: - if (!commState.putLong(topVer)) + if (!commState.putLong(null, topVer)) return false; commState.idx++; case 31: - if (!commState.putUuid(subjId)) + if (!commState.putUuid(null, subjId)) return false; commState.idx++; case 32: - if (!commState.putInt(taskNameHash)) + if (!commState.putInt(null, taskNameHash)) return false; commState.idx++; case 33: - if (!commState.putBoolean(hasTransforms)) + if (!commState.putBoolean(null, hasTransforms)) return false; commState.idx++; @@ -455,7 +455,7 @@ public GridCacheVersion dhtVersion(int idx) { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -463,7 +463,7 @@ public GridCacheVersion dhtVersion(int idx) { dhtVers = new GridCacheVersion[commState.readSize]; for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheVersion _val = commState.getCacheVersion(); + GridCacheVersion _val = commState.getCacheVersion(null); if (_val == CACHE_VER_NOT_READ) return false; @@ -484,7 +484,7 @@ public GridCacheVersion dhtVersion(int idx) { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -492,7 +492,7 @@ public GridCacheVersion dhtVersion(int idx) { filterBytes = new byte[commState.readSize][]; for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(); + byte[] _val = commState.getByteArray(null); if (_val == BYTE_ARR_NOT_READ) return false; @@ -512,7 +512,7 @@ public GridCacheVersion dhtVersion(int idx) { if (buf.remaining() < 1) return false; - implicitSingleTx = commState.getBoolean(); + implicitSingleTx = commState.getBoolean(null); commState.idx++; @@ -520,12 +520,12 @@ public GridCacheVersion dhtVersion(int idx) { if (buf.remaining() < 1) return false; - implicitTx = commState.getBoolean(); + implicitTx = commState.getBoolean(null); commState.idx++; case 28: - IgniteUuid miniId0 = commState.getGridUuid(); + IgniteUuid miniId0 = commState.getGridUuid(null); if (miniId0 == GRID_UUID_NOT_READ) return false; @@ -538,7 +538,7 @@ public GridCacheVersion dhtVersion(int idx) { if (buf.remaining() < 1) return false; - onePhaseCommit = commState.getBoolean(); + onePhaseCommit = commState.getBoolean(null); commState.idx++; @@ -546,12 +546,12 @@ public GridCacheVersion dhtVersion(int idx) { if (buf.remaining() < 8) return false; - topVer = commState.getLong(); + topVer = commState.getLong(null); commState.idx++; case 31: - UUID subjId0 = commState.getUuid(); + UUID subjId0 = commState.getUuid(null); if (subjId0 == UUID_NOT_READ) return false; @@ -564,7 +564,7 @@ public GridCacheVersion dhtVersion(int idx) { if (buf.remaining() < 4) return false; - taskNameHash = commState.getInt(); + taskNameHash = commState.getInt(null); commState.idx++; @@ -572,7 +572,7 @@ public GridCacheVersion dhtVersion(int idx) { if (buf.remaining() < 1) return false; - hasTransforms = commState.getBoolean(); + hasTransforms = commState.getBoolean(null); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearLockResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearLockResponse.java index 7a0c2fd715c56..f5476fc018ff7 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearLockResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearLockResponse.java @@ -202,7 +202,7 @@ public void addValueBytes( return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -212,7 +212,7 @@ public void addValueBytes( case 11: if (dhtVers != null) { if (commState.it == null) { - if (!commState.putInt(dhtVers.length)) + if (!commState.putInt(null, dhtVers.length)) return false; commState.it = arrayIterator(dhtVers); @@ -222,7 +222,7 @@ public void addValueBytes( if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putCacheVersion((GridCacheVersion)commState.cur)) + if (!commState.putCacheVersion(null, (GridCacheVersion)commState.cur)) return false; commState.cur = NULL; @@ -230,14 +230,14 @@ public void addValueBytes( commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 12: - if (!commState.putBooleanArray(filterRes)) + if (!commState.putBooleanArray(null, filterRes)) return false; commState.idx++; @@ -245,7 +245,7 @@ public void addValueBytes( case 13: if (mappedVers != null) { if (commState.it == null) { - if (!commState.putInt(mappedVers.length)) + if (!commState.putInt(null, mappedVers.length)) return false; commState.it = arrayIterator(mappedVers); @@ -255,7 +255,7 @@ public void addValueBytes( if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putCacheVersion((GridCacheVersion)commState.cur)) + if (!commState.putCacheVersion(null, (GridCacheVersion)commState.cur)) return false; commState.cur = NULL; @@ -263,14 +263,14 @@ public void addValueBytes( commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 14: - if (!commState.putGridUuid(miniId)) + if (!commState.putGridUuid(null, miniId)) return false; commState.idx++; @@ -278,7 +278,7 @@ public void addValueBytes( case 15: if (pending != null) { if (commState.it == null) { - if (!commState.putInt(pending.size())) + if (!commState.putInt(null, pending.size())) return false; commState.it = pending.iterator(); @@ -288,7 +288,7 @@ public void addValueBytes( if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putCacheVersion((GridCacheVersion)commState.cur)) + if (!commState.putCacheVersion(null, (GridCacheVersion)commState.cur)) return false; commState.cur = NULL; @@ -296,7 +296,7 @@ public void addValueBytes( commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } @@ -321,7 +321,7 @@ public void addValueBytes( if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -329,7 +329,7 @@ public void addValueBytes( dhtVers = new GridCacheVersion[commState.readSize]; for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheVersion _val = commState.getCacheVersion(); + GridCacheVersion _val = commState.getCacheVersion(null); if (_val == CACHE_VER_NOT_READ) return false; @@ -346,7 +346,7 @@ public void addValueBytes( commState.idx++; case 12: - boolean[] filterRes0 = commState.getBooleanArray(); + boolean[] filterRes0 = commState.getBooleanArray(null); if (filterRes0 == BOOLEAN_ARR_NOT_READ) return false; @@ -360,7 +360,7 @@ public void addValueBytes( if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -368,7 +368,7 @@ public void addValueBytes( mappedVers = new GridCacheVersion[commState.readSize]; for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheVersion _val = commState.getCacheVersion(); + GridCacheVersion _val = commState.getCacheVersion(null); if (_val == CACHE_VER_NOT_READ) return false; @@ -385,7 +385,7 @@ public void addValueBytes( commState.idx++; case 14: - IgniteUuid miniId0 = commState.getGridUuid(); + IgniteUuid miniId0 = commState.getGridUuid(null); if (miniId0 == GRID_UUID_NOT_READ) return false; @@ -399,7 +399,7 @@ public void addValueBytes( if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -407,7 +407,7 @@ public void addValueBytes( pending = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheVersion _val = commState.getCacheVersion(); + GridCacheVersion _val = commState.getCacheVersion(null); if (_val == CACHE_VER_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxFinishRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxFinishRequest.java index 90cdfe6764aa8..b63b03886b309 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxFinishRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxFinishRequest.java @@ -168,7 +168,7 @@ public int taskNameHash() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -176,31 +176,31 @@ public int taskNameHash() { switch (commState.idx) { case 20: - if (!commState.putBoolean(explicitLock)) + if (!commState.putBoolean(null, explicitLock)) return false; commState.idx++; case 21: - if (!commState.putGridUuid(miniId)) + if (!commState.putGridUuid(null, miniId)) return false; commState.idx++; case 22: - if (!commState.putLong(topVer)) + if (!commState.putLong(null, topVer)) return false; commState.idx++; case 23: - if (!commState.putUuid(subjId)) + if (!commState.putUuid(null, subjId)) return false; commState.idx++; case 24: - if (!commState.putInt(taskNameHash)) + if (!commState.putInt(null, taskNameHash)) return false; commState.idx++; @@ -223,12 +223,12 @@ public int taskNameHash() { if (buf.remaining() < 1) return false; - explicitLock = commState.getBoolean(); + explicitLock = commState.getBoolean(null); commState.idx++; case 21: - IgniteUuid miniId0 = commState.getGridUuid(); + IgniteUuid miniId0 = commState.getGridUuid(null); if (miniId0 == GRID_UUID_NOT_READ) return false; @@ -241,12 +241,12 @@ public int taskNameHash() { if (buf.remaining() < 8) return false; - topVer = commState.getLong(); + topVer = commState.getLong(null); commState.idx++; case 23: - UUID subjId0 = commState.getUuid(); + UUID subjId0 = commState.getUuid(null); if (subjId0 == UUID_NOT_READ) return false; @@ -259,7 +259,7 @@ public int taskNameHash() { if (buf.remaining() < 4) return false; - taskNameHash = commState.getInt(); + taskNameHash = commState.getInt(null); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxFinishResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxFinishResponse.java index 52825bcca90ee..b09310634a910 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxFinishResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxFinishResponse.java @@ -135,7 +135,7 @@ public long threadId() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -143,19 +143,19 @@ public long threadId() { switch (commState.idx) { case 5: - if (!commState.putByteArray(errBytes)) + if (!commState.putByteArray(null, errBytes)) return false; commState.idx++; case 6: - if (!commState.putGridUuid(miniId)) + if (!commState.putGridUuid(null, miniId)) return false; commState.idx++; case 7: - if (!commState.putLong(nearThreadId)) + if (!commState.putLong(null, nearThreadId)) return false; commState.idx++; @@ -175,7 +175,7 @@ public long threadId() { switch (commState.idx) { case 5: - byte[] errBytes0 = commState.getByteArray(); + byte[] errBytes0 = commState.getByteArray(null); if (errBytes0 == BYTE_ARR_NOT_READ) return false; @@ -185,7 +185,7 @@ public long threadId() { commState.idx++; case 6: - IgniteUuid miniId0 = commState.getGridUuid(); + IgniteUuid miniId0 = commState.getGridUuid(null); if (miniId0 == GRID_UUID_NOT_READ) return false; @@ -198,7 +198,7 @@ public long threadId() { if (buf.remaining() < 8) return false; - nearThreadId = commState.getLong(); + nearThreadId = commState.getLong(null); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareRequest.java index 30b7aef42f2d9..7decc5ebf130a 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareRequest.java @@ -235,7 +235,7 @@ private Collection> cloneEntries(Collection> cloneEntries(Collection> cloneEntries(Collection> cloneEntries(Collection> cloneEntries(Collection> cloneEntries(Collection> cloneEntries(Collection> cloneEntries(Collection= 0) { @@ -356,7 +356,7 @@ private Collection> cloneEntries(Collection(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - UUID _val = commState.getUuid(); + UUID _val = commState.getUuid(null); if (_val == UUID_NOT_READ) return false; @@ -373,7 +373,7 @@ private Collection> cloneEntries(Collection> cloneEntries(Collection> cloneEntries(Collection> cloneEntries(Collection invalidPartitions() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -255,13 +255,13 @@ public Collection invalidPartitions() { switch (commState.idx) { case 10: - if (!commState.putCacheVersion(dhtVer)) + if (!commState.putCacheVersion(null, dhtVer)) return false; commState.idx++; case 11: - if (!commState.putGridUuid(futId)) + if (!commState.putGridUuid(null, futId)) return false; commState.idx++; @@ -269,7 +269,7 @@ public Collection invalidPartitions() { case 12: if (invalidParts != null) { if (commState.it == null) { - if (!commState.putInt(invalidParts.size())) + if (!commState.putInt(null, invalidParts.size())) return false; commState.it = invalidParts.iterator(); @@ -279,7 +279,7 @@ public Collection invalidPartitions() { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putInt((int)commState.cur)) + if (!commState.putInt(null, (int)commState.cur)) return false; commState.cur = NULL; @@ -287,14 +287,14 @@ public Collection invalidPartitions() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 13: - if (!commState.putGridUuid(miniId)) + if (!commState.putGridUuid(null, miniId)) return false; commState.idx++; @@ -302,7 +302,7 @@ public Collection invalidPartitions() { case 14: if (ownedValsBytes != null) { if (commState.it == null) { - if (!commState.putInt(ownedValsBytes.size())) + if (!commState.putInt(null, ownedValsBytes.size())) return false; commState.it = ownedValsBytes.iterator(); @@ -312,7 +312,7 @@ public Collection invalidPartitions() { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putByteArray((byte[])commState.cur)) + if (!commState.putByteArray(null, (byte[])commState.cur)) return false; commState.cur = NULL; @@ -320,7 +320,7 @@ public Collection invalidPartitions() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } @@ -329,7 +329,7 @@ public Collection invalidPartitions() { case 15: if (pending != null) { if (commState.it == null) { - if (!commState.putInt(pending.size())) + if (!commState.putInt(null, pending.size())) return false; commState.it = pending.iterator(); @@ -339,7 +339,7 @@ public Collection invalidPartitions() { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putCacheVersion((GridCacheVersion)commState.cur)) + if (!commState.putCacheVersion(null, (GridCacheVersion)commState.cur)) return false; commState.cur = NULL; @@ -347,7 +347,7 @@ public Collection invalidPartitions() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } @@ -368,7 +368,7 @@ public Collection invalidPartitions() { switch (commState.idx) { case 10: - GridCacheVersion dhtVer0 = commState.getCacheVersion(); + GridCacheVersion dhtVer0 = commState.getCacheVersion(null); if (dhtVer0 == CACHE_VER_NOT_READ) return false; @@ -378,7 +378,7 @@ public Collection invalidPartitions() { commState.idx++; case 11: - IgniteUuid futId0 = commState.getGridUuid(); + IgniteUuid futId0 = commState.getGridUuid(null); if (futId0 == GRID_UUID_NOT_READ) return false; @@ -392,7 +392,7 @@ public Collection invalidPartitions() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -403,7 +403,7 @@ public Collection invalidPartitions() { if (buf.remaining() < 4) return false; - int _val = commState.getInt(); + int _val = commState.getInt(null); invalidParts.add((Integer)_val); @@ -417,7 +417,7 @@ public Collection invalidPartitions() { commState.idx++; case 13: - IgniteUuid miniId0 = commState.getGridUuid(); + IgniteUuid miniId0 = commState.getGridUuid(null); if (miniId0 == GRID_UUID_NOT_READ) return false; @@ -431,7 +431,7 @@ public Collection invalidPartitions() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -439,7 +439,7 @@ public Collection invalidPartitions() { ownedValsBytes = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(); + byte[] _val = commState.getByteArray(null); if (_val == BYTE_ARR_NOT_READ) return false; @@ -460,7 +460,7 @@ public Collection invalidPartitions() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -468,7 +468,7 @@ public Collection invalidPartitions() { pending = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheVersion _val = commState.getCacheVersion(); + GridCacheVersion _val = commState.getCacheVersion(null); if (_val == CACHE_VER_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearUnlockRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearUnlockRequest.java index 818ba669c76e9..1e2fe21a3b61f 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearUnlockRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearUnlockRequest.java @@ -63,7 +63,7 @@ public GridNearUnlockRequest(int cacheId, int keyCnt) { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueryRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueryRequest.java index 2abaae240b9d6..4318df6b7e6e6 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueryRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueryRequest.java @@ -486,7 +486,7 @@ public int taskHash() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -494,115 +494,115 @@ public int taskHash() { switch (commState.idx) { case 3: - if (!commState.putBoolean(all)) + if (!commState.putBoolean(null, all)) return false; commState.idx++; case 4: - if (!commState.putByteArray(argsBytes)) + if (!commState.putByteArray(null, argsBytes)) return false; commState.idx++; case 5: - if (!commState.putString(cacheName)) + if (!commState.putString(null, cacheName)) return false; commState.idx++; case 6: - if (!commState.putBoolean(cancel)) + if (!commState.putBoolean(null, cancel)) return false; commState.idx++; case 7: - if (!commState.putString(clause)) + if (!commState.putString(null, clause)) return false; commState.idx++; case 8: - if (!commState.putString(clsName)) + if (!commState.putString(null, clsName)) return false; commState.idx++; case 9: - if (!commState.putBoolean(fields)) + if (!commState.putBoolean(null, fields)) return false; commState.idx++; case 10: - if (!commState.putLong(id)) + if (!commState.putLong(null, id)) return false; commState.idx++; case 11: - if (!commState.putBoolean(incBackups)) + if (!commState.putBoolean(null, incBackups)) return false; commState.idx++; case 12: - if (!commState.putBoolean(incMeta)) + if (!commState.putBoolean(null, incMeta)) return false; commState.idx++; case 13: - if (!commState.putByteArray(keyValFilterBytes)) + if (!commState.putByteArray(null, keyValFilterBytes)) return false; commState.idx++; case 14: - if (!commState.putInt(pageSize)) + if (!commState.putInt(null, pageSize)) return false; commState.idx++; case 15: - if (!commState.putByteArray(prjFilterBytes)) + if (!commState.putByteArray(null, prjFilterBytes)) return false; commState.idx++; case 16: - if (!commState.putByteArray(rdcBytes)) + if (!commState.putByteArray(null, rdcBytes)) return false; commState.idx++; case 17: - if (!commState.putByteArray(transBytes)) + if (!commState.putByteArray(null, transBytes)) return false; commState.idx++; case 18: - if (!commState.putEnum(type)) + if (!commState.putEnum(null, type)) return false; commState.idx++; case 19: - if (!commState.putBoolean(keepPortable)) + if (!commState.putBoolean(null, keepPortable)) return false; commState.idx++; case 20: - if (!commState.putUuid(subjId)) + if (!commState.putUuid(null, subjId)) return false; commState.idx++; case 21: - if (!commState.putInt(taskHash)) + if (!commState.putInt(null, taskHash)) return false; commState.idx++; @@ -625,12 +625,12 @@ public int taskHash() { if (buf.remaining() < 1) return false; - all = commState.getBoolean(); + all = commState.getBoolean(null); commState.idx++; case 4: - byte[] argsBytes0 = commState.getByteArray(); + byte[] argsBytes0 = commState.getByteArray(null); if (argsBytes0 == BYTE_ARR_NOT_READ) return false; @@ -640,7 +640,7 @@ public int taskHash() { commState.idx++; case 5: - String cacheName0 = commState.getString(); + String cacheName0 = commState.getString(null); if (cacheName0 == STR_NOT_READ) return false; @@ -653,12 +653,12 @@ public int taskHash() { if (buf.remaining() < 1) return false; - cancel = commState.getBoolean(); + cancel = commState.getBoolean(null); commState.idx++; case 7: - String clause0 = commState.getString(); + String clause0 = commState.getString(null); if (clause0 == STR_NOT_READ) return false; @@ -668,7 +668,7 @@ public int taskHash() { commState.idx++; case 8: - String clsName0 = commState.getString(); + String clsName0 = commState.getString(null); if (clsName0 == STR_NOT_READ) return false; @@ -681,7 +681,7 @@ public int taskHash() { if (buf.remaining() < 1) return false; - fields = commState.getBoolean(); + fields = commState.getBoolean(null); commState.idx++; @@ -689,7 +689,7 @@ public int taskHash() { if (buf.remaining() < 8) return false; - id = commState.getLong(); + id = commState.getLong(null); commState.idx++; @@ -697,7 +697,7 @@ public int taskHash() { if (buf.remaining() < 1) return false; - incBackups = commState.getBoolean(); + incBackups = commState.getBoolean(null); commState.idx++; @@ -705,12 +705,12 @@ public int taskHash() { if (buf.remaining() < 1) return false; - incMeta = commState.getBoolean(); + incMeta = commState.getBoolean(null); commState.idx++; case 13: - byte[] keyValFilterBytes0 = commState.getByteArray(); + byte[] keyValFilterBytes0 = commState.getByteArray(null); if (keyValFilterBytes0 == BYTE_ARR_NOT_READ) return false; @@ -723,12 +723,12 @@ public int taskHash() { if (buf.remaining() < 4) return false; - pageSize = commState.getInt(); + pageSize = commState.getInt(null); commState.idx++; case 15: - byte[] prjFilterBytes0 = commState.getByteArray(); + byte[] prjFilterBytes0 = commState.getByteArray(null); if (prjFilterBytes0 == BYTE_ARR_NOT_READ) return false; @@ -738,7 +738,7 @@ public int taskHash() { commState.idx++; case 16: - byte[] rdcBytes0 = commState.getByteArray(); + byte[] rdcBytes0 = commState.getByteArray(null); if (rdcBytes0 == BYTE_ARR_NOT_READ) return false; @@ -748,7 +748,7 @@ public int taskHash() { commState.idx++; case 17: - byte[] transBytes0 = commState.getByteArray(); + byte[] transBytes0 = commState.getByteArray(null); if (transBytes0 == BYTE_ARR_NOT_READ) return false; @@ -761,7 +761,7 @@ public int taskHash() { if (buf.remaining() < 1) return false; - byte type0 = commState.getByte(); + byte type0 = commState.getByte(null); type = GridCacheQueryType.fromOrdinal(type0); @@ -771,12 +771,12 @@ public int taskHash() { if (buf.remaining() < 1) return false; - keepPortable = commState.getBoolean(); + keepPortable = commState.getBoolean(null); commState.idx++; case 20: - UUID subjId0 = commState.getUuid(); + UUID subjId0 = commState.getUuid(null); if (subjId0 == UUID_NOT_READ) return false; @@ -789,7 +789,7 @@ public int taskHash() { if (buf.remaining() < 4) return false; - taskHash = commState.getInt(); + taskHash = commState.getInt(null); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueryResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueryResponse.java index caf783cdc1c3f..0254c6d2983ed 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueryResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueryResponse.java @@ -229,7 +229,7 @@ public boolean fields() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -239,7 +239,7 @@ public boolean fields() { case 3: if (dataBytes != null) { if (commState.it == null) { - if (!commState.putInt(dataBytes.size())) + if (!commState.putInt(null, dataBytes.size())) return false; commState.it = dataBytes.iterator(); @@ -249,7 +249,7 @@ public boolean fields() { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putByteArray((byte[])commState.cur)) + if (!commState.putByteArray(null, (byte[])commState.cur)) return false; commState.cur = NULL; @@ -257,26 +257,26 @@ public boolean fields() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 4: - if (!commState.putByteArray(errBytes)) + if (!commState.putByteArray(null, errBytes)) return false; commState.idx++; case 5: - if (!commState.putBoolean(fields)) + if (!commState.putBoolean(null, fields)) return false; commState.idx++; case 6: - if (!commState.putBoolean(finished)) + if (!commState.putBoolean(null, finished)) return false; commState.idx++; @@ -284,7 +284,7 @@ public boolean fields() { case 7: if (metaDataBytes != null) { if (commState.it == null) { - if (!commState.putInt(metaDataBytes.size())) + if (!commState.putInt(null, metaDataBytes.size())) return false; commState.it = metaDataBytes.iterator(); @@ -294,7 +294,7 @@ public boolean fields() { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putByteArray((byte[])commState.cur)) + if (!commState.putByteArray(null, (byte[])commState.cur)) return false; commState.cur = NULL; @@ -302,14 +302,14 @@ public boolean fields() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 8: - if (!commState.putLong(reqId)) + if (!commState.putLong(null, reqId)) return false; commState.idx++; @@ -333,7 +333,7 @@ public boolean fields() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -341,7 +341,7 @@ public boolean fields() { dataBytes = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(); + byte[] _val = commState.getByteArray(null); if (_val == BYTE_ARR_NOT_READ) return false; @@ -358,7 +358,7 @@ public boolean fields() { commState.idx++; case 4: - byte[] errBytes0 = commState.getByteArray(); + byte[] errBytes0 = commState.getByteArray(null); if (errBytes0 == BYTE_ARR_NOT_READ) return false; @@ -371,7 +371,7 @@ public boolean fields() { if (buf.remaining() < 1) return false; - fields = commState.getBoolean(); + fields = commState.getBoolean(null); commState.idx++; @@ -379,7 +379,7 @@ public boolean fields() { if (buf.remaining() < 1) return false; - finished = commState.getBoolean(); + finished = commState.getBoolean(null); commState.idx++; @@ -388,7 +388,7 @@ public boolean fields() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -396,7 +396,7 @@ public boolean fields() { metaDataBytes = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(); + byte[] _val = commState.getByteArray(null); if (_val == BYTE_ARR_NOT_READ) return false; @@ -416,7 +416,7 @@ public boolean fields() { if (buf.remaining() < 8) return false; - reqId = commState.getLong(); + reqId = commState.getLong(null); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/clock/GridClockDeltaSnapshotMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/clock/GridClockDeltaSnapshotMessage.java index 28bddd82d6566..f3a61c8a4a165 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/clock/GridClockDeltaSnapshotMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/clock/GridClockDeltaSnapshotMessage.java @@ -87,7 +87,7 @@ public Map deltas() { commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -97,7 +97,7 @@ public Map deltas() { case 0: if (deltas != null) { if (commState.it == null) { - if (!commState.putInt(deltas.size())) + if (!commState.putInt(null, deltas.size())) return false; commState.it = deltas.entrySet().iterator(); @@ -110,13 +110,13 @@ public Map deltas() { Map.Entry e = (Map.Entry)commState.cur; if (!commState.keyDone) { - if (!commState.putUuid(e.getKey())) + if (!commState.putUuid(null, e.getKey())) return false; commState.keyDone = true; } - if (!commState.putLong(e.getValue())) + if (!commState.putLong(null, e.getValue())) return false; commState.keyDone = false; @@ -126,14 +126,14 @@ public Map deltas() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 1: - if (!commState.putClockDeltaVersion(snapVer)) + if (!commState.putClockDeltaVersion(null, snapVer)) return false; commState.idx++; @@ -154,7 +154,7 @@ public Map deltas() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -163,7 +163,7 @@ public Map deltas() { for (int i = commState.readItems; i < commState.readSize; i++) { if (!commState.keyDone) { - UUID _val = commState.getUuid(); + UUID _val = commState.getUuid(null); if (_val == UUID_NOT_READ) return false; @@ -175,7 +175,7 @@ public Map deltas() { if (buf.remaining() < 8) return false; - long _val = commState.getLong(); + long _val = commState.getLong(null); deltas.put((UUID)commState.cur, _val); @@ -192,7 +192,7 @@ public Map deltas() { commState.idx++; case 1: - GridClockDeltaVersion snapVer0 = commState.getClockDeltaVersion(); + GridClockDeltaVersion snapVer0 = commState.getClockDeltaVersion(null); if (snapVer0 == CLOCK_DELTA_VER_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/continuous/GridContinuousMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/continuous/GridContinuousMessage.java index 09b717162a04e..e87e972912a2a 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/continuous/GridContinuousMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/continuous/GridContinuousMessage.java @@ -129,7 +129,7 @@ public void dataBytes(byte[] dataBytes) { commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -137,19 +137,19 @@ public void dataBytes(byte[] dataBytes) { switch (commState.idx) { case 0: - if (!commState.putByteArray(dataBytes)) + if (!commState.putByteArray(null, dataBytes)) return false; commState.idx++; case 1: - if (!commState.putUuid(routineId)) + if (!commState.putUuid(null, routineId)) return false; commState.idx++; case 2: - if (!commState.putEnum(type)) + if (!commState.putEnum(null, type)) return false; commState.idx++; @@ -166,7 +166,7 @@ public void dataBytes(byte[] dataBytes) { switch (commState.idx) { case 0: - byte[] dataBytes0 = commState.getByteArray(); + byte[] dataBytes0 = commState.getByteArray(null); if (dataBytes0 == BYTE_ARR_NOT_READ) return false; @@ -176,7 +176,7 @@ public void dataBytes(byte[] dataBytes) { commState.idx++; case 1: - UUID routineId0 = commState.getUuid(); + UUID routineId0 = commState.getUuid(null); if (routineId0 == UUID_NOT_READ) return false; @@ -189,7 +189,7 @@ public void dataBytes(byte[] dataBytes) { if (buf.remaining() < 1) return false; - byte type0 = commState.getByte(); + byte type0 = commState.getByte(null); type = GridContinuousMessageType.fromOrdinal(type0); diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/dataload/GridDataLoadRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/dataload/GridDataLoadRequest.java index efaa1530fe086..781063342396c 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/dataload/GridDataLoadRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/dataload/GridDataLoadRequest.java @@ -206,7 +206,7 @@ public boolean forceLocalDeployment() { commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -214,37 +214,37 @@ public boolean forceLocalDeployment() { switch (commState.idx) { case 0: - if (!commState.putString(cacheName)) + if (!commState.putString(null, cacheName)) return false; commState.idx++; case 1: - if (!commState.putGridUuid(clsLdrId)) + if (!commState.putGridUuid(null, clsLdrId)) return false; commState.idx++; case 2: - if (!commState.putByteArray(colBytes)) + if (!commState.putByteArray(null, colBytes)) return false; commState.idx++; case 3: - if (!commState.putEnum(depMode)) + if (!commState.putEnum(null, depMode)) return false; commState.idx++; case 4: - if (!commState.putBoolean(forceLocDep)) + if (!commState.putBoolean(null, forceLocDep)) return false; commState.idx++; case 5: - if (!commState.putBoolean(ignoreDepOwnership)) + if (!commState.putBoolean(null, ignoreDepOwnership)) return false; commState.idx++; @@ -252,7 +252,7 @@ public boolean forceLocalDeployment() { case 6: if (ldrParticipants != null) { if (commState.it == null) { - if (!commState.putInt(ldrParticipants.size())) + if (!commState.putInt(null, ldrParticipants.size())) return false; commState.it = ldrParticipants.entrySet().iterator(); @@ -265,13 +265,13 @@ public boolean forceLocalDeployment() { Map.Entry e = (Map.Entry)commState.cur; if (!commState.keyDone) { - if (!commState.putUuid(e.getKey())) + if (!commState.putUuid(null, e.getKey())) return false; commState.keyDone = true; } - if (!commState.putGridUuid(e.getValue())) + if (!commState.putGridUuid(null, e.getValue())) return false; commState.keyDone = false; @@ -281,38 +281,38 @@ public boolean forceLocalDeployment() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 7: - if (!commState.putLong(reqId)) + if (!commState.putLong(null, reqId)) return false; commState.idx++; case 8: - if (!commState.putByteArray(resTopicBytes)) + if (!commState.putByteArray(null, resTopicBytes)) return false; commState.idx++; case 9: - if (!commState.putString(sampleClsName)) + if (!commState.putString(null, sampleClsName)) return false; commState.idx++; case 10: - if (!commState.putByteArray(updaterBytes)) + if (!commState.putByteArray(null, updaterBytes)) return false; commState.idx++; case 11: - if (!commState.putString(userVer)) + if (!commState.putString(null, userVer)) return false; commState.idx++; @@ -328,7 +328,7 @@ public boolean forceLocalDeployment() { switch (commState.idx) { case 0: - String cacheName0 = commState.getString(); + String cacheName0 = commState.getString(null); if (cacheName0 == STR_NOT_READ) return false; @@ -338,7 +338,7 @@ public boolean forceLocalDeployment() { commState.idx++; case 1: - IgniteUuid clsLdrId0 = commState.getGridUuid(); + IgniteUuid clsLdrId0 = commState.getGridUuid(null); if (clsLdrId0 == GRID_UUID_NOT_READ) return false; @@ -348,7 +348,7 @@ public boolean forceLocalDeployment() { commState.idx++; case 2: - byte[] colBytes0 = commState.getByteArray(); + byte[] colBytes0 = commState.getByteArray(null); if (colBytes0 == BYTE_ARR_NOT_READ) return false; @@ -361,7 +361,7 @@ public boolean forceLocalDeployment() { if (buf.remaining() < 1) return false; - byte depMode0 = commState.getByte(); + byte depMode0 = commState.getByte(null); depMode = IgniteDeploymentMode.fromOrdinal(depMode0); @@ -371,7 +371,7 @@ public boolean forceLocalDeployment() { if (buf.remaining() < 1) return false; - forceLocDep = commState.getBoolean(); + forceLocDep = commState.getBoolean(null); commState.idx++; @@ -379,7 +379,7 @@ public boolean forceLocalDeployment() { if (buf.remaining() < 1) return false; - ignoreDepOwnership = commState.getBoolean(); + ignoreDepOwnership = commState.getBoolean(null); commState.idx++; @@ -388,7 +388,7 @@ public boolean forceLocalDeployment() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -397,7 +397,7 @@ public boolean forceLocalDeployment() { for (int i = commState.readItems; i < commState.readSize; i++) { if (!commState.keyDone) { - UUID _val = commState.getUuid(); + UUID _val = commState.getUuid(null); if (_val == UUID_NOT_READ) return false; @@ -406,7 +406,7 @@ public boolean forceLocalDeployment() { commState.keyDone = true; } - IgniteUuid _val = commState.getGridUuid(); + IgniteUuid _val = commState.getGridUuid(null); if (_val == GRID_UUID_NOT_READ) return false; @@ -429,12 +429,12 @@ public boolean forceLocalDeployment() { if (buf.remaining() < 8) return false; - reqId = commState.getLong(); + reqId = commState.getLong(null); commState.idx++; case 8: - byte[] resTopicBytes0 = commState.getByteArray(); + byte[] resTopicBytes0 = commState.getByteArray(null); if (resTopicBytes0 == BYTE_ARR_NOT_READ) return false; @@ -444,7 +444,7 @@ public boolean forceLocalDeployment() { commState.idx++; case 9: - String sampleClsName0 = commState.getString(); + String sampleClsName0 = commState.getString(null); if (sampleClsName0 == STR_NOT_READ) return false; @@ -454,7 +454,7 @@ public boolean forceLocalDeployment() { commState.idx++; case 10: - byte[] updaterBytes0 = commState.getByteArray(); + byte[] updaterBytes0 = commState.getByteArray(null); if (updaterBytes0 == BYTE_ARR_NOT_READ) return false; @@ -464,7 +464,7 @@ public boolean forceLocalDeployment() { commState.idx++; case 11: - String userVer0 = commState.getString(); + String userVer0 = commState.getString(null); if (userVer0 == STR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/dataload/GridDataLoadResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/dataload/GridDataLoadResponse.java index 4c94bd2bd976f..f726db820e1d7 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/dataload/GridDataLoadResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/dataload/GridDataLoadResponse.java @@ -99,7 +99,7 @@ public boolean forceLocalDeployment() { commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -107,19 +107,19 @@ public boolean forceLocalDeployment() { switch (commState.idx) { case 0: - if (!commState.putByteArray(errBytes)) + if (!commState.putByteArray(null, errBytes)) return false; commState.idx++; case 1: - if (!commState.putBoolean(forceLocDep)) + if (!commState.putBoolean(null, forceLocDep)) return false; commState.idx++; case 2: - if (!commState.putLong(reqId)) + if (!commState.putLong(null, reqId)) return false; commState.idx++; @@ -136,7 +136,7 @@ public boolean forceLocalDeployment() { switch (commState.idx) { case 0: - byte[] errBytes0 = commState.getByteArray(); + byte[] errBytes0 = commState.getByteArray(null); if (errBytes0 == BYTE_ARR_NOT_READ) return false; @@ -149,7 +149,7 @@ public boolean forceLocalDeployment() { if (buf.remaining() < 1) return false; - forceLocDep = commState.getBoolean(); + forceLocDep = commState.getBoolean(null); commState.idx++; @@ -157,7 +157,7 @@ public boolean forceLocalDeployment() { if (buf.remaining() < 8) return false; - reqId = commState.getLong(); + reqId = commState.getLong(null); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsAckMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsAckMessage.java index d47c661cde6f2..f01b397e7bc6e 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsAckMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsAckMessage.java @@ -125,7 +125,7 @@ public IgniteCheckedException error() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -133,19 +133,19 @@ public IgniteCheckedException error() { switch (commState.idx) { case 0: - if (!commState.putByteArray(errBytes)) + if (!commState.putByteArray(null, errBytes)) return false; commState.idx++; case 1: - if (!commState.putGridUuid(fileId)) + if (!commState.putGridUuid(null, fileId)) return false; commState.idx++; case 2: - if (!commState.putLong(id)) + if (!commState.putLong(null, id)) return false; commState.idx++; @@ -165,7 +165,7 @@ public IgniteCheckedException error() { switch (commState.idx) { case 0: - byte[] errBytes0 = commState.getByteArray(); + byte[] errBytes0 = commState.getByteArray(null); if (errBytes0 == BYTE_ARR_NOT_READ) return false; @@ -175,7 +175,7 @@ public IgniteCheckedException error() { commState.idx++; case 1: - IgniteUuid fileId0 = commState.getGridUuid(); + IgniteUuid fileId0 = commState.getGridUuid(null); if (fileId0 == GRID_UUID_NOT_READ) return false; @@ -188,7 +188,7 @@ public IgniteCheckedException error() { if (buf.remaining() < 8) return false; - id = commState.getLong(); + id = commState.getLong(null); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsBlockKey.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsBlockKey.java index 3e64ee591b7ce..563c4585c5ab6 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsBlockKey.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsBlockKey.java @@ -176,7 +176,7 @@ public long getBlockId() { commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -184,25 +184,25 @@ public long getBlockId() { switch (commState.idx) { case 0: - if (!commState.putGridUuid(affKey)) + if (!commState.putGridUuid(null, affKey)) return false; commState.idx++; case 1: - if (!commState.putLong(blockId)) + if (!commState.putLong(null, blockId)) return false; commState.idx++; case 2: - if (!commState.putBoolean(evictExclude)) + if (!commState.putBoolean(null, evictExclude)) return false; commState.idx++; case 3: - if (!commState.putGridUuid(fileId)) + if (!commState.putGridUuid(null, fileId)) return false; commState.idx++; @@ -219,7 +219,7 @@ public long getBlockId() { switch (commState.idx) { case 0: - IgniteUuid affKey0 = commState.getGridUuid(); + IgniteUuid affKey0 = commState.getGridUuid(null); if (affKey0 == GRID_UUID_NOT_READ) return false; @@ -232,7 +232,7 @@ public long getBlockId() { if (buf.remaining() < 8) return false; - blockId = commState.getLong(); + blockId = commState.getLong(null); commState.idx++; @@ -240,12 +240,12 @@ public long getBlockId() { if (buf.remaining() < 1) return false; - evictExclude = commState.getBoolean(); + evictExclude = commState.getBoolean(null); commState.idx++; case 3: - IgniteUuid fileId0 = commState.getGridUuid(); + IgniteUuid fileId0 = commState.getGridUuid(null); if (fileId0 == GRID_UUID_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsBlocksMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsBlocksMessage.java index 8f1de6174ee81..2f9ea6009464b 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsBlocksMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsBlocksMessage.java @@ -106,7 +106,7 @@ public Map blocks() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -116,7 +116,7 @@ public Map blocks() { case 0: if (blocks != null) { if (commState.it == null) { - if (!commState.putInt(blocks.size())) + if (!commState.putInt(null, blocks.size())) return false; commState.it = blocks.entrySet().iterator(); @@ -129,13 +129,13 @@ public Map blocks() { Map.Entry e = (Map.Entry)commState.cur; if (!commState.keyDone) { - if (!commState.putMessage(e.getKey())) + if (!commState.putMessage(null, e.getKey())) return false; commState.keyDone = true; } - if (!commState.putByteArray(e.getValue())) + if (!commState.putByteArray(null, e.getValue())) return false; commState.keyDone = false; @@ -145,20 +145,20 @@ public Map blocks() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 1: - if (!commState.putGridUuid(fileId)) + if (!commState.putGridUuid(null, fileId)) return false; commState.idx++; case 2: - if (!commState.putLong(id)) + if (!commState.putLong(null, id)) return false; commState.idx++; @@ -182,7 +182,7 @@ public Map blocks() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -191,7 +191,7 @@ public Map blocks() { for (int i = commState.readItems; i < commState.readSize; i++) { if (!commState.keyDone) { - Object _val = commState.getMessage(); + Object _val = commState.getMessage(null); if (_val == MSG_NOT_READ) return false; @@ -200,7 +200,7 @@ public Map blocks() { commState.keyDone = true; } - byte[] _val = commState.getByteArray(); + byte[] _val = commState.getByteArray(null); if (_val == BYTE_ARR_NOT_READ) return false; @@ -220,7 +220,7 @@ public Map blocks() { commState.idx++; case 1: - IgniteUuid fileId0 = commState.getGridUuid(); + IgniteUuid fileId0 = commState.getGridUuid(null); if (fileId0 == GRID_UUID_NOT_READ) return false; @@ -233,7 +233,7 @@ public Map blocks() { if (buf.remaining() < 8) return false; - id = commState.getLong(); + id = commState.getLong(null); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsCommunicationMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsCommunicationMessage.java index a905c52801697..6bd43e90a2741 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsCommunicationMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsCommunicationMessage.java @@ -49,7 +49,7 @@ public void finishUnmarshal(IgniteMarshaller marsh, @Nullable ClassLoader ldr) t commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsDeleteMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsDeleteMessage.java index c74c5e6a145e1..c9131323d0048 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsDeleteMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsDeleteMessage.java @@ -128,7 +128,7 @@ public IgniteCheckedException error() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -136,13 +136,13 @@ public IgniteCheckedException error() { switch (commState.idx) { case 0: - if (!commState.putByteArray(errBytes)) + if (!commState.putByteArray(null, errBytes)) return false; commState.idx++; case 1: - if (!commState.putGridUuid(id)) + if (!commState.putGridUuid(null, id)) return false; commState.idx++; @@ -162,7 +162,7 @@ public IgniteCheckedException error() { switch (commState.idx) { case 0: - byte[] errBytes0 = commState.getByteArray(); + byte[] errBytes0 = commState.getByteArray(null); if (errBytes0 == BYTE_ARR_NOT_READ) return false; @@ -172,7 +172,7 @@ public IgniteCheckedException error() { commState.idx++; case 1: - IgniteUuid id0 = commState.getGridUuid(); + IgniteUuid id0 = commState.getGridUuid(null); if (id0 == GRID_UUID_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsFileAffinityRange.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsFileAffinityRange.java index 77d188b9bf6e5..46975bb31b690 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsFileAffinityRange.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsFileAffinityRange.java @@ -281,7 +281,7 @@ public boolean regionEqual(GridGgfsFileAffinityRange other) { commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -289,31 +289,31 @@ public boolean regionEqual(GridGgfsFileAffinityRange other) { switch (commState.idx) { case 0: - if (!commState.putGridUuid(affKey)) + if (!commState.putGridUuid(null, affKey)) return false; commState.idx++; case 1: - if (!commState.putBoolean(done)) + if (!commState.putBoolean(null, done)) return false; commState.idx++; case 2: - if (!commState.putLong(endOff)) + if (!commState.putLong(null, endOff)) return false; commState.idx++; case 3: - if (!commState.putLong(startOff)) + if (!commState.putLong(null, startOff)) return false; commState.idx++; case 4: - if (!commState.putInt(status)) + if (!commState.putInt(null, status)) return false; commState.idx++; @@ -330,7 +330,7 @@ public boolean regionEqual(GridGgfsFileAffinityRange other) { switch (commState.idx) { case 0: - IgniteUuid affKey0 = commState.getGridUuid(); + IgniteUuid affKey0 = commState.getGridUuid(null); if (affKey0 == GRID_UUID_NOT_READ) return false; @@ -343,7 +343,7 @@ public boolean regionEqual(GridGgfsFileAffinityRange other) { if (buf.remaining() < 1) return false; - done = commState.getBoolean(); + done = commState.getBoolean(null); commState.idx++; @@ -351,7 +351,7 @@ public boolean regionEqual(GridGgfsFileAffinityRange other) { if (buf.remaining() < 8) return false; - endOff = commState.getLong(); + endOff = commState.getLong(null); commState.idx++; @@ -359,7 +359,7 @@ public boolean regionEqual(GridGgfsFileAffinityRange other) { if (buf.remaining() < 8) return false; - startOff = commState.getLong(); + startOff = commState.getLong(null); commState.idx++; @@ -367,7 +367,7 @@ public boolean regionEqual(GridGgfsFileAffinityRange other) { if (buf.remaining() < 4) return false; - status = commState.getInt(); + status = commState.getInt(null); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsFragmentizerRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsFragmentizerRequest.java index d6329ccfc2af6..80b4621579aed 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsFragmentizerRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsFragmentizerRequest.java @@ -99,7 +99,7 @@ public Collection fragmentRanges() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -107,7 +107,7 @@ public Collection fragmentRanges() { switch (commState.idx) { case 0: - if (!commState.putGridUuid(fileId)) + if (!commState.putGridUuid(null, fileId)) return false; commState.idx++; @@ -115,7 +115,7 @@ public Collection fragmentRanges() { case 1: if (fragmentRanges != null) { if (commState.it == null) { - if (!commState.putInt(fragmentRanges.size())) + if (!commState.putInt(null, fragmentRanges.size())) return false; commState.it = fragmentRanges.iterator(); @@ -125,7 +125,7 @@ public Collection fragmentRanges() { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putMessage((GridGgfsFileAffinityRange)commState.cur)) + if (!commState.putMessage(null, (GridGgfsFileAffinityRange)commState.cur)) return false; commState.cur = NULL; @@ -133,7 +133,7 @@ public Collection fragmentRanges() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } @@ -154,7 +154,7 @@ public Collection fragmentRanges() { switch (commState.idx) { case 0: - IgniteUuid fileId0 = commState.getGridUuid(); + IgniteUuid fileId0 = commState.getGridUuid(null); if (fileId0 == GRID_UUID_NOT_READ) return false; @@ -168,7 +168,7 @@ public Collection fragmentRanges() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -176,7 +176,7 @@ public Collection fragmentRanges() { fragmentRanges = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - Object _val = commState.getMessage(); + Object _val = commState.getMessage(null); if (_val == MSG_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsFragmentizerResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsFragmentizerResponse.java index 18024b3c58c1a..9d71c9c26d117 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsFragmentizerResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsFragmentizerResponse.java @@ -74,7 +74,7 @@ public IgniteUuid fileId() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -82,7 +82,7 @@ public IgniteUuid fileId() { switch (commState.idx) { case 0: - if (!commState.putGridUuid(fileId)) + if (!commState.putGridUuid(null, fileId)) return false; commState.idx++; @@ -102,7 +102,7 @@ public IgniteUuid fileId() { switch (commState.idx) { case 0: - IgniteUuid fileId0 = commState.getGridUuid(); + IgniteUuid fileId0 = commState.getGridUuid(null); if (fileId0 == GRID_UUID_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsSyncMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsSyncMessage.java index f1ab657f3ceed..06fbcef791637 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsSyncMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsSyncMessage.java @@ -92,7 +92,7 @@ public boolean response() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -100,13 +100,13 @@ public boolean response() { switch (commState.idx) { case 0: - if (!commState.putLong(order)) + if (!commState.putLong(null, order)) return false; commState.idx++; case 1: - if (!commState.putBoolean(res)) + if (!commState.putBoolean(null, res)) return false; commState.idx++; @@ -129,7 +129,7 @@ public boolean response() { if (buf.remaining() < 8) return false; - order = commState.getLong(); + order = commState.getLong(null); commState.idx++; @@ -137,7 +137,7 @@ public boolean response() { if (buf.remaining() < 1) return false; - res = commState.getBoolean(); + res = commState.getBoolean(null); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/portable/GridPortableOutputStream.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/portable/GridPortableOutputStream.java index c72ddd7f11bd4..a71be26916fed 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/portable/GridPortableOutputStream.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/portable/GridPortableOutputStream.java @@ -150,13 +150,6 @@ public interface GridPortableOutputStream extends GridPortableStream, AutoClosea */ public void write(long addr, int cnt); - /** - * Ensure capacity. - * - * @param cnt Required byte count. - */ - public void ensureCapacity(int cnt); - /** * Close the stream releasing resources. */ diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java index 7adca40dde63a..601428c7fe9cf 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java @@ -54,7 +54,7 @@ public byte[] bytes() { commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -62,7 +62,7 @@ public byte[] bytes() { switch (commState.idx) { case 0: - if (!commState.putByteArrayClient(bytes)) + if (!commState.putByteArray(null, bytes)) return false; commState.idx++; @@ -78,12 +78,12 @@ public byte[] bytes() { switch (commState.idx) { case 0: - byte[] bytes0 = commState.getByteArrayClient(GridClientHandshakeRequest.PACKET_SIZE); - - if (bytes0 == BYTE_ARR_NOT_READ) - return false; - - bytes = bytes0; +// byte[] bytes0 = commState.getByteArray(null, GridClientHandshakeRequest.PACKET_SIZE); +// +// if (bytes0 == BYTE_ARR_NOT_READ) +// return false; +// +// bytes = bytes0; commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java index bc5b7af3c899c..c77964b300e16 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java @@ -43,7 +43,7 @@ public GridClientHandshakeResponseWrapper(byte code) { commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientMessageWrapper.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientMessageWrapper.java index 99e1306e22cc9..4779afbd60750 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientMessageWrapper.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientMessageWrapper.java @@ -125,7 +125,7 @@ public void message(ByteBuffer msg) { commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -133,32 +133,32 @@ public void message(ByteBuffer msg) { switch (commState.idx) { case 0: - if (!commState.putIntClient(msgSize)) + if (!commState.putInt(null, msgSize)) return false; commState.idx++; case 1: - if (!commState.putLongClient(reqId)) + if (!commState.putLong(null, reqId)) return false; commState.idx++; case 2: - if (!commState.putUuidClient(clientId)) + if (!commState.putUuid(null, clientId)) return false; commState.idx++; case 3: - if (!commState.putUuidClient(destId)) + if (!commState.putUuid(null, destId)) return false; commState.idx++; case 4: - if (!commState.putByteBufferClient(msg)) - return false; +// if (!commState.putByteBuffer(null, msg)) +// return false; commState.idx++; @@ -176,7 +176,7 @@ public void message(ByteBuffer msg) { if (buf.remaining() < 4) return false; - msgSize = commState.getIntClient(); + msgSize = commState.getInt(null); if (msgSize == 0) // Ping message. return true; @@ -187,12 +187,12 @@ public void message(ByteBuffer msg) { if (buf.remaining() < 8) return false; - reqId = commState.getLongClient(); + reqId = commState.getLong(null); commState.idx++; case 2: - UUID clientId0 = commState.getUuidClient(); + UUID clientId0 = commState.getUuid(null); if (clientId0 == UUID_NOT_READ) return false; @@ -202,7 +202,7 @@ public void message(ByteBuffer msg) { commState.idx++; case 3: - UUID destId0 = commState.getUuidClient(); + UUID destId0 = commState.getUuid(null); if (destId0 == UUID_NOT_READ) return false; @@ -212,14 +212,14 @@ public void message(ByteBuffer msg) { commState.idx++; case 4: - byte[] msg0 = commState.getByteArrayClient(msgSize - 40); - - if (msg0 == BYTE_ARR_NOT_READ) - return false; - - msg = ByteBuffer.wrap(msg0); - - commState.idx++; +// byte[] msg0 = commState.getByteArray(null, msgSize - 40); +// +// if (msg0 == BYTE_ARR_NOT_READ) +// return false; +// +// msg = ByteBuffer.wrap(msg0); +// +// commState.idx++; } return true; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientPingPacketWrapper.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientPingPacketWrapper.java index 517b804d4fb6c..b719531aab833 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientPingPacketWrapper.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientPingPacketWrapper.java @@ -29,7 +29,7 @@ public class GridClientPingPacketWrapper extends GridTcpCommunicationMessageAdap commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -37,7 +37,7 @@ public class GridClientPingPacketWrapper extends GridTcpCommunicationMessageAdap switch (commState.idx) { case 0: - if (!commState.putIntClient(size)) + if (!commState.putInt(null, size)) return false; commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/handlers/task/GridTaskResultRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/handlers/task/GridTaskResultRequest.java index 0485f3f7609eb..2b66ef67f1f48 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/handlers/task/GridTaskResultRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/handlers/task/GridTaskResultRequest.java @@ -115,7 +115,7 @@ public void topic(String topic) { commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -123,13 +123,13 @@ public void topic(String topic) { switch (commState.idx) { case 0: - if (!commState.putGridUuid(taskId)) + if (!commState.putGridUuid(null, taskId)) return false; commState.idx++; case 1: - if (!commState.putByteArray(topicBytes)) + if (!commState.putByteArray(null, topicBytes)) return false; commState.idx++; @@ -146,7 +146,7 @@ public void topic(String topic) { switch (commState.idx) { case 0: - IgniteUuid taskId0 = commState.getGridUuid(); + IgniteUuid taskId0 = commState.getGridUuid(null); if (taskId0 == GRID_UUID_NOT_READ) return false; @@ -156,7 +156,7 @@ public void topic(String topic) { commState.idx++; case 1: - byte[] topicBytes0 = commState.getByteArray(); + byte[] topicBytes0 = commState.getByteArray(null); if (topicBytes0 == BYTE_ARR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/handlers/task/GridTaskResultResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/handlers/task/GridTaskResultResponse.java index 91cb28f4cebfe..ad9e42f0076d5 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/handlers/task/GridTaskResultResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/handlers/task/GridTaskResultResponse.java @@ -135,7 +135,7 @@ public void error(String err) { commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -143,25 +143,25 @@ public void error(String err) { switch (commState.idx) { case 0: - if (!commState.putString(err)) + if (!commState.putString(null, err)) return false; commState.idx++; case 1: - if (!commState.putBoolean(finished)) + if (!commState.putBoolean(null, finished)) return false; commState.idx++; case 2: - if (!commState.putBoolean(found)) + if (!commState.putBoolean(null, found)) return false; commState.idx++; case 3: - if (!commState.putByteArray(resBytes)) + if (!commState.putByteArray(null, resBytes)) return false; commState.idx++; @@ -178,7 +178,7 @@ public void error(String err) { switch (commState.idx) { case 0: - String err0 = commState.getString(); + String err0 = commState.getString(null); if (err0 == STR_NOT_READ) return false; @@ -191,7 +191,7 @@ public void error(String err) { if (buf.remaining() < 1) return false; - finished = commState.getBoolean(); + finished = commState.getBoolean(null); commState.idx++; @@ -199,12 +199,12 @@ public void error(String err) { if (buf.remaining() < 1) return false; - found = commState.getBoolean(); + found = commState.getBoolean(null); commState.idx++; case 3: - byte[] resBytes0 = commState.getByteArray(); + byte[] resBytes0 = commState.getByteArray(null); if (resBytes0 == BYTE_ARR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java index 40c0331af19f9..077aa93abd5ad 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java @@ -58,7 +58,7 @@ public GridMemcachedMessageWrapper(GridMemcachedMessage msg, IgniteMarshaller jd commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -66,7 +66,7 @@ public GridMemcachedMessageWrapper(GridMemcachedMessage msg, IgniteMarshaller jd switch (commState.idx) { case 0: - if (!commState.putByteArrayClient(bytes)) + if (!commState.putByteArray(null, bytes)) return false; commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/protocols/tcp/GridTcpRestDirectParser.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/protocols/tcp/GridTcpRestDirectParser.java index d42c762ffb88e..99dcd44ab658b 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/protocols/tcp/GridTcpRestDirectParser.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/protocols/tcp/GridTcpRestDirectParser.java @@ -38,20 +38,16 @@ public class GridTcpRestDirectParser implements GridNioParser { /** Protocol handler. */ private final GridTcpRestProtocol proto; - /** Message reader. */ - private final GridNioMessageReader msgReader; - /** * @param proto Protocol handler. - * @param msgReader Message reader. */ - public GridTcpRestDirectParser(GridTcpRestProtocol proto, GridNioMessageReader msgReader) { + public GridTcpRestDirectParser(GridTcpRestProtocol proto) { this.proto = proto; - this.msgReader = msgReader; } /** {@inheritDoc} */ - @Nullable @Override public Object decode(GridNioSession ses, ByteBuffer buf) throws IOException, IgniteCheckedException { + @Nullable @Override public Object decode(GridNioSession ses, ByteBuffer buf) + throws IOException, IgniteCheckedException { ParserState state = ses.removeMeta(PARSER_STATE.ordinal()); if (state != null) { @@ -100,7 +96,7 @@ else if (type == MEMCACHE_REQ_FLAG) { boolean finished = false; if (buf.hasRemaining()) - finished = msgReader.read(null, msg, buf); + finished = msg.readFrom(buf); if (finished) { if (msg instanceof GridClientMessageWrapper) { diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/protocols/tcp/GridTcpRestProtocol.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/protocols/tcp/GridTcpRestProtocol.java index 24e259f11f957..1974347f332c4 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/protocols/tcp/GridTcpRestProtocol.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/protocols/tcp/GridTcpRestProtocol.java @@ -22,7 +22,6 @@ import org.gridgain.grid.kernal.processors.rest.*; import org.gridgain.grid.kernal.processors.rest.client.message.*; import org.gridgain.grid.kernal.processors.rest.protocols.*; -import org.gridgain.grid.util.direct.*; import org.gridgain.grid.util.nio.*; import org.gridgain.grid.util.nio.ssl.*; import org.gridgain.grid.util.typedef.internal.*; @@ -49,59 +48,6 @@ public class GridTcpRestProtocol extends GridRestProtocolAdapter { /** NIO server listener. */ private GridTcpRestNioListener lsnr; - /** Message reader. */ - private final GridNioMessageReader msgReader = new GridNioMessageReader() { - @Override public boolean read(@Nullable UUID nodeId, GridTcpCommunicationMessageAdapter msg, ByteBuffer buf) { - assert msg != null; - assert buf != null; - - msg.messageReader(this, nodeId); - - return msg.readFrom(buf); - } - - @Nullable @Override public GridTcpMessageFactory messageFactory() { - return null; - } - }; - - /** Message writer. */ - private final GridNioMessageWriter msgWriter = new GridNioMessageWriter() { - @Override public boolean write(@Nullable UUID nodeId, GridTcpCommunicationMessageAdapter msg, ByteBuffer buf) { - assert msg != null; - assert buf != null; - - msg.messageWriter(this, nodeId); - - return msg.writeTo(buf); - } - - @Override public int writeFully(@Nullable UUID nodeId, GridTcpCommunicationMessageAdapter msg, OutputStream out, - ByteBuffer buf) throws IOException { - assert msg != null; - assert out != null; - assert buf != null; - assert buf.hasArray(); - - msg.messageWriter(this, nodeId); - - boolean finished = false; - int cnt = 0; - - while (!finished) { - finished = msg.writeTo(buf); - - out.write(buf.array(), 0, buf.position()); - - cnt += buf.position(); - - buf.clear(); - } - - return cnt; - } - }; - /** @param ctx Context. */ public GridTcpRestProtocol(GridKernalContext ctx) { super(ctx); @@ -152,7 +98,7 @@ boolean portableMode(GridNioSession ses) { lsnr = new GridTcpRestNioListener(log, this, hnd, ctx); - GridNioParser parser = new GridTcpRestDirectParser(this, msgReader); + GridNioParser parser = new GridTcpRestDirectParser(this); try { host = resolveRestTcpHost(ctx.config()); @@ -291,7 +237,6 @@ private boolean startTcpServer(InetAddress hostAddr, int port, GridNioServerList .sendQueueLimit(cfg.getRestTcpSendQueueLimit()) .filters(filters) .directMode(true) - .messageWriter(msgWriter) .build(); srv.idleTimeout(cfg.getRestIdleTimeout()); diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/streamer/GridStreamerCancelRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/streamer/GridStreamerCancelRequest.java index be602db8db190..cc56dc8adbb4e 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/streamer/GridStreamerCancelRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/streamer/GridStreamerCancelRequest.java @@ -69,7 +69,7 @@ public IgniteUuid cancelledFutureId() { commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -77,7 +77,7 @@ public IgniteUuid cancelledFutureId() { switch (commState.idx) { case 0: - if (!commState.putGridUuid(cancelledFutId)) + if (!commState.putGridUuid(null, cancelledFutId)) return false; commState.idx++; @@ -94,7 +94,7 @@ public IgniteUuid cancelledFutureId() { switch (commState.idx) { case 0: - IgniteUuid cancelledFutId0 = commState.getGridUuid(); + IgniteUuid cancelledFutId0 = commState.getGridUuid(null); if (cancelledFutId0 == GRID_UUID_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/streamer/GridStreamerExecutionRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/streamer/GridStreamerExecutionRequest.java index 40e8d5a4c88e7..39c8cf2aa99c6 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/streamer/GridStreamerExecutionRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/streamer/GridStreamerExecutionRequest.java @@ -170,7 +170,7 @@ public byte[] batchBytes() { commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -178,25 +178,25 @@ public byte[] batchBytes() { switch (commState.idx) { case 0: - if (!commState.putByteArray(batchBytes)) + if (!commState.putByteArray(null, batchBytes)) return false; commState.idx++; case 1: - if (!commState.putGridUuid(clsLdrId)) + if (!commState.putGridUuid(null, clsLdrId)) return false; commState.idx++; case 2: - if (!commState.putEnum(depMode)) + if (!commState.putEnum(null, depMode)) return false; commState.idx++; case 3: - if (!commState.putBoolean(forceLocDep)) + if (!commState.putBoolean(null, forceLocDep)) return false; commState.idx++; @@ -204,7 +204,7 @@ public byte[] batchBytes() { case 4: if (ldrParticipants != null) { if (commState.it == null) { - if (!commState.putInt(ldrParticipants.size())) + if (!commState.putInt(null, ldrParticipants.size())) return false; commState.it = ldrParticipants.entrySet().iterator(); @@ -217,13 +217,13 @@ public byte[] batchBytes() { Map.Entry e = (Map.Entry)commState.cur; if (!commState.keyDone) { - if (!commState.putUuid(e.getKey())) + if (!commState.putUuid(null, e.getKey())) return false; commState.keyDone = true; } - if (!commState.putGridUuid(e.getValue())) + if (!commState.putGridUuid(null, e.getValue())) return false; commState.keyDone = false; @@ -233,20 +233,20 @@ public byte[] batchBytes() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 5: - if (!commState.putString(sampleClsName)) + if (!commState.putString(null, sampleClsName)) return false; commState.idx++; case 6: - if (!commState.putString(userVer)) + if (!commState.putString(null, userVer)) return false; commState.idx++; @@ -263,7 +263,7 @@ public byte[] batchBytes() { switch (commState.idx) { case 0: - byte[] batchBytes0 = commState.getByteArray(); + byte[] batchBytes0 = commState.getByteArray(null); if (batchBytes0 == BYTE_ARR_NOT_READ) return false; @@ -273,7 +273,7 @@ public byte[] batchBytes() { commState.idx++; case 1: - IgniteUuid clsLdrId0 = commState.getGridUuid(); + IgniteUuid clsLdrId0 = commState.getGridUuid(null); if (clsLdrId0 == GRID_UUID_NOT_READ) return false; @@ -286,7 +286,7 @@ public byte[] batchBytes() { if (buf.remaining() < 1) return false; - byte depMode0 = commState.getByte(); + byte depMode0 = commState.getByte(null); depMode = IgniteDeploymentMode.fromOrdinal(depMode0); @@ -296,7 +296,7 @@ public byte[] batchBytes() { if (buf.remaining() < 1) return false; - forceLocDep = commState.getBoolean(); + forceLocDep = commState.getBoolean(null); commState.idx++; @@ -305,7 +305,7 @@ public byte[] batchBytes() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -314,7 +314,7 @@ public byte[] batchBytes() { for (int i = commState.readItems; i < commState.readSize; i++) { if (!commState.keyDone) { - UUID _val = commState.getUuid(); + UUID _val = commState.getUuid(null); if (_val == UUID_NOT_READ) return false; @@ -323,7 +323,7 @@ public byte[] batchBytes() { commState.keyDone = true; } - IgniteUuid _val = commState.getGridUuid(); + IgniteUuid _val = commState.getGridUuid(null); if (_val == GRID_UUID_NOT_READ) return false; @@ -343,7 +343,7 @@ public byte[] batchBytes() { commState.idx++; case 5: - String sampleClsName0 = commState.getString(); + String sampleClsName0 = commState.getString(null); if (sampleClsName0 == STR_NOT_READ) return false; @@ -353,7 +353,7 @@ public byte[] batchBytes() { commState.idx++; case 6: - String userVer0 = commState.getString(); + String userVer0 = commState.getString(null); if (userVer0 == STR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/streamer/GridStreamerResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/streamer/GridStreamerResponse.java index 2933e45bcc2ad..fc3cfcbd7e144 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/streamer/GridStreamerResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/streamer/GridStreamerResponse.java @@ -90,7 +90,7 @@ public byte[] errorBytes() { commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -98,13 +98,13 @@ public byte[] errorBytes() { switch (commState.idx) { case 0: - if (!commState.putByteArray(errBytes)) + if (!commState.putByteArray(null, errBytes)) return false; commState.idx++; case 1: - if (!commState.putGridUuid(futId)) + if (!commState.putGridUuid(null, futId)) return false; commState.idx++; @@ -121,7 +121,7 @@ public byte[] errorBytes() { switch (commState.idx) { case 0: - byte[] errBytes0 = commState.getByteArray(); + byte[] errBytes0 = commState.getByteArray(null); if (errBytes0 == BYTE_ARR_NOT_READ) return false; @@ -131,7 +131,7 @@ public byte[] errorBytes() { commState.idx++; case 1: - IgniteUuid futId0 = commState.getGridUuid(); + IgniteUuid futId0 = commState.getGridUuid(null); if (futId0 == GRID_UUID_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/util/GridLongList.java b/modules/core/src/main/java/org/gridgain/grid/util/GridLongList.java index f740ad91f4004..857f80a5bfb6b 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/GridLongList.java +++ b/modules/core/src/main/java/org/gridgain/grid/util/GridLongList.java @@ -369,10 +369,14 @@ public int replaceValue(int startIdx, long oldVal, long newVal) { } /** - * @return Internal array. + * @return Array copy. */ - public long[] internalArray() { - return arr; + public long[] array() { + long[] res = new long[idx]; + + System.arraycopy(arr, 0, res, 0, idx); + + return res; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/gridgain/grid/util/GridUtils.java b/modules/core/src/main/java/org/gridgain/grid/util/GridUtils.java index 803badd910b70..3e9f61c2ac83f 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/GridUtils.java +++ b/modules/core/src/main/java/org/gridgain/grid/util/GridUtils.java @@ -27,6 +27,7 @@ import org.gridgain.grid.kernal.processors.cache.*; import org.gridgain.grid.kernal.processors.streamer.*; import org.apache.ignite.spi.discovery.*; +import org.gridgain.grid.util.direct.*; import org.gridgain.grid.util.io.*; import org.gridgain.grid.util.lang.*; import org.gridgain.grid.util.typedef.*; @@ -9027,4 +9028,37 @@ public static List arrayList(Iterable c, int cap, return list; } + + /** + * Fully writes communication message to provided stream. + * + * @param msg Message. + * @param out Stream to write to. + * @param buf Byte buffer that will be passed to {@link GridTcpCommunicationMessageAdapter#writeTo(ByteBuffer)} + * method. + * @return Number of written bytes. + * @throws IOException In case of error. + */ + public static int writeMessageFully(GridTcpCommunicationMessageAdapter msg, OutputStream out, ByteBuffer buf) + throws IOException { + assert msg != null; + assert out != null; + assert buf != null; + assert buf.hasArray(); + + boolean finished = false; + int cnt = 0; + + while (!finished) { + finished = msg.writeTo(buf); + + out.write(buf.array(), 0, buf.position()); + + cnt += buf.position(); + + buf.clear(); + } + + return cnt; + } } diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridPortableByteBufferStream.java b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridPortableByteBufferStream.java new file mode 100644 index 0000000000000..4433cbf3912b7 --- /dev/null +++ b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridPortableByteBufferStream.java @@ -0,0 +1,726 @@ +/* @java.file.header */ + +/* _________ _____ __________________ _____ + * __ ____/___________(_)______ /__ ____/______ ____(_)_______ + * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ + * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / + * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ + */ + +package org.gridgain.grid.util.direct; + +import org.gridgain.grid.kernal.processors.portable.*; +import org.gridgain.grid.util.*; +import sun.misc.*; +import sun.nio.ch.*; + +import java.nio.*; + +import static org.gridgain.grid.util.direct.GridTcpCommunicationMessageAdapter.*; + +/** + * Portable stream based on {@link ByteBuffer}. + */ +public class GridPortableByteBufferStream implements GridPortableOutputStream, GridPortableInputStream { + /** */ + private static final Unsafe UNSAFE = GridUnsafe.unsafe(); + + /** */ + private static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class); + + /** */ + private static final long SHORT_ARR_OFF = UNSAFE.arrayBaseOffset(short[].class); + + /** */ + private static final long INT_ARR_OFF = UNSAFE.arrayBaseOffset(int[].class); + + /** */ + private static final long LONG_ARR_OFF = UNSAFE.arrayBaseOffset(long[].class); + + /** */ + private static final long FLOAT_ARR_OFF = UNSAFE.arrayBaseOffset(float[].class); + + /** */ + private static final long DOUBLE_ARR_OFF = UNSAFE.arrayBaseOffset(double[].class); + + /** */ + private static final long CHAR_ARR_OFF = UNSAFE.arrayBaseOffset(char[].class); + + /** */ + private static final long BOOLEAN_ARR_OFF = UNSAFE.arrayBaseOffset(boolean[].class); + + /** */ + private static final byte[] BYTE_ARR_EMPTY = new byte[0]; + + /** */ + private static final short[] SHORT_ARR_EMPTY = new short[0]; + + /** */ + private static final int[] INT_ARR_EMPTY = new int[0]; + + /** */ + private static final long[] LONG_ARR_EMPTY = new long[0]; + + /** */ + private static final float[] FLOAT_ARR_EMPTY = new float[0]; + + /** */ + private static final double[] DOUBLE_ARR_EMPTY = new double[0]; + + /** */ + private static final char[] CHAR_ARR_EMPTY = new char[0]; + + /** */ + private static final boolean[] BOOLEAN_ARR_EMPTY = new boolean[0]; + + /** */ + private static final ArrayCreator BYTE_ARR_CREATOR = new ArrayCreator() { + @Override public byte[] create(int len) { + switch (len) { + case -1: + return BYTE_ARR_NOT_READ; + + case 0: + return BYTE_ARR_EMPTY; + + default: + return new byte[len]; + } + } + }; + + /** */ + private static final ArrayCreator SHORT_ARR_CREATOR = new ArrayCreator() { + @Override public short[] create(int len) { + switch (len) { + case -1: + return SHORT_ARR_NOT_READ; + + case 0: + return SHORT_ARR_EMPTY; + + default: + return new short[len]; + } + } + }; + + /** */ + private static final ArrayCreator INT_ARR_CREATOR = new ArrayCreator() { + @Override public int[] create(int len) { + switch (len) { + case -1: + return INT_ARR_NOT_READ; + + case 0: + return INT_ARR_EMPTY; + + default: + return new int[len]; + } + } + }; + + /** */ + private static final ArrayCreator LONG_ARR_CREATOR = new ArrayCreator() { + @Override public long[] create(int len) { + switch (len) { + case -1: + return LONG_ARR_NOT_READ; + + case 0: + return LONG_ARR_EMPTY; + + default: + return new long[len]; + } + } + }; + + /** */ + private static final ArrayCreator FLOAT_ARR_CREATOR = new ArrayCreator() { + @Override public float[] create(int len) { + switch (len) { + case -1: + return FLOAT_ARR_NOT_READ; + + case 0: + return FLOAT_ARR_EMPTY; + + default: + return new float[len]; + } + } + }; + + /** */ + private static final ArrayCreator DOUBLE_ARR_CREATOR = new ArrayCreator() { + @Override public double[] create(int len) { + switch (len) { + case -1: + return DOUBLE_ARR_NOT_READ; + + case 0: + return DOUBLE_ARR_EMPTY; + + default: + return new double[len]; + } + } + }; + + /** */ + private static final ArrayCreator CHAR_ARR_CREATOR = new ArrayCreator() { + @Override public char[] create(int len) { + switch (len) { + case -1: + return CHAR_ARR_NOT_READ; + + case 0: + return CHAR_ARR_EMPTY; + + default: + return new char[len]; + } + } + }; + + /** */ + private static final ArrayCreator BOOLEAN_ARR_CREATOR = new ArrayCreator() { + @Override public boolean[] create(int len) { + switch (len) { + case -1: + return BOOLEAN_ARR_NOT_READ; + + case 0: + return BOOLEAN_ARR_EMPTY; + + default: + return new boolean[len]; + } + } + }; + + /** */ + private ByteBuffer buf; + + /** */ + private byte[] heapArr; + + /** */ + private long baseOff; + + /** */ + private int arrOff; + + /** */ + private Object tmpArr; + + /** */ + private int tmpArrOff; + + /** */ + private int tmpArrBytes; + + /** */ + private boolean msgTypeDone; + + /** */ + private GridTcpCommunicationMessageAdapter msg; + + /** */ + private boolean lastWritten; + + /** + * @param buf Buffer. + */ + public final void setBuffer(ByteBuffer buf) { + assert buf != null; + + if (this.buf != buf) { + this.buf = buf; + + heapArr = buf.isDirect() ? null : buf.array(); + baseOff = buf.isDirect() ? ((DirectBuffer)buf).address() : BYTE_ARR_OFF; + } + } + + /** + * @return Whether last object was fully written. + */ + public boolean lastWritten() { + boolean lastWritten0 = lastWritten; + + lastWritten = false; + + return lastWritten0; + } + + /** + * @param msg Message. + */ + public void writeMessage(GridTcpCommunicationMessageAdapter msg) { + assert msg != null; + + lastWritten = msg.writeTo(buf); + } + + /** + * @return Message. + */ + public GridTcpCommunicationMessageAdapter readMessage() { + if (!msgTypeDone) { + if (!buf.hasRemaining()) + return MSG_NOT_READ; + + byte type = readByte(); + + msg = GridTcpCommunicationMessageFactory.create(type); + + msgTypeDone = true; + } + + if (msg.readFrom(buf)) { + GridTcpCommunicationMessageAdapter msg0 = msg; + + msgTypeDone = false; + msg = null; + + return msg0; + } + else + return MSG_NOT_READ; + } + + /** {@inheritDoc} */ + @Override public void writeByte(byte val) { + int pos = buf.position(); + + UNSAFE.putByte(heapArr, baseOff + pos, val); + + buf.position(pos + 1); + } + + /** {@inheritDoc} */ + @Override public void writeByteArray(byte[] val) { + assert val != null; + + lastWritten = writeArray(val, BYTE_ARR_OFF, val.length); + } + + /** {@inheritDoc} */ + @Override public void writeBoolean(boolean val) { + int pos = buf.position(); + + UNSAFE.putBoolean(heapArr, baseOff + pos, val); + + buf.position(pos + 1); + } + + /** {@inheritDoc} */ + @Override public void writeBooleanArray(boolean[] val) { + assert val != null; + + lastWritten = writeArray(val, BOOLEAN_ARR_OFF, val.length); + } + + /** {@inheritDoc} */ + @Override public void writeShort(short val) { + int pos = buf.position(); + + UNSAFE.putShort(heapArr, baseOff + pos, val); + + buf.position(pos + 2); + } + + /** {@inheritDoc} */ + @Override public void writeShortArray(short[] val) { + assert val != null; + + lastWritten = writeArray(val, SHORT_ARR_OFF, val.length << 1); + } + + /** {@inheritDoc} */ + @Override public void writeChar(char val) { + int pos = buf.position(); + + UNSAFE.putChar(heapArr, baseOff + pos, val); + + buf.position(pos + 2); + } + + /** {@inheritDoc} */ + @Override public void writeCharArray(char[] val) { + assert val != null; + + lastWritten = writeArray(val, CHAR_ARR_OFF, val.length << 1); + } + + /** {@inheritDoc} */ + @Override public void writeInt(int val) { + int pos = buf.position(); + + UNSAFE.putInt(heapArr, baseOff + pos, val); + + buf.position(pos + 4); + } + + /** {@inheritDoc} */ + @Override public void writeInt(int pos, int val) { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Override public void writeIntArray(int[] val) { + assert val != null; + + lastWritten = writeArray(val, INT_ARR_OFF, val.length << 2); + } + + /** {@inheritDoc} */ + @Override public void writeFloat(float val) { + int pos = buf.position(); + + UNSAFE.putFloat(heapArr, baseOff + pos, val); + + buf.position(pos + 4); + } + + /** {@inheritDoc} */ + @Override public void writeFloatArray(float[] val) { + assert val != null; + + lastWritten = writeArray(val, FLOAT_ARR_OFF, val.length << 2); + } + + /** {@inheritDoc} */ + @Override public void writeLong(long val) { + int pos = buf.position(); + + UNSAFE.putLong(heapArr, baseOff + pos, val); + + buf.position(pos + 8); + } + + /** {@inheritDoc} */ + @Override public void writeLongArray(long[] val) { + assert val != null; + + lastWritten = writeArray(val, LONG_ARR_OFF, val.length << 3); + } + + /** {@inheritDoc} */ + @Override public void writeDouble(double val) { + int pos = buf.position(); + + UNSAFE.putDouble(heapArr, baseOff + pos, val); + + buf.position(pos + 8); + } + + /** {@inheritDoc} */ + @Override public void writeDoubleArray(double[] val) { + assert val != null; + + lastWritten = writeArray(val, DOUBLE_ARR_OFF, val.length << 3); + } + + /** {@inheritDoc} */ + @Override public void write(byte[] arr, int off, int len) { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Override public void write(long addr, int cnt) { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Override public byte readByte() { + assert buf.hasRemaining(); + + int pos = buf.position(); + + buf.position(pos + 1); + + return UNSAFE.getByte(heapArr, baseOff + pos); + } + + /** {@inheritDoc} */ + @Override public byte[] readByteArray(int cnt) { + return readArray(BYTE_ARR_CREATOR, cnt, 0, BYTE_ARR_OFF); + } + + /** {@inheritDoc} */ + @Override public boolean readBoolean() { + assert buf.hasRemaining(); + + int pos = buf.position(); + + buf.position(pos + 1); + + return UNSAFE.getBoolean(heapArr, baseOff + pos); + } + + /** {@inheritDoc} */ + @Override public boolean[] readBooleanArray(int cnt) { + return readArray(BOOLEAN_ARR_CREATOR, cnt, 0, BOOLEAN_ARR_OFF); + } + + /** {@inheritDoc} */ + @Override public short readShort() { + assert buf.remaining() >= 2; + + int pos = buf.position(); + + buf.position(pos + 2); + + return UNSAFE.getShort(heapArr, baseOff + pos); + } + + /** {@inheritDoc} */ + @Override public short[] readShortArray(int cnt) { + return readArray(SHORT_ARR_CREATOR, cnt, 1, SHORT_ARR_OFF); + } + + /** {@inheritDoc} */ + @Override public char readChar() { + assert buf.remaining() >= 2; + + int pos = buf.position(); + + buf.position(pos + 2); + + return UNSAFE.getChar(heapArr, baseOff + pos); + } + + /** {@inheritDoc} */ + @Override public char[] readCharArray(int cnt) { + return readArray(CHAR_ARR_CREATOR, cnt, 1, CHAR_ARR_OFF); + } + + /** {@inheritDoc} */ + @Override public int readInt() { + assert buf.remaining() >= 4; + + int pos = buf.position(); + + buf.position(pos + 4); + + return UNSAFE.getInt(heapArr, baseOff + pos); + } + + /** {@inheritDoc} */ + @Override public int readInt(int pos) { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Override public int[] readIntArray(int cnt) { + return readArray(INT_ARR_CREATOR, cnt, 2, INT_ARR_OFF); + } + + /** {@inheritDoc} */ + @Override public float readFloat() { + assert buf.remaining() >= 4; + + int pos = buf.position(); + + buf.position(pos + 4); + + return UNSAFE.getFloat(heapArr, baseOff + pos); + } + + /** {@inheritDoc} */ + @Override public float[] readFloatArray(int cnt) { + return readArray(FLOAT_ARR_CREATOR, cnt, 2, FLOAT_ARR_OFF); + } + + /** {@inheritDoc} */ + @Override public long readLong() { + assert buf.remaining() >= 8; + + int pos = buf.position(); + + buf.position(pos + 8); + + return UNSAFE.getLong(heapArr, baseOff + pos); + } + + /** {@inheritDoc} */ + @Override public long[] readLongArray(int cnt) { + return readArray(LONG_ARR_CREATOR, cnt, 3, LONG_ARR_OFF); + } + + /** {@inheritDoc} */ + @Override public double readDouble() { + assert buf.remaining() >= 8; + + int pos = buf.position(); + + buf.position(pos + 8); + + return UNSAFE.getDouble(heapArr, baseOff + pos); + } + + /** {@inheritDoc} */ + @Override public double[] readDoubleArray(int cnt) { + return readArray(DOUBLE_ARR_CREATOR, cnt, 3, DOUBLE_ARR_OFF); + } + + /** {@inheritDoc} */ + @Override public int read(byte[] arr, int off, int len) { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Override public int read(long addr, int len) { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Override public int position() { + return buf.position(); + } + + /** {@inheritDoc} */ + @Override public void position(int pos) { + buf.position(pos); + } + + /** {@inheritDoc} */ + public int remaining() { + return buf.remaining(); + } + + /** {@inheritDoc} */ + @Override public void close() { + // No-op. + } + + /** {@inheritDoc} */ + @Override public byte[] array() { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Override public byte[] arrayCopy() { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Override public long offheapPointer() { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Override public boolean hasArray() { + throw new UnsupportedOperationException(); + } + + /** + * @param arr Array. + * @param off Offset. + * @param bytes Length in bytes. + * @return Whether array was fully written + */ + private boolean writeArray(Object arr, long off, int bytes) { + assert arr != null; + assert arr.getClass().isArray() && arr.getClass().getComponentType().isPrimitive(); + assert off > 0; + assert bytes >= 0; + assert bytes >= arrOff; + + if (!buf.hasRemaining()) + return false; + + int toWrite = bytes - arrOff; + int pos = buf.position(); + int remaining = buf.remaining(); + + if (toWrite <= remaining) { + UNSAFE.copyMemory(arr, off + arrOff, heapArr, baseOff + pos, toWrite); + + pos += toWrite; + + buf.position(pos); + + arrOff = 0; + + return true; + } + else { + UNSAFE.copyMemory(arr, off + arrOff, heapArr, baseOff + pos, remaining); + + pos += remaining; + + buf.position(pos); + + arrOff += remaining; + + return false; + } + } + + /** + * @param creator Array creator. + * @param len Array Array length. + * @param lenShift Array length shift size. + * @param off Base offset. + * @return Array or special value if it was not fully read. + */ + private T readArray(ArrayCreator creator, int len, int lenShift, long off) { + assert creator != null; + + if (tmpArr == null) { + assert len >= 0; + + switch (len) { + case 0: + return creator.create(0); + + default: + tmpArr = creator.create(len); + tmpArrBytes = len << lenShift; + } + } + + int toRead = tmpArrBytes - tmpArrOff; + int remaining = buf.remaining(); + int pos = buf.position(); + + if (remaining < toRead) { + UNSAFE.copyMemory(heapArr, baseOff + pos, tmpArr, off + tmpArrOff, remaining); + + buf.position(pos + remaining); + + tmpArrOff += remaining; + + return creator.create(-1); + } + else { + UNSAFE.copyMemory(heapArr, baseOff + pos, tmpArr, off + tmpArrOff, toRead); + + buf.position(pos + toRead); + + T arr = (T)tmpArr; + + tmpArr = null; + tmpArrBytes = 0; + tmpArrOff = 0; + + return arr; + } + } + + /** + * Array creator. + */ + private static interface ArrayCreator { + /** + * @param len Array length or {@code -1} if array was not fully read. + * @return New array. + */ + public T create(int len); + } +} diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageAdapter.java b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageAdapter.java index af63a2f0f0548..8961688b20063 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageAdapter.java +++ b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageAdapter.java @@ -14,8 +14,6 @@ import org.gridgain.grid.kernal.processors.cache.distributed.dht.preloader.*; import org.gridgain.grid.kernal.processors.clock.*; import org.gridgain.grid.util.*; -import org.gridgain.grid.util.nio.*; -import org.jetbrains.annotations.*; import java.io.*; import java.nio.*; @@ -119,26 +117,6 @@ public abstract class GridTcpCommunicationMessageAdapter implements Serializable /** */ protected final GridTcpCommunicationMessageState commState = new GridTcpCommunicationMessageState(); - /** - * @param msgWriter Message writer. - * @param nodeId Node ID (provided only if versions are different). - */ - public void messageWriter(GridNioMessageWriter msgWriter, @Nullable UUID nodeId) { - assert msgWriter != null; - - commState.messageWriter(msgWriter, nodeId); - } - - /** - * @param msgReader Message reader. - * @param nodeId Node ID (provided only if versions are different). - */ - public void messageReader(GridNioMessageReader msgReader, @Nullable UUID nodeId) { - assert msgReader != null; - - commState.messageReader(msgReader, nodeId); - } - /** * @param buf Byte buffer. * @return Whether message was fully written. diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java index abd0d3bea5e10..a5df7107fbd4e 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java +++ b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java @@ -10,15 +10,13 @@ package org.gridgain.grid.util.direct; import org.apache.ignite.lang.*; +import org.apache.ignite.portables.*; import org.gridgain.grid.kernal.processors.cache.*; import org.gridgain.grid.kernal.processors.cache.distributed.dht.preloader.*; import org.gridgain.grid.kernal.processors.clock.*; import org.gridgain.grid.util.*; -import org.gridgain.grid.util.nio.*; -import org.gridgain.grid.util.typedef.internal.*; import org.jetbrains.annotations.*; import sun.misc.*; -import sun.nio.ch.*; import java.nio.*; import java.util.*; @@ -37,225 +35,19 @@ public class GridTcpCommunicationMessageState { private static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class); /** */ - private static final long SHORT_ARR_OFF = UNSAFE.arrayBaseOffset(short[].class); + private static final int FIELD_HDR_LEN = 9; /** */ - private static final long INT_ARR_OFF = UNSAFE.arrayBaseOffset(int[].class); + private final GridPortableByteBufferStream stream = new GridPortableByteBufferStream(); /** */ - private static final long LONG_ARR_OFF = UNSAFE.arrayBaseOffset(long[].class); + private final PortableWriter writer = null;//new org.gridgain.grid.util.portable.GridPortableWriterImpl(); /** */ - private static final long FLOAT_ARR_OFF = UNSAFE.arrayBaseOffset(float[].class); + private final PortableReader reader = null;//new org.gridgain.grid.util.portable.GridPortableReaderImpl(); /** */ - private static final long DOUBLE_ARR_OFF = UNSAFE.arrayBaseOffset(double[].class); - - /** */ - private static final long CHAR_ARR_OFF = UNSAFE.arrayBaseOffset(char[].class); - - /** */ - private static final long BOOLEAN_ARR_OFF = UNSAFE.arrayBaseOffset(boolean[].class); - - /** */ - private static final byte[] BYTE_ARR_EMPTY = new byte[0]; - - /** */ - private static final short[] SHORT_ARR_EMPTY = new short[0]; - - /** */ - private static final int[] INT_ARR_EMPTY = new int[0]; - - /** */ - private static final long[] LONG_ARR_EMPTY = new long[0]; - - /** */ - private static final float[] FLOAT_ARR_EMPTY = new float[0]; - - /** */ - private static final double[] DOUBLE_ARR_EMPTY = new double[0]; - - /** */ - private static final char[] CHAR_ARR_EMPTY = new char[0]; - - /** */ - private static final boolean[] BOOLEAN_ARR_EMPTY = new boolean[0]; - - /** */ - private static final byte[] EMPTY_UUID_BYTES = new byte[16]; - - /** */ - private static final ArrayCreator BYTE_ARR_CREATOR = new ArrayCreator() { - @Override public byte[] create(int len) { - switch (len) { - case -1: - return BYTE_ARR_NOT_READ; - - case 0: - return BYTE_ARR_EMPTY; - - default: - return new byte[len]; - } - } - }; - - /** */ - private static final ArrayCreator SHORT_ARR_CREATOR = new ArrayCreator() { - @Override public short[] create(int len) { - switch (len) { - case -1: - return SHORT_ARR_NOT_READ; - - case 0: - return SHORT_ARR_EMPTY; - - default: - return new short[len]; - } - } - }; - - /** */ - private static final ArrayCreator INT_ARR_CREATOR = new ArrayCreator() { - @Override public int[] create(int len) { - switch (len) { - case -1: - return INT_ARR_NOT_READ; - - case 0: - return INT_ARR_EMPTY; - - default: - return new int[len]; - } - } - }; - - /** */ - private static final ArrayCreator LONG_ARR_CREATOR = new ArrayCreator() { - @Override public long[] create(int len) { - switch (len) { - case -1: - return LONG_ARR_NOT_READ; - - case 0: - return LONG_ARR_EMPTY; - - default: - return new long[len]; - } - } - }; - - /** */ - private static final ArrayCreator FLOAT_ARR_CREATOR = new ArrayCreator() { - @Override public float[] create(int len) { - switch (len) { - case -1: - return FLOAT_ARR_NOT_READ; - - case 0: - return FLOAT_ARR_EMPTY; - - default: - return new float[len]; - } - } - }; - - /** */ - private static final ArrayCreator DOUBLE_ARR_CREATOR = new ArrayCreator() { - @Override public double[] create(int len) { - switch (len) { - case -1: - return DOUBLE_ARR_NOT_READ; - - case 0: - return DOUBLE_ARR_EMPTY; - - default: - return new double[len]; - } - } - }; - - /** */ - private static final ArrayCreator CHAR_ARR_CREATOR = new ArrayCreator() { - @Override public char[] create(int len) { - switch (len) { - case -1: - return CHAR_ARR_NOT_READ; - - case 0: - return CHAR_ARR_EMPTY; - - default: - return new char[len]; - } - } - }; - - /** */ - private static final ArrayCreator BOOLEAN_ARR_CREATOR = new ArrayCreator() { - @Override public boolean[] create(int len) { - switch (len) { - case -1: - return BOOLEAN_ARR_NOT_READ; - - case 0: - return BOOLEAN_ARR_EMPTY; - - default: - return new boolean[len]; - } - } - }; - - /** */ - private GridNioMessageWriter msgWriter; - - /** */ - private GridNioMessageReader msgReader; - - /** */ - private UUID nodeId; - - /** */ - private ByteBuffer buf; - - /** */ - private byte[] heapArr; - - /** */ - private long baseOff; - - /** */ - private boolean arrHdrDone; - - /** */ - private int arrOff; - - /** */ - private Object tmpArr; - - /** */ - private int tmpArrOff; - - /** */ - private int tmpArrBytes; - - /** */ - private boolean msgNotNull; - - /** */ - private boolean msgNotNullDone; - - /** */ - private boolean msgTypeDone; - - /** */ - private GridTcpCommunicationMessageAdapter msg; + private boolean hdrDone; /** */ public int idx; @@ -278,495 +70,563 @@ public class GridTcpCommunicationMessageState { /** */ public int readItems; - /** - * @param msgWriter Message writer. - * @param nodeId Node ID (provided only if versions are different). - */ - public void messageWriter(GridNioMessageWriter msgWriter, @Nullable UUID nodeId) { - assert msgWriter != null; - - this.msgWriter = msgWriter; - this.nodeId = nodeId; - } - - /** - * @param msgReader Message reader. - * @param nodeId Node ID (provided only if versions are different). - */ - public void messageReader(GridNioMessageReader msgReader, @Nullable UUID nodeId) { - assert msgReader != null; - - this.msgReader = msgReader; - this.nodeId = nodeId; - } - /** * @param buf Buffer. */ public final void setBuffer(ByteBuffer buf) { assert buf != null; - - if (this.buf != buf) { - this.buf = buf; - - heapArr = buf.isDirect() ? null : buf.array(); - baseOff = buf.isDirect() ? ((DirectBuffer)buf).address() : BYTE_ARR_OFF; - } } /** + * @param name Field name. * @param b Byte value. * @return Whether value was written. */ - public final boolean putByte(byte b) { - assert buf != null; - - if (!buf.hasRemaining()) + public final boolean putByte(String name, byte b) { + if (stream.remaining() < FIELD_HDR_LEN + 1) return false; - int pos = buf.position(); - - UNSAFE.putByte(heapArr, baseOff + pos, b); - - buf.position(pos + 1); + writer.writeByte(name, b); return true; } /** + * @param name Field name. * @return Byte value. */ - public final byte getByte() { - assert buf != null; - assert buf.hasRemaining(); - - int pos = buf.position(); - - buf.position(pos + 1); - - return UNSAFE.getByte(heapArr, baseOff + pos); + public final byte getByte(String name) { + return reader.readByte(name); } /** + * @param name Field name. * @param s Short value. * @return Whether value was written. */ - public final boolean putShort(short s) { - assert buf != null; - - if (buf.remaining() < 2) + public final boolean putShort(String name, short s) { + if (stream.remaining() < FIELD_HDR_LEN + 2) return false; - int pos = buf.position(); - - UNSAFE.putShort(heapArr, baseOff + pos, s); - - buf.position(pos + 2); + writer.writeShort(name, s); return true; } /** + * @param name Field name. * @return Short value. */ - public final short getShort() { - assert buf != null; - assert buf.remaining() >= 2; - - int pos = buf.position(); - - buf.position(pos + 2); - - return UNSAFE.getShort(heapArr, baseOff + pos); + public final short getShort(String name) { + return reader.readShort(name); } /** + * @param name Field name. * @param i Integer value. * @return Whether value was written. */ - public final boolean putInt(int i) { - assert buf != null; - - if (buf.remaining() < 4) + public final boolean putInt(String name, int i) { + if (stream.remaining() < FIELD_HDR_LEN + 4) return false; - int pos = buf.position(); - - UNSAFE.putInt(heapArr, baseOff + pos, i); - - buf.position(pos + 4); + writer.writeInt(name, i); return true; } /** + * @param name Field name. * @return Integer value. */ - public final int getInt() { - assert buf != null; - assert buf.remaining() >= 4; - - int pos = buf.position(); - - buf.position(pos + 4); - - return UNSAFE.getInt(heapArr, baseOff + pos); + public final int getInt(String name) { + return reader.readInt(name); } /** + * @param name Field name. * @param l Long value. * @return Whether value was written. */ - public final boolean putLong(long l) { - assert buf != null; - - if (buf.remaining() < 8) + public final boolean putLong(String name, long l) { + if (stream.remaining() < FIELD_HDR_LEN + 8) return false; - int pos = buf.position(); - - UNSAFE.putLong(heapArr, baseOff + pos, l); - - buf.position(pos + 8); + writer.writeLong(name, l); return true; } /** + * @param name Field name. * @return Long value. */ - public final long getLong() { - assert buf != null; - assert buf.remaining() >= 8; - - int pos = buf.position(); - - buf.position(pos + 8); - - return UNSAFE.getLong(heapArr, baseOff + pos); + public final long getLong(String name) { + return reader.readLong(name); } /** + * @param name Field name. * @param f Float value. * @return Whether value was written. */ - public final boolean putFloat(float f) { - assert buf != null; - - if (buf.remaining() < 4) + public final boolean putFloat(String name, float f) { + if (stream.remaining() < FIELD_HDR_LEN + 4) return false; - int pos = buf.position(); - - UNSAFE.putFloat(heapArr, baseOff + pos, f); - - buf.position(pos + 4); + writer.writeFloat(name, f); return true; } /** + * @param name Field name. * @return Float value. */ - public final float getFloat() { - assert buf != null; - assert buf.remaining() >= 4; - - int pos = buf.position(); - - buf.position(pos + 4); - - return UNSAFE.getFloat(heapArr, baseOff + pos); + public final float getFloat(String name) { + return reader.readFloat(name); } /** + * @param name Field name. * @param d Double value. * @return Whether value was written. */ - public final boolean putDouble(double d) { - assert buf != null; - - if (buf.remaining() < 8) + public final boolean putDouble(String name, double d) { + if (stream.remaining() < FIELD_HDR_LEN + 8) return false; - int pos = buf.position(); - - UNSAFE.putDouble(heapArr, baseOff + pos, d); - - buf.position(pos + 8); + writer.writeDouble(name, d); return true; } /** + * @param name Field name. * @return Double value. */ - public final double getDouble() { - assert buf != null; - assert buf.remaining() >= 8; - - int pos = buf.position(); - - buf.position(pos + 8); - - return UNSAFE.getDouble(heapArr, baseOff + pos); + public final double getDouble(String name) { + return reader.readDouble(name); } /** + * @param name Field name. * @param c Char value. * @return Whether value was written. */ - public final boolean putChar(char c) { - assert buf != null; - - if (buf.remaining() < 2) + public final boolean putChar(String name, char c) { + if (stream.remaining() < FIELD_HDR_LEN + 2) return false; - int pos = buf.position(); - - UNSAFE.putChar(heapArr, baseOff + pos, c); - - buf.position(pos + 2); + writer.writeChar(name, c); return true; } /** + * @param name Field name. * @return Char value. */ - public final char getChar() { - assert buf != null; - assert buf.remaining() >= 2; - - int pos = buf.position(); - - buf.position(pos + 2); - - return UNSAFE.getChar(heapArr, baseOff + pos); + public final char getChar(String name) { + return reader.readChar(name); } /** + * @param name Field name. * @param b Boolean value. * @return Whether value was written. */ - public final boolean putBoolean(boolean b) { - assert buf != null; - - if (buf.remaining() < 1) + public final boolean putBoolean(String name, boolean b) { + if (stream.remaining() < FIELD_HDR_LEN + 1) return false; - int pos = buf.position(); - - UNSAFE.putBoolean(heapArr, baseOff + pos, b); - - buf.position(pos + 1); + writer.writeBoolean(name, b); return true; } /** + * @param name Field name. * @return Boolean value. */ - public final boolean getBoolean() { - assert buf != null; - assert buf.hasRemaining(); - - int pos = buf.position(); - - buf.position(pos + 1); - - return UNSAFE.getBoolean(heapArr, baseOff + pos); + public final boolean getBoolean(String name) { + return reader.readBoolean(name); } /** + * @param name Field name. * @param arr Byte array. * @return Whether array was fully written. */ - public final boolean putByteArray(@Nullable byte[] arr) { - assert buf != null; + public final boolean putByteArray(String name, @Nullable byte[] arr) { + if (!hdrDone) { + if (stream.remaining() < FIELD_HDR_LEN + 4) + return false; + + writer.writeByteArray(name, arr); - int len = arr != null ? arr.length : 0; + hdrDone = true; + } + else + stream.writeByteArray(arr); - return putArray(arr, BYTE_ARR_OFF, len, len); + return lastWritten(); } /** + * @param name Field name. * @return Byte array or special * {@link GridTcpCommunicationMessageAdapter#BYTE_ARR_NOT_READ} * value if it was not fully read. */ - public final byte[] getByteArray() { - assert buf != null; + public final byte[] getByteArray(String name) { + byte[] arr; + + if (!hdrDone) { + if (stream.remaining() < FIELD_HDR_LEN + 4) + return BYTE_ARR_NOT_READ; + + arr = reader.readByteArray(name); + + hdrDone = true; + } + else + arr = stream.readByteArray(-1); - return getArray(BYTE_ARR_CREATOR, 0, BYTE_ARR_OFF); + if (arr != BYTE_ARR_NOT_READ) + hdrDone = false; + + return arr; } /** + * @param name Field name. * @param arr Short array. * @return Whether array was fully written. */ - public final boolean putShortArray(short[] arr) { - assert buf != null; + public final boolean putShortArray(String name, short[] arr) { + if (!hdrDone) { + if (stream.remaining() < FIELD_HDR_LEN + 4) + return false; - int len = arr != null ? arr.length : 0; + writer.writeShortArray(name, arr); - return putArray(arr, SHORT_ARR_OFF, len, len << 1); + hdrDone = true; + } + else + stream.writeShortArray(arr); + + return lastWritten(); } /** + * @param name Field name. * @return Short array or special * {@link GridTcpCommunicationMessageAdapter#SHORT_ARR_NOT_READ} * value if it was not fully read. */ - public final short[] getShortArray() { - assert buf != null; + public final short[] getShortArray(String name) { + short[] arr; - return getArray(SHORT_ARR_CREATOR, 1, SHORT_ARR_OFF); + if (!hdrDone) { + if (stream.remaining() < FIELD_HDR_LEN + 4) + return SHORT_ARR_NOT_READ; + + arr = reader.readShortArray(name); + + hdrDone = true; + } + else + arr = stream.readShortArray(-1); + + if (arr != SHORT_ARR_NOT_READ) + hdrDone = false; + + return arr; } /** + * @param name Field name. * @param arr Integer array. * @return Whether array was fully written. */ - public final boolean putIntArray(int[] arr) { - assert buf != null; + public final boolean putIntArray(String name, int[] arr) { + if (!hdrDone) { + if (stream.remaining() < FIELD_HDR_LEN + 4) + return false; - int len = arr != null ? arr.length : 0; + writer.writeIntArray(name, arr); - return putArray(arr, INT_ARR_OFF, len, len << 2); + hdrDone = true; + } + else + stream.writeIntArray(arr); + + return lastWritten(); } /** + * @param name Field name. * @return Integer array or special * {@link GridTcpCommunicationMessageAdapter#INT_ARR_NOT_READ} * value if it was not fully read. */ - public final int[] getIntArray() { - assert buf != null; + public final int[] getIntArray(String name) { + int[] arr; + + if (!hdrDone) { + if (stream.remaining() < FIELD_HDR_LEN + 4) + return INT_ARR_NOT_READ; + + arr = reader.readIntArray(name); + + hdrDone = true; + } + else + arr = stream.readIntArray(-1); - return getArray(INT_ARR_CREATOR, 2, INT_ARR_OFF); + if (arr != INT_ARR_NOT_READ) + hdrDone = false; + + return arr; } /** + * @param name Field name. * @param arr Long array. * @return Whether array was fully written. */ - public final boolean putLongArray(long[] arr) { - assert buf != null; + public final boolean putLongArray(String name, long[] arr) { + if (!hdrDone) { + if (stream.remaining() < FIELD_HDR_LEN + 4) + return false; + + writer.writeLongArray(name, arr); - int len = arr != null ? arr.length : 0; + hdrDone = true; + } + else + stream.writeLongArray(arr); - return putArray(arr, LONG_ARR_OFF, len, len << 3); + return lastWritten(); } /** + * @param name Field name. * @return Long array or special * {@link GridTcpCommunicationMessageAdapter#LONG_ARR_NOT_READ} * value if it was not fully read. */ - public final long[] getLongArray() { - assert buf != null; + public final long[] getLongArray(String name) { + long[] arr; + + if (!hdrDone) { + if (stream.remaining() < FIELD_HDR_LEN + 4) + return LONG_ARR_NOT_READ; + + arr = reader.readLongArray(name); + + hdrDone = true; + } + else + arr = stream.readLongArray(-1); + + if (arr != LONG_ARR_NOT_READ) + hdrDone = false; - return getArray(LONG_ARR_CREATOR, 3, LONG_ARR_OFF); + return arr; } /** + * @param name Field name. * @param arr Float array. * @return Whether array was fully written. */ - public final boolean putFloatArray(float[] arr) { - assert buf != null; + public final boolean putFloatArray(String name, float[] arr) { + if (!hdrDone) { + if (stream.remaining() < FIELD_HDR_LEN + 4) + return false; - int len = arr != null ? arr.length : 0; + writer.writeFloatArray(name, arr); + + hdrDone = true; + } + else + stream.writeFloatArray(arr); - return putArray(arr, FLOAT_ARR_OFF, len, len << 2); + return lastWritten(); } /** + * @param name Field name. * @return Float array or special * {@link GridTcpCommunicationMessageAdapter#FLOAT_ARR_NOT_READ} * value if it was not fully read. */ - public final float[] getFloatArray() { - assert buf != null; + public final float[] getFloatArray(String name) { + float[] arr; + + if (!hdrDone) { + if (stream.remaining() < FIELD_HDR_LEN + 4) + return FLOAT_ARR_NOT_READ; + + arr = reader.readFloatArray(name); - return getArray(FLOAT_ARR_CREATOR, 2, FLOAT_ARR_OFF); + hdrDone = true; + } + else + arr = stream.readFloatArray(-1); + + if (arr != FLOAT_ARR_NOT_READ) + hdrDone = false; + + return arr; } /** + * @param name Field name. * @param arr Double array. * @return Whether array was fully written. */ - public final boolean putDoubleArray(double[] arr) { - assert buf != null; + public final boolean putDoubleArray(String name, double[] arr) { + if (!hdrDone) { + if (stream.remaining() < FIELD_HDR_LEN + 4) + return false; + + writer.writeDoubleArray(name, arr); - int len = arr != null ? arr.length : 0; + hdrDone = true; + } + else + stream.writeDoubleArray(arr); - return putArray(arr, DOUBLE_ARR_OFF, len, len << 3); + return lastWritten(); } /** + * @param name Field name. * @return Double array or special * {@link GridTcpCommunicationMessageAdapter#DOUBLE_ARR_NOT_READ} * value if it was not fully read. */ - public final double[] getDoubleArray() { - assert buf != null; + public final double[] getDoubleArray(String name) { + double[] arr; + + if (!hdrDone) { + if (stream.remaining() < FIELD_HDR_LEN + 4) + return DOUBLE_ARR_NOT_READ; + + arr = reader.readDoubleArray(name); + + hdrDone = true; + } + else + arr = stream.readDoubleArray(-1); - return getArray(DOUBLE_ARR_CREATOR, 3, DOUBLE_ARR_OFF); + if (arr != DOUBLE_ARR_NOT_READ) + hdrDone = false; + + return arr; } /** + * @param name Field name. * @param arr Char array. * @return Whether array was fully written. */ - public final boolean putCharArray(char[] arr) { - assert buf != null; + public final boolean putCharArray(String name, char[] arr) { + if (!hdrDone) { + if (stream.remaining() < FIELD_HDR_LEN + 4) + return false; - int len = arr != null ? arr.length : 0; + writer.writeCharArray(name, arr); - return putArray(arr, CHAR_ARR_OFF, len, len << 1); + hdrDone = true; + } + else + stream.writeCharArray(arr); + + return lastWritten(); } /** + * @param name Field name. * @return Char array or special * {@link GridTcpCommunicationMessageAdapter#CHAR_ARR_NOT_READ} * value if it was not fully read. */ - public final char[] getCharArray() { - assert buf != null; + public final char[] getCharArray(String name) { + char[] arr; - return getArray(CHAR_ARR_CREATOR, 1, CHAR_ARR_OFF); + if (!hdrDone) { + if (stream.remaining() < FIELD_HDR_LEN + 4) + return CHAR_ARR_NOT_READ; + + arr = reader.readCharArray(name); + + hdrDone = true; + } + else + arr = stream.readCharArray(-1); + + if (arr != CHAR_ARR_NOT_READ) + hdrDone = false; + + return arr; } /** + * @param name Field name. * @param arr Boolean array. * @return Whether array was fully written. */ - public final boolean putBooleanArray(boolean[] arr) { - assert buf != null; + public final boolean putBooleanArray(String name, boolean[] arr) { + if (!hdrDone) { + if (stream.remaining() < FIELD_HDR_LEN + 4) + return false; - int len = arr != null ? arr.length : 0; + writer.writeBooleanArray(name, arr); - return putArray(arr, BOOLEAN_ARR_OFF, len, len); + hdrDone = true; + } + else + stream.writeBooleanArray(arr); + + return lastWritten(); } /** + * @param name Field name. * @return Boolean array or special * {@link GridTcpCommunicationMessageAdapter#BOOLEAN_ARR_NOT_READ} * value if it was not fully read. */ - public final boolean[] getBooleanArray() { - assert buf != null; + public final boolean[] getBooleanArray(String name) { + boolean[] arr; + + if (!hdrDone) { + if (stream.remaining() < FIELD_HDR_LEN + 4) + return BOOLEAN_ARR_NOT_READ; + + arr = reader.readBooleanArray(name); + + hdrDone = true; + } + else + arr = stream.readBooleanArray(-1); - return getArray(BOOLEAN_ARR_CREATOR, 0, BOOLEAN_ARR_OFF); + if (arr != BOOLEAN_ARR_NOT_READ) + hdrDone = false; + + return arr; } /** + * @param name Field name. * @param uuid {@link UUID}. * @return Whether value was fully written. */ - public final boolean putUuid(@Nullable UUID uuid) { + public final boolean putUuid(String name, @Nullable UUID uuid) { byte[] arr = null; if (uuid != null) { @@ -776,16 +636,17 @@ public final boolean putUuid(@Nullable UUID uuid) { UNSAFE.putLong(arr, BYTE_ARR_OFF + 8, uuid.getLeastSignificantBits()); } - return putByteArray(arr); + return putByteArray(name, arr); } /** + * @param name Field name. * @return {@link UUID} or special * {@link GridTcpCommunicationMessageAdapter#UUID_NOT_READ} * value if it was not fully read. */ - public final UUID getUuid() { - byte[] arr = getByteArray(); + public final UUID getUuid(String name) { + byte[] arr = getByteArray(name); if (arr == BYTE_ARR_NOT_READ) return UUID_NOT_READ; @@ -800,10 +661,11 @@ else if (arr == null) } /** - * @param uuid {@link org.apache.ignite.lang.IgniteUuid}. + * @param name Field name. + * @param uuid {@link IgniteUuid}. * @return Whether value was fully written. */ - public final boolean putGridUuid(@Nullable IgniteUuid uuid) { + public final boolean putGridUuid(String name, @Nullable IgniteUuid uuid) { byte[] arr = null; if (uuid != null) { @@ -814,16 +676,17 @@ public final boolean putGridUuid(@Nullable IgniteUuid uuid) { UNSAFE.putLong(arr, BYTE_ARR_OFF + 16, uuid.localId()); } - return putByteArray(arr); + return putByteArray(name, arr); } /** + * @param name Field name. * @return {@link org.apache.ignite.lang.IgniteUuid} or special * {@link GridTcpCommunicationMessageAdapter#GRID_UUID_NOT_READ} * value if it was not fully read. */ - public final IgniteUuid getGridUuid() { - byte[] arr = getByteArray(); + public final IgniteUuid getGridUuid(String name) { + byte[] arr = getByteArray(name); if (arr == BYTE_ARR_NOT_READ) return GRID_UUID_NOT_READ; @@ -839,10 +702,11 @@ else if (arr == null) } /** + * @param name Field name. * @param ver {@link GridClockDeltaVersion}. * @return Whether value was fully written. */ - public final boolean putClockDeltaVersion(@Nullable GridClockDeltaVersion ver) { + public final boolean putClockDeltaVersion(String name, @Nullable GridClockDeltaVersion ver) { byte[] arr = null; if (ver != null) { @@ -852,16 +716,17 @@ public final boolean putClockDeltaVersion(@Nullable GridClockDeltaVersion ver) { UNSAFE.putLong(arr, BYTE_ARR_OFF + 8, ver.topologyVersion()); } - return putByteArray(arr); + return putByteArray(name, arr); } /** + * @param name Field name. * @return {@link GridClockDeltaVersion} or special * {@link GridTcpCommunicationMessageAdapter#CLOCK_DELTA_VER_NOT_READ} * value if it was not fully read. */ - public final GridClockDeltaVersion getClockDeltaVersion() { - byte[] arr = getByteArray(); + public final GridClockDeltaVersion getClockDeltaVersion(String name) { + byte[] arr = getByteArray(name); if (arr == BYTE_ARR_NOT_READ) return CLOCK_DELTA_VER_NOT_READ; @@ -876,24 +741,23 @@ else if (arr == null) } /** + * @param name Field name. * @param list {@link GridByteArrayList}. * @return Whether value was fully written. */ - public final boolean putByteArrayList(@Nullable GridByteArrayList list) { - byte[] arr = list != null ? list.internalArray() : null; - int size = list != null ? list.size() : 0; - - return putArray(arr, BYTE_ARR_OFF, size, size); + public final boolean putByteArrayList(String name, @Nullable GridByteArrayList list) { + return putByteArray(name, list != null ? list.array() : null); } /** + * @param name Field name. * @return {@link GridByteArrayList} or special * {@link GridTcpCommunicationMessageAdapter#BYTE_ARR_LIST_NOT_READ} * value if it was not fully read. */ @SuppressWarnings("IfMayBeConditional") - public final GridByteArrayList getByteArrayList() { - byte[] arr = getByteArray(); + public final GridByteArrayList getByteArrayList(String name) { + byte[] arr = getByteArray(name); if (arr == BYTE_ARR_NOT_READ) return BYTE_ARR_LIST_NOT_READ; @@ -904,24 +768,23 @@ else if (arr == null) } /** + * @param name Field name. * @param list {@link GridLongList}. * @return Whether value was fully written. */ - public final boolean putLongList(@Nullable GridLongList list) { - long[] arr = list != null ? list.internalArray() : null; - int size = list != null ? list.size() : 0; - - return putArray(arr, LONG_ARR_OFF, size, size << 3); + public final boolean putLongList(String name, @Nullable GridLongList list) { + return putLongArray(name, list != null ? list.array() : null); } /** + * @param name Field name. * @return {@link GridLongList} or special * {@link GridTcpCommunicationMessageAdapter#LONG_LIST_NOT_READ} * value if it was not fully read. */ @SuppressWarnings("IfMayBeConditional") - public final GridLongList getLongList() { - long[] arr = getLongArray(); + public final GridLongList getLongList(String name) { + long[] arr = getLongArray(name); if (arr == LONG_ARR_NOT_READ) return LONG_LIST_NOT_READ; @@ -932,10 +795,11 @@ else if (arr == null) } /** + * @param name Field name. * @param ver {@link GridCacheVersion}. * @return Whether value was fully written. */ - public final boolean putCacheVersion(@Nullable GridCacheVersion ver) { + public final boolean putCacheVersion(String name, @Nullable GridCacheVersion ver) { byte[] arr = null; if (ver != null) { @@ -947,16 +811,17 @@ public final boolean putCacheVersion(@Nullable GridCacheVersion ver) { UNSAFE.putLong(arr, BYTE_ARR_OFF + 16, ver.order()); } - return putByteArray(arr); + return putByteArray(name, arr); } /** + * @param name Field name. * @return {@link GridCacheVersion} or special * {@link GridTcpCommunicationMessageAdapter#CACHE_VER_NOT_READ} * value if it was not fully read. */ - public final GridCacheVersion getCacheVersion() { - byte[] arr = getByteArray(); + public final GridCacheVersion getCacheVersion(String name) { + byte[] arr = getByteArray(name); if (arr == BYTE_ARR_NOT_READ) return CACHE_VER_NOT_READ; @@ -973,10 +838,11 @@ else if (arr == null) } /** + * @param name Field name. * @param id {@link GridDhtPartitionExchangeId}. * @return Whether value was fully written. */ - public final boolean putDhtPartitionExchangeId(@Nullable GridDhtPartitionExchangeId id) { + public final boolean putDhtPartitionExchangeId(String name, @Nullable GridDhtPartitionExchangeId id) { byte[] arr = null; if (id != null) { @@ -988,16 +854,17 @@ public final boolean putDhtPartitionExchangeId(@Nullable GridDhtPartitionExchang UNSAFE.putLong(arr, BYTE_ARR_OFF + 20, id.topologyVersion()); } - return putByteArray(arr); + return putByteArray(name, arr); } /** + * @param name Field name. * @return {@link GridDhtPartitionExchangeId} or special * {@link GridTcpCommunicationMessageAdapter#DHT_PART_EXCHANGE_ID_NOT_READ} * value if it was not fully read. */ - public final GridDhtPartitionExchangeId getDhtPartitionExchangeId() { - byte[] arr = getByteArray(); + public final GridDhtPartitionExchangeId getDhtPartitionExchangeId(String name) { + byte[] arr = getByteArray(name); if (arr == BYTE_ARR_NOT_READ) return DHT_PART_EXCHANGE_ID_NOT_READ; @@ -1014,20 +881,23 @@ else if (arr == null) } /** + * @param name Field name. * @param bytes {@link GridCacheValueBytes}. * @return Whether value was fully written. */ - public final boolean putValueBytes(@Nullable GridCacheValueBytes bytes) { + public final boolean putValueBytes(String name, @Nullable GridCacheValueBytes bytes) { byte[] arr = null; if (bytes != null) { - if (bytes.get() != null) { - int len = bytes.get().length; + byte[] bytes0 = bytes.get(); + + if (bytes0 != null) { + int len = bytes0.length; arr = new byte[len + 2]; UNSAFE.putBoolean(arr, BYTE_ARR_OFF, true); - UNSAFE.copyMemory(bytes.get(), BYTE_ARR_OFF, arr, BYTE_ARR_OFF + 1, len); + UNSAFE.copyMemory(bytes0, BYTE_ARR_OFF, arr, BYTE_ARR_OFF + 1, len); UNSAFE.putBoolean(arr, BYTE_ARR_OFF + 1 + len, bytes.isPlain()); } else { @@ -1037,16 +907,17 @@ public final boolean putValueBytes(@Nullable GridCacheValueBytes bytes) { } } - return putByteArray(arr); + return putByteArray(name, arr); } /** + * @param name Field name. * @return {@link GridCacheValueBytes} or special * {@link GridTcpCommunicationMessageAdapter#VAL_BYTES_NOT_READ} * value if it was not fully read. */ - public final GridCacheValueBytes getValueBytes() { - byte[] arr = getByteArray(); + public final GridCacheValueBytes getValueBytes(String name) { + byte[] arr = getByteArray(name); if (arr == BYTE_ARR_NOT_READ) return VAL_BYTES_NOT_READ; @@ -1074,20 +945,22 @@ else if (arr == null) } /** + * @param name Field name. * @param str {@link String}. * @return Whether value was fully written. */ - public final boolean putString(@Nullable String str) { - return putByteArray(str != null ? str.getBytes() : null); + public final boolean putString(String name, @Nullable String str) { + return putByteArray(name, str != null ? str.getBytes() : null); } /** + * @param name Field name. * @return {@link String} or special {@link GridTcpCommunicationMessageAdapter#STR_NOT_READ} * value if it was not fully read. */ @SuppressWarnings("IfMayBeConditional") - public final String getString() { - byte[] arr = getByteArray(); + public final String getString(String name) { + byte[] arr = getByteArray(name); if (arr == BYTE_ARR_NOT_READ) return STR_NOT_READ; @@ -1098,20 +971,22 @@ else if (arr == null) } /** + * @param name Field name. * @param bits {@link BitSet}. * @return Whether value was fully written. */ - public final boolean putBitSet(@Nullable BitSet bits) { - return putLongArray(bits != null ? bits.toLongArray() : null); + public final boolean putBitSet(String name, @Nullable BitSet bits) { + return putLongArray(name, bits != null ? bits.toLongArray() : null); } /** + * @param name Field name. * @return {@link BitSet} or special {@link GridTcpCommunicationMessageAdapter#BIT_SET_NOT_READ} * value if it was not fully read. */ @SuppressWarnings("IfMayBeConditional") - public final BitSet getBitSet() { - long[] arr = getLongArray(); + public final BitSet getBitSet(String name) { + long[] arr = getLongArray(name); if (arr == LONG_ARR_NOT_READ) return BIT_SET_NOT_READ; @@ -1122,469 +997,69 @@ else if (arr == null) } /** + * @param name Field name. * @param e Enum. * @return Whether value was fully written. */ - public final boolean putEnum(@Nullable Enum e) { - return putByte(e != null ? (byte)e.ordinal() : -1); + public final boolean putEnum(String name, @Nullable Enum e) { + return putByte(name, e != null ? (byte)e.ordinal() : -1); } /** + * @param name Field name. * @param msg {@link GridTcpCommunicationMessageAdapter}. * @return Whether value was fully written. */ - public final boolean putMessage(@Nullable GridTcpCommunicationMessageAdapter msg) { - assert buf != null; - - if (!msgNotNullDone) { - if (!putBoolean(msg != null)) + public final boolean putMessage(String name, @Nullable GridTcpCommunicationMessageAdapter msg) { + if (!hdrDone) { + if (stream.remaining() < FIELD_HDR_LEN) return false; - msgNotNullDone = true; - } - - if (msg != null) { - if (!msgWriter.write(nodeId, msg, buf)) - return false; + writer.writeObject(name, msg); - msgNotNullDone = false; + hdrDone = true; } + else + stream.writeMessage(msg); - return true; + return lastWritten(); } /** + * @param name Field name. * @return {@link GridTcpCommunicationMessageAdapter} or special - * {@link GridTcpCommunicationMessageAdapter#MSG_NOT_READ} + * {@link GridTcpCommunicationMessageAdapter#MSG_NOT_READ} * value if it was not fully read. */ - public final GridTcpCommunicationMessageAdapter getMessage() { - assert buf != null; + public final GridTcpCommunicationMessageAdapter getMessage(String name) { + GridTcpCommunicationMessageAdapter msg; - if (!msgNotNullDone) { - if (!buf.hasRemaining()) + if (!hdrDone) { + if (stream.remaining() < FIELD_HDR_LEN) return MSG_NOT_READ; - msgNotNull = getBoolean(); - - msgNotNullDone = true; - } - - if (msgNotNull) { - if (!msgTypeDone) { - if (!buf.hasRemaining()) - return MSG_NOT_READ; - - GridTcpMessageFactory factory = msgReader.messageFactory(); - - byte type = getByte(); - - msg = factory != null ? factory.create(type) : GridTcpCommunicationMessageFactory.create(type); - - msgTypeDone = true; - } - - if (msgReader.read(nodeId, msg, buf)) { - GridTcpCommunicationMessageAdapter msg0 = msg; + msg = reader.readObject(name); - msgNotNullDone = false; - msgTypeDone = false; - msg = null; - - return msg0; - } - else - return MSG_NOT_READ; + hdrDone = true; } else - return null; - } - - /** - * @param arr Array. - * @param off Offset. - * @param len Length. - * @param bytes Length in bytes. - * @return Whether array was fully written - */ - private boolean putArray(@Nullable Object arr, long off, int len, int bytes) { - assert off > 0; - assert len >= 0; - assert bytes >= 0; - assert bytes >= arrOff; - - if (!buf.hasRemaining()) - return false; - - int pos = buf.position(); - - if (arr != null) { - assert arr.getClass().isArray() && arr.getClass().getComponentType().isPrimitive(); - - if (!arrHdrDone) { - if (buf.remaining() < 5) - return false; - - UNSAFE.putBoolean(heapArr, baseOff + pos++, true); - UNSAFE.putInt(heapArr, baseOff + pos, len); - - pos += 4; - - buf.position(pos); - - arrHdrDone = true; - } - - if (!buf.hasRemaining()) - return false; - - int left = bytes - arrOff; - int remaining = buf.remaining(); - - if (left <= remaining) { - UNSAFE.copyMemory(arr, off + arrOff, heapArr, baseOff + pos, left); - - pos += left; - - buf.position(pos); - - arrHdrDone = false; - arrOff = 0; - } - else { - UNSAFE.copyMemory(arr, off + arrOff, heapArr, baseOff + pos, remaining); - - pos += remaining; - - buf.position(pos); - - arrOff += remaining; - - return false; - } - } - else { - UNSAFE.putBoolean(heapArr, baseOff + pos++, false); - - buf.position(pos); - } - - return true; - } - - /** - * @param creator Array creator. - * @param lenShift Array length shift size. - * @param off Base offset. - * @return Array or special value if it was not fully read. - */ - private T getArray(ArrayCreator creator, int lenShift, long off) { - assert creator != null; - assert lenShift >= 0; - - if (!arrHdrDone) { - if (!buf.hasRemaining()) - return creator.create(-1); - - if (!getBoolean()) - return null; - - arrHdrDone = true; - } - - if (tmpArr == null) { - if (buf.remaining() < 4) - return creator.create(-1); - - int len = getInt(); - - if (len == 0) { - arrHdrDone = false; - - return creator.create(0); - } - - tmpArr = creator.create(len); - tmpArrBytes = len << lenShift; - } - - int toRead = tmpArrBytes - tmpArrOff; - int remaining = buf.remaining(); - int pos = buf.position(); - - if (remaining < toRead) { - UNSAFE.copyMemory(heapArr, baseOff + pos, tmpArr, off + tmpArrOff, remaining); - - buf.position(pos + remaining); - - tmpArrOff += remaining; - - return creator.create(-1); - } - else { - UNSAFE.copyMemory(heapArr, baseOff + pos, tmpArr, off + tmpArrOff, toRead); - - buf.position(pos + toRead); - - T arr = (T)tmpArr; - - arrHdrDone = false; - tmpArr = null; - tmpArrBytes = 0; - tmpArrOff = 0; - - return arr; - } - } - - /** - * @param i Integer value. - * @return Whether value was written. - */ - public final boolean putIntClient(int i) { - assert buf != null; - - if (buf.remaining() < 4) - return false; - - putByte((byte)(0xFF & (i >>> 24))); - putByte((byte)(0xFF & (i >>> 16))); - putByte((byte)(0xFF & (i >>> 8))); - putByte((byte)(0xFF & i)); - - return true; - } - - /** - * @return Integer value. - */ - public final int getIntClient() { - assert buf != null; - assert buf.remaining() >= 4; - - int val = 0; - - val |= (0xFF & getByte()) << 24; - val |= (0xFF & getByte()) << 16; - val |= (0xFF & getByte()) << 8; - val |= (0xFF & getByte()); - - return val; - } - - /** - * @param val Long value. - * @return Whether value was written. - */ - public final boolean putLongClient(long val) { - assert buf != null; - - if (buf.remaining() < 8) - return false; - - putByte((byte)(val >>> 56)); - putByte((byte)(0xFFL & (val >>> 48))); - putByte((byte)(0xFFL & (val >>> 40))); - putByte((byte)(0xFFL & (val >>> 32))); - putByte((byte)(0xFFL & (val >>> 24))); - putByte((byte)(0xFFL & (val >>> 16))); - putByte((byte)(0xFFL & (val >>> 8))); - putByte((byte) (0xFFL & val)); - - return true; - } - - /** - * @return Long value. - */ - public final long getLongClient() { - assert buf != null; - assert buf.remaining() >= 8; - - long x = 0; - - x |= (0xFFL & getByte()) << 56; - x |= (0xFFL & getByte()) << 48; - x |= (0xFFL & getByte()) << 40; - x |= (0xFFL & getByte()) << 32; - x |= (0xFFL & getByte()) << 24; - x |= (0xFFL & getByte()) << 16; - x |= (0xFFL & getByte()) << 8; - x |= (0xFFL & getByte()); - - return x; - } - - /** - * @param uuid {@link UUID}. - * @return Whether value was fully written. - */ - public final boolean putUuidClient(@Nullable UUID uuid) { - byte[] arr = uuid != null ? U.uuidToBytes(uuid) : EMPTY_UUID_BYTES; - - return putByteArrayClient(arr); - } - - /** - * @param arr Byte array. - * @return Whether array was fully written. - */ - public final boolean putByteArrayClient(byte[] arr) { - assert buf != null; - assert arr != null; - - return putArrayClient(arr, BYTE_ARR_OFF, arr.length, arr.length); - } - - /** - * @param src Buffer. - * @return Whether array was fully written - */ - public boolean putByteBufferClient(ByteBuffer src) { - assert src != null; - assert src.hasArray(); + msg = stream.readMessage(); - return putArrayClient(src.array(), BYTE_ARR_OFF + src.position(), src.remaining(), src.remaining()); - } - - /** - * @param arr Array. - * @param off Offset. - * @param len Length. - * @param bytes Length in bytes. - * @return Whether array was fully written - */ - private boolean putArrayClient(Object arr, long off, int len, int bytes) { - assert off > 0; - assert len >= 0; - assert bytes >= 0; - assert bytes >= arrOff; - assert arr != null; - - if (!buf.hasRemaining()) - return false; - - int pos = buf.position(); - - assert arr.getClass().isArray() && arr.getClass().getComponentType().isPrimitive(); - - if (!arrHdrDone) - arrHdrDone = true; - - if (!buf.hasRemaining()) - return false; - - int left = bytes - arrOff; - int remaining = buf.remaining(); - - if (left <= remaining) { - UNSAFE.copyMemory(arr, off + arrOff, heapArr, baseOff + pos, left); - - pos += left; - - buf.position(pos); - - arrHdrDone = false; - arrOff = 0; - } - else { - UNSAFE.copyMemory(arr, off + arrOff, heapArr, baseOff + pos, remaining); - - pos += remaining; - - buf.position(pos); - - arrOff += remaining; - - return false; - } - - return true; - } - - /** - * @param len Array length. - * @return Byte array or special {@link GridTcpCommunicationMessageAdapter#BYTE_ARR_NOT_READ} - * value if it was not fully read. - */ - public final byte[] getByteArrayClient(int len) { - assert buf != null; + if (msg != MSG_NOT_READ) + hdrDone = false; - return getArrayClient(BYTE_ARR_CREATOR, BYTE_ARR_OFF, len); + return msg; } /** - * @return {@link UUID} or special - * {@link GridTcpCommunicationMessageAdapter#UUID_NOT_READ} - * value if it was not fully read. + * @return Whether last array was fully written. */ - public final UUID getUuidClient() { - byte[] arr = getByteArrayClient(16); - - assert arr != null; - - return arr == BYTE_ARR_NOT_READ ? UUID_NOT_READ : U.bytesToUuid(arr, 0); - } - - /** - * @param creator Array creator. - * @param off Base offset. - * @param len Length. - * @return Array or special value if it was not fully read. - */ - private T getArrayClient(ArrayCreator creator, long off, int len) { - assert creator != null; - - if (tmpArr == null) { - tmpArr = creator.create(len); - tmpArrBytes = len; - } - - int toRead = tmpArrBytes - tmpArrOff; - int remaining = buf.remaining(); - int pos = buf.position(); - - if (remaining < toRead) { - UNSAFE.copyMemory(heapArr, baseOff + pos, tmpArr, off + tmpArrOff, remaining); - - buf.position(pos + remaining); + private boolean lastWritten() { + boolean written = stream.lastWritten(); - tmpArrOff += remaining; + if (written) + hdrDone = false; - return creator.create(-1); - } - else { - UNSAFE.copyMemory(heapArr, baseOff + pos, tmpArr, off + tmpArrOff, toRead); - - buf.position(pos + toRead); - - T arr = (T)tmpArr; - - arrHdrDone = false; - tmpArr = null; - tmpArrBytes = 0; - tmpArrOff = 0; - - return arr; - } - } - - /** - * Array creator. - */ - private static interface ArrayCreator { - /** - * @param len Array length or {@code -1} if array was not fully read. - * @return New array. - */ - public T create(int len); - } - - /** - * Dummy enum. - */ - private enum DummyEnum { - /** */ - DUMMY + return written; } } diff --git a/modules/core/src/main/java/org/gridgain/grid/util/ipc/GridIpcToNioAdapter.java b/modules/core/src/main/java/org/gridgain/grid/util/ipc/GridIpcToNioAdapter.java index 0222add6fc4b0..3f02666764aa2 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/ipc/GridIpcToNioAdapter.java +++ b/modules/core/src/main/java/org/gridgain/grid/util/ipc/GridIpcToNioAdapter.java @@ -10,9 +10,9 @@ package org.gridgain.grid.util.ipc; import org.apache.ignite.*; -import org.gridgain.grid.*; import org.gridgain.grid.util.direct.*; import org.gridgain.grid.util.nio.*; +import org.gridgain.grid.util.typedef.internal.*; import java.io.*; import java.nio.*; @@ -45,25 +45,19 @@ public class GridIpcToNioAdapter { /** */ private final GridNioMetricsListener metricsLsnr; - /** */ - private final GridNioMessageWriter msgWriter; - /** * @param metricsLsnr Metrics listener. * @param log Log. * @param endp Endpoint. - * @param msgWriter Message writer. * @param lsnr Listener. * @param filters Filters. */ public GridIpcToNioAdapter(GridNioMetricsListener metricsLsnr, IgniteLogger log, GridIpcEndpoint endp, - GridNioMessageWriter msgWriter, GridNioServerListener lsnr, GridNioFilter... filters) { + GridNioServerListener lsnr, GridNioFilter... filters) { assert metricsLsnr != null; - assert msgWriter != null; this.metricsLsnr = metricsLsnr; this.endp = endp; - this.msgWriter = msgWriter; chain = new GridNioFilterChain<>(log, lsnr, new HeadFilter(), filters); ses = new GridNioSessionImpl(chain, null, null, true); @@ -145,10 +139,7 @@ private GridNioFuture send(GridTcpCommunicationMessageAdapter msg) { assert writeBuf.hasArray(); try { - // This method is called only on handshake, - // so we don't need to provide node ID for - // rolling updates support. - int cnt = msgWriter.writeFully(null, msg, endp.outputStream(), writeBuf); + int cnt = U.writeMessageFully(msg, endp.outputStream(), writeBuf); metricsLsnr.onBytesSent(cnt); } diff --git a/modules/core/src/main/java/org/gridgain/grid/util/nio/GridDirectParser.java b/modules/core/src/main/java/org/gridgain/grid/util/nio/GridDirectParser.java index 2a87162152e36..cacb9808d4b33 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/nio/GridDirectParser.java +++ b/modules/core/src/main/java/org/gridgain/grid/util/nio/GridDirectParser.java @@ -16,7 +16,6 @@ import java.io.*; import java.nio.*; -import java.util.*; /** * Parser for direct messages. @@ -25,9 +24,6 @@ public class GridDirectParser implements GridNioParser { /** Message metadata key. */ private static final int MSG_META_KEY = GridNioSessionMetaKey.nextUniqueKey(); - /** Message reader. */ - private final GridNioMessageReader msgReader; - /** */ private IgniteSpiAdapter spi; @@ -35,11 +31,9 @@ public class GridDirectParser implements GridNioParser { private GridTcpMessageFactory msgFactory; /** - * @param msgReader Message reader. * @param spi Spi. */ - public GridDirectParser(GridNioMessageReader msgReader, IgniteSpiAdapter spi) { - this.msgReader = msgReader; + public GridDirectParser(IgniteSpiAdapter spi) { this.spi = spi; } @@ -49,7 +43,6 @@ public GridDirectParser(GridNioMessageReader msgReader, IgniteSpiAdapter spi) { msgFactory = spi.getSpiContext().messageFactory(); GridTcpCommunicationMessageAdapter msg = ses.removeMeta(MSG_META_KEY); - UUID nodeId = ses.meta(GridNioServer.DIFF_VER_NODE_ID_META_KEY); if (msg == null && buf.hasRemaining()) msg = msgFactory.create(buf.get()); @@ -57,7 +50,7 @@ public GridDirectParser(GridNioMessageReader msgReader, IgniteSpiAdapter spi) { boolean finished = false; if (buf.hasRemaining()) - finished = msgReader.read(nodeId, msg, buf); + finished = msg.readFrom(buf); if (finished) return msg; diff --git a/modules/core/src/main/java/org/gridgain/grid/util/nio/GridNioMessageReader.java b/modules/core/src/main/java/org/gridgain/grid/util/nio/GridNioMessageReader.java deleted file mode 100644 index 1d9529ec29d9b..0000000000000 --- a/modules/core/src/main/java/org/gridgain/grid/util/nio/GridNioMessageReader.java +++ /dev/null @@ -1,34 +0,0 @@ -/* @java.file.header */ - -/* _________ _____ __________________ _____ - * __ ____/___________(_)______ /__ ____/______ ____(_)_______ - * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ - * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / - * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ - */ - -package org.gridgain.grid.util.nio; - -import org.gridgain.grid.util.direct.*; -import org.jetbrains.annotations.*; - -import java.nio.*; -import java.util.*; - -/** - * Message reader. - */ -public interface GridNioMessageReader { - /** - * @param nodeId Node ID. - * @param msg Message to read. - * @param buf Buffer. - * @return Whether message was fully read. - */ - public boolean read(@Nullable UUID nodeId, GridTcpCommunicationMessageAdapter msg, ByteBuffer buf); - - /** - * @return Optional message factory. - */ - @Nullable public GridTcpMessageFactory messageFactory(); -} diff --git a/modules/core/src/main/java/org/gridgain/grid/util/nio/GridNioMessageWriter.java b/modules/core/src/main/java/org/gridgain/grid/util/nio/GridNioMessageWriter.java deleted file mode 100644 index 4271d77dfc295..0000000000000 --- a/modules/core/src/main/java/org/gridgain/grid/util/nio/GridNioMessageWriter.java +++ /dev/null @@ -1,41 +0,0 @@ -/* @java.file.header */ - -/* _________ _____ __________________ _____ - * __ ____/___________(_)______ /__ ____/______ ____(_)_______ - * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ - * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / - * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ - */ - -package org.gridgain.grid.util.nio; - -import org.gridgain.grid.util.direct.*; -import org.jetbrains.annotations.*; - -import java.io.*; -import java.nio.*; -import java.util.*; - -/** - * Message writer. - */ -public interface GridNioMessageWriter { - /** - * @param nodeId Node ID. - * @param msg Message to write. - * @param buf Buffer. - * @return Whether message was fully written. - */ - public boolean write(@Nullable UUID nodeId, GridTcpCommunicationMessageAdapter msg, ByteBuffer buf); - - /** - * @param nodeId Node ID. - * @param msg Message to write. - * @param out Output stream to write to. - * @param buf Buffer. - * @return Number of bytes written. - * @throws IOException In case of error. - */ - public int writeFully(@Nullable UUID nodeId, GridTcpCommunicationMessageAdapter msg, OutputStream out, - ByteBuffer buf) throws IOException; -} diff --git a/modules/core/src/main/java/org/gridgain/grid/util/nio/GridNioServer.java b/modules/core/src/main/java/org/gridgain/grid/util/nio/GridNioServer.java index b0279ef8872d1..03c37632f85c4 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/nio/GridNioServer.java +++ b/modules/core/src/main/java/org/gridgain/grid/util/nio/GridNioServer.java @@ -59,12 +59,9 @@ public class GridNioServer { /** Buffer metadata key. */ private static final int BUF_META_KEY = GridNioSessionMetaKey.nextUniqueKey(); - /** SSL sysmtem data buffer metadata key. */ + /** SSL system data buffer metadata key. */ private static final int BUF_SSL_SYSTEM_META_KEY = GridNioSessionMetaKey.nextUniqueKey(); - /** Node ID meta key (set only if versions are different). */ - public static final int DIFF_VER_NODE_ID_META_KEY = GridNioSessionMetaKey.nextUniqueKey(); - /** Accept worker thread. */ @GridToStringExclude private final IgniteThread acceptThread; @@ -126,9 +123,6 @@ public class GridNioServer { /** Metrics listener. */ private final GridNioMetricsListener metricsLsnr; - /** Message writer. */ - private final GridNioMessageWriter msgWriter; - /** Sessions. */ private final GridConcurrentHashSet sessions = new GridConcurrentHashSet<>(); @@ -162,7 +156,6 @@ public class GridNioServer { * @param directMode Whether direct mode is used. * @param daemon Daemon flag to create threads. * @param metricsLsnr Metrics listener. - * @param msgWriter Message writer. * @param filters Filters for this server. * @throws IgniteCheckedException If failed. */ @@ -182,7 +175,6 @@ private GridNioServer( boolean directMode, boolean daemon, GridNioMetricsListener metricsLsnr, - GridNioMessageWriter msgWriter, GridNioFilter... filters ) throws IgniteCheckedException { A.notNull(addr, "addr"); @@ -247,7 +239,6 @@ private GridNioServer( this.directMode = directMode; this.metricsLsnr = metricsLsnr; - this.msgWriter = msgWriter; } /** @@ -855,7 +846,6 @@ private void processWriteSsl(SelectionKey key) throws IOException { ByteBuffer buf = ses.writeBuffer(); NioOperationFuture req = ses.removeMeta(NIO_OPERATION.ordinal()); - UUID nodeId = ses.meta(DIFF_VER_NODE_ID_META_KEY); List> doneFuts = null; @@ -877,9 +867,8 @@ private void processWriteSsl(SelectionKey key) throws IOException { msg = req.directMessage(); assert msg != null; - assert msgWriter != null; - finished = msgWriter.write(nodeId, msg, buf); + finished = msg.writeTo(buf); } // Fill up as many messages as possible to write buffer. @@ -897,9 +886,8 @@ private void processWriteSsl(SelectionKey key) throws IOException { msg = req.directMessage(); assert msg != null; - assert msgWriter != null; - finished = msgWriter.write(nodeId, msg, buf); + finished = msg.writeTo(buf); } buf.flip(); @@ -995,7 +983,6 @@ private void processWrite0(SelectionKey key) throws IOException { GridSelectorNioSessionImpl ses = (GridSelectorNioSessionImpl)key.attachment(); ByteBuffer buf = ses.writeBuffer(); NioOperationFuture req = ses.removeMeta(NIO_OPERATION.ordinal()); - UUID nodeId = ses.meta(DIFF_VER_NODE_ID_META_KEY); List> doneFuts = null; @@ -1017,9 +1004,8 @@ private void processWrite0(SelectionKey key) throws IOException { msg = req.directMessage(); assert msg != null; - assert msgWriter != null; - finished = msgWriter.write(nodeId, msg, buf); + finished = msg.writeTo(buf); } // Fill up as many messages as possible to write buffer. @@ -1037,9 +1023,8 @@ private void processWrite0(SelectionKey key) throws IOException { msg = req.directMessage(); assert msg != null; - assert msgWriter != null; - finished = msgWriter.write(nodeId, msg, buf); + finished = msg.writeTo(buf); } buf.flip(); @@ -2053,9 +2038,6 @@ public static class Builder { /** Metrics listener. */ private GridNioMetricsListener metricsLsnr; - /** Message writer. */ - private GridNioMessageWriter msgWriter; - /** NIO filters. */ private GridNioFilter[] filters; @@ -2091,7 +2073,6 @@ public GridNioServer build() throws IgniteCheckedException { directMode, daemon, metricsLsnr, - msgWriter, filters != null ? Arrays.copyOf(filters, filters.length) : EMPTY_FILTERS ); @@ -2245,16 +2226,6 @@ public Builder metricsListener(GridNioMetricsListener metricsLsnr) { return this; } - /** - * @param msgWriter Message writer. - * @return This for chaining. - */ - public Builder messageWriter(GridNioMessageWriter msgWriter) { - this.msgWriter = msgWriter; - - return this; - } - /** * @param filters NIO filters. * @return This for chaining. diff --git a/modules/core/src/main/java/org/gridgain/grid/util/nio/GridShmemCommunicationClient.java b/modules/core/src/main/java/org/gridgain/grid/util/nio/GridShmemCommunicationClient.java index 501e7ee7a8d0b..56bbc94eeae2f 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/nio/GridShmemCommunicationClient.java +++ b/modules/core/src/main/java/org/gridgain/grid/util/nio/GridShmemCommunicationClient.java @@ -10,12 +10,11 @@ package org.gridgain.grid.util.nio; import org.apache.ignite.*; -import org.gridgain.grid.*; import org.gridgain.grid.util.direct.*; -import org.gridgain.grid.util.typedef.internal.*; import org.gridgain.grid.util.ipc.shmem.*; -import org.jetbrains.annotations.*; import org.gridgain.grid.util.lang.*; +import org.gridgain.grid.util.typedef.internal.*; +import org.jetbrains.annotations.*; import java.io.*; import java.nio.*; @@ -31,31 +30,23 @@ public class GridShmemCommunicationClient extends GridAbstractCommunicationClien /** */ private final ByteBuffer writeBuf; - /** */ - private final GridNioMessageWriter msgWriter; - /** * @param metricsLsnr Metrics listener. * @param port Shared memory IPC server port. * @param connTimeout Connection timeout. * @param log Logger. - * @param msgWriter Message writer. * @throws IgniteCheckedException If failed. */ - public GridShmemCommunicationClient(GridNioMetricsListener metricsLsnr, int port, long connTimeout, IgniteLogger log, - GridNioMessageWriter msgWriter) - throws IgniteCheckedException { + public GridShmemCommunicationClient(GridNioMetricsListener metricsLsnr, int port, long connTimeout, + IgniteLogger log) throws IgniteCheckedException { super(metricsLsnr); assert metricsLsnr != null; - assert msgWriter != null; assert port > 0 && port < 0xffff; assert connTimeout >= 0; shmem = new GridIpcSharedMemoryClientEndpoint(port, (int)connTimeout, log); - this.msgWriter = msgWriter; - writeBuf = ByteBuffer.allocate(8 << 10); writeBuf.order(ByteOrder.nativeOrder()); @@ -111,7 +102,7 @@ public GridShmemCommunicationClient(GridNioMetricsListener metricsLsnr, int port assert writeBuf.hasArray(); try { - int cnt = msgWriter.writeFully(nodeId, msg, shmem.outputStream(), writeBuf); + int cnt = U.writeMessageFully(msg, shmem.outputStream(), writeBuf); metricsLsnr.onBytesSent(cnt); } diff --git a/modules/core/src/main/java/org/gridgain/grid/util/nio/GridTcpCommunicationClient.java b/modules/core/src/main/java/org/gridgain/grid/util/nio/GridTcpCommunicationClient.java index 632ce352ddbb3..379e87e2c7e11 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/nio/GridTcpCommunicationClient.java +++ b/modules/core/src/main/java/org/gridgain/grid/util/nio/GridTcpCommunicationClient.java @@ -37,15 +37,11 @@ public class GridTcpCommunicationClient extends GridAbstractCommunicationClient /** Communication buffer size ratio. */ private final double bufSizeRatio; - /** */ - private final GridNioMessageWriter msgWriter; - /** */ private final ByteBuffer writeBuf; /** * @param metricsLsnr Metrics listener. - * @param msgWriter Message writer. * @param addr Address. * @param locHost Local address. * @param connTimeout Connect timeout. @@ -59,7 +55,6 @@ public class GridTcpCommunicationClient extends GridAbstractCommunicationClient */ public GridTcpCommunicationClient( GridNioMetricsListener metricsLsnr, - GridNioMessageWriter msgWriter, InetSocketAddress addr, InetAddress locHost, long connTimeout, @@ -73,7 +68,6 @@ public GridTcpCommunicationClient( super(metricsLsnr); assert metricsLsnr != null; - assert msgWriter != null; assert addr != null; assert locHost != null; assert connTimeout >= 0; @@ -84,7 +78,6 @@ public GridTcpCommunicationClient( A.ensure(bufSizeRatio > 0 && bufSizeRatio < 1, "Value of bufSizeRatio property must be between 0 and 1 (exclusive)."); - this.msgWriter = msgWriter; this.minBufferedMsgCnt = minBufferedMsgCnt; this.bufSizeRatio = bufSizeRatio; @@ -190,7 +183,7 @@ public GridTcpCommunicationClient( assert writeBuf.hasArray(); try { - int cnt = msgWriter.writeFully(nodeId, msg, out, writeBuf); + int cnt = U.writeMessageFully(msg, out, writeBuf); metricsLsnr.onBytesSent(cnt); } diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/GridTestMessage.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/GridTestMessage.java index 58cb184a6bf36..a82aeccaac8c1 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/GridTestMessage.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/GridTestMessage.java @@ -111,7 +111,7 @@ public byte[] payload() { commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -119,25 +119,25 @@ public byte[] payload() { switch (commState.idx) { case 0: - if (!commState.putUuid(srcNodeId)) + if (!commState.putUuid(null, srcNodeId)) return false; commState.idx++; case 1: - if (!commState.putLong(msgId)) + if (!commState.putLong(null, msgId)) return false; commState.idx++; case 2: - if (!commState.putLong(resId)) + if (!commState.putLong(null, resId)) return false; commState.idx++; case 3: - if (!commState.putByteArray(payload)) + if (!commState.putByteArray(null, payload)) return false; commState.idx++; @@ -153,7 +153,7 @@ public byte[] payload() { switch (commState.idx) { case 0: - srcNodeId = commState.getUuid(); + srcNodeId = commState.getUuid(null); if (srcNodeId == UUID_NOT_READ) return false; @@ -164,7 +164,7 @@ public byte[] payload() { if (buf.remaining() < 8) return false; - msgId = commState.getLong(); + msgId = commState.getLong(null); commState.idx++; @@ -172,12 +172,12 @@ public byte[] payload() { if (buf.remaining() < 8) return false; - resId = commState.getLong(); + resId = commState.getLong(null); commState.idx++; case 3: - payload = commState.getByteArray(); + payload = commState.getByteArray(null); if (payload == BYTE_ARR_NOT_READ) return false; diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/managers/communication/GridCommunicationSendMessageSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/managers/communication/GridCommunicationSendMessageSelfTest.java index 5c3e2ab38a5ee..e398d9f2b6974 100644 --- a/modules/core/src/test/java/org/gridgain/grid/kernal/managers/communication/GridCommunicationSendMessageSelfTest.java +++ b/modules/core/src/test/java/org/gridgain/grid/kernal/managers/communication/GridCommunicationSendMessageSelfTest.java @@ -149,7 +149,7 @@ private static class TestMessage extends GridTcpCommunicationMessageAdapter { @Override public boolean writeTo(ByteBuffer buf) { commState.setBuffer(buf); - return commState.putByte(directType()); + return commState.putByte(null, directType()); } /** {@inheritDoc} */ From ac71f06cba36cae91275bd677c4dff4df692fa89 Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Thu, 18 Dec 2014 17:03:01 +0300 Subject: [PATCH 02/95] IGNITE-61 - Portable format in direct marshalling --- .../GridTcpCommunicationMessageAdapter.java | 11 - .../GridTcpCommunicationMessageState.java | 10 +- .../GridTcpCommunicationPortableReader.java | 207 ++++++++++++++++ ...> GridTcpCommunicationPortableStream.java} | 14 +- .../GridTcpCommunicationPortableWriter.java | 223 ++++++++++++++++++ 5 files changed, 442 insertions(+), 23 deletions(-) create mode 100644 modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationPortableReader.java rename modules/core/src/main/java/org/gridgain/grid/util/direct/{GridPortableByteBufferStream.java => GridTcpCommunicationPortableStream.java} (98%) create mode 100644 modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationPortableWriter.java diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageAdapter.java b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageAdapter.java index 8961688b20063..d08caea054d45 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageAdapter.java +++ b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageAdapter.java @@ -84,9 +84,6 @@ public abstract class GridTcpCommunicationMessageAdapter implements Serializable /** */ public static final BitSet BIT_SET_NOT_READ = new BitSet(); - /** */ - public static final Enum ENUM_NOT_READ = DummyEnum.DUMMY; - /** */ public static final GridTcpCommunicationMessageAdapter MSG_NOT_READ = new GridTcpCommunicationMessageAdapter() { @SuppressWarnings("CloneDoesntCallSuperClone") @@ -176,12 +173,4 @@ protected final Iterator arrayIterator(final Object[] arr) { } }; } - - /** - * Dummy enum. - */ - private enum DummyEnum { - /** */ - DUMMY - } } diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java index a5df7107fbd4e..ee60070606413 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java +++ b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java @@ -35,16 +35,16 @@ public class GridTcpCommunicationMessageState { private static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class); /** */ - private static final int FIELD_HDR_LEN = 9; + private static final int FIELD_HDR_LEN = 0; /** */ - private final GridPortableByteBufferStream stream = new GridPortableByteBufferStream(); + private final GridTcpCommunicationPortableStream stream = new GridTcpCommunicationPortableStream(); /** */ - private final PortableWriter writer = null;//new org.gridgain.grid.util.portable.GridPortableWriterImpl(); + private final PortableWriter writer = new GridTcpCommunicationPortableWriter(stream); /** */ - private final PortableReader reader = null;//new org.gridgain.grid.util.portable.GridPortableReaderImpl(); + private final PortableReader reader = new GridTcpCommunicationPortableReader(stream); /** */ private boolean hdrDone; @@ -1012,7 +1012,7 @@ public final boolean putEnum(String name, @Nullable Enum e) { */ public final boolean putMessage(String name, @Nullable GridTcpCommunicationMessageAdapter msg) { if (!hdrDone) { - if (stream.remaining() < FIELD_HDR_LEN) + if (stream.remaining() < FIELD_HDR_LEN + 1) return false; writer.writeObject(name, msg); diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationPortableReader.java b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationPortableReader.java new file mode 100644 index 0000000000000..d4b6e2db0b440 --- /dev/null +++ b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationPortableReader.java @@ -0,0 +1,207 @@ +/* @java.file.header */ + +/* _________ _____ __________________ _____ + * __ ____/___________(_)______ /__ ____/______ ____(_)_______ + * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ + * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / + * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ + */ + +package org.gridgain.grid.util.direct; + +import org.apache.ignite.portables.*; +import org.jetbrains.annotations.*; + +import java.math.*; +import java.sql.*; +import java.util.*; +import java.util.Date; + +/** + * Portable reader implementation. + */ +public class GridTcpCommunicationPortableReader implements PortableReader { + /** Stream. */ + private final GridTcpCommunicationPortableStream stream; + + /** + * @param stream Stream. + */ + public GridTcpCommunicationPortableReader(GridTcpCommunicationPortableStream stream) { + this.stream = stream; + } + + /** {@inheritDoc} */ + @Override public byte readByte(String fieldName) throws PortableException { + return stream.readByte(); + } + + /** {@inheritDoc} */ + @Override public short readShort(String fieldName) throws PortableException { + return stream.readShort(); + } + + /** {@inheritDoc} */ + @Override public int readInt(String fieldName) throws PortableException { + return stream.readInt(); + } + + /** {@inheritDoc} */ + @Override public long readLong(String fieldName) throws PortableException { + return stream.readLong(); + } + + /** {@inheritDoc} */ + @Override public float readFloat(String fieldName) throws PortableException { + return stream.readFloat(); + } + + /** {@inheritDoc} */ + @Override public double readDouble(String fieldName) throws PortableException { + return stream.readDouble(); + } + + /** {@inheritDoc} */ + @Override public char readChar(String fieldName) throws PortableException { + return stream.readChar(); + } + + /** {@inheritDoc} */ + @Override public boolean readBoolean(String fieldName) throws PortableException { + return stream.readBoolean(); + } + + /** {@inheritDoc} */ + @Nullable @Override public byte[] readByteArray(String fieldName) throws PortableException { + return stream.readByteArray(stream.readInt()); + } + + /** {@inheritDoc} */ + @Nullable @Override public short[] readShortArray(String fieldName) throws PortableException { + return stream.readShortArray(stream.readInt()); + } + + /** {@inheritDoc} */ + @Nullable @Override public int[] readIntArray(String fieldName) throws PortableException { + return stream.readIntArray(stream.readInt()); + } + + /** {@inheritDoc} */ + @Nullable @Override public long[] readLongArray(String fieldName) throws PortableException { + return stream.readLongArray(stream.readInt()); + } + + /** {@inheritDoc} */ + @Nullable @Override public float[] readFloatArray(String fieldName) throws PortableException { + return stream.readFloatArray(stream.readInt()); + } + + /** {@inheritDoc} */ + @Nullable @Override public double[] readDoubleArray(String fieldName) throws PortableException { + return stream.readDoubleArray(stream.readInt()); + } + + /** {@inheritDoc} */ + @Nullable @Override public char[] readCharArray(String fieldName) throws PortableException { + return stream.readCharArray(stream.readInt()); + } + + /** {@inheritDoc} */ + @Nullable @Override public boolean[] readBooleanArray(String fieldName) throws PortableException { + return stream.readBooleanArray(stream.readInt()); + } + + /** {@inheritDoc} */ + @Nullable @Override public T readObject(String fieldName) throws PortableException { + return (T)stream.readMessage(); + } + + /** {@inheritDoc} */ + @Nullable @Override public BigDecimal readDecimal(String fieldName) throws PortableException { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Nullable @Override public String readString(String fieldName) throws PortableException { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Nullable @Override public UUID readUuid(String fieldName) throws PortableException { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Nullable @Override public Date readDate(String fieldName) throws PortableException { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Nullable @Override public Timestamp readTimestamp(String fieldName) throws PortableException { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Nullable @Override public BigDecimal[] readDecimalArray(String fieldName) throws PortableException { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Nullable @Override public String[] readStringArray(String fieldName) throws PortableException { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Nullable @Override public UUID[] readUuidArray(String fieldName) throws PortableException { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Nullable @Override public Date[] readDateArray(String fieldName) throws PortableException { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Nullable @Override public Object[] readObjectArray(String fieldName) throws PortableException { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Nullable @Override public Collection readCollection(String fieldName) throws PortableException { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Nullable @Override public Collection readCollection(String fieldName, Class> colCls) + throws PortableException { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Nullable @Override public Map readMap(String fieldName) throws PortableException { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Nullable @Override public Map readMap(String fieldName, Class> mapCls) + throws PortableException { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Nullable @Override public > T readEnum(String fieldName, Class enumCls) + throws PortableException { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Nullable @Override public > T[] readEnumArray(String fieldName, Class enumCls) + throws PortableException { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Override public PortableRawReader rawReader() { + throw new UnsupportedOperationException(); + } +} diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridPortableByteBufferStream.java b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationPortableStream.java similarity index 98% rename from modules/core/src/main/java/org/gridgain/grid/util/direct/GridPortableByteBufferStream.java rename to modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationPortableStream.java index 4433cbf3912b7..c87837f22861a 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridPortableByteBufferStream.java +++ b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationPortableStream.java @@ -21,7 +21,7 @@ /** * Portable stream based on {@link ByteBuffer}. */ -public class GridPortableByteBufferStream implements GridPortableOutputStream, GridPortableInputStream { +public class GridTcpCommunicationPortableStream implements GridPortableOutputStream, GridPortableInputStream { /** */ private static final Unsafe UNSAFE = GridUnsafe.unsafe(); @@ -270,17 +270,16 @@ public void writeMessage(GridTcpCommunicationMessageAdapter msg) { */ public GridTcpCommunicationMessageAdapter readMessage() { if (!msgTypeDone) { - if (!buf.hasRemaining()) - return MSG_NOT_READ; + assert buf.hasRemaining(); byte type = readByte(); - msg = GridTcpCommunicationMessageFactory.create(type); + msg = type == Byte.MIN_VALUE ? null : GridTcpCommunicationMessageFactory.create(type); msgTypeDone = true; } - if (msg.readFrom(buf)) { + if (msg == null || msg.readFrom(buf)) { GridTcpCommunicationMessageAdapter msg0 = msg; msgTypeDone = false; @@ -673,9 +672,10 @@ private T readArray(ArrayCreator creator, int len, int lenShift, long off assert creator != null; if (tmpArr == null) { - assert len >= 0; - switch (len) { + case -1: + return null; + case 0: return creator.create(0); diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationPortableWriter.java b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationPortableWriter.java new file mode 100644 index 0000000000000..7f7f971ec7b44 --- /dev/null +++ b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationPortableWriter.java @@ -0,0 +1,223 @@ +/* @java.file.header */ + +/* _________ _____ __________________ _____ + * __ ____/___________(_)______ /__ ____/______ ____(_)_______ + * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ + * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / + * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ + */ + +package org.gridgain.grid.util.direct; + +import org.apache.ignite.portables.*; +import org.jetbrains.annotations.*; + +import java.math.*; +import java.sql.*; +import java.util.*; +import java.util.Date; + +/** + * Portable writer implementation. + */ +public class GridTcpCommunicationPortableWriter implements PortableWriter { + /** Stream. */ + private final GridTcpCommunicationPortableStream stream; + + /** + * @param stream Stream. + */ + public GridTcpCommunicationPortableWriter(GridTcpCommunicationPortableStream stream) { + this.stream = stream; + } + + /** {@inheritDoc} */ + @Override public void writeByte(String fieldName, byte val) throws PortableException { + stream.writeByte(val); + } + + /** {@inheritDoc} */ + @Override public void writeShort(String fieldName, short val) throws PortableException { + stream.writeShort(val); + } + + /** {@inheritDoc} */ + @Override public void writeInt(String fieldName, int val) throws PortableException { + stream.writeInt(val); + } + + /** {@inheritDoc} */ + @Override public void writeLong(String fieldName, long val) throws PortableException { + stream.writeLong(val); + } + + /** {@inheritDoc} */ + @Override public void writeFloat(String fieldName, float val) throws PortableException { + stream.writeFloat(val); + } + + /** {@inheritDoc} */ + @Override public void writeDouble(String fieldName, double val) throws PortableException { + stream.writeDouble(val); + } + + /** {@inheritDoc} */ + @Override public void writeChar(String fieldName, char val) throws PortableException { + stream.writeChar(val); + } + + /** {@inheritDoc} */ + @Override public void writeBoolean(String fieldName, boolean val) throws PortableException { + stream.writeBoolean(val); + } + + /** {@inheritDoc} */ + @Override public void writeByteArray(String fieldName, @Nullable byte[] val) throws PortableException { + stream.writeInt(val != null ? val.length : -1); + + if (val != null) + stream.writeByteArray(val); + } + + /** {@inheritDoc} */ + @Override public void writeShortArray(String fieldName, @Nullable short[] val) throws PortableException { + stream.writeInt(val != null ? val.length : -1); + + if (val != null) + stream.writeShortArray(val); + } + + /** {@inheritDoc} */ + @Override public void writeIntArray(String fieldName, @Nullable int[] val) throws PortableException { + stream.writeInt(val != null ? val.length : -1); + + if (val != null) + stream.writeIntArray(val); + } + + /** {@inheritDoc} */ + @Override public void writeLongArray(String fieldName, @Nullable long[] val) throws PortableException { + stream.writeInt(val != null ? val.length : -1); + + if (val != null) + stream.writeLongArray(val); + } + + /** {@inheritDoc} */ + @Override public void writeFloatArray(String fieldName, @Nullable float[] val) throws PortableException { + stream.writeInt(val != null ? val.length : -1); + + if (val != null) + stream.writeFloatArray(val); + } + + /** {@inheritDoc} */ + @Override public void writeDoubleArray(String fieldName, @Nullable double[] val) throws PortableException { + stream.writeInt(val != null ? val.length : -1); + + if (val != null) + stream.writeDoubleArray(val); + } + + /** {@inheritDoc} */ + @Override public void writeCharArray(String fieldName, @Nullable char[] val) throws PortableException { + stream.writeInt(val != null ? val.length : -1); + + if (val != null) + stream.writeCharArray(val); + } + + /** {@inheritDoc} */ + @Override public void writeBooleanArray(String fieldName, @Nullable boolean[] val) throws PortableException { + stream.writeInt(val != null ? val.length : -1); + + if (val != null) + stream.writeBooleanArray(val); + } + + /** {@inheritDoc} */ + @Override public void writeObject(String fieldName, @Nullable Object obj) throws PortableException { + if (obj != null) { + assert obj instanceof GridTcpCommunicationMessageAdapter; + + stream.writeMessage((GridTcpCommunicationMessageAdapter)obj); + } + else + stream.writeByte(Byte.MIN_VALUE); + } + + /** {@inheritDoc} */ + @Override public void writeDecimal(String fieldName, @Nullable BigDecimal val) throws PortableException { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Override public void writeString(String fieldName, @Nullable String val) throws PortableException { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Override public void writeUuid(String fieldName, @Nullable UUID val) throws PortableException { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Override public void writeDate(String fieldName, @Nullable Date val) throws PortableException { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Override public void writeTimestamp(String fieldName, @Nullable Timestamp val) throws PortableException { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Override public void writeDecimalArray(String fieldName, @Nullable BigDecimal[] val) throws PortableException { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Override public void writeStringArray(String fieldName, @Nullable String[] val) throws PortableException { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Override public void writeUuidArray(String fieldName, @Nullable UUID[] val) throws PortableException { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Override public void writeDateArray(String fieldName, @Nullable Date[] val) throws PortableException { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Override public void writeObjectArray(String fieldName, @Nullable Object[] val) throws PortableException { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Override public void writeCollection(String fieldName, @Nullable Collection col) throws PortableException { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Override public void writeMap(String fieldName, @Nullable Map map) throws PortableException { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Override public > void writeEnum(String fieldName, T val) throws PortableException { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Override public > void writeEnumArray(String fieldName, T[] val) throws PortableException { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Override public PortableRawWriter rawWriter() { + throw new UnsupportedOperationException(); + } +} From 5ed5176eff3df499014e7084c5bb3f46aa319c6c Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Thu, 18 Dec 2014 17:12:26 +0300 Subject: [PATCH 03/95] IGNITE-61 - Portable format in direct marshalling --- .../collision/jobstealing/JobStealingRequest.java | 2 +- .../direct/GridTcpCommunicationMessageState.java | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java b/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java index 6e43563e9dd5d..1b3a91e277eaa 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java @@ -69,7 +69,7 @@ int delta() { commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!commState.writeType(directType())) return false; commState.typeWritten = true; diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java index ee60070606413..5a3e74dc0dcdb 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java +++ b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java @@ -77,6 +77,19 @@ public final void setBuffer(ByteBuffer buf) { assert buf != null; } + /** + * @param type Message type. + * @return Whether message type was written. + */ + public final boolean writeType(byte type) { + if (stream.remaining() == 0) + return false; + + stream.writeByte(type); + + return true; + } + /** * @param name Field name. * @param b Byte value. From 1767ba5e69648c3e5d471a73b66b0bf172f28a6f Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Fri, 19 Dec 2014 14:56:59 +0300 Subject: [PATCH 04/95] IGNITE-61 - Portable format in direct marshalling --- .../jobstealing/JobStealingRequest.java | 2 +- .../GridTcpCommunicationMessageState.java | 30 +++++++++++++++---- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java b/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java index 1b3a91e277eaa..73450e0b74c0f 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java @@ -69,7 +69,7 @@ int delta() { commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.writeType(directType())) + if (!commState.writeByte(directType())) return false; commState.typeWritten = true; diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java index 5a3e74dc0dcdb..13576277656c1 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java +++ b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java @@ -78,18 +78,38 @@ public final void setBuffer(ByteBuffer buf) { } /** - * @param type Message type. - * @return Whether message type was written. + * @param val Byte value. + * @return Whether value was written. + */ + public final boolean writeByte(byte val) { + if (stream.remaining() < 1) + return false; + + stream.writeByte(val); + + return true; + } + + /** + * @param val Int value. + * @return Whether value was written. */ - public final boolean writeType(byte type) { - if (stream.remaining() == 0) + public final boolean writeInt(int val) { + if (stream.remaining() < 4) return false; - stream.writeByte(type); + stream.writeInt(val); return true; } + /** + * @return Int value. + */ + public final int readInt() { + return stream.readInt(); + } + /** * @param name Field name. * @param b Byte value. From eb7eb8d0ff8385502784ea43b08ac9dcf21046c3 Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Fri, 19 Dec 2014 16:38:44 +0300 Subject: [PATCH 05/95] IGNITE-61 - Portable format in direct marshalling --- .../GridTcpCommunicationMessageState.java | 33 ------------------- 1 file changed, 33 deletions(-) diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java index 13576277656c1..ee60070606413 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java +++ b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java @@ -77,39 +77,6 @@ public final void setBuffer(ByteBuffer buf) { assert buf != null; } - /** - * @param val Byte value. - * @return Whether value was written. - */ - public final boolean writeByte(byte val) { - if (stream.remaining() < 1) - return false; - - stream.writeByte(val); - - return true; - } - - /** - * @param val Int value. - * @return Whether value was written. - */ - public final boolean writeInt(int val) { - if (stream.remaining() < 4) - return false; - - stream.writeInt(val); - - return true; - } - - /** - * @return Int value. - */ - public final int readInt() { - return stream.readInt(); - } - /** * @param name Field name. * @param b Byte value. From 4abbc39c04c66ff6ad88035ba787b9e496d28275 Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Fri, 19 Dec 2014 17:27:46 +0300 Subject: [PATCH 06/95] IGNITE-61 - Portable format in direct marshalling --- .../jobstealing/JobStealingRequest.java | 8 ++-- .../GridTcpCommunicationMessageAdapter.java | 3 ++ .../GridTcpCommunicationMessageState.java | 38 +++++++++++++++++++ 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java b/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java index 73450e0b74c0f..0c4e968d98010 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java @@ -69,10 +69,10 @@ int delta() { commState.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.writeByte(directType())) - return false; - - commState.typeWritten = true; +// if (!commState.writeByte(directType())) +// return false; +// +// commState.typeWritten = true; } switch (commState.idx) { diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageAdapter.java b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageAdapter.java index d08caea054d45..7f5d97c6ce079 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageAdapter.java +++ b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageAdapter.java @@ -55,6 +55,9 @@ public abstract class GridTcpCommunicationMessageAdapter implements Serializable /** */ public static final UUID UUID_NOT_READ = new UUID(0, 0); + /** */ + public static final ByteBuffer BYTE_BUF_NOT_READ = ByteBuffer.allocate(0); + /** */ public static final IgniteUuid GRID_UUID_NOT_READ = new IgniteUuid(new UUID(0, 0), 0); diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java index ee60070606413..c2d8b1487bfd2 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java +++ b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java @@ -621,6 +621,44 @@ public final boolean[] getBooleanArray(String name) { return arr; } + /** + * @param name Field name. + * @param buf Buffer. + * @return Whether value was fully written. + */ + public final boolean putByteBuffer(String name, @Nullable ByteBuffer buf) { + byte[] arr = null; + + if (buf != null) { + ByteBuffer buf0 = buf.duplicate(); + + buf0.flip(); + + arr = new byte[buf0.remaining()]; + + buf0.get(arr); + } + + return putByteArray(name, arr); + } + + /** + * @param name Field name. + * @return {@link ByteBuffer} or special + * {@link GridTcpCommunicationMessageAdapter#BYTE_BUF_NOT_READ} + * value if it was not fully read. + */ + public final ByteBuffer getByteBuffer(String name) { + byte[] arr = getByteArray(name); + + if (arr == BYTE_ARR_NOT_READ) + return BYTE_BUF_NOT_READ; + else if (arr == null) + return null; + else + return ByteBuffer.wrap(arr); + } + /** * @param name Field name. * @param uuid {@link UUID}. From d0ecc3fd21cd2ac07595c78140932f6044ad7d0d Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Fri, 19 Dec 2014 19:16:51 +0300 Subject: [PATCH 07/95] IGNITE-61 - Portable format in direct marshalling --- .../grid/util/direct/GridTcpCommunicationMessageState.java | 2 +- .../util/direct/GridTcpCommunicationPortableStream.java | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java index c2d8b1487bfd2..0a3f856cb1287 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java +++ b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java @@ -74,7 +74,7 @@ public class GridTcpCommunicationMessageState { * @param buf Buffer. */ public final void setBuffer(ByteBuffer buf) { - assert buf != null; + stream.setBuffer(buf); } /** diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationPortableStream.java b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationPortableStream.java index c87837f22861a..3ec27df7b6eb6 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationPortableStream.java +++ b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationPortableStream.java @@ -249,11 +249,7 @@ public final void setBuffer(ByteBuffer buf) { * @return Whether last object was fully written. */ public boolean lastWritten() { - boolean lastWritten0 = lastWritten; - - lastWritten = false; - - return lastWritten0; + return lastWritten; } /** From f5b3f26e4ff9f8dbcbd1089aa9ddd309e462edc6 Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Mon, 22 Dec 2014 14:39:29 -0800 Subject: [PATCH 08/95] IGNITE-61 - Portable format in direct marshalling --- .../jobstealing/JobStealingRequest.java | 12 +-- .../grid/kernal/GridJobCancelRequest.java | 12 +-- .../grid/kernal/GridJobExecuteRequest.java | 80 ++++++++--------- .../grid/kernal/GridJobExecuteRequestV2.java | 4 +- .../grid/kernal/GridJobExecuteResponse.java | 28 +++--- .../grid/kernal/GridJobSiblingsRequest.java | 8 +- .../grid/kernal/GridJobSiblingsResponse.java | 4 +- .../grid/kernal/GridTaskCancelRequest.java | 4 +- .../grid/kernal/GridTaskSessionRequest.java | 12 +-- .../checkpoint/GridCheckpointRequest.java | 12 +-- .../managers/communication/GridIoMessage.java | 28 +++--- .../communication/GridIoUserMessage.java | 26 +++--- .../deployment/GridDeploymentInfoBean.java | 18 ++-- .../deployment/GridDeploymentRequest.java | 16 ++-- .../deployment/GridDeploymentResponse.java | 12 +-- .../eventstorage/GridEventStorageMessage.java | 34 +++---- .../cache/GridCacheEvictionRequest.java | 12 +-- .../cache/GridCacheEvictionResponse.java | 8 +- .../processors/cache/GridCacheMessage.java | 12 +-- ...CacheOptimisticCheckPreparedTxRequest.java | 16 ++-- ...acheOptimisticCheckPreparedTxResponse.java | 12 +-- ...chePessimisticCheckCommittedTxRequest.java | 24 ++--- ...hePessimisticCheckCommittedTxResponse.java | 12 +-- .../GridDistributedBaseMessage.java | 12 +-- .../GridDistributedLockRequest.java | 56 ++++++------ .../GridDistributedLockResponse.java | 8 +- .../GridDistributedTxFinishRequest.java | 90 ++++++++++--------- .../GridDistributedTxFinishResponse.java | 8 +- .../GridDistributedTxPrepareRequest.java | 44 ++++----- .../GridDistributedTxPrepareResponse.java | 8 +- .../dht/GridDhtAffinityAssignmentRequest.java | 4 +- .../GridDhtAffinityAssignmentResponse.java | 8 +- .../distributed/dht/GridDhtLockRequest.java | 28 +++--- .../distributed/dht/GridDhtLockResponse.java | 4 +- .../dht/GridDhtTxFinishRequest.java | 36 ++++---- .../dht/GridDhtTxFinishResponse.java | 4 +- .../dht/GridDhtTxPrepareRequest.java | 44 ++++----- .../dht/GridDhtTxPrepareResponse.java | 8 +- .../atomic/GridDhtAtomicUpdateRequest.java | 44 ++++----- .../atomic/GridDhtAtomicUpdateResponse.java | 12 +-- .../atomic/GridNearAtomicUpdateRequest.java | 56 ++++++------ .../atomic/GridNearAtomicUpdateResponse.java | 28 +++--- .../preloader/GridDhtForceKeysRequest.java | 12 +-- .../preloader/GridDhtForceKeysResponse.java | 12 +-- .../GridDhtPartitionDemandMessage.java | 20 ++--- .../GridDhtPartitionSupplyMessage.java | 16 ++-- .../GridDhtPartitionsAbstractMessage.java | 8 +- .../GridDhtPartitionsFullMessage.java | 12 +-- .../GridDhtPartitionsSingleMessage.java | 4 +- .../distributed/near/GridNearGetRequest.java | 28 +++--- .../distributed/near/GridNearGetResponse.java | 24 ++--- .../distributed/near/GridNearLockRequest.java | 32 +++---- .../near/GridNearLockResponse.java | 8 +- .../near/GridNearTxFinishRequest.java | 20 ++--- .../near/GridNearTxFinishResponse.java | 12 +-- .../near/GridNearTxPrepareRequest.java | 29 +++--- .../near/GridNearTxPrepareResponse.java | 12 +-- .../cache/query/GridCacheQueryRequest.java | 76 ++++++++-------- .../cache/query/GridCacheQueryResponse.java | 16 ++-- .../clock/GridClockDeltaSnapshotMessage.java | 6 +- .../continuous/GridContinuousMessage.java | 18 ++-- .../dataload/GridDataLoadRequest.java | 46 +++++----- .../dataload/GridDataLoadResponse.java | 12 +-- .../processors/ggfs/GridGgfsAckMessage.java | 12 +-- .../processors/ggfs/GridGgfsBlockKey.java | 16 ++-- .../ggfs/GridGgfsBlocksMessage.java | 10 +-- .../ggfs/GridGgfsDeleteMessage.java | 8 +- .../ggfs/GridGgfsFileAffinityRange.java | 20 ++--- .../ggfs/GridGgfsFragmentizerRequest.java | 4 +- .../ggfs/GridGgfsFragmentizerResponse.java | 4 +- .../processors/ggfs/GridGgfsSyncMessage.java | 8 +- .../GridClientHandshakeRequestWrapper.java | 14 +-- .../GridClientHandshakeResponseWrapper.java | 20 +++++ .../message/GridClientMessageWrapper.java | 56 ++++++------ .../message/GridClientPingPacketWrapper.java | 17 +++- .../handlers/task/GridTaskResultRequest.java | 8 +- .../handlers/task/GridTaskResultResponse.java | 16 ++-- .../tcp/GridMemcachedMessageWrapper.java | 19 +++- .../streamer/GridStreamerCancelRequest.java | 4 +- .../GridStreamerExecutionRequest.java | 26 +++--- .../streamer/GridStreamerResponse.java | 8 +- .../GridTcpCommunicationMessageState.java | 27 ++++++ 82 files changed, 852 insertions(+), 776 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java b/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java index 0c4e968d98010..a6c3346914f8f 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java @@ -69,15 +69,15 @@ int delta() { commState.setBuffer(buf); if (!commState.typeWritten) { -// if (!commState.writeByte(directType())) -// return false; -// -// commState.typeWritten = true; + if (!commState.putByte(null, directType())) + return false; + + commState.typeWritten = true; } switch (commState.idx) { case 0: - if (!commState.putInt(null, delta)) + if (!commState.putInt("delta", delta)) return false; commState.idx++; @@ -97,7 +97,7 @@ int delta() { if (buf.remaining() < 4) return false; - delta = commState.getInt(null); + delta = commState.getInt("delta"); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobCancelRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobCancelRequest.java index 1c0e1a4901a49..00fc2e5df4008 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobCancelRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobCancelRequest.java @@ -134,19 +134,19 @@ public boolean system() { switch (commState.idx) { case 0: - if (!commState.putGridUuid(null, jobId)) + if (!commState.putGridUuid("jobId", jobId)) return false; commState.idx++; case 1: - if (!commState.putGridUuid(null, sesId)) + if (!commState.putGridUuid("sesId", sesId)) return false; commState.idx++; case 2: - if (!commState.putBoolean(null, sys)) + if (!commState.putBoolean("sys", sys)) return false; commState.idx++; @@ -163,7 +163,7 @@ public boolean system() { switch (commState.idx) { case 0: - IgniteUuid jobId0 = commState.getGridUuid(null); + IgniteUuid jobId0 = commState.getGridUuid("jobId"); if (jobId0 == GRID_UUID_NOT_READ) return false; @@ -173,7 +173,7 @@ public boolean system() { commState.idx++; case 1: - IgniteUuid sesId0 = commState.getGridUuid(null); + IgniteUuid sesId0 = commState.getGridUuid("sesId"); if (sesId0 == GRID_UUID_NOT_READ) return false; @@ -186,7 +186,7 @@ public boolean system() { if (buf.remaining() < 1) return false; - sys = commState.getBoolean(null); + sys = commState.getBoolean("sys"); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobExecuteRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobExecuteRequest.java index 2e3eba7cbdf71..c7e3bcca30f94 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobExecuteRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobExecuteRequest.java @@ -432,8 +432,8 @@ public UUID getSubjectId() { _clone.cpSpi = cpSpi; _clone.siblings = siblings; _clone.siblingsBytes = siblingsBytes; - _clone.createTime = createTime; _clone.createTime0 = createTime0; + _clone.createTime = createTime; _clone.clsLdrId = clsLdrId; _clone.depMode = depMode; _clone.dynamicSiblings = dynamicSiblings; @@ -457,61 +457,61 @@ public UUID getSubjectId() { switch (commState.idx) { case 0: - if (!commState.putGridUuid(null, clsLdrId)) + if (!commState.putGridUuid("clsLdrId", clsLdrId)) return false; commState.idx++; case 1: - if (!commState.putString(null, cpSpi)) + if (!commState.putString("cpSpi", cpSpi)) return false; commState.idx++; case 2: - if (!commState.putLong(null, createTime)) + if (!commState.putLong("createTime", createTime)) return false; commState.idx++; case 3: - if (!commState.putEnum(null, depMode)) + if (!commState.putEnum("depMode", depMode)) return false; commState.idx++; case 4: - if (!commState.putBoolean(null, dynamicSiblings)) + if (!commState.putBoolean("dynamicSiblings", dynamicSiblings)) return false; commState.idx++; case 5: - if (!commState.putBoolean(null, forceLocDep)) + if (!commState.putBoolean("forceLocDep", forceLocDep)) return false; commState.idx++; case 6: - if (!commState.putBoolean(null, internal)) + if (!commState.putBoolean("internal", internal)) return false; commState.idx++; case 7: - if (!commState.putByteArray(null, jobAttrsBytes)) + if (!commState.putByteArray("jobAttrsBytes", jobAttrsBytes)) return false; commState.idx++; case 8: - if (!commState.putByteArray(null, jobBytes)) + if (!commState.putByteArray("jobBytes", jobBytes)) return false; commState.idx++; case 9: - if (!commState.putGridUuid(null, jobId)) + if (!commState.putGridUuid("jobId", jobId)) return false; commState.idx++; @@ -555,49 +555,49 @@ public UUID getSubjectId() { commState.idx++; case 11: - if (!commState.putByteArray(null, sesAttrsBytes)) + if (!commState.putByteArray("sesAttrsBytes", sesAttrsBytes)) return false; commState.idx++; case 12: - if (!commState.putBoolean(null, sesFullSup)) + if (!commState.putBoolean("sesFullSup", sesFullSup)) return false; commState.idx++; case 13: - if (!commState.putGridUuid(null, sesId)) + if (!commState.putGridUuid("sesId", sesId)) return false; commState.idx++; case 14: - if (!commState.putByteArray(null, siblingsBytes)) + if (!commState.putByteArray("siblingsBytes", siblingsBytes)) return false; commState.idx++; case 15: - if (!commState.putLong(null, startTaskTime)) + if (!commState.putLong("startTaskTime", startTaskTime)) return false; commState.idx++; case 16: - if (!commState.putString(null, taskClsName)) + if (!commState.putString("taskClsName", taskClsName)) return false; commState.idx++; case 17: - if (!commState.putString(null, taskName)) + if (!commState.putString("taskName", taskName)) return false; commState.idx++; case 18: - if (!commState.putLong(null, timeout)) + if (!commState.putLong("timeout", timeout)) return false; commState.idx++; @@ -630,7 +630,7 @@ public UUID getSubjectId() { commState.idx++; case 20: - if (!commState.putString(null, userVer)) + if (!commState.putString("userVer", userVer)) return false; commState.idx++; @@ -647,7 +647,7 @@ public UUID getSubjectId() { switch (commState.idx) { case 0: - IgniteUuid clsLdrId0 = commState.getGridUuid(null); + IgniteUuid clsLdrId0 = commState.getGridUuid("clsLdrId"); if (clsLdrId0 == GRID_UUID_NOT_READ) return false; @@ -657,7 +657,7 @@ public UUID getSubjectId() { commState.idx++; case 1: - String cpSpi0 = commState.getString(null); + String cpSpi0 = commState.getString("cpSpi"); if (cpSpi0 == STR_NOT_READ) return false; @@ -670,7 +670,7 @@ public UUID getSubjectId() { if (buf.remaining() < 8) return false; - createTime = commState.getLong(null); + createTime = commState.getLong("createTime"); commState.idx++; @@ -678,7 +678,7 @@ public UUID getSubjectId() { if (buf.remaining() < 1) return false; - byte depMode0 = commState.getByte(null); + byte depMode0 = commState.getByte("depMode"); depMode = IgniteDeploymentMode.fromOrdinal(depMode0); @@ -688,7 +688,7 @@ public UUID getSubjectId() { if (buf.remaining() < 1) return false; - dynamicSiblings = commState.getBoolean(null); + dynamicSiblings = commState.getBoolean("dynamicSiblings"); commState.idx++; @@ -696,7 +696,7 @@ public UUID getSubjectId() { if (buf.remaining() < 1) return false; - forceLocDep = commState.getBoolean(null); + forceLocDep = commState.getBoolean("forceLocDep"); commState.idx++; @@ -704,12 +704,12 @@ public UUID getSubjectId() { if (buf.remaining() < 1) return false; - internal = commState.getBoolean(null); + internal = commState.getBoolean("internal"); commState.idx++; case 7: - byte[] jobAttrsBytes0 = commState.getByteArray(null); + byte[] jobAttrsBytes0 = commState.getByteArray("jobAttrsBytes"); if (jobAttrsBytes0 == BYTE_ARR_NOT_READ) return false; @@ -719,7 +719,7 @@ public UUID getSubjectId() { commState.idx++; case 8: - byte[] jobBytes0 = commState.getByteArray(null); + byte[] jobBytes0 = commState.getByteArray("jobBytes"); if (jobBytes0 == BYTE_ARR_NOT_READ) return false; @@ -729,7 +729,7 @@ public UUID getSubjectId() { commState.idx++; case 9: - IgniteUuid jobId0 = commState.getGridUuid(null); + IgniteUuid jobId0 = commState.getGridUuid("jobId"); if (jobId0 == GRID_UUID_NOT_READ) return false; @@ -748,7 +748,7 @@ public UUID getSubjectId() { if (commState.readSize >= 0) { if (ldrParticipants == null) - ldrParticipants = U.newHashMap(commState.readSize); + ldrParticipants = new HashMap<>(commState.readSize, 1.0f); for (int i = commState.readItems; i < commState.readSize; i++) { if (!commState.keyDone) { @@ -781,7 +781,7 @@ public UUID getSubjectId() { commState.idx++; case 11: - byte[] sesAttrsBytes0 = commState.getByteArray(null); + byte[] sesAttrsBytes0 = commState.getByteArray("sesAttrsBytes"); if (sesAttrsBytes0 == BYTE_ARR_NOT_READ) return false; @@ -794,12 +794,12 @@ public UUID getSubjectId() { if (buf.remaining() < 1) return false; - sesFullSup = commState.getBoolean(null); + sesFullSup = commState.getBoolean("sesFullSup"); commState.idx++; case 13: - IgniteUuid sesId0 = commState.getGridUuid(null); + IgniteUuid sesId0 = commState.getGridUuid("sesId"); if (sesId0 == GRID_UUID_NOT_READ) return false; @@ -809,7 +809,7 @@ public UUID getSubjectId() { commState.idx++; case 14: - byte[] siblingsBytes0 = commState.getByteArray(null); + byte[] siblingsBytes0 = commState.getByteArray("siblingsBytes"); if (siblingsBytes0 == BYTE_ARR_NOT_READ) return false; @@ -822,12 +822,12 @@ public UUID getSubjectId() { if (buf.remaining() < 8) return false; - startTaskTime = commState.getLong(null); + startTaskTime = commState.getLong("startTaskTime"); commState.idx++; case 16: - String taskClsName0 = commState.getString(null); + String taskClsName0 = commState.getString("taskClsName"); if (taskClsName0 == STR_NOT_READ) return false; @@ -837,7 +837,7 @@ public UUID getSubjectId() { commState.idx++; case 17: - String taskName0 = commState.getString(null); + String taskName0 = commState.getString("taskName"); if (taskName0 == STR_NOT_READ) return false; @@ -850,7 +850,7 @@ public UUID getSubjectId() { if (buf.remaining() < 8) return false; - timeout = commState.getLong(null); + timeout = commState.getLong("timeout"); commState.idx++; @@ -884,7 +884,7 @@ public UUID getSubjectId() { commState.idx++; case 20: - String userVer0 = commState.getString(null); + String userVer0 = commState.getString("userVer"); if (userVer0 == STR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobExecuteRequestV2.java b/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobExecuteRequestV2.java index cf708427ebcfb..9e3e5836449f1 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobExecuteRequestV2.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobExecuteRequestV2.java @@ -137,7 +137,7 @@ public GridJobExecuteRequestV2( switch (commState.idx) { case 21: - if (!commState.putUuid(null, subjId)) + if (!commState.putUuid("subjId", subjId)) return false; commState.idx++; @@ -156,7 +156,7 @@ public GridJobExecuteRequestV2( switch (commState.idx) { case 21: - UUID subjId0 = commState.getUuid(null); + UUID subjId0 = commState.getUuid("subjId"); if (subjId0 == UUID_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobExecuteResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobExecuteResponse.java index 88e74831b0be2..2ef82d8afb634 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobExecuteResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobExecuteResponse.java @@ -229,43 +229,43 @@ public void setFakeException(IgniteCheckedException fakeEx) { switch (commState.idx) { case 0: - if (!commState.putByteArray(null, gridExBytes)) + if (!commState.putByteArray("gridExBytes", gridExBytes)) return false; commState.idx++; case 1: - if (!commState.putBoolean(null, isCancelled)) + if (!commState.putBoolean("isCancelled", isCancelled)) return false; commState.idx++; case 2: - if (!commState.putByteArray(null, jobAttrsBytes)) + if (!commState.putByteArray("jobAttrsBytes", jobAttrsBytes)) return false; commState.idx++; case 3: - if (!commState.putGridUuid(null, jobId)) + if (!commState.putGridUuid("jobId", jobId)) return false; commState.idx++; case 4: - if (!commState.putUuid(null, nodeId)) + if (!commState.putUuid("nodeId", nodeId)) return false; commState.idx++; case 5: - if (!commState.putByteArray(null, resBytes)) + if (!commState.putByteArray("resBytes", resBytes)) return false; commState.idx++; case 6: - if (!commState.putGridUuid(null, sesId)) + if (!commState.putGridUuid("sesId", sesId)) return false; commState.idx++; @@ -282,7 +282,7 @@ public void setFakeException(IgniteCheckedException fakeEx) { switch (commState.idx) { case 0: - byte[] gridExBytes0 = commState.getByteArray(null); + byte[] gridExBytes0 = commState.getByteArray("gridExBytes"); if (gridExBytes0 == BYTE_ARR_NOT_READ) return false; @@ -295,12 +295,12 @@ public void setFakeException(IgniteCheckedException fakeEx) { if (buf.remaining() < 1) return false; - isCancelled = commState.getBoolean(null); + isCancelled = commState.getBoolean("isCancelled"); commState.idx++; case 2: - byte[] jobAttrsBytes0 = commState.getByteArray(null); + byte[] jobAttrsBytes0 = commState.getByteArray("jobAttrsBytes"); if (jobAttrsBytes0 == BYTE_ARR_NOT_READ) return false; @@ -310,7 +310,7 @@ public void setFakeException(IgniteCheckedException fakeEx) { commState.idx++; case 3: - IgniteUuid jobId0 = commState.getGridUuid(null); + IgniteUuid jobId0 = commState.getGridUuid("jobId"); if (jobId0 == GRID_UUID_NOT_READ) return false; @@ -320,7 +320,7 @@ public void setFakeException(IgniteCheckedException fakeEx) { commState.idx++; case 4: - UUID nodeId0 = commState.getUuid(null); + UUID nodeId0 = commState.getUuid("nodeId"); if (nodeId0 == UUID_NOT_READ) return false; @@ -330,7 +330,7 @@ public void setFakeException(IgniteCheckedException fakeEx) { commState.idx++; case 5: - byte[] resBytes0 = commState.getByteArray(null); + byte[] resBytes0 = commState.getByteArray("resBytes"); if (resBytes0 == BYTE_ARR_NOT_READ) return false; @@ -340,7 +340,7 @@ public void setFakeException(IgniteCheckedException fakeEx) { commState.idx++; case 6: - IgniteUuid sesId0 = commState.getGridUuid(null); + IgniteUuid sesId0 = commState.getGridUuid("sesId"); if (sesId0 == GRID_UUID_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobSiblingsRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobSiblingsRequest.java index a852d23263bd6..31bf8e0b4c883 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobSiblingsRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobSiblingsRequest.java @@ -108,13 +108,13 @@ public byte[] topicBytes() { switch (commState.idx) { case 0: - if (!commState.putGridUuid(null, sesId)) + if (!commState.putGridUuid("sesId", sesId)) return false; commState.idx++; case 1: - if (!commState.putByteArray(null, topicBytes)) + if (!commState.putByteArray("topicBytes", topicBytes)) return false; commState.idx++; @@ -131,7 +131,7 @@ public byte[] topicBytes() { switch (commState.idx) { case 0: - IgniteUuid sesId0 = commState.getGridUuid(null); + IgniteUuid sesId0 = commState.getGridUuid("sesId"); if (sesId0 == GRID_UUID_NOT_READ) return false; @@ -141,7 +141,7 @@ public byte[] topicBytes() { commState.idx++; case 1: - byte[] topicBytes0 = commState.getByteArray(null); + byte[] topicBytes0 = commState.getByteArray("topicBytes"); if (topicBytes0 == BYTE_ARR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobSiblingsResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobSiblingsResponse.java index 55e17f53bf229..81821b1cf054e 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobSiblingsResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobSiblingsResponse.java @@ -100,7 +100,7 @@ public void unmarshalSiblings(IgniteMarshaller marsh) throws IgniteCheckedExcept switch (commState.idx) { case 0: - if (!commState.putByteArray(null, siblingsBytes)) + if (!commState.putByteArray("siblingsBytes", siblingsBytes)) return false; commState.idx++; @@ -117,7 +117,7 @@ public void unmarshalSiblings(IgniteMarshaller marsh) throws IgniteCheckedExcept switch (commState.idx) { case 0: - byte[] siblingsBytes0 = commState.getByteArray(null); + byte[] siblingsBytes0 = commState.getByteArray("siblingsBytes"); if (siblingsBytes0 == BYTE_ARR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/GridTaskCancelRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/GridTaskCancelRequest.java index 15ae1ad9ab59c..d1ae10161fcac 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/GridTaskCancelRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/GridTaskCancelRequest.java @@ -83,7 +83,7 @@ public IgniteUuid sessionId() { switch (commState.idx) { case 0: - if (!commState.putGridUuid(null, sesId)) + if (!commState.putGridUuid("sesId", sesId)) return false; commState.idx++; @@ -100,7 +100,7 @@ public IgniteUuid sessionId() { switch (commState.idx) { case 0: - IgniteUuid sesId0 = commState.getGridUuid(null); + IgniteUuid sesId0 = commState.getGridUuid("sesId"); if (sesId0 == GRID_UUID_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/GridTaskSessionRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/GridTaskSessionRequest.java index 86457da92a2ed..8c9c63e21c4cc 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/GridTaskSessionRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/GridTaskSessionRequest.java @@ -123,19 +123,19 @@ public IgniteUuid getJobId() { switch (commState.idx) { case 0: - if (!commState.putByteArray(null, attrsBytes)) + if (!commState.putByteArray("attrsBytes", attrsBytes)) return false; commState.idx++; case 1: - if (!commState.putGridUuid(null, jobId)) + if (!commState.putGridUuid("jobId", jobId)) return false; commState.idx++; case 2: - if (!commState.putGridUuid(null, sesId)) + if (!commState.putGridUuid("sesId", sesId)) return false; commState.idx++; @@ -152,7 +152,7 @@ public IgniteUuid getJobId() { switch (commState.idx) { case 0: - byte[] attrsBytes0 = commState.getByteArray(null); + byte[] attrsBytes0 = commState.getByteArray("attrsBytes"); if (attrsBytes0 == BYTE_ARR_NOT_READ) return false; @@ -162,7 +162,7 @@ public IgniteUuid getJobId() { commState.idx++; case 1: - IgniteUuid jobId0 = commState.getGridUuid(null); + IgniteUuid jobId0 = commState.getGridUuid("jobId"); if (jobId0 == GRID_UUID_NOT_READ) return false; @@ -172,7 +172,7 @@ public IgniteUuid getJobId() { commState.idx++; case 2: - IgniteUuid sesId0 = commState.getGridUuid(null); + IgniteUuid sesId0 = commState.getGridUuid("sesId"); if (sesId0 == GRID_UUID_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/checkpoint/GridCheckpointRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/checkpoint/GridCheckpointRequest.java index c7ca93c3e4385..8932cc3397cb5 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/checkpoint/GridCheckpointRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/checkpoint/GridCheckpointRequest.java @@ -108,19 +108,19 @@ public String getCheckpointSpi() { switch (commState.idx) { case 0: - if (!commState.putString(null, cpSpi)) + if (!commState.putString("cpSpi", cpSpi)) return false; commState.idx++; case 1: - if (!commState.putString(null, key)) + if (!commState.putString("key", key)) return false; commState.idx++; case 2: - if (!commState.putGridUuid(null, sesId)) + if (!commState.putGridUuid("sesId", sesId)) return false; commState.idx++; @@ -137,7 +137,7 @@ public String getCheckpointSpi() { switch (commState.idx) { case 0: - String cpSpi0 = commState.getString(null); + String cpSpi0 = commState.getString("cpSpi"); if (cpSpi0 == STR_NOT_READ) return false; @@ -147,7 +147,7 @@ public String getCheckpointSpi() { commState.idx++; case 1: - String key0 = commState.getString(null); + String key0 = commState.getString("key"); if (key0 == STR_NOT_READ) return false; @@ -157,7 +157,7 @@ public String getCheckpointSpi() { commState.idx++; case 2: - IgniteUuid sesId0 = commState.getGridUuid(null); + IgniteUuid sesId0 = commState.getGridUuid("sesId"); if (sesId0 == GRID_UUID_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/communication/GridIoMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/communication/GridIoMessage.java index d9c11a565d526..098f52a53f73f 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/communication/GridIoMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/communication/GridIoMessage.java @@ -222,43 +222,43 @@ boolean isOrdered() { switch (commState.idx) { case 0: - if (!commState.putMessage(null, msg)) + if (!commState.putMessage("msg", msg)) return false; commState.idx++; case 1: - if (!commState.putLong(null, msgId)) + if (!commState.putLong("msgId", msgId)) return false; commState.idx++; case 2: - if (!commState.putEnum(null, plc)) + if (!commState.putEnum("plc", plc)) return false; commState.idx++; case 3: - if (!commState.putBoolean(null, skipOnTimeout)) + if (!commState.putBoolean("skipOnTimeout", skipOnTimeout)) return false; commState.idx++; case 4: - if (!commState.putLong(null, timeout)) + if (!commState.putLong("timeout", timeout)) return false; commState.idx++; case 5: - if (!commState.putByteArray(null, topicBytes)) + if (!commState.putByteArray("topicBytes", topicBytes)) return false; commState.idx++; case 6: - if (!commState.putInt(null, topicOrd)) + if (!commState.putInt("topicOrd", topicOrd)) return false; commState.idx++; @@ -275,7 +275,7 @@ boolean isOrdered() { switch (commState.idx) { case 0: - Object msg0 = commState.getMessage(null); + Object msg0 = commState.getMessage("msg"); if (msg0 == MSG_NOT_READ) return false; @@ -288,7 +288,7 @@ boolean isOrdered() { if (buf.remaining() < 8) return false; - msgId = commState.getLong(null); + msgId = commState.getLong("msgId"); commState.idx++; @@ -296,7 +296,7 @@ boolean isOrdered() { if (buf.remaining() < 1) return false; - byte plc0 = commState.getByte(null); + byte plc0 = commState.getByte("plc"); plc = GridIoPolicy.fromOrdinal(plc0); @@ -306,7 +306,7 @@ boolean isOrdered() { if (buf.remaining() < 1) return false; - skipOnTimeout = commState.getBoolean(null); + skipOnTimeout = commState.getBoolean("skipOnTimeout"); commState.idx++; @@ -314,12 +314,12 @@ boolean isOrdered() { if (buf.remaining() < 8) return false; - timeout = commState.getLong(null); + timeout = commState.getLong("timeout"); commState.idx++; case 5: - byte[] topicBytes0 = commState.getByteArray(null); + byte[] topicBytes0 = commState.getByteArray("topicBytes"); if (topicBytes0 == BYTE_ARR_NOT_READ) return false; @@ -332,7 +332,7 @@ boolean isOrdered() { if (buf.remaining() < 4) return false; - topicOrd = commState.getInt(null); + topicOrd = commState.getInt("topicOrd"); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/communication/GridIoUserMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/communication/GridIoUserMessage.java index 28590167f711d..3c5c459ae8d15 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/communication/GridIoUserMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/communication/GridIoUserMessage.java @@ -234,25 +234,25 @@ public void deployment(GridDeployment dep) { switch (commState.idx) { case 0: - if (!commState.putByteArray(null, bodyBytes)) + if (!commState.putByteArray("bodyBytes", bodyBytes)) return false; commState.idx++; case 1: - if (!commState.putGridUuid(null, clsLdrId)) + if (!commState.putGridUuid("clsLdrId", clsLdrId)) return false; commState.idx++; case 2: - if (!commState.putString(null, depClsName)) + if (!commState.putString("depClsName", depClsName)) return false; commState.idx++; case 3: - if (!commState.putEnum(null, depMode)) + if (!commState.putEnum("depMode", depMode)) return false; commState.idx++; @@ -296,13 +296,13 @@ public void deployment(GridDeployment dep) { commState.idx++; case 5: - if (!commState.putByteArray(null, topicBytes)) + if (!commState.putByteArray("topicBytes", topicBytes)) return false; commState.idx++; case 6: - if (!commState.putString(null, userVer)) + if (!commState.putString("userVer", userVer)) return false; commState.idx++; @@ -319,7 +319,7 @@ public void deployment(GridDeployment dep) { switch (commState.idx) { case 0: - byte[] bodyBytes0 = commState.getByteArray(null); + byte[] bodyBytes0 = commState.getByteArray("bodyBytes"); if (bodyBytes0 == BYTE_ARR_NOT_READ) return false; @@ -329,7 +329,7 @@ public void deployment(GridDeployment dep) { commState.idx++; case 1: - IgniteUuid clsLdrId0 = commState.getGridUuid(null); + IgniteUuid clsLdrId0 = commState.getGridUuid("clsLdrId"); if (clsLdrId0 == GRID_UUID_NOT_READ) return false; @@ -339,7 +339,7 @@ public void deployment(GridDeployment dep) { commState.idx++; case 2: - String depClsName0 = commState.getString(null); + String depClsName0 = commState.getString("depClsName"); if (depClsName0 == STR_NOT_READ) return false; @@ -352,7 +352,7 @@ public void deployment(GridDeployment dep) { if (buf.remaining() < 1) return false; - byte depMode0 = commState.getByte(null); + byte depMode0 = commState.getByte("depMode"); depMode = IgniteDeploymentMode.fromOrdinal(depMode0); @@ -368,7 +368,7 @@ public void deployment(GridDeployment dep) { if (commState.readSize >= 0) { if (ldrParties == null) - ldrParties = U.newHashMap(commState.readSize); + ldrParties = new HashMap<>(commState.readSize, 1.0f); for (int i = commState.readItems; i < commState.readSize; i++) { if (!commState.keyDone) { @@ -401,7 +401,7 @@ public void deployment(GridDeployment dep) { commState.idx++; case 5: - byte[] topicBytes0 = commState.getByteArray(null); + byte[] topicBytes0 = commState.getByteArray("topicBytes"); if (topicBytes0 == BYTE_ARR_NOT_READ) return false; @@ -411,7 +411,7 @@ public void deployment(GridDeployment dep) { commState.idx++; case 6: - String userVer0 = commState.getString(null); + String userVer0 = commState.getString("userVer"); if (userVer0 == STR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/deployment/GridDeploymentInfoBean.java b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/deployment/GridDeploymentInfoBean.java index c294a8c94d887..f9d1d85e1a557 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/deployment/GridDeploymentInfoBean.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/deployment/GridDeploymentInfoBean.java @@ -164,19 +164,19 @@ public void localDeploymentOwner(boolean locDepOwner) { switch (commState.idx) { case 0: - if (!commState.putGridUuid(null, clsLdrId)) + if (!commState.putGridUuid("clsLdrId", clsLdrId)) return false; commState.idx++; case 1: - if (!commState.putEnum(null, depMode)) + if (!commState.putEnum("depMode", depMode)) return false; commState.idx++; case 2: - if (!commState.putBoolean(null, locDepOwner)) + if (!commState.putBoolean("locDepOwner", locDepOwner)) return false; commState.idx++; @@ -220,7 +220,7 @@ public void localDeploymentOwner(boolean locDepOwner) { commState.idx++; case 4: - if (!commState.putString(null, userVer)) + if (!commState.putString("userVer", userVer)) return false; commState.idx++; @@ -237,7 +237,7 @@ public void localDeploymentOwner(boolean locDepOwner) { switch (commState.idx) { case 0: - IgniteUuid clsLdrId0 = commState.getGridUuid(null); + IgniteUuid clsLdrId0 = commState.getGridUuid("clsLdrId"); if (clsLdrId0 == GRID_UUID_NOT_READ) return false; @@ -250,7 +250,7 @@ public void localDeploymentOwner(boolean locDepOwner) { if (buf.remaining() < 1) return false; - byte depMode0 = commState.getByte(null); + byte depMode0 = commState.getByte("depMode"); depMode = IgniteDeploymentMode.fromOrdinal(depMode0); @@ -260,7 +260,7 @@ public void localDeploymentOwner(boolean locDepOwner) { if (buf.remaining() < 1) return false; - locDepOwner = commState.getBoolean(null); + locDepOwner = commState.getBoolean("locDepOwner"); commState.idx++; @@ -274,7 +274,7 @@ public void localDeploymentOwner(boolean locDepOwner) { if (commState.readSize >= 0) { if (participants == null) - participants = U.newHashMap(commState.readSize); + participants = new HashMap<>(commState.readSize, 1.0f); for (int i = commState.readItems; i < commState.readSize; i++) { if (!commState.keyDone) { @@ -307,7 +307,7 @@ public void localDeploymentOwner(boolean locDepOwner) { commState.idx++; case 4: - String userVer0 = commState.getString(null); + String userVer0 = commState.getString("userVer"); if (userVer0 == STR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/deployment/GridDeploymentRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/deployment/GridDeploymentRequest.java index ffcd80570a559..3dcc483f56e7a 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/deployment/GridDeploymentRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/deployment/GridDeploymentRequest.java @@ -183,13 +183,13 @@ public void nodeIds(Collection nodeIds) { switch (commState.idx) { case 0: - if (!commState.putBoolean(null, isUndeploy)) + if (!commState.putBoolean("isUndeploy", isUndeploy)) return false; commState.idx++; case 1: - if (!commState.putGridUuid(null, ldrId)) + if (!commState.putGridUuid("ldrId", ldrId)) return false; commState.idx++; @@ -222,13 +222,13 @@ public void nodeIds(Collection nodeIds) { commState.idx++; case 3: - if (!commState.putByteArray(null, resTopicBytes)) + if (!commState.putByteArray("resTopicBytes", resTopicBytes)) return false; commState.idx++; case 4: - if (!commState.putString(null, rsrcName)) + if (!commState.putString("rsrcName", rsrcName)) return false; commState.idx++; @@ -248,12 +248,12 @@ public void nodeIds(Collection nodeIds) { if (buf.remaining() < 1) return false; - isUndeploy = commState.getBoolean(null); + isUndeploy = commState.getBoolean("isUndeploy"); commState.idx++; case 1: - IgniteUuid ldrId0 = commState.getGridUuid(null); + IgniteUuid ldrId0 = commState.getGridUuid("ldrId"); if (ldrId0 == GRID_UUID_NOT_READ) return false; @@ -292,7 +292,7 @@ public void nodeIds(Collection nodeIds) { commState.idx++; case 3: - byte[] resTopicBytes0 = commState.getByteArray(null); + byte[] resTopicBytes0 = commState.getByteArray("resTopicBytes"); if (resTopicBytes0 == BYTE_ARR_NOT_READ) return false; @@ -302,7 +302,7 @@ public void nodeIds(Collection nodeIds) { commState.idx++; case 4: - String rsrcName0 = commState.getString(null); + String rsrcName0 = commState.getString("rsrcName"); if (rsrcName0 == STR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/deployment/GridDeploymentResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/deployment/GridDeploymentResponse.java index 3d8e7acd386b2..bf0a4b6780b27 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/deployment/GridDeploymentResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/deployment/GridDeploymentResponse.java @@ -131,19 +131,19 @@ void errorMessage(String errMsg) { switch (commState.idx) { case 0: - if (!commState.putByteArrayList(null, byteSrc)) + if (!commState.putByteArrayList("byteSrc", byteSrc)) return false; commState.idx++; case 1: - if (!commState.putString(null, errMsg)) + if (!commState.putString("errMsg", errMsg)) return false; commState.idx++; case 2: - if (!commState.putBoolean(null, success)) + if (!commState.putBoolean("success", success)) return false; commState.idx++; @@ -160,7 +160,7 @@ void errorMessage(String errMsg) { switch (commState.idx) { case 0: - GridByteArrayList byteSrc0 = commState.getByteArrayList(null); + GridByteArrayList byteSrc0 = commState.getByteArrayList("byteSrc"); if (byteSrc0 == BYTE_ARR_LIST_NOT_READ) return false; @@ -170,7 +170,7 @@ void errorMessage(String errMsg) { commState.idx++; case 1: - String errMsg0 = commState.getString(null); + String errMsg0 = commState.getString("errMsg"); if (errMsg0 == STR_NOT_READ) return false; @@ -183,7 +183,7 @@ void errorMessage(String errMsg) { if (buf.remaining() < 1) return false; - success = commState.getBoolean(null); + success = commState.getBoolean("success"); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/eventstorage/GridEventStorageMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/eventstorage/GridEventStorageMessage.java index f80707a142d98..4b5543cf146c1 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/eventstorage/GridEventStorageMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/eventstorage/GridEventStorageMessage.java @@ -294,37 +294,37 @@ void exceptionBytes(byte[] exBytes) { switch (commState.idx) { case 0: - if (!commState.putGridUuid(null, clsLdrId)) + if (!commState.putGridUuid("clsLdrId", clsLdrId)) return false; commState.idx++; case 1: - if (!commState.putEnum(null, depMode)) + if (!commState.putEnum("depMode", depMode)) return false; commState.idx++; case 2: - if (!commState.putByteArray(null, evtsBytes)) + if (!commState.putByteArray("evtsBytes", evtsBytes)) return false; commState.idx++; case 3: - if (!commState.putByteArray(null, exBytes)) + if (!commState.putByteArray("exBytes", exBytes)) return false; commState.idx++; case 4: - if (!commState.putByteArray(null, filter)) + if (!commState.putByteArray("filter", filter)) return false; commState.idx++; case 5: - if (!commState.putString(null, filterClsName)) + if (!commState.putString("filterClsName", filterClsName)) return false; commState.idx++; @@ -368,13 +368,13 @@ void exceptionBytes(byte[] exBytes) { commState.idx++; case 7: - if (!commState.putByteArray(null, resTopicBytes)) + if (!commState.putByteArray("resTopicBytes", resTopicBytes)) return false; commState.idx++; case 8: - if (!commState.putString(null, userVer)) + if (!commState.putString("userVer", userVer)) return false; commState.idx++; @@ -391,7 +391,7 @@ void exceptionBytes(byte[] exBytes) { switch (commState.idx) { case 0: - IgniteUuid clsLdrId0 = commState.getGridUuid(null); + IgniteUuid clsLdrId0 = commState.getGridUuid("clsLdrId"); if (clsLdrId0 == GRID_UUID_NOT_READ) return false; @@ -404,14 +404,14 @@ void exceptionBytes(byte[] exBytes) { if (buf.remaining() < 1) return false; - byte depMode0 = commState.getByte(null); + byte depMode0 = commState.getByte("depMode"); depMode = IgniteDeploymentMode.fromOrdinal(depMode0); commState.idx++; case 2: - byte[] evtsBytes0 = commState.getByteArray(null); + byte[] evtsBytes0 = commState.getByteArray("evtsBytes"); if (evtsBytes0 == BYTE_ARR_NOT_READ) return false; @@ -421,7 +421,7 @@ void exceptionBytes(byte[] exBytes) { commState.idx++; case 3: - byte[] exBytes0 = commState.getByteArray(null); + byte[] exBytes0 = commState.getByteArray("exBytes"); if (exBytes0 == BYTE_ARR_NOT_READ) return false; @@ -431,7 +431,7 @@ void exceptionBytes(byte[] exBytes) { commState.idx++; case 4: - byte[] filter0 = commState.getByteArray(null); + byte[] filter0 = commState.getByteArray("filter"); if (filter0 == BYTE_ARR_NOT_READ) return false; @@ -441,7 +441,7 @@ void exceptionBytes(byte[] exBytes) { commState.idx++; case 5: - String filterClsName0 = commState.getString(null); + String filterClsName0 = commState.getString("filterClsName"); if (filterClsName0 == STR_NOT_READ) return false; @@ -460,7 +460,7 @@ void exceptionBytes(byte[] exBytes) { if (commState.readSize >= 0) { if (ldrParties == null) - ldrParties = U.newHashMap(commState.readSize); + ldrParties = new HashMap<>(commState.readSize, 1.0f); for (int i = commState.readItems; i < commState.readSize; i++) { if (!commState.keyDone) { @@ -493,7 +493,7 @@ void exceptionBytes(byte[] exBytes) { commState.idx++; case 7: - byte[] resTopicBytes0 = commState.getByteArray(null); + byte[] resTopicBytes0 = commState.getByteArray("resTopicBytes"); if (resTopicBytes0 == BYTE_ARR_NOT_READ) return false; @@ -503,7 +503,7 @@ void exceptionBytes(byte[] exBytes) { commState.idx++; case 8: - String userVer0 = commState.getString(null); + String userVer0 = commState.getString("userVer"); if (userVer0 == STR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEvictionRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEvictionRequest.java index 8a1f0b9d9d642..3c3bd83a92bda 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEvictionRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEvictionRequest.java @@ -169,19 +169,19 @@ void addKey(K key, GridCacheVersion ver, boolean near) { switch (commState.idx) { case 3: - if (!commState.putByteArray(null, entriesBytes)) + if (!commState.putByteArray("entriesBytes", entriesBytes)) return false; commState.idx++; case 4: - if (!commState.putLong(null, futId)) + if (!commState.putLong("futId", futId)) return false; commState.idx++; case 5: - if (!commState.putLong(null, topVer)) + if (!commState.putLong("topVer", topVer)) return false; commState.idx++; @@ -201,7 +201,7 @@ void addKey(K key, GridCacheVersion ver, boolean near) { switch (commState.idx) { case 3: - byte[] entriesBytes0 = commState.getByteArray(null); + byte[] entriesBytes0 = commState.getByteArray("entriesBytes"); if (entriesBytes0 == BYTE_ARR_NOT_READ) return false; @@ -214,7 +214,7 @@ void addKey(K key, GridCacheVersion ver, boolean near) { if (buf.remaining() < 8) return false; - futId = commState.getLong(null); + futId = commState.getLong("futId"); commState.idx++; @@ -222,7 +222,7 @@ void addKey(K key, GridCacheVersion ver, boolean near) { if (buf.remaining() < 8) return false; - topVer = commState.getLong(null); + topVer = commState.getLong("topVer"); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEvictionResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEvictionResponse.java index 203b99d8396fc..a14604af94354 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEvictionResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEvictionResponse.java @@ -159,13 +159,13 @@ boolean error() { switch (commState.idx) { case 3: - if (!commState.putBoolean(null, err)) + if (!commState.putBoolean("err", err)) return false; commState.idx++; case 4: - if (!commState.putLong(null, futId)) + if (!commState.putLong("futId", futId)) return false; commState.idx++; @@ -215,7 +215,7 @@ boolean error() { if (buf.remaining() < 1) return false; - err = commState.getBoolean(null); + err = commState.getBoolean("err"); commState.idx++; @@ -223,7 +223,7 @@ boolean error() { if (buf.remaining() < 8) return false; - futId = commState.getLong(null); + futId = commState.getLong("futId"); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMessage.java index ea7987de5d858..8d6986baeaf80 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMessage.java @@ -594,19 +594,19 @@ protected final void unmarshalTx(Iterable> txEntries, boo switch (commState.idx) { case 0: - if (!commState.putInt(null, cacheId)) + if (!commState.putInt("cacheId", cacheId)) return false; commState.idx++; case 1: - if (!commState.putMessage(null, depInfo)) + if (!commState.putMessage("depInfo", depInfo)) return false; commState.idx++; case 2: - if (!commState.putLong(null, msgId)) + if (!commState.putLong("msgId", msgId)) return false; commState.idx++; @@ -626,12 +626,12 @@ protected final void unmarshalTx(Iterable> txEntries, boo if (buf.remaining() < 4) return false; - cacheId = commState.getInt(null); + cacheId = commState.getInt("cacheId"); commState.idx++; case 1: - Object depInfo0 = commState.getMessage(null); + Object depInfo0 = commState.getMessage("depInfo"); if (depInfo0 == MSG_NOT_READ) return false; @@ -644,7 +644,7 @@ protected final void unmarshalTx(Iterable> txEntries, boo if (buf.remaining() < 8) return false; - msgId = commState.getLong(null); + msgId = commState.getLong("msgId"); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxRequest.java index 88c087fd6a33f..93f8653b9c4b7 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxRequest.java @@ -126,25 +126,25 @@ public int transactions() { switch (commState.idx) { case 8: - if (!commState.putGridUuid(null, futId)) + if (!commState.putGridUuid("futId", futId)) return false; commState.idx++; case 9: - if (!commState.putGridUuid(null, miniId)) + if (!commState.putGridUuid("miniId", miniId)) return false; commState.idx++; case 10: - if (!commState.putCacheVersion(null, nearXidVer)) + if (!commState.putCacheVersion("nearXidVer", nearXidVer)) return false; commState.idx++; case 11: - if (!commState.putInt(null, txNum)) + if (!commState.putInt("txNum", txNum)) return false; commState.idx++; @@ -164,7 +164,7 @@ public int transactions() { switch (commState.idx) { case 8: - IgniteUuid futId0 = commState.getGridUuid(null); + IgniteUuid futId0 = commState.getGridUuid("futId"); if (futId0 == GRID_UUID_NOT_READ) return false; @@ -174,7 +174,7 @@ public int transactions() { commState.idx++; case 9: - IgniteUuid miniId0 = commState.getGridUuid(null); + IgniteUuid miniId0 = commState.getGridUuid("miniId"); if (miniId0 == GRID_UUID_NOT_READ) return false; @@ -184,7 +184,7 @@ public int transactions() { commState.idx++; case 10: - GridCacheVersion nearXidVer0 = commState.getCacheVersion(null); + GridCacheVersion nearXidVer0 = commState.getCacheVersion("nearXidVer"); if (nearXidVer0 == CACHE_VER_NOT_READ) return false; @@ -197,7 +197,7 @@ public int transactions() { if (buf.remaining() < 4) return false; - txNum = commState.getInt(null); + txNum = commState.getInt("txNum"); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxResponse.java index 1baa17a275381..4bfda3dc9388d 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxResponse.java @@ -114,19 +114,19 @@ public boolean success() { switch (commState.idx) { case 8: - if (!commState.putGridUuid(null, futId)) + if (!commState.putGridUuid("futId", futId)) return false; commState.idx++; case 9: - if (!commState.putGridUuid(null, miniId)) + if (!commState.putGridUuid("miniId", miniId)) return false; commState.idx++; case 10: - if (!commState.putBoolean(null, success)) + if (!commState.putBoolean("success", success)) return false; commState.idx++; @@ -146,7 +146,7 @@ public boolean success() { switch (commState.idx) { case 8: - IgniteUuid futId0 = commState.getGridUuid(null); + IgniteUuid futId0 = commState.getGridUuid("futId"); if (futId0 == GRID_UUID_NOT_READ) return false; @@ -156,7 +156,7 @@ public boolean success() { commState.idx++; case 9: - IgniteUuid miniId0 = commState.getGridUuid(null); + IgniteUuid miniId0 = commState.getGridUuid("miniId"); if (miniId0 == GRID_UUID_NOT_READ) return false; @@ -169,7 +169,7 @@ public boolean success() { if (buf.remaining() < 1) return false; - success = commState.getBoolean(null); + success = commState.getBoolean("success"); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxRequest.java index 89b1a4b92c08f..f25317ae3dde7 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxRequest.java @@ -161,37 +161,37 @@ public boolean nearOnlyCheck() { switch (commState.idx) { case 8: - if (!commState.putGridUuid(null, futId)) + if (!commState.putGridUuid("futId", futId)) return false; commState.idx++; case 9: - if (!commState.putGridUuid(null, miniId)) + if (!commState.putGridUuid("miniId", miniId)) return false; commState.idx++; case 10: - if (!commState.putCacheVersion(null, nearXidVer)) + if (!commState.putCacheVersion("nearXidVer", nearXidVer)) return false; commState.idx++; case 11: - if (!commState.putUuid(null, originatingNodeId)) + if (!commState.putUuid("originatingNodeId", originatingNodeId)) return false; commState.idx++; case 12: - if (!commState.putLong(null, originatingThreadId)) + if (!commState.putLong("originatingThreadId", originatingThreadId)) return false; commState.idx++; case 13: - if (!commState.putBoolean(null, nearOnlyCheck)) + if (!commState.putBoolean("nearOnlyCheck", nearOnlyCheck)) return false; commState.idx++; @@ -211,7 +211,7 @@ public boolean nearOnlyCheck() { switch (commState.idx) { case 8: - IgniteUuid futId0 = commState.getGridUuid(null); + IgniteUuid futId0 = commState.getGridUuid("futId"); if (futId0 == GRID_UUID_NOT_READ) return false; @@ -221,7 +221,7 @@ public boolean nearOnlyCheck() { commState.idx++; case 9: - IgniteUuid miniId0 = commState.getGridUuid(null); + IgniteUuid miniId0 = commState.getGridUuid("miniId"); if (miniId0 == GRID_UUID_NOT_READ) return false; @@ -231,7 +231,7 @@ public boolean nearOnlyCheck() { commState.idx++; case 10: - GridCacheVersion nearXidVer0 = commState.getCacheVersion(null); + GridCacheVersion nearXidVer0 = commState.getCacheVersion("nearXidVer"); if (nearXidVer0 == CACHE_VER_NOT_READ) return false; @@ -241,7 +241,7 @@ public boolean nearOnlyCheck() { commState.idx++; case 11: - UUID originatingNodeId0 = commState.getUuid(null); + UUID originatingNodeId0 = commState.getUuid("originatingNodeId"); if (originatingNodeId0 == UUID_NOT_READ) return false; @@ -254,7 +254,7 @@ public boolean nearOnlyCheck() { if (buf.remaining() < 8) return false; - originatingThreadId = commState.getLong(null); + originatingThreadId = commState.getLong("originatingThreadId"); commState.idx++; @@ -262,7 +262,7 @@ public boolean nearOnlyCheck() { if (buf.remaining() < 1) return false; - nearOnlyCheck = commState.getBoolean(null); + nearOnlyCheck = commState.getBoolean("nearOnlyCheck"); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxResponse.java index 88f354bb4afa7..19cfbb824fc8f 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxResponse.java @@ -145,19 +145,19 @@ public GridCacheCommittedTxInfo committedTxInfo() { switch (commState.idx) { case 8: - if (!commState.putByteArray(null, committedTxInfoBytes)) + if (!commState.putByteArray("committedTxInfoBytes", committedTxInfoBytes)) return false; commState.idx++; case 9: - if (!commState.putGridUuid(null, futId)) + if (!commState.putGridUuid("futId", futId)) return false; commState.idx++; case 10: - if (!commState.putGridUuid(null, miniId)) + if (!commState.putGridUuid("miniId", miniId)) return false; commState.idx++; @@ -177,7 +177,7 @@ public GridCacheCommittedTxInfo committedTxInfo() { switch (commState.idx) { case 8: - byte[] committedTxInfoBytes0 = commState.getByteArray(null); + byte[] committedTxInfoBytes0 = commState.getByteArray("committedTxInfoBytes"); if (committedTxInfoBytes0 == BYTE_ARR_NOT_READ) return false; @@ -187,7 +187,7 @@ public GridCacheCommittedTxInfo committedTxInfo() { commState.idx++; case 9: - IgniteUuid futId0 = commState.getGridUuid(null); + IgniteUuid futId0 = commState.getGridUuid("futId"); if (futId0 == GRID_UUID_NOT_READ) return false; @@ -197,7 +197,7 @@ public GridCacheCommittedTxInfo committedTxInfo() { commState.idx++; case 10: - IgniteUuid miniId0 = commState.getGridUuid(null); + IgniteUuid miniId0 = commState.getGridUuid("miniId"); if (miniId0 == GRID_UUID_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedBaseMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedBaseMessage.java index 3a0a86ff17b66..3709cd951122c 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedBaseMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedBaseMessage.java @@ -263,13 +263,13 @@ public int keysCount() { switch (commState.idx) { case 3: - if (!commState.putByteArray(null, candsByIdxBytes)) + if (!commState.putByteArray("candsByIdxBytes", candsByIdxBytes)) return false; commState.idx++; case 4: - if (!commState.putByteArray(null, candsByKeyBytes)) + if (!commState.putByteArray("candsByKeyBytes", candsByKeyBytes)) return false; commState.idx++; @@ -329,7 +329,7 @@ public int keysCount() { commState.idx++; case 7: - if (!commState.putCacheVersion(null, ver)) + if (!commState.putCacheVersion("ver", ver)) return false; commState.idx++; @@ -349,7 +349,7 @@ public int keysCount() { switch (commState.idx) { case 3: - byte[] candsByIdxBytes0 = commState.getByteArray(null); + byte[] candsByIdxBytes0 = commState.getByteArray("candsByIdxBytes"); if (candsByIdxBytes0 == BYTE_ARR_NOT_READ) return false; @@ -359,7 +359,7 @@ public int keysCount() { commState.idx++; case 4: - byte[] candsByKeyBytes0 = commState.getByteArray(null); + byte[] candsByKeyBytes0 = commState.getByteArray("candsByKeyBytes"); if (candsByKeyBytes0 == BYTE_ARR_NOT_READ) return false; @@ -427,7 +427,7 @@ public int keysCount() { commState.idx++; case 7: - GridCacheVersion ver0 = commState.getCacheVersion(null); + GridCacheVersion ver0 = commState.getCacheVersion("ver"); if (ver0 == CACHE_VER_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedLockRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedLockRequest.java index add0721cd7bea..0a49f1043d5c8 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedLockRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedLockRequest.java @@ -498,37 +498,37 @@ public GridCacheVersion[] drVersions() { commState.idx++; case 9: - if (!commState.putGridUuid(null, futId)) + if (!commState.putGridUuid("futId", futId)) return false; commState.idx++; case 10: - if (!commState.putByteArray(null, grpLockKeyBytes)) + if (!commState.putByteArray("grpLockKeyBytes", grpLockKeyBytes)) return false; commState.idx++; case 11: - if (!commState.putBoolean(null, isInTx)) + if (!commState.putBoolean("isInTx", isInTx)) return false; commState.idx++; case 12: - if (!commState.putBoolean(null, isInvalidate)) + if (!commState.putBoolean("isInvalidate", isInvalidate)) return false; commState.idx++; case 13: - if (!commState.putBoolean(null, isRead)) + if (!commState.putBoolean("isRead", isRead)) return false; commState.idx++; case 14: - if (!commState.putEnum(null, isolation)) + if (!commState.putEnum("isolation", isolation)) return false; commState.idx++; @@ -561,49 +561,49 @@ public GridCacheVersion[] drVersions() { commState.idx++; case 16: - if (!commState.putCacheVersion(null, nearXidVer)) + if (!commState.putCacheVersion("nearXidVer", nearXidVer)) return false; commState.idx++; case 17: - if (!commState.putUuid(null, nodeId)) + if (!commState.putUuid("nodeId", nodeId)) return false; commState.idx++; case 18: - if (!commState.putBoolean(null, partLock)) + if (!commState.putBoolean("partLock", partLock)) return false; commState.idx++; case 19: - if (!commState.putBooleanArray(null, retVals)) + if (!commState.putBooleanArray("retVals", retVals)) return false; commState.idx++; case 20: - if (!commState.putLong(null, threadId)) + if (!commState.putLong("threadId", threadId)) return false; commState.idx++; case 21: - if (!commState.putLong(null, timeout)) + if (!commState.putLong("timeout", timeout)) return false; commState.idx++; case 22: - if (!commState.putInt(null, txSize)) + if (!commState.putInt("txSize", txSize)) return false; commState.idx++; case 23: - if (!commState.putByteArray(null, writeEntriesBytes)) + if (!commState.putByteArray("writeEntriesBytes", writeEntriesBytes)) return false; commState.idx++; @@ -652,7 +652,7 @@ public GridCacheVersion[] drVersions() { commState.idx++; case 9: - IgniteUuid futId0 = commState.getGridUuid(null); + IgniteUuid futId0 = commState.getGridUuid("futId"); if (futId0 == GRID_UUID_NOT_READ) return false; @@ -662,7 +662,7 @@ public GridCacheVersion[] drVersions() { commState.idx++; case 10: - byte[] grpLockKeyBytes0 = commState.getByteArray(null); + byte[] grpLockKeyBytes0 = commState.getByteArray("grpLockKeyBytes"); if (grpLockKeyBytes0 == BYTE_ARR_NOT_READ) return false; @@ -675,7 +675,7 @@ public GridCacheVersion[] drVersions() { if (buf.remaining() < 1) return false; - isInTx = commState.getBoolean(null); + isInTx = commState.getBoolean("isInTx"); commState.idx++; @@ -683,7 +683,7 @@ public GridCacheVersion[] drVersions() { if (buf.remaining() < 1) return false; - isInvalidate = commState.getBoolean(null); + isInvalidate = commState.getBoolean("isInvalidate"); commState.idx++; @@ -691,7 +691,7 @@ public GridCacheVersion[] drVersions() { if (buf.remaining() < 1) return false; - isRead = commState.getBoolean(null); + isRead = commState.getBoolean("isRead"); commState.idx++; @@ -699,7 +699,7 @@ public GridCacheVersion[] drVersions() { if (buf.remaining() < 1) return false; - byte isolation0 = commState.getByte(null); + byte isolation0 = commState.getByte("isolation"); isolation = GridCacheTxIsolation.fromOrdinal(isolation0); @@ -735,7 +735,7 @@ public GridCacheVersion[] drVersions() { commState.idx++; case 16: - GridCacheVersion nearXidVer0 = commState.getCacheVersion(null); + GridCacheVersion nearXidVer0 = commState.getCacheVersion("nearXidVer"); if (nearXidVer0 == CACHE_VER_NOT_READ) return false; @@ -745,7 +745,7 @@ public GridCacheVersion[] drVersions() { commState.idx++; case 17: - UUID nodeId0 = commState.getUuid(null); + UUID nodeId0 = commState.getUuid("nodeId"); if (nodeId0 == UUID_NOT_READ) return false; @@ -758,12 +758,12 @@ public GridCacheVersion[] drVersions() { if (buf.remaining() < 1) return false; - partLock = commState.getBoolean(null); + partLock = commState.getBoolean("partLock"); commState.idx++; case 19: - boolean[] retVals0 = commState.getBooleanArray(null); + boolean[] retVals0 = commState.getBooleanArray("retVals"); if (retVals0 == BOOLEAN_ARR_NOT_READ) return false; @@ -776,7 +776,7 @@ public GridCacheVersion[] drVersions() { if (buf.remaining() < 8) return false; - threadId = commState.getLong(null); + threadId = commState.getLong("threadId"); commState.idx++; @@ -784,7 +784,7 @@ public GridCacheVersion[] drVersions() { if (buf.remaining() < 8) return false; - timeout = commState.getLong(null); + timeout = commState.getLong("timeout"); commState.idx++; @@ -792,12 +792,12 @@ public GridCacheVersion[] drVersions() { if (buf.remaining() < 4) return false; - txSize = commState.getInt(null); + txSize = commState.getInt("txSize"); commState.idx++; case 23: - byte[] writeEntriesBytes0 = commState.getByteArray(null); + byte[] writeEntriesBytes0 = commState.getByteArray("writeEntriesBytes"); if (writeEntriesBytes0 == BYTE_ARR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedLockResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedLockResponse.java index cf940597e2027..7facf11bda2a3 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedLockResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedLockResponse.java @@ -295,13 +295,13 @@ protected int valuesSize() { switch (commState.idx) { case 8: - if (!commState.putByteArray(null, errBytes)) + if (!commState.putByteArray("errBytes", errBytes)) return false; commState.idx++; case 9: - if (!commState.putGridUuid(null, futId)) + if (!commState.putGridUuid("futId", futId)) return false; commState.idx++; @@ -348,7 +348,7 @@ protected int valuesSize() { switch (commState.idx) { case 8: - byte[] errBytes0 = commState.getByteArray(null); + byte[] errBytes0 = commState.getByteArray("errBytes"); if (errBytes0 == BYTE_ARR_NOT_READ) return false; @@ -358,7 +358,7 @@ protected int valuesSize() { commState.idx++; case 9: - IgniteUuid futId0 = commState.getGridUuid(null); + IgniteUuid futId0 = commState.getGridUuid("futId"); if (futId0 == GRID_UUID_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxFinishRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxFinishRequest.java index 8ffbc3dff2329..b41665d45a730 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxFinishRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxFinishRequest.java @@ -342,6 +342,8 @@ public boolean groupLock() { _clone.commitVer = commitVer; _clone.invalidate = invalidate; _clone.commit = commit; + _clone.syncCommit = syncCommit; + _clone.syncRollback = syncRollback; _clone.baseVer = baseVer; _clone.writeEntries = writeEntries; _clone.writeEntriesBytes = writeEntriesBytes; @@ -369,54 +371,42 @@ public boolean groupLock() { switch (commState.idx) { case 8: - if (!commState.putCacheVersion(null, baseVer)) + if (!commState.putCacheVersion("baseVer", baseVer)) return false; commState.idx++; case 9: - if (!commState.putBoolean(null, commit)) + if (!commState.putBoolean("commit", commit)) return false; commState.idx++; case 10: - if (!commState.putCacheVersion(null, commitVer)) + if (!commState.putCacheVersion("commitVer", commitVer)) return false; commState.idx++; case 11: - if (!commState.putGridUuid(null, futId)) + if (!commState.putGridUuid("futId", futId)) return false; commState.idx++; case 12: - if (!commState.putByteArray(null, grpLockKeyBytes)) + if (!commState.putByteArray("grpLockKeyBytes", grpLockKeyBytes)) return false; commState.idx++; case 13: - if (!commState.putBoolean(null, invalidate)) + if (!commState.putBoolean("invalidate", invalidate)) return false; commState.idx++; case 14: - if (!commState.putBoolean(null, syncCommit)) - return false; - - commState.idx++; - - case 15: - if (!commState.putBoolean(null, syncRollback)) - return false; - - commState.idx++; - - case 16: if (recoveryWritesBytes != null) { if (commState.it == null) { if (!commState.putInt(null, recoveryWritesBytes.size())) @@ -443,14 +433,26 @@ public boolean groupLock() { commState.idx++; + case 15: + if (!commState.putBoolean("syncCommit", syncCommit)) + return false; + + commState.idx++; + + case 16: + if (!commState.putBoolean("syncRollback", syncRollback)) + return false; + + commState.idx++; + case 17: - if (!commState.putLong(null, threadId)) + if (!commState.putLong("threadId", threadId)) return false; commState.idx++; case 18: - if (!commState.putInt(null, txSize)) + if (!commState.putInt("txSize", txSize)) return false; commState.idx++; @@ -497,7 +499,7 @@ public boolean groupLock() { switch (commState.idx) { case 8: - GridCacheVersion baseVer0 = commState.getCacheVersion(null); + GridCacheVersion baseVer0 = commState.getCacheVersion("baseVer"); if (baseVer0 == CACHE_VER_NOT_READ) return false; @@ -510,12 +512,12 @@ public boolean groupLock() { if (buf.remaining() < 1) return false; - commit = commState.getBoolean(null); + commit = commState.getBoolean("commit"); commState.idx++; case 10: - GridCacheVersion commitVer0 = commState.getCacheVersion(null); + GridCacheVersion commitVer0 = commState.getCacheVersion("commitVer"); if (commitVer0 == CACHE_VER_NOT_READ) return false; @@ -525,7 +527,7 @@ public boolean groupLock() { commState.idx++; case 11: - IgniteUuid futId0 = commState.getGridUuid(null); + IgniteUuid futId0 = commState.getGridUuid("futId"); if (futId0 == GRID_UUID_NOT_READ) return false; @@ -535,7 +537,7 @@ public boolean groupLock() { commState.idx++; case 12: - byte[] grpLockKeyBytes0 = commState.getByteArray(null); + byte[] grpLockKeyBytes0 = commState.getByteArray("grpLockKeyBytes"); if (grpLockKeyBytes0 == BYTE_ARR_NOT_READ) return false; @@ -548,27 +550,11 @@ public boolean groupLock() { if (buf.remaining() < 1) return false; - invalidate = commState.getBoolean(null); + invalidate = commState.getBoolean("invalidate"); commState.idx++; case 14: - if (buf.remaining() < 1) - return false; - - syncCommit = commState.getBoolean(null); - - commState.idx++; - - case 15: - if (buf.remaining() < 1) - return false; - - syncRollback = commState.getBoolean(null); - - commState.idx++; - - case 16: if (commState.readSize == -1) { if (buf.remaining() < 4) return false; @@ -597,11 +583,27 @@ public boolean groupLock() { commState.idx++; + case 15: + if (buf.remaining() < 1) + return false; + + syncCommit = commState.getBoolean("syncCommit"); + + commState.idx++; + + case 16: + if (buf.remaining() < 1) + return false; + + syncRollback = commState.getBoolean("syncRollback"); + + commState.idx++; + case 17: if (buf.remaining() < 8) return false; - threadId = commState.getLong(null); + threadId = commState.getLong("threadId"); commState.idx++; @@ -609,7 +611,7 @@ public boolean groupLock() { if (buf.remaining() < 4) return false; - txSize = commState.getInt(null); + txSize = commState.getInt("txSize"); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxFinishResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxFinishResponse.java index eb68e05a27c2d..fd616d0bd2553 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxFinishResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxFinishResponse.java @@ -102,13 +102,13 @@ public IgniteUuid futureId() { switch (commState.idx) { case 3: - if (!commState.putGridUuid(null, futId)) + if (!commState.putGridUuid("futId", futId)) return false; commState.idx++; case 4: - if (!commState.putCacheVersion(null, txId)) + if (!commState.putCacheVersion("txId", txId)) return false; commState.idx++; @@ -128,7 +128,7 @@ public IgniteUuid futureId() { switch (commState.idx) { case 3: - IgniteUuid futId0 = commState.getGridUuid(null); + IgniteUuid futId0 = commState.getGridUuid("futId"); if (futId0 == GRID_UUID_NOT_READ) return false; @@ -138,7 +138,7 @@ public IgniteUuid futureId() { commState.idx++; case 4: - GridCacheVersion txId0 = commState.getCacheVersion(null); + GridCacheVersion txId0 = commState.getCacheVersion("txId"); if (txId0 == CACHE_VER_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxPrepareRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxPrepareRequest.java index 4aa4963494d96..25db96ef8e9fc 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxPrepareRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxPrepareRequest.java @@ -434,43 +434,43 @@ private void writeCollection(ObjectOutput out, Collection switch (commState.idx) { case 8: - if (!commState.putCacheVersion(null, commitVer)) + if (!commState.putCacheVersion("commitVer", commitVer)) return false; commState.idx++; case 9: - if (!commState.putEnum(null, concurrency)) + if (!commState.putEnum("concurrency", concurrency)) return false; commState.idx++; case 10: - if (!commState.putByteArray(null, dhtVersBytes)) + if (!commState.putByteArray("dhtVersBytes", dhtVersBytes)) return false; commState.idx++; case 11: - if (!commState.putByteArray(null, grpLockKeyBytes)) + if (!commState.putByteArray("grpLockKeyBytes", grpLockKeyBytes)) return false; commState.idx++; case 12: - if (!commState.putBoolean(null, invalidate)) + if (!commState.putBoolean("invalidate", invalidate)) return false; commState.idx++; case 13: - if (!commState.putEnum(null, isolation)) + if (!commState.putEnum("isolation", isolation)) return false; commState.idx++; case 14: - if (!commState.putBoolean(null, partLock)) + if (!commState.putBoolean("partLock", partLock)) return false; commState.idx++; @@ -503,25 +503,25 @@ private void writeCollection(ObjectOutput out, Collection commState.idx++; case 16: - if (!commState.putLong(null, threadId)) + if (!commState.putLong("threadId", threadId)) return false; commState.idx++; case 17: - if (!commState.putLong(null, timeout)) + if (!commState.putLong("timeout", timeout)) return false; commState.idx++; case 18: - if (!commState.putByteArray(null, txNodesBytes)) + if (!commState.putByteArray("txNodesBytes", txNodesBytes)) return false; commState.idx++; case 19: - if (!commState.putInt(null, txSize)) + if (!commState.putInt("txSize", txSize)) return false; commState.idx++; @@ -568,7 +568,7 @@ private void writeCollection(ObjectOutput out, Collection switch (commState.idx) { case 8: - GridCacheVersion commitVer0 = commState.getCacheVersion(null); + GridCacheVersion commitVer0 = commState.getCacheVersion("commitVer"); if (commitVer0 == CACHE_VER_NOT_READ) return false; @@ -581,14 +581,14 @@ private void writeCollection(ObjectOutput out, Collection if (buf.remaining() < 1) return false; - byte concurrency0 = commState.getByte(null); + byte concurrency0 = commState.getByte("concurrency"); concurrency = GridCacheTxConcurrency.fromOrdinal(concurrency0); commState.idx++; case 10: - byte[] dhtVersBytes0 = commState.getByteArray(null); + byte[] dhtVersBytes0 = commState.getByteArray("dhtVersBytes"); if (dhtVersBytes0 == BYTE_ARR_NOT_READ) return false; @@ -598,7 +598,7 @@ private void writeCollection(ObjectOutput out, Collection commState.idx++; case 11: - byte[] grpLockKeyBytes0 = commState.getByteArray(null); + byte[] grpLockKeyBytes0 = commState.getByteArray("grpLockKeyBytes"); if (grpLockKeyBytes0 == BYTE_ARR_NOT_READ) return false; @@ -611,7 +611,7 @@ private void writeCollection(ObjectOutput out, Collection if (buf.remaining() < 1) return false; - invalidate = commState.getBoolean(null); + invalidate = commState.getBoolean("invalidate"); commState.idx++; @@ -619,7 +619,7 @@ private void writeCollection(ObjectOutput out, Collection if (buf.remaining() < 1) return false; - byte isolation0 = commState.getByte(null); + byte isolation0 = commState.getByte("isolation"); isolation = GridCacheTxIsolation.fromOrdinal(isolation0); @@ -629,7 +629,7 @@ private void writeCollection(ObjectOutput out, Collection if (buf.remaining() < 1) return false; - partLock = commState.getBoolean(null); + partLock = commState.getBoolean("partLock"); commState.idx++; @@ -666,7 +666,7 @@ private void writeCollection(ObjectOutput out, Collection if (buf.remaining() < 8) return false; - threadId = commState.getLong(null); + threadId = commState.getLong("threadId"); commState.idx++; @@ -674,12 +674,12 @@ private void writeCollection(ObjectOutput out, Collection if (buf.remaining() < 8) return false; - timeout = commState.getLong(null); + timeout = commState.getLong("timeout"); commState.idx++; case 18: - byte[] txNodesBytes0 = commState.getByteArray(null); + byte[] txNodesBytes0 = commState.getByteArray("txNodesBytes"); if (txNodesBytes0 == BYTE_ARR_NOT_READ) return false; @@ -692,7 +692,7 @@ private void writeCollection(ObjectOutput out, Collection if (buf.remaining() < 4) return false; - txSize = commState.getInt(null); + txSize = commState.getInt("txSize"); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxPrepareResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxPrepareResponse.java index 2754c9e8d82a9..64922f7ce6947 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxPrepareResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxPrepareResponse.java @@ -179,13 +179,13 @@ public void candidates(Map>> cands) { switch (commState.idx) { case 8: - if (!commState.putByteArray(null, candsBytes)) + if (!commState.putByteArray("candsBytes", candsBytes)) return false; commState.idx++; case 9: - if (!commState.putByteArray(null, errBytes)) + if (!commState.putByteArray("errBytes", errBytes)) return false; commState.idx++; @@ -205,7 +205,7 @@ public void candidates(Map>> cands) { switch (commState.idx) { case 8: - byte[] candsBytes0 = commState.getByteArray(null); + byte[] candsBytes0 = commState.getByteArray("candsBytes"); if (candsBytes0 == BYTE_ARR_NOT_READ) return false; @@ -215,7 +215,7 @@ public void candidates(Map>> cands) { commState.idx++; case 9: - byte[] errBytes0 = commState.getByteArray(null); + byte[] errBytes0 = commState.getByteArray("errBytes"); if (errBytes0 == BYTE_ARR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java index ef4e7bad28b97..9c6b74ba5eaae 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java @@ -93,7 +93,7 @@ public GridDhtAffinityAssignmentRequest(int cacheId, long topVer) { switch (commState.idx) { case 3: - if (!commState.putLong(null, topVer)) + if (!commState.putLong("topVer", topVer)) return false; commState.idx++; @@ -115,7 +115,7 @@ public GridDhtAffinityAssignmentRequest(int cacheId, long topVer) { if (buf.remaining() < 8) return false; - topVer = commState.getLong(null); + topVer = commState.getLong("topVer"); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java index 24957637b47c8..151e833804e3a 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java @@ -134,13 +134,13 @@ public List> affinityAssignment() { switch (commState.idx) { case 3: - if (!commState.putByteArray(null, affAssignmentBytes)) + if (!commState.putByteArray("affAssignmentBytes", affAssignmentBytes)) return false; commState.idx++; case 4: - if (!commState.putLong(null, topVer)) + if (!commState.putLong("topVer", topVer)) return false; commState.idx++; @@ -159,7 +159,7 @@ public List> affinityAssignment() { switch (commState.idx) { case 3: - byte[] affAssignmentBytes0 = commState.getByteArray(null); + byte[] affAssignmentBytes0 = commState.getByteArray("affAssignmentBytes"); if (affAssignmentBytes0 == BYTE_ARR_NOT_READ) return false; @@ -172,7 +172,7 @@ public List> affinityAssignment() { if (buf.remaining() < 8) return false; - topVer = commState.getLong(null); + topVer = commState.getLong("topVer"); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtLockRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtLockRequest.java index a78a6e363cbcc..685f2b932afde 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtLockRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtLockRequest.java @@ -348,13 +348,13 @@ public IgniteUuid miniId() { switch (commState.idx) { case 24: - if (!commState.putBitSet(null, invalidateEntries)) + if (!commState.putBitSet("invalidateEntries", invalidateEntries)) return false; commState.idx++; case 25: - if (!commState.putGridUuid(null, miniId)) + if (!commState.putGridUuid("miniId", miniId)) return false; commState.idx++; @@ -387,31 +387,31 @@ public IgniteUuid miniId() { commState.idx++; case 27: - if (!commState.putByteArray(null, ownedBytes)) + if (!commState.putByteArray("ownedBytes", ownedBytes)) return false; commState.idx++; case 28: - if (!commState.putLong(null, topVer)) + if (!commState.putLong("topVer", topVer)) return false; commState.idx++; case 29: - if (!commState.putUuid(null, subjId)) + if (!commState.putUuid("subjId", subjId)) return false; commState.idx++; case 30: - if (!commState.putInt(null, taskNameHash)) + if (!commState.putInt("taskNameHash", taskNameHash)) return false; commState.idx++; case 31: - if (!commState.putBitSet(null, preloadKeys)) + if (!commState.putBitSet("preloadKeys", preloadKeys)) return false; commState.idx++; @@ -431,7 +431,7 @@ public IgniteUuid miniId() { switch (commState.idx) { case 24: - BitSet invalidateEntries0 = commState.getBitSet(null); + BitSet invalidateEntries0 = commState.getBitSet("invalidateEntries"); if (invalidateEntries0 == BIT_SET_NOT_READ) return false; @@ -441,7 +441,7 @@ public IgniteUuid miniId() { commState.idx++; case 25: - IgniteUuid miniId0 = commState.getGridUuid(null); + IgniteUuid miniId0 = commState.getGridUuid("miniId"); if (miniId0 == GRID_UUID_NOT_READ) return false; @@ -480,7 +480,7 @@ public IgniteUuid miniId() { commState.idx++; case 27: - byte[] ownedBytes0 = commState.getByteArray(null); + byte[] ownedBytes0 = commState.getByteArray("ownedBytes"); if (ownedBytes0 == BYTE_ARR_NOT_READ) return false; @@ -493,12 +493,12 @@ public IgniteUuid miniId() { if (buf.remaining() < 8) return false; - topVer = commState.getLong(null); + topVer = commState.getLong("topVer"); commState.idx++; case 29: - UUID subjId0 = commState.getUuid(null); + UUID subjId0 = commState.getUuid("subjId"); if (subjId0 == UUID_NOT_READ) return false; @@ -511,12 +511,12 @@ public IgniteUuid miniId() { if (buf.remaining() < 4) return false; - taskNameHash = commState.getInt(null); + taskNameHash = commState.getInt("taskNameHash"); commState.idx++; case 31: - BitSet preloadKeys0 = commState.getBitSet(null); + BitSet preloadKeys0 = commState.getBitSet("preloadKeys"); if (preloadKeys0 == BIT_SET_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtLockResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtLockResponse.java index 2563a318b96bc..6c68bdb1b2c0c 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtLockResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtLockResponse.java @@ -257,7 +257,7 @@ public Collection> preloadEntries() { commState.idx++; case 12: - if (!commState.putGridUuid(null, miniId)) + if (!commState.putGridUuid("miniId", miniId)) return false; commState.idx++; @@ -360,7 +360,7 @@ public Collection> preloadEntries() { commState.idx++; case 12: - IgniteUuid miniId0 = commState.getGridUuid(null); + IgniteUuid miniId0 = commState.getGridUuid("miniId"); if (miniId0 == GRID_UUID_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java index 105787f528514..d435b58954bc8 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java @@ -323,19 +323,19 @@ public Collection pendingVersions() { switch (commState.idx) { case 20: - if (!commState.putEnum(null, isolation)) + if (!commState.putEnum("isolation", isolation)) return false; commState.idx++; case 21: - if (!commState.putGridUuid(null, miniId)) + if (!commState.putGridUuid("miniId", miniId)) return false; commState.idx++; case 22: - if (!commState.putUuid(null, nearNodeId)) + if (!commState.putUuid("nearNodeId", nearNodeId)) return false; commState.idx++; @@ -368,7 +368,7 @@ public Collection pendingVersions() { commState.idx++; case 24: - if (!commState.putBoolean(null, onePhaseCommit)) + if (!commState.putBoolean("onePhaseCommit", onePhaseCommit)) return false; commState.idx++; @@ -401,31 +401,31 @@ public Collection pendingVersions() { commState.idx++; case 26: - if (!commState.putBoolean(null, sysInvalidate)) + if (!commState.putBoolean("sysInvalidate", sysInvalidate)) return false; commState.idx++; case 27: - if (!commState.putLong(null, topVer)) + if (!commState.putLong("topVer", topVer)) return false; commState.idx++; case 28: - if (!commState.putCacheVersion(null, writeVer)) + if (!commState.putCacheVersion("writeVer", writeVer)) return false; commState.idx++; case 29: - if (!commState.putUuid(null, subjId)) + if (!commState.putUuid("subjId", subjId)) return false; commState.idx++; case 30: - if (!commState.putInt(null, taskNameHash)) + if (!commState.putInt("taskNameHash", taskNameHash)) return false; commState.idx++; @@ -448,14 +448,14 @@ public Collection pendingVersions() { if (buf.remaining() < 1) return false; - byte isolation0 = commState.getByte(null); + byte isolation0 = commState.getByte("isolation"); isolation = GridCacheTxIsolation.fromOrdinal(isolation0); commState.idx++; case 21: - IgniteUuid miniId0 = commState.getGridUuid(null); + IgniteUuid miniId0 = commState.getGridUuid("miniId"); if (miniId0 == GRID_UUID_NOT_READ) return false; @@ -465,7 +465,7 @@ public Collection pendingVersions() { commState.idx++; case 22: - UUID nearNodeId0 = commState.getUuid(null); + UUID nearNodeId0 = commState.getUuid("nearNodeId"); if (nearNodeId0 == UUID_NOT_READ) return false; @@ -507,7 +507,7 @@ public Collection pendingVersions() { if (buf.remaining() < 1) return false; - onePhaseCommit = commState.getBoolean(null); + onePhaseCommit = commState.getBoolean("onePhaseCommit"); commState.idx++; @@ -544,7 +544,7 @@ public Collection pendingVersions() { if (buf.remaining() < 1) return false; - sysInvalidate = commState.getBoolean(null); + sysInvalidate = commState.getBoolean("sysInvalidate"); commState.idx++; @@ -552,12 +552,12 @@ public Collection pendingVersions() { if (buf.remaining() < 8) return false; - topVer = commState.getLong(null); + topVer = commState.getLong("topVer"); commState.idx++; case 28: - GridCacheVersion writeVer0 = commState.getCacheVersion(null); + GridCacheVersion writeVer0 = commState.getCacheVersion("writeVer"); if (writeVer0 == CACHE_VER_NOT_READ) return false; @@ -567,7 +567,7 @@ public Collection pendingVersions() { commState.idx++; case 29: - UUID subjId0 = commState.getUuid(null); + UUID subjId0 = commState.getUuid("subjId"); if (subjId0 == UUID_NOT_READ) return false; @@ -580,7 +580,7 @@ public Collection pendingVersions() { if (buf.remaining() < 4) return false; - taskNameHash = commState.getInt(null); + taskNameHash = commState.getInt("taskNameHash"); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java index b64e78056e8f6..1215f1e48bc0e 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java @@ -96,7 +96,7 @@ public IgniteUuid miniId() { switch (commState.idx) { case 5: - if (!commState.putGridUuid(null, miniId)) + if (!commState.putGridUuid("miniId", miniId)) return false; commState.idx++; @@ -116,7 +116,7 @@ public IgniteUuid miniId() { switch (commState.idx) { case 5: - IgniteUuid miniId0 = commState.getGridUuid(null); + IgniteUuid miniId0 = commState.getGridUuid("miniId"); if (miniId0 == GRID_UUID_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java index 1455e5dd7b503..51be9d5190098 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java @@ -353,31 +353,31 @@ public Map, GridCacheVersion> owned() { switch (commState.idx) { case 21: - if (!commState.putGridUuid(null, futId)) + if (!commState.putGridUuid("futId", futId)) return false; commState.idx++; case 22: - if (!commState.putBitSet(null, invalidateNearEntries)) + if (!commState.putBitSet("invalidateNearEntries", invalidateNearEntries)) return false; commState.idx++; case 23: - if (!commState.putBoolean(null, last)) + if (!commState.putBoolean("last", last)) return false; commState.idx++; case 24: - if (!commState.putGridUuid(null, miniId)) + if (!commState.putGridUuid("miniId", miniId)) return false; commState.idx++; case 25: - if (!commState.putUuid(null, nearNodeId)) + if (!commState.putUuid("nearNodeId", nearNodeId)) return false; commState.idx++; @@ -410,37 +410,37 @@ public Map, GridCacheVersion> owned() { commState.idx++; case 27: - if (!commState.putCacheVersion(null, nearXidVer)) + if (!commState.putCacheVersion("nearXidVer", nearXidVer)) return false; commState.idx++; case 28: - if (!commState.putByteArray(null, ownedBytes)) + if (!commState.putByteArray("ownedBytes", ownedBytes)) return false; commState.idx++; case 29: - if (!commState.putLong(null, topVer)) + if (!commState.putLong("topVer", topVer)) return false; commState.idx++; case 30: - if (!commState.putUuid(null, subjId)) + if (!commState.putUuid("subjId", subjId)) return false; commState.idx++; case 31: - if (!commState.putInt(null, taskNameHash)) + if (!commState.putInt("taskNameHash", taskNameHash)) return false; commState.idx++; case 32: - if (!commState.putBitSet(null, preloadKeys)) + if (!commState.putBitSet("preloadKeys", preloadKeys)) return false; commState.idx++; @@ -460,7 +460,7 @@ public Map, GridCacheVersion> owned() { switch (commState.idx) { case 21: - IgniteUuid futId0 = commState.getGridUuid(null); + IgniteUuid futId0 = commState.getGridUuid("futId"); if (futId0 == GRID_UUID_NOT_READ) return false; @@ -470,7 +470,7 @@ public Map, GridCacheVersion> owned() { commState.idx++; case 22: - BitSet invalidateNearEntries0 = commState.getBitSet(null); + BitSet invalidateNearEntries0 = commState.getBitSet("invalidateNearEntries"); if (invalidateNearEntries0 == BIT_SET_NOT_READ) return false; @@ -483,12 +483,12 @@ public Map, GridCacheVersion> owned() { if (buf.remaining() < 1) return false; - last = commState.getBoolean(null); + last = commState.getBoolean("last"); commState.idx++; case 24: - IgniteUuid miniId0 = commState.getGridUuid(null); + IgniteUuid miniId0 = commState.getGridUuid("miniId"); if (miniId0 == GRID_UUID_NOT_READ) return false; @@ -498,7 +498,7 @@ public Map, GridCacheVersion> owned() { commState.idx++; case 25: - UUID nearNodeId0 = commState.getUuid(null); + UUID nearNodeId0 = commState.getUuid("nearNodeId"); if (nearNodeId0 == UUID_NOT_READ) return false; @@ -537,7 +537,7 @@ public Map, GridCacheVersion> owned() { commState.idx++; case 27: - GridCacheVersion nearXidVer0 = commState.getCacheVersion(null); + GridCacheVersion nearXidVer0 = commState.getCacheVersion("nearXidVer"); if (nearXidVer0 == CACHE_VER_NOT_READ) return false; @@ -547,7 +547,7 @@ public Map, GridCacheVersion> owned() { commState.idx++; case 28: - byte[] ownedBytes0 = commState.getByteArray(null); + byte[] ownedBytes0 = commState.getByteArray("ownedBytes"); if (ownedBytes0 == BYTE_ARR_NOT_READ) return false; @@ -560,12 +560,12 @@ public Map, GridCacheVersion> owned() { if (buf.remaining() < 8) return false; - topVer = commState.getLong(null); + topVer = commState.getLong("topVer"); commState.idx++; case 30: - UUID subjId0 = commState.getUuid(null); + UUID subjId0 = commState.getUuid("subjId"); if (subjId0 == UUID_NOT_READ) return false; @@ -578,12 +578,12 @@ public Map, GridCacheVersion> owned() { if (buf.remaining() < 4) return false; - taskNameHash = commState.getInt(null); + taskNameHash = commState.getInt("taskNameHash"); commState.idx++; case 32: - BitSet preloadKeys0 = commState.getBitSet(null); + BitSet preloadKeys0 = commState.getBitSet("preloadKeys"); if (preloadKeys0 == BIT_SET_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java index d541b5812b986..33fe66fcbaa09 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java @@ -237,7 +237,7 @@ public void addPreloadEntry(GridCacheEntryInfo info) { switch (commState.idx) { case 10: - if (!commState.putGridUuid(null, futId)) + if (!commState.putGridUuid("futId", futId)) return false; commState.idx++; @@ -270,7 +270,7 @@ public void addPreloadEntry(GridCacheEntryInfo info) { commState.idx++; case 12: - if (!commState.putGridUuid(null, miniId)) + if (!commState.putGridUuid("miniId", miniId)) return false; commState.idx++; @@ -344,7 +344,7 @@ public void addPreloadEntry(GridCacheEntryInfo info) { switch (commState.idx) { case 10: - IgniteUuid futId0 = commState.getGridUuid(null); + IgniteUuid futId0 = commState.getGridUuid("futId"); if (futId0 == GRID_UUID_NOT_READ) return false; @@ -383,7 +383,7 @@ public void addPreloadEntry(GridCacheEntryInfo info) { commState.idx++; case 12: - IgniteUuid miniId0 = commState.getGridUuid(null); + IgniteUuid miniId0 = commState.getGridUuid("miniId"); if (miniId0 == GRID_UUID_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java index 6e084f33056c6..18ba7c4eb4268 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java @@ -652,13 +652,13 @@ public long drExpireTime(int idx) { switch (commState.idx) { case 3: - if (!commState.putLongList(null, drExpireTimes)) + if (!commState.putLongList("drExpireTimes", drExpireTimes)) return false; commState.idx++; case 4: - if (!commState.putLongList(null, drTtls)) + if (!commState.putLongList("drTtls", drTtls)) return false; commState.idx++; @@ -691,7 +691,7 @@ public long drExpireTime(int idx) { commState.idx++; case 6: - if (!commState.putCacheVersion(null, futVer)) + if (!commState.putCacheVersion("futVer", futVer)) return false; commState.idx++; @@ -724,25 +724,25 @@ public long drExpireTime(int idx) { commState.idx++; case 8: - if (!commState.putUuid(null, nodeId)) + if (!commState.putUuid("nodeId", nodeId)) return false; commState.idx++; case 9: - if (!commState.putEnum(null, syncMode)) + if (!commState.putEnum("syncMode", syncMode)) return false; commState.idx++; case 10: - if (!commState.putLong(null, topVer)) + if (!commState.putLong("topVer", topVer)) return false; commState.idx++; case 11: - if (!commState.putLong(null, ttl)) + if (!commState.putLong("ttl", ttl)) return false; commState.idx++; @@ -775,7 +775,7 @@ public long drExpireTime(int idx) { commState.idx++; case 13: - if (!commState.putCacheVersion(null, writeVer)) + if (!commState.putCacheVersion("writeVer", writeVer)) return false; commState.idx++; @@ -835,7 +835,7 @@ public long drExpireTime(int idx) { commState.idx++; case 16: - if (!commState.putBoolean(null, forceTransformBackups)) + if (!commState.putBoolean("forceTransformBackups", forceTransformBackups)) return false; commState.idx++; @@ -895,13 +895,13 @@ public long drExpireTime(int idx) { commState.idx++; case 19: - if (!commState.putUuid(null, subjId)) + if (!commState.putUuid("subjId", subjId)) return false; commState.idx++; case 20: - if (!commState.putInt(null, taskNameHash)) + if (!commState.putInt("taskNameHash", taskNameHash)) return false; commState.idx++; @@ -921,7 +921,7 @@ public long drExpireTime(int idx) { switch (commState.idx) { case 3: - GridLongList drExpireTimes0 = commState.getLongList(null); + GridLongList drExpireTimes0 = commState.getLongList("drExpireTimes"); if (drExpireTimes0 == LONG_LIST_NOT_READ) return false; @@ -931,7 +931,7 @@ public long drExpireTime(int idx) { commState.idx++; case 4: - GridLongList drTtls0 = commState.getLongList(null); + GridLongList drTtls0 = commState.getLongList("drTtls"); if (drTtls0 == LONG_LIST_NOT_READ) return false; @@ -970,7 +970,7 @@ public long drExpireTime(int idx) { commState.idx++; case 6: - GridCacheVersion futVer0 = commState.getCacheVersion(null); + GridCacheVersion futVer0 = commState.getCacheVersion("futVer"); if (futVer0 == CACHE_VER_NOT_READ) return false; @@ -1009,7 +1009,7 @@ public long drExpireTime(int idx) { commState.idx++; case 8: - UUID nodeId0 = commState.getUuid(null); + UUID nodeId0 = commState.getUuid("nodeId"); if (nodeId0 == UUID_NOT_READ) return false; @@ -1022,7 +1022,7 @@ public long drExpireTime(int idx) { if (buf.remaining() < 1) return false; - byte syncMode0 = commState.getByte(null); + byte syncMode0 = commState.getByte("syncMode"); syncMode = GridCacheWriteSynchronizationMode.fromOrdinal(syncMode0); @@ -1032,7 +1032,7 @@ public long drExpireTime(int idx) { if (buf.remaining() < 8) return false; - topVer = commState.getLong(null); + topVer = commState.getLong("topVer"); commState.idx++; @@ -1040,7 +1040,7 @@ public long drExpireTime(int idx) { if (buf.remaining() < 8) return false; - ttl = commState.getLong(null); + ttl = commState.getLong("ttl"); commState.idx++; @@ -1074,7 +1074,7 @@ public long drExpireTime(int idx) { commState.idx++; case 13: - GridCacheVersion writeVer0 = commState.getCacheVersion(null); + GridCacheVersion writeVer0 = commState.getCacheVersion("writeVer"); if (writeVer0 == CACHE_VER_NOT_READ) return false; @@ -1145,7 +1145,7 @@ public long drExpireTime(int idx) { if (buf.remaining() < 1) return false; - forceTransformBackups = commState.getBoolean(null); + forceTransformBackups = commState.getBoolean("forceTransformBackups"); commState.idx++; @@ -1208,7 +1208,7 @@ public long drExpireTime(int idx) { commState.idx++; case 19: - UUID subjId0 = commState.getUuid(null); + UUID subjId0 = commState.getUuid("subjId"); if (subjId0 == UUID_NOT_READ) return false; @@ -1221,7 +1221,7 @@ public long drExpireTime(int idx) { if (buf.remaining() < 4) return false; - taskNameHash = commState.getInt(null); + taskNameHash = commState.getInt("taskNameHash"); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java index 5d3ba598d1361..bc54e2fc280f6 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java @@ -211,19 +211,19 @@ public void addNearEvicted(K key, @Nullable byte[] bytes) { switch (commState.idx) { case 3: - if (!commState.putByteArray(null, errBytes)) + if (!commState.putByteArray("errBytes", errBytes)) return false; commState.idx++; case 4: - if (!commState.putByteArray(null, failedKeysBytes)) + if (!commState.putByteArray("failedKeysBytes", failedKeysBytes)) return false; commState.idx++; case 5: - if (!commState.putCacheVersion(null, futVer)) + if (!commState.putCacheVersion("futVer", futVer)) return false; commState.idx++; @@ -270,7 +270,7 @@ public void addNearEvicted(K key, @Nullable byte[] bytes) { switch (commState.idx) { case 3: - byte[] errBytes0 = commState.getByteArray(null); + byte[] errBytes0 = commState.getByteArray("errBytes"); if (errBytes0 == BYTE_ARR_NOT_READ) return false; @@ -280,7 +280,7 @@ public void addNearEvicted(K key, @Nullable byte[] bytes) { commState.idx++; case 4: - byte[] failedKeysBytes0 = commState.getByteArray(null); + byte[] failedKeysBytes0 = commState.getByteArray("failedKeysBytes"); if (failedKeysBytes0 == BYTE_ARR_NOT_READ) return false; @@ -290,7 +290,7 @@ public void addNearEvicted(K key, @Nullable byte[] bytes) { commState.idx++; case 5: - GridCacheVersion futVer0 = commState.getCacheVersion(null); + GridCacheVersion futVer0 = commState.getCacheVersion("futVer"); if (futVer0 == CACHE_VER_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java index 446a52139e438..353446a838797 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java @@ -553,13 +553,13 @@ public void forceTransformBackups(boolean forceTransformBackups) { switch (commState.idx) { case 3: - if (!commState.putLongList(null, drExpireTimes)) + if (!commState.putLongList("drExpireTimes", drExpireTimes)) return false; commState.idx++; case 4: - if (!commState.putLongList(null, drTtls)) + if (!commState.putLongList("drTtls", drTtls)) return false; commState.idx++; @@ -592,7 +592,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { commState.idx++; case 6: - if (!commState.putBoolean(null, fastMap)) + if (!commState.putBoolean("fastMap", fastMap)) return false; commState.idx++; @@ -625,13 +625,13 @@ public void forceTransformBackups(boolean forceTransformBackups) { commState.idx++; case 8: - if (!commState.putCacheVersion(null, futVer)) + if (!commState.putCacheVersion("futVer", futVer)) return false; commState.idx++; case 9: - if (!commState.putBoolean(null, hasPrimary)) + if (!commState.putBoolean("hasPrimary", hasPrimary)) return false; commState.idx++; @@ -664,37 +664,37 @@ public void forceTransformBackups(boolean forceTransformBackups) { commState.idx++; case 11: - if (!commState.putEnum(null, op)) + if (!commState.putEnum("op", op)) return false; commState.idx++; case 12: - if (!commState.putBoolean(null, retval)) + if (!commState.putBoolean("retval", retval)) return false; commState.idx++; case 13: - if (!commState.putEnum(null, syncMode)) + if (!commState.putEnum("syncMode", syncMode)) return false; commState.idx++; case 14: - if (!commState.putLong(null, topVer)) + if (!commState.putLong("topVer", topVer)) return false; commState.idx++; case 15: - if (!commState.putLong(null, ttl)) + if (!commState.putLong("ttl", ttl)) return false; commState.idx++; case 16: - if (!commState.putCacheVersion(null, updateVer)) + if (!commState.putCacheVersion("updateVer", updateVer)) return false; commState.idx++; @@ -727,19 +727,19 @@ public void forceTransformBackups(boolean forceTransformBackups) { commState.idx++; case 18: - if (!commState.putBoolean(null, forceTransformBackups)) + if (!commState.putBoolean("forceTransformBackups", forceTransformBackups)) return false; commState.idx++; case 19: - if (!commState.putUuid(null, subjId)) + if (!commState.putUuid("subjId", subjId)) return false; commState.idx++; case 20: - if (!commState.putInt(null, taskNameHash)) + if (!commState.putInt("taskNameHash", taskNameHash)) return false; commState.idx++; @@ -759,7 +759,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { switch (commState.idx) { case 3: - GridLongList drExpireTimes0 = commState.getLongList(null); + GridLongList drExpireTimes0 = commState.getLongList("drExpireTimes"); if (drExpireTimes0 == LONG_LIST_NOT_READ) return false; @@ -769,7 +769,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { commState.idx++; case 4: - GridLongList drTtls0 = commState.getLongList(null); + GridLongList drTtls0 = commState.getLongList("drTtls"); if (drTtls0 == LONG_LIST_NOT_READ) return false; @@ -811,7 +811,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { if (buf.remaining() < 1) return false; - fastMap = commState.getBoolean(null); + fastMap = commState.getBoolean("fastMap"); commState.idx++; @@ -845,7 +845,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { commState.idx++; case 8: - GridCacheVersion futVer0 = commState.getCacheVersion(null); + GridCacheVersion futVer0 = commState.getCacheVersion("futVer"); if (futVer0 == CACHE_VER_NOT_READ) return false; @@ -858,7 +858,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { if (buf.remaining() < 1) return false; - hasPrimary = commState.getBoolean(null); + hasPrimary = commState.getBoolean("hasPrimary"); commState.idx++; @@ -895,7 +895,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { if (buf.remaining() < 1) return false; - byte op0 = commState.getByte(null); + byte op0 = commState.getByte("op"); op = GridCacheOperation.fromOrdinal(op0); @@ -905,7 +905,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { if (buf.remaining() < 1) return false; - retval = commState.getBoolean(null); + retval = commState.getBoolean("retval"); commState.idx++; @@ -913,7 +913,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { if (buf.remaining() < 1) return false; - byte syncMode0 = commState.getByte(null); + byte syncMode0 = commState.getByte("syncMode"); syncMode = GridCacheWriteSynchronizationMode.fromOrdinal(syncMode0); @@ -923,7 +923,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { if (buf.remaining() < 8) return false; - topVer = commState.getLong(null); + topVer = commState.getLong("topVer"); commState.idx++; @@ -931,12 +931,12 @@ public void forceTransformBackups(boolean forceTransformBackups) { if (buf.remaining() < 8) return false; - ttl = commState.getLong(null); + ttl = commState.getLong("ttl"); commState.idx++; case 16: - GridCacheVersion updateVer0 = commState.getCacheVersion(null); + GridCacheVersion updateVer0 = commState.getCacheVersion("updateVer"); if (updateVer0 == CACHE_VER_NOT_READ) return false; @@ -978,12 +978,12 @@ public void forceTransformBackups(boolean forceTransformBackups) { if (buf.remaining() < 1) return false; - forceTransformBackups = commState.getBoolean(null); + forceTransformBackups = commState.getBoolean("forceTransformBackups"); commState.idx++; case 19: - UUID subjId0 = commState.getUuid(null); + UUID subjId0 = commState.getUuid("subjId"); if (subjId0 == UUID_NOT_READ) return false; @@ -996,7 +996,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { if (buf.remaining() < 4) return false; - taskNameHash = commState.getInt(null); + taskNameHash = commState.getInt("taskNameHash"); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java index ba683c3f2dddd..363ac8b8a279d 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java @@ -404,31 +404,31 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { switch (commState.idx) { case 3: - if (!commState.putByteArray(null, errBytes)) + if (!commState.putByteArray("errBytes", errBytes)) return false; commState.idx++; case 4: - if (!commState.putByteArray(null, failedKeysBytes)) + if (!commState.putByteArray("failedKeysBytes", failedKeysBytes)) return false; commState.idx++; case 5: - if (!commState.putCacheVersion(null, futVer)) + if (!commState.putCacheVersion("futVer", futVer)) return false; commState.idx++; case 6: - if (!commState.putByteArray(null, remapKeysBytes)) + if (!commState.putByteArray("remapKeysBytes", remapKeysBytes)) return false; commState.idx++; case 7: - if (!commState.putByteArray(null, retValBytes)) + if (!commState.putByteArray("retValBytes", retValBytes)) return false; commState.idx++; @@ -461,7 +461,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { commState.idx++; case 9: - if (!commState.putLong(null, nearTtl)) + if (!commState.putLong("nearTtl", nearTtl)) return false; commState.idx++; @@ -521,7 +521,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { commState.idx++; case 12: - if (!commState.putCacheVersion(null, nearVer)) + if (!commState.putCacheVersion("nearVer", nearVer)) return false; commState.idx++; @@ -541,7 +541,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { switch (commState.idx) { case 3: - byte[] errBytes0 = commState.getByteArray(null); + byte[] errBytes0 = commState.getByteArray("errBytes"); if (errBytes0 == BYTE_ARR_NOT_READ) return false; @@ -551,7 +551,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { commState.idx++; case 4: - byte[] failedKeysBytes0 = commState.getByteArray(null); + byte[] failedKeysBytes0 = commState.getByteArray("failedKeysBytes"); if (failedKeysBytes0 == BYTE_ARR_NOT_READ) return false; @@ -561,7 +561,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { commState.idx++; case 5: - GridCacheVersion futVer0 = commState.getCacheVersion(null); + GridCacheVersion futVer0 = commState.getCacheVersion("futVer"); if (futVer0 == CACHE_VER_NOT_READ) return false; @@ -571,7 +571,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { commState.idx++; case 6: - byte[] remapKeysBytes0 = commState.getByteArray(null); + byte[] remapKeysBytes0 = commState.getByteArray("remapKeysBytes"); if (remapKeysBytes0 == BYTE_ARR_NOT_READ) return false; @@ -581,7 +581,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { commState.idx++; case 7: - byte[] retValBytes0 = commState.getByteArray(null); + byte[] retValBytes0 = commState.getByteArray("retValBytes"); if (retValBytes0 == BYTE_ARR_NOT_READ) return false; @@ -623,7 +623,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { if (buf.remaining() < 8) return false; - nearTtl = commState.getLong(null); + nearTtl = commState.getLong("nearTtl"); commState.idx++; @@ -686,7 +686,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { commState.idx++; case 12: - GridCacheVersion nearVer0 = commState.getCacheVersion(null); + GridCacheVersion nearVer0 = commState.getCacheVersion("nearVer"); if (nearVer0 == CACHE_VER_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java index 30c18cc4904f3..60f91449c9297 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java @@ -193,7 +193,7 @@ private int keyCount() { switch (commState.idx) { case 3: - if (!commState.putGridUuid(null, futId)) + if (!commState.putGridUuid("futId", futId)) return false; commState.idx++; @@ -226,13 +226,13 @@ private int keyCount() { commState.idx++; case 5: - if (!commState.putGridUuid(null, miniId)) + if (!commState.putGridUuid("miniId", miniId)) return false; commState.idx++; case 6: - if (!commState.putLong(null, topVer)) + if (!commState.putLong("topVer", topVer)) return false; commState.idx++; @@ -252,7 +252,7 @@ private int keyCount() { switch (commState.idx) { case 3: - IgniteUuid futId0 = commState.getGridUuid(null); + IgniteUuid futId0 = commState.getGridUuid("futId"); if (futId0 == GRID_UUID_NOT_READ) return false; @@ -291,7 +291,7 @@ private int keyCount() { commState.idx++; case 5: - IgniteUuid miniId0 = commState.getGridUuid(null); + IgniteUuid miniId0 = commState.getGridUuid("miniId"); if (miniId0 == GRID_UUID_NOT_READ) return false; @@ -304,7 +304,7 @@ private int keyCount() { if (buf.remaining() < 8) return false; - topVer = commState.getLong(null); + topVer = commState.getLong("topVer"); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java index e333a956bf57f..bd5693732e4aa 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java @@ -197,19 +197,19 @@ public void addInfo(GridCacheEntryInfo info) { switch (commState.idx) { case 3: - if (!commState.putGridUuid(null, futId)) + if (!commState.putGridUuid("futId", futId)) return false; commState.idx++; case 4: - if (!commState.putByteArray(null, infosBytes)) + if (!commState.putByteArray("infosBytes", infosBytes)) return false; commState.idx++; case 5: - if (!commState.putGridUuid(null, miniId)) + if (!commState.putGridUuid("miniId", miniId)) return false; commState.idx++; @@ -256,7 +256,7 @@ public void addInfo(GridCacheEntryInfo info) { switch (commState.idx) { case 3: - IgniteUuid futId0 = commState.getGridUuid(null); + IgniteUuid futId0 = commState.getGridUuid("futId"); if (futId0 == GRID_UUID_NOT_READ) return false; @@ -266,7 +266,7 @@ public void addInfo(GridCacheEntryInfo info) { commState.idx++; case 4: - byte[] infosBytes0 = commState.getByteArray(null); + byte[] infosBytes0 = commState.getByteArray("infosBytes"); if (infosBytes0 == BYTE_ARR_NOT_READ) return false; @@ -276,7 +276,7 @@ public void addInfo(GridCacheEntryInfo info) { commState.idx++; case 5: - IgniteUuid miniId0 = commState.getGridUuid(null); + IgniteUuid miniId0 = commState.getGridUuid("miniId"); if (miniId0 == GRID_UUID_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java index f77adc5f716f4..bb036cd29d499 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java @@ -250,31 +250,31 @@ void workerId(int workerId) { commState.idx++; case 4: - if (!commState.putLong(null, timeout)) + if (!commState.putLong("timeout", timeout)) return false; commState.idx++; case 5: - if (!commState.putLong(null, topVer)) + if (!commState.putLong("topVer", topVer)) return false; commState.idx++; case 6: - if (!commState.putByteArray(null, topicBytes)) + if (!commState.putByteArray("topicBytes", topicBytes)) return false; commState.idx++; case 7: - if (!commState.putLong(null, updateSeq)) + if (!commState.putLong("updateSeq", updateSeq)) return false; commState.idx++; case 8: - if (!commState.putInt(null, workerId)) + if (!commState.putInt("workerId", workerId)) return false; commState.idx++; @@ -326,7 +326,7 @@ void workerId(int workerId) { if (buf.remaining() < 8) return false; - timeout = commState.getLong(null); + timeout = commState.getLong("timeout"); commState.idx++; @@ -334,12 +334,12 @@ void workerId(int workerId) { if (buf.remaining() < 8) return false; - topVer = commState.getLong(null); + topVer = commState.getLong("topVer"); commState.idx++; case 6: - byte[] topicBytes0 = commState.getByteArray(null); + byte[] topicBytes0 = commState.getByteArray("topicBytes"); if (topicBytes0 == BYTE_ARR_NOT_READ) return false; @@ -352,7 +352,7 @@ void workerId(int workerId) { if (buf.remaining() < 8) return false; - updateSeq = commState.getLong(null); + updateSeq = commState.getLong("updateSeq"); commState.idx++; @@ -360,7 +360,7 @@ void workerId(int workerId) { if (buf.remaining() < 4) return false; - workerId = commState.getInt(null); + workerId = commState.getInt("workerId"); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java index bf3b606efe221..4736f5c747bbc 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java @@ -308,13 +308,13 @@ public int size() { switch (commState.idx) { case 3: - if (!commState.putBoolean(null, ack)) + if (!commState.putBoolean("ack", ack)) return false; commState.idx++; case 4: - if (!commState.putByteArray(null, infoBytes)) + if (!commState.putByteArray("infoBytes", infoBytes)) return false; commState.idx++; @@ -374,13 +374,13 @@ public int size() { commState.idx++; case 7: - if (!commState.putLong(null, updateSeq)) + if (!commState.putLong("updateSeq", updateSeq)) return false; commState.idx++; case 8: - if (!commState.putInt(null, workerId)) + if (!commState.putInt("workerId", workerId)) return false; commState.idx++; @@ -403,12 +403,12 @@ public int size() { if (buf.remaining() < 1) return false; - ack = commState.getBoolean(null); + ack = commState.getBoolean("ack"); commState.idx++; case 4: - byte[] infoBytes0 = commState.getByteArray(null); + byte[] infoBytes0 = commState.getByteArray("infoBytes"); if (infoBytes0 == BYTE_ARR_NOT_READ) return false; @@ -479,7 +479,7 @@ public int size() { if (buf.remaining() < 8) return false; - updateSeq = commState.getLong(null); + updateSeq = commState.getLong("updateSeq"); commState.idx++; @@ -487,7 +487,7 @@ public int size() { if (buf.remaining() < 4) return false; - workerId = commState.getInt(null); + workerId = commState.getInt("workerId"); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsAbstractMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsAbstractMessage.java index e275f1731e12e..6b975e7183b1a 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsAbstractMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsAbstractMessage.java @@ -92,13 +92,13 @@ public GridDhtPartitionExchangeId exchangeId() { switch (commState.idx) { case 3: - if (!commState.putDhtPartitionExchangeId(null, exchId)) + if (!commState.putDhtPartitionExchangeId("exchId", exchId)) return false; commState.idx++; case 4: - if (!commState.putCacheVersion(null, lastVer)) + if (!commState.putCacheVersion("lastVer", lastVer)) return false; commState.idx++; @@ -118,7 +118,7 @@ public GridDhtPartitionExchangeId exchangeId() { switch (commState.idx) { case 3: - GridDhtPartitionExchangeId exchId0 = commState.getDhtPartitionExchangeId(null); + GridDhtPartitionExchangeId exchId0 = commState.getDhtPartitionExchangeId("exchId"); if (exchId0 == DHT_PART_EXCHANGE_ID_NOT_READ) return false; @@ -128,7 +128,7 @@ public GridDhtPartitionExchangeId exchangeId() { commState.idx++; case 4: - GridCacheVersion lastVer0 = commState.getCacheVersion(null); + GridCacheVersion lastVer0 = commState.getCacheVersion("lastVer"); if (lastVer0 == CACHE_VER_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java index d4d4570ee52a9..7ce00845a8ede 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java @@ -173,19 +173,19 @@ public void affinityAssignment(List> affAssignment) { switch (commState.idx) { case 5: - if (!commState.putByteArray(null, affAssignmentBytes)) + if (!commState.putByteArray("affAssignmentBytes", affAssignmentBytes)) return false; commState.idx++; case 6: - if (!commState.putByteArray(null, partsBytes)) + if (!commState.putByteArray("partsBytes", partsBytes)) return false; commState.idx++; case 7: - if (!commState.putLong(null, topVer)) + if (!commState.putLong("topVer", topVer)) return false; commState.idx++; @@ -205,7 +205,7 @@ public void affinityAssignment(List> affAssignment) { switch (commState.idx) { case 5: - byte[] affAssignmentBytes0 = commState.getByteArray(null); + byte[] affAssignmentBytes0 = commState.getByteArray("affAssignmentBytes"); if (affAssignmentBytes0 == BYTE_ARR_NOT_READ) return false; @@ -215,7 +215,7 @@ public void affinityAssignment(List> affAssignment) { commState.idx++; case 6: - byte[] partsBytes0 = commState.getByteArray(null); + byte[] partsBytes0 = commState.getByteArray("partsBytes"); if (partsBytes0 == BYTE_ARR_NOT_READ) return false; @@ -228,7 +228,7 @@ public void affinityAssignment(List> affAssignment) { if (buf.remaining() < 8) return false; - topVer = commState.getLong(null); + topVer = commState.getLong("topVer"); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java index 0671800fad9ab..a2cee94b5990c 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java @@ -122,7 +122,7 @@ public Map partitions() { switch (commState.idx) { case 5: - if (!commState.putByteArray(null, partsBytes)) + if (!commState.putByteArray("partsBytes", partsBytes)) return false; commState.idx++; @@ -142,7 +142,7 @@ public Map partitions() { switch (commState.idx) { case 5: - byte[] partsBytes0 = commState.getByteArray(null); + byte[] partsBytes0 = commState.getByteArray("partsBytes"); if (partsBytes0 == BYTE_ARR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearGetRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearGetRequest.java index 61815b0d6593e..133569af5cac0 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearGetRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearGetRequest.java @@ -285,7 +285,7 @@ public IgnitePredicate>[] filter() { commState.idx++; case 4: - if (!commState.putGridUuid(null, futId)) + if (!commState.putGridUuid("futId", futId)) return false; commState.idx++; @@ -329,37 +329,37 @@ public IgnitePredicate>[] filter() { commState.idx++; case 6: - if (!commState.putGridUuid(null, miniId)) + if (!commState.putGridUuid("miniId", miniId)) return false; commState.idx++; case 7: - if (!commState.putBoolean(null, reload)) + if (!commState.putBoolean("reload", reload)) return false; commState.idx++; case 8: - if (!commState.putLong(null, topVer)) + if (!commState.putLong("topVer", topVer)) return false; commState.idx++; case 9: - if (!commState.putCacheVersion(null, ver)) + if (!commState.putCacheVersion("ver", ver)) return false; commState.idx++; case 10: - if (!commState.putUuid(null, subjId)) + if (!commState.putUuid("subjId", subjId)) return false; commState.idx++; case 11: - if (!commState.putInt(null, taskNameHash)) + if (!commState.putInt("taskNameHash", taskNameHash)) return false; commState.idx++; @@ -408,7 +408,7 @@ public IgnitePredicate>[] filter() { commState.idx++; case 4: - IgniteUuid futId0 = commState.getGridUuid(null); + IgniteUuid futId0 = commState.getGridUuid("futId"); if (futId0 == GRID_UUID_NOT_READ) return false; @@ -460,7 +460,7 @@ public IgnitePredicate>[] filter() { commState.idx++; case 6: - IgniteUuid miniId0 = commState.getGridUuid(null); + IgniteUuid miniId0 = commState.getGridUuid("miniId"); if (miniId0 == GRID_UUID_NOT_READ) return false; @@ -473,7 +473,7 @@ public IgnitePredicate>[] filter() { if (buf.remaining() < 1) return false; - reload = commState.getBoolean(null); + reload = commState.getBoolean("reload"); commState.idx++; @@ -481,12 +481,12 @@ public IgnitePredicate>[] filter() { if (buf.remaining() < 8) return false; - topVer = commState.getLong(null); + topVer = commState.getLong("topVer"); commState.idx++; case 9: - GridCacheVersion ver0 = commState.getCacheVersion(null); + GridCacheVersion ver0 = commState.getCacheVersion("ver"); if (ver0 == CACHE_VER_NOT_READ) return false; @@ -496,7 +496,7 @@ public IgnitePredicate>[] filter() { commState.idx++; case 10: - UUID subjId0 = commState.getUuid(null); + UUID subjId0 = commState.getUuid("subjId"); if (subjId0 == UUID_NOT_READ) return false; @@ -509,7 +509,7 @@ public IgnitePredicate>[] filter() { if (buf.remaining() < 4) return false; - taskNameHash = commState.getInt(null); + taskNameHash = commState.getInt("taskNameHash"); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearGetResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearGetResponse.java index 1eba548208db0..c652c521336dc 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearGetResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearGetResponse.java @@ -234,19 +234,19 @@ public void error(Throwable err) { switch (commState.idx) { case 3: - if (!commState.putByteArray(null, entriesBytes)) + if (!commState.putByteArray("entriesBytes", entriesBytes)) return false; commState.idx++; case 4: - if (!commState.putByteArray(null, errBytes)) + if (!commState.putByteArray("errBytes", errBytes)) return false; commState.idx++; case 5: - if (!commState.putGridUuid(null, futId)) + if (!commState.putGridUuid("futId", futId)) return false; commState.idx++; @@ -279,19 +279,19 @@ public void error(Throwable err) { commState.idx++; case 7: - if (!commState.putGridUuid(null, miniId)) + if (!commState.putGridUuid("miniId", miniId)) return false; commState.idx++; case 8: - if (!commState.putLong(null, topVer)) + if (!commState.putLong("topVer", topVer)) return false; commState.idx++; case 9: - if (!commState.putCacheVersion(null, ver)) + if (!commState.putCacheVersion("ver", ver)) return false; commState.idx++; @@ -311,7 +311,7 @@ public void error(Throwable err) { switch (commState.idx) { case 3: - byte[] entriesBytes0 = commState.getByteArray(null); + byte[] entriesBytes0 = commState.getByteArray("entriesBytes"); if (entriesBytes0 == BYTE_ARR_NOT_READ) return false; @@ -321,7 +321,7 @@ public void error(Throwable err) { commState.idx++; case 4: - byte[] errBytes0 = commState.getByteArray(null); + byte[] errBytes0 = commState.getByteArray("errBytes"); if (errBytes0 == BYTE_ARR_NOT_READ) return false; @@ -331,7 +331,7 @@ public void error(Throwable err) { commState.idx++; case 5: - IgniteUuid futId0 = commState.getGridUuid(null); + IgniteUuid futId0 = commState.getGridUuid("futId"); if (futId0 == GRID_UUID_NOT_READ) return false; @@ -370,7 +370,7 @@ public void error(Throwable err) { commState.idx++; case 7: - IgniteUuid miniId0 = commState.getGridUuid(null); + IgniteUuid miniId0 = commState.getGridUuid("miniId"); if (miniId0 == GRID_UUID_NOT_READ) return false; @@ -383,12 +383,12 @@ public void error(Throwable err) { if (buf.remaining() < 8) return false; - topVer = commState.getLong(null); + topVer = commState.getLong("topVer"); commState.idx++; case 9: - GridCacheVersion ver0 = commState.getCacheVersion(null); + GridCacheVersion ver0 = commState.getCacheVersion("ver"); if (ver0 == CACHE_VER_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearLockRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearLockRequest.java index 6f80471b96a25..68c76df46151a 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearLockRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearLockRequest.java @@ -389,49 +389,49 @@ public GridCacheVersion dhtVersion(int idx) { commState.idx++; case 26: - if (!commState.putBoolean(null, implicitSingleTx)) + if (!commState.putBoolean("implicitSingleTx", implicitSingleTx)) return false; commState.idx++; case 27: - if (!commState.putBoolean(null, implicitTx)) + if (!commState.putBoolean("implicitTx", implicitTx)) return false; commState.idx++; case 28: - if (!commState.putGridUuid(null, miniId)) + if (!commState.putGridUuid("miniId", miniId)) return false; commState.idx++; case 29: - if (!commState.putBoolean(null, onePhaseCommit)) + if (!commState.putBoolean("onePhaseCommit", onePhaseCommit)) return false; commState.idx++; case 30: - if (!commState.putLong(null, topVer)) + if (!commState.putLong("topVer", topVer)) return false; commState.idx++; case 31: - if (!commState.putUuid(null, subjId)) + if (!commState.putUuid("subjId", subjId)) return false; commState.idx++; case 32: - if (!commState.putInt(null, taskNameHash)) + if (!commState.putInt("taskNameHash", taskNameHash)) return false; commState.idx++; case 33: - if (!commState.putBoolean(null, hasTransforms)) + if (!commState.putBoolean("hasTransforms", hasTransforms)) return false; commState.idx++; @@ -512,7 +512,7 @@ public GridCacheVersion dhtVersion(int idx) { if (buf.remaining() < 1) return false; - implicitSingleTx = commState.getBoolean(null); + implicitSingleTx = commState.getBoolean("implicitSingleTx"); commState.idx++; @@ -520,12 +520,12 @@ public GridCacheVersion dhtVersion(int idx) { if (buf.remaining() < 1) return false; - implicitTx = commState.getBoolean(null); + implicitTx = commState.getBoolean("implicitTx"); commState.idx++; case 28: - IgniteUuid miniId0 = commState.getGridUuid(null); + IgniteUuid miniId0 = commState.getGridUuid("miniId"); if (miniId0 == GRID_UUID_NOT_READ) return false; @@ -538,7 +538,7 @@ public GridCacheVersion dhtVersion(int idx) { if (buf.remaining() < 1) return false; - onePhaseCommit = commState.getBoolean(null); + onePhaseCommit = commState.getBoolean("onePhaseCommit"); commState.idx++; @@ -546,12 +546,12 @@ public GridCacheVersion dhtVersion(int idx) { if (buf.remaining() < 8) return false; - topVer = commState.getLong(null); + topVer = commState.getLong("topVer"); commState.idx++; case 31: - UUID subjId0 = commState.getUuid(null); + UUID subjId0 = commState.getUuid("subjId"); if (subjId0 == UUID_NOT_READ) return false; @@ -564,7 +564,7 @@ public GridCacheVersion dhtVersion(int idx) { if (buf.remaining() < 4) return false; - taskNameHash = commState.getInt(null); + taskNameHash = commState.getInt("taskNameHash"); commState.idx++; @@ -572,7 +572,7 @@ public GridCacheVersion dhtVersion(int idx) { if (buf.remaining() < 1) return false; - hasTransforms = commState.getBoolean(null); + hasTransforms = commState.getBoolean("hasTransforms"); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearLockResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearLockResponse.java index f5476fc018ff7..9c0a0b0fcddbd 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearLockResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearLockResponse.java @@ -237,7 +237,7 @@ public void addValueBytes( commState.idx++; case 12: - if (!commState.putBooleanArray(null, filterRes)) + if (!commState.putBooleanArray("filterRes", filterRes)) return false; commState.idx++; @@ -270,7 +270,7 @@ public void addValueBytes( commState.idx++; case 14: - if (!commState.putGridUuid(null, miniId)) + if (!commState.putGridUuid("miniId", miniId)) return false; commState.idx++; @@ -346,7 +346,7 @@ public void addValueBytes( commState.idx++; case 12: - boolean[] filterRes0 = commState.getBooleanArray(null); + boolean[] filterRes0 = commState.getBooleanArray("filterRes"); if (filterRes0 == BOOLEAN_ARR_NOT_READ) return false; @@ -385,7 +385,7 @@ public void addValueBytes( commState.idx++; case 14: - IgniteUuid miniId0 = commState.getGridUuid(null); + IgniteUuid miniId0 = commState.getGridUuid("miniId"); if (miniId0 == GRID_UUID_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxFinishRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxFinishRequest.java index b63b03886b309..41647887ebd34 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxFinishRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxFinishRequest.java @@ -176,31 +176,31 @@ public int taskNameHash() { switch (commState.idx) { case 20: - if (!commState.putBoolean(null, explicitLock)) + if (!commState.putBoolean("explicitLock", explicitLock)) return false; commState.idx++; case 21: - if (!commState.putGridUuid(null, miniId)) + if (!commState.putGridUuid("miniId", miniId)) return false; commState.idx++; case 22: - if (!commState.putLong(null, topVer)) + if (!commState.putLong("topVer", topVer)) return false; commState.idx++; case 23: - if (!commState.putUuid(null, subjId)) + if (!commState.putUuid("subjId", subjId)) return false; commState.idx++; case 24: - if (!commState.putInt(null, taskNameHash)) + if (!commState.putInt("taskNameHash", taskNameHash)) return false; commState.idx++; @@ -223,12 +223,12 @@ public int taskNameHash() { if (buf.remaining() < 1) return false; - explicitLock = commState.getBoolean(null); + explicitLock = commState.getBoolean("explicitLock"); commState.idx++; case 21: - IgniteUuid miniId0 = commState.getGridUuid(null); + IgniteUuid miniId0 = commState.getGridUuid("miniId"); if (miniId0 == GRID_UUID_NOT_READ) return false; @@ -241,12 +241,12 @@ public int taskNameHash() { if (buf.remaining() < 8) return false; - topVer = commState.getLong(null); + topVer = commState.getLong("topVer"); commState.idx++; case 23: - UUID subjId0 = commState.getUuid(null); + UUID subjId0 = commState.getUuid("subjId"); if (subjId0 == UUID_NOT_READ) return false; @@ -259,7 +259,7 @@ public int taskNameHash() { if (buf.remaining() < 4) return false; - taskNameHash = commState.getInt(null); + taskNameHash = commState.getInt("taskNameHash"); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxFinishResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxFinishResponse.java index b09310634a910..93629bf1963db 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxFinishResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxFinishResponse.java @@ -143,19 +143,19 @@ public long threadId() { switch (commState.idx) { case 5: - if (!commState.putByteArray(null, errBytes)) + if (!commState.putByteArray("errBytes", errBytes)) return false; commState.idx++; case 6: - if (!commState.putGridUuid(null, miniId)) + if (!commState.putGridUuid("miniId", miniId)) return false; commState.idx++; case 7: - if (!commState.putLong(null, nearThreadId)) + if (!commState.putLong("nearThreadId", nearThreadId)) return false; commState.idx++; @@ -175,7 +175,7 @@ public long threadId() { switch (commState.idx) { case 5: - byte[] errBytes0 = commState.getByteArray(null); + byte[] errBytes0 = commState.getByteArray("errBytes"); if (errBytes0 == BYTE_ARR_NOT_READ) return false; @@ -185,7 +185,7 @@ public long threadId() { commState.idx++; case 6: - IgniteUuid miniId0 = commState.getGridUuid(null); + IgniteUuid miniId0 = commState.getGridUuid("miniId"); if (miniId0 == GRID_UUID_NOT_READ) return false; @@ -198,7 +198,7 @@ public long threadId() { if (buf.remaining() < 8) return false; - nearThreadId = commState.getLong(null); + nearThreadId = commState.getLong("nearThreadId"); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareRequest.java index 7decc5ebf130a..ab51ff3e8c91f 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareRequest.java @@ -219,6 +219,7 @@ private Collection> cloneEntries(Collection> cloneEntries(Collection> cloneEntries(Collection> cloneEntries(Collection> cloneEntries(Collection> cloneEntries(Collection> cloneEntries(Collection> cloneEntries(Collection> cloneEntries(Collection invalidPartitions() { switch (commState.idx) { case 10: - if (!commState.putCacheVersion(null, dhtVer)) + if (!commState.putCacheVersion("dhtVer", dhtVer)) return false; commState.idx++; case 11: - if (!commState.putGridUuid(null, futId)) + if (!commState.putGridUuid("futId", futId)) return false; commState.idx++; @@ -294,7 +294,7 @@ public Collection invalidPartitions() { commState.idx++; case 13: - if (!commState.putGridUuid(null, miniId)) + if (!commState.putGridUuid("miniId", miniId)) return false; commState.idx++; @@ -368,7 +368,7 @@ public Collection invalidPartitions() { switch (commState.idx) { case 10: - GridCacheVersion dhtVer0 = commState.getCacheVersion(null); + GridCacheVersion dhtVer0 = commState.getCacheVersion("dhtVer"); if (dhtVer0 == CACHE_VER_NOT_READ) return false; @@ -378,7 +378,7 @@ public Collection invalidPartitions() { commState.idx++; case 11: - IgniteUuid futId0 = commState.getGridUuid(null); + IgniteUuid futId0 = commState.getGridUuid("futId"); if (futId0 == GRID_UUID_NOT_READ) return false; @@ -417,7 +417,7 @@ public Collection invalidPartitions() { commState.idx++; case 13: - IgniteUuid miniId0 = commState.getGridUuid(null); + IgniteUuid miniId0 = commState.getGridUuid("miniId"); if (miniId0 == GRID_UUID_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueryRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueryRequest.java index 4318df6b7e6e6..46145131b069b 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueryRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueryRequest.java @@ -494,115 +494,115 @@ public int taskHash() { switch (commState.idx) { case 3: - if (!commState.putBoolean(null, all)) + if (!commState.putBoolean("all", all)) return false; commState.idx++; case 4: - if (!commState.putByteArray(null, argsBytes)) + if (!commState.putByteArray("argsBytes", argsBytes)) return false; commState.idx++; case 5: - if (!commState.putString(null, cacheName)) + if (!commState.putString("cacheName", cacheName)) return false; commState.idx++; case 6: - if (!commState.putBoolean(null, cancel)) + if (!commState.putBoolean("cancel", cancel)) return false; commState.idx++; case 7: - if (!commState.putString(null, clause)) + if (!commState.putString("clause", clause)) return false; commState.idx++; case 8: - if (!commState.putString(null, clsName)) + if (!commState.putString("clsName", clsName)) return false; commState.idx++; case 9: - if (!commState.putBoolean(null, fields)) + if (!commState.putBoolean("fields", fields)) return false; commState.idx++; case 10: - if (!commState.putLong(null, id)) + if (!commState.putLong("id", id)) return false; commState.idx++; case 11: - if (!commState.putBoolean(null, incBackups)) + if (!commState.putBoolean("incBackups", incBackups)) return false; commState.idx++; case 12: - if (!commState.putBoolean(null, incMeta)) + if (!commState.putBoolean("incMeta", incMeta)) return false; commState.idx++; case 13: - if (!commState.putByteArray(null, keyValFilterBytes)) + if (!commState.putByteArray("keyValFilterBytes", keyValFilterBytes)) return false; commState.idx++; case 14: - if (!commState.putInt(null, pageSize)) + if (!commState.putInt("pageSize", pageSize)) return false; commState.idx++; case 15: - if (!commState.putByteArray(null, prjFilterBytes)) + if (!commState.putByteArray("prjFilterBytes", prjFilterBytes)) return false; commState.idx++; case 16: - if (!commState.putByteArray(null, rdcBytes)) + if (!commState.putByteArray("rdcBytes", rdcBytes)) return false; commState.idx++; case 17: - if (!commState.putByteArray(null, transBytes)) + if (!commState.putByteArray("transBytes", transBytes)) return false; commState.idx++; case 18: - if (!commState.putEnum(null, type)) + if (!commState.putEnum("type", type)) return false; commState.idx++; case 19: - if (!commState.putBoolean(null, keepPortable)) + if (!commState.putBoolean("keepPortable", keepPortable)) return false; commState.idx++; case 20: - if (!commState.putUuid(null, subjId)) + if (!commState.putUuid("subjId", subjId)) return false; commState.idx++; case 21: - if (!commState.putInt(null, taskHash)) + if (!commState.putInt("taskHash", taskHash)) return false; commState.idx++; @@ -625,12 +625,12 @@ public int taskHash() { if (buf.remaining() < 1) return false; - all = commState.getBoolean(null); + all = commState.getBoolean("all"); commState.idx++; case 4: - byte[] argsBytes0 = commState.getByteArray(null); + byte[] argsBytes0 = commState.getByteArray("argsBytes"); if (argsBytes0 == BYTE_ARR_NOT_READ) return false; @@ -640,7 +640,7 @@ public int taskHash() { commState.idx++; case 5: - String cacheName0 = commState.getString(null); + String cacheName0 = commState.getString("cacheName"); if (cacheName0 == STR_NOT_READ) return false; @@ -653,12 +653,12 @@ public int taskHash() { if (buf.remaining() < 1) return false; - cancel = commState.getBoolean(null); + cancel = commState.getBoolean("cancel"); commState.idx++; case 7: - String clause0 = commState.getString(null); + String clause0 = commState.getString("clause"); if (clause0 == STR_NOT_READ) return false; @@ -668,7 +668,7 @@ public int taskHash() { commState.idx++; case 8: - String clsName0 = commState.getString(null); + String clsName0 = commState.getString("clsName"); if (clsName0 == STR_NOT_READ) return false; @@ -681,7 +681,7 @@ public int taskHash() { if (buf.remaining() < 1) return false; - fields = commState.getBoolean(null); + fields = commState.getBoolean("fields"); commState.idx++; @@ -689,7 +689,7 @@ public int taskHash() { if (buf.remaining() < 8) return false; - id = commState.getLong(null); + id = commState.getLong("id"); commState.idx++; @@ -697,7 +697,7 @@ public int taskHash() { if (buf.remaining() < 1) return false; - incBackups = commState.getBoolean(null); + incBackups = commState.getBoolean("incBackups"); commState.idx++; @@ -705,12 +705,12 @@ public int taskHash() { if (buf.remaining() < 1) return false; - incMeta = commState.getBoolean(null); + incMeta = commState.getBoolean("incMeta"); commState.idx++; case 13: - byte[] keyValFilterBytes0 = commState.getByteArray(null); + byte[] keyValFilterBytes0 = commState.getByteArray("keyValFilterBytes"); if (keyValFilterBytes0 == BYTE_ARR_NOT_READ) return false; @@ -723,12 +723,12 @@ public int taskHash() { if (buf.remaining() < 4) return false; - pageSize = commState.getInt(null); + pageSize = commState.getInt("pageSize"); commState.idx++; case 15: - byte[] prjFilterBytes0 = commState.getByteArray(null); + byte[] prjFilterBytes0 = commState.getByteArray("prjFilterBytes"); if (prjFilterBytes0 == BYTE_ARR_NOT_READ) return false; @@ -738,7 +738,7 @@ public int taskHash() { commState.idx++; case 16: - byte[] rdcBytes0 = commState.getByteArray(null); + byte[] rdcBytes0 = commState.getByteArray("rdcBytes"); if (rdcBytes0 == BYTE_ARR_NOT_READ) return false; @@ -748,7 +748,7 @@ public int taskHash() { commState.idx++; case 17: - byte[] transBytes0 = commState.getByteArray(null); + byte[] transBytes0 = commState.getByteArray("transBytes"); if (transBytes0 == BYTE_ARR_NOT_READ) return false; @@ -761,7 +761,7 @@ public int taskHash() { if (buf.remaining() < 1) return false; - byte type0 = commState.getByte(null); + byte type0 = commState.getByte("type"); type = GridCacheQueryType.fromOrdinal(type0); @@ -771,12 +771,12 @@ public int taskHash() { if (buf.remaining() < 1) return false; - keepPortable = commState.getBoolean(null); + keepPortable = commState.getBoolean("keepPortable"); commState.idx++; case 20: - UUID subjId0 = commState.getUuid(null); + UUID subjId0 = commState.getUuid("subjId"); if (subjId0 == UUID_NOT_READ) return false; @@ -789,7 +789,7 @@ public int taskHash() { if (buf.remaining() < 4) return false; - taskHash = commState.getInt(null); + taskHash = commState.getInt("taskHash"); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueryResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueryResponse.java index 0254c6d2983ed..825a575fc3908 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueryResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueryResponse.java @@ -264,19 +264,19 @@ public boolean fields() { commState.idx++; case 4: - if (!commState.putByteArray(null, errBytes)) + if (!commState.putByteArray("errBytes", errBytes)) return false; commState.idx++; case 5: - if (!commState.putBoolean(null, fields)) + if (!commState.putBoolean("fields", fields)) return false; commState.idx++; case 6: - if (!commState.putBoolean(null, finished)) + if (!commState.putBoolean("finished", finished)) return false; commState.idx++; @@ -309,7 +309,7 @@ public boolean fields() { commState.idx++; case 8: - if (!commState.putLong(null, reqId)) + if (!commState.putLong("reqId", reqId)) return false; commState.idx++; @@ -358,7 +358,7 @@ public boolean fields() { commState.idx++; case 4: - byte[] errBytes0 = commState.getByteArray(null); + byte[] errBytes0 = commState.getByteArray("errBytes"); if (errBytes0 == BYTE_ARR_NOT_READ) return false; @@ -371,7 +371,7 @@ public boolean fields() { if (buf.remaining() < 1) return false; - fields = commState.getBoolean(null); + fields = commState.getBoolean("fields"); commState.idx++; @@ -379,7 +379,7 @@ public boolean fields() { if (buf.remaining() < 1) return false; - finished = commState.getBoolean(null); + finished = commState.getBoolean("finished"); commState.idx++; @@ -416,7 +416,7 @@ public boolean fields() { if (buf.remaining() < 8) return false; - reqId = commState.getLong(null); + reqId = commState.getLong("reqId"); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/clock/GridClockDeltaSnapshotMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/clock/GridClockDeltaSnapshotMessage.java index f3a61c8a4a165..cca184bbdcdf3 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/clock/GridClockDeltaSnapshotMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/clock/GridClockDeltaSnapshotMessage.java @@ -133,7 +133,7 @@ public Map deltas() { commState.idx++; case 1: - if (!commState.putClockDeltaVersion(null, snapVer)) + if (!commState.putClockDeltaVersion("snapVer", snapVer)) return false; commState.idx++; @@ -159,7 +159,7 @@ public Map deltas() { if (commState.readSize >= 0) { if (deltas == null) - deltas = U.newHashMap(commState.readSize); + deltas = new HashMap<>(commState.readSize, 1.0f); for (int i = commState.readItems; i < commState.readSize; i++) { if (!commState.keyDone) { @@ -192,7 +192,7 @@ public Map deltas() { commState.idx++; case 1: - GridClockDeltaVersion snapVer0 = commState.getClockDeltaVersion(null); + GridClockDeltaVersion snapVer0 = commState.getClockDeltaVersion("snapVer"); if (snapVer0 == CLOCK_DELTA_VER_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/continuous/GridContinuousMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/continuous/GridContinuousMessage.java index e87e972912a2a..6f0ef14243a47 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/continuous/GridContinuousMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/continuous/GridContinuousMessage.java @@ -106,11 +106,11 @@ public void dataBytes(byte[] dataBytes) { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) @Override public GridTcpCommunicationMessageAdapter clone() { - GridContinuousMessage clone = new GridContinuousMessage(); + GridContinuousMessage _clone = new GridContinuousMessage(); - clone0(clone); + clone0(_clone); - return clone; + return _clone; } /** {@inheritDoc} */ @@ -137,19 +137,19 @@ public void dataBytes(byte[] dataBytes) { switch (commState.idx) { case 0: - if (!commState.putByteArray(null, dataBytes)) + if (!commState.putByteArray("dataBytes", dataBytes)) return false; commState.idx++; case 1: - if (!commState.putUuid(null, routineId)) + if (!commState.putUuid("routineId", routineId)) return false; commState.idx++; case 2: - if (!commState.putEnum(null, type)) + if (!commState.putEnum("type", type)) return false; commState.idx++; @@ -166,7 +166,7 @@ public void dataBytes(byte[] dataBytes) { switch (commState.idx) { case 0: - byte[] dataBytes0 = commState.getByteArray(null); + byte[] dataBytes0 = commState.getByteArray("dataBytes"); if (dataBytes0 == BYTE_ARR_NOT_READ) return false; @@ -176,7 +176,7 @@ public void dataBytes(byte[] dataBytes) { commState.idx++; case 1: - UUID routineId0 = commState.getUuid(null); + UUID routineId0 = commState.getUuid("routineId"); if (routineId0 == UUID_NOT_READ) return false; @@ -189,7 +189,7 @@ public void dataBytes(byte[] dataBytes) { if (buf.remaining() < 1) return false; - byte type0 = commState.getByte(null); + byte type0 = commState.getByte("type"); type = GridContinuousMessageType.fromOrdinal(type0); diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/dataload/GridDataLoadRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/dataload/GridDataLoadRequest.java index 781063342396c..d7b815e848883 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/dataload/GridDataLoadRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/dataload/GridDataLoadRequest.java @@ -214,37 +214,37 @@ public boolean forceLocalDeployment() { switch (commState.idx) { case 0: - if (!commState.putString(null, cacheName)) + if (!commState.putString("cacheName", cacheName)) return false; commState.idx++; case 1: - if (!commState.putGridUuid(null, clsLdrId)) + if (!commState.putGridUuid("clsLdrId", clsLdrId)) return false; commState.idx++; case 2: - if (!commState.putByteArray(null, colBytes)) + if (!commState.putByteArray("colBytes", colBytes)) return false; commState.idx++; case 3: - if (!commState.putEnum(null, depMode)) + if (!commState.putEnum("depMode", depMode)) return false; commState.idx++; case 4: - if (!commState.putBoolean(null, forceLocDep)) + if (!commState.putBoolean("forceLocDep", forceLocDep)) return false; commState.idx++; case 5: - if (!commState.putBoolean(null, ignoreDepOwnership)) + if (!commState.putBoolean("ignoreDepOwnership", ignoreDepOwnership)) return false; commState.idx++; @@ -288,31 +288,31 @@ public boolean forceLocalDeployment() { commState.idx++; case 7: - if (!commState.putLong(null, reqId)) + if (!commState.putLong("reqId", reqId)) return false; commState.idx++; case 8: - if (!commState.putByteArray(null, resTopicBytes)) + if (!commState.putByteArray("resTopicBytes", resTopicBytes)) return false; commState.idx++; case 9: - if (!commState.putString(null, sampleClsName)) + if (!commState.putString("sampleClsName", sampleClsName)) return false; commState.idx++; case 10: - if (!commState.putByteArray(null, updaterBytes)) + if (!commState.putByteArray("updaterBytes", updaterBytes)) return false; commState.idx++; case 11: - if (!commState.putString(null, userVer)) + if (!commState.putString("userVer", userVer)) return false; commState.idx++; @@ -328,7 +328,7 @@ public boolean forceLocalDeployment() { switch (commState.idx) { case 0: - String cacheName0 = commState.getString(null); + String cacheName0 = commState.getString("cacheName"); if (cacheName0 == STR_NOT_READ) return false; @@ -338,7 +338,7 @@ public boolean forceLocalDeployment() { commState.idx++; case 1: - IgniteUuid clsLdrId0 = commState.getGridUuid(null); + IgniteUuid clsLdrId0 = commState.getGridUuid("clsLdrId"); if (clsLdrId0 == GRID_UUID_NOT_READ) return false; @@ -348,7 +348,7 @@ public boolean forceLocalDeployment() { commState.idx++; case 2: - byte[] colBytes0 = commState.getByteArray(null); + byte[] colBytes0 = commState.getByteArray("colBytes"); if (colBytes0 == BYTE_ARR_NOT_READ) return false; @@ -361,7 +361,7 @@ public boolean forceLocalDeployment() { if (buf.remaining() < 1) return false; - byte depMode0 = commState.getByte(null); + byte depMode0 = commState.getByte("depMode"); depMode = IgniteDeploymentMode.fromOrdinal(depMode0); @@ -371,7 +371,7 @@ public boolean forceLocalDeployment() { if (buf.remaining() < 1) return false; - forceLocDep = commState.getBoolean(null); + forceLocDep = commState.getBoolean("forceLocDep"); commState.idx++; @@ -379,7 +379,7 @@ public boolean forceLocalDeployment() { if (buf.remaining() < 1) return false; - ignoreDepOwnership = commState.getBoolean(null); + ignoreDepOwnership = commState.getBoolean("ignoreDepOwnership"); commState.idx++; @@ -393,7 +393,7 @@ public boolean forceLocalDeployment() { if (commState.readSize >= 0) { if (ldrParticipants == null) - ldrParticipants = U.newHashMap(commState.readSize); + ldrParticipants = new HashMap<>(commState.readSize, 1.0f); for (int i = commState.readItems; i < commState.readSize; i++) { if (!commState.keyDone) { @@ -429,12 +429,12 @@ public boolean forceLocalDeployment() { if (buf.remaining() < 8) return false; - reqId = commState.getLong(null); + reqId = commState.getLong("reqId"); commState.idx++; case 8: - byte[] resTopicBytes0 = commState.getByteArray(null); + byte[] resTopicBytes0 = commState.getByteArray("resTopicBytes"); if (resTopicBytes0 == BYTE_ARR_NOT_READ) return false; @@ -444,7 +444,7 @@ public boolean forceLocalDeployment() { commState.idx++; case 9: - String sampleClsName0 = commState.getString(null); + String sampleClsName0 = commState.getString("sampleClsName"); if (sampleClsName0 == STR_NOT_READ) return false; @@ -454,7 +454,7 @@ public boolean forceLocalDeployment() { commState.idx++; case 10: - byte[] updaterBytes0 = commState.getByteArray(null); + byte[] updaterBytes0 = commState.getByteArray("updaterBytes"); if (updaterBytes0 == BYTE_ARR_NOT_READ) return false; @@ -464,7 +464,7 @@ public boolean forceLocalDeployment() { commState.idx++; case 11: - String userVer0 = commState.getString(null); + String userVer0 = commState.getString("userVer"); if (userVer0 == STR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/dataload/GridDataLoadResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/dataload/GridDataLoadResponse.java index f726db820e1d7..46bab8511c420 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/dataload/GridDataLoadResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/dataload/GridDataLoadResponse.java @@ -107,19 +107,19 @@ public boolean forceLocalDeployment() { switch (commState.idx) { case 0: - if (!commState.putByteArray(null, errBytes)) + if (!commState.putByteArray("errBytes", errBytes)) return false; commState.idx++; case 1: - if (!commState.putBoolean(null, forceLocDep)) + if (!commState.putBoolean("forceLocDep", forceLocDep)) return false; commState.idx++; case 2: - if (!commState.putLong(null, reqId)) + if (!commState.putLong("reqId", reqId)) return false; commState.idx++; @@ -136,7 +136,7 @@ public boolean forceLocalDeployment() { switch (commState.idx) { case 0: - byte[] errBytes0 = commState.getByteArray(null); + byte[] errBytes0 = commState.getByteArray("errBytes"); if (errBytes0 == BYTE_ARR_NOT_READ) return false; @@ -149,7 +149,7 @@ public boolean forceLocalDeployment() { if (buf.remaining() < 1) return false; - forceLocDep = commState.getBoolean(null); + forceLocDep = commState.getBoolean("forceLocDep"); commState.idx++; @@ -157,7 +157,7 @@ public boolean forceLocalDeployment() { if (buf.remaining() < 8) return false; - reqId = commState.getLong(null); + reqId = commState.getLong("reqId"); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsAckMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsAckMessage.java index f01b397e7bc6e..d3cb730de124e 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsAckMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsAckMessage.java @@ -133,19 +133,19 @@ public IgniteCheckedException error() { switch (commState.idx) { case 0: - if (!commState.putByteArray(null, errBytes)) + if (!commState.putByteArray("errBytes", errBytes)) return false; commState.idx++; case 1: - if (!commState.putGridUuid(null, fileId)) + if (!commState.putGridUuid("fileId", fileId)) return false; commState.idx++; case 2: - if (!commState.putLong(null, id)) + if (!commState.putLong("id", id)) return false; commState.idx++; @@ -165,7 +165,7 @@ public IgniteCheckedException error() { switch (commState.idx) { case 0: - byte[] errBytes0 = commState.getByteArray(null); + byte[] errBytes0 = commState.getByteArray("errBytes"); if (errBytes0 == BYTE_ARR_NOT_READ) return false; @@ -175,7 +175,7 @@ public IgniteCheckedException error() { commState.idx++; case 1: - IgniteUuid fileId0 = commState.getGridUuid(null); + IgniteUuid fileId0 = commState.getGridUuid("fileId"); if (fileId0 == GRID_UUID_NOT_READ) return false; @@ -188,7 +188,7 @@ public IgniteCheckedException error() { if (buf.remaining() < 8) return false; - id = commState.getLong(null); + id = commState.getLong("id"); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsBlockKey.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsBlockKey.java index 563c4585c5ab6..0675e7b9e3092 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsBlockKey.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsBlockKey.java @@ -184,25 +184,25 @@ public long getBlockId() { switch (commState.idx) { case 0: - if (!commState.putGridUuid(null, affKey)) + if (!commState.putGridUuid("affKey", affKey)) return false; commState.idx++; case 1: - if (!commState.putLong(null, blockId)) + if (!commState.putLong("blockId", blockId)) return false; commState.idx++; case 2: - if (!commState.putBoolean(null, evictExclude)) + if (!commState.putBoolean("evictExclude", evictExclude)) return false; commState.idx++; case 3: - if (!commState.putGridUuid(null, fileId)) + if (!commState.putGridUuid("fileId", fileId)) return false; commState.idx++; @@ -219,7 +219,7 @@ public long getBlockId() { switch (commState.idx) { case 0: - IgniteUuid affKey0 = commState.getGridUuid(null); + IgniteUuid affKey0 = commState.getGridUuid("affKey"); if (affKey0 == GRID_UUID_NOT_READ) return false; @@ -232,7 +232,7 @@ public long getBlockId() { if (buf.remaining() < 8) return false; - blockId = commState.getLong(null); + blockId = commState.getLong("blockId"); commState.idx++; @@ -240,12 +240,12 @@ public long getBlockId() { if (buf.remaining() < 1) return false; - evictExclude = commState.getBoolean(null); + evictExclude = commState.getBoolean("evictExclude"); commState.idx++; case 3: - IgniteUuid fileId0 = commState.getGridUuid(null); + IgniteUuid fileId0 = commState.getGridUuid("fileId"); if (fileId0 == GRID_UUID_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsBlocksMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsBlocksMessage.java index 2f9ea6009464b..0b169a76bfcd9 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsBlocksMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsBlocksMessage.java @@ -152,13 +152,13 @@ public Map blocks() { commState.idx++; case 1: - if (!commState.putGridUuid(null, fileId)) + if (!commState.putGridUuid("fileId", fileId)) return false; commState.idx++; case 2: - if (!commState.putLong(null, id)) + if (!commState.putLong("id", id)) return false; commState.idx++; @@ -187,7 +187,7 @@ public Map blocks() { if (commState.readSize >= 0) { if (blocks == null) - blocks = U.newHashMap(commState.readSize); + blocks = new HashMap<>(commState.readSize, 1.0f); for (int i = commState.readItems; i < commState.readSize; i++) { if (!commState.keyDone) { @@ -220,7 +220,7 @@ public Map blocks() { commState.idx++; case 1: - IgniteUuid fileId0 = commState.getGridUuid(null); + IgniteUuid fileId0 = commState.getGridUuid("fileId"); if (fileId0 == GRID_UUID_NOT_READ) return false; @@ -233,7 +233,7 @@ public Map blocks() { if (buf.remaining() < 8) return false; - id = commState.getLong(null); + id = commState.getLong("id"); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsDeleteMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsDeleteMessage.java index c9131323d0048..e2fedec69c97d 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsDeleteMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsDeleteMessage.java @@ -136,13 +136,13 @@ public IgniteCheckedException error() { switch (commState.idx) { case 0: - if (!commState.putByteArray(null, errBytes)) + if (!commState.putByteArray("errBytes", errBytes)) return false; commState.idx++; case 1: - if (!commState.putGridUuid(null, id)) + if (!commState.putGridUuid("id", id)) return false; commState.idx++; @@ -162,7 +162,7 @@ public IgniteCheckedException error() { switch (commState.idx) { case 0: - byte[] errBytes0 = commState.getByteArray(null); + byte[] errBytes0 = commState.getByteArray("errBytes"); if (errBytes0 == BYTE_ARR_NOT_READ) return false; @@ -172,7 +172,7 @@ public IgniteCheckedException error() { commState.idx++; case 1: - IgniteUuid id0 = commState.getGridUuid(null); + IgniteUuid id0 = commState.getGridUuid("id"); if (id0 == GRID_UUID_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsFileAffinityRange.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsFileAffinityRange.java index 46975bb31b690..ce82844b5b65a 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsFileAffinityRange.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsFileAffinityRange.java @@ -289,31 +289,31 @@ public boolean regionEqual(GridGgfsFileAffinityRange other) { switch (commState.idx) { case 0: - if (!commState.putGridUuid(null, affKey)) + if (!commState.putGridUuid("affKey", affKey)) return false; commState.idx++; case 1: - if (!commState.putBoolean(null, done)) + if (!commState.putBoolean("done", done)) return false; commState.idx++; case 2: - if (!commState.putLong(null, endOff)) + if (!commState.putLong("endOff", endOff)) return false; commState.idx++; case 3: - if (!commState.putLong(null, startOff)) + if (!commState.putLong("startOff", startOff)) return false; commState.idx++; case 4: - if (!commState.putInt(null, status)) + if (!commState.putInt("status", status)) return false; commState.idx++; @@ -330,7 +330,7 @@ public boolean regionEqual(GridGgfsFileAffinityRange other) { switch (commState.idx) { case 0: - IgniteUuid affKey0 = commState.getGridUuid(null); + IgniteUuid affKey0 = commState.getGridUuid("affKey"); if (affKey0 == GRID_UUID_NOT_READ) return false; @@ -343,7 +343,7 @@ public boolean regionEqual(GridGgfsFileAffinityRange other) { if (buf.remaining() < 1) return false; - done = commState.getBoolean(null); + done = commState.getBoolean("done"); commState.idx++; @@ -351,7 +351,7 @@ public boolean regionEqual(GridGgfsFileAffinityRange other) { if (buf.remaining() < 8) return false; - endOff = commState.getLong(null); + endOff = commState.getLong("endOff"); commState.idx++; @@ -359,7 +359,7 @@ public boolean regionEqual(GridGgfsFileAffinityRange other) { if (buf.remaining() < 8) return false; - startOff = commState.getLong(null); + startOff = commState.getLong("startOff"); commState.idx++; @@ -367,7 +367,7 @@ public boolean regionEqual(GridGgfsFileAffinityRange other) { if (buf.remaining() < 4) return false; - status = commState.getInt(null); + status = commState.getInt("status"); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsFragmentizerRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsFragmentizerRequest.java index 80b4621579aed..b35991bbe10f0 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsFragmentizerRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsFragmentizerRequest.java @@ -107,7 +107,7 @@ public Collection fragmentRanges() { switch (commState.idx) { case 0: - if (!commState.putGridUuid(null, fileId)) + if (!commState.putGridUuid("fileId", fileId)) return false; commState.idx++; @@ -154,7 +154,7 @@ public Collection fragmentRanges() { switch (commState.idx) { case 0: - IgniteUuid fileId0 = commState.getGridUuid(null); + IgniteUuid fileId0 = commState.getGridUuid("fileId"); if (fileId0 == GRID_UUID_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsFragmentizerResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsFragmentizerResponse.java index 9d71c9c26d117..5ea3ae5552a9d 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsFragmentizerResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsFragmentizerResponse.java @@ -82,7 +82,7 @@ public IgniteUuid fileId() { switch (commState.idx) { case 0: - if (!commState.putGridUuid(null, fileId)) + if (!commState.putGridUuid("fileId", fileId)) return false; commState.idx++; @@ -102,7 +102,7 @@ public IgniteUuid fileId() { switch (commState.idx) { case 0: - IgniteUuid fileId0 = commState.getGridUuid(null); + IgniteUuid fileId0 = commState.getGridUuid("fileId"); if (fileId0 == GRID_UUID_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsSyncMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsSyncMessage.java index 06fbcef791637..4cbec782af219 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsSyncMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsSyncMessage.java @@ -100,13 +100,13 @@ public boolean response() { switch (commState.idx) { case 0: - if (!commState.putLong(null, order)) + if (!commState.putLong("order", order)) return false; commState.idx++; case 1: - if (!commState.putBoolean(null, res)) + if (!commState.putBoolean("res", res)) return false; commState.idx++; @@ -129,7 +129,7 @@ public boolean response() { if (buf.remaining() < 8) return false; - order = commState.getLong(null); + order = commState.getLong("order"); commState.idx++; @@ -137,7 +137,7 @@ public boolean response() { if (buf.remaining() < 1) return false; - res = commState.getBoolean(null); + res = commState.getBoolean("res"); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java index 601428c7fe9cf..df9fd66d8ca6a 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java @@ -62,7 +62,7 @@ public byte[] bytes() { switch (commState.idx) { case 0: - if (!commState.putByteArray(null, bytes)) + if (!commState.putByteArray("bytes", bytes)) return false; commState.idx++; @@ -78,12 +78,12 @@ public byte[] bytes() { switch (commState.idx) { case 0: -// byte[] bytes0 = commState.getByteArray(null, GridClientHandshakeRequest.PACKET_SIZE); -// -// if (bytes0 == BYTE_ARR_NOT_READ) -// return false; -// -// bytes = bytes0; + byte[] bytes0 = commState.getByteArray("bytes"); + + if (bytes0 == BYTE_ARR_NOT_READ) + return false; + + bytes = bytes0; commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java index c77964b300e16..bf3ee7c11bf2f 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java @@ -49,6 +49,15 @@ public GridClientHandshakeResponseWrapper(byte code) { commState.typeWritten = true; } + switch (commState.idx) { + case 0: + if (!commState.putByte("code", code)) + return false; + + commState.idx++; + + } + return true; } @@ -56,6 +65,17 @@ public GridClientHandshakeResponseWrapper(byte code) { @Override public boolean readFrom(ByteBuffer buf) { commState.setBuffer(buf); + switch (commState.idx) { + case 0: + if (buf.remaining() < 1) + return false; + + code = commState.getByte("code"); + + commState.idx++; + + } + return true; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientMessageWrapper.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientMessageWrapper.java index 4779afbd60750..128c657bc7f25 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientMessageWrapper.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientMessageWrapper.java @@ -133,32 +133,32 @@ public void message(ByteBuffer msg) { switch (commState.idx) { case 0: - if (!commState.putInt(null, msgSize)) + if (!commState.putUuid("clientId", clientId)) return false; commState.idx++; case 1: - if (!commState.putLong(null, reqId)) + if (!commState.putUuid("destId", destId)) return false; commState.idx++; case 2: - if (!commState.putUuid(null, clientId)) + if (!commState.putByteBuffer("msg", msg)) return false; commState.idx++; case 3: - if (!commState.putUuid(null, destId)) + if (!commState.putInt("msgSize", msgSize)) return false; commState.idx++; case 4: -// if (!commState.putByteBuffer(null, msg)) -// return false; + if (!commState.putLong("reqId", reqId)) + return false; commState.idx++; @@ -173,53 +173,51 @@ public void message(ByteBuffer msg) { switch (commState.idx) { case 0: - if (buf.remaining() < 4) - return false; + UUID clientId0 = commState.getUuid("clientId"); - msgSize = commState.getInt(null); + if (clientId0 == UUID_NOT_READ) + return false; - if (msgSize == 0) // Ping message. - return true; + clientId = clientId0; commState.idx++; case 1: - if (buf.remaining() < 8) + UUID destId0 = commState.getUuid("destId"); + + if (destId0 == UUID_NOT_READ) return false; - reqId = commState.getLong(null); + destId = destId0; commState.idx++; case 2: - UUID clientId0 = commState.getUuid(null); + ByteBuffer msg0 = commState.getByteBuffer("msg"); - if (clientId0 == UUID_NOT_READ) + if (msg0 == BYTE_BUF_NOT_READ) return false; - clientId = clientId0; + msg = msg0; commState.idx++; case 3: - UUID destId0 = commState.getUuid(null); - - if (destId0 == UUID_NOT_READ) + if (buf.remaining() < 4) return false; - destId = destId0; + msgSize = commState.getInt("msgSize"); commState.idx++; case 4: -// byte[] msg0 = commState.getByteArray(null, msgSize - 40); -// -// if (msg0 == BYTE_ARR_NOT_READ) -// return false; -// -// msg = ByteBuffer.wrap(msg0); -// -// commState.idx++; + if (buf.remaining() < 8) + return false; + + reqId = commState.getLong("reqId"); + + commState.idx++; + } return true; @@ -244,8 +242,8 @@ public void message(ByteBuffer msg) { @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { GridClientMessageWrapper _clone = (GridClientMessageWrapper)_msg; - _clone.reqId = reqId; _clone.msgSize = msgSize; + _clone.reqId = reqId; _clone.clientId = clientId; _clone.destId = destId; _clone.msg = msg; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientPingPacketWrapper.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientPingPacketWrapper.java index b719531aab833..ea1da3dd93a49 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientPingPacketWrapper.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientPingPacketWrapper.java @@ -37,7 +37,7 @@ public class GridClientPingPacketWrapper extends GridTcpCommunicationMessageAdap switch (commState.idx) { case 0: - if (!commState.putInt(null, size)) + if (!commState.putInt("size", size)) return false; commState.idx++; @@ -49,7 +49,20 @@ public class GridClientPingPacketWrapper extends GridTcpCommunicationMessageAdap /** {@inheritDoc} */ @Override public boolean readFrom(ByteBuffer buf) { - throw new UnsupportedOperationException(); + commState.setBuffer(buf); + + switch (commState.idx) { + case 0: + if (buf.remaining() < 4) + return false; + + size = commState.getInt("size"); + + commState.idx++; + + } + + return true; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/handlers/task/GridTaskResultRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/handlers/task/GridTaskResultRequest.java index 2b66ef67f1f48..1894d03bd5400 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/handlers/task/GridTaskResultRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/handlers/task/GridTaskResultRequest.java @@ -123,13 +123,13 @@ public void topic(String topic) { switch (commState.idx) { case 0: - if (!commState.putGridUuid(null, taskId)) + if (!commState.putGridUuid("taskId", taskId)) return false; commState.idx++; case 1: - if (!commState.putByteArray(null, topicBytes)) + if (!commState.putByteArray("topicBytes", topicBytes)) return false; commState.idx++; @@ -146,7 +146,7 @@ public void topic(String topic) { switch (commState.idx) { case 0: - IgniteUuid taskId0 = commState.getGridUuid(null); + IgniteUuid taskId0 = commState.getGridUuid("taskId"); if (taskId0 == GRID_UUID_NOT_READ) return false; @@ -156,7 +156,7 @@ public void topic(String topic) { commState.idx++; case 1: - byte[] topicBytes0 = commState.getByteArray(null); + byte[] topicBytes0 = commState.getByteArray("topicBytes"); if (topicBytes0 == BYTE_ARR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/handlers/task/GridTaskResultResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/handlers/task/GridTaskResultResponse.java index ad9e42f0076d5..6d3043227de0e 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/handlers/task/GridTaskResultResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/handlers/task/GridTaskResultResponse.java @@ -143,25 +143,25 @@ public void error(String err) { switch (commState.idx) { case 0: - if (!commState.putString(null, err)) + if (!commState.putString("err", err)) return false; commState.idx++; case 1: - if (!commState.putBoolean(null, finished)) + if (!commState.putBoolean("finished", finished)) return false; commState.idx++; case 2: - if (!commState.putBoolean(null, found)) + if (!commState.putBoolean("found", found)) return false; commState.idx++; case 3: - if (!commState.putByteArray(null, resBytes)) + if (!commState.putByteArray("resBytes", resBytes)) return false; commState.idx++; @@ -178,7 +178,7 @@ public void error(String err) { switch (commState.idx) { case 0: - String err0 = commState.getString(null); + String err0 = commState.getString("err"); if (err0 == STR_NOT_READ) return false; @@ -191,7 +191,7 @@ public void error(String err) { if (buf.remaining() < 1) return false; - finished = commState.getBoolean(null); + finished = commState.getBoolean("finished"); commState.idx++; @@ -199,12 +199,12 @@ public void error(String err) { if (buf.remaining() < 1) return false; - found = commState.getBoolean(null); + found = commState.getBoolean("found"); commState.idx++; case 3: - byte[] resBytes0 = commState.getByteArray(null); + byte[] resBytes0 = commState.getByteArray("resBytes"); if (resBytes0 == BYTE_ARR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java index 077aa93abd5ad..4aebe5470e126 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java @@ -66,7 +66,7 @@ public GridMemcachedMessageWrapper(GridMemcachedMessage msg, IgniteMarshaller jd switch (commState.idx) { case 0: - if (!commState.putByteArray(null, bytes)) + if (!commState.putByteArray("bytes", bytes)) return false; commState.idx++; @@ -78,7 +78,22 @@ public GridMemcachedMessageWrapper(GridMemcachedMessage msg, IgniteMarshaller jd /** {@inheritDoc} */ @Override public boolean readFrom(ByteBuffer buf) { - throw new UnsupportedOperationException(); + commState.setBuffer(buf); + + switch (commState.idx) { + case 0: + byte[] bytes0 = commState.getByteArray("bytes"); + + if (bytes0 == BYTE_ARR_NOT_READ) + return false; + + bytes = bytes0; + + commState.idx++; + + } + + return true; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/streamer/GridStreamerCancelRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/streamer/GridStreamerCancelRequest.java index cc56dc8adbb4e..358b7a4cfd9e3 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/streamer/GridStreamerCancelRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/streamer/GridStreamerCancelRequest.java @@ -77,7 +77,7 @@ public IgniteUuid cancelledFutureId() { switch (commState.idx) { case 0: - if (!commState.putGridUuid(null, cancelledFutId)) + if (!commState.putGridUuid("cancelledFutId", cancelledFutId)) return false; commState.idx++; @@ -94,7 +94,7 @@ public IgniteUuid cancelledFutureId() { switch (commState.idx) { case 0: - IgniteUuid cancelledFutId0 = commState.getGridUuid(null); + IgniteUuid cancelledFutId0 = commState.getGridUuid("cancelledFutId"); if (cancelledFutId0 == GRID_UUID_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/streamer/GridStreamerExecutionRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/streamer/GridStreamerExecutionRequest.java index 39c8cf2aa99c6..be546c65745c4 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/streamer/GridStreamerExecutionRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/streamer/GridStreamerExecutionRequest.java @@ -178,25 +178,25 @@ public byte[] batchBytes() { switch (commState.idx) { case 0: - if (!commState.putByteArray(null, batchBytes)) + if (!commState.putByteArray("batchBytes", batchBytes)) return false; commState.idx++; case 1: - if (!commState.putGridUuid(null, clsLdrId)) + if (!commState.putGridUuid("clsLdrId", clsLdrId)) return false; commState.idx++; case 2: - if (!commState.putEnum(null, depMode)) + if (!commState.putEnum("depMode", depMode)) return false; commState.idx++; case 3: - if (!commState.putBoolean(null, forceLocDep)) + if (!commState.putBoolean("forceLocDep", forceLocDep)) return false; commState.idx++; @@ -240,13 +240,13 @@ public byte[] batchBytes() { commState.idx++; case 5: - if (!commState.putString(null, sampleClsName)) + if (!commState.putString("sampleClsName", sampleClsName)) return false; commState.idx++; case 6: - if (!commState.putString(null, userVer)) + if (!commState.putString("userVer", userVer)) return false; commState.idx++; @@ -263,7 +263,7 @@ public byte[] batchBytes() { switch (commState.idx) { case 0: - byte[] batchBytes0 = commState.getByteArray(null); + byte[] batchBytes0 = commState.getByteArray("batchBytes"); if (batchBytes0 == BYTE_ARR_NOT_READ) return false; @@ -273,7 +273,7 @@ public byte[] batchBytes() { commState.idx++; case 1: - IgniteUuid clsLdrId0 = commState.getGridUuid(null); + IgniteUuid clsLdrId0 = commState.getGridUuid("clsLdrId"); if (clsLdrId0 == GRID_UUID_NOT_READ) return false; @@ -286,7 +286,7 @@ public byte[] batchBytes() { if (buf.remaining() < 1) return false; - byte depMode0 = commState.getByte(null); + byte depMode0 = commState.getByte("depMode"); depMode = IgniteDeploymentMode.fromOrdinal(depMode0); @@ -296,7 +296,7 @@ public byte[] batchBytes() { if (buf.remaining() < 1) return false; - forceLocDep = commState.getBoolean(null); + forceLocDep = commState.getBoolean("forceLocDep"); commState.idx++; @@ -310,7 +310,7 @@ public byte[] batchBytes() { if (commState.readSize >= 0) { if (ldrParticipants == null) - ldrParticipants = U.newHashMap(commState.readSize); + ldrParticipants = new HashMap<>(commState.readSize, 1.0f); for (int i = commState.readItems; i < commState.readSize; i++) { if (!commState.keyDone) { @@ -343,7 +343,7 @@ public byte[] batchBytes() { commState.idx++; case 5: - String sampleClsName0 = commState.getString(null); + String sampleClsName0 = commState.getString("sampleClsName"); if (sampleClsName0 == STR_NOT_READ) return false; @@ -353,7 +353,7 @@ public byte[] batchBytes() { commState.idx++; case 6: - String userVer0 = commState.getString(null); + String userVer0 = commState.getString("userVer"); if (userVer0 == STR_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/streamer/GridStreamerResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/streamer/GridStreamerResponse.java index fc3cfcbd7e144..bfaeb09244b55 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/streamer/GridStreamerResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/streamer/GridStreamerResponse.java @@ -98,13 +98,13 @@ public byte[] errorBytes() { switch (commState.idx) { case 0: - if (!commState.putByteArray(null, errBytes)) + if (!commState.putByteArray("errBytes", errBytes)) return false; commState.idx++; case 1: - if (!commState.putGridUuid(null, futId)) + if (!commState.putGridUuid("futId", futId)) return false; commState.idx++; @@ -121,7 +121,7 @@ public byte[] errorBytes() { switch (commState.idx) { case 0: - byte[] errBytes0 = commState.getByteArray(null); + byte[] errBytes0 = commState.getByteArray("errBytes"); if (errBytes0 == BYTE_ARR_NOT_READ) return false; @@ -131,7 +131,7 @@ public byte[] errorBytes() { commState.idx++; case 1: - IgniteUuid futId0 = commState.getGridUuid(null); + IgniteUuid futId0 = commState.getGridUuid("futId"); if (futId0 == GRID_UUID_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java index 0a3f856cb1287..1fa6a8d02e6f2 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java +++ b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java @@ -265,6 +265,9 @@ public final boolean putByteArray(String name, @Nullable byte[] arr) { writer.writeByteArray(name, arr); + if (arr == null) + return true; + hdrDone = true; } else @@ -311,6 +314,9 @@ public final boolean putShortArray(String name, short[] arr) { writer.writeShortArray(name, arr); + if (arr == null) + return true; + hdrDone = true; } else @@ -357,6 +363,9 @@ public final boolean putIntArray(String name, int[] arr) { writer.writeIntArray(name, arr); + if (arr == null) + return true; + hdrDone = true; } else @@ -403,6 +412,9 @@ public final boolean putLongArray(String name, long[] arr) { writer.writeLongArray(name, arr); + if (arr == null) + return true; + hdrDone = true; } else @@ -449,6 +461,9 @@ public final boolean putFloatArray(String name, float[] arr) { writer.writeFloatArray(name, arr); + if (arr == null) + return true; + hdrDone = true; } else @@ -495,6 +510,9 @@ public final boolean putDoubleArray(String name, double[] arr) { writer.writeDoubleArray(name, arr); + if (arr == null) + return true; + hdrDone = true; } else @@ -541,6 +559,9 @@ public final boolean putCharArray(String name, char[] arr) { writer.writeCharArray(name, arr); + if (arr == null) + return true; + hdrDone = true; } else @@ -587,6 +608,9 @@ public final boolean putBooleanArray(String name, boolean[] arr) { writer.writeBooleanArray(name, arr); + if (arr == null) + return true; + hdrDone = true; } else @@ -1055,6 +1079,9 @@ public final boolean putMessage(String name, @Nullable GridTcpCommunicationMessa writer.writeObject(name, msg); + if (msg == null) + return true; + hdrDone = true; } else From e9f8b57a15ef12a464a6e4a1ea850b1640d4a84a Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Mon, 22 Dec 2014 17:07:04 -0800 Subject: [PATCH 09/95] Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-ignite into ignite-61 Conflicts: modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxFinishRequest.java modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareRequest.java --- .../dht/GridDhtTxFinishRequest.java | 58 +++++++++---------- .../dht/GridDhtTxPrepareRequest.java | 56 +++++++++--------- .../near/GridNearTxFinishRequest.java | 26 ++++----- .../near/GridNearTxPrepareRequest.java | 40 ++++++------- 4 files changed, 90 insertions(+), 90 deletions(-) diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java index ec091d379f20a..8efd398743155 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java @@ -318,7 +318,7 @@ public Collection pendingVersions() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -326,19 +326,19 @@ public Collection pendingVersions() { switch (commState.idx) { case 21: - if (!commState.putEnum(isolation)) + if (!commState.putEnum(null, isolation)) return false; commState.idx++; case 22: - if (!commState.putGridUuid(miniId)) + if (!commState.putGridUuid(null, miniId)) return false; commState.idx++; case 23: - if (!commState.putUuid(nearNodeId)) + if (!commState.putUuid(null, nearNodeId)) return false; commState.idx++; @@ -346,7 +346,7 @@ public Collection pendingVersions() { case 24: if (nearWritesBytes != null) { if (commState.it == null) { - if (!commState.putInt(nearWritesBytes.size())) + if (!commState.putInt(null, nearWritesBytes.size())) return false; commState.it = nearWritesBytes.iterator(); @@ -356,7 +356,7 @@ public Collection pendingVersions() { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putByteArray((byte[])commState.cur)) + if (!commState.putByteArray(null, (byte[])commState.cur)) return false; commState.cur = NULL; @@ -364,14 +364,14 @@ public Collection pendingVersions() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 25: - if (!commState.putBoolean(onePhaseCommit)) + if (!commState.putBoolean(null, onePhaseCommit)) return false; commState.idx++; @@ -379,7 +379,7 @@ public Collection pendingVersions() { case 26: if (pendingVers != null) { if (commState.it == null) { - if (!commState.putInt(pendingVers.size())) + if (!commState.putInt(null, pendingVers.size())) return false; commState.it = pendingVers.iterator(); @@ -389,7 +389,7 @@ public Collection pendingVersions() { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putCacheVersion((GridCacheVersion)commState.cur)) + if (!commState.putCacheVersion(null, (GridCacheVersion)commState.cur)) return false; commState.cur = NULL; @@ -397,38 +397,38 @@ public Collection pendingVersions() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 27: - if (!commState.putBoolean(sysInvalidate)) + if (!commState.putBoolean(null, sysInvalidate)) return false; commState.idx++; case 28: - if (!commState.putLong(topVer)) + if (!commState.putLong(null, topVer)) return false; commState.idx++; case 29: - if (!commState.putCacheVersion(writeVer)) + if (!commState.putCacheVersion(null, writeVer)) return false; commState.idx++; case 30: - if (!commState.putUuid(subjId)) + if (!commState.putUuid(null, subjId)) return false; commState.idx++; case 31: - if (!commState.putInt(taskNameHash)) + if (!commState.putInt(null, taskNameHash)) return false; commState.idx++; @@ -451,14 +451,14 @@ public Collection pendingVersions() { if (buf.remaining() < 1) return false; - byte isolation0 = commState.getByte(); + byte isolation0 = commState.getByte(null); isolation = IgniteTxIsolation.fromOrdinal(isolation0); commState.idx++; case 22: - IgniteUuid miniId0 = commState.getGridUuid(); + IgniteUuid miniId0 = commState.getGridUuid(null); if (miniId0 == GRID_UUID_NOT_READ) return false; @@ -468,7 +468,7 @@ public Collection pendingVersions() { commState.idx++; case 23: - UUID nearNodeId0 = commState.getUuid(); + UUID nearNodeId0 = commState.getUuid(null); if (nearNodeId0 == UUID_NOT_READ) return false; @@ -482,7 +482,7 @@ public Collection pendingVersions() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -490,7 +490,7 @@ public Collection pendingVersions() { nearWritesBytes = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(); + byte[] _val = commState.getByteArray(null); if (_val == BYTE_ARR_NOT_READ) return false; @@ -510,7 +510,7 @@ public Collection pendingVersions() { if (buf.remaining() < 1) return false; - onePhaseCommit = commState.getBoolean(); + onePhaseCommit = commState.getBoolean(null); commState.idx++; @@ -519,7 +519,7 @@ public Collection pendingVersions() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -527,7 +527,7 @@ public Collection pendingVersions() { pendingVers = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheVersion _val = commState.getCacheVersion(); + GridCacheVersion _val = commState.getCacheVersion(null); if (_val == CACHE_VER_NOT_READ) return false; @@ -547,7 +547,7 @@ public Collection pendingVersions() { if (buf.remaining() < 1) return false; - sysInvalidate = commState.getBoolean(); + sysInvalidate = commState.getBoolean(null); commState.idx++; @@ -555,12 +555,12 @@ public Collection pendingVersions() { if (buf.remaining() < 8) return false; - topVer = commState.getLong(); + topVer = commState.getLong(null); commState.idx++; case 29: - GridCacheVersion writeVer0 = commState.getCacheVersion(); + GridCacheVersion writeVer0 = commState.getCacheVersion(null); if (writeVer0 == CACHE_VER_NOT_READ) return false; @@ -570,7 +570,7 @@ public Collection pendingVersions() { commState.idx++; case 30: - UUID subjId0 = commState.getUuid(); + UUID subjId0 = commState.getUuid(null); if (subjId0 == UUID_NOT_READ) return false; @@ -583,7 +583,7 @@ public Collection pendingVersions() { if (buf.remaining() < 4) return false; - taskNameHash = commState.getInt(); + taskNameHash = commState.getInt(null); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java index ed01977aaf862..4f5b01bd790be 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java @@ -346,7 +346,7 @@ public Map, GridCacheVersion> owned() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -354,31 +354,31 @@ public Map, GridCacheVersion> owned() { switch (commState.idx) { case 22: - if (!commState.putGridUuid(futId)) + if (!commState.putGridUuid(null, futId)) return false; commState.idx++; case 23: - if (!commState.putBitSet(invalidateNearEntries)) + if (!commState.putBitSet(null, invalidateNearEntries)) return false; commState.idx++; case 24: - if (!commState.putBoolean(last)) + if (!commState.putBoolean(null, last)) return false; commState.idx++; case 25: - if (!commState.putGridUuid(miniId)) + if (!commState.putGridUuid(null, miniId)) return false; commState.idx++; case 26: - if (!commState.putUuid(nearNodeId)) + if (!commState.putUuid(null, nearNodeId)) return false; commState.idx++; @@ -386,7 +386,7 @@ public Map, GridCacheVersion> owned() { case 27: if (nearWritesBytes != null) { if (commState.it == null) { - if (!commState.putInt(nearWritesBytes.size())) + if (!commState.putInt(null, nearWritesBytes.size())) return false; commState.it = nearWritesBytes.iterator(); @@ -396,7 +396,7 @@ public Map, GridCacheVersion> owned() { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putByteArray((byte[])commState.cur)) + if (!commState.putByteArray(null, (byte[])commState.cur)) return false; commState.cur = NULL; @@ -404,44 +404,44 @@ public Map, GridCacheVersion> owned() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 28: - if (!commState.putCacheVersion(nearXidVer)) + if (!commState.putCacheVersion(null, nearXidVer)) return false; commState.idx++; case 29: - if (!commState.putByteArray(ownedBytes)) + if (!commState.putByteArray(null, ownedBytes)) return false; commState.idx++; case 30: - if (!commState.putLong(topVer)) + if (!commState.putLong(null, topVer)) return false; commState.idx++; case 31: - if (!commState.putUuid(subjId)) + if (!commState.putUuid(null, subjId)) return false; commState.idx++; case 32: - if (!commState.putInt(taskNameHash)) + if (!commState.putInt(null, taskNameHash)) return false; commState.idx++; case 33: - if (!commState.putBitSet(preloadKeys)) + if (!commState.putBitSet(null, preloadKeys)) return false; commState.idx++; @@ -461,7 +461,7 @@ public Map, GridCacheVersion> owned() { switch (commState.idx) { case 22: - IgniteUuid futId0 = commState.getGridUuid(); + IgniteUuid futId0 = commState.getGridUuid(null); if (futId0 == GRID_UUID_NOT_READ) return false; @@ -471,7 +471,7 @@ public Map, GridCacheVersion> owned() { commState.idx++; case 23: - BitSet invalidateNearEntries0 = commState.getBitSet(); + BitSet invalidateNearEntries0 = commState.getBitSet(null); if (invalidateNearEntries0 == BIT_SET_NOT_READ) return false; @@ -484,12 +484,12 @@ public Map, GridCacheVersion> owned() { if (buf.remaining() < 1) return false; - last = commState.getBoolean(); + last = commState.getBoolean(null); commState.idx++; case 25: - IgniteUuid miniId0 = commState.getGridUuid(); + IgniteUuid miniId0 = commState.getGridUuid(null); if (miniId0 == GRID_UUID_NOT_READ) return false; @@ -499,7 +499,7 @@ public Map, GridCacheVersion> owned() { commState.idx++; case 26: - UUID nearNodeId0 = commState.getUuid(); + UUID nearNodeId0 = commState.getUuid(null); if (nearNodeId0 == UUID_NOT_READ) return false; @@ -513,7 +513,7 @@ public Map, GridCacheVersion> owned() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -521,7 +521,7 @@ public Map, GridCacheVersion> owned() { nearWritesBytes = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(); + byte[] _val = commState.getByteArray(null); if (_val == BYTE_ARR_NOT_READ) return false; @@ -538,7 +538,7 @@ public Map, GridCacheVersion> owned() { commState.idx++; case 28: - GridCacheVersion nearXidVer0 = commState.getCacheVersion(); + GridCacheVersion nearXidVer0 = commState.getCacheVersion(null); if (nearXidVer0 == CACHE_VER_NOT_READ) return false; @@ -548,7 +548,7 @@ public Map, GridCacheVersion> owned() { commState.idx++; case 29: - byte[] ownedBytes0 = commState.getByteArray(); + byte[] ownedBytes0 = commState.getByteArray(null); if (ownedBytes0 == BYTE_ARR_NOT_READ) return false; @@ -561,12 +561,12 @@ public Map, GridCacheVersion> owned() { if (buf.remaining() < 8) return false; - topVer = commState.getLong(); + topVer = commState.getLong(null); commState.idx++; case 31: - UUID subjId0 = commState.getUuid(); + UUID subjId0 = commState.getUuid(null); if (subjId0 == UUID_NOT_READ) return false; @@ -579,12 +579,12 @@ public Map, GridCacheVersion> owned() { if (buf.remaining() < 4) return false; - taskNameHash = commState.getInt(); + taskNameHash = commState.getInt(null); commState.idx++; case 33: - BitSet preloadKeys0 = commState.getBitSet(); + BitSet preloadKeys0 = commState.getBitSet(null); if (preloadKeys0 == BIT_SET_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxFinishRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxFinishRequest.java index b7b274fddcf00..0a58739e2410d 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxFinishRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxFinishRequest.java @@ -185,7 +185,7 @@ public int taskNameHash() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -193,37 +193,37 @@ public int taskNameHash() { switch (commState.idx) { case 21: - if (!commState.putBoolean(explicitLock)) + if (!commState.putBoolean(null, explicitLock)) return false; commState.idx++; case 22: - if (!commState.putGridUuid(miniId)) + if (!commState.putGridUuid(null, miniId)) return false; commState.idx++; case 23: - if (!commState.putLong(topVer)) + if (!commState.putLong(null, topVer)) return false; commState.idx++; case 24: - if (!commState.putUuid(subjId)) + if (!commState.putUuid(null, subjId)) return false; commState.idx++; case 25: - if (!commState.putInt(taskNameHash)) + if (!commState.putInt(null, taskNameHash)) return false; commState.idx++; case 26: - if (!commState.putBoolean(storeEnabled)) + if (!commState.putBoolean(null, storeEnabled)) return false; commState.idx++; @@ -245,12 +245,12 @@ public int taskNameHash() { if (buf.remaining() < 1) return false; - explicitLock = commState.getBoolean(); + explicitLock = commState.getBoolean(null); commState.idx++; case 22: - IgniteUuid miniId0 = commState.getGridUuid(); + IgniteUuid miniId0 = commState.getGridUuid(null); if (miniId0 == GRID_UUID_NOT_READ) return false; @@ -263,12 +263,12 @@ public int taskNameHash() { if (buf.remaining() < 8) return false; - topVer = commState.getLong(); + topVer = commState.getLong(null); commState.idx++; case 24: - UUID subjId0 = commState.getUuid(); + UUID subjId0 = commState.getUuid(null); if (subjId0 == UUID_NOT_READ) return false; @@ -281,7 +281,7 @@ public int taskNameHash() { if (buf.remaining() < 4) return false; - taskNameHash = commState.getInt(); + taskNameHash = commState.getInt(null); commState.idx++; @@ -289,7 +289,7 @@ public int taskNameHash() { if (buf.remaining() < 1) return false; - storeEnabled = commState.getBoolean(); + storeEnabled = commState.getBoolean(null); commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareRequest.java index 46e1b8ae72e94..7eb57a69e4053 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareRequest.java @@ -236,7 +236,7 @@ private Collection> cloneEntries(Collection> cloneEntries(Collection> cloneEntries(Collection> cloneEntries(Collection> cloneEntries(Collection> cloneEntries(Collection> cloneEntries(Collection> cloneEntries(Collection= 0) { @@ -357,7 +357,7 @@ private Collection> cloneEntries(Collection(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - UUID _val = commState.getUuid(); + UUID _val = commState.getUuid(null); if (_val == UUID_NOT_READ) return false; @@ -374,7 +374,7 @@ private Collection> cloneEntries(Collection> cloneEntries(Collection> cloneEntries(Collection> cloneEntries(Collection Date: Mon, 22 Dec 2014 17:33:08 -0800 Subject: [PATCH 10/95] # Fixed compilation --- .../cache/distributed/GridDistributedTxFinishRequest.java | 4 ++-- .../cache/distributed/GridDistributedTxPrepareRequest.java | 4 ++-- .../cache/distributed/near/GridNearLockRequest.java | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxFinishRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxFinishRequest.java index c478b6e778aab..147001cf12718 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxFinishRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxFinishRequest.java @@ -500,7 +500,7 @@ public boolean groupLock() { commState.idx++; case 20: - if (!commState.putBoolean(sys)) + if (!commState.putBoolean("sys", sys)) return false; commState.idx++; @@ -668,7 +668,7 @@ public boolean groupLock() { if (buf.remaining() < 1) return false; - sys = commState.getBoolean(); + sys = commState.getBoolean("sys"); commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxPrepareRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxPrepareRequest.java index 840383a9f3222..1cc7219dd93f7 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxPrepareRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxPrepareRequest.java @@ -567,7 +567,7 @@ private void writeCollection(ObjectOutput out, Collection> c commState.idx++; case 21: - if (!commState.putBoolean(sys)) + if (!commState.putBoolean("sys", sys)) return false; commState.idx++; @@ -747,7 +747,7 @@ private void writeCollection(ObjectOutput out, Collection> c if (buf.remaining() < 1) return false; - sys = commState.getBoolean(); + sys = commState.getBoolean("sys"); commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearLockRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearLockRequest.java index eb4ca88fc7a50..d0086ba0a84b4 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearLockRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearLockRequest.java @@ -452,7 +452,7 @@ public GridCacheVersion dhtVersion(int idx) { commState.idx++; case 34: - if (!commState.putBoolean(syncCommit)) + if (!commState.putBoolean("syncCommit", syncCommit)) return false; commState.idx++; @@ -600,7 +600,7 @@ public GridCacheVersion dhtVersion(int idx) { if (buf.remaining() < 1) return false; - syncCommit = commState.getBoolean(); + syncCommit = commState.getBoolean("syncCommit"); commState.idx++; } From b0297259be3209414899e1f8749fa634a52db5c4 Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Fri, 26 Dec 2014 17:07:06 -0800 Subject: [PATCH 11/95] IGNITE-61 - Portable format in direct marshalling --- .../apache/ignite/plugin/PluginProvider.java | 2 - .../communication/MessageFactory.java} | 6 +- .../communication/MessageReader.java | 58 ++ .../communication/MessageReaderFactory.java | 17 + .../communication/MessageWriter.java | 56 ++ .../communication/MessageWriterFactory.java | 17 + .../apache/ignite/spi/IgniteSpiAdapter.java | 5 +- .../apache/ignite/spi/IgniteSpiContext.java | 4 +- .../org/gridgain/grid/kernal/GridKernal.java | 2 +- .../grid/kernal/GridKernalContext.java | 14 +- .../grid/kernal/GridKernalContextImpl.java | 70 --- .../grid/kernal/GridPluginContext.java | 2 +- .../kernal/managers/GridManagerAdapter.java | 9 +- .../managers/communication/GridIoManager.java | 110 ++++ .../plugin/IgnitePluginProcessor.java | 4 +- ...GridTcpCommunicationByteBufferStream.java} | 315 +++++------ .../GridTcpCommunicationMessageAdapter.java | 105 +--- .../GridTcpCommunicationMessageFactory.java | 2 +- .../GridTcpCommunicationMessageReader.java | 232 ++++++++ .../GridTcpCommunicationMessageState.java | 534 +++--------------- .../GridTcpCommunicationMessageWriter.java | 261 +++++++++ .../GridTcpCommunicationPortableReader.java | 207 ------- .../GridTcpCommunicationPortableWriter.java | 223 -------- .../grid/util/nio/GridDirectParser.java | 3 +- .../testframework/GridSpiTestContext.java | 5 +- 25 files changed, 1010 insertions(+), 1253 deletions(-) rename modules/core/src/main/java/org/{gridgain/grid/util/direct/GridTcpMessageFactory.java => apache/ignite/plugin/extensions/communication/MessageFactory.java} (79%) create mode 100644 modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java create mode 100644 modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReaderFactory.java create mode 100644 modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java create mode 100644 modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriterFactory.java rename modules/core/src/main/java/org/gridgain/grid/util/direct/{GridTcpCommunicationPortableStream.java => GridTcpCommunicationByteBufferStream.java} (67%) create mode 100644 modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageReader.java create mode 100644 modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageWriter.java delete mode 100644 modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationPortableReader.java delete mode 100644 modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationPortableWriter.java diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/PluginProvider.java b/modules/core/src/main/java/org/apache/ignite/plugin/PluginProvider.java index 33280dcbc8080..9a0151161acb9 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/PluginProvider.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/PluginProvider.java @@ -38,8 +38,6 @@ public interface PluginProvider { public T plugin(); /** - * TODO remove. - * * @param cls Ignite component class. * @return Ignite component or {@code null} if component is not supported. */ diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpMessageFactory.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageFactory.java similarity index 79% rename from modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpMessageFactory.java rename to modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageFactory.java index 8767af10a55ca..d8d74f6601ce1 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpMessageFactory.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageFactory.java @@ -7,12 +7,14 @@ * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ */ -package org.gridgain.grid.util.direct; +package org.apache.ignite.plugin.extensions.communication; + +import org.gridgain.grid.util.direct.*; /** * */ -public interface GridTcpMessageFactory { +public interface MessageFactory { /** * @param type Message type. * @return Message instance. diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java new file mode 100644 index 0000000000000..dc2bee8f12b9f --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java @@ -0,0 +1,58 @@ +/* @java.file.header */ + +/* _________ _____ __________________ _____ + * __ ____/___________(_)______ /__ ____/______ ____(_)_______ + * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ + * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / + * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ + */ + +package org.apache.ignite.plugin.extensions.communication; + +import org.apache.ignite.plugin.*; +import org.gridgain.grid.util.direct.*; + +import java.nio.*; + +/** + * TODO + */ +public interface MessageReader extends IgniteExtension { + public void setBuffer(ByteBuffer buf); + + public byte readByte(String name); + + public short readShort(String name); + + public int readInt(String name); + + public long readLong(String name); + + public float readFloat(String name); + + public double readDouble(String name); + + public char readChar(String name); + + public boolean readBoolean(String name); + + public byte[] readByteArray(String name); + + public short[] readShortArray(String name); + + public int[] readIntArray(String name); + + public long[] readLongArray(String name); + + public float[] readFloatArray(String name); + + public double[] readDoubleArray(String name); + + public char[] readCharArray(String name); + + public boolean[] readBooleanArray(String name); + + public GridTcpCommunicationMessageAdapter readMessage(String name); + + public boolean isLastRead(); +} diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReaderFactory.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReaderFactory.java new file mode 100644 index 0000000000000..51e51a95aba50 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReaderFactory.java @@ -0,0 +1,17 @@ +/* @java.file.header */ + +/* _________ _____ __________________ _____ + * __ ____/___________(_)______ /__ ____/______ ____(_)_______ + * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ + * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / + * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ + */ + +package org.apache.ignite.plugin.extensions.communication; + +/** + * TODO + */ +public interface MessageReaderFactory { + public MessageReader reader(); +} diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java new file mode 100644 index 0000000000000..ce0b24973fee5 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java @@ -0,0 +1,56 @@ +/* @java.file.header */ + +/* _________ _____ __________________ _____ + * __ ____/___________(_)______ /__ ____/______ ____(_)_______ + * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ + * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / + * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ + */ + +package org.apache.ignite.plugin.extensions.communication; + +import org.apache.ignite.plugin.*; +import org.gridgain.grid.util.direct.*; + +import java.nio.*; + +/** + * TODO + */ +public interface MessageWriter extends IgniteExtension { + public void setBuffer(ByteBuffer buf); + + public boolean writeByte(String name, byte val); + + public boolean writeShort(String name, short val); + + public boolean writeInt(String name, int val); + + public boolean writeLong(String name, long val); + + public boolean writeFloat(String name, float val); + + public boolean writeDouble(String name, double val); + + public boolean writeChar(String name, char val); + + public boolean writeBoolean(String name, boolean val); + + public boolean writeByteArray(String name, byte[] val); + + public boolean writeShortArray(String name, short[] val); + + public boolean writeIntArray(String name, int[] val); + + public boolean writeLongArray(String name, long[] val); + + public boolean writeFloatArray(String name, float[] val); + + public boolean writeDoubleArray(String name, double[] val); + + public boolean writeCharArray(String name, char[] val); + + public boolean writeBooleanArray(String name, boolean[] val); + + public boolean writeMessage(String name, GridTcpCommunicationMessageAdapter val); +} diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriterFactory.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriterFactory.java new file mode 100644 index 0000000000000..613f312a034cb --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriterFactory.java @@ -0,0 +1,17 @@ +/* @java.file.header */ + +/* _________ _____ __________________ _____ + * __ ____/___________(_)______ /__ ____/______ ____(_)_______ + * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ + * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / + * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ + */ + +package org.apache.ignite.plugin.extensions.communication; + +/** + * TODO + */ +public interface MessageWriterFactory { + public MessageWriter writer(); +} diff --git a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java index 508e81ed483ea..8c9354f16e2e3 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java @@ -12,16 +12,15 @@ import org.apache.ignite.*; import org.apache.ignite.cluster.*; import org.apache.ignite.events.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.resources.*; import org.apache.ignite.spi.authentication.*; -import org.gridgain.grid.*; import org.gridgain.grid.kernal.*; import org.gridgain.grid.kernal.managers.communication.*; import org.gridgain.grid.kernal.managers.eventstorage.*; import org.apache.ignite.plugin.security.*; import org.apache.ignite.spi.securesession.*; import org.apache.ignite.spi.swapspace.*; -import org.gridgain.grid.util.direct.*; import org.gridgain.grid.util.typedef.*; import org.gridgain.grid.util.typedef.internal.*; import org.jetbrains.annotations.*; @@ -725,7 +724,7 @@ public ClusterNode node(UUID nodeId) { } /** {@inheritDoc} */ - @Override public GridTcpMessageFactory messageFactory() { + @Override public MessageFactory messageFactory() { return null; } } diff --git a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiContext.java b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiContext.java index 69ba6fd6d7ae1..e4c239a56dc52 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiContext.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiContext.java @@ -12,11 +12,11 @@ import org.apache.ignite.*; import org.apache.ignite.cluster.*; import org.apache.ignite.events.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.plugin.security.*; import org.apache.ignite.spi.swapspace.*; import org.gridgain.grid.kernal.managers.communication.*; import org.gridgain.grid.kernal.managers.eventstorage.*; -import org.gridgain.grid.util.direct.*; import org.jetbrains.annotations.*; import java.io.*; @@ -391,5 +391,5 @@ public boolean removeFromOffheap(@Nullable String spaceName, int part, Object ke /** * @return Message factory. */ - public GridTcpMessageFactory messageFactory(); + public MessageFactory messageFactory(); } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/GridKernal.java b/modules/core/src/main/java/org/gridgain/grid/kernal/GridKernal.java index 535935339fb4b..04f52ca20556a 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/GridKernal.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/GridKernal.java @@ -752,7 +752,7 @@ public void start(final IgniteConfiguration cfg, ExecutorService utilityCachePoo provider.start(ctx.plugins().pluginContextForProvider(provider), attrs); } - ctx.createMessageFactory(); + ctx.io().initMessageFactory(); if (ctx.isEnterprise()) { security = new GridSecurityImpl(ctx); diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/GridKernalContext.java b/modules/core/src/main/java/org/gridgain/grid/kernal/GridKernalContext.java index e1b9d9250ac7a..03cf112ccaeb4 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/GridKernalContext.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/GridKernalContext.java @@ -14,7 +14,6 @@ import org.apache.ignite.plugin.*; import org.apache.ignite.product.*; import org.gridgain.grid.*; -import org.gridgain.grid.kernal.managers.security.*; import org.gridgain.grid.kernal.managers.checkpoint.*; import org.gridgain.grid.kernal.managers.collision.*; import org.gridgain.grid.kernal.managers.communication.*; @@ -25,6 +24,7 @@ import org.gridgain.grid.kernal.managers.indexing.*; import org.gridgain.grid.kernal.managers.loadbalancer.*; import org.gridgain.grid.kernal.managers.securesession.*; +import org.gridgain.grid.kernal.managers.security.*; import org.gridgain.grid.kernal.managers.swapspace.*; import org.gridgain.grid.kernal.processors.affinity.*; import org.gridgain.grid.kernal.processors.cache.*; @@ -53,7 +53,6 @@ import org.gridgain.grid.kernal.processors.streamer.*; import org.gridgain.grid.kernal.processors.task.*; import org.gridgain.grid.kernal.processors.timeout.*; -import org.gridgain.grid.util.direct.*; import org.gridgain.grid.util.tostring.*; import java.util.*; @@ -494,15 +493,4 @@ public interface GridKernalContext extends GridMetadataAware, Iterable T createComponent(Class cls); - - /** - * @return Message factory. - */ - public GridTcpMessageFactory messageFactory(); - - /** - * @param producer Message producer. - * @return Message type code. - */ - public byte registerMessageProducer(GridTcpCommunicationMessageProducer producer); } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/GridKernalContextImpl.java b/modules/core/src/main/java/org/gridgain/grid/kernal/GridKernalContextImpl.java index b6f4ac8858545..5ed40bdd5fdac 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/GridKernalContextImpl.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/GridKernalContextImpl.java @@ -13,7 +13,6 @@ import org.apache.ignite.configuration.*; import org.apache.ignite.plugin.*; import org.apache.ignite.product.*; -import org.gridgain.grid.*; import org.gridgain.grid.kernal.managers.checkpoint.*; import org.gridgain.grid.kernal.managers.collision.*; import org.gridgain.grid.kernal.managers.communication.*; @@ -56,7 +55,6 @@ import org.gridgain.grid.kernal.processors.streamer.*; import org.gridgain.grid.kernal.processors.task.*; import org.gridgain.grid.kernal.processors.timeout.*; -import org.gridgain.grid.util.direct.*; import org.gridgain.grid.util.lang.*; import org.gridgain.grid.util.tostring.*; import org.gridgain.grid.util.typedef.*; @@ -287,15 +285,6 @@ public class GridKernalContextImpl extends GridMetadataAwareAdapter implements G /** Enterprise release flag. */ private boolean ent; - /** */ - private GridTcpMessageFactory msgFactory; - - /** */ - private int pluginMsg = GridTcpCommunicationMessageFactory.MAX_COMMON_TYPE; - - /** */ - private Map pluginMsgs; - /** * No-arg constructor is required by externalization. */ @@ -799,65 +788,6 @@ public void timeSource(GridClockSource clockSrc) { throw new IgniteException("Unsupported component type: " + cls); } - /** {@inheritDoc} */ - @Override public GridTcpMessageFactory messageFactory() { - assert msgFactory != null; - - return msgFactory; - } - - /** {@inheritDoc} */ - @Override public byte registerMessageProducer(GridTcpCommunicationMessageProducer producer) { - int nextMsg = ++pluginMsg; - - if (nextMsg > Byte.MAX_VALUE) - throw new IgniteException(); - - if (pluginMsgs == null) - pluginMsgs = new HashMap<>(); - - pluginMsgs.put((byte)nextMsg, producer); - - return (byte)nextMsg; - } - - /** - * Creates message factory. - */ - void createMessageFactory() { - final GridTcpCommunicationMessageProducer[] common = GridTcpCommunicationMessageFactory.commonProducers(); - - final GridTcpCommunicationMessageProducer[] producers; - - if (pluginMsgs != null) { - producers = Arrays.copyOf(common, pluginMsg + 1); - - for (Map.Entry e : pluginMsgs.entrySet()) { - assert producers[e.getKey()] == null : e.getKey(); - - producers[e.getKey()] = e.getValue(); - } - - pluginMsgs = null; - } - else - producers = common; - - msgFactory = new GridTcpMessageFactory() { - @Override public GridTcpCommunicationMessageAdapter create(byte type) { - if (type < 0 || type >= producers.length) - return GridTcpCommunicationMessageFactory.create(type); - - GridTcpCommunicationMessageProducer producer = producers[type]; - - if (producer != null) - return producer.create(type); - else - throw new IllegalStateException("Common message type producer is not registered: " + type); - } - }; - } - /** * @return Plugin manager. */ diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/GridPluginContext.java b/modules/core/src/main/java/org/gridgain/grid/kernal/GridPluginContext.java index 19d875cc6aa53..01d0397a1833f 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/GridPluginContext.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/GridPluginContext.java @@ -88,6 +88,6 @@ public GridPluginContext(GridKernalContext ctx, PluginConfiguration cfg, IgniteC /** {@inheritDoc} */ @Override public byte registerMessageProducer(GridTcpCommunicationMessageProducer producer) { - return ctx.registerMessageProducer(producer); + return ctx.io().registerMessageProducer(producer); } } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/GridManagerAdapter.java b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/GridManagerAdapter.java index 8a8bc0eceef8d..b8b6a7584e8d0 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/GridManagerAdapter.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/GridManagerAdapter.java @@ -14,15 +14,14 @@ import org.apache.ignite.events.*; import org.apache.ignite.lang.*; import org.apache.ignite.plugin.extensions.communication.*; +import org.apache.ignite.plugin.security.*; import org.apache.ignite.spi.*; -import org.gridgain.grid.*; +import org.apache.ignite.spi.swapspace.*; import org.gridgain.grid.cache.*; import org.gridgain.grid.kernal.*; import org.gridgain.grid.kernal.managers.communication.*; import org.gridgain.grid.kernal.managers.eventstorage.*; import org.gridgain.grid.kernal.processors.cache.*; -import org.apache.ignite.plugin.security.*; -import org.apache.ignite.spi.swapspace.*; import org.gridgain.grid.util.direct.*; import org.gridgain.grid.util.tostring.*; import org.gridgain.grid.util.typedef.*; @@ -503,8 +502,8 @@ protected final String stopInfo() { return e != null ? (V)e.value() : null; } - @Override public GridTcpMessageFactory messageFactory() { - return ctx.messageFactory(); + @Override public MessageFactory messageFactory() { + return ctx.io().messageFactory(); } /** diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/communication/GridIoManager.java index 52cd53d400542..7c11a92609119 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/communication/GridIoManager.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/communication/GridIoManager.java @@ -14,6 +14,7 @@ import org.apache.ignite.events.*; import org.apache.ignite.lang.*; import org.apache.ignite.marshaller.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.spi.*; import org.apache.ignite.spi.communication.*; import org.gridgain.grid.*; @@ -136,6 +137,21 @@ public class GridIoManager extends GridManagerAdapter pluginMsgs; + + /** */ + private MessageFactory msgFactory; + + /** */ + private MessageWriterFactory writerFactory; + + /** */ + private MessageReaderFactory readerFactory; + /** * @param ctx Grid kernal context. */ @@ -150,6 +166,74 @@ public GridIoManager(GridKernalContext ctx) { marsh = ctx.config().getMarshaller(); } + /** + * @param producer Message producer. + * @return Message type code. + */ + public byte registerMessageProducer(GridTcpCommunicationMessageProducer producer) { + int nextMsg = ++pluginMsg; + + if (nextMsg > Byte.MAX_VALUE) + throw new IgniteException(); + + if (pluginMsgs == null) + pluginMsgs = new HashMap<>(); + + pluginMsgs.put((byte)nextMsg, producer); + + return (byte)nextMsg; + } + + /** + * Initializes manager (called prior to discovery start, but after all other components). + */ + public void initMessageFactory() { + final GridTcpCommunicationMessageProducer[] common = GridTcpCommunicationMessageFactory.commonProducers(); + + final GridTcpCommunicationMessageProducer[] producers; + + if (pluginMsgs != null) { + producers = Arrays.copyOf(common, pluginMsg + 1); + + for (Map.Entry e : pluginMsgs.entrySet()) { + assert producers[e.getKey()] == null : e.getKey(); + + producers[e.getKey()] = e.getValue(); + } + + pluginMsgs = null; + } + else + producers = common; + + msgFactory = new MessageFactory() { + @Override public GridTcpCommunicationMessageAdapter create(byte type) { + GridTcpCommunicationMessageAdapter msg; + + if (type < 0 || type >= producers.length) + msg = GridTcpCommunicationMessageFactory.create(type); + else { + GridTcpCommunicationMessageProducer producer = producers[type]; + + if (producer == null) + throw new IllegalStateException("Common message type producer is not registered: " + type); + + msg = producer.create(type); + } + + msg.setReader(readerFactory.reader()); + + return msg; + } + }; + } + + public MessageFactory messageFactory() { + assert msgFactory != null; + + return msgFactory; + } + /** * Resets metrics for this manager. */ @@ -189,6 +273,30 @@ public void resetMetrics() { } }); + MessageWriterFactory[] writerExt = ctx.plugins().extensions(MessageWriterFactory.class); + + if (writerExt != null && writerExt.length > 0) + writerFactory = writerExt[0]; + else { + writerFactory = new MessageWriterFactory() { + @Override public MessageWriter writer() { + return new GridTcpCommunicationMessageWriter(); + } + }; + } + + MessageReaderFactory[] readerExt = ctx.plugins().extensions(MessageReaderFactory.class); + + if (readerExt != null && readerExt.length > 0) + readerFactory = readerExt[0]; + else { + readerFactory = new MessageReaderFactory() { + @Override public MessageReader reader() { + return new GridTcpCommunicationMessageReader(msgFactory); + } + }; + } + if (log.isDebugEnabled()) log.debug(startInfo()); } @@ -892,6 +1000,8 @@ private void send(ClusterNode node, Object topic, int topicOrd, GridTcpCommunica processRegularMessage0(ioMsg, locNodeId); } else { + ioMsg.setWriter(writerFactory.writer()); + if (topicOrd < 0) ioMsg.topicBytes(marsh.marshal(topic)); diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/plugin/IgnitePluginProcessor.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/plugin/IgnitePluginProcessor.java index 4c74423e37560..7bc4f40209846 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/plugin/IgnitePluginProcessor.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/plugin/IgnitePluginProcessor.java @@ -55,14 +55,14 @@ public IgnitePluginProcessor(GridKernalContext ctx, IgniteConfiguration cfg) { throw new IgniteException("Provider class is null."); try { - Constructor ctr = + Constructor ctr = pluginCfg.providerClass().getConstructor(PluginContext.class); provider = ctr.newInstance(pluginCtx); } catch (NoSuchMethodException ignore) { try { - Constructor ctr = + Constructor ctr = pluginCfg.providerClass().getConstructor(pluginCfg.getClass()); provider = ctr.newInstance(pluginCfg); diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationPortableStream.java b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationByteBufferStream.java similarity index 67% rename from modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationPortableStream.java rename to modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationByteBufferStream.java index 3ec27df7b6eb6..0de1ea3e2e392 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationPortableStream.java +++ b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationByteBufferStream.java @@ -9,19 +9,18 @@ package org.gridgain.grid.util.direct; -import org.gridgain.grid.kernal.processors.portable.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.gridgain.grid.util.*; +import org.jetbrains.annotations.*; import sun.misc.*; import sun.nio.ch.*; import java.nio.*; -import static org.gridgain.grid.util.direct.GridTcpCommunicationMessageAdapter.*; - /** * Portable stream based on {@link ByteBuffer}. */ -public class GridTcpCommunicationPortableStream implements GridPortableOutputStream, GridPortableInputStream { +public class GridTcpCommunicationByteBufferStream { /** */ private static final Unsafe UNSAFE = GridUnsafe.unsafe(); @@ -76,10 +75,9 @@ public class GridTcpCommunicationPortableStream implements GridPortableOutputStr /** */ private static final ArrayCreator BYTE_ARR_CREATOR = new ArrayCreator() { @Override public byte[] create(int len) { - switch (len) { - case -1: - return BYTE_ARR_NOT_READ; + assert len >= 0; + switch (len) { case 0: return BYTE_ARR_EMPTY; @@ -92,10 +90,9 @@ public class GridTcpCommunicationPortableStream implements GridPortableOutputStr /** */ private static final ArrayCreator SHORT_ARR_CREATOR = new ArrayCreator() { @Override public short[] create(int len) { - switch (len) { - case -1: - return SHORT_ARR_NOT_READ; + assert len >= 0; + switch (len) { case 0: return SHORT_ARR_EMPTY; @@ -108,10 +105,9 @@ public class GridTcpCommunicationPortableStream implements GridPortableOutputStr /** */ private static final ArrayCreator INT_ARR_CREATOR = new ArrayCreator() { @Override public int[] create(int len) { - switch (len) { - case -1: - return INT_ARR_NOT_READ; + assert len >= 0; + switch (len) { case 0: return INT_ARR_EMPTY; @@ -124,10 +120,9 @@ public class GridTcpCommunicationPortableStream implements GridPortableOutputStr /** */ private static final ArrayCreator LONG_ARR_CREATOR = new ArrayCreator() { @Override public long[] create(int len) { - switch (len) { - case -1: - return LONG_ARR_NOT_READ; + assert len >= 0; + switch (len) { case 0: return LONG_ARR_EMPTY; @@ -140,10 +135,9 @@ public class GridTcpCommunicationPortableStream implements GridPortableOutputStr /** */ private static final ArrayCreator FLOAT_ARR_CREATOR = new ArrayCreator() { @Override public float[] create(int len) { - switch (len) { - case -1: - return FLOAT_ARR_NOT_READ; + assert len >= 0; + switch (len) { case 0: return FLOAT_ARR_EMPTY; @@ -156,10 +150,9 @@ public class GridTcpCommunicationPortableStream implements GridPortableOutputStr /** */ private static final ArrayCreator DOUBLE_ARR_CREATOR = new ArrayCreator() { @Override public double[] create(int len) { - switch (len) { - case -1: - return DOUBLE_ARR_NOT_READ; + assert len >= 0; + switch (len) { case 0: return DOUBLE_ARR_EMPTY; @@ -172,10 +165,9 @@ public class GridTcpCommunicationPortableStream implements GridPortableOutputStr /** */ private static final ArrayCreator CHAR_ARR_CREATOR = new ArrayCreator() { @Override public char[] create(int len) { - switch (len) { - case -1: - return CHAR_ARR_NOT_READ; + assert len >= 0; + switch (len) { case 0: return CHAR_ARR_EMPTY; @@ -188,10 +180,9 @@ public class GridTcpCommunicationPortableStream implements GridPortableOutputStr /** */ private static final ArrayCreator BOOLEAN_ARR_CREATOR = new ArrayCreator() { @Override public boolean[] create(int len) { - switch (len) { - case -1: - return BOOLEAN_ARR_NOT_READ; + assert len >= 0; + switch (len) { case 0: return BOOLEAN_ARR_EMPTY; @@ -201,6 +192,9 @@ public class GridTcpCommunicationPortableStream implements GridPortableOutputStr } }; + /** */ + private final MessageFactory msgFactory; + /** */ private ByteBuffer buf; @@ -229,12 +223,19 @@ public class GridTcpCommunicationPortableStream implements GridPortableOutputStr private GridTcpCommunicationMessageAdapter msg; /** */ - private boolean lastWritten; + private boolean lastFinished; + + /** + * @param msgFactory Message factory. + */ + public GridTcpCommunicationByteBufferStream(@Nullable MessageFactory msgFactory) { + this.msgFactory = msgFactory; + } /** * @param buf Buffer. */ - public final void setBuffer(ByteBuffer buf) { + public void setBuffer(ByteBuffer buf) { assert buf != null; if (this.buf != buf) { @@ -245,50 +246,19 @@ public final void setBuffer(ByteBuffer buf) { } } - /** - * @return Whether last object was fully written. - */ - public boolean lastWritten() { - return lastWritten; + public int remaining() { + return buf.remaining(); } /** - * @param msg Message. + * @return Whether last object was fully written or read. */ - public void writeMessage(GridTcpCommunicationMessageAdapter msg) { - assert msg != null; - - lastWritten = msg.writeTo(buf); - } - - /** - * @return Message. - */ - public GridTcpCommunicationMessageAdapter readMessage() { - if (!msgTypeDone) { - assert buf.hasRemaining(); - - byte type = readByte(); - - msg = type == Byte.MIN_VALUE ? null : GridTcpCommunicationMessageFactory.create(type); - - msgTypeDone = true; - } - - if (msg == null || msg.readFrom(buf)) { - GridTcpCommunicationMessageAdapter msg0 = msg; - - msgTypeDone = false; - msg = null; - - return msg0; - } - else - return MSG_NOT_READ; + public boolean lastFinished() { + return lastFinished; } /** {@inheritDoc} */ - @Override public void writeByte(byte val) { + public void writeByte(byte val) { int pos = buf.position(); UNSAFE.putByte(heapArr, baseOff + pos, val); @@ -297,14 +267,14 @@ public GridTcpCommunicationMessageAdapter readMessage() { } /** {@inheritDoc} */ - @Override public void writeByteArray(byte[] val) { + public void writeByteArray(byte[] val) { assert val != null; - lastWritten = writeArray(val, BYTE_ARR_OFF, val.length); + lastFinished = writeArray(val, BYTE_ARR_OFF, val.length, val.length); } /** {@inheritDoc} */ - @Override public void writeBoolean(boolean val) { + public void writeBoolean(boolean val) { int pos = buf.position(); UNSAFE.putBoolean(heapArr, baseOff + pos, val); @@ -313,14 +283,14 @@ public GridTcpCommunicationMessageAdapter readMessage() { } /** {@inheritDoc} */ - @Override public void writeBooleanArray(boolean[] val) { + public void writeBooleanArray(boolean[] val) { assert val != null; - lastWritten = writeArray(val, BOOLEAN_ARR_OFF, val.length); + lastFinished = writeArray(val, BOOLEAN_ARR_OFF, val.length, val.length); } /** {@inheritDoc} */ - @Override public void writeShort(short val) { + public void writeShort(short val) { int pos = buf.position(); UNSAFE.putShort(heapArr, baseOff + pos, val); @@ -329,14 +299,14 @@ public GridTcpCommunicationMessageAdapter readMessage() { } /** {@inheritDoc} */ - @Override public void writeShortArray(short[] val) { + public void writeShortArray(short[] val) { assert val != null; - lastWritten = writeArray(val, SHORT_ARR_OFF, val.length << 1); + lastFinished = writeArray(val, SHORT_ARR_OFF, val.length, val.length << 1); } /** {@inheritDoc} */ - @Override public void writeChar(char val) { + public void writeChar(char val) { int pos = buf.position(); UNSAFE.putChar(heapArr, baseOff + pos, val); @@ -345,14 +315,14 @@ public GridTcpCommunicationMessageAdapter readMessage() { } /** {@inheritDoc} */ - @Override public void writeCharArray(char[] val) { + public void writeCharArray(char[] val) { assert val != null; - lastWritten = writeArray(val, CHAR_ARR_OFF, val.length << 1); + lastFinished = writeArray(val, CHAR_ARR_OFF, val.length, val.length << 1); } /** {@inheritDoc} */ - @Override public void writeInt(int val) { + public void writeInt(int val) { int pos = buf.position(); UNSAFE.putInt(heapArr, baseOff + pos, val); @@ -361,19 +331,14 @@ public GridTcpCommunicationMessageAdapter readMessage() { } /** {@inheritDoc} */ - @Override public void writeInt(int pos, int val) { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Override public void writeIntArray(int[] val) { + public void writeIntArray(int[] val) { assert val != null; - lastWritten = writeArray(val, INT_ARR_OFF, val.length << 2); + lastFinished = writeArray(val, INT_ARR_OFF, val.length, val.length << 2); } /** {@inheritDoc} */ - @Override public void writeFloat(float val) { + public void writeFloat(float val) { int pos = buf.position(); UNSAFE.putFloat(heapArr, baseOff + pos, val); @@ -382,14 +347,14 @@ public GridTcpCommunicationMessageAdapter readMessage() { } /** {@inheritDoc} */ - @Override public void writeFloatArray(float[] val) { + public void writeFloatArray(float[] val) { assert val != null; - lastWritten = writeArray(val, FLOAT_ARR_OFF, val.length << 2); + lastFinished = writeArray(val, FLOAT_ARR_OFF, val.length, val.length << 2); } /** {@inheritDoc} */ - @Override public void writeLong(long val) { + public void writeLong(long val) { int pos = buf.position(); UNSAFE.putLong(heapArr, baseOff + pos, val); @@ -398,14 +363,14 @@ public GridTcpCommunicationMessageAdapter readMessage() { } /** {@inheritDoc} */ - @Override public void writeLongArray(long[] val) { + public void writeLongArray(long[] val) { assert val != null; - lastWritten = writeArray(val, LONG_ARR_OFF, val.length << 3); + lastFinished = writeArray(val, LONG_ARR_OFF, val.length, val.length << 3); } /** {@inheritDoc} */ - @Override public void writeDouble(double val) { + public void writeDouble(double val) { int pos = buf.position(); UNSAFE.putDouble(heapArr, baseOff + pos, val); @@ -414,24 +379,23 @@ public GridTcpCommunicationMessageAdapter readMessage() { } /** {@inheritDoc} */ - @Override public void writeDoubleArray(double[] val) { + public void writeDoubleArray(double[] val) { assert val != null; - lastWritten = writeArray(val, DOUBLE_ARR_OFF, val.length << 3); + lastFinished = writeArray(val, DOUBLE_ARR_OFF, val.length, val.length << 3); } - /** {@inheritDoc} */ - @Override public void write(byte[] arr, int off, int len) { - throw new UnsupportedOperationException(); - } + /** + * @param msg Message. + */ + public void writeMessage(GridTcpCommunicationMessageAdapter msg) { + assert msg != null; - /** {@inheritDoc} */ - @Override public void write(long addr, int cnt) { - throw new UnsupportedOperationException(); + lastFinished = msg.writeTo(buf); } /** {@inheritDoc} */ - @Override public byte readByte() { + public byte readByte() { assert buf.hasRemaining(); int pos = buf.position(); @@ -442,12 +406,12 @@ public GridTcpCommunicationMessageAdapter readMessage() { } /** {@inheritDoc} */ - @Override public byte[] readByteArray(int cnt) { - return readArray(BYTE_ARR_CREATOR, cnt, 0, BYTE_ARR_OFF); + public byte[] readByteArray() { + return readArray(BYTE_ARR_CREATOR, 0, BYTE_ARR_OFF); } /** {@inheritDoc} */ - @Override public boolean readBoolean() { + public boolean readBoolean() { assert buf.hasRemaining(); int pos = buf.position(); @@ -458,12 +422,12 @@ public GridTcpCommunicationMessageAdapter readMessage() { } /** {@inheritDoc} */ - @Override public boolean[] readBooleanArray(int cnt) { - return readArray(BOOLEAN_ARR_CREATOR, cnt, 0, BOOLEAN_ARR_OFF); + public boolean[] readBooleanArray() { + return readArray(BOOLEAN_ARR_CREATOR, 0, BOOLEAN_ARR_OFF); } /** {@inheritDoc} */ - @Override public short readShort() { + public short readShort() { assert buf.remaining() >= 2; int pos = buf.position(); @@ -474,12 +438,12 @@ public GridTcpCommunicationMessageAdapter readMessage() { } /** {@inheritDoc} */ - @Override public short[] readShortArray(int cnt) { - return readArray(SHORT_ARR_CREATOR, cnt, 1, SHORT_ARR_OFF); + public short[] readShortArray() { + return readArray(SHORT_ARR_CREATOR, 1, SHORT_ARR_OFF); } /** {@inheritDoc} */ - @Override public char readChar() { + public char readChar() { assert buf.remaining() >= 2; int pos = buf.position(); @@ -490,12 +454,12 @@ public GridTcpCommunicationMessageAdapter readMessage() { } /** {@inheritDoc} */ - @Override public char[] readCharArray(int cnt) { - return readArray(CHAR_ARR_CREATOR, cnt, 1, CHAR_ARR_OFF); + public char[] readCharArray() { + return readArray(CHAR_ARR_CREATOR, 1, CHAR_ARR_OFF); } /** {@inheritDoc} */ - @Override public int readInt() { + public int readInt() { assert buf.remaining() >= 4; int pos = buf.position(); @@ -506,17 +470,12 @@ public GridTcpCommunicationMessageAdapter readMessage() { } /** {@inheritDoc} */ - @Override public int readInt(int pos) { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Override public int[] readIntArray(int cnt) { - return readArray(INT_ARR_CREATOR, cnt, 2, INT_ARR_OFF); + public int[] readIntArray() { + return readArray(INT_ARR_CREATOR, 2, INT_ARR_OFF); } /** {@inheritDoc} */ - @Override public float readFloat() { + public float readFloat() { assert buf.remaining() >= 4; int pos = buf.position(); @@ -527,12 +486,12 @@ public GridTcpCommunicationMessageAdapter readMessage() { } /** {@inheritDoc} */ - @Override public float[] readFloatArray(int cnt) { - return readArray(FLOAT_ARR_CREATOR, cnt, 2, FLOAT_ARR_OFF); + public float[] readFloatArray() { + return readArray(FLOAT_ARR_CREATOR, 2, FLOAT_ARR_OFF); } /** {@inheritDoc} */ - @Override public long readLong() { + public long readLong() { assert buf.remaining() >= 8; int pos = buf.position(); @@ -543,12 +502,12 @@ public GridTcpCommunicationMessageAdapter readMessage() { } /** {@inheritDoc} */ - @Override public long[] readLongArray(int cnt) { - return readArray(LONG_ARR_CREATOR, cnt, 3, LONG_ARR_OFF); + public long[] readLongArray() { + return readArray(LONG_ARR_CREATOR, 3, LONG_ARR_OFF); } /** {@inheritDoc} */ - @Override public double readDouble() { + public double readDouble() { assert buf.remaining() >= 8; int pos = buf.position(); @@ -559,75 +518,58 @@ public GridTcpCommunicationMessageAdapter readMessage() { } /** {@inheritDoc} */ - @Override public double[] readDoubleArray(int cnt) { - return readArray(DOUBLE_ARR_CREATOR, cnt, 3, DOUBLE_ARR_OFF); - } - - /** {@inheritDoc} */ - @Override public int read(byte[] arr, int off, int len) { - throw new UnsupportedOperationException(); + public double[] readDoubleArray() { + return readArray(DOUBLE_ARR_CREATOR, 3, DOUBLE_ARR_OFF); } - /** {@inheritDoc} */ - @Override public int read(long addr, int len) { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Override public int position() { - return buf.position(); - } - - /** {@inheritDoc} */ - @Override public void position(int pos) { - buf.position(pos); - } + /** + * @return Message. + */ + public GridTcpCommunicationMessageAdapter readMessage() { + if (!msgTypeDone) { + if (!buf.hasRemaining()) + return null; - /** {@inheritDoc} */ - public int remaining() { - return buf.remaining(); - } + byte type = readByte(); - /** {@inheritDoc} */ - @Override public void close() { - // No-op. - } + msg = type == Byte.MIN_VALUE ? null : msgFactory.create(type); - /** {@inheritDoc} */ - @Override public byte[] array() { - throw new UnsupportedOperationException(); - } + msgTypeDone = true; + } - /** {@inheritDoc} */ - @Override public byte[] arrayCopy() { - throw new UnsupportedOperationException(); - } + if (msg == null || msg.readFrom(buf)) { + GridTcpCommunicationMessageAdapter msg0 = msg; - /** {@inheritDoc} */ - @Override public long offheapPointer() { - throw new UnsupportedOperationException(); - } + msgTypeDone = false; + msg = null; - /** {@inheritDoc} */ - @Override public boolean hasArray() { - throw new UnsupportedOperationException(); + return msg0; + } + else + return null; } /** * @param arr Array. * @param off Offset. + * @param len Length. * @param bytes Length in bytes. * @return Whether array was fully written */ - private boolean writeArray(Object arr, long off, int bytes) { + private boolean writeArray(Object arr, long off, int len, int bytes) { assert arr != null; assert arr.getClass().isArray() && arr.getClass().getComponentType().isPrimitive(); assert off > 0; + assert len >= 0; assert bytes >= 0; assert bytes >= arrOff; - if (!buf.hasRemaining()) - return false; + if (arrOff == 0) { + if (remaining() < 4) + return false; + + writeInt(len); + } int toWrite = bytes - arrOff; int pos = buf.position(); @@ -659,20 +601,31 @@ private boolean writeArray(Object arr, long off, int bytes) { /** * @param creator Array creator. - * @param len Array Array length. * @param lenShift Array length shift size. * @param off Base offset. * @return Array or special value if it was not fully read. */ - private T readArray(ArrayCreator creator, int len, int lenShift, long off) { + private T readArray(ArrayCreator creator, int lenShift, long off) { assert creator != null; if (tmpArr == null) { + if (remaining() < 4) { + lastFinished = false; + + return null; + } + + int len = readInt(); + switch (len) { case -1: + lastFinished = true; + return null; case 0: + lastFinished = true; + return creator.create(0); default: @@ -692,7 +645,9 @@ private T readArray(ArrayCreator creator, int len, int lenShift, long off tmpArrOff += remaining; - return creator.create(-1); + lastFinished = false; + + return null; } else { UNSAFE.copyMemory(heapArr, baseOff + pos, tmpArr, off + tmpArrOff, toRead); @@ -705,6 +660,8 @@ private T readArray(ArrayCreator creator, int len, int lenShift, long off tmpArrBytes = 0; tmpArrOff = 0; + lastFinished = true; + return arr; } } diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageAdapter.java b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageAdapter.java index 7f5d97c6ce079..108425cc52c4f 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageAdapter.java +++ b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageAdapter.java @@ -9,18 +9,12 @@ package org.gridgain.grid.util.direct; -import org.apache.ignite.lang.*; -import org.gridgain.grid.kernal.processors.cache.*; -import org.gridgain.grid.kernal.processors.cache.distributed.dht.preloader.*; -import org.gridgain.grid.kernal.processors.clock.*; -import org.gridgain.grid.util.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; import java.util.*; -import static org.apache.ignite.events.IgniteEventType.*; - /** * Communication message adapter. */ @@ -29,93 +23,28 @@ public abstract class GridTcpCommunicationMessageAdapter implements Serializable private static final long serialVersionUID = 0L; /** */ - public static final byte[] BYTE_ARR_NOT_READ = new byte[0]; - - /** */ - public static final short[] SHORT_ARR_NOT_READ = new short[0]; - - /** */ - public static final int[] INT_ARR_NOT_READ = new int[0]; - - /** */ - public static final long[] LONG_ARR_NOT_READ = new long[0]; - - /** */ - public static final float[] FLOAT_ARR_NOT_READ = new float[0]; - - /** */ - public static final double[] DOUBLE_ARR_NOT_READ = new double[0]; - - /** */ - public static final char[] CHAR_ARR_NOT_READ = new char[0]; - - /** */ - public static final boolean[] BOOLEAN_ARR_NOT_READ = new boolean[0]; - - /** */ - public static final UUID UUID_NOT_READ = new UUID(0, 0); - - /** */ - public static final ByteBuffer BYTE_BUF_NOT_READ = ByteBuffer.allocate(0); - - /** */ - public static final IgniteUuid GRID_UUID_NOT_READ = new IgniteUuid(new UUID(0, 0), 0); - - /** */ - public static final GridClockDeltaVersion CLOCK_DELTA_VER_NOT_READ = new GridClockDeltaVersion(0, 0); - - /** */ - public static final GridByteArrayList BYTE_ARR_LIST_NOT_READ = new GridByteArrayList(new byte[0]); - - /** */ - public static final GridLongList LONG_LIST_NOT_READ = new GridLongList(0); - - /** */ - public static final GridCacheVersion CACHE_VER_NOT_READ = new GridCacheVersion(0, 0, 0, 0); - - /** */ - public static final GridDhtPartitionExchangeId DHT_PART_EXCHANGE_ID_NOT_READ = - new GridDhtPartitionExchangeId(new UUID(0, 0), EVT_NODE_LEFT, 1); - - /** */ - public static final GridCacheValueBytes VAL_BYTES_NOT_READ = new GridCacheValueBytes(); - - /** */ - @SuppressWarnings("RedundantStringConstructorCall") - public static final String STR_NOT_READ = new String(); - - /** */ - public static final BitSet BIT_SET_NOT_READ = new BitSet(); + protected static final Object NULL = new Object(); /** */ - public static final GridTcpCommunicationMessageAdapter MSG_NOT_READ = new GridTcpCommunicationMessageAdapter() { - @SuppressWarnings("CloneDoesntCallSuperClone") - @Override public GridTcpCommunicationMessageAdapter clone() { - throw new UnsupportedOperationException(); - } - - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { - throw new UnsupportedOperationException(); - } - - @Override public boolean writeTo(ByteBuffer buf) { - throw new UnsupportedOperationException(); - } + protected final GridTcpCommunicationMessageState commState = new GridTcpCommunicationMessageState(); - @Override public boolean readFrom(ByteBuffer buf) { - throw new UnsupportedOperationException(); - } + /** + * @param writer Writer. + */ + public final void setWriter(MessageWriter writer) { + assert writer != null; - @Override public byte directType() { - throw new UnsupportedOperationException(); - } - }; + commState.setWriter(writer); + } - /** */ - protected static final Object NULL = new Object(); + /** + * @param reader Reader. + */ + public final void setReader(MessageReader reader) { + assert reader != null; - /** */ - protected final GridTcpCommunicationMessageState commState = new GridTcpCommunicationMessageState(); + commState.setReader(reader); + } /** * @param buf Byte buffer. diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageFactory.java b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageFactory.java index 7c92065d86fd9..653c62261e2b9 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageFactory.java +++ b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageFactory.java @@ -323,7 +323,7 @@ private static GridTcpCommunicationMessageAdapter create0(byte type) { */ public static void registerCommon(GridTcpCommunicationMessageProducer producer, int... types) { for (int type : types) { - assert type >= 0 && type < COMMON.length : "Commmon type being registered is out of common messages " + + assert type >= 0 && type < COMMON.length : "Common type being registered is out of common messages " + "array length: " + type; COMMON[type] = producer; diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageReader.java b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageReader.java new file mode 100644 index 0000000000000..1645fb5582abc --- /dev/null +++ b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageReader.java @@ -0,0 +1,232 @@ +/* @java.file.header */ + +/* _________ _____ __________________ _____ + * __ ____/___________(_)______ /__ ____/______ ____(_)_______ + * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ + * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / + * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ + */ + +package org.gridgain.grid.util.direct; + +import org.apache.ignite.plugin.extensions.communication.*; +import org.jetbrains.annotations.*; + +import java.nio.*; + +/** + * Portable reader implementation. + */ +public class GridTcpCommunicationMessageReader implements MessageReader { + /** Stream. */ + private final GridTcpCommunicationByteBufferStream stream; + + /** Whether last field was fully read. */ + private boolean lastRead; + + /** + * @param msgFactory Message factory. + */ + public GridTcpCommunicationMessageReader(MessageFactory msgFactory) { + this.stream = new GridTcpCommunicationByteBufferStream(msgFactory); + } + + /** {@inheritDoc} */ + @Override public void setBuffer(ByteBuffer buf) { + stream.setBuffer(buf); + } + + /** {@inheritDoc} */ + @Override public byte readByte(String name) { + if (stream.remaining() < 1) { + lastRead = false; + + return 0; + } + else { + lastRead = true; + + return stream.readByte(); + } + } + + /** {@inheritDoc} */ + @Override public short readShort(String name) { + if (stream.remaining() < 2) { + lastRead = false; + + return 0; + } + else { + lastRead = true; + + return stream.readShort(); + } + } + + /** {@inheritDoc} */ + @Override public int readInt(String name) { + if (stream.remaining() < 4) { + lastRead = false; + + return 0; + } + else { + lastRead = true; + + return stream.readInt(); + } + } + + /** {@inheritDoc} */ + @Override public long readLong(String name) { + if (stream.remaining() < 8) { + lastRead = false; + + return 0; + } + else { + lastRead = true; + + return stream.readLong(); + } + } + + /** {@inheritDoc} */ + @Override public float readFloat(String name) { + if (stream.remaining() < 4) { + lastRead = false; + + return 0; + } + else { + lastRead = true; + + return stream.readFloat(); + } + } + + /** {@inheritDoc} */ + @Override public double readDouble(String name) { + if (stream.remaining() < 8) { + lastRead = false; + + return 0; + } + else { + lastRead = true; + + return stream.readDouble(); + } + } + + /** {@inheritDoc} */ + @Override public char readChar(String name) { + if (stream.remaining() < 2) { + lastRead = false; + + return 0; + } + else { + lastRead = true; + + return stream.readChar(); + } + } + + /** {@inheritDoc} */ + @Override public boolean readBoolean(String name) { + if (stream.remaining() < 1) { + lastRead = false; + + return false; + } + else { + lastRead = true; + + return stream.readBoolean(); + } + } + + /** {@inheritDoc} */ + @Nullable @Override public byte[] readByteArray(String name) { + byte[] arr = stream.readByteArray(); + + lastRead = stream.lastFinished(); + + return arr; + } + + /** {@inheritDoc} */ + @Nullable @Override public short[] readShortArray(String name) { + short[] arr = stream.readShortArray(); + + lastRead = stream.lastFinished(); + + return arr; + } + + /** {@inheritDoc} */ + @Nullable @Override public int[] readIntArray(String name) { + int[] arr = stream.readIntArray(); + + lastRead = stream.lastFinished(); + + return arr; + } + + /** {@inheritDoc} */ + @Nullable @Override public long[] readLongArray(String name) { + long[] arr = stream.readLongArray(); + + lastRead = stream.lastFinished(); + + return arr; + } + + /** {@inheritDoc} */ + @Nullable @Override public float[] readFloatArray(String name) { + float[] arr = stream.readFloatArray(); + + lastRead = stream.lastFinished(); + + return arr; + } + + /** {@inheritDoc} */ + @Nullable @Override public double[] readDoubleArray(String name) { + double[] arr = stream.readDoubleArray(); + + lastRead = stream.lastFinished(); + + return arr; + } + + /** {@inheritDoc} */ + @Nullable @Override public char[] readCharArray(String name) { + char[] arr = stream.readCharArray(); + + lastRead = stream.lastFinished(); + + return arr; + } + + /** {@inheritDoc} */ + @Nullable @Override public boolean[] readBooleanArray(String name) { + boolean[] arr = stream.readBooleanArray(); + + lastRead = stream.lastFinished(); + + return arr; + } + + /** {@inheritDoc} */ + @Nullable @Override public GridTcpCommunicationMessageAdapter readMessage(String name) { + return stream.readMessage(); + } + + /** {@inheritDoc} */ + @Override public boolean isLastRead() { + return lastRead; + } +} diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java index 1fa6a8d02e6f2..6f6cf81a58499 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java +++ b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java @@ -10,7 +10,7 @@ package org.gridgain.grid.util.direct; import org.apache.ignite.lang.*; -import org.apache.ignite.portables.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.gridgain.grid.kernal.processors.cache.*; import org.gridgain.grid.kernal.processors.cache.distributed.dht.preloader.*; import org.gridgain.grid.kernal.processors.clock.*; @@ -35,19 +35,10 @@ public class GridTcpCommunicationMessageState { private static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class); /** */ - private static final int FIELD_HDR_LEN = 0; + private MessageWriter writer; /** */ - private final GridTcpCommunicationPortableStream stream = new GridTcpCommunicationPortableStream(); - - /** */ - private final PortableWriter writer = new GridTcpCommunicationPortableWriter(stream); - - /** */ - private final PortableReader reader = new GridTcpCommunicationPortableReader(stream); - - /** */ - private boolean hdrDone; + private MessageReader reader; /** */ public int idx; @@ -70,11 +61,31 @@ public class GridTcpCommunicationMessageState { /** */ public int readItems; + /** + * @param writer Writer. + */ + public final void setWriter(MessageWriter writer) { + if (this.writer == null) + this.writer = writer; + } + + /** + * @param reader Reader. + */ + public final void setReader(MessageReader reader) { + if (this.reader == null) + this.reader = reader; + } + /** * @param buf Buffer. */ public final void setBuffer(ByteBuffer buf) { - stream.setBuffer(buf); + if (writer != null) + writer.setBuffer(buf); + + if (reader != null) + reader.setBuffer(buf); } /** @@ -83,12 +94,7 @@ public final void setBuffer(ByteBuffer buf) { * @return Whether value was written. */ public final boolean putByte(String name, byte b) { - if (stream.remaining() < FIELD_HDR_LEN + 1) - return false; - - writer.writeByte(name, b); - - return true; + return writer.writeByte(name, b); } /** @@ -105,12 +111,7 @@ public final byte getByte(String name) { * @return Whether value was written. */ public final boolean putShort(String name, short s) { - if (stream.remaining() < FIELD_HDR_LEN + 2) - return false; - - writer.writeShort(name, s); - - return true; + return writer.writeShort(name, s); } /** @@ -127,12 +128,7 @@ public final short getShort(String name) { * @return Whether value was written. */ public final boolean putInt(String name, int i) { - if (stream.remaining() < FIELD_HDR_LEN + 4) - return false; - - writer.writeInt(name, i); - - return true; + return writer.writeInt(name, i); } /** @@ -149,12 +145,7 @@ public final int getInt(String name) { * @return Whether value was written. */ public final boolean putLong(String name, long l) { - if (stream.remaining() < FIELD_HDR_LEN + 8) - return false; - - writer.writeLong(name, l); - - return true; + return writer.writeLong(name, l); } /** @@ -171,12 +162,7 @@ public final long getLong(String name) { * @return Whether value was written. */ public final boolean putFloat(String name, float f) { - if (stream.remaining() < FIELD_HDR_LEN + 4) - return false; - - writer.writeFloat(name, f); - - return true; + return writer.writeFloat(name, f); } /** @@ -193,12 +179,7 @@ public final float getFloat(String name) { * @return Whether value was written. */ public final boolean putDouble(String name, double d) { - if (stream.remaining() < FIELD_HDR_LEN + 8) - return false; - - writer.writeDouble(name, d); - - return true; + return writer.writeDouble(name, d); } /** @@ -215,12 +196,7 @@ public final double getDouble(String name) { * @return Whether value was written. */ public final boolean putChar(String name, char c) { - if (stream.remaining() < FIELD_HDR_LEN + 2) - return false; - - writer.writeChar(name, c); - - return true; + return writer.writeChar(name, c); } /** @@ -237,12 +213,7 @@ public final char getChar(String name) { * @return Whether value was written. */ public final boolean putBoolean(String name, boolean b) { - if (stream.remaining() < FIELD_HDR_LEN + 1) - return false; - - writer.writeBoolean(name, b); - - return true; + return writer.writeBoolean(name, b); } /** @@ -259,47 +230,15 @@ public final boolean getBoolean(String name) { * @return Whether array was fully written. */ public final boolean putByteArray(String name, @Nullable byte[] arr) { - if (!hdrDone) { - if (stream.remaining() < FIELD_HDR_LEN + 4) - return false; - - writer.writeByteArray(name, arr); - - if (arr == null) - return true; - - hdrDone = true; - } - else - stream.writeByteArray(arr); - - return lastWritten(); + return writer.writeByteArray(name, arr); } /** * @param name Field name. - * @return Byte array or special - * {@link GridTcpCommunicationMessageAdapter#BYTE_ARR_NOT_READ} - * value if it was not fully read. + * @return Byte array. */ public final byte[] getByteArray(String name) { - byte[] arr; - - if (!hdrDone) { - if (stream.remaining() < FIELD_HDR_LEN + 4) - return BYTE_ARR_NOT_READ; - - arr = reader.readByteArray(name); - - hdrDone = true; - } - else - arr = stream.readByteArray(-1); - - if (arr != BYTE_ARR_NOT_READ) - hdrDone = false; - - return arr; + return reader.readByteArray(name); } /** @@ -308,47 +247,15 @@ public final byte[] getByteArray(String name) { * @return Whether array was fully written. */ public final boolean putShortArray(String name, short[] arr) { - if (!hdrDone) { - if (stream.remaining() < FIELD_HDR_LEN + 4) - return false; - - writer.writeShortArray(name, arr); - - if (arr == null) - return true; - - hdrDone = true; - } - else - stream.writeShortArray(arr); - - return lastWritten(); + return writer.writeShortArray(name, arr); } /** * @param name Field name. - * @return Short array or special - * {@link GridTcpCommunicationMessageAdapter#SHORT_ARR_NOT_READ} - * value if it was not fully read. + * @return Short array. */ public final short[] getShortArray(String name) { - short[] arr; - - if (!hdrDone) { - if (stream.remaining() < FIELD_HDR_LEN + 4) - return SHORT_ARR_NOT_READ; - - arr = reader.readShortArray(name); - - hdrDone = true; - } - else - arr = stream.readShortArray(-1); - - if (arr != SHORT_ARR_NOT_READ) - hdrDone = false; - - return arr; + return reader.readShortArray(name); } /** @@ -357,47 +264,15 @@ public final short[] getShortArray(String name) { * @return Whether array was fully written. */ public final boolean putIntArray(String name, int[] arr) { - if (!hdrDone) { - if (stream.remaining() < FIELD_HDR_LEN + 4) - return false; - - writer.writeIntArray(name, arr); - - if (arr == null) - return true; - - hdrDone = true; - } - else - stream.writeIntArray(arr); - - return lastWritten(); + return writer.writeIntArray(name, arr); } /** * @param name Field name. - * @return Integer array or special - * {@link GridTcpCommunicationMessageAdapter#INT_ARR_NOT_READ} - * value if it was not fully read. + * @return Integer array. */ public final int[] getIntArray(String name) { - int[] arr; - - if (!hdrDone) { - if (stream.remaining() < FIELD_HDR_LEN + 4) - return INT_ARR_NOT_READ; - - arr = reader.readIntArray(name); - - hdrDone = true; - } - else - arr = stream.readIntArray(-1); - - if (arr != INT_ARR_NOT_READ) - hdrDone = false; - - return arr; + return reader.readIntArray(name); } /** @@ -406,47 +281,15 @@ public final int[] getIntArray(String name) { * @return Whether array was fully written. */ public final boolean putLongArray(String name, long[] arr) { - if (!hdrDone) { - if (stream.remaining() < FIELD_HDR_LEN + 4) - return false; - - writer.writeLongArray(name, arr); - - if (arr == null) - return true; - - hdrDone = true; - } - else - stream.writeLongArray(arr); - - return lastWritten(); + return writer.writeLongArray(name, arr); } /** * @param name Field name. - * @return Long array or special - * {@link GridTcpCommunicationMessageAdapter#LONG_ARR_NOT_READ} - * value if it was not fully read. + * @return Long array. */ public final long[] getLongArray(String name) { - long[] arr; - - if (!hdrDone) { - if (stream.remaining() < FIELD_HDR_LEN + 4) - return LONG_ARR_NOT_READ; - - arr = reader.readLongArray(name); - - hdrDone = true; - } - else - arr = stream.readLongArray(-1); - - if (arr != LONG_ARR_NOT_READ) - hdrDone = false; - - return arr; + return reader.readLongArray(name); } /** @@ -455,47 +298,15 @@ public final long[] getLongArray(String name) { * @return Whether array was fully written. */ public final boolean putFloatArray(String name, float[] arr) { - if (!hdrDone) { - if (stream.remaining() < FIELD_HDR_LEN + 4) - return false; - - writer.writeFloatArray(name, arr); - - if (arr == null) - return true; - - hdrDone = true; - } - else - stream.writeFloatArray(arr); - - return lastWritten(); + return writer.writeFloatArray(name, arr); } /** * @param name Field name. - * @return Float array or special - * {@link GridTcpCommunicationMessageAdapter#FLOAT_ARR_NOT_READ} - * value if it was not fully read. + * @return Float array. */ public final float[] getFloatArray(String name) { - float[] arr; - - if (!hdrDone) { - if (stream.remaining() < FIELD_HDR_LEN + 4) - return FLOAT_ARR_NOT_READ; - - arr = reader.readFloatArray(name); - - hdrDone = true; - } - else - arr = stream.readFloatArray(-1); - - if (arr != FLOAT_ARR_NOT_READ) - hdrDone = false; - - return arr; + return reader.readFloatArray(name); } /** @@ -504,47 +315,15 @@ public final float[] getFloatArray(String name) { * @return Whether array was fully written. */ public final boolean putDoubleArray(String name, double[] arr) { - if (!hdrDone) { - if (stream.remaining() < FIELD_HDR_LEN + 4) - return false; - - writer.writeDoubleArray(name, arr); - - if (arr == null) - return true; - - hdrDone = true; - } - else - stream.writeDoubleArray(arr); - - return lastWritten(); + return writer.writeDoubleArray(name, arr); } /** * @param name Field name. - * @return Double array or special - * {@link GridTcpCommunicationMessageAdapter#DOUBLE_ARR_NOT_READ} - * value if it was not fully read. + * @return Double array. */ public final double[] getDoubleArray(String name) { - double[] arr; - - if (!hdrDone) { - if (stream.remaining() < FIELD_HDR_LEN + 4) - return DOUBLE_ARR_NOT_READ; - - arr = reader.readDoubleArray(name); - - hdrDone = true; - } - else - arr = stream.readDoubleArray(-1); - - if (arr != DOUBLE_ARR_NOT_READ) - hdrDone = false; - - return arr; + return reader.readDoubleArray(name); } /** @@ -553,47 +332,15 @@ public final double[] getDoubleArray(String name) { * @return Whether array was fully written. */ public final boolean putCharArray(String name, char[] arr) { - if (!hdrDone) { - if (stream.remaining() < FIELD_HDR_LEN + 4) - return false; - - writer.writeCharArray(name, arr); - - if (arr == null) - return true; - - hdrDone = true; - } - else - stream.writeCharArray(arr); - - return lastWritten(); + return writer.writeCharArray(name, arr); } /** * @param name Field name. - * @return Char array or special - * {@link GridTcpCommunicationMessageAdapter#CHAR_ARR_NOT_READ} - * value if it was not fully read. + * @return Char array. */ public final char[] getCharArray(String name) { - char[] arr; - - if (!hdrDone) { - if (stream.remaining() < FIELD_HDR_LEN + 4) - return CHAR_ARR_NOT_READ; - - arr = reader.readCharArray(name); - - hdrDone = true; - } - else - arr = stream.readCharArray(-1); - - if (arr != CHAR_ARR_NOT_READ) - hdrDone = false; - - return arr; + return reader.readCharArray(name); } /** @@ -602,47 +349,15 @@ public final char[] getCharArray(String name) { * @return Whether array was fully written. */ public final boolean putBooleanArray(String name, boolean[] arr) { - if (!hdrDone) { - if (stream.remaining() < FIELD_HDR_LEN + 4) - return false; - - writer.writeBooleanArray(name, arr); - - if (arr == null) - return true; - - hdrDone = true; - } - else - stream.writeBooleanArray(arr); - - return lastWritten(); + return writer.writeBooleanArray(name, arr); } /** * @param name Field name. - * @return Boolean array or special - * {@link GridTcpCommunicationMessageAdapter#BOOLEAN_ARR_NOT_READ} - * value if it was not fully read. + * @return Boolean array. */ public final boolean[] getBooleanArray(String name) { - boolean[] arr; - - if (!hdrDone) { - if (stream.remaining() < FIELD_HDR_LEN + 4) - return BOOLEAN_ARR_NOT_READ; - - arr = reader.readBooleanArray(name); - - hdrDone = true; - } - else - arr = stream.readBooleanArray(-1); - - if (arr != BOOLEAN_ARR_NOT_READ) - hdrDone = false; - - return arr; + return reader.readBooleanArray(name); } /** @@ -668,16 +383,12 @@ public final boolean putByteBuffer(String name, @Nullable ByteBuffer buf) { /** * @param name Field name. - * @return {@link ByteBuffer} or special - * {@link GridTcpCommunicationMessageAdapter#BYTE_BUF_NOT_READ} - * value if it was not fully read. + * @return {@link ByteBuffer}. */ public final ByteBuffer getByteBuffer(String name) { byte[] arr = getByteArray(name); - if (arr == BYTE_ARR_NOT_READ) - return BYTE_BUF_NOT_READ; - else if (arr == null) + if (arr == null) return null; else return ByteBuffer.wrap(arr); @@ -703,16 +414,12 @@ public final boolean putUuid(String name, @Nullable UUID uuid) { /** * @param name Field name. - * @return {@link UUID} or special - * {@link GridTcpCommunicationMessageAdapter#UUID_NOT_READ} - * value if it was not fully read. + * @return {@link UUID}. */ public final UUID getUuid(String name) { byte[] arr = getByteArray(name); - if (arr == BYTE_ARR_NOT_READ) - return UUID_NOT_READ; - else if (arr == null) + if (arr == null) return null; else { long most = UNSAFE.getLong(arr, BYTE_ARR_OFF); @@ -743,16 +450,12 @@ public final boolean putGridUuid(String name, @Nullable IgniteUuid uuid) { /** * @param name Field name. - * @return {@link org.apache.ignite.lang.IgniteUuid} or special - * {@link GridTcpCommunicationMessageAdapter#GRID_UUID_NOT_READ} - * value if it was not fully read. + * @return {@link IgniteUuid}. */ public final IgniteUuid getGridUuid(String name) { byte[] arr = getByteArray(name); - if (arr == BYTE_ARR_NOT_READ) - return GRID_UUID_NOT_READ; - else if (arr == null) + if (arr == null) return null; else { long most = UNSAFE.getLong(arr, BYTE_ARR_OFF); @@ -783,16 +486,12 @@ public final boolean putClockDeltaVersion(String name, @Nullable GridClockDeltaV /** * @param name Field name. - * @return {@link GridClockDeltaVersion} or special - * {@link GridTcpCommunicationMessageAdapter#CLOCK_DELTA_VER_NOT_READ} - * value if it was not fully read. + * @return {@link GridClockDeltaVersion}. */ public final GridClockDeltaVersion getClockDeltaVersion(String name) { byte[] arr = getByteArray(name); - if (arr == BYTE_ARR_NOT_READ) - return CLOCK_DELTA_VER_NOT_READ; - else if (arr == null) + if (arr == null) return null; else { long ver = UNSAFE.getLong(arr, BYTE_ARR_OFF); @@ -813,17 +512,13 @@ public final boolean putByteArrayList(String name, @Nullable GridByteArrayList l /** * @param name Field name. - * @return {@link GridByteArrayList} or special - * {@link GridTcpCommunicationMessageAdapter#BYTE_ARR_LIST_NOT_READ} - * value if it was not fully read. + * @return {@link GridByteArrayList}. */ @SuppressWarnings("IfMayBeConditional") public final GridByteArrayList getByteArrayList(String name) { byte[] arr = getByteArray(name); - if (arr == BYTE_ARR_NOT_READ) - return BYTE_ARR_LIST_NOT_READ; - else if (arr == null) + if (arr == null) return null; else return new GridByteArrayList(arr); @@ -840,17 +535,13 @@ public final boolean putLongList(String name, @Nullable GridLongList list) { /** * @param name Field name. - * @return {@link GridLongList} or special - * {@link GridTcpCommunicationMessageAdapter#LONG_LIST_NOT_READ} - * value if it was not fully read. + * @return {@link GridLongList}. */ @SuppressWarnings("IfMayBeConditional") public final GridLongList getLongList(String name) { long[] arr = getLongArray(name); - if (arr == LONG_ARR_NOT_READ) - return LONG_LIST_NOT_READ; - else if (arr == null) + if (arr == null) return null; else return new GridLongList(arr); @@ -878,16 +569,12 @@ public final boolean putCacheVersion(String name, @Nullable GridCacheVersion ver /** * @param name Field name. - * @return {@link GridCacheVersion} or special - * {@link GridTcpCommunicationMessageAdapter#CACHE_VER_NOT_READ} - * value if it was not fully read. + * @return {@link GridCacheVersion}. */ public final GridCacheVersion getCacheVersion(String name) { byte[] arr = getByteArray(name); - if (arr == BYTE_ARR_NOT_READ) - return CACHE_VER_NOT_READ; - else if (arr == null) + if (arr == null) return null; else { int topVerDrId = UNSAFE.getInt(arr, BYTE_ARR_OFF); @@ -921,16 +608,12 @@ public final boolean putDhtPartitionExchangeId(String name, @Nullable GridDhtPar /** * @param name Field name. - * @return {@link GridDhtPartitionExchangeId} or special - * {@link GridTcpCommunicationMessageAdapter#DHT_PART_EXCHANGE_ID_NOT_READ} - * value if it was not fully read. + * @return {@link GridDhtPartitionExchangeId}. */ public final GridDhtPartitionExchangeId getDhtPartitionExchangeId(String name) { byte[] arr = getByteArray(name); - if (arr == BYTE_ARR_NOT_READ) - return DHT_PART_EXCHANGE_ID_NOT_READ; - else if (arr == null) + if (arr == null) return null; else { long most = UNSAFE.getLong(arr, BYTE_ARR_OFF); @@ -974,16 +657,12 @@ public final boolean putValueBytes(String name, @Nullable GridCacheValueBytes by /** * @param name Field name. - * @return {@link GridCacheValueBytes} or special - * {@link GridTcpCommunicationMessageAdapter#VAL_BYTES_NOT_READ} - * value if it was not fully read. + * @return {@link GridCacheValueBytes}. */ public final GridCacheValueBytes getValueBytes(String name) { byte[] arr = getByteArray(name); - if (arr == BYTE_ARR_NOT_READ) - return VAL_BYTES_NOT_READ; - else if (arr == null) + if (arr == null) return null; else { boolean notNull = UNSAFE.getBoolean(arr, BYTE_ARR_OFF); @@ -1017,16 +696,13 @@ public final boolean putString(String name, @Nullable String str) { /** * @param name Field name. - * @return {@link String} or special {@link GridTcpCommunicationMessageAdapter#STR_NOT_READ} - * value if it was not fully read. + * @return {@link String}. */ @SuppressWarnings("IfMayBeConditional") public final String getString(String name) { byte[] arr = getByteArray(name); - if (arr == BYTE_ARR_NOT_READ) - return STR_NOT_READ; - else if (arr == null) + if (arr == null) return null; else return new String(arr); @@ -1043,16 +719,13 @@ public final boolean putBitSet(String name, @Nullable BitSet bits) { /** * @param name Field name. - * @return {@link BitSet} or special {@link GridTcpCommunicationMessageAdapter#BIT_SET_NOT_READ} - * value if it was not fully read. + * @return {@link BitSet}. */ @SuppressWarnings("IfMayBeConditional") public final BitSet getBitSet(String name) { long[] arr = getLongArray(name); - if (arr == LONG_ARR_NOT_READ) - return BIT_SET_NOT_READ; - else if (arr == null) + if (arr == null) return null; else return BitSet.valueOf(arr); @@ -1073,58 +746,17 @@ public final boolean putEnum(String name, @Nullable Enum e) { * @return Whether value was fully written. */ public final boolean putMessage(String name, @Nullable GridTcpCommunicationMessageAdapter msg) { - if (!hdrDone) { - if (stream.remaining() < FIELD_HDR_LEN + 1) - return false; - - writer.writeObject(name, msg); - - if (msg == null) - return true; - - hdrDone = true; - } - else - stream.writeMessage(msg); + if (msg != null) + msg.setWriter(writer); - return lastWritten(); + return writer.writeMessage(name, msg); } /** * @param name Field name. - * @return {@link GridTcpCommunicationMessageAdapter} or special - * {@link GridTcpCommunicationMessageAdapter#MSG_NOT_READ} - * value if it was not fully read. + * @return {@link GridTcpCommunicationMessageAdapter}. */ public final GridTcpCommunicationMessageAdapter getMessage(String name) { - GridTcpCommunicationMessageAdapter msg; - - if (!hdrDone) { - if (stream.remaining() < FIELD_HDR_LEN) - return MSG_NOT_READ; - - msg = reader.readObject(name); - - hdrDone = true; - } - else - msg = stream.readMessage(); - - if (msg != MSG_NOT_READ) - hdrDone = false; - - return msg; - } - - /** - * @return Whether last array was fully written. - */ - private boolean lastWritten() { - boolean written = stream.lastWritten(); - - if (written) - hdrDone = false; - - return written; + return reader.readMessage(name); } } diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageWriter.java b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageWriter.java new file mode 100644 index 0000000000000..101015c5113ff --- /dev/null +++ b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageWriter.java @@ -0,0 +1,261 @@ +/* @java.file.header */ + +/* _________ _____ __________________ _____ + * __ ____/___________(_)______ /__ ____/______ ____(_)_______ + * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ + * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / + * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ + */ + +package org.gridgain.grid.util.direct; + +import org.apache.ignite.plugin.extensions.communication.*; +import org.jetbrains.annotations.*; + +import java.nio.*; + +/** + * Portable writer implementation. + */ +public class GridTcpCommunicationMessageWriter implements MessageWriter { + /** Stream. */ + private final GridTcpCommunicationByteBufferStream stream = new GridTcpCommunicationByteBufferStream(null); + + /** {@inheritDoc} */ + @Override public void setBuffer(ByteBuffer buf) { + stream.setBuffer(buf); + } + + /** {@inheritDoc} */ + @Override public boolean writeByte(String name, byte val) { + if (stream.remaining() < 1) + return false; + + stream.writeByte(val); + + return true; + } + + /** {@inheritDoc} */ + @Override public boolean writeShort(String name, short val) { + if (stream.remaining() < 2) + return false; + + stream.writeShort(val); + + return true; + } + + /** {@inheritDoc} */ + @Override public boolean writeInt(String name, int val) { + if (stream.remaining() < 4) + return false; + + stream.writeInt(val); + + return true; + } + + /** {@inheritDoc} */ + @Override public boolean writeLong(String name, long val) { + if (stream.remaining() < 8) + return false; + + stream.writeLong(val); + + return true; + } + + /** {@inheritDoc} */ + @Override public boolean writeFloat(String name, float val) { + if (stream.remaining() < 4) + return false; + + stream.writeFloat(val); + + return true; + } + + /** {@inheritDoc} */ + @Override public boolean writeDouble(String name, double val) { + if (stream.remaining() < 8) + return false; + + stream.writeDouble(val); + + return true; + } + + /** {@inheritDoc} */ + @Override public boolean writeChar(String name, char val) { + if (stream.remaining() < 2) + return false; + + stream.writeChar(val); + + return true; + } + + /** {@inheritDoc} */ + @Override public boolean writeBoolean(String name, boolean val) { + if (stream.remaining() < 1) + return false; + + stream.writeBoolean(val); + + return true; + } + + /** {@inheritDoc} */ + @Override public boolean writeByteArray(String name, @Nullable byte[] val) { + if (val != null) { + stream.writeByteArray(val); + + return stream.lastFinished(); + } + else { + if (stream.remaining() < 4) + return false; + + stream.writeInt(-1); + + return true; + } + } + + /** {@inheritDoc} */ + @Override public boolean writeShortArray(String name, @Nullable short[] val) { + if (val != null) { + stream.writeShortArray(val); + + return stream.lastFinished(); + } + else { + if (stream.remaining() < 4) + return false; + + stream.writeInt(-1); + + return true; + } + } + + /** {@inheritDoc} */ + @Override public boolean writeIntArray(String name, @Nullable int[] val) { + if (val != null) { + stream.writeIntArray(val); + + return stream.lastFinished(); + } + else { + if (stream.remaining() < 4) + return false; + + stream.writeInt(-1); + + return true; + } + } + + /** {@inheritDoc} */ + @Override public boolean writeLongArray(String name, @Nullable long[] val) { + if (val != null) { + stream.writeLongArray(val); + + return stream.lastFinished(); + } + else { + if (stream.remaining() < 4) + return false; + + stream.writeInt(-1); + + return true; + } + } + + /** {@inheritDoc} */ + @Override public boolean writeFloatArray(String name, @Nullable float[] val) { + if (val != null) { + stream.writeFloatArray(val); + + return stream.lastFinished(); + } + else { + if (stream.remaining() < 4) + return false; + + stream.writeInt(-1); + + return true; + } + } + + /** {@inheritDoc} */ + @Override public boolean writeDoubleArray(String name, @Nullable double[] val) { + if (val != null) { + stream.writeDoubleArray(val); + + return stream.lastFinished(); + } + else { + if (stream.remaining() < 4) + return false; + + stream.writeInt(-1); + + return true; + } + } + + /** {@inheritDoc} */ + @Override public boolean writeCharArray(String name, @Nullable char[] val) { + if (val != null) { + stream.writeCharArray(val); + + return stream.lastFinished(); + } + else { + if (stream.remaining() < 4) + return false; + + stream.writeInt(-1); + + return true; + } + } + + /** {@inheritDoc} */ + @Override public boolean writeBooleanArray(String name, @Nullable boolean[] val) { + if (val != null) { + stream.writeBooleanArray(val); + + return stream.lastFinished(); + } + else { + if (stream.remaining() < 4) + return false; + + stream.writeInt(-1); + + return true; + } + } + + /** {@inheritDoc} */ + @Override public boolean writeMessage(String name, @Nullable GridTcpCommunicationMessageAdapter msg) { + if (msg != null) { + stream.writeMessage(msg); + + return stream.lastFinished(); + } + else { + if (stream.remaining() < 1) + return false; + + stream.writeByte(Byte.MIN_VALUE); + + return true; + } + } +} diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationPortableReader.java b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationPortableReader.java deleted file mode 100644 index d4b6e2db0b440..0000000000000 --- a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationPortableReader.java +++ /dev/null @@ -1,207 +0,0 @@ -/* @java.file.header */ - -/* _________ _____ __________________ _____ - * __ ____/___________(_)______ /__ ____/______ ____(_)_______ - * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ - * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / - * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ - */ - -package org.gridgain.grid.util.direct; - -import org.apache.ignite.portables.*; -import org.jetbrains.annotations.*; - -import java.math.*; -import java.sql.*; -import java.util.*; -import java.util.Date; - -/** - * Portable reader implementation. - */ -public class GridTcpCommunicationPortableReader implements PortableReader { - /** Stream. */ - private final GridTcpCommunicationPortableStream stream; - - /** - * @param stream Stream. - */ - public GridTcpCommunicationPortableReader(GridTcpCommunicationPortableStream stream) { - this.stream = stream; - } - - /** {@inheritDoc} */ - @Override public byte readByte(String fieldName) throws PortableException { - return stream.readByte(); - } - - /** {@inheritDoc} */ - @Override public short readShort(String fieldName) throws PortableException { - return stream.readShort(); - } - - /** {@inheritDoc} */ - @Override public int readInt(String fieldName) throws PortableException { - return stream.readInt(); - } - - /** {@inheritDoc} */ - @Override public long readLong(String fieldName) throws PortableException { - return stream.readLong(); - } - - /** {@inheritDoc} */ - @Override public float readFloat(String fieldName) throws PortableException { - return stream.readFloat(); - } - - /** {@inheritDoc} */ - @Override public double readDouble(String fieldName) throws PortableException { - return stream.readDouble(); - } - - /** {@inheritDoc} */ - @Override public char readChar(String fieldName) throws PortableException { - return stream.readChar(); - } - - /** {@inheritDoc} */ - @Override public boolean readBoolean(String fieldName) throws PortableException { - return stream.readBoolean(); - } - - /** {@inheritDoc} */ - @Nullable @Override public byte[] readByteArray(String fieldName) throws PortableException { - return stream.readByteArray(stream.readInt()); - } - - /** {@inheritDoc} */ - @Nullable @Override public short[] readShortArray(String fieldName) throws PortableException { - return stream.readShortArray(stream.readInt()); - } - - /** {@inheritDoc} */ - @Nullable @Override public int[] readIntArray(String fieldName) throws PortableException { - return stream.readIntArray(stream.readInt()); - } - - /** {@inheritDoc} */ - @Nullable @Override public long[] readLongArray(String fieldName) throws PortableException { - return stream.readLongArray(stream.readInt()); - } - - /** {@inheritDoc} */ - @Nullable @Override public float[] readFloatArray(String fieldName) throws PortableException { - return stream.readFloatArray(stream.readInt()); - } - - /** {@inheritDoc} */ - @Nullable @Override public double[] readDoubleArray(String fieldName) throws PortableException { - return stream.readDoubleArray(stream.readInt()); - } - - /** {@inheritDoc} */ - @Nullable @Override public char[] readCharArray(String fieldName) throws PortableException { - return stream.readCharArray(stream.readInt()); - } - - /** {@inheritDoc} */ - @Nullable @Override public boolean[] readBooleanArray(String fieldName) throws PortableException { - return stream.readBooleanArray(stream.readInt()); - } - - /** {@inheritDoc} */ - @Nullable @Override public T readObject(String fieldName) throws PortableException { - return (T)stream.readMessage(); - } - - /** {@inheritDoc} */ - @Nullable @Override public BigDecimal readDecimal(String fieldName) throws PortableException { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Nullable @Override public String readString(String fieldName) throws PortableException { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Nullable @Override public UUID readUuid(String fieldName) throws PortableException { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Nullable @Override public Date readDate(String fieldName) throws PortableException { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Nullable @Override public Timestamp readTimestamp(String fieldName) throws PortableException { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Nullable @Override public BigDecimal[] readDecimalArray(String fieldName) throws PortableException { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Nullable @Override public String[] readStringArray(String fieldName) throws PortableException { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Nullable @Override public UUID[] readUuidArray(String fieldName) throws PortableException { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Nullable @Override public Date[] readDateArray(String fieldName) throws PortableException { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Nullable @Override public Object[] readObjectArray(String fieldName) throws PortableException { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Nullable @Override public Collection readCollection(String fieldName) throws PortableException { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Nullable @Override public Collection readCollection(String fieldName, Class> colCls) - throws PortableException { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Nullable @Override public Map readMap(String fieldName) throws PortableException { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Nullable @Override public Map readMap(String fieldName, Class> mapCls) - throws PortableException { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Nullable @Override public > T readEnum(String fieldName, Class enumCls) - throws PortableException { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Nullable @Override public > T[] readEnumArray(String fieldName, Class enumCls) - throws PortableException { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Override public PortableRawReader rawReader() { - throw new UnsupportedOperationException(); - } -} diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationPortableWriter.java b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationPortableWriter.java deleted file mode 100644 index 7f7f971ec7b44..0000000000000 --- a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationPortableWriter.java +++ /dev/null @@ -1,223 +0,0 @@ -/* @java.file.header */ - -/* _________ _____ __________________ _____ - * __ ____/___________(_)______ /__ ____/______ ____(_)_______ - * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ - * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / - * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ - */ - -package org.gridgain.grid.util.direct; - -import org.apache.ignite.portables.*; -import org.jetbrains.annotations.*; - -import java.math.*; -import java.sql.*; -import java.util.*; -import java.util.Date; - -/** - * Portable writer implementation. - */ -public class GridTcpCommunicationPortableWriter implements PortableWriter { - /** Stream. */ - private final GridTcpCommunicationPortableStream stream; - - /** - * @param stream Stream. - */ - public GridTcpCommunicationPortableWriter(GridTcpCommunicationPortableStream stream) { - this.stream = stream; - } - - /** {@inheritDoc} */ - @Override public void writeByte(String fieldName, byte val) throws PortableException { - stream.writeByte(val); - } - - /** {@inheritDoc} */ - @Override public void writeShort(String fieldName, short val) throws PortableException { - stream.writeShort(val); - } - - /** {@inheritDoc} */ - @Override public void writeInt(String fieldName, int val) throws PortableException { - stream.writeInt(val); - } - - /** {@inheritDoc} */ - @Override public void writeLong(String fieldName, long val) throws PortableException { - stream.writeLong(val); - } - - /** {@inheritDoc} */ - @Override public void writeFloat(String fieldName, float val) throws PortableException { - stream.writeFloat(val); - } - - /** {@inheritDoc} */ - @Override public void writeDouble(String fieldName, double val) throws PortableException { - stream.writeDouble(val); - } - - /** {@inheritDoc} */ - @Override public void writeChar(String fieldName, char val) throws PortableException { - stream.writeChar(val); - } - - /** {@inheritDoc} */ - @Override public void writeBoolean(String fieldName, boolean val) throws PortableException { - stream.writeBoolean(val); - } - - /** {@inheritDoc} */ - @Override public void writeByteArray(String fieldName, @Nullable byte[] val) throws PortableException { - stream.writeInt(val != null ? val.length : -1); - - if (val != null) - stream.writeByteArray(val); - } - - /** {@inheritDoc} */ - @Override public void writeShortArray(String fieldName, @Nullable short[] val) throws PortableException { - stream.writeInt(val != null ? val.length : -1); - - if (val != null) - stream.writeShortArray(val); - } - - /** {@inheritDoc} */ - @Override public void writeIntArray(String fieldName, @Nullable int[] val) throws PortableException { - stream.writeInt(val != null ? val.length : -1); - - if (val != null) - stream.writeIntArray(val); - } - - /** {@inheritDoc} */ - @Override public void writeLongArray(String fieldName, @Nullable long[] val) throws PortableException { - stream.writeInt(val != null ? val.length : -1); - - if (val != null) - stream.writeLongArray(val); - } - - /** {@inheritDoc} */ - @Override public void writeFloatArray(String fieldName, @Nullable float[] val) throws PortableException { - stream.writeInt(val != null ? val.length : -1); - - if (val != null) - stream.writeFloatArray(val); - } - - /** {@inheritDoc} */ - @Override public void writeDoubleArray(String fieldName, @Nullable double[] val) throws PortableException { - stream.writeInt(val != null ? val.length : -1); - - if (val != null) - stream.writeDoubleArray(val); - } - - /** {@inheritDoc} */ - @Override public void writeCharArray(String fieldName, @Nullable char[] val) throws PortableException { - stream.writeInt(val != null ? val.length : -1); - - if (val != null) - stream.writeCharArray(val); - } - - /** {@inheritDoc} */ - @Override public void writeBooleanArray(String fieldName, @Nullable boolean[] val) throws PortableException { - stream.writeInt(val != null ? val.length : -1); - - if (val != null) - stream.writeBooleanArray(val); - } - - /** {@inheritDoc} */ - @Override public void writeObject(String fieldName, @Nullable Object obj) throws PortableException { - if (obj != null) { - assert obj instanceof GridTcpCommunicationMessageAdapter; - - stream.writeMessage((GridTcpCommunicationMessageAdapter)obj); - } - else - stream.writeByte(Byte.MIN_VALUE); - } - - /** {@inheritDoc} */ - @Override public void writeDecimal(String fieldName, @Nullable BigDecimal val) throws PortableException { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Override public void writeString(String fieldName, @Nullable String val) throws PortableException { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Override public void writeUuid(String fieldName, @Nullable UUID val) throws PortableException { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Override public void writeDate(String fieldName, @Nullable Date val) throws PortableException { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Override public void writeTimestamp(String fieldName, @Nullable Timestamp val) throws PortableException { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Override public void writeDecimalArray(String fieldName, @Nullable BigDecimal[] val) throws PortableException { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Override public void writeStringArray(String fieldName, @Nullable String[] val) throws PortableException { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Override public void writeUuidArray(String fieldName, @Nullable UUID[] val) throws PortableException { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Override public void writeDateArray(String fieldName, @Nullable Date[] val) throws PortableException { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Override public void writeObjectArray(String fieldName, @Nullable Object[] val) throws PortableException { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Override public void writeCollection(String fieldName, @Nullable Collection col) throws PortableException { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Override public void writeMap(String fieldName, @Nullable Map map) throws PortableException { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Override public > void writeEnum(String fieldName, T val) throws PortableException { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Override public > void writeEnumArray(String fieldName, T[] val) throws PortableException { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Override public PortableRawWriter rawWriter() { - throw new UnsupportedOperationException(); - } -} diff --git a/modules/core/src/main/java/org/gridgain/grid/util/nio/GridDirectParser.java b/modules/core/src/main/java/org/gridgain/grid/util/nio/GridDirectParser.java index cacb9808d4b33..eadcd992f2648 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/nio/GridDirectParser.java +++ b/modules/core/src/main/java/org/gridgain/grid/util/nio/GridDirectParser.java @@ -10,6 +10,7 @@ package org.gridgain.grid.util.nio; import org.apache.ignite.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.spi.*; import org.gridgain.grid.util.direct.*; import org.jetbrains.annotations.*; @@ -28,7 +29,7 @@ public class GridDirectParser implements GridNioParser { private IgniteSpiAdapter spi; /** */ - private GridTcpMessageFactory msgFactory; + private MessageFactory msgFactory; /** * @param spi Spi. diff --git a/modules/core/src/test/java/org/gridgain/testframework/GridSpiTestContext.java b/modules/core/src/test/java/org/gridgain/testframework/GridSpiTestContext.java index dee09517fe434..5f380a5fc55f4 100644 --- a/modules/core/src/test/java/org/gridgain/testframework/GridSpiTestContext.java +++ b/modules/core/src/test/java/org/gridgain/testframework/GridSpiTestContext.java @@ -13,6 +13,7 @@ import org.apache.ignite.cluster.*; import org.apache.ignite.events.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.plugin.security.*; import org.apache.ignite.spi.*; import org.apache.ignite.spi.discovery.*; @@ -509,8 +510,8 @@ public void triggerEvent(IgniteEvent evt) { } /** {@inheritDoc} */ - @Override public GridTcpMessageFactory messageFactory() { - return new GridTcpMessageFactory() { + @Override public MessageFactory messageFactory() { + return new MessageFactory() { @Override public GridTcpCommunicationMessageAdapter create(byte type) { return GridTcpCommunicationMessageFactory.create(type); } From 2c4a36cfee9a57bd48b7c872f332eee88771e7bc Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Fri, 26 Dec 2014 18:24:29 -0800 Subject: [PATCH 12/95] IGNITE-61 - Portable format in direct marshalling --- .../jobstealing/JobStealingRequest.java | 6 +- .../grid/kernal/GridJobCancelRequest.java | 18 +-- .../grid/kernal/GridJobExecuteRequest.java | 132 ++++++++---------- .../grid/kernal/GridJobExecuteRequestV2.java | 6 +- .../grid/kernal/GridJobExecuteResponse.java | 42 ++---- .../grid/kernal/GridJobSiblingsRequest.java | 12 +- .../grid/kernal/GridJobSiblingsResponse.java | 6 +- .../grid/kernal/GridTaskCancelRequest.java | 6 +- .../grid/kernal/GridTaskSessionRequest.java | 18 +-- .../checkpoint/GridCheckpointRequest.java | 18 +-- .../managers/communication/GridIoMessage.java | 42 +++--- .../communication/GridIoUserMessage.java | 46 +++--- .../deployment/GridDeploymentInfoBean.java | 34 ++--- .../deployment/GridDeploymentRequest.java | 32 ++--- .../deployment/GridDeploymentResponse.java | 18 +-- .../eventstorage/GridEventStorageMessage.java | 58 +++----- .../cache/GridCacheEvictionRequest.java | 18 ++- .../cache/GridCacheEvictionResponse.java | 20 +-- .../processors/cache/GridCacheMessage.java | 18 ++- ...CacheOptimisticCheckPreparedTxRequest.java | 24 ++-- ...acheOptimisticCheckPreparedTxResponse.java | 18 +-- ...chePessimisticCheckCommittedTxRequest.java | 36 ++--- ...hePessimisticCheckCommittedTxResponse.java | 18 +-- .../GridDistributedBaseMessage.java | 34 ++--- .../GridDistributedLockRequest.java | 100 ++++++------- .../GridDistributedLockResponse.java | 20 ++- .../GridDistributedTxFinishRequest.java | 104 +++++++------- .../GridDistributedTxFinishResponse.java | 12 +- .../GridDistributedTxPrepareRequest.java | 114 +++++++-------- .../GridDistributedTxPrepareResponse.java | 12 +- .../GridDistributedUnlockRequest.java | 8 +- .../dht/GridDhtAffinityAssignmentRequest.java | 6 +- .../GridDhtAffinityAssignmentResponse.java | 12 +- .../distributed/dht/GridDhtLockRequest.java | 50 +++---- .../distributed/dht/GridDhtLockResponse.java | 34 +++-- .../dht/GridDhtTxFinishRequest.java | 88 ++++++------ .../dht/GridDhtTxFinishResponse.java | 6 +- .../dht/GridDhtTxPrepareRequest.java | 96 ++++++------- .../dht/GridDhtTxPrepareResponse.java | 40 +++--- .../distributed/dht/GridDhtUnlockRequest.java | 8 +- .../GridDhtAtomicDeferredUpdateResponse.java | 8 +- .../atomic/GridDhtAtomicUpdateRequest.java | 122 ++++++++-------- .../atomic/GridDhtAtomicUpdateResponse.java | 26 ++-- .../atomic/GridNearAtomicUpdateRequest.java | 116 +++++++-------- .../atomic/GridNearAtomicUpdateResponse.java | 74 ++++------ .../preloader/GridDhtForceKeysRequest.java | 26 ++-- .../preloader/GridDhtForceKeysResponse.java | 26 ++-- .../GridDhtPartitionDemandMessage.java | 42 +++--- .../GridDhtPartitionSupplyMessage.java | 48 +++---- .../GridDhtPartitionsAbstractMessage.java | 12 +- .../GridDhtPartitionsFullMessage.java | 18 +-- .../GridDhtPartitionsSingleMessage.java | 6 +- .../distributed/near/GridNearGetRequest.java | 64 ++++----- .../distributed/near/GridNearGetResponse.java | 48 +++---- .../distributed/near/GridNearLockRequest.java | 82 ++++++----- .../near/GridNearLockResponse.java | 36 +++-- .../near/GridNearTxFinishRequest.java | 50 ++++--- .../near/GridNearTxFinishResponse.java | 18 +-- .../near/GridNearTxPrepareRequest.java | 65 ++++----- .../near/GridNearTxPrepareResponse.java | 46 +++--- .../cache/query/GridCacheQueryRequest.java | 114 +++++++-------- .../cache/query/GridCacheQueryResponse.java | 40 +++--- .../clock/GridClockDeltaSnapshotMessage.java | 20 ++- .../continuous/GridContinuousMessage.java | 18 +-- .../dataload/GridDataLoadRequest.java | 76 ++++------ .../dataload/GridDataLoadResponse.java | 18 ++- .../processors/ggfs/GridGgfsAckMessage.java | 18 +-- .../processors/ggfs/GridGgfsBlockKey.java | 24 ++-- .../ggfs/GridGgfsBlocksMessage.java | 25 ++-- .../ggfs/GridGgfsDeleteMessage.java | 12 +- .../ggfs/GridGgfsFileAffinityRange.java | 30 ++-- .../ggfs/GridGgfsFragmentizerRequest.java | 16 +-- .../ggfs/GridGgfsFragmentizerResponse.java | 6 +- .../processors/ggfs/GridGgfsSyncMessage.java | 12 +- .../GridClientHandshakeRequestWrapper.java | 6 +- .../GridClientHandshakeResponseWrapper.java | 6 +- .../message/GridClientMessageWrapper.java | 30 ++-- .../message/GridClientPingPacketWrapper.java | 6 +- .../handlers/task/GridTaskResultRequest.java | 12 +- .../handlers/task/GridTaskResultResponse.java | 24 ++-- .../tcp/GridMemcachedMessageWrapper.java | 6 +- .../streamer/GridStreamerCancelRequest.java | 6 +- .../GridStreamerExecutionRequest.java | 46 +++--- .../streamer/GridStreamerResponse.java | 12 +- .../GridTcpCommunicationMessageAdapter.java | 90 ++++++++++++ .../GridTcpCommunicationMessageState.java | 4 + 86 files changed, 1339 insertions(+), 1661 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java b/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java index a6c3346914f8f..ff7728568a7c7 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java @@ -94,11 +94,11 @@ int delta() { switch (commState.idx) { case 0: - if (buf.remaining() < 4) - return false; - delta = commState.getInt("delta"); + if (!commState.lastRead()) + return false; + commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobCancelRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobCancelRequest.java index 00fc2e5df4008..40b6e36926f2c 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobCancelRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobCancelRequest.java @@ -163,31 +163,27 @@ public boolean system() { switch (commState.idx) { case 0: - IgniteUuid jobId0 = commState.getGridUuid("jobId"); + jobId = commState.getGridUuid("jobId"); - if (jobId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - jobId = jobId0; - commState.idx++; case 1: - IgniteUuid sesId0 = commState.getGridUuid("sesId"); + sesId = commState.getGridUuid("sesId"); - if (sesId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - sesId = sesId0; - commState.idx++; case 2: - if (buf.remaining() < 1) - return false; - sys = commState.getBoolean("sys"); + if (!commState.lastRead()) + return false; + commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobExecuteRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobExecuteRequest.java index c7e3bcca30f94..fca9df87858c3 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobExecuteRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobExecuteRequest.java @@ -647,103 +647,93 @@ public UUID getSubjectId() { switch (commState.idx) { case 0: - IgniteUuid clsLdrId0 = commState.getGridUuid("clsLdrId"); + clsLdrId = commState.getGridUuid("clsLdrId"); - if (clsLdrId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - clsLdrId = clsLdrId0; - commState.idx++; case 1: - String cpSpi0 = commState.getString("cpSpi"); + cpSpi = commState.getString("cpSpi"); - if (cpSpi0 == STR_NOT_READ) + if (!commState.lastRead()) return false; - cpSpi = cpSpi0; - commState.idx++; case 2: - if (buf.remaining() < 8) - return false; - createTime = commState.getLong("createTime"); + if (!commState.lastRead()) + return false; + commState.idx++; case 3: - if (buf.remaining() < 1) - return false; - byte depMode0 = commState.getByte("depMode"); + if (!commState.lastRead()) + return false; + depMode = IgniteDeploymentMode.fromOrdinal(depMode0); commState.idx++; case 4: - if (buf.remaining() < 1) - return false; - dynamicSiblings = commState.getBoolean("dynamicSiblings"); + if (!commState.lastRead()) + return false; + commState.idx++; case 5: - if (buf.remaining() < 1) - return false; - forceLocDep = commState.getBoolean("forceLocDep"); + if (!commState.lastRead()) + return false; + commState.idx++; case 6: - if (buf.remaining() < 1) - return false; - internal = commState.getBoolean("internal"); + if (!commState.lastRead()) + return false; + commState.idx++; case 7: - byte[] jobAttrsBytes0 = commState.getByteArray("jobAttrsBytes"); + jobAttrsBytes = commState.getByteArray("jobAttrsBytes"); - if (jobAttrsBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - jobAttrsBytes = jobAttrsBytes0; - commState.idx++; case 8: - byte[] jobBytes0 = commState.getByteArray("jobBytes"); + jobBytes = commState.getByteArray("jobBytes"); - if (jobBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - jobBytes = jobBytes0; - commState.idx++; case 9: - IgniteUuid jobId0 = commState.getGridUuid("jobId"); + jobId = commState.getGridUuid("jobId"); - if (jobId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - jobId = jobId0; - commState.idx++; case 10: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -754,7 +744,7 @@ public UUID getSubjectId() { if (!commState.keyDone) { UUID _val = commState.getUuid(null); - if (_val == UUID_NOT_READ) + if (!commState.lastRead()) return false; commState.cur = _val; @@ -763,7 +753,7 @@ public UUID getSubjectId() { IgniteUuid _val = commState.getGridUuid(null); - if (_val == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; ldrParticipants.put((UUID)commState.cur, _val); @@ -781,85 +771,75 @@ public UUID getSubjectId() { commState.idx++; case 11: - byte[] sesAttrsBytes0 = commState.getByteArray("sesAttrsBytes"); + sesAttrsBytes = commState.getByteArray("sesAttrsBytes"); - if (sesAttrsBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - sesAttrsBytes = sesAttrsBytes0; - commState.idx++; case 12: - if (buf.remaining() < 1) - return false; - sesFullSup = commState.getBoolean("sesFullSup"); + if (!commState.lastRead()) + return false; + commState.idx++; case 13: - IgniteUuid sesId0 = commState.getGridUuid("sesId"); + sesId = commState.getGridUuid("sesId"); - if (sesId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - sesId = sesId0; - commState.idx++; case 14: - byte[] siblingsBytes0 = commState.getByteArray("siblingsBytes"); + siblingsBytes = commState.getByteArray("siblingsBytes"); - if (siblingsBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - siblingsBytes = siblingsBytes0; - commState.idx++; case 15: - if (buf.remaining() < 8) - return false; - startTaskTime = commState.getLong("startTaskTime"); + if (!commState.lastRead()) + return false; + commState.idx++; case 16: - String taskClsName0 = commState.getString("taskClsName"); + taskClsName = commState.getString("taskClsName"); - if (taskClsName0 == STR_NOT_READ) + if (!commState.lastRead()) return false; - taskClsName = taskClsName0; - commState.idx++; case 17: - String taskName0 = commState.getString("taskName"); + taskName = commState.getString("taskName"); - if (taskName0 == STR_NOT_READ) + if (!commState.lastRead()) return false; - taskName = taskName0; - commState.idx++; case 18: - if (buf.remaining() < 8) - return false; - timeout = commState.getLong("timeout"); + if (!commState.lastRead()) + return false; + commState.idx++; case 19: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -869,7 +849,7 @@ public UUID getSubjectId() { for (int i = commState.readItems; i < commState.readSize; i++) { UUID _val = commState.getUuid(null); - if (_val == UUID_NOT_READ) + if (!commState.lastRead()) return false; top.add((UUID)_val); @@ -884,13 +864,11 @@ public UUID getSubjectId() { commState.idx++; case 20: - String userVer0 = commState.getString("userVer"); + userVer = commState.getString("userVer"); - if (userVer0 == STR_NOT_READ) + if (!commState.lastRead()) return false; - userVer = userVer0; - commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobExecuteRequestV2.java b/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobExecuteRequestV2.java index 9e3e5836449f1..fb4d9e504572b 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobExecuteRequestV2.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobExecuteRequestV2.java @@ -156,13 +156,11 @@ public GridJobExecuteRequestV2( switch (commState.idx) { case 21: - UUID subjId0 = commState.getUuid("subjId"); + subjId = commState.getUuid("subjId"); - if (subjId0 == UUID_NOT_READ) + if (!commState.lastRead()) return false; - subjId = subjId0; - commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobExecuteResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobExecuteResponse.java index 2ef82d8afb634..ca0f0e264aac4 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobExecuteResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobExecuteResponse.java @@ -282,71 +282,59 @@ public void setFakeException(IgniteCheckedException fakeEx) { switch (commState.idx) { case 0: - byte[] gridExBytes0 = commState.getByteArray("gridExBytes"); + gridExBytes = commState.getByteArray("gridExBytes"); - if (gridExBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - gridExBytes = gridExBytes0; - commState.idx++; case 1: - if (buf.remaining() < 1) - return false; - isCancelled = commState.getBoolean("isCancelled"); + if (!commState.lastRead()) + return false; + commState.idx++; case 2: - byte[] jobAttrsBytes0 = commState.getByteArray("jobAttrsBytes"); + jobAttrsBytes = commState.getByteArray("jobAttrsBytes"); - if (jobAttrsBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - jobAttrsBytes = jobAttrsBytes0; - commState.idx++; case 3: - IgniteUuid jobId0 = commState.getGridUuid("jobId"); + jobId = commState.getGridUuid("jobId"); - if (jobId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - jobId = jobId0; - commState.idx++; case 4: - UUID nodeId0 = commState.getUuid("nodeId"); + nodeId = commState.getUuid("nodeId"); - if (nodeId0 == UUID_NOT_READ) + if (!commState.lastRead()) return false; - nodeId = nodeId0; - commState.idx++; case 5: - byte[] resBytes0 = commState.getByteArray("resBytes"); + resBytes = commState.getByteArray("resBytes"); - if (resBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - resBytes = resBytes0; - commState.idx++; case 6: - IgniteUuid sesId0 = commState.getGridUuid("sesId"); + sesId = commState.getGridUuid("sesId"); - if (sesId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - sesId = sesId0; - commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobSiblingsRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobSiblingsRequest.java index 31bf8e0b4c883..36bac1d371709 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobSiblingsRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobSiblingsRequest.java @@ -131,23 +131,19 @@ public byte[] topicBytes() { switch (commState.idx) { case 0: - IgniteUuid sesId0 = commState.getGridUuid("sesId"); + sesId = commState.getGridUuid("sesId"); - if (sesId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - sesId = sesId0; - commState.idx++; case 1: - byte[] topicBytes0 = commState.getByteArray("topicBytes"); + topicBytes = commState.getByteArray("topicBytes"); - if (topicBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - topicBytes = topicBytes0; - commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobSiblingsResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobSiblingsResponse.java index 81821b1cf054e..1975acbeb38a9 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobSiblingsResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/GridJobSiblingsResponse.java @@ -117,13 +117,11 @@ public void unmarshalSiblings(IgniteMarshaller marsh) throws IgniteCheckedExcept switch (commState.idx) { case 0: - byte[] siblingsBytes0 = commState.getByteArray("siblingsBytes"); + siblingsBytes = commState.getByteArray("siblingsBytes"); - if (siblingsBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - siblingsBytes = siblingsBytes0; - commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/GridTaskCancelRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/GridTaskCancelRequest.java index d1ae10161fcac..640ef5846f95f 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/GridTaskCancelRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/GridTaskCancelRequest.java @@ -100,13 +100,11 @@ public IgniteUuid sessionId() { switch (commState.idx) { case 0: - IgniteUuid sesId0 = commState.getGridUuid("sesId"); + sesId = commState.getGridUuid("sesId"); - if (sesId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - sesId = sesId0; - commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/GridTaskSessionRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/GridTaskSessionRequest.java index 8c9c63e21c4cc..337c035c9a034 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/GridTaskSessionRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/GridTaskSessionRequest.java @@ -152,33 +152,27 @@ public IgniteUuid getJobId() { switch (commState.idx) { case 0: - byte[] attrsBytes0 = commState.getByteArray("attrsBytes"); + attrsBytes = commState.getByteArray("attrsBytes"); - if (attrsBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - attrsBytes = attrsBytes0; - commState.idx++; case 1: - IgniteUuid jobId0 = commState.getGridUuid("jobId"); + jobId = commState.getGridUuid("jobId"); - if (jobId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - jobId = jobId0; - commState.idx++; case 2: - IgniteUuid sesId0 = commState.getGridUuid("sesId"); + sesId = commState.getGridUuid("sesId"); - if (sesId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - sesId = sesId0; - commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/checkpoint/GridCheckpointRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/checkpoint/GridCheckpointRequest.java index 8932cc3397cb5..117de443783ad 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/checkpoint/GridCheckpointRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/checkpoint/GridCheckpointRequest.java @@ -137,33 +137,27 @@ public String getCheckpointSpi() { switch (commState.idx) { case 0: - String cpSpi0 = commState.getString("cpSpi"); + cpSpi = commState.getString("cpSpi"); - if (cpSpi0 == STR_NOT_READ) + if (!commState.lastRead()) return false; - cpSpi = cpSpi0; - commState.idx++; case 1: - String key0 = commState.getString("key"); + key = commState.getString("key"); - if (key0 == STR_NOT_READ) + if (!commState.lastRead()) return false; - key = key0; - commState.idx++; case 2: - IgniteUuid sesId0 = commState.getGridUuid("sesId"); + sesId = commState.getGridUuid("sesId"); - if (sesId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - sesId = sesId0; - commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/communication/GridIoMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/communication/GridIoMessage.java index 098f52a53f73f..2c5f7258e37fb 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/communication/GridIoMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/communication/GridIoMessage.java @@ -275,65 +275,61 @@ boolean isOrdered() { switch (commState.idx) { case 0: - Object msg0 = commState.getMessage("msg"); + msg = (GridTcpCommunicationMessageAdapter)commState.getMessage("msg"); - if (msg0 == MSG_NOT_READ) + if (!commState.lastRead()) return false; - msg = (GridTcpCommunicationMessageAdapter)msg0; - commState.idx++; case 1: - if (buf.remaining() < 8) - return false; - msgId = commState.getLong("msgId"); + if (!commState.lastRead()) + return false; + commState.idx++; case 2: - if (buf.remaining() < 1) - return false; - byte plc0 = commState.getByte("plc"); + if (!commState.lastRead()) + return false; + plc = GridIoPolicy.fromOrdinal(plc0); commState.idx++; case 3: - if (buf.remaining() < 1) - return false; - skipOnTimeout = commState.getBoolean("skipOnTimeout"); + if (!commState.lastRead()) + return false; + commState.idx++; case 4: - if (buf.remaining() < 8) - return false; - timeout = commState.getLong("timeout"); + if (!commState.lastRead()) + return false; + commState.idx++; case 5: - byte[] topicBytes0 = commState.getByteArray("topicBytes"); + topicBytes = commState.getByteArray("topicBytes"); - if (topicBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - topicBytes = topicBytes0; - commState.idx++; case 6: - if (buf.remaining() < 4) - return false; - topicOrd = commState.getInt("topicOrd"); + if (!commState.lastRead()) + return false; + commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/communication/GridIoUserMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/communication/GridIoUserMessage.java index 3c5c459ae8d15..96ea5b5b73987 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/communication/GridIoUserMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/communication/GridIoUserMessage.java @@ -319,51 +319,45 @@ public void deployment(GridDeployment dep) { switch (commState.idx) { case 0: - byte[] bodyBytes0 = commState.getByteArray("bodyBytes"); + bodyBytes = commState.getByteArray("bodyBytes"); - if (bodyBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - bodyBytes = bodyBytes0; - commState.idx++; case 1: - IgniteUuid clsLdrId0 = commState.getGridUuid("clsLdrId"); + clsLdrId = commState.getGridUuid("clsLdrId"); - if (clsLdrId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - clsLdrId = clsLdrId0; - commState.idx++; case 2: - String depClsName0 = commState.getString("depClsName"); + depClsName = commState.getString("depClsName"); - if (depClsName0 == STR_NOT_READ) + if (!commState.lastRead()) return false; - depClsName = depClsName0; - commState.idx++; case 3: - if (buf.remaining() < 1) - return false; - byte depMode0 = commState.getByte("depMode"); + if (!commState.lastRead()) + return false; + depMode = IgniteDeploymentMode.fromOrdinal(depMode0); commState.idx++; case 4: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -374,7 +368,7 @@ public void deployment(GridDeployment dep) { if (!commState.keyDone) { UUID _val = commState.getUuid(null); - if (_val == UUID_NOT_READ) + if (!commState.lastRead()) return false; commState.cur = _val; @@ -383,7 +377,7 @@ public void deployment(GridDeployment dep) { IgniteUuid _val = commState.getGridUuid(null); - if (_val == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; ldrParties.put((UUID)commState.cur, _val); @@ -401,23 +395,19 @@ public void deployment(GridDeployment dep) { commState.idx++; case 5: - byte[] topicBytes0 = commState.getByteArray("topicBytes"); + topicBytes = commState.getByteArray("topicBytes"); - if (topicBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - topicBytes = topicBytes0; - commState.idx++; case 6: - String userVer0 = commState.getString("userVer"); + userVer = commState.getString("userVer"); - if (userVer0 == STR_NOT_READ) + if (!commState.lastRead()) return false; - userVer = userVer0; - commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/deployment/GridDeploymentInfoBean.java b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/deployment/GridDeploymentInfoBean.java index f9d1d85e1a557..599ff25f50ace 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/deployment/GridDeploymentInfoBean.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/deployment/GridDeploymentInfoBean.java @@ -237,39 +237,37 @@ public void localDeploymentOwner(boolean locDepOwner) { switch (commState.idx) { case 0: - IgniteUuid clsLdrId0 = commState.getGridUuid("clsLdrId"); + clsLdrId = commState.getGridUuid("clsLdrId"); - if (clsLdrId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - clsLdrId = clsLdrId0; - commState.idx++; case 1: - if (buf.remaining() < 1) - return false; - byte depMode0 = commState.getByte("depMode"); + if (!commState.lastRead()) + return false; + depMode = IgniteDeploymentMode.fromOrdinal(depMode0); commState.idx++; case 2: - if (buf.remaining() < 1) - return false; - locDepOwner = commState.getBoolean("locDepOwner"); + if (!commState.lastRead()) + return false; + commState.idx++; case 3: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -280,7 +278,7 @@ public void localDeploymentOwner(boolean locDepOwner) { if (!commState.keyDone) { UUID _val = commState.getUuid(null); - if (_val == UUID_NOT_READ) + if (!commState.lastRead()) return false; commState.cur = _val; @@ -289,7 +287,7 @@ public void localDeploymentOwner(boolean locDepOwner) { IgniteUuid _val = commState.getGridUuid(null); - if (_val == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; participants.put((UUID)commState.cur, _val); @@ -307,13 +305,11 @@ public void localDeploymentOwner(boolean locDepOwner) { commState.idx++; case 4: - String userVer0 = commState.getString("userVer"); + userVer = commState.getString("userVer"); - if (userVer0 == STR_NOT_READ) + if (!commState.lastRead()) return false; - userVer = userVer0; - commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/deployment/GridDeploymentRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/deployment/GridDeploymentRequest.java index 3dcc483f56e7a..ca3edfe28b474 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/deployment/GridDeploymentRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/deployment/GridDeploymentRequest.java @@ -245,29 +245,27 @@ public void nodeIds(Collection nodeIds) { switch (commState.idx) { case 0: - if (buf.remaining() < 1) - return false; - isUndeploy = commState.getBoolean("isUndeploy"); + if (!commState.lastRead()) + return false; + commState.idx++; case 1: - IgniteUuid ldrId0 = commState.getGridUuid("ldrId"); + ldrId = commState.getGridUuid("ldrId"); - if (ldrId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - ldrId = ldrId0; - commState.idx++; case 2: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -277,7 +275,7 @@ public void nodeIds(Collection nodeIds) { for (int i = commState.readItems; i < commState.readSize; i++) { UUID _val = commState.getUuid(null); - if (_val == UUID_NOT_READ) + if (!commState.lastRead()) return false; nodeIds.add((UUID)_val); @@ -292,23 +290,19 @@ public void nodeIds(Collection nodeIds) { commState.idx++; case 3: - byte[] resTopicBytes0 = commState.getByteArray("resTopicBytes"); + resTopicBytes = commState.getByteArray("resTopicBytes"); - if (resTopicBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - resTopicBytes = resTopicBytes0; - commState.idx++; case 4: - String rsrcName0 = commState.getString("rsrcName"); + rsrcName = commState.getString("rsrcName"); - if (rsrcName0 == STR_NOT_READ) + if (!commState.lastRead()) return false; - rsrcName = rsrcName0; - commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/deployment/GridDeploymentResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/deployment/GridDeploymentResponse.java index bf0a4b6780b27..7c63d917b20f0 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/deployment/GridDeploymentResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/deployment/GridDeploymentResponse.java @@ -160,31 +160,27 @@ void errorMessage(String errMsg) { switch (commState.idx) { case 0: - GridByteArrayList byteSrc0 = commState.getByteArrayList("byteSrc"); + byteSrc = commState.getByteArrayList("byteSrc"); - if (byteSrc0 == BYTE_ARR_LIST_NOT_READ) + if (!commState.lastRead()) return false; - byteSrc = byteSrc0; - commState.idx++; case 1: - String errMsg0 = commState.getString("errMsg"); + errMsg = commState.getString("errMsg"); - if (errMsg0 == STR_NOT_READ) + if (!commState.lastRead()) return false; - errMsg = errMsg0; - commState.idx++; case 2: - if (buf.remaining() < 1) - return false; - success = commState.getBoolean("success"); + if (!commState.lastRead()) + return false; + commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/eventstorage/GridEventStorageMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/eventstorage/GridEventStorageMessage.java index 4b5543cf146c1..97db9173a7a37 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/eventstorage/GridEventStorageMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/eventstorage/GridEventStorageMessage.java @@ -391,71 +391,61 @@ void exceptionBytes(byte[] exBytes) { switch (commState.idx) { case 0: - IgniteUuid clsLdrId0 = commState.getGridUuid("clsLdrId"); + clsLdrId = commState.getGridUuid("clsLdrId"); - if (clsLdrId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - clsLdrId = clsLdrId0; - commState.idx++; case 1: - if (buf.remaining() < 1) - return false; - byte depMode0 = commState.getByte("depMode"); + if (!commState.lastRead()) + return false; + depMode = IgniteDeploymentMode.fromOrdinal(depMode0); commState.idx++; case 2: - byte[] evtsBytes0 = commState.getByteArray("evtsBytes"); + evtsBytes = commState.getByteArray("evtsBytes"); - if (evtsBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - evtsBytes = evtsBytes0; - commState.idx++; case 3: - byte[] exBytes0 = commState.getByteArray("exBytes"); + exBytes = commState.getByteArray("exBytes"); - if (exBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - exBytes = exBytes0; - commState.idx++; case 4: - byte[] filter0 = commState.getByteArray("filter"); + filter = commState.getByteArray("filter"); - if (filter0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - filter = filter0; - commState.idx++; case 5: - String filterClsName0 = commState.getString("filterClsName"); + filterClsName = commState.getString("filterClsName"); - if (filterClsName0 == STR_NOT_READ) + if (!commState.lastRead()) return false; - filterClsName = filterClsName0; - commState.idx++; case 6: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -466,7 +456,7 @@ void exceptionBytes(byte[] exBytes) { if (!commState.keyDone) { UUID _val = commState.getUuid(null); - if (_val == UUID_NOT_READ) + if (!commState.lastRead()) return false; commState.cur = _val; @@ -475,7 +465,7 @@ void exceptionBytes(byte[] exBytes) { IgniteUuid _val = commState.getGridUuid(null); - if (_val == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; ldrParties.put((UUID)commState.cur, _val); @@ -493,23 +483,19 @@ void exceptionBytes(byte[] exBytes) { commState.idx++; case 7: - byte[] resTopicBytes0 = commState.getByteArray("resTopicBytes"); + resTopicBytes = commState.getByteArray("resTopicBytes"); - if (resTopicBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - resTopicBytes = resTopicBytes0; - commState.idx++; case 8: - String userVer0 = commState.getString("userVer"); + userVer = commState.getString("userVer"); - if (userVer0 == STR_NOT_READ) + if (!commState.lastRead()) return false; - userVer = userVer0; - commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEvictionRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEvictionRequest.java index 3c3bd83a92bda..dca0c24b59841 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEvictionRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEvictionRequest.java @@ -201,29 +201,27 @@ void addKey(K key, GridCacheVersion ver, boolean near) { switch (commState.idx) { case 3: - byte[] entriesBytes0 = commState.getByteArray("entriesBytes"); + entriesBytes = commState.getByteArray("entriesBytes"); - if (entriesBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - entriesBytes = entriesBytes0; - commState.idx++; case 4: - if (buf.remaining() < 8) - return false; - futId = commState.getLong("futId"); + if (!commState.lastRead()) + return false; + commState.idx++; case 5: - if (buf.remaining() < 8) - return false; - topVer = commState.getLong("topVer"); + if (!commState.lastRead()) + return false; + commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEvictionResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEvictionResponse.java index a14604af94354..9bdce8f18a607 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEvictionResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheEvictionResponse.java @@ -212,27 +212,27 @@ boolean error() { switch (commState.idx) { case 3: - if (buf.remaining() < 1) - return false; - err = commState.getBoolean("err"); + if (!commState.lastRead()) + return false; + commState.idx++; case 4: - if (buf.remaining() < 8) - return false; - futId = commState.getLong("futId"); + if (!commState.lastRead()) + return false; + commState.idx++; case 5: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -242,7 +242,7 @@ boolean error() { for (int i = commState.readItems; i < commState.readSize; i++) { byte[] _val = commState.getByteArray(null); - if (_val == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; rejectedKeyBytes.add((byte[])_val); diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMessage.java index 7b7ab7124a030..1d908485b392d 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheMessage.java @@ -624,29 +624,27 @@ protected final void unmarshalTx(Iterable> txEntries, boolea switch (commState.idx) { case 0: - if (buf.remaining() < 4) - return false; - cacheId = commState.getInt("cacheId"); + if (!commState.lastRead()) + return false; + commState.idx++; case 1: - Object depInfo0 = commState.getMessage("depInfo"); + depInfo = (GridDeploymentInfoBean)commState.getMessage("depInfo"); - if (depInfo0 == MSG_NOT_READ) + if (!commState.lastRead()) return false; - depInfo = (GridDeploymentInfoBean)depInfo0; - commState.idx++; case 2: - if (buf.remaining() < 8) - return false; - msgId = commState.getLong("msgId"); + if (!commState.lastRead()) + return false; + commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxRequest.java index 30b3b65a90988..8e995c204f4e7 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxRequest.java @@ -165,41 +165,35 @@ public int transactions() { switch (commState.idx) { case 8: - IgniteUuid futId0 = commState.getGridUuid("futId"); + futId = commState.getGridUuid("futId"); - if (futId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - futId = futId0; - commState.idx++; case 9: - IgniteUuid miniId0 = commState.getGridUuid("miniId"); + miniId = commState.getGridUuid("miniId"); - if (miniId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - miniId = miniId0; - commState.idx++; case 10: - GridCacheVersion nearXidVer0 = commState.getCacheVersion("nearXidVer"); + nearXidVer = commState.getCacheVersion("nearXidVer"); - if (nearXidVer0 == CACHE_VER_NOT_READ) + if (!commState.lastRead()) return false; - nearXidVer = nearXidVer0; - commState.idx++; case 11: - if (buf.remaining() < 4) - return false; - txNum = commState.getInt("txNum"); + if (!commState.lastRead()) + return false; + commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxResponse.java index 4bfda3dc9388d..62b8cb2c3d225 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxResponse.java @@ -146,31 +146,27 @@ public boolean success() { switch (commState.idx) { case 8: - IgniteUuid futId0 = commState.getGridUuid("futId"); + futId = commState.getGridUuid("futId"); - if (futId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - futId = futId0; - commState.idx++; case 9: - IgniteUuid miniId0 = commState.getGridUuid("miniId"); + miniId = commState.getGridUuid("miniId"); - if (miniId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - miniId = miniId0; - commState.idx++; case 10: - if (buf.remaining() < 1) - return false; - success = commState.getBoolean("success"); + if (!commState.lastRead()) + return false; + commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxRequest.java index 92347bdd44f9c..0302063a0a870 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxRequest.java @@ -212,59 +212,51 @@ public boolean nearOnlyCheck() { switch (commState.idx) { case 8: - IgniteUuid futId0 = commState.getGridUuid("futId"); + futId = commState.getGridUuid("futId"); - if (futId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - futId = futId0; - commState.idx++; case 9: - IgniteUuid miniId0 = commState.getGridUuid("miniId"); + miniId = commState.getGridUuid("miniId"); - if (miniId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - miniId = miniId0; - commState.idx++; case 10: - GridCacheVersion nearXidVer0 = commState.getCacheVersion("nearXidVer"); + nearXidVer = commState.getCacheVersion("nearXidVer"); - if (nearXidVer0 == CACHE_VER_NOT_READ) + if (!commState.lastRead()) return false; - nearXidVer = nearXidVer0; - commState.idx++; case 11: - UUID originatingNodeId0 = commState.getUuid("originatingNodeId"); + originatingNodeId = commState.getUuid("originatingNodeId"); - if (originatingNodeId0 == UUID_NOT_READ) + if (!commState.lastRead()) return false; - originatingNodeId = originatingNodeId0; - commState.idx++; case 12: - if (buf.remaining() < 8) - return false; - originatingThreadId = commState.getLong("originatingThreadId"); + if (!commState.lastRead()) + return false; + commState.idx++; case 13: - if (buf.remaining() < 1) - return false; - nearOnlyCheck = commState.getBoolean("nearOnlyCheck"); + if (!commState.lastRead()) + return false; + commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxResponse.java index 19cfbb824fc8f..c616a22705dbf 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxResponse.java @@ -177,33 +177,27 @@ public GridCacheCommittedTxInfo committedTxInfo() { switch (commState.idx) { case 8: - byte[] committedTxInfoBytes0 = commState.getByteArray("committedTxInfoBytes"); + committedTxInfoBytes = commState.getByteArray("committedTxInfoBytes"); - if (committedTxInfoBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - committedTxInfoBytes = committedTxInfoBytes0; - commState.idx++; case 9: - IgniteUuid futId0 = commState.getGridUuid("futId"); + futId = commState.getGridUuid("futId"); - if (futId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - futId = futId0; - commState.idx++; case 10: - IgniteUuid miniId0 = commState.getGridUuid("miniId"); + miniId = commState.getGridUuid("miniId"); - if (miniId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - miniId = miniId0; - commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedBaseMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedBaseMessage.java index 3709cd951122c..669e8445217b1 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedBaseMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedBaseMessage.java @@ -349,31 +349,27 @@ public int keysCount() { switch (commState.idx) { case 3: - byte[] candsByIdxBytes0 = commState.getByteArray("candsByIdxBytes"); + candsByIdxBytes = commState.getByteArray("candsByIdxBytes"); - if (candsByIdxBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - candsByIdxBytes = candsByIdxBytes0; - commState.idx++; case 4: - byte[] candsByKeyBytes0 = commState.getByteArray("candsByKeyBytes"); + candsByKeyBytes = commState.getByteArray("candsByKeyBytes"); - if (candsByKeyBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - candsByKeyBytes = candsByKeyBytes0; - commState.idx++; case 5: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -383,7 +379,7 @@ public int keysCount() { for (int i = commState.readItems; i < commState.readSize; i++) { GridCacheVersion _val = commState.getCacheVersion(null); - if (_val == CACHE_VER_NOT_READ) + if (!commState.lastRead()) return false; committedVers.add((GridCacheVersion)_val); @@ -399,10 +395,10 @@ public int keysCount() { case 6: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -412,7 +408,7 @@ public int keysCount() { for (int i = commState.readItems; i < commState.readSize; i++) { GridCacheVersion _val = commState.getCacheVersion(null); - if (_val == CACHE_VER_NOT_READ) + if (!commState.lastRead()) return false; rolledbackVers.add((GridCacheVersion)_val); @@ -427,13 +423,11 @@ public int keysCount() { commState.idx++; case 7: - GridCacheVersion ver0 = commState.getCacheVersion("ver"); + ver = commState.getCacheVersion("ver"); - if (ver0 == CACHE_VER_NOT_READ) + if (!commState.lastRead()) return false; - ver = ver0; - commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedLockRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedLockRequest.java index eab007293ca79..471482345633e 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedLockRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedLockRequest.java @@ -625,10 +625,10 @@ public GridCacheVersion[] drVersions() { switch (commState.idx) { case 8: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -638,7 +638,7 @@ public GridCacheVersion[] drVersions() { for (int i = commState.readItems; i < commState.readSize; i++) { GridCacheVersion _val = commState.getCacheVersion(null); - if (_val == CACHE_VER_NOT_READ) + if (!commState.lastRead()) return false; drVersByIdx[i] = (GridCacheVersion)_val; @@ -653,65 +653,61 @@ public GridCacheVersion[] drVersions() { commState.idx++; case 9: - IgniteUuid futId0 = commState.getGridUuid("futId"); + futId = commState.getGridUuid("futId"); - if (futId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - futId = futId0; - commState.idx++; case 10: - byte[] grpLockKeyBytes0 = commState.getByteArray("grpLockKeyBytes"); + grpLockKeyBytes = commState.getByteArray("grpLockKeyBytes"); - if (grpLockKeyBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - grpLockKeyBytes = grpLockKeyBytes0; - commState.idx++; case 11: - if (buf.remaining() < 1) - return false; - isInTx = commState.getBoolean("isInTx"); + if (!commState.lastRead()) + return false; + commState.idx++; case 12: - if (buf.remaining() < 1) - return false; - isInvalidate = commState.getBoolean("isInvalidate"); + if (!commState.lastRead()) + return false; + commState.idx++; case 13: - if (buf.remaining() < 1) - return false; - isRead = commState.getBoolean("isRead"); + if (!commState.lastRead()) + return false; + commState.idx++; case 14: - if (buf.remaining() < 1) - return false; - byte isolation0 = commState.getByte("isolation"); + if (!commState.lastRead()) + return false; + isolation = IgniteTxIsolation.fromOrdinal(isolation0); commState.idx++; case 15: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -721,7 +717,7 @@ public GridCacheVersion[] drVersions() { for (int i = commState.readItems; i < commState.readSize; i++) { byte[] _val = commState.getByteArray(null); - if (_val == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; keyBytes.add((byte[])_val); @@ -736,75 +732,67 @@ public GridCacheVersion[] drVersions() { commState.idx++; case 16: - GridCacheVersion nearXidVer0 = commState.getCacheVersion("nearXidVer"); + nearXidVer = commState.getCacheVersion("nearXidVer"); - if (nearXidVer0 == CACHE_VER_NOT_READ) + if (!commState.lastRead()) return false; - nearXidVer = nearXidVer0; - commState.idx++; case 17: - UUID nodeId0 = commState.getUuid("nodeId"); + nodeId = commState.getUuid("nodeId"); - if (nodeId0 == UUID_NOT_READ) + if (!commState.lastRead()) return false; - nodeId = nodeId0; - commState.idx++; case 18: - if (buf.remaining() < 1) - return false; - partLock = commState.getBoolean("partLock"); + if (!commState.lastRead()) + return false; + commState.idx++; case 19: - boolean[] retVals0 = commState.getBooleanArray("retVals"); + retVals = commState.getBooleanArray("retVals"); - if (retVals0 == BOOLEAN_ARR_NOT_READ) + if (!commState.lastRead()) return false; - retVals = retVals0; - commState.idx++; case 20: - if (buf.remaining() < 8) - return false; - threadId = commState.getLong("threadId"); + if (!commState.lastRead()) + return false; + commState.idx++; case 21: - if (buf.remaining() < 8) - return false; - timeout = commState.getLong("timeout"); + if (!commState.lastRead()) + return false; + commState.idx++; case 22: - if (buf.remaining() < 4) - return false; - txSize = commState.getInt("txSize"); + if (!commState.lastRead()) + return false; + commState.idx++; case 23: - byte[] writeEntriesBytes0 = commState.getByteArray("writeEntriesBytes"); + writeEntriesBytes = commState.getByteArray("writeEntriesBytes"); - if (writeEntriesBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - writeEntriesBytes = writeEntriesBytes0; - commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedLockResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedLockResponse.java index 7facf11bda2a3..2715aa951373c 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedLockResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedLockResponse.java @@ -348,31 +348,27 @@ protected int valuesSize() { switch (commState.idx) { case 8: - byte[] errBytes0 = commState.getByteArray("errBytes"); + errBytes = commState.getByteArray("errBytes"); - if (errBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - errBytes = errBytes0; - commState.idx++; case 9: - IgniteUuid futId0 = commState.getGridUuid("futId"); + futId = commState.getGridUuid("futId"); - if (futId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - futId = futId0; - commState.idx++; case 10: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -382,7 +378,7 @@ protected int valuesSize() { for (int i = commState.readItems; i < commState.readSize; i++) { GridCacheValueBytes _val = commState.getValueBytes(null); - if (_val == VAL_BYTES_NOT_READ) + if (!commState.lastRead()) return false; valBytes.add((GridCacheValueBytes)_val); diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxFinishRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxFinishRequest.java index 147001cf12718..8f68aa1caefc0 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxFinishRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxFinishRequest.java @@ -461,18 +461,24 @@ public boolean groupLock() { commState.idx++; case 17: - if (!commState.putLong("threadId", threadId)) + if (!commState.putBoolean("sys", sys)) return false; commState.idx++; case 18: - if (!commState.putInt("txSize", txSize)) + if (!commState.putLong("threadId", threadId)) return false; commState.idx++; case 19: + if (!commState.putInt("txSize", txSize)) + return false; + + commState.idx++; + + case 20: if (writeEntriesBytes != null) { if (commState.it == null) { if (!commState.putInt(null, writeEntriesBytes.size())) @@ -499,11 +505,6 @@ public boolean groupLock() { commState.idx++; - case 20: - if (!commState.putBoolean("sys", sys)) - return false; - - commState.idx++; } return true; @@ -519,67 +520,59 @@ public boolean groupLock() { switch (commState.idx) { case 8: - GridCacheVersion baseVer0 = commState.getCacheVersion("baseVer"); + baseVer = commState.getCacheVersion("baseVer"); - if (baseVer0 == CACHE_VER_NOT_READ) + if (!commState.lastRead()) return false; - baseVer = baseVer0; - commState.idx++; case 9: - if (buf.remaining() < 1) - return false; - commit = commState.getBoolean("commit"); + if (!commState.lastRead()) + return false; + commState.idx++; case 10: - GridCacheVersion commitVer0 = commState.getCacheVersion("commitVer"); + commitVer = commState.getCacheVersion("commitVer"); - if (commitVer0 == CACHE_VER_NOT_READ) + if (!commState.lastRead()) return false; - commitVer = commitVer0; - commState.idx++; case 11: - IgniteUuid futId0 = commState.getGridUuid("futId"); + futId = commState.getGridUuid("futId"); - if (futId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - futId = futId0; - commState.idx++; case 12: - byte[] grpLockKeyBytes0 = commState.getByteArray("grpLockKeyBytes"); + grpLockKeyBytes = commState.getByteArray("grpLockKeyBytes"); - if (grpLockKeyBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - grpLockKeyBytes = grpLockKeyBytes0; - commState.idx++; case 13: - if (buf.remaining() < 1) - return false; - invalidate = commState.getBoolean("invalidate"); + if (!commState.lastRead()) + return false; + commState.idx++; case 14: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -589,7 +582,7 @@ public boolean groupLock() { for (int i = commState.readItems; i < commState.readSize; i++) { byte[] _val = commState.getByteArray(null); - if (_val == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; recoveryWritesBytes.add((byte[])_val); @@ -604,43 +597,51 @@ public boolean groupLock() { commState.idx++; case 15: - if (buf.remaining() < 1) - return false; - syncCommit = commState.getBoolean("syncCommit"); + if (!commState.lastRead()) + return false; + commState.idx++; case 16: - if (buf.remaining() < 1) - return false; - syncRollback = commState.getBoolean("syncRollback"); + if (!commState.lastRead()) + return false; + commState.idx++; case 17: - if (buf.remaining() < 8) - return false; + sys = commState.getBoolean("sys"); - threadId = commState.getLong("threadId"); + if (!commState.lastRead()) + return false; commState.idx++; case 18: - if (buf.remaining() < 4) + threadId = commState.getLong("threadId"); + + if (!commState.lastRead()) return false; + commState.idx++; + + case 19: txSize = commState.getInt("txSize"); + if (!commState.lastRead()) + return false; + commState.idx++; - case 19: + case 20: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -650,7 +651,7 @@ public boolean groupLock() { for (int i = commState.readItems; i < commState.readSize; i++) { byte[] _val = commState.getByteArray(null); - if (_val == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; writeEntriesBytes.add((byte[])_val); @@ -664,13 +665,6 @@ public boolean groupLock() { commState.idx++; - case 20: - if (buf.remaining() < 1) - return false; - - sys = commState.getBoolean("sys"); - - commState.idx++; } return true; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxFinishResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxFinishResponse.java index fd616d0bd2553..e8a916c11572b 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxFinishResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxFinishResponse.java @@ -128,23 +128,19 @@ public IgniteUuid futureId() { switch (commState.idx) { case 3: - IgniteUuid futId0 = commState.getGridUuid("futId"); + futId = commState.getGridUuid("futId"); - if (futId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - futId = futId0; - commState.idx++; case 4: - GridCacheVersion txId0 = commState.getCacheVersion("txId"); + txId = commState.getCacheVersion("txId"); - if (txId0 == CACHE_VER_NOT_READ) + if (!commState.lastRead()) return false; - txId = txId0; - commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxPrepareRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxPrepareRequest.java index 1cc7219dd93f7..47e42a3e03fda 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxPrepareRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxPrepareRequest.java @@ -516,30 +516,36 @@ private void writeCollection(ObjectOutput out, Collection> c commState.idx++; case 16: - if (!commState.putLong("threadId", threadId)) + if (!commState.putBoolean("sys", sys)) return false; commState.idx++; case 17: - if (!commState.putLong("timeout", timeout)) + if (!commState.putLong("threadId", threadId)) return false; commState.idx++; case 18: - if (!commState.putByteArray("txNodesBytes", txNodesBytes)) + if (!commState.putLong("timeout", timeout)) return false; commState.idx++; case 19: - if (!commState.putInt("txSize", txSize)) + if (!commState.putByteArray("txNodesBytes", txNodesBytes)) return false; commState.idx++; case 20: + if (!commState.putInt("txSize", txSize)) + return false; + + commState.idx++; + + case 21: if (writesBytes != null) { if (commState.it == null) { if (!commState.putInt(null, writesBytes.size())) @@ -566,11 +572,6 @@ private void writeCollection(ObjectOutput out, Collection> c commState.idx++; - case 21: - if (!commState.putBoolean("sys", sys)) - return false; - - commState.idx++; } return true; @@ -586,77 +587,71 @@ private void writeCollection(ObjectOutput out, Collection> c switch (commState.idx) { case 8: - GridCacheVersion commitVer0 = commState.getCacheVersion("commitVer"); + commitVer = commState.getCacheVersion("commitVer"); - if (commitVer0 == CACHE_VER_NOT_READ) + if (!commState.lastRead()) return false; - commitVer = commitVer0; - commState.idx++; case 9: - if (buf.remaining() < 1) - return false; - byte concurrency0 = commState.getByte("concurrency"); + if (!commState.lastRead()) + return false; + concurrency = IgniteTxConcurrency.fromOrdinal(concurrency0); commState.idx++; case 10: - byte[] dhtVersBytes0 = commState.getByteArray("dhtVersBytes"); + dhtVersBytes = commState.getByteArray("dhtVersBytes"); - if (dhtVersBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - dhtVersBytes = dhtVersBytes0; - commState.idx++; case 11: - byte[] grpLockKeyBytes0 = commState.getByteArray("grpLockKeyBytes"); + grpLockKeyBytes = commState.getByteArray("grpLockKeyBytes"); - if (grpLockKeyBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - grpLockKeyBytes = grpLockKeyBytes0; - commState.idx++; case 12: - if (buf.remaining() < 1) - return false; - invalidate = commState.getBoolean("invalidate"); + if (!commState.lastRead()) + return false; + commState.idx++; case 13: - if (buf.remaining() < 1) - return false; - byte isolation0 = commState.getByte("isolation"); + if (!commState.lastRead()) + return false; + isolation = IgniteTxIsolation.fromOrdinal(isolation0); commState.idx++; case 14: - if (buf.remaining() < 1) - return false; - partLock = commState.getBoolean("partLock"); + if (!commState.lastRead()) + return false; + commState.idx++; case 15: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -666,7 +661,7 @@ private void writeCollection(ObjectOutput out, Collection> c for (int i = commState.readItems; i < commState.readSize; i++) { byte[] _val = commState.getByteArray(null); - if (_val == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; readsBytes.add((byte[])_val); @@ -681,45 +676,51 @@ private void writeCollection(ObjectOutput out, Collection> c commState.idx++; case 16: - if (buf.remaining() < 8) - return false; + sys = commState.getBoolean("sys"); - threadId = commState.getLong("threadId"); + if (!commState.lastRead()) + return false; commState.idx++; case 17: - if (buf.remaining() < 8) - return false; + threadId = commState.getLong("threadId"); - timeout = commState.getLong("timeout"); + if (!commState.lastRead()) + return false; commState.idx++; case 18: - byte[] txNodesBytes0 = commState.getByteArray("txNodesBytes"); + timeout = commState.getLong("timeout"); - if (txNodesBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - txNodesBytes = txNodesBytes0; - commState.idx++; case 19: - if (buf.remaining() < 4) + txNodesBytes = commState.getByteArray("txNodesBytes"); + + if (!commState.lastRead()) return false; + commState.idx++; + + case 20: txSize = commState.getInt("txSize"); + if (!commState.lastRead()) + return false; + commState.idx++; - case 20: + case 21: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -729,7 +730,7 @@ private void writeCollection(ObjectOutput out, Collection> c for (int i = commState.readItems; i < commState.readSize; i++) { byte[] _val = commState.getByteArray(null); - if (_val == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; writesBytes.add((byte[])_val); @@ -743,13 +744,6 @@ private void writeCollection(ObjectOutput out, Collection> c commState.idx++; - case 21: - if (buf.remaining() < 1) - return false; - - sys = commState.getBoolean("sys"); - - commState.idx++; } return true; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxPrepareResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxPrepareResponse.java index 64922f7ce6947..011fd9cbfb7ec 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxPrepareResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedTxPrepareResponse.java @@ -205,23 +205,19 @@ public void candidates(Map>> cands) { switch (commState.idx) { case 8: - byte[] candsBytes0 = commState.getByteArray("candsBytes"); + candsBytes = commState.getByteArray("candsBytes"); - if (candsBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - candsBytes = candsBytes0; - commState.idx++; case 9: - byte[] errBytes0 = commState.getByteArray("errBytes"); + errBytes = commState.getByteArray("errBytes"); - if (errBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - errBytes = errBytes0; - commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedUnlockRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedUnlockRequest.java index aa0772e4c4a15..42b51fab57fdc 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedUnlockRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/GridDistributedUnlockRequest.java @@ -186,10 +186,10 @@ public void addKey(K key, byte[] bytes, GridCacheContext ctx) throws Ignit switch (commState.idx) { case 8: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -199,7 +199,7 @@ public void addKey(K key, byte[] bytes, GridCacheContext ctx) throws Ignit for (int i = commState.readItems; i < commState.readSize; i++) { byte[] _val = commState.getByteArray(null); - if (_val == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; keyBytes.add((byte[])_val); diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java index 9c6b74ba5eaae..5f329cb56de9c 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java @@ -112,11 +112,11 @@ public GridDhtAffinityAssignmentRequest(int cacheId, long topVer) { switch (commState.idx) { case 3: - if (buf.remaining() < 8) - return false; - topVer = commState.getLong("topVer"); + if (!commState.lastRead()) + return false; + commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java index 151e833804e3a..12bdce94bdb37 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java @@ -159,21 +159,19 @@ public List> affinityAssignment() { switch (commState.idx) { case 3: - byte[] affAssignmentBytes0 = commState.getByteArray("affAssignmentBytes"); + affAssignmentBytes = commState.getByteArray("affAssignmentBytes"); - if (affAssignmentBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - affAssignmentBytes = affAssignmentBytes0; - commState.idx++; case 4: - if (buf.remaining() < 8) - return false; - topVer = commState.getLong("topVer"); + if (!commState.lastRead()) + return false; + commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtLockRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtLockRequest.java index f7e5d11f38d76..0f404ab92550c 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtLockRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtLockRequest.java @@ -432,31 +432,27 @@ public IgniteUuid miniId() { switch (commState.idx) { case 24: - BitSet invalidateEntries0 = commState.getBitSet("invalidateEntries"); + invalidateEntries = commState.getBitSet("invalidateEntries"); - if (invalidateEntries0 == BIT_SET_NOT_READ) + if (!commState.lastRead()) return false; - invalidateEntries = invalidateEntries0; - commState.idx++; case 25: - IgniteUuid miniId0 = commState.getGridUuid("miniId"); + miniId = commState.getGridUuid("miniId"); - if (miniId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - miniId = miniId0; - commState.idx++; case 26: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -466,7 +462,7 @@ public IgniteUuid miniId() { for (int i = commState.readItems; i < commState.readSize; i++) { byte[] _val = commState.getByteArray(null); - if (_val == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; nearKeyBytes.add((byte[])_val); @@ -481,49 +477,43 @@ public IgniteUuid miniId() { commState.idx++; case 27: - byte[] ownedBytes0 = commState.getByteArray("ownedBytes"); + ownedBytes = commState.getByteArray("ownedBytes"); - if (ownedBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - ownedBytes = ownedBytes0; - commState.idx++; case 28: - if (buf.remaining() < 8) - return false; - topVer = commState.getLong("topVer"); + if (!commState.lastRead()) + return false; + commState.idx++; case 29: - UUID subjId0 = commState.getUuid("subjId"); + subjId = commState.getUuid("subjId"); - if (subjId0 == UUID_NOT_READ) + if (!commState.lastRead()) return false; - subjId = subjId0; - commState.idx++; case 30: - if (buf.remaining() < 4) - return false; - taskNameHash = commState.getInt("taskNameHash"); + if (!commState.lastRead()) + return false; + commState.idx++; case 31: - BitSet preloadKeys0 = commState.getBitSet("preloadKeys"); + preloadKeys = commState.getBitSet("preloadKeys"); - if (preloadKeys0 == BIT_SET_NOT_READ) + if (!commState.lastRead()) return false; - preloadKeys = preloadKeys0; - commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtLockResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtLockResponse.java index 054529a4e8680..57305f2e4db69 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtLockResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtLockResponse.java @@ -333,10 +333,10 @@ public Collection> preloadEntries() { switch (commState.idx) { case 11: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -344,11 +344,11 @@ public Collection> preloadEntries() { invalidParts = new HashSet<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - if (buf.remaining() < 4) - return false; - int _val = commState.getInt(null); + if (!commState.lastRead()) + return false; + invalidParts.add((Integer)_val); commState.readItems++; @@ -361,21 +361,19 @@ public Collection> preloadEntries() { commState.idx++; case 12: - IgniteUuid miniId0 = commState.getGridUuid("miniId"); + miniId = commState.getGridUuid("miniId"); - if (miniId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - miniId = miniId0; - commState.idx++; case 13: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -385,7 +383,7 @@ public Collection> preloadEntries() { for (int i = commState.readItems; i < commState.readSize; i++) { byte[] _val = commState.getByteArray(null); - if (_val == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; nearEvictedBytes.add((byte[])_val); @@ -401,10 +399,10 @@ public Collection> preloadEntries() { case 14: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -414,7 +412,7 @@ public Collection> preloadEntries() { for (int i = commState.readItems; i < commState.readSize; i++) { byte[] _val = commState.getByteArray(null); - if (_val == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; preloadEntriesBytes.add((byte[])_val); diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java index 8efd398743155..7407286541e68 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java @@ -326,19 +326,19 @@ public Collection pendingVersions() { switch (commState.idx) { case 21: - if (!commState.putEnum(null, isolation)) + if (!commState.putEnum("isolation", isolation)) return false; commState.idx++; case 22: - if (!commState.putGridUuid(null, miniId)) + if (!commState.putGridUuid("miniId", miniId)) return false; commState.idx++; case 23: - if (!commState.putUuid(null, nearNodeId)) + if (!commState.putUuid("nearNodeId", nearNodeId)) return false; commState.idx++; @@ -371,7 +371,7 @@ public Collection pendingVersions() { commState.idx++; case 25: - if (!commState.putBoolean(null, onePhaseCommit)) + if (!commState.putBoolean("onePhaseCommit", onePhaseCommit)) return false; commState.idx++; @@ -404,31 +404,31 @@ public Collection pendingVersions() { commState.idx++; case 27: - if (!commState.putBoolean(null, sysInvalidate)) + if (!commState.putBoolean("sysInvalidate", sysInvalidate)) return false; commState.idx++; case 28: - if (!commState.putLong(null, topVer)) + if (!commState.putLong("topVer", topVer)) return false; commState.idx++; case 29: - if (!commState.putCacheVersion(null, writeVer)) + if (!commState.putCacheVersion("writeVer", writeVer)) return false; commState.idx++; case 30: - if (!commState.putUuid(null, subjId)) + if (!commState.putUuid("subjId", subjId)) return false; commState.idx++; case 31: - if (!commState.putInt(null, taskNameHash)) + if (!commState.putInt("taskNameHash", taskNameHash)) return false; commState.idx++; @@ -448,41 +448,37 @@ public Collection pendingVersions() { switch (commState.idx) { case 21: - if (buf.remaining() < 1) - return false; + byte isolation0 = commState.getByte("isolation"); - byte isolation0 = commState.getByte(null); + if (!commState.lastRead()) + return false; isolation = IgniteTxIsolation.fromOrdinal(isolation0); commState.idx++; case 22: - IgniteUuid miniId0 = commState.getGridUuid(null); + miniId = commState.getGridUuid("miniId"); - if (miniId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - miniId = miniId0; - commState.idx++; case 23: - UUID nearNodeId0 = commState.getUuid(null); + nearNodeId = commState.getUuid("nearNodeId"); - if (nearNodeId0 == UUID_NOT_READ) + if (!commState.lastRead()) return false; - nearNodeId = nearNodeId0; - commState.idx++; case 24: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -492,7 +488,7 @@ public Collection pendingVersions() { for (int i = commState.readItems; i < commState.readSize; i++) { byte[] _val = commState.getByteArray(null); - if (_val == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; nearWritesBytes.add((byte[])_val); @@ -507,19 +503,19 @@ public Collection pendingVersions() { commState.idx++; case 25: - if (buf.remaining() < 1) - return false; + onePhaseCommit = commState.getBoolean("onePhaseCommit"); - onePhaseCommit = commState.getBoolean(null); + if (!commState.lastRead()) + return false; commState.idx++; case 26: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -529,7 +525,7 @@ public Collection pendingVersions() { for (int i = commState.readItems; i < commState.readSize; i++) { GridCacheVersion _val = commState.getCacheVersion(null); - if (_val == CACHE_VER_NOT_READ) + if (!commState.lastRead()) return false; pendingVers.add((GridCacheVersion)_val); @@ -544,46 +540,42 @@ public Collection pendingVersions() { commState.idx++; case 27: - if (buf.remaining() < 1) - return false; + sysInvalidate = commState.getBoolean("sysInvalidate"); - sysInvalidate = commState.getBoolean(null); + if (!commState.lastRead()) + return false; commState.idx++; case 28: - if (buf.remaining() < 8) - return false; + topVer = commState.getLong("topVer"); - topVer = commState.getLong(null); + if (!commState.lastRead()) + return false; commState.idx++; case 29: - GridCacheVersion writeVer0 = commState.getCacheVersion(null); + writeVer = commState.getCacheVersion("writeVer"); - if (writeVer0 == CACHE_VER_NOT_READ) + if (!commState.lastRead()) return false; - writeVer = writeVer0; - commState.idx++; case 30: - UUID subjId0 = commState.getUuid(null); + subjId = commState.getUuid("subjId"); - if (subjId0 == UUID_NOT_READ) + if (!commState.lastRead()) return false; - subjId = subjId0; - commState.idx++; case 31: - if (buf.remaining() < 4) - return false; + taskNameHash = commState.getInt("taskNameHash"); - taskNameHash = commState.getInt(null); + if (!commState.lastRead()) + return false; commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java index 1215f1e48bc0e..c881d472bb4e9 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java @@ -116,13 +116,11 @@ public IgniteUuid miniId() { switch (commState.idx) { case 5: - IgniteUuid miniId0 = commState.getGridUuid("miniId"); + miniId = commState.getGridUuid("miniId"); - if (miniId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - miniId = miniId0; - commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java index 4f5b01bd790be..c9e598dd1c35c 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java @@ -354,31 +354,31 @@ public Map, GridCacheVersion> owned() { switch (commState.idx) { case 22: - if (!commState.putGridUuid(null, futId)) + if (!commState.putGridUuid("futId", futId)) return false; commState.idx++; case 23: - if (!commState.putBitSet(null, invalidateNearEntries)) + if (!commState.putBitSet("invalidateNearEntries", invalidateNearEntries)) return false; commState.idx++; case 24: - if (!commState.putBoolean(null, last)) + if (!commState.putBoolean("last", last)) return false; commState.idx++; case 25: - if (!commState.putGridUuid(null, miniId)) + if (!commState.putGridUuid("miniId", miniId)) return false; commState.idx++; case 26: - if (!commState.putUuid(null, nearNodeId)) + if (!commState.putUuid("nearNodeId", nearNodeId)) return false; commState.idx++; @@ -411,37 +411,37 @@ public Map, GridCacheVersion> owned() { commState.idx++; case 28: - if (!commState.putCacheVersion(null, nearXidVer)) + if (!commState.putCacheVersion("nearXidVer", nearXidVer)) return false; commState.idx++; case 29: - if (!commState.putByteArray(null, ownedBytes)) + if (!commState.putByteArray("ownedBytes", ownedBytes)) return false; commState.idx++; case 30: - if (!commState.putLong(null, topVer)) + if (!commState.putLong("topVer", topVer)) return false; commState.idx++; case 31: - if (!commState.putUuid(null, subjId)) + if (!commState.putUuid("subjId", subjId)) return false; commState.idx++; case 32: - if (!commState.putInt(null, taskNameHash)) + if (!commState.putInt("taskNameHash", taskNameHash)) return false; commState.idx++; case 33: - if (!commState.putBitSet(null, preloadKeys)) + if (!commState.putBitSet("preloadKeys", preloadKeys)) return false; commState.idx++; @@ -461,59 +461,51 @@ public Map, GridCacheVersion> owned() { switch (commState.idx) { case 22: - IgniteUuid futId0 = commState.getGridUuid(null); + futId = commState.getGridUuid("futId"); - if (futId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - futId = futId0; - commState.idx++; case 23: - BitSet invalidateNearEntries0 = commState.getBitSet(null); + invalidateNearEntries = commState.getBitSet("invalidateNearEntries"); - if (invalidateNearEntries0 == BIT_SET_NOT_READ) + if (!commState.lastRead()) return false; - invalidateNearEntries = invalidateNearEntries0; - commState.idx++; case 24: - if (buf.remaining() < 1) - return false; + last = commState.getBoolean("last"); - last = commState.getBoolean(null); + if (!commState.lastRead()) + return false; commState.idx++; case 25: - IgniteUuid miniId0 = commState.getGridUuid(null); + miniId = commState.getGridUuid("miniId"); - if (miniId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - miniId = miniId0; - commState.idx++; case 26: - UUID nearNodeId0 = commState.getUuid(null); + nearNodeId = commState.getUuid("nearNodeId"); - if (nearNodeId0 == UUID_NOT_READ) + if (!commState.lastRead()) return false; - nearNodeId = nearNodeId0; - commState.idx++; case 27: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -523,7 +515,7 @@ public Map, GridCacheVersion> owned() { for (int i = commState.readItems; i < commState.readSize; i++) { byte[] _val = commState.getByteArray(null); - if (_val == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; nearWritesBytes.add((byte[])_val); @@ -538,59 +530,51 @@ public Map, GridCacheVersion> owned() { commState.idx++; case 28: - GridCacheVersion nearXidVer0 = commState.getCacheVersion(null); + nearXidVer = commState.getCacheVersion("nearXidVer"); - if (nearXidVer0 == CACHE_VER_NOT_READ) + if (!commState.lastRead()) return false; - nearXidVer = nearXidVer0; - commState.idx++; case 29: - byte[] ownedBytes0 = commState.getByteArray(null); + ownedBytes = commState.getByteArray("ownedBytes"); - if (ownedBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - ownedBytes = ownedBytes0; - commState.idx++; case 30: - if (buf.remaining() < 8) - return false; + topVer = commState.getLong("topVer"); - topVer = commState.getLong(null); + if (!commState.lastRead()) + return false; commState.idx++; case 31: - UUID subjId0 = commState.getUuid(null); + subjId = commState.getUuid("subjId"); - if (subjId0 == UUID_NOT_READ) + if (!commState.lastRead()) return false; - subjId = subjId0; - commState.idx++; case 32: - if (buf.remaining() < 4) - return false; + taskNameHash = commState.getInt("taskNameHash"); - taskNameHash = commState.getInt(null); + if (!commState.lastRead()) + return false; commState.idx++; case 33: - BitSet preloadKeys0 = commState.getBitSet(null); + preloadKeys = commState.getBitSet("preloadKeys"); - if (preloadKeys0 == BIT_SET_NOT_READ) + if (!commState.lastRead()) return false; - preloadKeys = preloadKeys0; - commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java index 1692d0a27d9f1..e499fd94038eb 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java @@ -345,21 +345,19 @@ public void addPreloadEntry(GridCacheEntryInfo info) { switch (commState.idx) { case 10: - IgniteUuid futId0 = commState.getGridUuid("futId"); + futId = commState.getGridUuid("futId"); - if (futId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - futId = futId0; - commState.idx++; case 11: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -367,11 +365,11 @@ public void addPreloadEntry(GridCacheEntryInfo info) { invalidParts = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - if (buf.remaining() < 4) - return false; - int _val = commState.getInt(null); + if (!commState.lastRead()) + return false; + invalidParts.add((Integer)_val); commState.readItems++; @@ -384,21 +382,19 @@ public void addPreloadEntry(GridCacheEntryInfo info) { commState.idx++; case 12: - IgniteUuid miniId0 = commState.getGridUuid("miniId"); + miniId = commState.getGridUuid("miniId"); - if (miniId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - miniId = miniId0; - commState.idx++; case 13: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -408,7 +404,7 @@ public void addPreloadEntry(GridCacheEntryInfo info) { for (int i = commState.readItems; i < commState.readSize; i++) { byte[] _val = commState.getByteArray(null); - if (_val == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; nearEvictedBytes.add((byte[])_val); @@ -424,10 +420,10 @@ public void addPreloadEntry(GridCacheEntryInfo info) { case 14: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -437,7 +433,7 @@ public void addPreloadEntry(GridCacheEntryInfo info) { for (int i = commState.readItems; i < commState.readSize; i++) { byte[] _val = commState.getByteArray(null); - if (_val == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; preloadEntriesBytes.add((byte[])_val); diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtUnlockRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtUnlockRequest.java index 3a4c289e77ed9..2acc96dfd1aee 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtUnlockRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridDhtUnlockRequest.java @@ -174,10 +174,10 @@ public void addNearKey(K key, byte[] keyBytes, GridCacheSharedContext ctx) switch (commState.idx) { case 9: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -187,7 +187,7 @@ public void addNearKey(K key, byte[] keyBytes, GridCacheSharedContext ctx) for (int i = commState.readItems; i < commState.readSize; i++) { byte[] _val = commState.getByteArray(null); - if (_val == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; nearKeyBytes.add((byte[])_val); diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicDeferredUpdateResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicDeferredUpdateResponse.java index f86a28c6297f3..04ef2c80af2ad 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicDeferredUpdateResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicDeferredUpdateResponse.java @@ -141,10 +141,10 @@ public Collection futureVersions() { switch (commState.idx) { case 3: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -154,7 +154,7 @@ public Collection futureVersions() { for (int i = commState.readItems; i < commState.readSize; i++) { GridCacheVersion _val = commState.getCacheVersion(null); - if (_val == CACHE_VER_NOT_READ) + if (!commState.lastRead()) return false; futVers.add((GridCacheVersion)_val); diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java index 18ba7c4eb4268..4911c4bd74d47 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java @@ -921,31 +921,27 @@ public long drExpireTime(int idx) { switch (commState.idx) { case 3: - GridLongList drExpireTimes0 = commState.getLongList("drExpireTimes"); + drExpireTimes = commState.getLongList("drExpireTimes"); - if (drExpireTimes0 == LONG_LIST_NOT_READ) + if (!commState.lastRead()) return false; - drExpireTimes = drExpireTimes0; - commState.idx++; case 4: - GridLongList drTtls0 = commState.getLongList("drTtls"); + drTtls = commState.getLongList("drTtls"); - if (drTtls0 == LONG_LIST_NOT_READ) + if (!commState.lastRead()) return false; - drTtls = drTtls0; - commState.idx++; case 5: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -955,7 +951,7 @@ public long drExpireTime(int idx) { for (int i = commState.readItems; i < commState.readSize; i++) { GridCacheVersion _val = commState.getCacheVersion(null); - if (_val == CACHE_VER_NOT_READ) + if (!commState.lastRead()) return false; drVers.add((GridCacheVersion)_val); @@ -970,21 +966,19 @@ public long drExpireTime(int idx) { commState.idx++; case 6: - GridCacheVersion futVer0 = commState.getCacheVersion("futVer"); + futVer = commState.getCacheVersion("futVer"); - if (futVer0 == CACHE_VER_NOT_READ) + if (!commState.lastRead()) return false; - futVer = futVer0; - commState.idx++; case 7: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -994,7 +988,7 @@ public long drExpireTime(int idx) { for (int i = commState.readItems; i < commState.readSize; i++) { byte[] _val = commState.getByteArray(null); - if (_val == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; keyBytes.add((byte[])_val); @@ -1009,47 +1003,45 @@ public long drExpireTime(int idx) { commState.idx++; case 8: - UUID nodeId0 = commState.getUuid("nodeId"); + nodeId = commState.getUuid("nodeId"); - if (nodeId0 == UUID_NOT_READ) + if (!commState.lastRead()) return false; - nodeId = nodeId0; - commState.idx++; case 9: - if (buf.remaining() < 1) - return false; - byte syncMode0 = commState.getByte("syncMode"); + if (!commState.lastRead()) + return false; + syncMode = GridCacheWriteSynchronizationMode.fromOrdinal(syncMode0); commState.idx++; case 10: - if (buf.remaining() < 8) - return false; - topVer = commState.getLong("topVer"); + if (!commState.lastRead()) + return false; + commState.idx++; case 11: - if (buf.remaining() < 8) - return false; - ttl = commState.getLong("ttl"); + if (!commState.lastRead()) + return false; + commState.idx++; case 12: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -1059,7 +1051,7 @@ public long drExpireTime(int idx) { for (int i = commState.readItems; i < commState.readSize; i++) { GridCacheValueBytes _val = commState.getValueBytes(null); - if (_val == VAL_BYTES_NOT_READ) + if (!commState.lastRead()) return false; valBytes.add((GridCacheValueBytes)_val); @@ -1074,21 +1066,19 @@ public long drExpireTime(int idx) { commState.idx++; case 13: - GridCacheVersion writeVer0 = commState.getCacheVersion("writeVer"); + writeVer = commState.getCacheVersion("writeVer"); - if (writeVer0 == CACHE_VER_NOT_READ) + if (!commState.lastRead()) return false; - writeVer = writeVer0; - commState.idx++; case 14: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -1098,7 +1088,7 @@ public long drExpireTime(int idx) { for (int i = commState.readItems; i < commState.readSize; i++) { byte[] _val = commState.getByteArray(null); - if (_val == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; nearKeyBytes.add((byte[])_val); @@ -1114,10 +1104,10 @@ public long drExpireTime(int idx) { case 15: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -1127,7 +1117,7 @@ public long drExpireTime(int idx) { for (int i = commState.readItems; i < commState.readSize; i++) { GridCacheValueBytes _val = commState.getValueBytes(null); - if (_val == VAL_BYTES_NOT_READ) + if (!commState.lastRead()) return false; nearValBytes.add((GridCacheValueBytes)_val); @@ -1142,19 +1132,19 @@ public long drExpireTime(int idx) { commState.idx++; case 16: - if (buf.remaining() < 1) - return false; - forceTransformBackups = commState.getBoolean("forceTransformBackups"); + if (!commState.lastRead()) + return false; + commState.idx++; case 17: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -1164,7 +1154,7 @@ public long drExpireTime(int idx) { for (int i = commState.readItems; i < commState.readSize; i++) { byte[] _val = commState.getByteArray(null); - if (_val == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; nearTransformClosBytes.add((byte[])_val); @@ -1180,10 +1170,10 @@ public long drExpireTime(int idx) { case 18: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -1193,7 +1183,7 @@ public long drExpireTime(int idx) { for (int i = commState.readItems; i < commState.readSize; i++) { byte[] _val = commState.getByteArray(null); - if (_val == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; transformClosBytes.add((byte[])_val); @@ -1208,21 +1198,19 @@ public long drExpireTime(int idx) { commState.idx++; case 19: - UUID subjId0 = commState.getUuid("subjId"); + subjId = commState.getUuid("subjId"); - if (subjId0 == UUID_NOT_READ) + if (!commState.lastRead()) return false; - subjId = subjId0; - commState.idx++; case 20: - if (buf.remaining() < 4) - return false; - taskNameHash = commState.getInt("taskNameHash"); + if (!commState.lastRead()) + return false; + commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java index bc54e2fc280f6..c48dfb9d0af39 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java @@ -270,41 +270,35 @@ public void addNearEvicted(K key, @Nullable byte[] bytes) { switch (commState.idx) { case 3: - byte[] errBytes0 = commState.getByteArray("errBytes"); + errBytes = commState.getByteArray("errBytes"); - if (errBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - errBytes = errBytes0; - commState.idx++; case 4: - byte[] failedKeysBytes0 = commState.getByteArray("failedKeysBytes"); + failedKeysBytes = commState.getByteArray("failedKeysBytes"); - if (failedKeysBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - failedKeysBytes = failedKeysBytes0; - commState.idx++; case 5: - GridCacheVersion futVer0 = commState.getCacheVersion("futVer"); + futVer = commState.getCacheVersion("futVer"); - if (futVer0 == CACHE_VER_NOT_READ) + if (!commState.lastRead()) return false; - futVer = futVer0; - commState.idx++; case 6: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -314,7 +308,7 @@ public void addNearEvicted(K key, @Nullable byte[] bytes) { for (int i = commState.readItems; i < commState.readSize; i++) { byte[] _val = commState.getByteArray(null); - if (_val == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; nearEvictedBytes.add((byte[])_val); diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java index 353446a838797..161c5915eea4b 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java @@ -759,31 +759,27 @@ public void forceTransformBackups(boolean forceTransformBackups) { switch (commState.idx) { case 3: - GridLongList drExpireTimes0 = commState.getLongList("drExpireTimes"); + drExpireTimes = commState.getLongList("drExpireTimes"); - if (drExpireTimes0 == LONG_LIST_NOT_READ) + if (!commState.lastRead()) return false; - drExpireTimes = drExpireTimes0; - commState.idx++; case 4: - GridLongList drTtls0 = commState.getLongList("drTtls"); + drTtls = commState.getLongList("drTtls"); - if (drTtls0 == LONG_LIST_NOT_READ) + if (!commState.lastRead()) return false; - drTtls = drTtls0; - commState.idx++; case 5: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -793,7 +789,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { for (int i = commState.readItems; i < commState.readSize; i++) { GridCacheVersion _val = commState.getCacheVersion(null); - if (_val == CACHE_VER_NOT_READ) + if (!commState.lastRead()) return false; drVers.add((GridCacheVersion)_val); @@ -808,19 +804,19 @@ public void forceTransformBackups(boolean forceTransformBackups) { commState.idx++; case 6: - if (buf.remaining() < 1) - return false; - fastMap = commState.getBoolean("fastMap"); + if (!commState.lastRead()) + return false; + commState.idx++; case 7: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -830,7 +826,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { for (int i = commState.readItems; i < commState.readSize; i++) { byte[] _val = commState.getByteArray(null); - if (_val == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; filterBytes[i] = (byte[])_val; @@ -845,29 +841,27 @@ public void forceTransformBackups(boolean forceTransformBackups) { commState.idx++; case 8: - GridCacheVersion futVer0 = commState.getCacheVersion("futVer"); + futVer = commState.getCacheVersion("futVer"); - if (futVer0 == CACHE_VER_NOT_READ) + if (!commState.lastRead()) return false; - futVer = futVer0; - commState.idx++; case 9: - if (buf.remaining() < 1) - return false; - hasPrimary = commState.getBoolean("hasPrimary"); + if (!commState.lastRead()) + return false; + commState.idx++; case 10: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -877,7 +871,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { for (int i = commState.readItems; i < commState.readSize; i++) { byte[] _val = commState.getByteArray(null); - if (_val == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; keyBytes.add((byte[])_val); @@ -892,65 +886,63 @@ public void forceTransformBackups(boolean forceTransformBackups) { commState.idx++; case 11: - if (buf.remaining() < 1) - return false; - byte op0 = commState.getByte("op"); + if (!commState.lastRead()) + return false; + op = GridCacheOperation.fromOrdinal(op0); commState.idx++; case 12: - if (buf.remaining() < 1) - return false; - retval = commState.getBoolean("retval"); + if (!commState.lastRead()) + return false; + commState.idx++; case 13: - if (buf.remaining() < 1) - return false; - byte syncMode0 = commState.getByte("syncMode"); + if (!commState.lastRead()) + return false; + syncMode = GridCacheWriteSynchronizationMode.fromOrdinal(syncMode0); commState.idx++; case 14: - if (buf.remaining() < 8) - return false; - topVer = commState.getLong("topVer"); + if (!commState.lastRead()) + return false; + commState.idx++; case 15: - if (buf.remaining() < 8) - return false; - ttl = commState.getLong("ttl"); + if (!commState.lastRead()) + return false; + commState.idx++; case 16: - GridCacheVersion updateVer0 = commState.getCacheVersion("updateVer"); + updateVer = commState.getCacheVersion("updateVer"); - if (updateVer0 == CACHE_VER_NOT_READ) + if (!commState.lastRead()) return false; - updateVer = updateVer0; - commState.idx++; case 17: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -960,7 +952,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { for (int i = commState.readItems; i < commState.readSize; i++) { GridCacheValueBytes _val = commState.getValueBytes(null); - if (_val == VAL_BYTES_NOT_READ) + if (!commState.lastRead()) return false; valBytes.add((GridCacheValueBytes)_val); @@ -975,29 +967,27 @@ public void forceTransformBackups(boolean forceTransformBackups) { commState.idx++; case 18: - if (buf.remaining() < 1) - return false; - forceTransformBackups = commState.getBoolean("forceTransformBackups"); + if (!commState.lastRead()) + return false; + commState.idx++; case 19: - UUID subjId0 = commState.getUuid("subjId"); + subjId = commState.getUuid("subjId"); - if (subjId0 == UUID_NOT_READ) + if (!commState.lastRead()) return false; - subjId = subjId0; - commState.idx++; case 20: - if (buf.remaining() < 4) - return false; - taskNameHash = commState.getInt("taskNameHash"); + if (!commState.lastRead()) + return false; + commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java index 363ac8b8a279d..1908c000490fd 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java @@ -541,61 +541,51 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { switch (commState.idx) { case 3: - byte[] errBytes0 = commState.getByteArray("errBytes"); + errBytes = commState.getByteArray("errBytes"); - if (errBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - errBytes = errBytes0; - commState.idx++; case 4: - byte[] failedKeysBytes0 = commState.getByteArray("failedKeysBytes"); + failedKeysBytes = commState.getByteArray("failedKeysBytes"); - if (failedKeysBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - failedKeysBytes = failedKeysBytes0; - commState.idx++; case 5: - GridCacheVersion futVer0 = commState.getCacheVersion("futVer"); + futVer = commState.getCacheVersion("futVer"); - if (futVer0 == CACHE_VER_NOT_READ) + if (!commState.lastRead()) return false; - futVer = futVer0; - commState.idx++; case 6: - byte[] remapKeysBytes0 = commState.getByteArray("remapKeysBytes"); + remapKeysBytes = commState.getByteArray("remapKeysBytes"); - if (remapKeysBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - remapKeysBytes = remapKeysBytes0; - commState.idx++; case 7: - byte[] retValBytes0 = commState.getByteArray("retValBytes"); + retValBytes = commState.getByteArray("retValBytes"); - if (retValBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - retValBytes = retValBytes0; - commState.idx++; case 8: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -603,11 +593,11 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { nearSkipIdxs = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - if (buf.remaining() < 4) - return false; - int _val = commState.getInt(null); + if (!commState.lastRead()) + return false; + nearSkipIdxs.add((Integer)_val); commState.readItems++; @@ -620,19 +610,19 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { commState.idx++; case 9: - if (buf.remaining() < 8) - return false; - nearTtl = commState.getLong("nearTtl"); + if (!commState.lastRead()) + return false; + commState.idx++; case 10: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -642,7 +632,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { for (int i = commState.readItems; i < commState.readSize; i++) { GridCacheValueBytes _val = commState.getValueBytes(null); - if (_val == VAL_BYTES_NOT_READ) + if (!commState.lastRead()) return false; nearValBytes.add((GridCacheValueBytes)_val); @@ -658,10 +648,10 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { case 11: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -669,11 +659,11 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { nearValsIdxs = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - if (buf.remaining() < 4) - return false; - int _val = commState.getInt(null); + if (!commState.lastRead()) + return false; + nearValsIdxs.add((Integer)_val); commState.readItems++; @@ -686,13 +676,11 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { commState.idx++; case 12: - GridCacheVersion nearVer0 = commState.getCacheVersion("nearVer"); + nearVer = commState.getCacheVersion("nearVer"); - if (nearVer0 == CACHE_VER_NOT_READ) + if (!commState.lastRead()) return false; - nearVer = nearVer0; - commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java index 60f91449c9297..fdf4189a132c8 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java @@ -252,21 +252,19 @@ private int keyCount() { switch (commState.idx) { case 3: - IgniteUuid futId0 = commState.getGridUuid("futId"); + futId = commState.getGridUuid("futId"); - if (futId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - futId = futId0; - commState.idx++; case 4: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -276,7 +274,7 @@ private int keyCount() { for (int i = commState.readItems; i < commState.readSize; i++) { byte[] _val = commState.getByteArray(null); - if (_val == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; keyBytes.add((byte[])_val); @@ -291,21 +289,19 @@ private int keyCount() { commState.idx++; case 5: - IgniteUuid miniId0 = commState.getGridUuid("miniId"); + miniId = commState.getGridUuid("miniId"); - if (miniId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - miniId = miniId0; - commState.idx++; case 6: - if (buf.remaining() < 8) - return false; - topVer = commState.getLong("topVer"); + if (!commState.lastRead()) + return false; + commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java index bd5693732e4aa..60c058dba87a2 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java @@ -256,41 +256,35 @@ public void addInfo(GridCacheEntryInfo info) { switch (commState.idx) { case 3: - IgniteUuid futId0 = commState.getGridUuid("futId"); + futId = commState.getGridUuid("futId"); - if (futId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - futId = futId0; - commState.idx++; case 4: - byte[] infosBytes0 = commState.getByteArray("infosBytes"); + infosBytes = commState.getByteArray("infosBytes"); - if (infosBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - infosBytes = infosBytes0; - commState.idx++; case 5: - IgniteUuid miniId0 = commState.getGridUuid("miniId"); + miniId = commState.getGridUuid("miniId"); - if (miniId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - miniId = miniId0; - commState.idx++; case 6: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -300,7 +294,7 @@ public void addInfo(GridCacheEntryInfo info) { for (int i = commState.readItems; i < commState.readSize; i++) { byte[] _val = commState.getByteArray(null); - if (_val == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; missedKeyBytes.add((byte[])_val); diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java index bb036cd29d499..28496dbe30df8 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java @@ -295,10 +295,10 @@ void workerId(int workerId) { switch (commState.idx) { case 3: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -306,11 +306,11 @@ void workerId(int workerId) { parts = new HashSet<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - if (buf.remaining() < 4) - return false; - int _val = commState.getInt(null); + if (!commState.lastRead()) + return false; + parts.add((Integer)_val); commState.readItems++; @@ -323,45 +323,43 @@ void workerId(int workerId) { commState.idx++; case 4: - if (buf.remaining() < 8) - return false; - timeout = commState.getLong("timeout"); + if (!commState.lastRead()) + return false; + commState.idx++; case 5: - if (buf.remaining() < 8) - return false; - topVer = commState.getLong("topVer"); + if (!commState.lastRead()) + return false; + commState.idx++; case 6: - byte[] topicBytes0 = commState.getByteArray("topicBytes"); + topicBytes = commState.getByteArray("topicBytes"); - if (topicBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - topicBytes = topicBytes0; - commState.idx++; case 7: - if (buf.remaining() < 8) - return false; - updateSeq = commState.getLong("updateSeq"); + if (!commState.lastRead()) + return false; + commState.idx++; case 8: - if (buf.remaining() < 4) - return false; - workerId = commState.getInt("workerId"); + if (!commState.lastRead()) + return false; + commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java index 4736f5c747bbc..48d0d033a9f78 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java @@ -400,29 +400,27 @@ public int size() { switch (commState.idx) { case 3: - if (buf.remaining() < 1) - return false; - ack = commState.getBoolean("ack"); + if (!commState.lastRead()) + return false; + commState.idx++; case 4: - byte[] infoBytes0 = commState.getByteArray("infoBytes"); + infoBytes = commState.getByteArray("infoBytes"); - if (infoBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - infoBytes = infoBytes0; - commState.idx++; case 5: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -430,11 +428,11 @@ public int size() { last = new HashSet<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - if (buf.remaining() < 4) - return false; - int _val = commState.getInt(null); + if (!commState.lastRead()) + return false; + last.add((Integer)_val); commState.readItems++; @@ -448,10 +446,10 @@ public int size() { case 6: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -459,11 +457,11 @@ public int size() { missed = new HashSet<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - if (buf.remaining() < 4) - return false; - int _val = commState.getInt(null); + if (!commState.lastRead()) + return false; + missed.add((Integer)_val); commState.readItems++; @@ -476,19 +474,19 @@ public int size() { commState.idx++; case 7: - if (buf.remaining() < 8) - return false; - updateSeq = commState.getLong("updateSeq"); + if (!commState.lastRead()) + return false; + commState.idx++; case 8: - if (buf.remaining() < 4) - return false; - workerId = commState.getInt("workerId"); + if (!commState.lastRead()) + return false; + commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsAbstractMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsAbstractMessage.java index 6b975e7183b1a..4f9e7e2338714 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsAbstractMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsAbstractMessage.java @@ -118,23 +118,19 @@ public GridDhtPartitionExchangeId exchangeId() { switch (commState.idx) { case 3: - GridDhtPartitionExchangeId exchId0 = commState.getDhtPartitionExchangeId("exchId"); + exchId = commState.getDhtPartitionExchangeId("exchId"); - if (exchId0 == DHT_PART_EXCHANGE_ID_NOT_READ) + if (!commState.lastRead()) return false; - exchId = exchId0; - commState.idx++; case 4: - GridCacheVersion lastVer0 = commState.getCacheVersion("lastVer"); + lastVer = commState.getCacheVersion("lastVer"); - if (lastVer0 == CACHE_VER_NOT_READ) + if (!commState.lastRead()) return false; - lastVer = lastVer0; - commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java index 7ce00845a8ede..f1fed4f8c8a09 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java @@ -205,31 +205,27 @@ public void affinityAssignment(List> affAssignment) { switch (commState.idx) { case 5: - byte[] affAssignmentBytes0 = commState.getByteArray("affAssignmentBytes"); + affAssignmentBytes = commState.getByteArray("affAssignmentBytes"); - if (affAssignmentBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - affAssignmentBytes = affAssignmentBytes0; - commState.idx++; case 6: - byte[] partsBytes0 = commState.getByteArray("partsBytes"); + partsBytes = commState.getByteArray("partsBytes"); - if (partsBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - partsBytes = partsBytes0; - commState.idx++; case 7: - if (buf.remaining() < 8) - return false; - topVer = commState.getLong("topVer"); + if (!commState.lastRead()) + return false; + commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java index a2cee94b5990c..7216ab6b818a8 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java @@ -142,13 +142,11 @@ public Map partitions() { switch (commState.idx) { case 5: - byte[] partsBytes0 = commState.getByteArray("partsBytes"); + partsBytes = commState.getByteArray("partsBytes"); - if (partsBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - partsBytes = partsBytes0; - commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearGetRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearGetRequest.java index 133569af5cac0..362c101440eaa 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearGetRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearGetRequest.java @@ -380,10 +380,10 @@ public IgnitePredicate>[] filter() { switch (commState.idx) { case 3: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -393,7 +393,7 @@ public IgnitePredicate>[] filter() { for (int i = commState.readItems; i < commState.readSize; i++) { byte[] _val = commState.getByteArray(null); - if (_val == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; filterBytes[i] = (byte[])_val; @@ -408,21 +408,19 @@ public IgnitePredicate>[] filter() { commState.idx++; case 4: - IgniteUuid futId0 = commState.getGridUuid("futId"); + futId = commState.getGridUuid("futId"); - if (futId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - futId = futId0; - commState.idx++; case 5: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -433,18 +431,18 @@ public IgnitePredicate>[] filter() { if (!commState.keyDone) { byte[] _val = commState.getByteArray(null); - if (_val == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; commState.cur = _val; commState.keyDone = true; } - if (buf.remaining() < 1) - return false; - boolean _val = commState.getBoolean(null); + if (!commState.lastRead()) + return false; + keyBytes.put((byte[])commState.cur, _val); commState.keyDone = false; @@ -460,57 +458,51 @@ public IgnitePredicate>[] filter() { commState.idx++; case 6: - IgniteUuid miniId0 = commState.getGridUuid("miniId"); + miniId = commState.getGridUuid("miniId"); - if (miniId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - miniId = miniId0; - commState.idx++; case 7: - if (buf.remaining() < 1) - return false; - reload = commState.getBoolean("reload"); + if (!commState.lastRead()) + return false; + commState.idx++; case 8: - if (buf.remaining() < 8) - return false; - topVer = commState.getLong("topVer"); + if (!commState.lastRead()) + return false; + commState.idx++; case 9: - GridCacheVersion ver0 = commState.getCacheVersion("ver"); + ver = commState.getCacheVersion("ver"); - if (ver0 == CACHE_VER_NOT_READ) + if (!commState.lastRead()) return false; - ver = ver0; - commState.idx++; case 10: - UUID subjId0 = commState.getUuid("subjId"); + subjId = commState.getUuid("subjId"); - if (subjId0 == UUID_NOT_READ) + if (!commState.lastRead()) return false; - subjId = subjId0; - commState.idx++; case 11: - if (buf.remaining() < 4) - return false; - taskNameHash = commState.getInt("taskNameHash"); + if (!commState.lastRead()) + return false; + commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearGetResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearGetResponse.java index c652c521336dc..a53e0d85320e3 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearGetResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearGetResponse.java @@ -311,41 +311,35 @@ public void error(Throwable err) { switch (commState.idx) { case 3: - byte[] entriesBytes0 = commState.getByteArray("entriesBytes"); + entriesBytes = commState.getByteArray("entriesBytes"); - if (entriesBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - entriesBytes = entriesBytes0; - commState.idx++; case 4: - byte[] errBytes0 = commState.getByteArray("errBytes"); + errBytes = commState.getByteArray("errBytes"); - if (errBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - errBytes = errBytes0; - commState.idx++; case 5: - IgniteUuid futId0 = commState.getGridUuid("futId"); + futId = commState.getGridUuid("futId"); - if (futId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - futId = futId0; - commState.idx++; case 6: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -353,11 +347,11 @@ public void error(Throwable err) { invalidParts = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - if (buf.remaining() < 4) - return false; - int _val = commState.getInt(null); + if (!commState.lastRead()) + return false; + invalidParts.add((Integer)_val); commState.readItems++; @@ -370,31 +364,27 @@ public void error(Throwable err) { commState.idx++; case 7: - IgniteUuid miniId0 = commState.getGridUuid("miniId"); + miniId = commState.getGridUuid("miniId"); - if (miniId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - miniId = miniId0; - commState.idx++; case 8: - if (buf.remaining() < 8) - return false; - topVer = commState.getLong("topVer"); + if (!commState.lastRead()) + return false; + commState.idx++; case 9: - GridCacheVersion ver0 = commState.getCacheVersion("ver"); + ver = commState.getCacheVersion("ver"); - if (ver0 == CACHE_VER_NOT_READ) + if (!commState.lastRead()) return false; - ver = ver0; - commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearLockRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearLockRequest.java index d0086ba0a84b4..4d5be8b46155d 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearLockRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearLockRequest.java @@ -428,34 +428,35 @@ public GridCacheVersion dhtVersion(int idx) { commState.idx++; case 30: - if (!commState.putLong("topVer", topVer)) + if (!commState.putBoolean("syncCommit", syncCommit)) return false; commState.idx++; case 31: - if (!commState.putUuid("subjId", subjId)) + if (!commState.putLong("topVer", topVer)) return false; commState.idx++; case 32: - if (!commState.putInt("taskNameHash", taskNameHash)) + if (!commState.putUuid("subjId", subjId)) return false; commState.idx++; case 33: - if (!commState.putBoolean("hasTransforms", hasTransforms)) + if (!commState.putInt("taskNameHash", taskNameHash)) return false; commState.idx++; case 34: - if (!commState.putBoolean("syncCommit", syncCommit)) + if (!commState.putBoolean("hasTransforms", hasTransforms)) return false; commState.idx++; + } return true; @@ -472,10 +473,10 @@ public GridCacheVersion dhtVersion(int idx) { switch (commState.idx) { case 24: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -485,7 +486,7 @@ public GridCacheVersion dhtVersion(int idx) { for (int i = commState.readItems; i < commState.readSize; i++) { GridCacheVersion _val = commState.getCacheVersion(null); - if (_val == CACHE_VER_NOT_READ) + if (!commState.lastRead()) return false; dhtVers[i] = (GridCacheVersion)_val; @@ -501,10 +502,10 @@ public GridCacheVersion dhtVersion(int idx) { case 25: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -514,7 +515,7 @@ public GridCacheVersion dhtVersion(int idx) { for (int i = commState.readItems; i < commState.readSize; i++) { byte[] _val = commState.getByteArray(null); - if (_val == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; filterBytes[i] = (byte[])_val; @@ -529,80 +530,77 @@ public GridCacheVersion dhtVersion(int idx) { commState.idx++; case 26: - if (buf.remaining() < 1) - return false; - implicitSingleTx = commState.getBoolean("implicitSingleTx"); + if (!commState.lastRead()) + return false; + commState.idx++; case 27: - if (buf.remaining() < 1) - return false; - implicitTx = commState.getBoolean("implicitTx"); + if (!commState.lastRead()) + return false; + commState.idx++; case 28: - IgniteUuid miniId0 = commState.getGridUuid("miniId"); + miniId = commState.getGridUuid("miniId"); - if (miniId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - miniId = miniId0; - commState.idx++; case 29: - if (buf.remaining() < 1) - return false; - onePhaseCommit = commState.getBoolean("onePhaseCommit"); + if (!commState.lastRead()) + return false; + commState.idx++; case 30: - if (buf.remaining() < 8) - return false; + syncCommit = commState.getBoolean("syncCommit"); - topVer = commState.getLong("topVer"); + if (!commState.lastRead()) + return false; commState.idx++; case 31: - UUID subjId0 = commState.getUuid("subjId"); + topVer = commState.getLong("topVer"); - if (subjId0 == UUID_NOT_READ) + if (!commState.lastRead()) return false; - subjId = subjId0; - commState.idx++; case 32: - if (buf.remaining() < 4) - return false; + subjId = commState.getUuid("subjId"); - taskNameHash = commState.getInt("taskNameHash"); + if (!commState.lastRead()) + return false; commState.idx++; case 33: - if (buf.remaining() < 1) - return false; + taskNameHash = commState.getInt("taskNameHash"); - hasTransforms = commState.getBoolean("hasTransforms"); + if (!commState.lastRead()) + return false; commState.idx++; case 34: - if (buf.remaining() < 1) - return false; + hasTransforms = commState.getBoolean("hasTransforms"); - syncCommit = commState.getBoolean("syncCommit"); + if (!commState.lastRead()) + return false; commState.idx++; + } return true; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearLockResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearLockResponse.java index 9c0a0b0fcddbd..9000530a01b8b 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearLockResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearLockResponse.java @@ -318,10 +318,10 @@ public void addValueBytes( switch (commState.idx) { case 11: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -331,7 +331,7 @@ public void addValueBytes( for (int i = commState.readItems; i < commState.readSize; i++) { GridCacheVersion _val = commState.getCacheVersion(null); - if (_val == CACHE_VER_NOT_READ) + if (!commState.lastRead()) return false; dhtVers[i] = (GridCacheVersion)_val; @@ -346,21 +346,19 @@ public void addValueBytes( commState.idx++; case 12: - boolean[] filterRes0 = commState.getBooleanArray("filterRes"); + filterRes = commState.getBooleanArray("filterRes"); - if (filterRes0 == BOOLEAN_ARR_NOT_READ) + if (!commState.lastRead()) return false; - filterRes = filterRes0; - commState.idx++; case 13: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -370,7 +368,7 @@ public void addValueBytes( for (int i = commState.readItems; i < commState.readSize; i++) { GridCacheVersion _val = commState.getCacheVersion(null); - if (_val == CACHE_VER_NOT_READ) + if (!commState.lastRead()) return false; mappedVers[i] = (GridCacheVersion)_val; @@ -385,21 +383,19 @@ public void addValueBytes( commState.idx++; case 14: - IgniteUuid miniId0 = commState.getGridUuid("miniId"); + miniId = commState.getGridUuid("miniId"); - if (miniId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - miniId = miniId0; - commState.idx++; case 15: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -409,7 +405,7 @@ public void addValueBytes( for (int i = commState.readItems; i < commState.readSize; i++) { GridCacheVersion _val = commState.getCacheVersion(null); - if (_val == CACHE_VER_NOT_READ) + if (!commState.lastRead()) return false; pending.add((GridCacheVersion)_val); diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxFinishRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxFinishRequest.java index 0a58739e2410d..5df67ad6f2e9b 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxFinishRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxFinishRequest.java @@ -193,40 +193,41 @@ public int taskNameHash() { switch (commState.idx) { case 21: - if (!commState.putBoolean(null, explicitLock)) + if (!commState.putBoolean("explicitLock", explicitLock)) return false; commState.idx++; case 22: - if (!commState.putGridUuid(null, miniId)) + if (!commState.putGridUuid("miniId", miniId)) return false; commState.idx++; case 23: - if (!commState.putLong(null, topVer)) + if (!commState.putBoolean("storeEnabled", storeEnabled)) return false; commState.idx++; case 24: - if (!commState.putUuid(null, subjId)) + if (!commState.putLong("topVer", topVer)) return false; commState.idx++; case 25: - if (!commState.putInt(null, taskNameHash)) + if (!commState.putUuid("subjId", subjId)) return false; commState.idx++; case 26: - if (!commState.putBoolean(null, storeEnabled)) + if (!commState.putInt("taskNameHash", taskNameHash)) return false; commState.idx++; + } return true; @@ -242,56 +243,53 @@ public int taskNameHash() { switch (commState.idx) { case 21: - if (buf.remaining() < 1) - return false; + explicitLock = commState.getBoolean("explicitLock"); - explicitLock = commState.getBoolean(null); + if (!commState.lastRead()) + return false; commState.idx++; case 22: - IgniteUuid miniId0 = commState.getGridUuid(null); + miniId = commState.getGridUuid("miniId"); - if (miniId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - miniId = miniId0; - commState.idx++; case 23: - if (buf.remaining() < 8) - return false; + storeEnabled = commState.getBoolean("storeEnabled"); - topVer = commState.getLong(null); + if (!commState.lastRead()) + return false; commState.idx++; case 24: - UUID subjId0 = commState.getUuid(null); + topVer = commState.getLong("topVer"); - if (subjId0 == UUID_NOT_READ) + if (!commState.lastRead()) return false; - subjId = subjId0; - commState.idx++; case 25: - if (buf.remaining() < 4) - return false; + subjId = commState.getUuid("subjId"); - taskNameHash = commState.getInt(null); + if (!commState.lastRead()) + return false; commState.idx++; case 26: - if (buf.remaining() < 1) - return false; + taskNameHash = commState.getInt("taskNameHash"); - storeEnabled = commState.getBoolean(null); + if (!commState.lastRead()) + return false; commState.idx++; + } return true; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxFinishResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxFinishResponse.java index 93629bf1963db..e1b4dbcd818da 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxFinishResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxFinishResponse.java @@ -175,31 +175,27 @@ public long threadId() { switch (commState.idx) { case 5: - byte[] errBytes0 = commState.getByteArray("errBytes"); + errBytes = commState.getByteArray("errBytes"); - if (errBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - errBytes = errBytes0; - commState.idx++; case 6: - IgniteUuid miniId0 = commState.getGridUuid("miniId"); + miniId = commState.getGridUuid("miniId"); - if (miniId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - miniId = miniId0; - commState.idx++; case 7: - if (buf.remaining() < 8) - return false; - nearThreadId = commState.getLong("nearThreadId"); + if (!commState.lastRead()) + return false; + commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareRequest.java index 7eb57a69e4053..c94089b7c0ec3 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridNearTxPrepareRequest.java @@ -220,6 +220,7 @@ private Collection> cloneEntries(Collection> cloneEntries(Collection> cloneEntries(Collection> cloneEntries(Collection= 0) { @@ -359,7 +358,7 @@ private Collection> cloneEntries(Collection> cloneEntries(Collection invalidPartitions() { switch (commState.idx) { case 10: - GridCacheVersion dhtVer0 = commState.getCacheVersion("dhtVer"); + dhtVer = commState.getCacheVersion("dhtVer"); - if (dhtVer0 == CACHE_VER_NOT_READ) + if (!commState.lastRead()) return false; - dhtVer = dhtVer0; - commState.idx++; case 11: - IgniteUuid futId0 = commState.getGridUuid("futId"); + futId = commState.getGridUuid("futId"); - if (futId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - futId = futId0; - commState.idx++; case 12: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -401,11 +397,11 @@ public Collection invalidPartitions() { invalidParts = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - if (buf.remaining() < 4) - return false; - int _val = commState.getInt(null); + if (!commState.lastRead()) + return false; + invalidParts.add((Integer)_val); commState.readItems++; @@ -418,21 +414,19 @@ public Collection invalidPartitions() { commState.idx++; case 13: - IgniteUuid miniId0 = commState.getGridUuid("miniId"); + miniId = commState.getGridUuid("miniId"); - if (miniId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - miniId = miniId0; - commState.idx++; case 14: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -442,7 +436,7 @@ public Collection invalidPartitions() { for (int i = commState.readItems; i < commState.readSize; i++) { byte[] _val = commState.getByteArray(null); - if (_val == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; ownedValsBytes.add((byte[])_val); @@ -458,10 +452,10 @@ public Collection invalidPartitions() { case 15: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -471,7 +465,7 @@ public Collection invalidPartitions() { for (int i = commState.readItems; i < commState.readSize; i++) { GridCacheVersion _val = commState.getCacheVersion(null); - if (_val == CACHE_VER_NOT_READ) + if (!commState.lastRead()) return false; pending.add((GridCacheVersion)_val); diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueryRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueryRequest.java index 46145131b069b..01715b08b77f6 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueryRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueryRequest.java @@ -622,175 +622,157 @@ public int taskHash() { switch (commState.idx) { case 3: - if (buf.remaining() < 1) - return false; - all = commState.getBoolean("all"); + if (!commState.lastRead()) + return false; + commState.idx++; case 4: - byte[] argsBytes0 = commState.getByteArray("argsBytes"); + argsBytes = commState.getByteArray("argsBytes"); - if (argsBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - argsBytes = argsBytes0; - commState.idx++; case 5: - String cacheName0 = commState.getString("cacheName"); + cacheName = commState.getString("cacheName"); - if (cacheName0 == STR_NOT_READ) + if (!commState.lastRead()) return false; - cacheName = cacheName0; - commState.idx++; case 6: - if (buf.remaining() < 1) - return false; - cancel = commState.getBoolean("cancel"); + if (!commState.lastRead()) + return false; + commState.idx++; case 7: - String clause0 = commState.getString("clause"); + clause = commState.getString("clause"); - if (clause0 == STR_NOT_READ) + if (!commState.lastRead()) return false; - clause = clause0; - commState.idx++; case 8: - String clsName0 = commState.getString("clsName"); + clsName = commState.getString("clsName"); - if (clsName0 == STR_NOT_READ) + if (!commState.lastRead()) return false; - clsName = clsName0; - commState.idx++; case 9: - if (buf.remaining() < 1) - return false; - fields = commState.getBoolean("fields"); + if (!commState.lastRead()) + return false; + commState.idx++; case 10: - if (buf.remaining() < 8) - return false; - id = commState.getLong("id"); + if (!commState.lastRead()) + return false; + commState.idx++; case 11: - if (buf.remaining() < 1) - return false; - incBackups = commState.getBoolean("incBackups"); + if (!commState.lastRead()) + return false; + commState.idx++; case 12: - if (buf.remaining() < 1) - return false; - incMeta = commState.getBoolean("incMeta"); + if (!commState.lastRead()) + return false; + commState.idx++; case 13: - byte[] keyValFilterBytes0 = commState.getByteArray("keyValFilterBytes"); + keyValFilterBytes = commState.getByteArray("keyValFilterBytes"); - if (keyValFilterBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - keyValFilterBytes = keyValFilterBytes0; - commState.idx++; case 14: - if (buf.remaining() < 4) - return false; - pageSize = commState.getInt("pageSize"); + if (!commState.lastRead()) + return false; + commState.idx++; case 15: - byte[] prjFilterBytes0 = commState.getByteArray("prjFilterBytes"); + prjFilterBytes = commState.getByteArray("prjFilterBytes"); - if (prjFilterBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - prjFilterBytes = prjFilterBytes0; - commState.idx++; case 16: - byte[] rdcBytes0 = commState.getByteArray("rdcBytes"); + rdcBytes = commState.getByteArray("rdcBytes"); - if (rdcBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - rdcBytes = rdcBytes0; - commState.idx++; case 17: - byte[] transBytes0 = commState.getByteArray("transBytes"); + transBytes = commState.getByteArray("transBytes"); - if (transBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - transBytes = transBytes0; - commState.idx++; case 18: - if (buf.remaining() < 1) - return false; - byte type0 = commState.getByte("type"); + if (!commState.lastRead()) + return false; + type = GridCacheQueryType.fromOrdinal(type0); commState.idx++; case 19: - if (buf.remaining() < 1) - return false; - keepPortable = commState.getBoolean("keepPortable"); + if (!commState.lastRead()) + return false; + commState.idx++; case 20: - UUID subjId0 = commState.getUuid("subjId"); + subjId = commState.getUuid("subjId"); - if (subjId0 == UUID_NOT_READ) + if (!commState.lastRead()) return false; - subjId = subjId0; - commState.idx++; case 21: - if (buf.remaining() < 4) - return false; - taskHash = commState.getInt("taskHash"); + if (!commState.lastRead()) + return false; + commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueryResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueryResponse.java index 825a575fc3908..6799609f9d62c 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueryResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/query/GridCacheQueryResponse.java @@ -330,10 +330,10 @@ public boolean fields() { switch (commState.idx) { case 3: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -343,7 +343,7 @@ public boolean fields() { for (int i = commState.readItems; i < commState.readSize; i++) { byte[] _val = commState.getByteArray(null); - if (_val == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; dataBytes.add((byte[])_val); @@ -358,37 +358,35 @@ public boolean fields() { commState.idx++; case 4: - byte[] errBytes0 = commState.getByteArray("errBytes"); + errBytes = commState.getByteArray("errBytes"); - if (errBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - errBytes = errBytes0; - commState.idx++; case 5: - if (buf.remaining() < 1) - return false; - fields = commState.getBoolean("fields"); + if (!commState.lastRead()) + return false; + commState.idx++; case 6: - if (buf.remaining() < 1) - return false; - finished = commState.getBoolean("finished"); + if (!commState.lastRead()) + return false; + commState.idx++; case 7: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -398,7 +396,7 @@ public boolean fields() { for (int i = commState.readItems; i < commState.readSize; i++) { byte[] _val = commState.getByteArray(null); - if (_val == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; metaDataBytes.add((byte[])_val); @@ -413,11 +411,11 @@ public boolean fields() { commState.idx++; case 8: - if (buf.remaining() < 8) - return false; - reqId = commState.getLong("reqId"); + if (!commState.lastRead()) + return false; + commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/clock/GridClockDeltaSnapshotMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/clock/GridClockDeltaSnapshotMessage.java index cca184bbdcdf3..c641b52e0451b 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/clock/GridClockDeltaSnapshotMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/clock/GridClockDeltaSnapshotMessage.java @@ -151,10 +151,10 @@ public Map deltas() { switch (commState.idx) { case 0: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -165,18 +165,18 @@ public Map deltas() { if (!commState.keyDone) { UUID _val = commState.getUuid(null); - if (_val == UUID_NOT_READ) + if (!commState.lastRead()) return false; commState.cur = _val; commState.keyDone = true; } - if (buf.remaining() < 8) - return false; - long _val = commState.getLong(null); + if (!commState.lastRead()) + return false; + deltas.put((UUID)commState.cur, _val); commState.keyDone = false; @@ -192,13 +192,11 @@ public Map deltas() { commState.idx++; case 1: - GridClockDeltaVersion snapVer0 = commState.getClockDeltaVersion("snapVer"); + snapVer = commState.getClockDeltaVersion("snapVer"); - if (snapVer0 == CLOCK_DELTA_VER_NOT_READ) + if (!commState.lastRead()) return false; - snapVer = snapVer0; - commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/continuous/GridContinuousMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/continuous/GridContinuousMessage.java index 6f0ef14243a47..83f3a056db90f 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/continuous/GridContinuousMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/continuous/GridContinuousMessage.java @@ -166,31 +166,27 @@ public void dataBytes(byte[] dataBytes) { switch (commState.idx) { case 0: - byte[] dataBytes0 = commState.getByteArray("dataBytes"); + dataBytes = commState.getByteArray("dataBytes"); - if (dataBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - dataBytes = dataBytes0; - commState.idx++; case 1: - UUID routineId0 = commState.getUuid("routineId"); + routineId = commState.getUuid("routineId"); - if (routineId0 == UUID_NOT_READ) + if (!commState.lastRead()) return false; - routineId = routineId0; - commState.idx++; case 2: - if (buf.remaining() < 1) - return false; - byte type0 = commState.getByte("type"); + if (!commState.lastRead()) + return false; + type = GridContinuousMessageType.fromOrdinal(type0); commState.idx++; diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/dataload/GridDataLoadRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/dataload/GridDataLoadRequest.java index d7b815e848883..3f50b480944ff 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/dataload/GridDataLoadRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/dataload/GridDataLoadRequest.java @@ -328,67 +328,61 @@ public boolean forceLocalDeployment() { switch (commState.idx) { case 0: - String cacheName0 = commState.getString("cacheName"); + cacheName = commState.getString("cacheName"); - if (cacheName0 == STR_NOT_READ) + if (!commState.lastRead()) return false; - cacheName = cacheName0; - commState.idx++; case 1: - IgniteUuid clsLdrId0 = commState.getGridUuid("clsLdrId"); + clsLdrId = commState.getGridUuid("clsLdrId"); - if (clsLdrId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - clsLdrId = clsLdrId0; - commState.idx++; case 2: - byte[] colBytes0 = commState.getByteArray("colBytes"); + colBytes = commState.getByteArray("colBytes"); - if (colBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - colBytes = colBytes0; - commState.idx++; case 3: - if (buf.remaining() < 1) - return false; - byte depMode0 = commState.getByte("depMode"); + if (!commState.lastRead()) + return false; + depMode = IgniteDeploymentMode.fromOrdinal(depMode0); commState.idx++; case 4: - if (buf.remaining() < 1) - return false; - forceLocDep = commState.getBoolean("forceLocDep"); + if (!commState.lastRead()) + return false; + commState.idx++; case 5: - if (buf.remaining() < 1) - return false; - ignoreDepOwnership = commState.getBoolean("ignoreDepOwnership"); + if (!commState.lastRead()) + return false; + commState.idx++; case 6: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -399,7 +393,7 @@ public boolean forceLocalDeployment() { if (!commState.keyDone) { UUID _val = commState.getUuid(null); - if (_val == UUID_NOT_READ) + if (!commState.lastRead()) return false; commState.cur = _val; @@ -408,7 +402,7 @@ public boolean forceLocalDeployment() { IgniteUuid _val = commState.getGridUuid(null); - if (_val == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; ldrParticipants.put((UUID)commState.cur, _val); @@ -426,51 +420,43 @@ public boolean forceLocalDeployment() { commState.idx++; case 7: - if (buf.remaining() < 8) - return false; - reqId = commState.getLong("reqId"); + if (!commState.lastRead()) + return false; + commState.idx++; case 8: - byte[] resTopicBytes0 = commState.getByteArray("resTopicBytes"); + resTopicBytes = commState.getByteArray("resTopicBytes"); - if (resTopicBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - resTopicBytes = resTopicBytes0; - commState.idx++; case 9: - String sampleClsName0 = commState.getString("sampleClsName"); + sampleClsName = commState.getString("sampleClsName"); - if (sampleClsName0 == STR_NOT_READ) + if (!commState.lastRead()) return false; - sampleClsName = sampleClsName0; - commState.idx++; case 10: - byte[] updaterBytes0 = commState.getByteArray("updaterBytes"); + updaterBytes = commState.getByteArray("updaterBytes"); - if (updaterBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - updaterBytes = updaterBytes0; - commState.idx++; case 11: - String userVer0 = commState.getString("userVer"); + userVer = commState.getString("userVer"); - if (userVer0 == STR_NOT_READ) + if (!commState.lastRead()) return false; - userVer = userVer0; - commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/dataload/GridDataLoadResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/dataload/GridDataLoadResponse.java index 46bab8511c420..20e1678ae8b23 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/dataload/GridDataLoadResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/dataload/GridDataLoadResponse.java @@ -136,29 +136,27 @@ public boolean forceLocalDeployment() { switch (commState.idx) { case 0: - byte[] errBytes0 = commState.getByteArray("errBytes"); + errBytes = commState.getByteArray("errBytes"); - if (errBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - errBytes = errBytes0; - commState.idx++; case 1: - if (buf.remaining() < 1) - return false; - forceLocDep = commState.getBoolean("forceLocDep"); + if (!commState.lastRead()) + return false; + commState.idx++; case 2: - if (buf.remaining() < 8) - return false; - reqId = commState.getLong("reqId"); + if (!commState.lastRead()) + return false; + commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsAckMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsAckMessage.java index d3cb730de124e..fa5b23b254915 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsAckMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsAckMessage.java @@ -165,31 +165,27 @@ public IgniteCheckedException error() { switch (commState.idx) { case 0: - byte[] errBytes0 = commState.getByteArray("errBytes"); + errBytes = commState.getByteArray("errBytes"); - if (errBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - errBytes = errBytes0; - commState.idx++; case 1: - IgniteUuid fileId0 = commState.getGridUuid("fileId"); + fileId = commState.getGridUuid("fileId"); - if (fileId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - fileId = fileId0; - commState.idx++; case 2: - if (buf.remaining() < 8) - return false; - id = commState.getLong("id"); + if (!commState.lastRead()) + return false; + commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsBlockKey.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsBlockKey.java index 0675e7b9e3092..9417334266692 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsBlockKey.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsBlockKey.java @@ -219,39 +219,35 @@ public long getBlockId() { switch (commState.idx) { case 0: - IgniteUuid affKey0 = commState.getGridUuid("affKey"); + affKey = commState.getGridUuid("affKey"); - if (affKey0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - affKey = affKey0; - commState.idx++; case 1: - if (buf.remaining() < 8) - return false; - blockId = commState.getLong("blockId"); + if (!commState.lastRead()) + return false; + commState.idx++; case 2: - if (buf.remaining() < 1) - return false; - evictExclude = commState.getBoolean("evictExclude"); + if (!commState.lastRead()) + return false; + commState.idx++; case 3: - IgniteUuid fileId0 = commState.getGridUuid("fileId"); + fileId = commState.getGridUuid("fileId"); - if (fileId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - fileId = fileId0; - commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsBlocksMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsBlocksMessage.java index 0b169a76bfcd9..52e4e96865cf2 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsBlocksMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsBlocksMessage.java @@ -12,7 +12,6 @@ import org.apache.ignite.lang.*; import org.gridgain.grid.kernal.*; import org.gridgain.grid.util.direct.*; -import org.gridgain.grid.util.typedef.internal.*; import java.io.*; import java.nio.*; @@ -179,10 +178,10 @@ public Map blocks() { switch (commState.idx) { case 0: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -191,9 +190,9 @@ public Map blocks() { for (int i = commState.readItems; i < commState.readSize; i++) { if (!commState.keyDone) { - Object _val = commState.getMessage(null); + GridGgfsBlockKey _val = (GridGgfsBlockKey)commState.getMessage(null); - if (_val == MSG_NOT_READ) + if (!commState.lastRead()) return false; commState.cur = _val; @@ -202,7 +201,7 @@ public Map blocks() { byte[] _val = commState.getByteArray(null); - if (_val == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; blocks.put((GridGgfsBlockKey)commState.cur, _val); @@ -220,21 +219,19 @@ public Map blocks() { commState.idx++; case 1: - IgniteUuid fileId0 = commState.getGridUuid("fileId"); + fileId = commState.getGridUuid("fileId"); - if (fileId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - fileId = fileId0; - commState.idx++; case 2: - if (buf.remaining() < 8) - return false; - id = commState.getLong("id"); + if (!commState.lastRead()) + return false; + commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsDeleteMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsDeleteMessage.java index e2fedec69c97d..f247c7d67446e 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsDeleteMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsDeleteMessage.java @@ -162,23 +162,19 @@ public IgniteCheckedException error() { switch (commState.idx) { case 0: - byte[] errBytes0 = commState.getByteArray("errBytes"); + errBytes = commState.getByteArray("errBytes"); - if (errBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - errBytes = errBytes0; - commState.idx++; case 1: - IgniteUuid id0 = commState.getGridUuid("id"); + id = commState.getGridUuid("id"); - if (id0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - id = id0; - commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsFileAffinityRange.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsFileAffinityRange.java index ce82844b5b65a..f120fdcde1748 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsFileAffinityRange.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsFileAffinityRange.java @@ -330,45 +330,43 @@ public boolean regionEqual(GridGgfsFileAffinityRange other) { switch (commState.idx) { case 0: - IgniteUuid affKey0 = commState.getGridUuid("affKey"); + affKey = commState.getGridUuid("affKey"); - if (affKey0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - affKey = affKey0; - commState.idx++; case 1: - if (buf.remaining() < 1) - return false; - done = commState.getBoolean("done"); + if (!commState.lastRead()) + return false; + commState.idx++; case 2: - if (buf.remaining() < 8) - return false; - endOff = commState.getLong("endOff"); + if (!commState.lastRead()) + return false; + commState.idx++; case 3: - if (buf.remaining() < 8) - return false; - startOff = commState.getLong("startOff"); + if (!commState.lastRead()) + return false; + commState.idx++; case 4: - if (buf.remaining() < 4) - return false; - status = commState.getInt("status"); + if (!commState.lastRead()) + return false; + commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsFragmentizerRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsFragmentizerRequest.java index b35991bbe10f0..34c8a0ff11723 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsFragmentizerRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsFragmentizerRequest.java @@ -154,21 +154,19 @@ public Collection fragmentRanges() { switch (commState.idx) { case 0: - IgniteUuid fileId0 = commState.getGridUuid("fileId"); + fileId = commState.getGridUuid("fileId"); - if (fileId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - fileId = fileId0; - commState.idx++; case 1: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -176,9 +174,9 @@ public Collection fragmentRanges() { fragmentRanges = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - Object _val = commState.getMessage(null); + GridGgfsFileAffinityRange _val = (GridGgfsFileAffinityRange)commState.getMessage(null); - if (_val == MSG_NOT_READ) + if (!commState.lastRead()) return false; fragmentRanges.add((GridGgfsFileAffinityRange)_val); diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsFragmentizerResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsFragmentizerResponse.java index 5ea3ae5552a9d..a52d671bf6956 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsFragmentizerResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsFragmentizerResponse.java @@ -102,13 +102,11 @@ public IgniteUuid fileId() { switch (commState.idx) { case 0: - IgniteUuid fileId0 = commState.getGridUuid("fileId"); + fileId = commState.getGridUuid("fileId"); - if (fileId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - fileId = fileId0; - commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsSyncMessage.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsSyncMessage.java index 4cbec782af219..3ba6969b97f1f 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsSyncMessage.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/ggfs/GridGgfsSyncMessage.java @@ -126,19 +126,19 @@ public boolean response() { switch (commState.idx) { case 0: - if (buf.remaining() < 8) - return false; - order = commState.getLong("order"); + if (!commState.lastRead()) + return false; + commState.idx++; case 1: - if (buf.remaining() < 1) - return false; - res = commState.getBoolean("res"); + if (!commState.lastRead()) + return false; + commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java index df9fd66d8ca6a..25a193801273a 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java @@ -78,13 +78,11 @@ public byte[] bytes() { switch (commState.idx) { case 0: - byte[] bytes0 = commState.getByteArray("bytes"); + bytes = commState.getByteArray("bytes"); - if (bytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - bytes = bytes0; - commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java index bf3ee7c11bf2f..5833251a1c283 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java @@ -67,11 +67,11 @@ public GridClientHandshakeResponseWrapper(byte code) { switch (commState.idx) { case 0: - if (buf.remaining() < 1) - return false; - code = commState.getByte("code"); + if (!commState.lastRead()) + return false; + commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientMessageWrapper.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientMessageWrapper.java index 128c657bc7f25..c866797151bea 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientMessageWrapper.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientMessageWrapper.java @@ -173,49 +173,43 @@ public void message(ByteBuffer msg) { switch (commState.idx) { case 0: - UUID clientId0 = commState.getUuid("clientId"); + clientId = commState.getUuid("clientId"); - if (clientId0 == UUID_NOT_READ) + if (!commState.lastRead()) return false; - clientId = clientId0; - commState.idx++; case 1: - UUID destId0 = commState.getUuid("destId"); + destId = commState.getUuid("destId"); - if (destId0 == UUID_NOT_READ) + if (!commState.lastRead()) return false; - destId = destId0; - commState.idx++; case 2: - ByteBuffer msg0 = commState.getByteBuffer("msg"); + msg = commState.getByteBuffer("msg"); - if (msg0 == BYTE_BUF_NOT_READ) + if (!commState.lastRead()) return false; - msg = msg0; - commState.idx++; case 3: - if (buf.remaining() < 4) - return false; - msgSize = commState.getInt("msgSize"); + if (!commState.lastRead()) + return false; + commState.idx++; case 4: - if (buf.remaining() < 8) - return false; - reqId = commState.getLong("reqId"); + if (!commState.lastRead()) + return false; + commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientPingPacketWrapper.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientPingPacketWrapper.java index ea1da3dd93a49..e4d06c30bbacc 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientPingPacketWrapper.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/client/message/GridClientPingPacketWrapper.java @@ -53,11 +53,11 @@ public class GridClientPingPacketWrapper extends GridTcpCommunicationMessageAdap switch (commState.idx) { case 0: - if (buf.remaining() < 4) - return false; - size = commState.getInt("size"); + if (!commState.lastRead()) + return false; + commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/handlers/task/GridTaskResultRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/handlers/task/GridTaskResultRequest.java index 1894d03bd5400..cd06c68acc2d6 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/handlers/task/GridTaskResultRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/handlers/task/GridTaskResultRequest.java @@ -146,23 +146,19 @@ public void topic(String topic) { switch (commState.idx) { case 0: - IgniteUuid taskId0 = commState.getGridUuid("taskId"); + taskId = commState.getGridUuid("taskId"); - if (taskId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - taskId = taskId0; - commState.idx++; case 1: - byte[] topicBytes0 = commState.getByteArray("topicBytes"); + topicBytes = commState.getByteArray("topicBytes"); - if (topicBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - topicBytes = topicBytes0; - commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/handlers/task/GridTaskResultResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/handlers/task/GridTaskResultResponse.java index 6d3043227de0e..6810315b06d4f 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/handlers/task/GridTaskResultResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/handlers/task/GridTaskResultResponse.java @@ -178,39 +178,35 @@ public void error(String err) { switch (commState.idx) { case 0: - String err0 = commState.getString("err"); + err = commState.getString("err"); - if (err0 == STR_NOT_READ) + if (!commState.lastRead()) return false; - err = err0; - commState.idx++; case 1: - if (buf.remaining() < 1) - return false; - finished = commState.getBoolean("finished"); + if (!commState.lastRead()) + return false; + commState.idx++; case 2: - if (buf.remaining() < 1) - return false; - found = commState.getBoolean("found"); + if (!commState.lastRead()) + return false; + commState.idx++; case 3: - byte[] resBytes0 = commState.getByteArray("resBytes"); + resBytes = commState.getByteArray("resBytes"); - if (resBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - resBytes = resBytes0; - commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java index 4aebe5470e126..bc5dc9509e8bd 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java @@ -82,13 +82,11 @@ public GridMemcachedMessageWrapper(GridMemcachedMessage msg, IgniteMarshaller jd switch (commState.idx) { case 0: - byte[] bytes0 = commState.getByteArray("bytes"); + bytes = commState.getByteArray("bytes"); - if (bytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - bytes = bytes0; - commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/streamer/GridStreamerCancelRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/streamer/GridStreamerCancelRequest.java index 358b7a4cfd9e3..879952eeb678b 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/streamer/GridStreamerCancelRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/streamer/GridStreamerCancelRequest.java @@ -94,13 +94,11 @@ public IgniteUuid cancelledFutureId() { switch (commState.idx) { case 0: - IgniteUuid cancelledFutId0 = commState.getGridUuid("cancelledFutId"); + cancelledFutId = commState.getGridUuid("cancelledFutId"); - if (cancelledFutId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - cancelledFutId = cancelledFutId0; - commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/streamer/GridStreamerExecutionRequest.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/streamer/GridStreamerExecutionRequest.java index be546c65745c4..709e71879c6e9 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/streamer/GridStreamerExecutionRequest.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/streamer/GridStreamerExecutionRequest.java @@ -263,49 +263,45 @@ public byte[] batchBytes() { switch (commState.idx) { case 0: - byte[] batchBytes0 = commState.getByteArray("batchBytes"); + batchBytes = commState.getByteArray("batchBytes"); - if (batchBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - batchBytes = batchBytes0; - commState.idx++; case 1: - IgniteUuid clsLdrId0 = commState.getGridUuid("clsLdrId"); + clsLdrId = commState.getGridUuid("clsLdrId"); - if (clsLdrId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - clsLdrId = clsLdrId0; - commState.idx++; case 2: - if (buf.remaining() < 1) - return false; - byte depMode0 = commState.getByte("depMode"); + if (!commState.lastRead()) + return false; + depMode = IgniteDeploymentMode.fromOrdinal(depMode0); commState.idx++; case 3: - if (buf.remaining() < 1) - return false; - forceLocDep = commState.getBoolean("forceLocDep"); + if (!commState.lastRead()) + return false; + commState.idx++; case 4: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -316,7 +312,7 @@ public byte[] batchBytes() { if (!commState.keyDone) { UUID _val = commState.getUuid(null); - if (_val == UUID_NOT_READ) + if (!commState.lastRead()) return false; commState.cur = _val; @@ -325,7 +321,7 @@ public byte[] batchBytes() { IgniteUuid _val = commState.getGridUuid(null); - if (_val == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; ldrParticipants.put((UUID)commState.cur, _val); @@ -343,23 +339,19 @@ public byte[] batchBytes() { commState.idx++; case 5: - String sampleClsName0 = commState.getString("sampleClsName"); + sampleClsName = commState.getString("sampleClsName"); - if (sampleClsName0 == STR_NOT_READ) + if (!commState.lastRead()) return false; - sampleClsName = sampleClsName0; - commState.idx++; case 6: - String userVer0 = commState.getString("userVer"); + userVer = commState.getString("userVer"); - if (userVer0 == STR_NOT_READ) + if (!commState.lastRead()) return false; - userVer = userVer0; - commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/streamer/GridStreamerResponse.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/streamer/GridStreamerResponse.java index bfaeb09244b55..790432e718bf0 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/streamer/GridStreamerResponse.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/streamer/GridStreamerResponse.java @@ -121,23 +121,19 @@ public byte[] errorBytes() { switch (commState.idx) { case 0: - byte[] errBytes0 = commState.getByteArray("errBytes"); + errBytes = commState.getByteArray("errBytes"); - if (errBytes0 == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; - errBytes = errBytes0; - commState.idx++; case 1: - IgniteUuid futId0 = commState.getGridUuid("futId"); + futId = commState.getGridUuid("futId"); - if (futId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - futId = futId0; - commState.idx++; } diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageAdapter.java b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageAdapter.java index 108425cc52c4f..c08d15faebd34 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageAdapter.java +++ b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageAdapter.java @@ -9,12 +9,19 @@ package org.gridgain.grid.util.direct; +import org.apache.ignite.lang.*; import org.apache.ignite.plugin.extensions.communication.*; +import org.gridgain.grid.kernal.processors.cache.*; +import org.gridgain.grid.kernal.processors.cache.distributed.dht.preloader.*; +import org.gridgain.grid.kernal.processors.clock.*; +import org.gridgain.grid.util.*; import java.io.*; import java.nio.*; import java.util.*; +import static org.apache.ignite.events.IgniteEventType.*; + /** * Communication message adapter. */ @@ -22,6 +29,89 @@ public abstract class GridTcpCommunicationMessageAdapter implements Serializable /** */ private static final long serialVersionUID = 0L; + /** */ + public static final byte[] BYTE_ARR_NOT_READ = new byte[0]; + + /** */ + public static final short[] SHORT_ARR_NOT_READ = new short[0]; + + /** */ + public static final int[] INT_ARR_NOT_READ = new int[0]; + + /** */ + public static final long[] LONG_ARR_NOT_READ = new long[0]; + + /** */ + public static final float[] FLOAT_ARR_NOT_READ = new float[0]; + + /** */ + public static final double[] DOUBLE_ARR_NOT_READ = new double[0]; + + /** */ + public static final char[] CHAR_ARR_NOT_READ = new char[0]; + + /** */ + public static final boolean[] BOOLEAN_ARR_NOT_READ = new boolean[0]; + + /** */ + public static final UUID UUID_NOT_READ = new UUID(0, 0); + + /** */ + public static final ByteBuffer BYTE_BUF_NOT_READ = ByteBuffer.allocate(0); + + /** */ + public static final IgniteUuid GRID_UUID_NOT_READ = new IgniteUuid(new UUID(0, 0), 0); + + /** */ + public static final GridClockDeltaVersion CLOCK_DELTA_VER_NOT_READ = new GridClockDeltaVersion(0, 0); + + /** */ + public static final GridByteArrayList BYTE_ARR_LIST_NOT_READ = new GridByteArrayList(new byte[0]); + + /** */ + public static final GridLongList LONG_LIST_NOT_READ = new GridLongList(0); + + /** */ + public static final GridCacheVersion CACHE_VER_NOT_READ = new GridCacheVersion(0, 0, 0, 0); + + /** */ + public static final GridDhtPartitionExchangeId DHT_PART_EXCHANGE_ID_NOT_READ = + new GridDhtPartitionExchangeId(new UUID(0, 0), EVT_NODE_LEFT, 1); + + /** */ + public static final GridCacheValueBytes VAL_BYTES_NOT_READ = new GridCacheValueBytes(); + + /** */ + @SuppressWarnings("RedundantStringConstructorCall") + public static final String STR_NOT_READ = new String(); + + /** */ + public static final BitSet BIT_SET_NOT_READ = new BitSet(); + + /** */ + public static final GridTcpCommunicationMessageAdapter MSG_NOT_READ = new GridTcpCommunicationMessageAdapter() { + @SuppressWarnings("CloneDoesntCallSuperClone") + @Override public GridTcpCommunicationMessageAdapter clone() { + throw new UnsupportedOperationException(); + } + + @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + throw new UnsupportedOperationException(); + } + + @Override public boolean writeTo(ByteBuffer buf) { + throw new UnsupportedOperationException(); + } + + @Override public boolean readFrom(ByteBuffer buf) { + throw new UnsupportedOperationException(); + } + + @Override public byte directType() { + throw new UnsupportedOperationException(); + } + }; + /** */ protected static final Object NULL = new Object(); diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java index 6f6cf81a58499..b61e4188909eb 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java +++ b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageState.java @@ -759,4 +759,8 @@ public final boolean putMessage(String name, @Nullable GridTcpCommunicationMessa public final GridTcpCommunicationMessageAdapter getMessage(String name) { return reader.readMessage(name); } + + public final boolean lastRead() { + return reader.isLastRead(); + } } From 7c93b5e9def21eed8b35795035d9ed2fa0acfb3b Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Sun, 1 Feb 2015 19:26:40 -0800 Subject: [PATCH 13/95] # IGNITE-61 - Fixed compilation --- .../internal/GridJobExecuteRequest.java | 2 +- .../internal/managers/GridManagerAdapter.java | 2 +- .../managers/communication/GridIoManager.java | 19 +++---- .../GridCacheTtlUpdateRequest.java | 50 +++++++++---------- .../distributed/dht/GridDhtLockRequest.java | 4 +- .../dht/GridDhtTxFinishRequest.java | 8 +-- .../atomic/GridDhtAtomicUpdateRequest.java | 10 ++-- .../atomic/GridNearAtomicUpdateRequest.java | 4 +- .../distributed/near/GridNearGetRequest.java | 4 +- .../ignite/internal/util/IgniteUtils.java | 1 + .../GridTcpCommunicationMessageAdapter.java | 5 +- .../GridTcpCommunicationMessageState.java | 5 +- .../internal/util/ipc/IpcToNioAdapter.java | 1 + .../internal/util/nio/GridDirectParser.java | 5 +- .../communication/MessageReader.java | 2 +- .../communication/MessageWriter.java | 2 +- .../apache/ignite/spi/IgniteSpiAdapter.java | 3 +- .../apache/ignite/spi/IgniteSpiContext.java | 8 +-- .../GridTcpCommunicationByteBufferStream.java | 8 +-- .../GridTcpCommunicationMessageReader.java | 3 +- .../GridTcpCommunicationMessageWriter.java | 1 + .../testframework/GridSpiTestContext.java | 13 +++-- 22 files changed, 83 insertions(+), 77 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java index 929f718dbbece..d26ce22c3096e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java @@ -832,7 +832,7 @@ public UUID getSubjectId() { commState.idx++; case 16: - UUID subjId0 = commState.getUuid(); + UUID subjId0 = commState.getUuid(null); if (subjId0 == UUID_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/GridManagerAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/GridManagerAdapter.java index a5c5e47411b9a..3cb470cb7b3ee 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/GridManagerAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/GridManagerAdapter.java @@ -516,7 +516,7 @@ protected final String stopInfo() { return e != null ? (V)e.value() : null; } - @Override public MessageFactory messageFactory() { + @Override public GridTcpMessageFactory messageFactory() { return ctx.io().messageFactory(); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java index b918b6817cb6f..e26a124ae19f8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java @@ -21,21 +21,22 @@ import org.apache.ignite.cluster.*; import org.apache.ignite.events.*; import org.apache.ignite.internal.*; -import org.apache.ignite.internal.util.*; -import org.apache.ignite.lang.*; -import org.apache.ignite.marshaller.*; -import org.apache.ignite.plugin.extensions.communication.*; -import org.apache.ignite.spi.*; -import org.apache.ignite.spi.communication.*; import org.apache.ignite.internal.managers.*; import org.apache.ignite.internal.managers.deployment.*; import org.apache.ignite.internal.managers.eventstorage.*; import org.apache.ignite.internal.processors.timeout.*; +import org.apache.ignite.internal.util.*; import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.internal.util.worker.*; +import org.apache.ignite.lang.*; +import org.apache.ignite.marshaller.*; +import org.apache.ignite.plugin.extensions.communication.*; +import org.apache.ignite.spi.*; +import org.apache.ignite.spi.communication.*; +import org.gridgain.grid.util.direct.*; import org.jdk8.backport.*; import org.jetbrains.annotations.*; @@ -138,7 +139,7 @@ public class GridIoManager extends GridManagerAdapter pluginMsgs; /** */ - private MessageFactory msgFactory; + private GridTcpMessageFactory msgFactory; /** */ private MessageWriterFactory writerFactory; @@ -200,7 +201,7 @@ public void initMessageFactory() { else producers = common; - msgFactory = new MessageFactory() { + msgFactory = new GridTcpMessageFactory() { @Override public GridTcpCommunicationMessageAdapter create(byte type) { GridTcpCommunicationMessageAdapter msg; @@ -222,7 +223,7 @@ public void initMessageFactory() { }; } - public MessageFactory messageFactory() { + public GridTcpMessageFactory messageFactory() { assert msgFactory != null; return msgFactory; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java index 615a1d422e6a7..6b0fa97b5e19d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java @@ -201,7 +201,7 @@ public List nearVersions() { return false; if (!commState.typeWritten) { - if (!commState.putByte(directType())) + if (!commState.putByte(null, directType())) return false; commState.typeWritten = true; @@ -211,7 +211,7 @@ public List nearVersions() { case 3: if (keysBytes != null) { if (commState.it == null) { - if (!commState.putInt(keysBytes.size())) + if (!commState.putInt(null, keysBytes.size())) return false; commState.it = keysBytes.iterator(); @@ -221,7 +221,7 @@ public List nearVersions() { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putByteArray((byte[])commState.cur)) + if (!commState.putByteArray(null, (byte[])commState.cur)) return false; commState.cur = NULL; @@ -229,7 +229,7 @@ public List nearVersions() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } @@ -238,7 +238,7 @@ public List nearVersions() { case 4: if (nearKeysBytes != null) { if (commState.it == null) { - if (!commState.putInt(nearKeysBytes.size())) + if (!commState.putInt(null, nearKeysBytes.size())) return false; commState.it = nearKeysBytes.iterator(); @@ -248,7 +248,7 @@ public List nearVersions() { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putByteArray((byte[])commState.cur)) + if (!commState.putByteArray(null, (byte[])commState.cur)) return false; commState.cur = NULL; @@ -256,7 +256,7 @@ public List nearVersions() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } @@ -265,7 +265,7 @@ public List nearVersions() { case 5: if (nearVers != null) { if (commState.it == null) { - if (!commState.putInt(nearVers.size())) + if (!commState.putInt(null, nearVers.size())) return false; commState.it = nearVers.iterator(); @@ -275,7 +275,7 @@ public List nearVersions() { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putCacheVersion((GridCacheVersion)commState.cur)) + if (!commState.putCacheVersion(null, (GridCacheVersion)commState.cur)) return false; commState.cur = NULL; @@ -283,20 +283,20 @@ public List nearVersions() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } commState.idx++; case 6: - if (!commState.putLong(topVer)) + if (!commState.putLong(null, topVer)) return false; commState.idx++; case 7: - if (!commState.putLong(ttl)) + if (!commState.putLong(null, ttl)) return false; commState.idx++; @@ -304,7 +304,7 @@ public List nearVersions() { case 8: if (vers != null) { if (commState.it == null) { - if (!commState.putInt(vers.size())) + if (!commState.putInt(null, vers.size())) return false; commState.it = vers.iterator(); @@ -314,7 +314,7 @@ public List nearVersions() { if (commState.cur == NULL) commState.cur = commState.it.next(); - if (!commState.putCacheVersion((GridCacheVersion)commState.cur)) + if (!commState.putCacheVersion(null, (GridCacheVersion)commState.cur)) return false; commState.cur = NULL; @@ -322,7 +322,7 @@ public List nearVersions() { commState.it = null; } else { - if (!commState.putInt(-1)) + if (!commState.putInt(null, -1)) return false; } @@ -346,7 +346,7 @@ public List nearVersions() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -354,7 +354,7 @@ public List nearVersions() { keysBytes = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(); + byte[] _val = commState.getByteArray(null); if (_val == BYTE_ARR_NOT_READ) return false; @@ -375,7 +375,7 @@ public List nearVersions() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -383,7 +383,7 @@ public List nearVersions() { nearKeysBytes = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(); + byte[] _val = commState.getByteArray(null); if (_val == BYTE_ARR_NOT_READ) return false; @@ -404,7 +404,7 @@ public List nearVersions() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -412,7 +412,7 @@ public List nearVersions() { nearVers = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheVersion _val = commState.getCacheVersion(); + GridCacheVersion _val = commState.getCacheVersion(null); if (_val == CACHE_VER_NOT_READ) return false; @@ -432,7 +432,7 @@ public List nearVersions() { if (buf.remaining() < 8) return false; - topVer = commState.getLong(); + topVer = commState.getLong(null); commState.idx++; @@ -440,7 +440,7 @@ public List nearVersions() { if (buf.remaining() < 8) return false; - ttl = commState.getLong(); + ttl = commState.getLong(null); commState.idx++; @@ -449,7 +449,7 @@ public List nearVersions() { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -457,7 +457,7 @@ public List nearVersions() { vers = new ArrayList<>(commState.readSize); for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheVersion _val = commState.getCacheVersion(); + GridCacheVersion _val = commState.getCacheVersion(null); if (_val == CACHE_VER_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java index b5fe8b32184ca..8ed971555e1ab 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java @@ -458,7 +458,7 @@ public long accessTtl() { commState.idx++; case 32: - if (!commState.putLong(accessTtl)) + if (!commState.putLong(null, accessTtl)) return false; commState.idx++; @@ -566,7 +566,7 @@ public long accessTtl() { if (buf.remaining() < 8) return false; - accessTtl = commState.getLong(); + accessTtl = commState.getLong(null); commState.idx++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java index 30987df96c319..c394cf682c54a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java @@ -506,13 +506,13 @@ public GridLongList nearTtls() { commState.idx++; case 32: - if (!commState.putLongList(ttls)) + if (!commState.putLongList(null, ttls)) return false; commState.idx++; case 33: - if (!commState.putLongList(nearTtls)) + if (!commState.putLongList(null, nearTtls)) return false; commState.idx++; @@ -664,7 +664,7 @@ public GridLongList nearTtls() { commState.idx++; case 32: - GridLongList ttls0 = commState.getLongList(); + GridLongList ttls0 = commState.getLongList(null); if (ttls0 == LONG_LIST_NOT_READ) return false; @@ -674,7 +674,7 @@ public GridLongList nearTtls() { commState.idx++; case 33: - GridLongList nearTtls0 = commState.getLongList(); + GridLongList nearTtls0 = commState.getLongList(null); if (nearTtls0 == LONG_LIST_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java index 6f7ce44d999e3..baf929b946483 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java @@ -866,13 +866,13 @@ public long nearExpireTime(int idx) { commState.idx++; case 12: - if (!commState.putLong(topVer)) + if (!commState.putLong(null, topVer)) return false; commState.idx++; case 13: - if (!commState.putLongList(ttls)) + if (!commState.putLongList(null, ttls)) return false; commState.idx++; @@ -1100,7 +1100,7 @@ public long nearExpireTime(int idx) { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { @@ -1154,7 +1154,7 @@ public long nearExpireTime(int idx) { commState.idx++; case 8: - GridLongList nearExpireTimes0 = commState.getLongList(); + GridLongList nearExpireTimes0 = commState.getLongList(null); if (nearExpireTimes0 == LONG_LIST_NOT_READ) return false; @@ -1164,7 +1164,7 @@ public long nearExpireTime(int idx) { commState.idx++; case 9: - GridLongList nearTtls0 = commState.getLongList(); + GridLongList nearTtls0 = commState.getLongList(null); if (nearTtls0 == LONG_LIST_NOT_READ) return false; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java index e095e1fb2b2e3..e27065ef86b2e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java @@ -955,7 +955,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { invokeArgsBytes = new byte[commState.readSize][]; for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(); + byte[] _val = commState.getByteArray(null); if (_val == BYTE_ARR_NOT_READ) return false; @@ -976,7 +976,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { if (buf.remaining() < 4) return false; - commState.readSize = commState.getInt(); + commState.readSize = commState.getInt(null); } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java index 2a51d59bc8fd9..033e793af1f4c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java @@ -297,7 +297,7 @@ public long accessTtl() { switch (commState.idx) { case 3: - if (!commState.putLong(accessTtl)) + if (!commState.putLong(null, accessTtl)) return false; commState.idx++; @@ -433,7 +433,7 @@ public long accessTtl() { if (buf.remaining() < 8) return false; - accessTtl = commState.getLong(); + accessTtl = commState.getLong(null); commState.idx++; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java index 5ba3403e74637..75939e06ed36e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java @@ -27,6 +27,7 @@ import org.apache.ignite.internal.mxbean.*; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.version.*; +import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.lang.*; import org.apache.ignite.lifecycle.*; import org.apache.ignite.portables.*; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageAdapter.java index 822c0bc11a210..3580cb70bce1d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageAdapter.java @@ -18,11 +18,12 @@ package org.apache.ignite.internal.util.direct; import org.apache.ignite.internal.processors.cache.*; +import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.*; import org.apache.ignite.internal.processors.cache.version.*; +import org.apache.ignite.internal.processors.clock.*; import org.apache.ignite.internal.util.*; import org.apache.ignite.lang.*; -import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.*; -import org.apache.ignite.internal.processors.clock.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageState.java b/modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageState.java index 85717e4dadf6a..44b22ce30f1d3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageState.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageState.java @@ -18,11 +18,12 @@ package org.apache.ignite.internal.util.direct; import org.apache.ignite.internal.processors.cache.*; +import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.*; import org.apache.ignite.internal.processors.cache.version.*; +import org.apache.ignite.internal.processors.clock.*; import org.apache.ignite.internal.util.*; import org.apache.ignite.lang.*; -import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.*; -import org.apache.ignite.internal.processors.clock.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import sun.misc.*; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/IpcToNioAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/IpcToNioAdapter.java index d9daba60f47a6..043e2bb4b039a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/IpcToNioAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/IpcToNioAdapter.java @@ -20,6 +20,7 @@ import org.apache.ignite.*; import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.nio.*; +import org.apache.ignite.internal.util.typedef.internal.*; import java.io.*; import java.nio.*; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java index 350d0b16c74c4..b87236ce7f139 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java @@ -18,9 +18,8 @@ package org.apache.ignite.internal.util.nio; import org.apache.ignite.*; -import org.apache.ignite.plugin.extensions.communication.*; -import org.apache.ignite.spi.*; import org.apache.ignite.internal.util.direct.*; +import org.apache.ignite.spi.*; import org.jetbrains.annotations.*; import java.io.*; @@ -37,7 +36,7 @@ public class GridDirectParser implements GridNioParser { private IgniteSpiAdapter spi; /** */ - private MessageFactory msgFactory; + private GridTcpMessageFactory msgFactory; /** * @param spi Spi. diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java index dc2bee8f12b9f..1431738f05c4f 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java @@ -9,8 +9,8 @@ package org.apache.ignite.plugin.extensions.communication; +import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.plugin.*; -import org.gridgain.grid.util.direct.*; import java.nio.*; diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java index ce0b24973fee5..125c84cb54bca 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java @@ -9,8 +9,8 @@ package org.apache.ignite.plugin.extensions.communication; +import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.plugin.*; -import org.gridgain.grid.util.direct.*; import java.nio.*; diff --git a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java index 892c0debe4fe2..4b07a0e5a3810 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java @@ -21,6 +21,7 @@ import org.apache.ignite.cluster.*; import org.apache.ignite.events.*; import org.apache.ignite.internal.*; +import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.resources.*; import org.apache.ignite.spi.authentication.*; import org.apache.ignite.internal.managers.communication.*; @@ -727,7 +728,7 @@ public ClusterNode node(UUID nodeId) { } /** {@inheritDoc} */ - @Override public MessageFactory messageFactory() { + @Override public GridTcpMessageFactory messageFactory() { return null; } } diff --git a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiContext.java b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiContext.java index 822dae71298aa..af4c54a553ee6 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiContext.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiContext.java @@ -20,11 +20,11 @@ import org.apache.ignite.*; import org.apache.ignite.cluster.*; import org.apache.ignite.events.*; -import org.apache.ignite.plugin.extensions.communication.*; -import org.apache.ignite.plugin.security.*; -import org.apache.ignite.spi.swapspace.*; import org.apache.ignite.internal.managers.communication.*; import org.apache.ignite.internal.managers.eventstorage.*; +import org.apache.ignite.internal.util.direct.*; +import org.apache.ignite.plugin.security.*; +import org.apache.ignite.spi.swapspace.*; import org.jetbrains.annotations.*; import java.io.*; @@ -399,5 +399,5 @@ public boolean removeFromOffheap(@Nullable String spaceName, int part, Object ke /** * @return Message factory. */ - public MessageFactory messageFactory(); + public GridTcpMessageFactory messageFactory(); } diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationByteBufferStream.java b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationByteBufferStream.java index 0de1ea3e2e392..85ce982a8b941 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationByteBufferStream.java +++ b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationByteBufferStream.java @@ -9,8 +9,8 @@ package org.gridgain.grid.util.direct; -import org.apache.ignite.plugin.extensions.communication.*; -import org.gridgain.grid.util.*; +import org.apache.ignite.internal.util.*; +import org.apache.ignite.internal.util.direct.*; import org.jetbrains.annotations.*; import sun.misc.*; import sun.nio.ch.*; @@ -193,7 +193,7 @@ public class GridTcpCommunicationByteBufferStream { }; /** */ - private final MessageFactory msgFactory; + private final GridTcpMessageFactory msgFactory; /** */ private ByteBuffer buf; @@ -228,7 +228,7 @@ public class GridTcpCommunicationByteBufferStream { /** * @param msgFactory Message factory. */ - public GridTcpCommunicationByteBufferStream(@Nullable MessageFactory msgFactory) { + public GridTcpCommunicationByteBufferStream(@Nullable GridTcpMessageFactory msgFactory) { this.msgFactory = msgFactory; } diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageReader.java b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageReader.java index 1645fb5582abc..278becafcb0ce 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageReader.java +++ b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageReader.java @@ -9,6 +9,7 @@ package org.gridgain.grid.util.direct; +import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; @@ -27,7 +28,7 @@ public class GridTcpCommunicationMessageReader implements MessageReader { /** * @param msgFactory Message factory. */ - public GridTcpCommunicationMessageReader(MessageFactory msgFactory) { + public GridTcpCommunicationMessageReader(GridTcpMessageFactory msgFactory) { this.stream = new GridTcpCommunicationByteBufferStream(msgFactory); } diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageWriter.java b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageWriter.java index 101015c5113ff..82ad4f81c33ea 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageWriter.java +++ b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageWriter.java @@ -9,6 +9,7 @@ package org.gridgain.grid.util.direct; +import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java b/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java index 6b5003f5907a7..4bba5ebd29e20 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java @@ -21,15 +21,14 @@ import org.apache.ignite.cluster.*; import org.apache.ignite.events.*; import org.apache.ignite.internal.*; -import org.apache.ignite.lang.*; -import org.apache.ignite.plugin.extensions.communication.*; -import org.apache.ignite.plugin.security.*; -import org.apache.ignite.spi.*; -import org.apache.ignite.spi.swapspace.*; import org.apache.ignite.internal.managers.communication.*; import org.apache.ignite.internal.managers.eventstorage.*; import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.*; +import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.security.*; +import org.apache.ignite.spi.*; +import org.apache.ignite.spi.swapspace.*; import org.jetbrains.annotations.*; import java.io.*; @@ -518,8 +517,8 @@ public void triggerEvent(IgniteEvent evt) { } /** {@inheritDoc} */ - @Override public MessageFactory messageFactory() { - return new MessageFactory() { + @Override public GridTcpMessageFactory messageFactory() { + return new GridTcpMessageFactory() { @Override public GridTcpCommunicationMessageAdapter create(byte type) { return GridTcpCommunicationMessageFactory.create(type); } From b2d5666fae0665156d2b75d093919602eab0de56 Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Mon, 2 Feb 2015 11:22:28 -0800 Subject: [PATCH 14/95] # IGNITE-61 - Moved code generator --- modules/tools/pom.xml | 6 + .../CommunicationMessageCodeGenerator.java | 1233 +++++++++++++++++ .../codegen/generated-classes-order.txt | 79 ++ 3 files changed, 1318 insertions(+) create mode 100644 modules/tools/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java create mode 100644 modules/tools/src/main/java/org/apache/ignite/codegen/generated-classes-order.txt diff --git a/modules/tools/pom.xml b/modules/tools/pom.xml index deab202d2059d..d81e692102196 100644 --- a/modules/tools/pom.xml +++ b/modules/tools/pom.xml @@ -41,6 +41,12 @@ + + org.apache.ignite + ignite-core + ${ignite.version} + + org.jodd jodd-lagarto diff --git a/modules/tools/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java b/modules/tools/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java new file mode 100644 index 0000000000000..8679aebd65317 --- /dev/null +++ b/modules/tools/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java @@ -0,0 +1,1233 @@ +/* @java.file.header */ + +/* _________ _____ __________________ _____ + * __ ____/___________(_)______ /__ ____/______ ____(_)_______ + * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ + * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / + * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ + */ + +package org.apache.ignite.codegen; + +import com.sun.istack.internal.*; +import org.apache.ignite.internal.*; +import org.apache.ignite.internal.processors.cache.*; +import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.*; +import org.apache.ignite.internal.processors.cache.version.*; +import org.apache.ignite.internal.processors.clock.*; +import org.apache.ignite.internal.util.*; +import org.apache.ignite.internal.util.direct.*; +import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.lang.*; + +import java.io.*; +import java.lang.reflect.*; +import java.net.*; +import java.nio.*; +import java.util.*; + +import static java.lang.reflect.Modifier.*; + +/** + * Direct marshallable code generator. + */ +public class CommunicationMessageCodeGenerator { + /** */ + private static final Comparator FIELD_CMP = new Comparator() { + @Override public int compare(Field f1, Field f2) { + int ver1 = 0; + + GridDirectVersion verAnn1 = f1.getAnnotation(GridDirectVersion.class); + + if (verAnn1 != null) { + ver1 = verAnn1.value(); + + assert ver1 > 0; + } + + int ver2 = 0; + + GridDirectVersion verAnn2 = f2.getAnnotation(GridDirectVersion.class); + + if (verAnn2 != null) { + ver2 = verAnn2.value(); + + assert ver2 > 0; + } + + return ver1 < ver2 ? -1 : ver1 > ver2 ? 1 : f1.getName().compareTo(f2.getName()); + } + }; + + /** */ + private static final String CLASSES_ORDER_FILE = U.getGridGainHome() + + "/modules/tools/src/main/java/org/apache/ignite/codegen/generated-classes-order.txt"; + + /** */ + private static final String SRC_DIR = U.getGridGainHome() + "/modules/core/src/main/java"; + + /** */ + private static final Class BASE_CLS = GridTcpCommunicationMessageAdapter.class; + + /** */ + private static final String EMPTY = ""; + + /** */ + private static final String TAB = " "; + + /** */ + private static final String COMM_STATE_VAR = "commState"; + + /** */ + private static final String BUF_VAR = "buf"; + + /** */ + private static final String STATE_VAR = COMM_STATE_VAR + "." + "idx"; + + /** */ + private static final String TYPE_WRITTEN_VAR = COMM_STATE_VAR + "." + "typeWritten"; + + /** */ + private static final String IT_VAR = COMM_STATE_VAR + "." + "it"; + + /** */ + private static final String CUR_VAR = COMM_STATE_VAR + "." + "cur"; + + /** */ + private static final String KEY_DONE_VAR = COMM_STATE_VAR + "." + "keyDone"; + + /** */ + private static final String READ_SIZE_VAR = COMM_STATE_VAR + "." + "readSize"; + + /** */ + private static final String READ_ITEMS_VAR = COMM_STATE_VAR + "." + "readItems"; + + /** */ + private static final String DFLT_LOC_VAR = "_val"; + + /** */ + private final Collection write = new ArrayList<>(); + + /** */ + private final Collection read = new ArrayList<>(); + + /** */ + private final Collection clone = new ArrayList<>(); + + /** */ + private final Collection clone0 = new ArrayList<>(); + + /** */ + private final Map, Integer> fieldCnt = new HashMap<>(); + + /** */ + private byte type = -1; + + /** */ + private List fields; + + /** */ + private int indent; + + /** + * @param args Arguments. + */ + public static void main(String[] args) { + CommunicationMessageCodeGenerator gen = new CommunicationMessageCodeGenerator(); + + try { +// gen.generateAndWrite(GridDistributedLockRequest.class); +// gen.generateAndWrite(GridNearLockRequest.class); +// gen.generateAndWrite(GridDhtLockRequest.class); +// gen.generateAndWrite(GridDistributedLockResponse.class); +// gen.generateAndWrite(GridNearLockResponse.class); +// gen.generateAndWrite(GridDhtLockResponse.class); +// +// gen.generateAndWrite(GridDistributedTxPrepareRequest.class); +// gen.generateAndWrite(GridNearTxPrepareRequest.class); +// gen.generateAndWrite(GridDhtTxPrepareRequest.class); +// gen.generateAndWrite(GridDistributedTxPrepareResponse.class); +// gen.generateAndWrite(GridNearTxPrepareResponse.class); +// gen.generateAndWrite(GridDhtTxPrepareResponse.class); +// +// gen.generateAndWrite(GridDistributedTxFinishRequest.class); +// gen.generateAndWrite(GridNearTxFinishRequest.class); +// gen.generateAndWrite(GridDhtTxFinishRequest.class); +// gen.generateAndWrite(GridDistributedTxFinishResponse.class); +// gen.generateAndWrite(GridNearTxFinishResponse.class); +// gen.generateAndWrite(GridDhtTxFinishResponse.class); + + gen.generateAll(true); + } + catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Generates code for all classes. + * + * @param write Whether to write to file. + * @throws Exception In case of error. + */ + public void generateAll(boolean write) throws Exception { + type = 0; + + Map classesOrder = classesOrder(); + + Collection> classes = classes(classesOrder); + + for (Class cls : classes) { + Integer t = classesOrder.get(cls.getName()); + + type = t != null ? t.byteValue() : 0; + + System.out.println("Processing class: " + cls.getName() + + (Modifier.isAbstract(cls.getModifiers()) ? " (abstract)" : "")); + + if (write) + generateAndWrite(cls); + else + generate(cls); + } + } + + /** + * Generates code for provided class and writes it to source file. + * Note: this method must be called only from {@code generateAll(boolean)} + * and only with updating {@code CLASSES_ORDER_FILE} and other auto generated files. + * + * @param cls Class. + * @throws Exception In case of error. + */ + @SuppressWarnings("ConstantConditions") + private void generateAndWrite(Class cls) throws Exception { + assert cls != null; + + generate(cls); + + File file = new File(SRC_DIR, cls.getName().replace('.', File.separatorChar) + ".java"); + + if (!file.exists() || !file.isFile()) { + System.out.println(" Source file not found: " + file.getPath()); + + return; + } + + Collection src = new ArrayList<>(); + + BufferedReader rdr = null; + + try { + rdr = new BufferedReader(new FileReader(file)); + + String line; + boolean skip = false; + + boolean writeFound = false; + boolean readFound = false; + boolean typeFound = false; + boolean cloneFound = false; + boolean clone0Found = false; + + while ((line = rdr.readLine()) != null) { + if (!skip) { + src.add(line); + + if (line.contains("public boolean writeTo(ByteBuffer buf)")) { + src.addAll(write); + + skip = true; + + writeFound = true; + } + else if (line.contains("public boolean readFrom(ByteBuffer buf)")) { + src.addAll(read); + + skip = true; + + readFound = true; + } +// else if (type >= 0 && line.contains("public byte directType()")) { +// src.add(TAB + TAB + "return " + type + ';'); +// +// skip = true; +// +// typeFound = true; +// } + else if (line.contains("public GridTcpCommunicationMessageAdapter clone()")) { + src.addAll(clone); + + skip = true; + + cloneFound = true; + } + else if (line.contains("protected void clone0(GridTcpCommunicationMessageAdapter _msg)")) { + src.addAll(clone0); + + skip = true; + + clone0Found = true; + } + } + else if (line.startsWith(TAB + "}")) { + src.add(line); + + skip = false; + } + } + + if (!writeFound) + System.out.println(" writeTo method doesn't exist."); + + if (!readFound) + System.out.println(" readFrom method doesn't exist."); + + if (!typeFound) + System.out.println(" directType method doesn't exist."); + + if (!cloneFound) + System.out.println(" clone method doesn't exist."); + + if (!clone0Found) + System.out.println(" clone0 method doesn't exist."); + } + finally { + if (rdr != null) + rdr.close(); + } + + BufferedWriter wr = null; + + try { + wr = new BufferedWriter(new FileWriter(file)); + + for (String line : src) + wr.write(line + '\n'); + } + finally { + if (wr != null) + wr.close(); + } + } + + /** + * Generates code for provided class. + * + * @param cls Class. + * @throws Exception In case of error. + */ + public void generate(Class cls) throws Exception { + assert cls != null; + + write.clear(); + read.clear(); + clone.clear(); + clone0.clear(); + + fields = new ArrayList<>(); + + Field[] declaredFields = cls.getDeclaredFields(); + + for (Field field : declaredFields) { + int mod = field.getModifiers(); + + if (!isStatic(mod) && !isTransient(mod) && !field.isAnnotationPresent(GridDirectTransient.class)) + fields.add(field); + } + + Collections.sort(fields, FIELD_CMP); + + indent = 2; + + boolean hasSuper = cls.getSuperclass() != BASE_CLS; + + String clsName = cls.getSimpleName(); + + if (!Modifier.isAbstract(cls.getModifiers())) { + clone.add(builder().a(clsName).a(" _clone = new ").a(clsName).a("();").toString()); + clone.add(EMPTY); + clone.add(builder().a("clone0(_clone);").toString()); + clone.add(EMPTY); + clone.add(builder().a("return _clone;").toString()); + } + + if (hasSuper) { + clone0.add(builder().a("super.clone0(_msg);").toString()); + clone0.add(EMPTY); + } + + Collection cloningFields = new ArrayList<>(declaredFields.length); + + for (Field field: declaredFields) + if (!isStatic(field.getModifiers())) + cloningFields.add(field); + + if (!cloningFields.isEmpty()) { + clone0.add(builder().a(clsName).a(" _clone = (").a(clsName).a(")_msg;").toString()); + clone0.add(EMPTY); + + for (Field field : cloningFields) { + String name = field.getName(); + Class type = field.getType(); + + String res = name; + + if (BASE_CLS.isAssignableFrom(type)) + res = name + " != null ? (" + type.getSimpleName() + ")" + name + ".clone() : null"; + + clone0.add(builder().a("_clone.").a(name).a(" = ").a(res).a(";").toString()); + } + } + + start(write, hasSuper ? "writeTo" : null, true); + start(read, hasSuper ? "readFrom" : null, false); + + indent++; + + int state = startState(cls); + + for (Field field : fields) + processField(field, state++); + + indent--; + + finish(write); + finish(read); + } + + /** + * @param cls Message class. + * @return Start state. + */ + private int startState(Class cls) { + assert cls != null; + + Class superCls = cls.getSuperclass(); + + Integer state = fieldCnt.get(superCls); + + if (state != null) + return state; + + state = 0; + + while (cls.getSuperclass() != BASE_CLS) { + cls = cls.getSuperclass(); + + for (Field field : cls.getDeclaredFields()) { + int mod = field.getModifiers(); + + if (!isStatic(mod) && !isTransient(mod) && !field.isAnnotationPresent(GridDirectTransient.class)) + state++; + } + } + + fieldCnt.put(superCls, state); + + return state; + } + + /** + * @param code Code lines. + * @param superMtd Super class method name. + * @param writeType Whether to write message type. + */ + private void start(Collection code, @Nullable String superMtd, boolean writeType) { + assert code != null; + + code.add(builder().a(COMM_STATE_VAR).a(".setBuffer(").a(BUF_VAR).a(");").toString()); + code.add(EMPTY); + + if (superMtd != null) { + returnFalseIfFailed(code, "super." + superMtd, BUF_VAR); + + code.add(EMPTY); + } + + if (writeType) { + code.add(builder().a("if (!").a(TYPE_WRITTEN_VAR).a(") {").toString()); + + indent++; + + returnFalseIfFailed(code, COMM_STATE_VAR + ".putByte", "null", "directType()"); + + code.add(EMPTY); + code.add(builder().a(TYPE_WRITTEN_VAR).a(" = true;").toString()); + + indent--; + + code.add(builder().a("}").toString()); + code.add(EMPTY); + } + + if (!fields.isEmpty()) + code.add(builder().a("switch (").a(STATE_VAR).a(") {").toString()); + } + + /** + * @param code Code lines. + */ + private void finish(Collection code) { + assert code != null; + + if (!fields.isEmpty()) { + code.add(builder().a("}").toString()); + code.add(EMPTY); + } + + code.add(builder().a("return true;").toString()); + } + + /** + * @param field Field. + * @param opt Case option. + */ + private void processField(Field field, int opt) { + assert field != null; + assert opt >= 0; + + GridDirectCollection colAnn = field.getAnnotation(GridDirectCollection.class); + GridDirectMap mapAnn = field.getAnnotation(GridDirectMap.class); + + if (colAnn == null && Collection.class.isAssignableFrom(field.getType())) + throw new IllegalStateException("@GridDirectCollection annotation is not provided for field: " + + field.getName()); + + if (mapAnn == null && Map.class.isAssignableFrom(field.getType())) + throw new IllegalStateException("@GridDirectMap annotation is not provided for field: " + field.getName()); + + writeField(field, opt, colAnn, mapAnn); + readField(field, opt, colAnn, mapAnn); + } + + /** + * @param field Field. + * @param opt Case option. + * @param colAnn Collection annotation. + * @param mapAnn Map annotation. + */ + private void writeField(Field field, int opt, @Nullable GridDirectCollection colAnn, + @Nullable GridDirectMap mapAnn) { + assert field != null; + assert opt >= 0; + + write.add(builder().a("case ").a(opt).a(":").toString()); + + indent++; + + returnFalseIfWriteFailed(field.getType(), field.getName(), colAnn != null ? colAnn.value() : null, + mapAnn != null ? mapAnn.keyType() : null, mapAnn != null ? mapAnn.valueType() : null, false); + + write.add(EMPTY); + write.add(builder().a(STATE_VAR).a("++;").toString()); + write.add(EMPTY); + + indent--; + } + + /** + * @param field Field. + * @param opt Case option. + * @param colAnn Collection annotation. + * @param mapAnn Map annotation. + */ + private void readField(Field field, int opt, @Nullable GridDirectCollection colAnn, + @Nullable GridDirectMap mapAnn) { + assert field != null; + assert opt >= 0; + + read.add(builder().a("case ").a(opt).a(":").toString()); + + indent++; + + returnFalseIfReadFailed(field.getType(), field.getName(), colAnn != null ? colAnn.value() : null, + mapAnn != null ? mapAnn.keyType() : null, mapAnn != null ? mapAnn.valueType() : null, false); + + read.add(EMPTY); + read.add(builder().a(STATE_VAR).a("++;").toString()); + read.add(EMPTY); + + indent--; + } + + /** + * @param type Field type. + * @param name Field name. + * @param colItemType Collection item type. + * @param mapKeyType Map key type. + * @param mapValType Map key value. + * @param raw Raw write flag. + */ + private void returnFalseIfWriteFailed(Class type, String name, @Nullable Class colItemType, + @Nullable Class mapKeyType, @Nullable Class mapValType, boolean raw) { + assert type != null; + assert name != null; + + String field = raw ? "null" : '"' + name + '"'; + + if (type == byte.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putByte", field, name); + else if (type == short.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putShort", field, name); + else if (type == int.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putInt", field, name); + else if (type == long.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putLong", field, name); + else if (type == float.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putFloat", field, name); + else if (type == double.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putDouble", field, name); + else if (type == char.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putChar", field, name); + else if (type == boolean.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putBoolean", field, name); + else if (type == byte[].class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putByteArray", field, name); + else if (type == short[].class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putShortArray", field, name); + else if (type == int[].class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putIntArray", field, name); + else if (type == long[].class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putLongArray", field, name); + else if (type == float[].class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putFloatArray", field, name); + else if (type == double[].class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putDoubleArray", field, name); + else if (type == char[].class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putCharArray", field, name); + else if (type == boolean[].class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putBooleanArray", field, name); + else if (type == UUID.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putUuid", field, name); + else if (type == ByteBuffer.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putByteBuffer", field, name); + else if (type == IgniteUuid.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putGridUuid", field, name); + else if (type == GridClockDeltaVersion.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putClockDeltaVersion", field, name); + else if (type == GridByteArrayList.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putByteArrayList", field, name); + else if (type == GridLongList.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putLongList", field, name); + else if (type == GridCacheVersion.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putCacheVersion", field, name); + else if (type == GridDhtPartitionExchangeId.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putDhtPartitionExchangeId", field, name); + else if (type == GridCacheValueBytes.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putValueBytes", field, name); + //else if (type == GridDrInternalRequestEntry.class) + // returnFalseIfFailed(write, COMM_STATE_VAR + ".putDrInternalRequestEntry", field, name); + else if (type == String.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putString", field, name); + else if (type == BitSet.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putBitSet", field, name); + else if (type.isEnum()) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putEnum", field, name); + else if (BASE_CLS.isAssignableFrom(type)) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putMessage", field, name); + else if (type.isArray() || Collection.class.isAssignableFrom(type)) { + boolean isArr = type.isArray(); + + if (isArr) + colItemType = type.getComponentType(); + + assert colItemType != null; + + write.add(builder().a("if (").a(name).a(" != null) {").toString()); + + indent++; + + write.add(builder().a("if (").a(IT_VAR).a(" == null) {").toString()); + + indent++; + + returnFalseIfFailed(write, COMM_STATE_VAR + ".putInt", "null", name + "." + (isArr ? "length" : "size()")); + + write.add(EMPTY); + write.add(builder().a(IT_VAR).a(" = ").a(isArr ? "arrayIterator(" + name + ")" : name + ".iterator()"). + a(";").toString()); + + indent--; + + write.add(builder().a("}").toString()); + write.add(EMPTY); + write.add(builder().a("while (").a(IT_VAR).a(".hasNext() || ").a(CUR_VAR).a(" != NULL").a(") {"). + toString()); + + indent++; + + write.add(builder().a("if (").a(CUR_VAR).a(" == NULL)").toString()); + + indent++; + + write.add(builder().a(CUR_VAR).a(" = ").a(IT_VAR).a(".next();").toString()); + + indent--; + + write.add(EMPTY); + + returnFalseIfWriteFailed(colItemType, "(" + colItemType.getSimpleName() + ")" + CUR_VAR, + null, null, null, true); + + write.add(EMPTY); + write.add(builder().a(CUR_VAR).a(" = NULL;").toString()); + + indent--; + + write.add(builder().a("}").toString()); + write.add(EMPTY); + write.add(builder().a(IT_VAR).a(" = null;").toString()); + + indent--; + + write.add(builder().a("} else {").toString()); + + indent++; + + returnFalseIfFailed(write, COMM_STATE_VAR + ".putInt", "null", "-1"); + + indent--; + + write.add(builder().a("}").toString()); + } + else if (Map.class.isAssignableFrom(type)) { + assert mapKeyType != null; + assert mapValType != null; + + write.add(builder().a("if (").a(name).a(" != null) {").toString()); + + indent++; + + write.add(builder().a("if (").a(IT_VAR).a(" == null) {").toString()); + + indent++; + + returnFalseIfFailed(write, COMM_STATE_VAR + ".putInt", "null", name + ".size()"); + + write.add(EMPTY); + write.add(builder().a(IT_VAR).a(" = ").a(name).a(".entrySet().iterator();").toString()); + + indent--; + + write.add(builder().a("}").toString()); + write.add(EMPTY); + write.add(builder().a("while (").a(IT_VAR).a(".hasNext() || ").a(CUR_VAR).a(" != NULL").a(") {"). + toString()); + + indent++; + + write.add(builder().a("if (").a(CUR_VAR).a(" == NULL)").toString()); + + indent++; + + write.add(builder().a(CUR_VAR).a(" = ").a(IT_VAR).a(".next();").toString()); + + indent--; + + String entryType = "Map.Entry<" + U.box(mapKeyType).getSimpleName() + ", " + + U.box(mapValType).getSimpleName() + ">"; + + write.add(EMPTY); + write.add(builder().a(entryType).a(" e = (").a(entryType).a(")").a(CUR_VAR).a(";").toString()); + write.add(EMPTY); + write.add(builder().a("if (!").a(KEY_DONE_VAR).a(") {").toString()); + + indent++; + + returnFalseIfWriteFailed(mapKeyType, "e.getKey()", null, null, null, true); + + write.add(EMPTY); + write.add(builder().a(KEY_DONE_VAR).a(" = true;").toString()); + + indent--; + + write.add(builder().a("}").toString()); + write.add(EMPTY); + + returnFalseIfWriteFailed(mapValType, "e.getValue()", null, null, null, true); + + write.add(EMPTY); + write.add(builder().a(KEY_DONE_VAR).a(" = false;").toString()); + write.add(EMPTY); + write.add(builder().a(CUR_VAR).a(" = NULL;").toString()); + + indent--; + + write.add(builder().a("}").toString()); + write.add(EMPTY); + write.add(builder().a(IT_VAR).a(" = null;").toString()); + + indent--; + + write.add(builder().a("} else {").toString()); + + indent++; + + returnFalseIfFailed(write, COMM_STATE_VAR + ".putInt", "null", "-1"); + + indent--; + + write.add(builder().a("}").toString()); + } + else + throw new IllegalStateException("Unsupported type: " + type); + } + + /** + * @param type Field type. + * @param name Field name. + * @param colItemType Collection item type. + * @param mapKeyType Map key type. + * @param mapValType Map value type. + * @param raw Raw read flag. + */ + private void returnFalseIfReadFailed(Class type, @Nullable String name, @Nullable Class colItemType, + @Nullable Class mapKeyType, @Nullable Class mapValType, boolean raw) { + assert type != null; + + String field = raw ? "null" : '"' + name + '"'; + + String retType = type.getSimpleName(); + + if (type == byte.class) + returnFalseIfReadFailed("byte", name, null, COMM_STATE_VAR + ".getByte", field, false); + else if (type == short.class) + returnFalseIfReadFailed("short", name, null, COMM_STATE_VAR + ".getShort", field, false); + else if (type == int.class) + returnFalseIfReadFailed("int", name, null, COMM_STATE_VAR + ".getInt", field, false); + else if (type == long.class) + returnFalseIfReadFailed("long", name, null, COMM_STATE_VAR + ".getLong", field, false); + else if (type == float.class) + returnFalseIfReadFailed("float", name, null, COMM_STATE_VAR + ".getFloat", field, false); + else if (type == double.class) + returnFalseIfReadFailed("double", name, null, COMM_STATE_VAR + ".getDouble", field, false); + else if (type == char.class) + returnFalseIfReadFailed("char", name, null, COMM_STATE_VAR + ".getChar", field, false); + else if (type == boolean.class) + returnFalseIfReadFailed("boolean", name, null, COMM_STATE_VAR + ".getBoolean", field, false); + else if (type == byte[].class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getByteArray", field, false); + else if (type == short[].class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getShortArray", field, false); + else if (type == int[].class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getIntArray", field, false); + else if (type == long[].class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getLongArray", field, false); + else if (type == float[].class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getFloatArray", field, false); + else if (type == double[].class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getDoubleArray", field, false); + else if (type == char[].class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getCharArray", field, false); + else if (type == boolean[].class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getBooleanArray", field, false); + else if (type == UUID.class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getUuid", field, false); + else if (type == ByteBuffer.class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getByteBuffer", field, false); + else if (type == IgniteUuid.class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getGridUuid", field, false); + else if (type == GridClockDeltaVersion.class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getClockDeltaVersion", field, false); + else if (type == GridLongList.class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getLongList", field, false); + else if (type == GridByteArrayList.class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getByteArrayList", field, false); + else if (type == GridCacheVersion.class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getCacheVersion", field, false); + else if (type == GridDhtPartitionExchangeId.class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getDhtPartitionExchangeId", field, false); + else if (type == GridCacheValueBytes.class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getValueBytes", field, false); + //else if (type == GridDrInternalRequestEntry.class) + // returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getDrInternalRequestEntry", field, false); + else if (type == String.class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getString", field, false); + else if (type == BitSet.class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getBitSet", field, false); + else if (type.isEnum()) { + assert name != null; + + returnFalseIfReadFailed("byte", null, name + "0", COMM_STATE_VAR + ".getByte", field, false); + + read.add(EMPTY); + read.add(builder().a(name).a(" = ").a(type.getSimpleName()).a(".fromOrdinal(").a(name).a("0);").toString()); + } + else if (BASE_CLS.isAssignableFrom(type)) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getMessage", field, true); + else if (type.isArray() || Collection.class.isAssignableFrom(type)) { + assert name != null; + + boolean isArr = type.isArray(); + + if (isArr) + colItemType = type.getComponentType(); + + assert colItemType != null; + + Class colType = Set.class.isAssignableFrom(type) ? HashSet.class : ArrayList.class; + + read.add(builder().a("if (").a(READ_SIZE_VAR).a(" == -1) {").toString()); + + indent++; + + returnFalseIfReadFailed(int.class, READ_SIZE_VAR, null, null, null, true); + + indent--; + + read.add(builder().a("}").toString()); + read.add(EMPTY); + read.add(builder().a("if (").a(READ_SIZE_VAR).a(" >= 0) {").toString()); + + indent++; + + read.add(builder().a("if (").a(name).a(" == null)").toString()); + + indent++; + + if (isArr) { + String val = colItemType.isArray() ? + colItemType.getComponentType().getSimpleName() + "[" + READ_SIZE_VAR + "][]" : + colItemType.getSimpleName() + "[" + READ_SIZE_VAR + "]"; + + read.add(builder().a(name).a(" = new ").a(val).a(";"). + toString()); + } + else { + read.add(builder().a(name).a(" = new ").a(colType.getSimpleName()).a("<>(").a(READ_SIZE_VAR).a(");"). + toString()); + } + + indent--; + + read.add(EMPTY); + read.add(builder().a("for (int i = ").a(READ_ITEMS_VAR).a("; i < ").a(READ_SIZE_VAR).a("; i++) {"). + toString()); + + indent++; + + String var = colItemType.isPrimitive() ? colItemType.getSimpleName() + " " + DFLT_LOC_VAR : null; + + returnFalseIfReadFailed(colItemType, var, null, null, null, true); + + read.add(EMPTY); + read.add(builder().a(name).a(isArr ? "[i] = " : ".add(").a("(").a(U.box(colItemType).getSimpleName()). + a(")").a(DFLT_LOC_VAR).a(isArr ? ";" : ");").toString()); + read.add(EMPTY); + read.add(builder().a(READ_ITEMS_VAR).a("++;").toString()); + + indent--; + + read.add(builder().a("}").toString()); + + indent--; + + read.add(builder().a("}").toString()); + read.add(EMPTY); + read.add(builder().a(READ_SIZE_VAR).a(" = -1;").toString()); + read.add(builder().a(READ_ITEMS_VAR).a(" = 0;").toString()); + } + else if (Map.class.isAssignableFrom(type)) { + assert name != null; + assert mapKeyType != null; + assert mapValType != null; + + Class mapType = LinkedHashMap.class.isAssignableFrom(type) ? LinkedHashMap.class : HashMap.class; + + read.add(builder().a("if (").a(READ_SIZE_VAR).a(" == -1) {").toString()); + + indent++; + + returnFalseIfReadFailed(int.class, READ_SIZE_VAR, null, null, null, true); + + indent--; + + read.add(builder().a("}").toString()); + read.add(EMPTY); + read.add(builder().a("if (").a(READ_SIZE_VAR).a(" >= 0) {").toString()); + + indent++; + + read.add(builder().a("if (").a(name).a(" == null)").toString()); + + indent++; + + read.add(builder().a(name).a(" = new ").a(mapType.getSimpleName()).a("<>(").a(READ_SIZE_VAR).a(", 1.0f);"). + toString()); + + indent--; + + read.add(EMPTY); + read.add(builder().a("for (int i = ").a(READ_ITEMS_VAR).a("; i < ").a(READ_SIZE_VAR).a("; i++) {"). + toString()); + + indent++; + + read.add(builder().a("if (!").a(KEY_DONE_VAR).a(") {").toString()); + + indent++; + + String var = mapKeyType.isPrimitive() ? mapKeyType.getSimpleName() + " " + DFLT_LOC_VAR : null; + + returnFalseIfReadFailed(mapKeyType, var, null, null, null, true); + + read.add(EMPTY); + read.add(builder().a(CUR_VAR).a(" = ").a(DFLT_LOC_VAR).a(";").toString()); + read.add(builder().a(KEY_DONE_VAR).a(" = true;").toString()); + + indent--; + + read.add(builder().a("}").toString()); + read.add(EMPTY); + + var = mapValType.isPrimitive() ? mapValType.getSimpleName() + " " + DFLT_LOC_VAR : null; + + returnFalseIfReadFailed(mapValType, var, null, null, null, true); + + read.add(EMPTY); + read.add(builder().a(name).a(".put((").a(U.box(mapKeyType).getSimpleName()).a(")").a(CUR_VAR). + a(", ").a(DFLT_LOC_VAR).a(");").toString()); + read.add(EMPTY); + read.add(builder().a(KEY_DONE_VAR).a(" = false;").toString()); + read.add(EMPTY); + read.add(builder().a(READ_ITEMS_VAR).a("++;").toString()); + + indent--; + + read.add(builder().a("}").toString()); + + indent--; + + read.add(builder().a("}").toString()); + read.add(EMPTY); + read.add(builder().a(READ_SIZE_VAR).a(" = -1;").toString()); + read.add(builder().a(READ_ITEMS_VAR).a(" = 0;").toString()); + read.add(builder().a(CUR_VAR).a(" = null;").toString()); + } + else + throw new IllegalStateException("Unsupported type: " + type); + } + + /** + * @param retType Return type. + * @param var Variable name. + * @param locVar Local variable name. + * @param mtd Method name. + * @param arg Method argument. + * @param cast Whether cast is needed. + */ + private void returnFalseIfReadFailed(String retType, @Nullable String var, @Nullable String locVar, String mtd, + @Nullable String arg, boolean cast) { + assert retType != null; + assert mtd != null; + + if (var == null) + var = retType + " " + (locVar != null ? locVar : DFLT_LOC_VAR); + + read.add(builder().a(var).a(" = ").a(cast ? "(" + retType + ")" : "").a(mtd). + a(arg != null ? "(" + arg + ");" : "();").toString()); + read.add(EMPTY); + + read.add(builder().a("if (!").a(COMM_STATE_VAR).a(".lastRead())").toString()); + + indent++; + + read.add(builder().a("return false;").toString()); + + indent--; + } + + /** + * @param code Code lines. + * @param accessor Field or method name. + * @param args Method arguments. + */ + private void returnFalseIfFailed(Collection code, String accessor, @Nullable String... args) { + assert code != null; + assert accessor != null; + + String argsStr = ""; + + if (args != null && args.length > 0) { + for (String arg : args) + argsStr += arg + ", "; + + argsStr = argsStr.substring(0, argsStr.length() - 2); + } + + code.add(builder().a("if (!").a(accessor).a("(" + argsStr + ")").a(")").toString()); + + indent++; + + code.add(builder().a("return false;").toString()); + + indent--; + } + + /** + * Creates new builder with correct indent. + * + * @return Builder. + */ + private SB builder() { + assert indent > 0; + + SB sb = new SB(); + + for (int i = 0; i < indent; i++) + sb.a(TAB); + + return sb; + } + + /** + * Gets all direct marshallable classes. + * First classes will be classes from {@code classesOrder} with same order + * as ordered values. Other classes will be at the end and ordered by name + * (with package prefix). + * That orders need for saving {@code directType} value. + * + * @param classesOrder Map {class name => order number}. + * @return Classes. + * @throws Exception In case of error. + */ + private Collection> classes(final Map classesOrder) throws Exception { + Collection> col = new TreeSet<>(new Comparator>() { + @Override public int compare(Class o1, Class o2) { + Integer c1 = classesOrder.get(o1.getName()); + + Integer c2 = classesOrder.get(o2.getName()); + + if (c1 == null) + return c2 == null ? o1.getName().compareTo(o2.getName()) : 1; + else + return c2 == null ? -1 : c1.compareTo(c2); + } + }); + + URLClassLoader ldr = (URLClassLoader)getClass().getClassLoader(); + + for (URL url : ldr.getURLs()) { + File file = new File(url.toURI()); + + int prefixLen = file.getPath().length() + 1; + + processFile(file, ldr, prefixLen, col); + } + + return col; + } + + /** + * Reads class names from {@code CLASSES_ORDER_FILE}. + * + * @return Map {class name => order number} + * @throws IOException In case of io error. + */ + private Map classesOrder() throws IOException { + BufferedReader reader = null; + + try { + reader = new BufferedReader(new FileReader(CLASSES_ORDER_FILE)); + + Map res = new HashMap<>(); + + while (true) { + String line = reader.readLine(); + + if (line == null) + break; + + line = line.trim(); + + if (!line.isEmpty()) + res.put(line, res.size()); + } + + return res; + } + finally { + if (reader != null) + reader.close(); + } + } + + /** + * Writes class names in {@code CLASSES_ORDER_FILE}. + * + * @param classes Classes for saving. + * @throws IOException In case of io error. + */ + private void classesOrder(Iterable> classes) + throws IOException { + Collection src = new ArrayList<>(); + + for (Class cls : classes) + src.add(cls.getName()); + + writeLines(new File(CLASSES_ORDER_FILE), src); + } + + /** + * Recursively process provided file or directory. + * + * @param file File. + * @param ldr Class loader. + * @param prefixLen Path prefix length. + * @param col Classes. + * @throws Exception In case of error. + */ + private void processFile(File file, ClassLoader ldr, int prefixLen, + Collection> col) throws Exception { + assert file != null; + assert ldr != null; + assert prefixLen > 0; + assert col != null; + + if (!file.exists()) + throw new FileNotFoundException("File doesn't exist: " + file); + + if (file.isDirectory()) { + for (File f : file.listFiles()) + processFile(f, ldr, prefixLen, col); + } + else { + assert file.isFile(); + + String path = file.getPath(); + + if (path.endsWith(".class")) { + String clsName = path.substring(prefixLen, path.length() - 6).replace(File.separatorChar, '.'); + + Class cls = Class.forName(clsName, false, ldr); + + if (cls.getDeclaringClass() == null && cls.getEnclosingClass() == null && + !BASE_CLS.equals(cls) && BASE_CLS.isAssignableFrom(cls)) + col.add((Class)cls); + } + } + } + + /** + * Writes lines in file. + * + * @param file File. + * @param lines Lines. + * @throws IOException In case of io error. + */ + private void writeLines(File file, Iterable lines) throws IOException { + BufferedWriter writer = null; + + try { + writer = new BufferedWriter(new FileWriter(file)); + + for (String line : lines) + writer.write(line + '\n'); + } + finally { + if (writer != null) + writer.close(); + } + } +} diff --git a/modules/tools/src/main/java/org/apache/ignite/codegen/generated-classes-order.txt b/modules/tools/src/main/java/org/apache/ignite/codegen/generated-classes-order.txt new file mode 100644 index 0000000000000..88ca4ac355bb8 --- /dev/null +++ b/modules/tools/src/main/java/org/apache/ignite/codegen/generated-classes-order.txt @@ -0,0 +1,79 @@ +org.apache.ignite.internal.GridJobCancelRequest +org.apache.ignite.internal.GridJobExecuteRequest +org.apache.ignite.internal.GridJobExecuteResponse +org.apache.ignite.internal.GridJobSiblingsRequest +org.apache.ignite.internal.GridJobSiblingsResponse +org.apache.ignite.internal.GridTaskCancelRequest +org.apache.ignite.internal.GridTaskSessionRequest +org.apache.ignite.internal.managers.checkpoint.GridCheckpointRequest +org.apache.ignite.internal.managers.communication.GridIoMessage +org.apache.ignite.internal.managers.communication.GridIoUserMessage +org.apache.ignite.internal.managers.deployment.GridDeploymentInfoBean +org.apache.ignite.internal.managers.deployment.GridDeploymentRequest +org.apache.ignite.internal.managers.deployment.GridDeploymentResponse +org.apache.ignite.internal.managers.eventstorage.GridEventStorageMessage +org.apache.ignite.internal.processors.cache.GridCacheEvictionRequest +org.apache.ignite.internal.processors.cache.GridCacheEvictionResponse +org.apache.ignite.internal.processors.cache.distributed.GridCacheOptimisticCheckPreparedTxRequest +org.apache.ignite.internal.processors.cache.distributed.GridCacheOptimisticCheckPreparedTxResponse +org.apache.ignite.internal.processors.cache.distributed.GridCachePessimisticCheckCommittedTxRequest +org.apache.ignite.internal.processors.cache.distributed.GridCachePessimisticCheckCommittedTxResponse +org.apache.ignite.internal.processors.cache.distributed.GridDistributedLockRequest +org.apache.ignite.internal.processors.cache.distributed.GridDistributedLockResponse +org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxFinishRequest +org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxFinishResponse +org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxPrepareRequest +org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxPrepareResponse +org.apache.ignite.internal.processors.cache.distributed.GridDistributedUnlockRequest +org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLockRequest +org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLockResponse +org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxFinishRequest +org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxFinishResponse +org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareRequest +org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareResponse +org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtUnlockRequest +org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicDeferredUpdateResponse +org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicUpdateRequest +org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicUpdateResponse +org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicUpdateRequest +org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicUpdateResponse +org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtForceKeysRequest +org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtForceKeysResponse +org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemandMessage +org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessage +org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsFullMessage +org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleMessage +org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleRequest +org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetRequest +org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetResponse +org.apache.ignite.internal.processors.cache.distributed.near.GridNearLockRequest +org.apache.ignite.internal.processors.cache.distributed.near.GridNearLockResponse +org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxFinishRequest +org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxFinishResponse +org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareRequest +org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareResponse +org.apache.ignite.internal.processors.cache.distributed.near.GridNearUnlockRequest +org.apache.ignite.internal.processors.cache.query.GridCacheQueryRequest +org.apache.ignite.internal.processors.cache.query.GridCacheQueryResponse +org.apache.ignite.internal.processors.clock.GridClockDeltaSnapshotMessage +org.apache.ignite.internal.processors.continuous.GridContinuousMessage +org.apache.ignite.internal.processors.dataload.GridDataLoadRequest +org.apache.ignite.internal.processors.dataload.GridDataLoadResponse +org.apache.ignite.internal.processors.dr.messages.internal.GridDrInternalRequest +org.apache.ignite.internal.processors.dr.messages.internal.GridDrInternalResponse +org.apache.ignite.internal.processors.ggfs.GridGgfsAckMessage +org.apache.ignite.internal.processors.ggfs.GridGgfsBlockKey +org.apache.ignite.internal.processors.ggfs.GridGgfsBlocksMessage +org.apache.ignite.internal.processors.ggfs.GridGgfsDeleteMessage +org.apache.ignite.internal.processors.ggfs.GridGgfsFileAffinityRange +org.apache.ignite.internal.processors.ggfs.GridGgfsFragmentizerRequest +org.apache.ignite.internal.processors.ggfs.GridGgfsFragmentizerResponse +org.apache.ignite.internal.processors.ggfs.GridGgfsSyncMessage +org.apache.ignite.internal.processors.rest.handlers.task.GridTaskResultRequest +org.apache.ignite.internal.processors.rest.handlers.task.GridTaskResultResponse +org.apache.ignite.internal.processors.streamer.GridStreamerCancelRequest +org.apache.ignite.internal.processors.streamer.GridStreamerExecutionRequest +org.apache.ignite.internal.processors.streamer.GridStreamerResponse +org.apache.ignite.spi.collision.jobstealing.JobStealingRequest +org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtAffinityAssignmentRequest +org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtAffinityAssignmentResponse From 1f80aebe8025ae9e72809319d8a9c017913f217e Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Mon, 2 Feb 2015 12:27:58 -0800 Subject: [PATCH 15/95] # IGNITE-61 - Direct marshalling --- .../internal/processors/continuous/GridContinuousMessage.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousMessage.java index 11339c65ef317..50e1b40460eaa 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousMessage.java @@ -141,8 +141,8 @@ public void dataBytes(byte[] dataBytes) { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter msg) { - GridContinuousMessage clone = (GridContinuousMessage)msg; + @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + GridContinuousMessage clone = (GridContinuousMessage)_msg; clone.type = type; clone.routineId = routineId; From 3f388b4e9e05690938f19428eaf2f2e7112d6101 Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Mon, 2 Feb 2015 14:49:17 -0800 Subject: [PATCH 16/95] # IGNITE-61 - Direct marshalling --- .../internal/GridJobExecuteRequest.java | 14 +- .../cache/GridCacheEvictionRequest.java | 2 +- .../cache/GridCacheEvictionResponse.java | 2 +- ...CacheOptimisticCheckPreparedTxRequest.java | 2 +- ...acheOptimisticCheckPreparedTxResponse.java | 2 +- ...chePessimisticCheckCommittedTxRequest.java | 2 +- ...hePessimisticCheckCommittedTxResponse.java | 2 +- .../GridCacheTtlUpdateRequest.java | 50 +++--- .../GridDistributedLockRequest.java | 2 +- .../GridDistributedLockResponse.java | 2 +- .../GridDistributedTxFinishRequest.java | 2 +- .../GridDistributedTxFinishResponse.java | 2 +- .../GridDistributedTxPrepareRequest.java | 2 +- .../GridDistributedTxPrepareResponse.java | 2 +- .../GridDistributedUnlockRequest.java | 2 +- .../dht/GridDhtAffinityAssignmentRequest.java | 2 +- .../GridDhtAffinityAssignmentResponse.java | 2 +- .../distributed/dht/GridDhtLockRequest.java | 57 +++---- .../distributed/dht/GridDhtLockResponse.java | 2 +- .../dht/GridDhtTxFinishRequest.java | 70 ++++---- .../dht/GridDhtTxFinishResponse.java | 2 +- .../dht/GridDhtTxPrepareRequest.java | 2 +- .../dht/GridDhtTxPrepareResponse.java | 2 +- .../distributed/dht/GridDhtUnlockRequest.java | 2 +- .../GridDhtAtomicDeferredUpdateResponse.java | 2 +- .../atomic/GridDhtAtomicUpdateRequest.java | 30 ++-- .../atomic/GridDhtAtomicUpdateResponse.java | 2 +- .../atomic/GridNearAtomicUpdateRequest.java | 12 +- .../atomic/GridNearAtomicUpdateResponse.java | 77 ++++----- .../preloader/GridDhtForceKeysRequest.java | 2 +- .../preloader/GridDhtForceKeysResponse.java | 2 +- .../GridDhtPartitionDemandMessage.java | 2 +- .../GridDhtPartitionSupplyMessage.java | 2 +- .../GridDhtPartitionsFullMessage.java | 2 +- .../GridDhtPartitionsSingleMessage.java | 2 +- .../GridDhtPartitionsSingleRequest.java | 2 +- .../distributed/near/GridNearGetRequest.java | 53 +++--- .../distributed/near/GridNearGetResponse.java | 2 +- .../distributed/near/GridNearLockRequest.java | 72 ++++---- .../near/GridNearLockResponse.java | 2 +- .../near/GridNearTxFinishRequest.java | 2 +- .../near/GridNearTxFinishResponse.java | 2 +- .../near/GridNearTxPrepareRequest.java | 2 +- .../near/GridNearTxPrepareResponse.java | 2 +- .../near/GridNearUnlockRequest.java | 2 +- .../cache/query/GridCacheQueryRequest.java | 2 +- .../cache/query/GridCacheQueryResponse.java | 2 +- .../clock/GridClockDeltaSnapshotMessage.java | 2 +- .../continuous/GridContinuousMessage.java | 32 ++-- .../dataload/GridDataLoadRequest.java | 18 +- .../dataload/GridDataLoadResponse.java | 2 +- .../processors/fs/GridGgfsAckMessage.java | 2 +- .../processors/fs/GridGgfsBlockKey.java | 2 +- .../processors/fs/GridGgfsBlocksMessage.java | 2 +- .../processors/fs/GridGgfsDeleteMessage.java | 2 +- .../fs/GridGgfsFileAffinityRange.java | 2 +- .../fs/GridGgfsFragmentizerRequest.java | 2 +- .../fs/GridGgfsFragmentizerResponse.java | 2 +- .../processors/fs/GridGgfsSyncMessage.java | 2 +- .../processors/fs/IgniteFsProcessor.java | 18 +- .../GridClientHandshakeRequestWrapper.java | 2 +- .../GridClientHandshakeResponseWrapper.java | 2 +- .../message/GridClientMessageWrapper.java | 2 +- .../message/GridClientPingPacketWrapper.java | 2 +- .../handlers/task/GridTaskResultRequest.java | 2 +- .../handlers/task/GridTaskResultResponse.java | 2 +- .../tcp/GridMemcachedMessageWrapper.java | 2 +- .../streamer/GridStreamerCancelRequest.java | 2 +- .../GridStreamerExecutionRequest.java | 2 +- .../streamer/GridStreamerResponse.java | 2 +- .../GridTcpCommunicationMessageFactory.java | 134 ++++++++------- .../jobstealing/JobStealingRequest.java | 2 +- .../CommunicationMessageCodeGenerator.java | 156 +++--------------- .../codegen/generated-classes-order.txt | 79 --------- 74 files changed, 405 insertions(+), 585 deletions(-) delete mode 100644 modules/tools/src/main/java/org/apache/ignite/codegen/generated-classes-order.txt diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java index d26ce22c3096e..44d2bd27fe9e4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java @@ -832,17 +832,15 @@ public UUID getSubjectId() { commState.idx++; case 16: - UUID subjId0 = commState.getUuid(null); + subjId = commState.getUuid("subjId"); - if (subjId0 == UUID_NOT_READ) + if (!commState.lastRead()) return false; - subjId = subjId0; - commState.idx++; case 17: - String taskClsName0 = commState.getString("taskClsName"); + taskClsName = commState.getString("taskClsName"); if (!commState.lastRead()) return false; @@ -850,7 +848,7 @@ public UUID getSubjectId() { commState.idx++; case 18: - String taskName0 = commState.getString("taskName"); + taskName = commState.getString("taskName"); if (!commState.lastRead()) return false; @@ -895,7 +893,7 @@ public UUID getSubjectId() { commState.idx++; case 21: - String userVer0 = commState.getString("userVer"); + userVer = commState.getString("userVer"); if (!commState.lastRead()) return false; @@ -909,7 +907,7 @@ public UUID getSubjectId() { /** {@inheritDoc} */ @Override public byte directType() { - return 81; + return 1; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionRequest.java index b0b773cb62c27..9059d75cdc1f0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionRequest.java @@ -240,7 +240,7 @@ void addKey(K key, GridCacheVersion ver, boolean near) { /** {@inheritDoc} */ @Override public byte directType() { - return 16; + return 14; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionResponse.java index 10adb63c2f207..1ff9225f39e93 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionResponse.java @@ -271,7 +271,7 @@ boolean error() { /** {@inheritDoc} */ @Override public byte directType() { - return 17; + return 15; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxRequest.java index 5fcef9f4a208c..23176535fd297 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxRequest.java @@ -211,7 +211,7 @@ public int transactions() { /** {@inheritDoc} */ @Override public byte directType() { - return 18; + return 16; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxResponse.java index e2a66fcb218fd..9e5e8d196a993 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxResponse.java @@ -184,7 +184,7 @@ public boolean success() { /** {@inheritDoc} */ @Override public byte directType() { - return 19; + return 17; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxRequest.java index e2d45d7a67c3a..386a6046cdf77 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxRequest.java @@ -274,7 +274,7 @@ public boolean nearOnlyCheck() { /** {@inheritDoc} */ @Override public byte directType() { - return 20; + return 18; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxResponse.java index 3ac0aac111c6f..0954c99819177 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxResponse.java @@ -216,7 +216,7 @@ public GridCacheCommittedTxInfo committedTxInfo() { /** {@inheritDoc} */ @Override public byte directType() { - return 21; + return 19; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java index 6b0fa97b5e19d..5c60c0c8d30c6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java @@ -180,7 +180,7 @@ public List nearVersions() { /** {@inheritDoc} */ @Override public byte directType() { - return 82; + return 20; } /** {@inheritDoc} */ @@ -290,13 +290,13 @@ public List nearVersions() { commState.idx++; case 6: - if (!commState.putLong(null, topVer)) + if (!commState.putLong("topVer", topVer)) return false; commState.idx++; case 7: - if (!commState.putLong(null, ttl)) + if (!commState.putLong("ttl", ttl)) return false; commState.idx++; @@ -343,10 +343,10 @@ public List nearVersions() { switch (commState.idx) { case 3: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -356,7 +356,7 @@ public List nearVersions() { for (int i = commState.readItems; i < commState.readSize; i++) { byte[] _val = commState.getByteArray(null); - if (_val == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; keysBytes.add((byte[])_val); @@ -372,10 +372,10 @@ public List nearVersions() { case 4: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -385,7 +385,7 @@ public List nearVersions() { for (int i = commState.readItems; i < commState.readSize; i++) { byte[] _val = commState.getByteArray(null); - if (_val == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; nearKeysBytes.add((byte[])_val); @@ -401,10 +401,10 @@ public List nearVersions() { case 5: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -414,7 +414,7 @@ public List nearVersions() { for (int i = commState.readItems; i < commState.readSize; i++) { GridCacheVersion _val = commState.getCacheVersion(null); - if (_val == CACHE_VER_NOT_READ) + if (!commState.lastRead()) return false; nearVers.add((GridCacheVersion)_val); @@ -429,27 +429,27 @@ public List nearVersions() { commState.idx++; case 6: - if (buf.remaining() < 8) - return false; + topVer = commState.getLong("topVer"); - topVer = commState.getLong(null); + if (!commState.lastRead()) + return false; commState.idx++; case 7: - if (buf.remaining() < 8) - return false; + ttl = commState.getLong("ttl"); - ttl = commState.getLong(null); + if (!commState.lastRead()) + return false; commState.idx++; case 8: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -459,7 +459,7 @@ public List nearVersions() { for (int i = commState.readItems; i < commState.readSize; i++) { GridCacheVersion _val = commState.getCacheVersion(null); - if (_val == CACHE_VER_NOT_READ) + if (!commState.lastRead()) return false; vers.add((GridCacheVersion)_val); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java index db4788999f05f..09f6877c50501 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java @@ -811,7 +811,7 @@ public GridCacheVersion[] drVersions() { /** {@inheritDoc} */ @Override public byte directType() { - return 22; + return 21; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java index 92877636f762d..5c37853e4988c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java @@ -421,7 +421,7 @@ protected int valuesSize() { /** {@inheritDoc} */ @Override public byte directType() { - return 23; + return 22; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java index 8b84546496e61..b378c3171ffc8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java @@ -681,7 +681,7 @@ public boolean groupLock() { /** {@inheritDoc} */ @Override public byte directType() { - return 24; + return 23; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishResponse.java index 0b2acfa9099f4..4b3c43c28f04a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishResponse.java @@ -159,7 +159,7 @@ public IgniteUuid futureId() { /** {@inheritDoc} */ @Override public byte directType() { - return 25; + return 24; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java index 11f454f3f533c..3e06ebfb9eb62 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java @@ -760,7 +760,7 @@ private void writeCollection(ObjectOutput out, Collection> c /** {@inheritDoc} */ @Override public byte directType() { - return 26; + return 25; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java index b61c66766d5ce..d7d2ce82c7142 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java @@ -236,7 +236,7 @@ public void candidates(Map>> cands) { /** {@inheritDoc} */ @Override public byte directType() { - return 27; + return 26; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedUnlockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedUnlockRequest.java index 9971d884eea86..45b44cc6e6873 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedUnlockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedUnlockRequest.java @@ -228,7 +228,7 @@ public void addKey(K key, byte[] bytes, GridCacheContext ctx) throws Ignit /** {@inheritDoc} */ @Override public byte directType() { - return 28; + return 27; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java index 50d8f1c251418..0e101c262f1a2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java @@ -63,7 +63,7 @@ public GridDhtAffinityAssignmentRequest(int cacheId, long topVer) { /** {@inheritDoc} */ @Override public byte directType() { - return 79; + return 28; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java index 669f5d03df38e..a107a44c6e127 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java @@ -85,7 +85,7 @@ public List> affinityAssignment() { /** {@inheritDoc} */ @Override public byte directType() { - return 80; + return 29; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java index 8ed971555e1ab..a61d587b49aec 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java @@ -389,18 +389,24 @@ public long accessTtl() { switch (commState.idx) { case 24: - if (!commState.putBitSet("invalidateEntries", invalidateEntries)) + if (!commState.putLong("accessTtl", accessTtl)) return false; commState.idx++; case 25: - if (!commState.putGridUuid("miniId", miniId)) + if (!commState.putBitSet("invalidateEntries", invalidateEntries)) return false; commState.idx++; case 26: + if (!commState.putGridUuid("miniId", miniId)) + return false; + + commState.idx++; + + case 27: if (nearKeyBytes != null) { if (commState.it == null) { if (!commState.putInt(null, nearKeyBytes.size())) @@ -427,38 +433,32 @@ public long accessTtl() { commState.idx++; - case 27: - if (!commState.putByteArray("ownedBytes", ownedBytes)) - return false; - - commState.idx++; - case 28: - if (!commState.putLong("topVer", topVer)) + if (!commState.putByteArray("ownedBytes", ownedBytes)) return false; commState.idx++; case 29: - if (!commState.putUuid("subjId", subjId)) + if (!commState.putLong("topVer", topVer)) return false; commState.idx++; case 30: - if (!commState.putInt("taskNameHash", taskNameHash)) + if (!commState.putUuid("subjId", subjId)) return false; commState.idx++; case 31: - if (!commState.putBitSet("preloadKeys", preloadKeys)) + if (!commState.putInt("taskNameHash", taskNameHash)) return false; commState.idx++; case 32: - if (!commState.putLong(null, accessTtl)) + if (!commState.putBitSet("preloadKeys", preloadKeys)) return false; commState.idx++; @@ -478,7 +478,7 @@ public long accessTtl() { switch (commState.idx) { case 24: - invalidateEntries = commState.getBitSet("invalidateEntries"); + accessTtl = commState.getLong("accessTtl"); if (!commState.lastRead()) return false; @@ -486,7 +486,7 @@ public long accessTtl() { commState.idx++; case 25: - miniId = commState.getGridUuid("miniId"); + invalidateEntries = commState.getBitSet("invalidateEntries"); if (!commState.lastRead()) return false; @@ -494,6 +494,14 @@ public long accessTtl() { commState.idx++; case 26: + miniId = commState.getGridUuid("miniId"); + + if (!commState.lastRead()) + return false; + + commState.idx++; + + case 27: if (commState.readSize == -1) { commState.readSize = commState.getInt(null); @@ -522,7 +530,7 @@ public long accessTtl() { commState.idx++; - case 27: + case 28: ownedBytes = commState.getByteArray("ownedBytes"); if (!commState.lastRead()) @@ -530,7 +538,7 @@ public long accessTtl() { commState.idx++; - case 28: + case 29: topVer = commState.getLong("topVer"); if (!commState.lastRead()) @@ -538,7 +546,7 @@ public long accessTtl() { commState.idx++; - case 29: + case 30: subjId = commState.getUuid("subjId"); if (!commState.lastRead()) @@ -546,7 +554,7 @@ public long accessTtl() { commState.idx++; - case 30: + case 31: taskNameHash = commState.getInt("taskNameHash"); if (!commState.lastRead()) @@ -554,7 +562,7 @@ public long accessTtl() { commState.idx++; - case 31: + case 32: preloadKeys = commState.getBitSet("preloadKeys"); if (!commState.lastRead()) @@ -562,13 +570,6 @@ public long accessTtl() { commState.idx++; - case 32: - if (buf.remaining() < 8) - return false; - - accessTtl = commState.getLong(null); - - commState.idx++; } return true; @@ -576,7 +577,7 @@ public long accessTtl() { /** {@inheritDoc} */ @Override public byte directType() { - return 29; + return 30; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java index 84d7effeef619..5cba82c8441ae 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java @@ -442,7 +442,7 @@ public Collection> preloadEntries() { /** {@inheritDoc} */ @Override public byte directType() { - return 30; + return 31; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java index c394cf682c54a..23c7eb5eeefdd 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java @@ -416,6 +416,12 @@ public GridLongList nearTtls() { commState.idx++; case 24: + if (!commState.putLongList("nearTtls", nearTtls)) + return false; + + commState.idx++; + + case 25: if (nearWritesBytes != null) { if (commState.it == null) { if (!commState.putInt(null, nearWritesBytes.size())) @@ -442,13 +448,13 @@ public GridLongList nearTtls() { commState.idx++; - case 25: + case 26: if (!commState.putBoolean("onePhaseCommit", onePhaseCommit)) return false; commState.idx++; - case 26: + case 27: if (pendingVers != null) { if (commState.it == null) { if (!commState.putInt(null, pendingVers.size())) @@ -475,44 +481,38 @@ public GridLongList nearTtls() { commState.idx++; - case 27: - if (!commState.putBoolean("sysInvalidate", sysInvalidate)) - return false; - - commState.idx++; - case 28: - if (!commState.putLong("topVer", topVer)) + if (!commState.putBoolean("sysInvalidate", sysInvalidate)) return false; commState.idx++; case 29: - if (!commState.putCacheVersion("writeVer", writeVer)) + if (!commState.putLong("topVer", topVer)) return false; commState.idx++; case 30: - if (!commState.putUuid("subjId", subjId)) + if (!commState.putLongList("ttls", ttls)) return false; commState.idx++; case 31: - if (!commState.putInt("taskNameHash", taskNameHash)) + if (!commState.putCacheVersion("writeVer", writeVer)) return false; commState.idx++; case 32: - if (!commState.putLongList(null, ttls)) + if (!commState.putUuid("subjId", subjId)) return false; commState.idx++; case 33: - if (!commState.putLongList(null, nearTtls)) + if (!commState.putInt("taskNameHash", taskNameHash)) return false; commState.idx++; @@ -558,6 +558,14 @@ public GridLongList nearTtls() { commState.idx++; case 24: + nearTtls = commState.getLongList("nearTtls"); + + if (!commState.lastRead()) + return false; + + commState.idx++; + + case 25: if (commState.readSize == -1) { commState.readSize = commState.getInt(null); @@ -586,7 +594,7 @@ public GridLongList nearTtls() { commState.idx++; - case 25: + case 26: onePhaseCommit = commState.getBoolean("onePhaseCommit"); if (!commState.lastRead()) @@ -594,7 +602,7 @@ public GridLongList nearTtls() { commState.idx++; - case 26: + case 27: if (commState.readSize == -1) { commState.readSize = commState.getInt(null); @@ -623,16 +631,8 @@ public GridLongList nearTtls() { commState.idx++; - case 27: - sysInvalidate = commState.getBoolean("sysInvalidate"); - - if (!commState.lastRead()) - return false; - - commState.idx++; - case 28: - topVer = commState.getLong("topVer"); + sysInvalidate = commState.getBoolean("sysInvalidate"); if (!commState.lastRead()) return false; @@ -640,7 +640,7 @@ public GridLongList nearTtls() { commState.idx++; case 29: - writeVer = commState.getCacheVersion("writeVer"); + topVer = commState.getLong("topVer"); if (!commState.lastRead()) return false; @@ -648,7 +648,7 @@ public GridLongList nearTtls() { commState.idx++; case 30: - subjId = commState.getUuid("subjId"); + ttls = commState.getLongList("ttls"); if (!commState.lastRead()) return false; @@ -656,7 +656,7 @@ public GridLongList nearTtls() { commState.idx++; case 31: - taskNameHash = commState.getInt("taskNameHash"); + writeVer = commState.getCacheVersion("writeVer"); if (!commState.lastRead()) return false; @@ -664,23 +664,19 @@ public GridLongList nearTtls() { commState.idx++; case 32: - GridLongList ttls0 = commState.getLongList(null); + subjId = commState.getUuid("subjId"); - if (ttls0 == LONG_LIST_NOT_READ) + if (!commState.lastRead()) return false; - ttls = ttls0; - commState.idx++; case 33: - GridLongList nearTtls0 = commState.getLongList(null); + taskNameHash = commState.getInt("taskNameHash"); - if (nearTtls0 == LONG_LIST_NOT_READ) + if (!commState.lastRead()) return false; - nearTtls = nearTtls0; - commState.idx++; } @@ -690,6 +686,6 @@ public GridLongList nearTtls() { /** {@inheritDoc} */ @Override public byte directType() { - return 31; + return 32; } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java index 1ee5a3f9e058d..c749d531e1e73 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java @@ -138,6 +138,6 @@ public IgniteUuid miniId() { /** {@inheritDoc} */ @Override public byte directType() { - return 32; + return 33; } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java index 819db64928786..e52245929faed 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java @@ -593,6 +593,6 @@ public Map, GridCacheVersion> owned() { /** {@inheritDoc} */ @Override public byte directType() { - return 33; + return 34; } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java index ec59dae96a49b..54d8c9a8145ac 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java @@ -463,6 +463,6 @@ public void addPreloadEntry(GridCacheEntryInfo info) { /** {@inheritDoc} */ @Override public byte directType() { - return 34; + return 35; } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java index 3c3c657476a15..91df86208cff2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java @@ -216,6 +216,6 @@ public void addNearKey(K key, byte[] keyBytes, GridCacheSharedContext ctx) /** {@inheritDoc} */ @Override public byte directType() { - return 35; + return 36; } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicDeferredUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicDeferredUpdateResponse.java index 04bef6abaa5fe..69daf3b895d6d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicDeferredUpdateResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicDeferredUpdateResponse.java @@ -184,6 +184,6 @@ public Collection futureVersions() { /** {@inheritDoc} */ @Override public byte directType() { - return 36; + return 37; } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java index baf929b946483..f55a8de23c09a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java @@ -866,13 +866,13 @@ public long nearExpireTime(int idx) { commState.idx++; case 12: - if (!commState.putLong(null, topVer)) + if (!commState.putLong("topVer", topVer)) return false; commState.idx++; case 13: - if (!commState.putLongList(null, ttls)) + if (!commState.putLongList("ttls", ttls)) return false; commState.idx++; @@ -1097,10 +1097,10 @@ public long nearExpireTime(int idx) { case 6: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -1110,7 +1110,7 @@ public long nearExpireTime(int idx) { for (int i = commState.readItems; i < commState.readSize; i++) { byte[] _val = commState.getByteArray(null); - if (_val == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; invokeArgsBytes[i] = (byte[])_val; @@ -1154,27 +1154,23 @@ public long nearExpireTime(int idx) { commState.idx++; case 8: - GridLongList nearExpireTimes0 = commState.getLongList(null); + nearExpireTimes = commState.getLongList("nearExpireTimes"); - if (nearExpireTimes0 == LONG_LIST_NOT_READ) + if (!commState.lastRead()) return false; - nearExpireTimes = nearExpireTimes0; - commState.idx++; case 9: - GridLongList nearTtls0 = commState.getLongList(null); + nearTtls = commState.getLongList("nearTtls"); - if (nearTtls0 == LONG_LIST_NOT_READ) + if (!commState.lastRead()) return false; - nearTtls = nearTtls0; - commState.idx++; case 10: - UUID nodeId0 = commState.getUuid("nodeId"); + nodeId = commState.getUuid("nodeId"); if (!commState.lastRead()) return false; @@ -1237,7 +1233,7 @@ public long nearExpireTime(int idx) { commState.idx++; case 15: - GridCacheVersion writeVer0 = commState.getCacheVersion("writeVer"); + writeVer = commState.getCacheVersion("writeVer"); if (!commState.lastRead()) return false; @@ -1391,7 +1387,7 @@ public long nearExpireTime(int idx) { /** {@inheritDoc} */ @Override public byte directType() { - return 37; + return 38; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java index 1ef4e54957490..5fc3ef77c19b4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java @@ -338,7 +338,7 @@ public void addNearEvicted(K key, @Nullable byte[] bytes) { /** {@inheritDoc} */ @Override public byte directType() { - return 38; + return 39; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java index e27065ef86b2e..69cd54683c613 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java @@ -882,7 +882,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { commState.idx++; case 6: - byte[] expiryPlcBytes = commState.getByteArray("expiryPlcBytes"); + expiryPlcBytes = commState.getByteArray("expiryPlcBytes"); if (!commState.lastRead()) return false; @@ -957,7 +957,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { for (int i = commState.readItems; i < commState.readSize; i++) { byte[] _val = commState.getByteArray(null); - if (_val == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; invokeArgsBytes[i] = (byte[])_val; @@ -973,10 +973,10 @@ public void forceTransformBackups(boolean forceTransformBackups) { case 12: if (commState.readSize == -1) { - if (buf.remaining() < 4) - return false; - commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; } if (commState.readSize >= 0) { @@ -1104,7 +1104,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { /** {@inheritDoc} */ @Override public byte directType() { - return 39; + return 40; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java index 42ee3db5f5875..2d8f00b8ec6c8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java @@ -491,18 +491,30 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { commState.idx++; case 6: - if (!commState.putByteArray("remapKeysBytes", remapKeysBytes)) + if (!commState.putLongList("nearExpireTimes", nearExpireTimes)) return false; commState.idx++; case 7: - if (!commState.putByteArray("retValBytes", retValBytes)) + if (!commState.putLongList("nearTtls", nearTtls)) return false; commState.idx++; case 8: + if (!commState.putByteArray("remapKeysBytes", remapKeysBytes)) + return false; + + commState.idx++; + + case 9: + if (!commState.putByteArray("retValBytes", retValBytes)) + return false; + + commState.idx++; + + case 10: if (nearSkipIdxs != null) { if (commState.it == null) { if (!commState.putInt(null, nearSkipIdxs.size())) @@ -529,7 +541,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { commState.idx++; - case 9: + case 11: if (nearValBytes != null) { if (commState.it == null) { if (!commState.putInt(null, nearValBytes.size())) @@ -556,7 +568,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { commState.idx++; - case 10: + case 12: if (nearValsIdxs != null) { if (commState.it == null) { if (!commState.putInt(null, nearValsIdxs.size())) @@ -583,23 +595,12 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { commState.idx++; - case 11: + case 13: if (!commState.putCacheVersion("nearVer", nearVer)) return false; commState.idx++; - case 12: - if (!commState.putLongList("nearExpireTimes", nearExpireTimes)) - return false; - - commState.idx++; - - case 13: - if (!commState.putLongList("nearTtls", nearTtls)) - return false; - - commState.idx++; } return true; @@ -639,7 +640,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { commState.idx++; case 6: - remapKeysBytes = commState.getByteArray("remapKeysBytes"); + nearExpireTimes = commState.getLongList("nearExpireTimes"); if (!commState.lastRead()) return false; @@ -647,7 +648,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { commState.idx++; case 7: - retValBytes = commState.getByteArray("retValBytes"); + nearTtls = commState.getLongList("nearTtls"); if (!commState.lastRead()) return false; @@ -655,6 +656,22 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { commState.idx++; case 8: + remapKeysBytes = commState.getByteArray("remapKeysBytes"); + + if (!commState.lastRead()) + return false; + + commState.idx++; + + case 9: + retValBytes = commState.getByteArray("retValBytes"); + + if (!commState.lastRead()) + return false; + + commState.idx++; + + case 10: if (commState.readSize == -1) { commState.readSize = commState.getInt(null); @@ -683,7 +700,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { commState.idx++; - case 9: + case 11: if (commState.readSize == -1) { commState.readSize = commState.getInt(null); @@ -712,7 +729,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { commState.idx++; - case 10: + case 12: if (commState.readSize == -1) { commState.readSize = commState.getInt(null); @@ -741,24 +758,8 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { commState.idx++; - case 11: - nearVer = commState.getCacheVersion("nearVer"); - - if (!commState.lastRead()) - return false; - - commState.idx++; - - case 12: - nearExpireTimes = commState.getLongList("nearExpireTimes"); - - if (!commState.lastRead()) - return false; - - commState.idx++; - case 13: - nearTtls = commState.getLongList("nearTtls"); + nearVer = commState.getCacheVersion("nearVer"); if (!commState.lastRead()) return false; @@ -772,7 +773,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { /** {@inheritDoc} */ @Override public byte directType() { - return 40; + return 41; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java index 1d94c2e60af16..20920a7545c30 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java @@ -319,7 +319,7 @@ private int keyCount() { /** {@inheritDoc} */ @Override public byte directType() { - return 41; + return 42; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java index 73fcb03218653..55845ac42c7bc 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java @@ -323,7 +323,7 @@ public void addInfo(GridCacheEntryInfo info) { /** {@inheritDoc} */ @Override public byte directType() { - return 42; + return 43; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java index bf41e14934cb6..6931543d0f265 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java @@ -377,7 +377,7 @@ void workerId(int workerId) { /** {@inheritDoc} */ @Override public byte directType() { - return 43; + return 44; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java index 417ab842d81e7..d7e785f5e2968 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java @@ -504,7 +504,7 @@ public int size() { /** {@inheritDoc} */ @Override public byte directType() { - return 44; + return 45; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java index ec138fd171af6..fa67ac08da7a1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java @@ -244,7 +244,7 @@ public void affinityAssignment(List> affAssignment) { /** {@inheritDoc} */ @Override public byte directType() { - return 45; + return 46; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java index 823f1f69fa343..57888bc1eee36 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java @@ -165,7 +165,7 @@ public Map partitions() { /** {@inheritDoc} */ @Override public byte directType() { - return 46; + return 47; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleRequest.java index d3fbe4006aeea..9cbd7d47e27d7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleRequest.java @@ -91,7 +91,7 @@ public GridDhtPartitionsSingleRequest() { /** {@inheritDoc} */ @Override public byte directType() { - return 47; + return 48; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java index 033e793af1f4c..8abde421a109e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java @@ -297,7 +297,7 @@ public long accessTtl() { switch (commState.idx) { case 3: - if (!commState.putLong(null, accessTtl)) + if (!commState.putLong("accessTtl", accessTtl)) return false; commState.idx++; @@ -330,7 +330,7 @@ public long accessTtl() { commState.idx++; case 5: - if (!commState.putGridUuid(null, futId)) + if (!commState.putGridUuid("futId", futId)) return false; commState.idx++; @@ -374,43 +374,43 @@ public long accessTtl() { commState.idx++; case 7: - if (!commState.putGridUuid(null, miniId)) + if (!commState.putGridUuid("miniId", miniId)) return false; commState.idx++; case 8: - if (!commState.putBoolean(null, readThrough)) + if (!commState.putBoolean("readThrough", readThrough)) return false; commState.idx++; case 9: - if (!commState.putBoolean(null, reload)) + if (!commState.putBoolean("reload", reload)) return false; commState.idx++; case 10: - if (!commState.putLong(null, topVer)) + if (!commState.putLong("topVer", topVer)) return false; commState.idx++; case 11: - if (!commState.putCacheVersion(null, ver)) + if (!commState.putCacheVersion("ver", ver)) return false; commState.idx++; case 12: - if (!commState.putUuid(null, subjId)) + if (!commState.putUuid("subjId", subjId)) return false; commState.idx++; case 13: - if (!commState.putInt(null, taskNameHash)) + if (!commState.putInt("taskNameHash", taskNameHash)) return false; commState.idx++; @@ -430,10 +430,10 @@ public long accessTtl() { switch (commState.idx) { case 3: - if (buf.remaining() < 8) - return false; + accessTtl = commState.getLong("accessTtl"); - accessTtl = commState.getLong(null); + if (!commState.lastRead()) + return false; commState.idx++; @@ -467,7 +467,7 @@ public long accessTtl() { commState.idx++; case 5: - IgniteUuid futId0 = commState.getGridUuid(null); + futId = commState.getGridUuid("futId"); if (!commState.lastRead()) return false; @@ -517,7 +517,7 @@ public long accessTtl() { commState.idx++; case 7: - IgniteUuid miniId0 = commState.getGridUuid(null); + miniId = commState.getGridUuid("miniId"); if (!commState.lastRead()) return false; @@ -525,29 +525,31 @@ public long accessTtl() { commState.idx++; case 8: - if (buf.remaining() < 1) - return false; + readThrough = commState.getBoolean("readThrough"); - readThrough = commState.getBoolean(null); + if (!commState.lastRead()) + return false; commState.idx++; case 9: - if (buf.remaining() < 1) - return false; + reload = commState.getBoolean("reload"); - reload = commState.getBoolean(null); + if (!commState.lastRead()) + return false; commState.idx++; case 10: - if (buf.remaining() < 8) + topVer = commState.getLong("topVer"); + + if (!commState.lastRead()) return false; commState.idx++; case 11: - GridCacheVersion ver0 = commState.getCacheVersion(null); + ver = commState.getCacheVersion("ver"); if (!commState.lastRead()) return false; @@ -555,7 +557,7 @@ public long accessTtl() { commState.idx++; case 12: - UUID subjId0 = commState.getUuid(null); + subjId = commState.getUuid("subjId"); if (!commState.lastRead()) return false; @@ -563,8 +565,7 @@ public long accessTtl() { commState.idx++; case 13: - if (buf.remaining() < 4) - return false; + taskNameHash = commState.getInt("taskNameHash"); if (!commState.lastRead()) return false; @@ -578,7 +579,7 @@ public long accessTtl() { /** {@inheritDoc} */ @Override public byte directType() { - return 48; + return 49; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java index 77dd8f6f195b5..0504d70b30b30 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java @@ -403,7 +403,7 @@ public void error(Throwable err) { /** {@inheritDoc} */ @Override public byte directType() { - return 49; + return 50; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java index 2d8e08f9cbb6a..efe60bd56e4ee 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java @@ -381,6 +381,12 @@ public long accessTtl() { switch (commState.idx) { case 24: + if (!commState.putLong("accessTtl", accessTtl)) + return false; + + commState.idx++; + + case 25: if (dhtVers != null) { if (commState.it == null) { if (!commState.putInt(null, dhtVers.length)) @@ -407,7 +413,7 @@ public long accessTtl() { commState.idx++; - case 25: + case 26: if (filterBytes != null) { if (commState.it == null) { if (!commState.putInt(null, filterBytes.length)) @@ -434,62 +440,56 @@ public long accessTtl() { commState.idx++; - case 26: - if (!commState.putBoolean("implicitSingleTx", implicitSingleTx)) - return false; - - commState.idx++; - case 27: - if (!commState.putBoolean("implicitTx", implicitTx)) + if (!commState.putBoolean("implicitSingleTx", implicitSingleTx)) return false; commState.idx++; case 28: - if (!commState.putGridUuid("miniId", miniId)) + if (!commState.putBoolean("implicitTx", implicitTx)) return false; commState.idx++; case 29: - if (!commState.putBoolean("onePhaseCommit", onePhaseCommit)) + if (!commState.putGridUuid("miniId", miniId)) return false; commState.idx++; case 30: - if (!commState.putBoolean("syncCommit", syncCommit)) + if (!commState.putBoolean("onePhaseCommit", onePhaseCommit)) return false; commState.idx++; case 31: - if (!commState.putLong("topVer", topVer)) + if (!commState.putBoolean("syncCommit", syncCommit)) return false; commState.idx++; case 32: - if (!commState.putUuid("subjId", subjId)) + if (!commState.putLong("topVer", topVer)) return false; commState.idx++; case 33: - if (!commState.putInt("taskNameHash", taskNameHash)) + if (!commState.putUuid("subjId", subjId)) return false; commState.idx++; case 34: - if (!commState.putBoolean("hasTransforms", hasTransforms)) + if (!commState.putInt("taskNameHash", taskNameHash)) return false; commState.idx++; case 35: - if (!commState.putLong("accessTtl", accessTtl)) + if (!commState.putBoolean("hasTransforms", hasTransforms)) return false; commState.idx++; @@ -509,6 +509,14 @@ public long accessTtl() { switch (commState.idx) { case 24: + accessTtl = commState.getLong("accessTtl"); + + if (!commState.lastRead()) + return false; + + commState.idx++; + + case 25: if (commState.readSize == -1) { commState.readSize = commState.getInt(null); @@ -537,7 +545,7 @@ public long accessTtl() { commState.idx++; - case 25: + case 26: if (commState.readSize == -1) { commState.readSize = commState.getInt(null); @@ -566,7 +574,7 @@ public long accessTtl() { commState.idx++; - case 26: + case 27: implicitSingleTx = commState.getBoolean("implicitSingleTx"); if (!commState.lastRead()) @@ -574,7 +582,7 @@ public long accessTtl() { commState.idx++; - case 27: + case 28: implicitTx = commState.getBoolean("implicitTx"); if (!commState.lastRead()) @@ -582,7 +590,7 @@ public long accessTtl() { commState.idx++; - case 28: + case 29: miniId = commState.getGridUuid("miniId"); if (!commState.lastRead()) @@ -590,7 +598,7 @@ public long accessTtl() { commState.idx++; - case 29: + case 30: onePhaseCommit = commState.getBoolean("onePhaseCommit"); if (!commState.lastRead()) @@ -598,7 +606,7 @@ public long accessTtl() { commState.idx++; - case 30: + case 31: syncCommit = commState.getBoolean("syncCommit"); if (!commState.lastRead()) @@ -606,7 +614,7 @@ public long accessTtl() { commState.idx++; - case 31: + case 32: topVer = commState.getLong("topVer"); if (!commState.lastRead()) @@ -614,7 +622,7 @@ public long accessTtl() { commState.idx++; - case 32: + case 33: subjId = commState.getUuid("subjId"); if (!commState.lastRead()) @@ -622,7 +630,7 @@ public long accessTtl() { commState.idx++; - case 33: + case 34: taskNameHash = commState.getInt("taskNameHash"); if (!commState.lastRead()) @@ -630,22 +638,12 @@ public long accessTtl() { commState.idx++; - case 34: + case 35: hasTransforms = commState.getBoolean("hasTransforms"); if (!commState.lastRead()) return false; - syncCommit = commState.getBoolean(null); - - commState.idx++; - - case 35: - if (buf.remaining() < 8) - return false; - - accessTtl = commState.getLong(null); - commState.idx++; } @@ -655,7 +653,7 @@ public long accessTtl() { /** {@inheritDoc} */ @Override public byte directType() { - return 50; + return 51; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockResponse.java index 98cbe8e7ee670..e53f1a290b0cb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockResponse.java @@ -436,7 +436,7 @@ public void addValueBytes( /** {@inheritDoc} */ @Override public byte directType() { - return 51; + return 52; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java index f4cb518a8bd2e..d67bee3d1677c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java @@ -305,7 +305,7 @@ public int taskNameHash() { /** {@inheritDoc} */ @Override public byte directType() { - return 52; + return 53; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java index 22c68e9ed3a94..ac4ae2cd39b88 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java @@ -214,7 +214,7 @@ public long threadId() { /** {@inheritDoc} */ @Override public byte directType() { - return 53; + return 54; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java index e0bc2166c1ea7..6e57ee44d3e21 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java @@ -434,7 +434,7 @@ private Collection> cloneEntries(Collection invalidPartitions() { /** {@inheritDoc} */ @Override public byte directType() { - return 55; + return 56; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearUnlockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearUnlockRequest.java index 40d3506bd0328..8df4302ac20ff 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearUnlockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearUnlockRequest.java @@ -93,7 +93,7 @@ public GridNearUnlockRequest(int cacheId, int keyCnt) { /** {@inheritDoc} */ @Override public byte directType() { - return 56; + return 57; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java index 7794028eac20a..b1904ae2db15b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java @@ -790,7 +790,7 @@ public int taskHash() { /** {@inheritDoc} */ @Override public byte directType() { - return 57; + return 58; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java index 01569cd0aee81..9738d60e1001d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java @@ -433,7 +433,7 @@ public boolean fields() { /** {@inheritDoc} */ @Override public byte directType() { - return 58; + return 59; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaSnapshotMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaSnapshotMessage.java index 4f9345ca8be81..04e3f503639b1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaSnapshotMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaSnapshotMessage.java @@ -214,7 +214,7 @@ public Map deltas() { /** {@inheritDoc} */ @Override public byte directType() { - return 59; + return 60; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousMessage.java index 50e1b40460eaa..0cc1d32113661 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousMessage.java @@ -142,13 +142,13 @@ public void dataBytes(byte[] dataBytes) { /** {@inheritDoc} */ @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { - GridContinuousMessage clone = (GridContinuousMessage)_msg; + GridContinuousMessage _clone = (GridContinuousMessage)_msg; - clone.type = type; - clone.routineId = routineId; - clone.futId = futId; - clone.data = data; - clone.dataBytes = dataBytes; + _clone.type = type; + _clone.routineId = routineId; + _clone.data = data; + _clone.dataBytes = dataBytes; + _clone.futId = futId; } /** {@inheritDoc} */ @@ -171,19 +171,19 @@ public void dataBytes(byte[] dataBytes) { commState.idx++; case 1: - if (!commState.putGridUuid(null, futId)) + if (!commState.putGridUuid("futId", futId)) return false; commState.idx++; case 2: - if (!commState.putUuid(null, routineId)) + if (!commState.putUuid("routineId", routineId)) return false; commState.idx++; case 3: - if (!commState.putEnum(null, type)) + if (!commState.putEnum("type", type)) return false; commState.idx++; @@ -208,17 +208,15 @@ public void dataBytes(byte[] dataBytes) { commState.idx++; case 1: - IgniteUuid futId0 = commState.getGridUuid(null); + futId = commState.getGridUuid("futId"); - if (futId0 == GRID_UUID_NOT_READ) + if (!commState.lastRead()) return false; - futId = futId0; - commState.idx++; case 2: - UUID routineId0 = commState.getUuid(null); + routineId = commState.getUuid("routineId"); if (!commState.lastRead()) return false; @@ -226,12 +224,12 @@ public void dataBytes(byte[] dataBytes) { commState.idx++; case 3: - if (buf.remaining() < 1) - return false; + byte type0 = commState.getByte("type"); if (!commState.lastRead()) return false; + type = GridContinuousMessageType.fromOrdinal(type0); commState.idx++; @@ -242,7 +240,7 @@ public void dataBytes(byte[] dataBytes) { /** {@inheritDoc} */ @Override public byte directType() { - return 60; + return 61; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadRequest.java index c842a0638f767..3a9c605439d79 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadRequest.java @@ -327,19 +327,19 @@ public boolean forceLocalDeployment() { commState.idx++; case 10: - if (!commState.putBoolean(null, skipStore)) + if (!commState.putBoolean("skipStore", skipStore)) return false; commState.idx++; case 11: - if (!commState.putByteArray(null, updaterBytes)) + if (!commState.putByteArray("updaterBytes", updaterBytes)) return false; commState.idx++; case 12: - if (!commState.putString(null, userVer)) + if (!commState.putString("userVer", userVer)) return false; commState.idx++; @@ -471,15 +471,15 @@ public boolean forceLocalDeployment() { commState.idx++; case 10: - if (buf.remaining() < 1) - return false; + skipStore = commState.getBoolean("skipStore"); - skipStore = commState.getBoolean(null); + if (!commState.lastRead()) + return false; commState.idx++; case 11: - byte[] updaterBytes0 = commState.getByteArray(null); + updaterBytes = commState.getByteArray("updaterBytes"); if (!commState.lastRead()) return false; @@ -487,7 +487,7 @@ public boolean forceLocalDeployment() { commState.idx++; case 12: - String userVer0 = commState.getString(null); + userVer = commState.getString("userVer"); if (!commState.lastRead()) return false; @@ -501,7 +501,7 @@ public boolean forceLocalDeployment() { /** {@inheritDoc} */ @Override public byte directType() { - return 61; + return 62; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadResponse.java index ed193a928db56..faff1d7c222ab 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadResponse.java @@ -174,6 +174,6 @@ public boolean forceLocalDeployment() { /** {@inheritDoc} */ @Override public byte directType() { - return 62; + return 63; } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsAckMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsAckMessage.java index e39bc6b4a16ae..dd73817f53f67 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsAckMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsAckMessage.java @@ -203,6 +203,6 @@ public IgniteCheckedException error() { /** {@inheritDoc} */ @Override public byte directType() { - return 65; + return 64; } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlockKey.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlockKey.java index 101db1954c2d3..a157f0376db54 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlockKey.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlockKey.java @@ -265,7 +265,7 @@ public long getBlockId() { /** {@inheritDoc} */ @Override public byte directType() { - return 66; + return 65; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlocksMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlocksMessage.java index 2a1f8a1c7344a..9e3f4c23640a7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlocksMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlocksMessage.java @@ -249,6 +249,6 @@ public Map blocks() { /** {@inheritDoc} */ @Override public byte directType() { - return 67; + return 66; } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsDeleteMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsDeleteMessage.java index cc64415a85713..8032bc33eb187 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsDeleteMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsDeleteMessage.java @@ -192,7 +192,7 @@ public IgniteCheckedException error() { /** {@inheritDoc} */ @Override public byte directType() { - return 68; + return 67; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFileAffinityRange.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFileAffinityRange.java index 6fb4699ac2c73..2216182d6500f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFileAffinityRange.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFileAffinityRange.java @@ -384,7 +384,7 @@ public boolean regionEqual(GridGgfsFileAffinityRange other) { /** {@inheritDoc} */ @Override public byte directType() { - return 69; + return 68; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerRequest.java index 37954a30a4566..37f7cf0830b9c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerRequest.java @@ -205,6 +205,6 @@ public Collection fragmentRanges() { /** {@inheritDoc} */ @Override public byte directType() { - return 70; + return 69; } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerResponse.java index 19a04d20814cd..1b337cd205f8e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerResponse.java @@ -124,6 +124,6 @@ public IgniteUuid fileId() { /** {@inheritDoc} */ @Override public byte directType() { - return 71; + return 70; } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsSyncMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsSyncMessage.java index fa917a0e7348d..8251242bbc52f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsSyncMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsSyncMessage.java @@ -156,6 +156,6 @@ public boolean response() { /** {@inheritDoc} */ @Override public byte directType() { - return 72; + return 71; } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/IgniteFsProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/IgniteFsProcessor.java index 8087d11b638c6..2f9fe76030f38 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/IgniteFsProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/IgniteFsProcessor.java @@ -85,28 +85,28 @@ public IgniteFsProcessor(GridKernalContext ctx) { @Override public GridTcpCommunicationMessageAdapter create(byte type) { switch (type) { - case 65: + case 64: return new GridGgfsAckMessage(); - case 66: + case 65: return new GridGgfsBlockKey(); - case 67: + case 66: return new GridGgfsBlocksMessage(); - case 68: + case 67: return new GridGgfsDeleteMessage(); - case 69: + case 68: return new GridGgfsFileAffinityRange(); - case 70: + case 69: return new GridGgfsFragmentizerRequest(); - case 71: + case 70: return new GridGgfsFragmentizerResponse(); - case 72: + case 71: return new GridGgfsSyncMessage(); default: @@ -115,7 +115,7 @@ public GridTcpCommunicationMessageAdapter create(byte type) { return null; } } - }, 65, 66, 67, 68, 69,70, 71, 72); + }, 64, 65, 66, 67, 68, 69, 70, 71); // Register HDFS edition usage with license manager. GridLicenseUseRegistry.onUsage(HADOOP, getClass()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java index 1c0366a99cd8b..e0dd3812f1344 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java @@ -100,7 +100,7 @@ public byte[] bytes() { /** {@inheritDoc} */ @Override public byte directType() { - return HANDSHAKE_HEADER; + return 72; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java index dff1f45e6731b..00ebc5ff1230c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java @@ -89,7 +89,7 @@ public GridClientHandshakeResponseWrapper(byte code) { /** {@inheritDoc} */ @Override public byte directType() { - return code; + return 73; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMessageWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMessageWrapper.java index 6e6f485bdfd5d..04edfc76de36b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMessageWrapper.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMessageWrapper.java @@ -227,7 +227,7 @@ public void message(ByteBuffer msg) { /** {@inheritDoc} */ @Override public byte directType() { - return REQ_HEADER; + return 74; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacketWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacketWrapper.java index 64e61c9e5ac08..9e42be0080a81 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacketWrapper.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacketWrapper.java @@ -75,7 +75,7 @@ public class GridClientPingPacketWrapper extends GridTcpCommunicationMessageAdap /** {@inheritDoc} */ @Override public byte directType() { - return GridClientMessageWrapper.REQ_HEADER; + return 75; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultRequest.java index 4abd3591a7276..ba70ee5842709 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultRequest.java @@ -176,6 +176,6 @@ public void topic(String topic) { /** {@inheritDoc} */ @Override public byte directType() { - return 73; + return 76; } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java index 06cec21389539..caa42ddfa568f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java @@ -224,6 +224,6 @@ public void error(String err) { /** {@inheritDoc} */ @Override public byte directType() { - return 74; + return 77; } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java index 3cc4358f8d183..33f9b27112321 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java @@ -104,7 +104,7 @@ public GridMemcachedMessageWrapper(GridMemcachedMessage msg, IgniteMarshaller jd /** {@inheritDoc} */ @Override public byte directType() { - return MEMCACHE_RES_FLAG; + return 78; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerCancelRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerCancelRequest.java index efc80cbcb084e..f5d3bdb36825d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerCancelRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerCancelRequest.java @@ -116,6 +116,6 @@ public IgniteUuid cancelledFutureId() { /** {@inheritDoc} */ @Override public byte directType() { - return 75; + return 79; } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerExecutionRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerExecutionRequest.java index e62a003b5af4e..03db23df39388 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerExecutionRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerExecutionRequest.java @@ -369,6 +369,6 @@ public byte[] batchBytes() { /** {@inheritDoc} */ @Override public byte directType() { - return 76; + return 80; } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerResponse.java index fdd21dff4aa92..c143ca10eb853 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerResponse.java @@ -151,6 +151,6 @@ public byte[] errorBytes() { /** {@inheritDoc} */ @Override public byte directType() { - return 77; + return 81; } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageFactory.java b/modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageFactory.java index 70074937ea369..ddcbdddc005d3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageFactory.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageFactory.java @@ -32,7 +32,9 @@ import org.apache.ignite.internal.processors.clock.*; import org.apache.ignite.internal.processors.continuous.*; import org.apache.ignite.internal.processors.dataload.*; +import org.apache.ignite.internal.processors.rest.client.message.*; import org.apache.ignite.internal.processors.rest.handlers.task.*; +import org.apache.ignite.internal.processors.rest.protocols.tcp.*; import org.apache.ignite.internal.processors.streamer.*; import org.apache.ignite.spi.collision.jobstealing.*; import org.apache.ignite.spi.communication.tcp.*; @@ -62,6 +64,9 @@ public class GridTcpCommunicationMessageFactory { case 0: return new GridJobCancelRequest(); + case 1: + return new GridJobExecuteRequest(); + case 2: return new GridJobExecuteResponse(); @@ -98,179 +103,190 @@ public class GridTcpCommunicationMessageFactory { case 13: return new GridEventStorageMessage(); - case 16: + case 14: return new GridCacheEvictionRequest(); - case 17: + case 15: return new GridCacheEvictionResponse(); - case 18: + case 16: return new GridCacheOptimisticCheckPreparedTxRequest(); - case 19: + case 17: return new GridCacheOptimisticCheckPreparedTxResponse(); - case 20: + case 18: return new GridCachePessimisticCheckCommittedTxRequest(); - case 21: + case 19: return new GridCachePessimisticCheckCommittedTxResponse(); - case 22: + case 20: + return new GridCacheTtlUpdateRequest(); + + case 21: return new GridDistributedLockRequest(); - case 23: + case 22: return new GridDistributedLockResponse(); - case 24: + case 23: return new GridDistributedTxFinishRequest(); - case 25: + case 24: return new GridDistributedTxFinishResponse(); - case 26: + case 25: return new GridDistributedTxPrepareRequest(); - case 27: + case 26: return new GridDistributedTxPrepareResponse(); - case 28: + case 27: return new GridDistributedUnlockRequest(); + case 28: + return new GridDhtAffinityAssignmentRequest(); + case 29: - return new GridDhtLockRequest(); + return new GridDhtAffinityAssignmentResponse(); case 30: - return new GridDhtLockResponse(); + return new GridDhtLockRequest(); case 31: - return new GridDhtTxFinishRequest(); + return new GridDhtLockResponse(); case 32: - return new GridDhtTxFinishResponse(); + return new GridDhtTxFinishRequest(); case 33: - return new GridDhtTxPrepareRequest(); + return new GridDhtTxFinishResponse(); case 34: - return new GridDhtTxPrepareResponse(); + return new GridDhtTxPrepareRequest(); case 35: - return new GridDhtUnlockRequest(); + return new GridDhtTxPrepareResponse(); case 36: - return new GridDhtAtomicDeferredUpdateResponse(); + return new GridDhtUnlockRequest(); case 37: - return new GridDhtAtomicUpdateRequest(); + return new GridDhtAtomicDeferredUpdateResponse(); case 38: - return new GridDhtAtomicUpdateResponse(); + return new GridDhtAtomicUpdateRequest(); case 39: - return new GridNearAtomicUpdateRequest(); + return new GridDhtAtomicUpdateResponse(); case 40: - return new GridNearAtomicUpdateResponse(); + return new GridNearAtomicUpdateRequest(); case 41: - return new GridDhtForceKeysRequest(); + return new GridNearAtomicUpdateResponse(); case 42: - return new GridDhtForceKeysResponse(); + return new GridDhtForceKeysRequest(); case 43: - return new GridDhtPartitionDemandMessage(); + return new GridDhtForceKeysResponse(); case 44: - return new GridDhtPartitionSupplyMessage(); + return new GridDhtPartitionDemandMessage(); case 45: - return new GridDhtPartitionsFullMessage(); + return new GridDhtPartitionSupplyMessage(); case 46: - return new GridDhtPartitionsSingleMessage(); + return new GridDhtPartitionsFullMessage(); case 47: - return new GridDhtPartitionsSingleRequest(); + return new GridDhtPartitionsSingleMessage(); case 48: - return new GridNearGetRequest(); + return new GridDhtPartitionsSingleRequest(); case 49: - return new GridNearGetResponse(); + return new GridNearGetRequest(); case 50: - return new GridNearLockRequest(); + return new GridNearGetResponse(); case 51: - return new GridNearLockResponse(); + return new GridNearLockRequest(); case 52: - return new GridNearTxFinishRequest(); + return new GridNearLockResponse(); case 53: - return new GridNearTxFinishResponse(); + return new GridNearTxFinishRequest(); case 54: - return new GridNearTxPrepareRequest(); + return new GridNearTxFinishResponse(); case 55: - return new GridNearTxPrepareResponse(); + return new GridNearTxPrepareRequest(); case 56: - return new GridNearUnlockRequest(); + return new GridNearTxPrepareResponse(); case 57: - return new GridCacheQueryRequest(); + return new GridNearUnlockRequest(); case 58: - return new GridCacheQueryResponse(); + return new GridCacheQueryRequest(); case 59: - return new GridClockDeltaSnapshotMessage(); + return new GridCacheQueryResponse(); case 60: - return new GridContinuousMessage(); + return new GridClockDeltaSnapshotMessage(); case 61: - return new GridDataLoadRequest(); + return new GridContinuousMessage(); case 62: + return new GridDataLoadRequest(); + + case 63: return new GridDataLoadResponse(); - // 65-72 are GGFS messages (see GridGgfsOpProcessor). + // 64-71: IgniteFS messages. + + case 72: + return new GridClientHandshakeRequestWrapper(); case 73: - return new GridTaskResultRequest(); + return new GridClientHandshakeResponseWrapper(); case 74: - return new GridTaskResultResponse(); + return new GridClientMessageWrapper(); - // TODO: Register from streamer processor. case 75: - return new GridStreamerCancelRequest(); + return new GridClientPingPacketWrapper(); case 76: - return new GridStreamerExecutionRequest(); + return new GridTaskResultRequest(); case 77: - return new GridStreamerResponse(); + return new GridTaskResultResponse(); case 78: - return new JobStealingRequest(); + return new GridMemcachedMessageWrapper(); case 79: - return new GridDhtAffinityAssignmentRequest(); + return new GridStreamerCancelRequest(); case 80: - return new GridDhtAffinityAssignmentResponse(); + return new GridStreamerExecutionRequest(); case 81: - return new GridJobExecuteRequest(); + return new GridStreamerResponse(); case 82: - return new GridCacheTtlUpdateRequest(); + return new JobStealingRequest(); default: assert false : "Invalid message type."; @@ -281,7 +297,7 @@ public class GridTcpCommunicationMessageFactory { }, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 64, /* 65-72 - GGFS messages. */ 73, 74, 75, 76, 77, 78, 79, + 60, 61, 62, 63, /* 64-71: IgniteFS messages. */ 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82); } diff --git a/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java b/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java index b903738cb8117..0653dcd9b63ec 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java @@ -116,7 +116,7 @@ int delta() { /** {@inheritDoc} */ @Override public byte directType() { - return 78; + return 82; } /** {@inheritDoc} */ diff --git a/modules/tools/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java b/modules/tools/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java index 8679aebd65317..5ab27cce8e24e 100644 --- a/modules/tools/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java +++ b/modules/tools/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java @@ -59,10 +59,6 @@ public class CommunicationMessageCodeGenerator { } }; - /** */ - private static final String CLASSES_ORDER_FILE = U.getGridGainHome() + - "/modules/tools/src/main/java/org/apache/ignite/codegen/generated-classes-order.txt"; - /** */ private static final String SRC_DIR = U.getGridGainHome() + "/modules/core/src/main/java"; @@ -120,9 +116,6 @@ public class CommunicationMessageCodeGenerator { /** */ private final Map, Integer> fieldCnt = new HashMap<>(); - /** */ - private byte type = -1; - /** */ private List fields; @@ -136,27 +129,6 @@ public static void main(String[] args) { CommunicationMessageCodeGenerator gen = new CommunicationMessageCodeGenerator(); try { -// gen.generateAndWrite(GridDistributedLockRequest.class); -// gen.generateAndWrite(GridNearLockRequest.class); -// gen.generateAndWrite(GridDhtLockRequest.class); -// gen.generateAndWrite(GridDistributedLockResponse.class); -// gen.generateAndWrite(GridNearLockResponse.class); -// gen.generateAndWrite(GridDhtLockResponse.class); -// -// gen.generateAndWrite(GridDistributedTxPrepareRequest.class); -// gen.generateAndWrite(GridNearTxPrepareRequest.class); -// gen.generateAndWrite(GridDhtTxPrepareRequest.class); -// gen.generateAndWrite(GridDistributedTxPrepareResponse.class); -// gen.generateAndWrite(GridNearTxPrepareResponse.class); -// gen.generateAndWrite(GridDhtTxPrepareResponse.class); -// -// gen.generateAndWrite(GridDistributedTxFinishRequest.class); -// gen.generateAndWrite(GridNearTxFinishRequest.class); -// gen.generateAndWrite(GridDhtTxFinishRequest.class); -// gen.generateAndWrite(GridDistributedTxFinishResponse.class); -// gen.generateAndWrite(GridNearTxFinishResponse.class); -// gen.generateAndWrite(GridDhtTxFinishResponse.class); - gen.generateAll(true); } catch (Exception e) { @@ -171,25 +143,31 @@ public static void main(String[] args) { * @throws Exception In case of error. */ public void generateAll(boolean write) throws Exception { - type = 0; + Collection> classes = classes(); - Map classesOrder = classesOrder(); - - Collection> classes = classes(classesOrder); + byte type = 0; for (Class cls : classes) { - Integer t = classesOrder.get(cls.getName()); - - type = t != null ? t.byteValue() : 0; + boolean isAbstract = Modifier.isAbstract(cls.getModifiers()); - System.out.println("Processing class: " + cls.getName() + - (Modifier.isAbstract(cls.getModifiers()) ? " (abstract)" : "")); + System.out.println("Processing class: " + cls.getName() + (isAbstract ? " (abstract)" : "")); if (write) - generateAndWrite(cls); + generateAndWrite(cls, isAbstract ? -1 : type++); else generate(cls); } + +// type = 0; +// +// for (Class cls : classes) { +// if (Modifier.isAbstract(cls.getModifiers())) +// continue; +// +// System.out.println("case " + type++ + ":"); +// System.out.println(" return new " + cls.getSimpleName() + "();"); +// System.out.println(); +// } } /** @@ -201,7 +179,7 @@ public void generateAll(boolean write) throws Exception { * @throws Exception In case of error. */ @SuppressWarnings("ConstantConditions") - private void generateAndWrite(Class cls) throws Exception { + private void generateAndWrite(Class cls, byte type) throws Exception { assert cls != null; generate(cls); @@ -226,7 +204,6 @@ private void generateAndWrite(Class order number}. * @return Classes. * @throws Exception In case of error. */ - private Collection> classes(final Map classesOrder) throws Exception { - Collection> col = new TreeSet<>(new Comparator>() { - @Override public int compare(Class o1, Class o2) { - Integer c1 = classesOrder.get(o1.getName()); - - Integer c2 = classesOrder.get(o2.getName()); - - if (c1 == null) - return c2 == null ? o1.getName().compareTo(o2.getName()) : 1; - else - return c2 == null ? -1 : c1.compareTo(c2); - } - }); + private Collection> classes() throws Exception { + Collection> col = new TreeSet<>( + new Comparator>() { + @Override public int compare(Class c1, + Class c2) { + return c1.getName().compareTo(c2.getName()); + } + }); URLClassLoader ldr = (URLClassLoader)getClass().getClassLoader(); @@ -1119,56 +1085,6 @@ private Collection> classes( return col; } - /** - * Reads class names from {@code CLASSES_ORDER_FILE}. - * - * @return Map {class name => order number} - * @throws IOException In case of io error. - */ - private Map classesOrder() throws IOException { - BufferedReader reader = null; - - try { - reader = new BufferedReader(new FileReader(CLASSES_ORDER_FILE)); - - Map res = new HashMap<>(); - - while (true) { - String line = reader.readLine(); - - if (line == null) - break; - - line = line.trim(); - - if (!line.isEmpty()) - res.put(line, res.size()); - } - - return res; - } - finally { - if (reader != null) - reader.close(); - } - } - - /** - * Writes class names in {@code CLASSES_ORDER_FILE}. - * - * @param classes Classes for saving. - * @throws IOException In case of io error. - */ - private void classesOrder(Iterable> classes) - throws IOException { - Collection src = new ArrayList<>(); - - for (Class cls : classes) - src.add(cls.getName()); - - writeLines(new File(CLASSES_ORDER_FILE), src); - } - /** * Recursively process provided file or directory. * @@ -1208,26 +1124,4 @@ private void processFile(File file, ClassLoader ldr, int prefixLen, } } } - - /** - * Writes lines in file. - * - * @param file File. - * @param lines Lines. - * @throws IOException In case of io error. - */ - private void writeLines(File file, Iterable lines) throws IOException { - BufferedWriter writer = null; - - try { - writer = new BufferedWriter(new FileWriter(file)); - - for (String line : lines) - writer.write(line + '\n'); - } - finally { - if (writer != null) - writer.close(); - } - } } diff --git a/modules/tools/src/main/java/org/apache/ignite/codegen/generated-classes-order.txt b/modules/tools/src/main/java/org/apache/ignite/codegen/generated-classes-order.txt deleted file mode 100644 index 88ca4ac355bb8..0000000000000 --- a/modules/tools/src/main/java/org/apache/ignite/codegen/generated-classes-order.txt +++ /dev/null @@ -1,79 +0,0 @@ -org.apache.ignite.internal.GridJobCancelRequest -org.apache.ignite.internal.GridJobExecuteRequest -org.apache.ignite.internal.GridJobExecuteResponse -org.apache.ignite.internal.GridJobSiblingsRequest -org.apache.ignite.internal.GridJobSiblingsResponse -org.apache.ignite.internal.GridTaskCancelRequest -org.apache.ignite.internal.GridTaskSessionRequest -org.apache.ignite.internal.managers.checkpoint.GridCheckpointRequest -org.apache.ignite.internal.managers.communication.GridIoMessage -org.apache.ignite.internal.managers.communication.GridIoUserMessage -org.apache.ignite.internal.managers.deployment.GridDeploymentInfoBean -org.apache.ignite.internal.managers.deployment.GridDeploymentRequest -org.apache.ignite.internal.managers.deployment.GridDeploymentResponse -org.apache.ignite.internal.managers.eventstorage.GridEventStorageMessage -org.apache.ignite.internal.processors.cache.GridCacheEvictionRequest -org.apache.ignite.internal.processors.cache.GridCacheEvictionResponse -org.apache.ignite.internal.processors.cache.distributed.GridCacheOptimisticCheckPreparedTxRequest -org.apache.ignite.internal.processors.cache.distributed.GridCacheOptimisticCheckPreparedTxResponse -org.apache.ignite.internal.processors.cache.distributed.GridCachePessimisticCheckCommittedTxRequest -org.apache.ignite.internal.processors.cache.distributed.GridCachePessimisticCheckCommittedTxResponse -org.apache.ignite.internal.processors.cache.distributed.GridDistributedLockRequest -org.apache.ignite.internal.processors.cache.distributed.GridDistributedLockResponse -org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxFinishRequest -org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxFinishResponse -org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxPrepareRequest -org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxPrepareResponse -org.apache.ignite.internal.processors.cache.distributed.GridDistributedUnlockRequest -org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLockRequest -org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLockResponse -org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxFinishRequest -org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxFinishResponse -org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareRequest -org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareResponse -org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtUnlockRequest -org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicDeferredUpdateResponse -org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicUpdateRequest -org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicUpdateResponse -org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicUpdateRequest -org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicUpdateResponse -org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtForceKeysRequest -org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtForceKeysResponse -org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemandMessage -org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessage -org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsFullMessage -org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleMessage -org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleRequest -org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetRequest -org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetResponse -org.apache.ignite.internal.processors.cache.distributed.near.GridNearLockRequest -org.apache.ignite.internal.processors.cache.distributed.near.GridNearLockResponse -org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxFinishRequest -org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxFinishResponse -org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareRequest -org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareResponse -org.apache.ignite.internal.processors.cache.distributed.near.GridNearUnlockRequest -org.apache.ignite.internal.processors.cache.query.GridCacheQueryRequest -org.apache.ignite.internal.processors.cache.query.GridCacheQueryResponse -org.apache.ignite.internal.processors.clock.GridClockDeltaSnapshotMessage -org.apache.ignite.internal.processors.continuous.GridContinuousMessage -org.apache.ignite.internal.processors.dataload.GridDataLoadRequest -org.apache.ignite.internal.processors.dataload.GridDataLoadResponse -org.apache.ignite.internal.processors.dr.messages.internal.GridDrInternalRequest -org.apache.ignite.internal.processors.dr.messages.internal.GridDrInternalResponse -org.apache.ignite.internal.processors.ggfs.GridGgfsAckMessage -org.apache.ignite.internal.processors.ggfs.GridGgfsBlockKey -org.apache.ignite.internal.processors.ggfs.GridGgfsBlocksMessage -org.apache.ignite.internal.processors.ggfs.GridGgfsDeleteMessage -org.apache.ignite.internal.processors.ggfs.GridGgfsFileAffinityRange -org.apache.ignite.internal.processors.ggfs.GridGgfsFragmentizerRequest -org.apache.ignite.internal.processors.ggfs.GridGgfsFragmentizerResponse -org.apache.ignite.internal.processors.ggfs.GridGgfsSyncMessage -org.apache.ignite.internal.processors.rest.handlers.task.GridTaskResultRequest -org.apache.ignite.internal.processors.rest.handlers.task.GridTaskResultResponse -org.apache.ignite.internal.processors.streamer.GridStreamerCancelRequest -org.apache.ignite.internal.processors.streamer.GridStreamerExecutionRequest -org.apache.ignite.internal.processors.streamer.GridStreamerResponse -org.apache.ignite.spi.collision.jobstealing.JobStealingRequest -org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtAffinityAssignmentRequest -org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtAffinityAssignmentResponse From f8f78d6a7ca5f1352c5401527d22de77de33465f Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Mon, 2 Feb 2015 16:55:33 -0800 Subject: [PATCH 17/95] # IGNITE-61 - Direct marshalling --- .../direct/GridTcpCommunicationByteBufferStream.java | 12 ++++++++++-- .../direct/GridTcpCommunicationMessageReader.java | 6 +++++- .../cache/GridCacheAbstractFullApiSelfTest.java | 1 - 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationByteBufferStream.java b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationByteBufferStream.java index 85ce982a8b941..42f7777b39017 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationByteBufferStream.java +++ b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationByteBufferStream.java @@ -527,8 +527,11 @@ public double[] readDoubleArray() { */ public GridTcpCommunicationMessageAdapter readMessage() { if (!msgTypeDone) { - if (!buf.hasRemaining()) + if (!buf.hasRemaining()) { + lastFinished = false; + return null; + } byte type = readByte(); @@ -543,10 +546,15 @@ public GridTcpCommunicationMessageAdapter readMessage() { msgTypeDone = false; msg = null; + lastFinished = true; + return msg0; } - else + else { + lastFinished = false; + return null; + } } /** diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageReader.java b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageReader.java index 278becafcb0ce..574378f54f73f 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageReader.java +++ b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageReader.java @@ -223,7 +223,11 @@ public GridTcpCommunicationMessageReader(GridTcpMessageFactory msgFactory) { /** {@inheritDoc} */ @Nullable @Override public GridTcpCommunicationMessageAdapter readMessage(String name) { - return stream.readMessage(); + GridTcpCommunicationMessageAdapter msg = stream.readMessage(); + + lastRead = stream.lastFinished(); + + return msg; } /** {@inheritDoc} */ diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java index 4f55e2faa26a7..e9a766007f78f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java @@ -129,7 +129,6 @@ protected boolean offHeapValues() { @Override protected void beforeTestsStarted() throws Exception { super.beforeTestsStarted(); - for (int i = 0; i < gridCount(); i++) info("Grid " + i + ": " + grid(i).localNode().id()); } From 8027fc90f66631ae0b59567705816939371bb1e2 Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Tue, 3 Feb 2015 12:10:17 -0800 Subject: [PATCH 18/95] Merge branch 'sprint-1' of https://git-wip-us.apache.org/repos/asf/incubator-ignite into ignite-61 Conflicts: modules/core/src/main/java/org/apache/ignite/client/impl/connection/GridClientConnectionManagerAdapter.java modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java modules/core/src/main/java/org/apache/ignite/internal/managers/GridManagerAdapter.java modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlocksMessage.java modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageAdapter.java modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageState.java modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java --- .../internal/managers/communication/GridIoManager.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java index 9a45c59553cd6..51ece70abfd50 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java @@ -21,6 +21,7 @@ import org.apache.ignite.cluster.*; import org.apache.ignite.events.*; import org.apache.ignite.internal.*; +import org.apache.ignite.internal.managers.*; import org.apache.ignite.internal.managers.deployment.*; import org.apache.ignite.internal.managers.eventstorage.*; import org.apache.ignite.internal.processors.timeout.*; @@ -32,10 +33,6 @@ import org.apache.ignite.internal.util.worker.*; import org.apache.ignite.lang.*; import org.apache.ignite.marshaller.*; -import org.apache.ignite.spi.*; -import org.apache.ignite.spi.communication.*; -import org.apache.ignite.lang.*; -import org.apache.ignite.marshaller.*; import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.spi.*; import org.apache.ignite.spi.communication.*; From 8bbac3570e8f6ff1bcf996ff8d4e46c9150e908d Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Wed, 4 Feb 2015 18:48:25 -0800 Subject: [PATCH 19/95] IGNITE-61 - Direct marshalling --- .../util/direct/GridTcpCommunicationMessageState.java | 7 ++++--- .../util/direct/GridTcpCommunicationByteBufferStream.java | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageState.java b/modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageState.java index 44b22ce30f1d3..f0ac50ee71bca 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageState.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageState.java @@ -24,6 +24,7 @@ import org.apache.ignite.internal.util.*; import org.apache.ignite.lang.*; import org.apache.ignite.plugin.extensions.communication.*; +import org.gridgain.grid.util.direct.*; import org.jetbrains.annotations.*; import sun.misc.*; @@ -44,7 +45,7 @@ public class GridTcpCommunicationMessageState { private static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class); /** */ - private MessageWriter writer; + private final MessageWriter writer = new GridTcpCommunicationMessageWriter(); /** */ private MessageReader reader; @@ -74,8 +75,8 @@ public class GridTcpCommunicationMessageState { * @param writer Writer. */ public final void setWriter(MessageWriter writer) { - if (this.writer == null) - this.writer = writer; +// if (this.writer == null) +// this.writer = writer; } /** diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationByteBufferStream.java b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationByteBufferStream.java index 42f7777b39017..379cc466923c7 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationByteBufferStream.java +++ b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationByteBufferStream.java @@ -391,7 +391,7 @@ public void writeDoubleArray(double[] val) { public void writeMessage(GridTcpCommunicationMessageAdapter msg) { assert msg != null; - lastFinished = msg.writeTo(buf); + lastFinished = buf.hasRemaining() && msg.writeTo(buf); } /** {@inheritDoc} */ From 06a542d121fe078b1307b1defcc6bff451509ccd Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Wed, 4 Feb 2015 18:59:25 -0800 Subject: [PATCH 20/95] IGNITE-61 - Temporary compilation fix --- modules/tools/pom.xml | 10 +- .../CommunicationMessageCodeGenerator.java | 2240 ++++++++--------- 2 files changed, 1125 insertions(+), 1125 deletions(-) diff --git a/modules/tools/pom.xml b/modules/tools/pom.xml index d81e692102196..3a01471a098db 100644 --- a/modules/tools/pom.xml +++ b/modules/tools/pom.xml @@ -41,11 +41,11 @@ - - org.apache.ignite - ignite-core - ${ignite.version} - + + + + + org.jodd diff --git a/modules/tools/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java b/modules/tools/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java index 5ab27cce8e24e..fdd999146cca6 100644 --- a/modules/tools/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java +++ b/modules/tools/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java @@ -1,1127 +1,1127 @@ -/* @java.file.header */ - -/* _________ _____ __________________ _____ - * __ ____/___________(_)______ /__ ____/______ ____(_)_______ - * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ - * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / - * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ - */ - -package org.apache.ignite.codegen; - -import com.sun.istack.internal.*; -import org.apache.ignite.internal.*; -import org.apache.ignite.internal.processors.cache.*; -import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.*; -import org.apache.ignite.internal.processors.cache.version.*; -import org.apache.ignite.internal.processors.clock.*; -import org.apache.ignite.internal.util.*; -import org.apache.ignite.internal.util.direct.*; -import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.lang.*; - -import java.io.*; -import java.lang.reflect.*; -import java.net.*; -import java.nio.*; -import java.util.*; - -import static java.lang.reflect.Modifier.*; - -/** - * Direct marshallable code generator. - */ -public class CommunicationMessageCodeGenerator { - /** */ - private static final Comparator FIELD_CMP = new Comparator() { - @Override public int compare(Field f1, Field f2) { - int ver1 = 0; - - GridDirectVersion verAnn1 = f1.getAnnotation(GridDirectVersion.class); - - if (verAnn1 != null) { - ver1 = verAnn1.value(); - - assert ver1 > 0; - } - - int ver2 = 0; - - GridDirectVersion verAnn2 = f2.getAnnotation(GridDirectVersion.class); - - if (verAnn2 != null) { - ver2 = verAnn2.value(); - - assert ver2 > 0; - } - - return ver1 < ver2 ? -1 : ver1 > ver2 ? 1 : f1.getName().compareTo(f2.getName()); - } - }; - - /** */ - private static final String SRC_DIR = U.getGridGainHome() + "/modules/core/src/main/java"; - - /** */ - private static final Class BASE_CLS = GridTcpCommunicationMessageAdapter.class; - - /** */ - private static final String EMPTY = ""; - - /** */ - private static final String TAB = " "; - - /** */ - private static final String COMM_STATE_VAR = "commState"; - - /** */ - private static final String BUF_VAR = "buf"; - - /** */ - private static final String STATE_VAR = COMM_STATE_VAR + "." + "idx"; - - /** */ - private static final String TYPE_WRITTEN_VAR = COMM_STATE_VAR + "." + "typeWritten"; - - /** */ - private static final String IT_VAR = COMM_STATE_VAR + "." + "it"; - - /** */ - private static final String CUR_VAR = COMM_STATE_VAR + "." + "cur"; - - /** */ - private static final String KEY_DONE_VAR = COMM_STATE_VAR + "." + "keyDone"; - - /** */ - private static final String READ_SIZE_VAR = COMM_STATE_VAR + "." + "readSize"; - - /** */ - private static final String READ_ITEMS_VAR = COMM_STATE_VAR + "." + "readItems"; - - /** */ - private static final String DFLT_LOC_VAR = "_val"; - - /** */ - private final Collection write = new ArrayList<>(); - - /** */ - private final Collection read = new ArrayList<>(); - - /** */ - private final Collection clone = new ArrayList<>(); - - /** */ - private final Collection clone0 = new ArrayList<>(); - - /** */ - private final Map, Integer> fieldCnt = new HashMap<>(); - - /** */ - private List fields; - - /** */ - private int indent; - - /** - * @param args Arguments. - */ - public static void main(String[] args) { - CommunicationMessageCodeGenerator gen = new CommunicationMessageCodeGenerator(); - - try { - gen.generateAll(true); - } - catch (Exception e) { - e.printStackTrace(); - } - } - - /** - * Generates code for all classes. - * - * @param write Whether to write to file. - * @throws Exception In case of error. - */ - public void generateAll(boolean write) throws Exception { - Collection> classes = classes(); - - byte type = 0; - - for (Class cls : classes) { - boolean isAbstract = Modifier.isAbstract(cls.getModifiers()); - - System.out.println("Processing class: " + cls.getName() + (isAbstract ? " (abstract)" : "")); - - if (write) - generateAndWrite(cls, isAbstract ? -1 : type++); - else - generate(cls); - } - -// type = 0; +///* @java.file.header */ +// +///* _________ _____ __________________ _____ +// * __ ____/___________(_)______ /__ ____/______ ____(_)_______ +// * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ +// * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / +// * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ +// */ +// +//package org.apache.ignite.codegen; +// +//import com.sun.istack.internal.*; +//import org.apache.ignite.internal.*; +//import org.apache.ignite.internal.processors.cache.*; +//import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.*; +//import org.apache.ignite.internal.processors.cache.version.*; +//import org.apache.ignite.internal.processors.clock.*; +//import org.apache.ignite.internal.util.*; +//import org.apache.ignite.internal.util.direct.*; +//import org.apache.ignite.internal.util.typedef.internal.*; +//import org.apache.ignite.lang.*; +// +//import java.io.*; +//import java.lang.reflect.*; +//import java.net.*; +//import java.nio.*; +//import java.util.*; +// +//import static java.lang.reflect.Modifier.*; +// +///** +// * Direct marshallable code generator. +// */ +//public class CommunicationMessageCodeGenerator { +// /** */ +// private static final Comparator FIELD_CMP = new Comparator() { +// @Override public int compare(Field f1, Field f2) { +// int ver1 = 0; +// +// GridDirectVersion verAnn1 = f1.getAnnotation(GridDirectVersion.class); +// +// if (verAnn1 != null) { +// ver1 = verAnn1.value(); +// +// assert ver1 > 0; +// } +// +// int ver2 = 0; +// +// GridDirectVersion verAnn2 = f2.getAnnotation(GridDirectVersion.class); +// +// if (verAnn2 != null) { +// ver2 = verAnn2.value(); +// +// assert ver2 > 0; +// } +// +// return ver1 < ver2 ? -1 : ver1 > ver2 ? 1 : f1.getName().compareTo(f2.getName()); +// } +// }; +// +// /** */ +// private static final String SRC_DIR = U.getGridGainHome() + "/modules/core/src/main/java"; +// +// /** */ +// private static final Class BASE_CLS = GridTcpCommunicationMessageAdapter.class; +// +// /** */ +// private static final String EMPTY = ""; +// +// /** */ +// private static final String TAB = " "; +// +// /** */ +// private static final String COMM_STATE_VAR = "commState"; +// +// /** */ +// private static final String BUF_VAR = "buf"; +// +// /** */ +// private static final String STATE_VAR = COMM_STATE_VAR + "." + "idx"; +// +// /** */ +// private static final String TYPE_WRITTEN_VAR = COMM_STATE_VAR + "." + "typeWritten"; +// +// /** */ +// private static final String IT_VAR = COMM_STATE_VAR + "." + "it"; +// +// /** */ +// private static final String CUR_VAR = COMM_STATE_VAR + "." + "cur"; +// +// /** */ +// private static final String KEY_DONE_VAR = COMM_STATE_VAR + "." + "keyDone"; +// +// /** */ +// private static final String READ_SIZE_VAR = COMM_STATE_VAR + "." + "readSize"; +// +// /** */ +// private static final String READ_ITEMS_VAR = COMM_STATE_VAR + "." + "readItems"; +// +// /** */ +// private static final String DFLT_LOC_VAR = "_val"; +// +// /** */ +// private final Collection write = new ArrayList<>(); +// +// /** */ +// private final Collection read = new ArrayList<>(); +// +// /** */ +// private final Collection clone = new ArrayList<>(); +// +// /** */ +// private final Collection clone0 = new ArrayList<>(); +// +// /** */ +// private final Map, Integer> fieldCnt = new HashMap<>(); +// +// /** */ +// private List fields; +// +// /** */ +// private int indent; +// +// /** +// * @param args Arguments. +// */ +// public static void main(String[] args) { +// CommunicationMessageCodeGenerator gen = new CommunicationMessageCodeGenerator(); +// +// try { +// gen.generateAll(true); +// } +// catch (Exception e) { +// e.printStackTrace(); +// } +// } +// +// /** +// * Generates code for all classes. +// * +// * @param write Whether to write to file. +// * @throws Exception In case of error. +// */ +// public void generateAll(boolean write) throws Exception { +// Collection> classes = classes(); +// +// byte type = 0; // // for (Class cls : classes) { -// if (Modifier.isAbstract(cls.getModifiers())) -// continue; +// boolean isAbstract = Modifier.isAbstract(cls.getModifiers()); +// +// System.out.println("Processing class: " + cls.getName() + (isAbstract ? " (abstract)" : "")); +// +// if (write) +// generateAndWrite(cls, isAbstract ? -1 : type++); +// else +// generate(cls); +// } +// +//// type = 0; +//// +//// for (Class cls : classes) { +//// if (Modifier.isAbstract(cls.getModifiers())) +//// continue; +//// +//// System.out.println("case " + type++ + ":"); +//// System.out.println(" return new " + cls.getSimpleName() + "();"); +//// System.out.println(); +//// } +// } +// +// /** +// * Generates code for provided class and writes it to source file. +// * Note: this method must be called only from {@code generateAll(boolean)} +// * and only with updating {@code CLASSES_ORDER_FILE} and other auto generated files. +// * +// * @param cls Class. +// * @throws Exception In case of error. +// */ +// @SuppressWarnings("ConstantConditions") +// private void generateAndWrite(Class cls, byte type) throws Exception { +// assert cls != null; +// +// generate(cls); +// +// File file = new File(SRC_DIR, cls.getName().replace('.', File.separatorChar) + ".java"); +// +// if (!file.exists() || !file.isFile()) { +// System.out.println(" Source file not found: " + file.getPath()); // -// System.out.println("case " + type++ + ":"); -// System.out.println(" return new " + cls.getSimpleName() + "();"); -// System.out.println(); +// return; // } - } - - /** - * Generates code for provided class and writes it to source file. - * Note: this method must be called only from {@code generateAll(boolean)} - * and only with updating {@code CLASSES_ORDER_FILE} and other auto generated files. - * - * @param cls Class. - * @throws Exception In case of error. - */ - @SuppressWarnings("ConstantConditions") - private void generateAndWrite(Class cls, byte type) throws Exception { - assert cls != null; - - generate(cls); - - File file = new File(SRC_DIR, cls.getName().replace('.', File.separatorChar) + ".java"); - - if (!file.exists() || !file.isFile()) { - System.out.println(" Source file not found: " + file.getPath()); - - return; - } - - Collection src = new ArrayList<>(); - - BufferedReader rdr = null; - - try { - rdr = new BufferedReader(new FileReader(file)); - - String line; - boolean skip = false; - - boolean writeFound = false; - boolean readFound = false; - boolean cloneFound = false; - boolean clone0Found = false; - - while ((line = rdr.readLine()) != null) { - if (!skip) { - src.add(line); - - if (line.contains("public boolean writeTo(ByteBuffer buf)")) { - src.addAll(write); - - skip = true; - - writeFound = true; - } - else if (line.contains("public boolean readFrom(ByteBuffer buf)")) { - src.addAll(read); - - skip = true; - - readFound = true; - } -// else if (type >= 0 && line.contains("public byte directType()")) { -// src.add(TAB + TAB + "return " + type + ';'); +// +// Collection src = new ArrayList<>(); +// +// BufferedReader rdr = null; +// +// try { +// rdr = new BufferedReader(new FileReader(file)); +// +// String line; +// boolean skip = false; +// +// boolean writeFound = false; +// boolean readFound = false; +// boolean cloneFound = false; +// boolean clone0Found = false; +// +// while ((line = rdr.readLine()) != null) { +// if (!skip) { +// src.add(line); +// +// if (line.contains("public boolean writeTo(ByteBuffer buf)")) { +// src.addAll(write); // // skip = true; +// +// writeFound = true; // } - else if (line.contains("public GridTcpCommunicationMessageAdapter clone()")) { - src.addAll(clone); - - skip = true; - - cloneFound = true; - } - else if (line.contains("protected void clone0(GridTcpCommunicationMessageAdapter _msg)")) { - src.addAll(clone0); - - skip = true; - - clone0Found = true; - } - } - else if (line.startsWith(TAB + "}")) { - src.add(line); - - skip = false; - } - } - - if (!writeFound) - System.out.println(" writeTo method doesn't exist."); - - if (!readFound) - System.out.println(" readFrom method doesn't exist."); - - if (!cloneFound) - System.out.println(" clone method doesn't exist."); - - if (!clone0Found) - System.out.println(" clone0 method doesn't exist."); - } - finally { - if (rdr != null) - rdr.close(); - } - - BufferedWriter wr = null; - - try { - wr = new BufferedWriter(new FileWriter(file)); - - for (String line : src) - wr.write(line + '\n'); - } - finally { - if (wr != null) - wr.close(); - } - } - - /** - * Generates code for provided class. - * - * @param cls Class. - * @throws Exception In case of error. - */ - public void generate(Class cls) throws Exception { - assert cls != null; - - write.clear(); - read.clear(); - clone.clear(); - clone0.clear(); - - fields = new ArrayList<>(); - - Field[] declaredFields = cls.getDeclaredFields(); - - for (Field field : declaredFields) { - int mod = field.getModifiers(); - - if (!isStatic(mod) && !isTransient(mod) && !field.isAnnotationPresent(GridDirectTransient.class)) - fields.add(field); - } - - Collections.sort(fields, FIELD_CMP); - - indent = 2; - - boolean hasSuper = cls.getSuperclass() != BASE_CLS; - - String clsName = cls.getSimpleName(); - - if (!Modifier.isAbstract(cls.getModifiers())) { - clone.add(builder().a(clsName).a(" _clone = new ").a(clsName).a("();").toString()); - clone.add(EMPTY); - clone.add(builder().a("clone0(_clone);").toString()); - clone.add(EMPTY); - clone.add(builder().a("return _clone;").toString()); - } - - if (hasSuper) { - clone0.add(builder().a("super.clone0(_msg);").toString()); - clone0.add(EMPTY); - } - - Collection cloningFields = new ArrayList<>(declaredFields.length); - - for (Field field: declaredFields) - if (!isStatic(field.getModifiers())) - cloningFields.add(field); - - if (!cloningFields.isEmpty()) { - clone0.add(builder().a(clsName).a(" _clone = (").a(clsName).a(")_msg;").toString()); - clone0.add(EMPTY); - - for (Field field : cloningFields) { - String name = field.getName(); - Class type = field.getType(); - - String res = name; - - if (BASE_CLS.isAssignableFrom(type)) - res = name + " != null ? (" + type.getSimpleName() + ")" + name + ".clone() : null"; - - clone0.add(builder().a("_clone.").a(name).a(" = ").a(res).a(";").toString()); - } - } - - start(write, hasSuper ? "writeTo" : null, true); - start(read, hasSuper ? "readFrom" : null, false); - - indent++; - - int state = startState(cls); - - for (Field field : fields) - processField(field, state++); - - indent--; - - finish(write); - finish(read); - } - - /** - * @param cls Message class. - * @return Start state. - */ - private int startState(Class cls) { - assert cls != null; - - Class superCls = cls.getSuperclass(); - - Integer state = fieldCnt.get(superCls); - - if (state != null) - return state; - - state = 0; - - while (cls.getSuperclass() != BASE_CLS) { - cls = cls.getSuperclass(); - - for (Field field : cls.getDeclaredFields()) { - int mod = field.getModifiers(); - - if (!isStatic(mod) && !isTransient(mod) && !field.isAnnotationPresent(GridDirectTransient.class)) - state++; - } - } - - fieldCnt.put(superCls, state); - - return state; - } - - /** - * @param code Code lines. - * @param superMtd Super class method name. - * @param writeType Whether to write message type. - */ - private void start(Collection code, @Nullable String superMtd, boolean writeType) { - assert code != null; - - code.add(builder().a(COMM_STATE_VAR).a(".setBuffer(").a(BUF_VAR).a(");").toString()); - code.add(EMPTY); - - if (superMtd != null) { - returnFalseIfFailed(code, "super." + superMtd, BUF_VAR); - - code.add(EMPTY); - } - - if (writeType) { - code.add(builder().a("if (!").a(TYPE_WRITTEN_VAR).a(") {").toString()); - - indent++; - - returnFalseIfFailed(code, COMM_STATE_VAR + ".putByte", "null", "directType()"); - - code.add(EMPTY); - code.add(builder().a(TYPE_WRITTEN_VAR).a(" = true;").toString()); - - indent--; - - code.add(builder().a("}").toString()); - code.add(EMPTY); - } - - if (!fields.isEmpty()) - code.add(builder().a("switch (").a(STATE_VAR).a(") {").toString()); - } - - /** - * @param code Code lines. - */ - private void finish(Collection code) { - assert code != null; - - if (!fields.isEmpty()) { - code.add(builder().a("}").toString()); - code.add(EMPTY); - } - - code.add(builder().a("return true;").toString()); - } - - /** - * @param field Field. - * @param opt Case option. - */ - private void processField(Field field, int opt) { - assert field != null; - assert opt >= 0; - - GridDirectCollection colAnn = field.getAnnotation(GridDirectCollection.class); - GridDirectMap mapAnn = field.getAnnotation(GridDirectMap.class); - - if (colAnn == null && Collection.class.isAssignableFrom(field.getType())) - throw new IllegalStateException("@GridDirectCollection annotation is not provided for field: " + - field.getName()); - - if (mapAnn == null && Map.class.isAssignableFrom(field.getType())) - throw new IllegalStateException("@GridDirectMap annotation is not provided for field: " + field.getName()); - - writeField(field, opt, colAnn, mapAnn); - readField(field, opt, colAnn, mapAnn); - } - - /** - * @param field Field. - * @param opt Case option. - * @param colAnn Collection annotation. - * @param mapAnn Map annotation. - */ - private void writeField(Field field, int opt, @Nullable GridDirectCollection colAnn, - @Nullable GridDirectMap mapAnn) { - assert field != null; - assert opt >= 0; - - write.add(builder().a("case ").a(opt).a(":").toString()); - - indent++; - - returnFalseIfWriteFailed(field.getType(), field.getName(), colAnn != null ? colAnn.value() : null, - mapAnn != null ? mapAnn.keyType() : null, mapAnn != null ? mapAnn.valueType() : null, false); - - write.add(EMPTY); - write.add(builder().a(STATE_VAR).a("++;").toString()); - write.add(EMPTY); - - indent--; - } - - /** - * @param field Field. - * @param opt Case option. - * @param colAnn Collection annotation. - * @param mapAnn Map annotation. - */ - private void readField(Field field, int opt, @Nullable GridDirectCollection colAnn, - @Nullable GridDirectMap mapAnn) { - assert field != null; - assert opt >= 0; - - read.add(builder().a("case ").a(opt).a(":").toString()); - - indent++; - - returnFalseIfReadFailed(field.getType(), field.getName(), colAnn != null ? colAnn.value() : null, - mapAnn != null ? mapAnn.keyType() : null, mapAnn != null ? mapAnn.valueType() : null, false); - - read.add(EMPTY); - read.add(builder().a(STATE_VAR).a("++;").toString()); - read.add(EMPTY); - - indent--; - } - - /** - * @param type Field type. - * @param name Field name. - * @param colItemType Collection item type. - * @param mapKeyType Map key type. - * @param mapValType Map key value. - * @param raw Raw write flag. - */ - private void returnFalseIfWriteFailed(Class type, String name, @Nullable Class colItemType, - @Nullable Class mapKeyType, @Nullable Class mapValType, boolean raw) { - assert type != null; - assert name != null; - - String field = raw ? "null" : '"' + name + '"'; - - if (type == byte.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putByte", field, name); - else if (type == short.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putShort", field, name); - else if (type == int.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putInt", field, name); - else if (type == long.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putLong", field, name); - else if (type == float.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putFloat", field, name); - else if (type == double.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putDouble", field, name); - else if (type == char.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putChar", field, name); - else if (type == boolean.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putBoolean", field, name); - else if (type == byte[].class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putByteArray", field, name); - else if (type == short[].class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putShortArray", field, name); - else if (type == int[].class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putIntArray", field, name); - else if (type == long[].class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putLongArray", field, name); - else if (type == float[].class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putFloatArray", field, name); - else if (type == double[].class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putDoubleArray", field, name); - else if (type == char[].class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putCharArray", field, name); - else if (type == boolean[].class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putBooleanArray", field, name); - else if (type == UUID.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putUuid", field, name); - else if (type == ByteBuffer.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putByteBuffer", field, name); - else if (type == IgniteUuid.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putGridUuid", field, name); - else if (type == GridClockDeltaVersion.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putClockDeltaVersion", field, name); - else if (type == GridByteArrayList.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putByteArrayList", field, name); - else if (type == GridLongList.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putLongList", field, name); - else if (type == GridCacheVersion.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putCacheVersion", field, name); - else if (type == GridDhtPartitionExchangeId.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putDhtPartitionExchangeId", field, name); - else if (type == GridCacheValueBytes.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putValueBytes", field, name); - //else if (type == GridDrInternalRequestEntry.class) - // returnFalseIfFailed(write, COMM_STATE_VAR + ".putDrInternalRequestEntry", field, name); - else if (type == String.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putString", field, name); - else if (type == BitSet.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putBitSet", field, name); - else if (type.isEnum()) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putEnum", field, name); - else if (BASE_CLS.isAssignableFrom(type)) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putMessage", field, name); - else if (type.isArray() || Collection.class.isAssignableFrom(type)) { - boolean isArr = type.isArray(); - - if (isArr) - colItemType = type.getComponentType(); - - assert colItemType != null; - - write.add(builder().a("if (").a(name).a(" != null) {").toString()); - - indent++; - - write.add(builder().a("if (").a(IT_VAR).a(" == null) {").toString()); - - indent++; - - returnFalseIfFailed(write, COMM_STATE_VAR + ".putInt", "null", name + "." + (isArr ? "length" : "size()")); - - write.add(EMPTY); - write.add(builder().a(IT_VAR).a(" = ").a(isArr ? "arrayIterator(" + name + ")" : name + ".iterator()"). - a(";").toString()); - - indent--; - - write.add(builder().a("}").toString()); - write.add(EMPTY); - write.add(builder().a("while (").a(IT_VAR).a(".hasNext() || ").a(CUR_VAR).a(" != NULL").a(") {"). - toString()); - - indent++; - - write.add(builder().a("if (").a(CUR_VAR).a(" == NULL)").toString()); - - indent++; - - write.add(builder().a(CUR_VAR).a(" = ").a(IT_VAR).a(".next();").toString()); - - indent--; - - write.add(EMPTY); - - returnFalseIfWriteFailed(colItemType, "(" + colItemType.getSimpleName() + ")" + CUR_VAR, - null, null, null, true); - - write.add(EMPTY); - write.add(builder().a(CUR_VAR).a(" = NULL;").toString()); - - indent--; - - write.add(builder().a("}").toString()); - write.add(EMPTY); - write.add(builder().a(IT_VAR).a(" = null;").toString()); - - indent--; - - write.add(builder().a("} else {").toString()); - - indent++; - - returnFalseIfFailed(write, COMM_STATE_VAR + ".putInt", "null", "-1"); - - indent--; - - write.add(builder().a("}").toString()); - } - else if (Map.class.isAssignableFrom(type)) { - assert mapKeyType != null; - assert mapValType != null; - - write.add(builder().a("if (").a(name).a(" != null) {").toString()); - - indent++; - - write.add(builder().a("if (").a(IT_VAR).a(" == null) {").toString()); - - indent++; - - returnFalseIfFailed(write, COMM_STATE_VAR + ".putInt", "null", name + ".size()"); - - write.add(EMPTY); - write.add(builder().a(IT_VAR).a(" = ").a(name).a(".entrySet().iterator();").toString()); - - indent--; - - write.add(builder().a("}").toString()); - write.add(EMPTY); - write.add(builder().a("while (").a(IT_VAR).a(".hasNext() || ").a(CUR_VAR).a(" != NULL").a(") {"). - toString()); - - indent++; - - write.add(builder().a("if (").a(CUR_VAR).a(" == NULL)").toString()); - - indent++; - - write.add(builder().a(CUR_VAR).a(" = ").a(IT_VAR).a(".next();").toString()); - - indent--; - - String entryType = "Map.Entry<" + U.box(mapKeyType).getSimpleName() + ", " + - U.box(mapValType).getSimpleName() + ">"; - - write.add(EMPTY); - write.add(builder().a(entryType).a(" e = (").a(entryType).a(")").a(CUR_VAR).a(";").toString()); - write.add(EMPTY); - write.add(builder().a("if (!").a(KEY_DONE_VAR).a(") {").toString()); - - indent++; - - returnFalseIfWriteFailed(mapKeyType, "e.getKey()", null, null, null, true); - - write.add(EMPTY); - write.add(builder().a(KEY_DONE_VAR).a(" = true;").toString()); - - indent--; - - write.add(builder().a("}").toString()); - write.add(EMPTY); - - returnFalseIfWriteFailed(mapValType, "e.getValue()", null, null, null, true); - - write.add(EMPTY); - write.add(builder().a(KEY_DONE_VAR).a(" = false;").toString()); - write.add(EMPTY); - write.add(builder().a(CUR_VAR).a(" = NULL;").toString()); - - indent--; - - write.add(builder().a("}").toString()); - write.add(EMPTY); - write.add(builder().a(IT_VAR).a(" = null;").toString()); - - indent--; - - write.add(builder().a("} else {").toString()); - - indent++; - - returnFalseIfFailed(write, COMM_STATE_VAR + ".putInt", "null", "-1"); - - indent--; - - write.add(builder().a("}").toString()); - } - else - throw new IllegalStateException("Unsupported type: " + type); - } - - /** - * @param type Field type. - * @param name Field name. - * @param colItemType Collection item type. - * @param mapKeyType Map key type. - * @param mapValType Map value type. - * @param raw Raw read flag. - */ - private void returnFalseIfReadFailed(Class type, @Nullable String name, @Nullable Class colItemType, - @Nullable Class mapKeyType, @Nullable Class mapValType, boolean raw) { - assert type != null; - - String field = raw ? "null" : '"' + name + '"'; - - String retType = type.getSimpleName(); - - if (type == byte.class) - returnFalseIfReadFailed("byte", name, null, COMM_STATE_VAR + ".getByte", field, false); - else if (type == short.class) - returnFalseIfReadFailed("short", name, null, COMM_STATE_VAR + ".getShort", field, false); - else if (type == int.class) - returnFalseIfReadFailed("int", name, null, COMM_STATE_VAR + ".getInt", field, false); - else if (type == long.class) - returnFalseIfReadFailed("long", name, null, COMM_STATE_VAR + ".getLong", field, false); - else if (type == float.class) - returnFalseIfReadFailed("float", name, null, COMM_STATE_VAR + ".getFloat", field, false); - else if (type == double.class) - returnFalseIfReadFailed("double", name, null, COMM_STATE_VAR + ".getDouble", field, false); - else if (type == char.class) - returnFalseIfReadFailed("char", name, null, COMM_STATE_VAR + ".getChar", field, false); - else if (type == boolean.class) - returnFalseIfReadFailed("boolean", name, null, COMM_STATE_VAR + ".getBoolean", field, false); - else if (type == byte[].class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getByteArray", field, false); - else if (type == short[].class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getShortArray", field, false); - else if (type == int[].class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getIntArray", field, false); - else if (type == long[].class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getLongArray", field, false); - else if (type == float[].class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getFloatArray", field, false); - else if (type == double[].class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getDoubleArray", field, false); - else if (type == char[].class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getCharArray", field, false); - else if (type == boolean[].class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getBooleanArray", field, false); - else if (type == UUID.class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getUuid", field, false); - else if (type == ByteBuffer.class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getByteBuffer", field, false); - else if (type == IgniteUuid.class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getGridUuid", field, false); - else if (type == GridClockDeltaVersion.class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getClockDeltaVersion", field, false); - else if (type == GridLongList.class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getLongList", field, false); - else if (type == GridByteArrayList.class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getByteArrayList", field, false); - else if (type == GridCacheVersion.class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getCacheVersion", field, false); - else if (type == GridDhtPartitionExchangeId.class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getDhtPartitionExchangeId", field, false); - else if (type == GridCacheValueBytes.class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getValueBytes", field, false); - //else if (type == GridDrInternalRequestEntry.class) - // returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getDrInternalRequestEntry", field, false); - else if (type == String.class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getString", field, false); - else if (type == BitSet.class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getBitSet", field, false); - else if (type.isEnum()) { - assert name != null; - - returnFalseIfReadFailed("byte", null, name + "0", COMM_STATE_VAR + ".getByte", field, false); - - read.add(EMPTY); - read.add(builder().a(name).a(" = ").a(type.getSimpleName()).a(".fromOrdinal(").a(name).a("0);").toString()); - } - else if (BASE_CLS.isAssignableFrom(type)) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getMessage", field, true); - else if (type.isArray() || Collection.class.isAssignableFrom(type)) { - assert name != null; - - boolean isArr = type.isArray(); - - if (isArr) - colItemType = type.getComponentType(); - - assert colItemType != null; - - Class colType = Set.class.isAssignableFrom(type) ? HashSet.class : ArrayList.class; - - read.add(builder().a("if (").a(READ_SIZE_VAR).a(" == -1) {").toString()); - - indent++; - - returnFalseIfReadFailed(int.class, READ_SIZE_VAR, null, null, null, true); - - indent--; - - read.add(builder().a("}").toString()); - read.add(EMPTY); - read.add(builder().a("if (").a(READ_SIZE_VAR).a(" >= 0) {").toString()); - - indent++; - - read.add(builder().a("if (").a(name).a(" == null)").toString()); - - indent++; - - if (isArr) { - String val = colItemType.isArray() ? - colItemType.getComponentType().getSimpleName() + "[" + READ_SIZE_VAR + "][]" : - colItemType.getSimpleName() + "[" + READ_SIZE_VAR + "]"; - - read.add(builder().a(name).a(" = new ").a(val).a(";"). - toString()); - } - else { - read.add(builder().a(name).a(" = new ").a(colType.getSimpleName()).a("<>(").a(READ_SIZE_VAR).a(");"). - toString()); - } - - indent--; - - read.add(EMPTY); - read.add(builder().a("for (int i = ").a(READ_ITEMS_VAR).a("; i < ").a(READ_SIZE_VAR).a("; i++) {"). - toString()); - - indent++; - - String var = colItemType.isPrimitive() ? colItemType.getSimpleName() + " " + DFLT_LOC_VAR : null; - - returnFalseIfReadFailed(colItemType, var, null, null, null, true); - - read.add(EMPTY); - read.add(builder().a(name).a(isArr ? "[i] = " : ".add(").a("(").a(U.box(colItemType).getSimpleName()). - a(")").a(DFLT_LOC_VAR).a(isArr ? ";" : ");").toString()); - read.add(EMPTY); - read.add(builder().a(READ_ITEMS_VAR).a("++;").toString()); - - indent--; - - read.add(builder().a("}").toString()); - - indent--; - - read.add(builder().a("}").toString()); - read.add(EMPTY); - read.add(builder().a(READ_SIZE_VAR).a(" = -1;").toString()); - read.add(builder().a(READ_ITEMS_VAR).a(" = 0;").toString()); - } - else if (Map.class.isAssignableFrom(type)) { - assert name != null; - assert mapKeyType != null; - assert mapValType != null; - - Class mapType = LinkedHashMap.class.isAssignableFrom(type) ? LinkedHashMap.class : HashMap.class; - - read.add(builder().a("if (").a(READ_SIZE_VAR).a(" == -1) {").toString()); - - indent++; - - returnFalseIfReadFailed(int.class, READ_SIZE_VAR, null, null, null, true); - - indent--; - - read.add(builder().a("}").toString()); - read.add(EMPTY); - read.add(builder().a("if (").a(READ_SIZE_VAR).a(" >= 0) {").toString()); - - indent++; - - read.add(builder().a("if (").a(name).a(" == null)").toString()); - - indent++; - - read.add(builder().a(name).a(" = new ").a(mapType.getSimpleName()).a("<>(").a(READ_SIZE_VAR).a(", 1.0f);"). - toString()); - - indent--; - - read.add(EMPTY); - read.add(builder().a("for (int i = ").a(READ_ITEMS_VAR).a("; i < ").a(READ_SIZE_VAR).a("; i++) {"). - toString()); - - indent++; - - read.add(builder().a("if (!").a(KEY_DONE_VAR).a(") {").toString()); - - indent++; - - String var = mapKeyType.isPrimitive() ? mapKeyType.getSimpleName() + " " + DFLT_LOC_VAR : null; - - returnFalseIfReadFailed(mapKeyType, var, null, null, null, true); - - read.add(EMPTY); - read.add(builder().a(CUR_VAR).a(" = ").a(DFLT_LOC_VAR).a(";").toString()); - read.add(builder().a(KEY_DONE_VAR).a(" = true;").toString()); - - indent--; - - read.add(builder().a("}").toString()); - read.add(EMPTY); - - var = mapValType.isPrimitive() ? mapValType.getSimpleName() + " " + DFLT_LOC_VAR : null; - - returnFalseIfReadFailed(mapValType, var, null, null, null, true); - - read.add(EMPTY); - read.add(builder().a(name).a(".put((").a(U.box(mapKeyType).getSimpleName()).a(")").a(CUR_VAR). - a(", ").a(DFLT_LOC_VAR).a(");").toString()); - read.add(EMPTY); - read.add(builder().a(KEY_DONE_VAR).a(" = false;").toString()); - read.add(EMPTY); - read.add(builder().a(READ_ITEMS_VAR).a("++;").toString()); - - indent--; - - read.add(builder().a("}").toString()); - - indent--; - - read.add(builder().a("}").toString()); - read.add(EMPTY); - read.add(builder().a(READ_SIZE_VAR).a(" = -1;").toString()); - read.add(builder().a(READ_ITEMS_VAR).a(" = 0;").toString()); - read.add(builder().a(CUR_VAR).a(" = null;").toString()); - } - else - throw new IllegalStateException("Unsupported type: " + type); - } - - /** - * @param retType Return type. - * @param var Variable name. - * @param locVar Local variable name. - * @param mtd Method name. - * @param arg Method argument. - * @param cast Whether cast is needed. - */ - private void returnFalseIfReadFailed(String retType, @Nullable String var, @Nullable String locVar, String mtd, - @Nullable String arg, boolean cast) { - assert retType != null; - assert mtd != null; - - if (var == null) - var = retType + " " + (locVar != null ? locVar : DFLT_LOC_VAR); - - read.add(builder().a(var).a(" = ").a(cast ? "(" + retType + ")" : "").a(mtd). - a(arg != null ? "(" + arg + ");" : "();").toString()); - read.add(EMPTY); - - read.add(builder().a("if (!").a(COMM_STATE_VAR).a(".lastRead())").toString()); - - indent++; - - read.add(builder().a("return false;").toString()); - - indent--; - } - - /** - * @param code Code lines. - * @param accessor Field or method name. - * @param args Method arguments. - */ - private void returnFalseIfFailed(Collection code, String accessor, @Nullable String... args) { - assert code != null; - assert accessor != null; - - String argsStr = ""; - - if (args != null && args.length > 0) { - for (String arg : args) - argsStr += arg + ", "; - - argsStr = argsStr.substring(0, argsStr.length() - 2); - } - - code.add(builder().a("if (!").a(accessor).a("(" + argsStr + ")").a(")").toString()); - - indent++; - - code.add(builder().a("return false;").toString()); - - indent--; - } - - /** - * Creates new builder with correct indent. - * - * @return Builder. - */ - private SB builder() { - assert indent > 0; - - SB sb = new SB(); - - for (int i = 0; i < indent; i++) - sb.a(TAB); - - return sb; - } - - /** - * Gets all direct marshallable classes. - * First classes will be classes from {@code classesOrder} with same order - * as ordered values. Other classes will be at the end and ordered by name - * (with package prefix). - * That orders need for saving {@code directType} value. - * - * @return Classes. - * @throws Exception In case of error. - */ - private Collection> classes() throws Exception { - Collection> col = new TreeSet<>( - new Comparator>() { - @Override public int compare(Class c1, - Class c2) { - return c1.getName().compareTo(c2.getName()); - } - }); - - URLClassLoader ldr = (URLClassLoader)getClass().getClassLoader(); - - for (URL url : ldr.getURLs()) { - File file = new File(url.toURI()); - - int prefixLen = file.getPath().length() + 1; - - processFile(file, ldr, prefixLen, col); - } - - return col; - } - - /** - * Recursively process provided file or directory. - * - * @param file File. - * @param ldr Class loader. - * @param prefixLen Path prefix length. - * @param col Classes. - * @throws Exception In case of error. - */ - private void processFile(File file, ClassLoader ldr, int prefixLen, - Collection> col) throws Exception { - assert file != null; - assert ldr != null; - assert prefixLen > 0; - assert col != null; - - if (!file.exists()) - throw new FileNotFoundException("File doesn't exist: " + file); - - if (file.isDirectory()) { - for (File f : file.listFiles()) - processFile(f, ldr, prefixLen, col); - } - else { - assert file.isFile(); - - String path = file.getPath(); - - if (path.endsWith(".class")) { - String clsName = path.substring(prefixLen, path.length() - 6).replace(File.separatorChar, '.'); - - Class cls = Class.forName(clsName, false, ldr); - - if (cls.getDeclaringClass() == null && cls.getEnclosingClass() == null && - !BASE_CLS.equals(cls) && BASE_CLS.isAssignableFrom(cls)) - col.add((Class)cls); - } - } - } -} +// else if (line.contains("public boolean readFrom(ByteBuffer buf)")) { +// src.addAll(read); +// +// skip = true; +// +// readFound = true; +// } +//// else if (type >= 0 && line.contains("public byte directType()")) { +//// src.add(TAB + TAB + "return " + type + ';'); +//// +//// skip = true; +//// } +// else if (line.contains("public GridTcpCommunicationMessageAdapter clone()")) { +// src.addAll(clone); +// +// skip = true; +// +// cloneFound = true; +// } +// else if (line.contains("protected void clone0(GridTcpCommunicationMessageAdapter _msg)")) { +// src.addAll(clone0); +// +// skip = true; +// +// clone0Found = true; +// } +// } +// else if (line.startsWith(TAB + "}")) { +// src.add(line); +// +// skip = false; +// } +// } +// +// if (!writeFound) +// System.out.println(" writeTo method doesn't exist."); +// +// if (!readFound) +// System.out.println(" readFrom method doesn't exist."); +// +// if (!cloneFound) +// System.out.println(" clone method doesn't exist."); +// +// if (!clone0Found) +// System.out.println(" clone0 method doesn't exist."); +// } +// finally { +// if (rdr != null) +// rdr.close(); +// } +// +// BufferedWriter wr = null; +// +// try { +// wr = new BufferedWriter(new FileWriter(file)); +// +// for (String line : src) +// wr.write(line + '\n'); +// } +// finally { +// if (wr != null) +// wr.close(); +// } +// } +// +// /** +// * Generates code for provided class. +// * +// * @param cls Class. +// * @throws Exception In case of error. +// */ +// public void generate(Class cls) throws Exception { +// assert cls != null; +// +// write.clear(); +// read.clear(); +// clone.clear(); +// clone0.clear(); +// +// fields = new ArrayList<>(); +// +// Field[] declaredFields = cls.getDeclaredFields(); +// +// for (Field field : declaredFields) { +// int mod = field.getModifiers(); +// +// if (!isStatic(mod) && !isTransient(mod) && !field.isAnnotationPresent(GridDirectTransient.class)) +// fields.add(field); +// } +// +// Collections.sort(fields, FIELD_CMP); +// +// indent = 2; +// +// boolean hasSuper = cls.getSuperclass() != BASE_CLS; +// +// String clsName = cls.getSimpleName(); +// +// if (!Modifier.isAbstract(cls.getModifiers())) { +// clone.add(builder().a(clsName).a(" _clone = new ").a(clsName).a("();").toString()); +// clone.add(EMPTY); +// clone.add(builder().a("clone0(_clone);").toString()); +// clone.add(EMPTY); +// clone.add(builder().a("return _clone;").toString()); +// } +// +// if (hasSuper) { +// clone0.add(builder().a("super.clone0(_msg);").toString()); +// clone0.add(EMPTY); +// } +// +// Collection cloningFields = new ArrayList<>(declaredFields.length); +// +// for (Field field: declaredFields) +// if (!isStatic(field.getModifiers())) +// cloningFields.add(field); +// +// if (!cloningFields.isEmpty()) { +// clone0.add(builder().a(clsName).a(" _clone = (").a(clsName).a(")_msg;").toString()); +// clone0.add(EMPTY); +// +// for (Field field : cloningFields) { +// String name = field.getName(); +// Class type = field.getType(); +// +// String res = name; +// +// if (BASE_CLS.isAssignableFrom(type)) +// res = name + " != null ? (" + type.getSimpleName() + ")" + name + ".clone() : null"; +// +// clone0.add(builder().a("_clone.").a(name).a(" = ").a(res).a(";").toString()); +// } +// } +// +// start(write, hasSuper ? "writeTo" : null, true); +// start(read, hasSuper ? "readFrom" : null, false); +// +// indent++; +// +// int state = startState(cls); +// +// for (Field field : fields) +// processField(field, state++); +// +// indent--; +// +// finish(write); +// finish(read); +// } +// +// /** +// * @param cls Message class. +// * @return Start state. +// */ +// private int startState(Class cls) { +// assert cls != null; +// +// Class superCls = cls.getSuperclass(); +// +// Integer state = fieldCnt.get(superCls); +// +// if (state != null) +// return state; +// +// state = 0; +// +// while (cls.getSuperclass() != BASE_CLS) { +// cls = cls.getSuperclass(); +// +// for (Field field : cls.getDeclaredFields()) { +// int mod = field.getModifiers(); +// +// if (!isStatic(mod) && !isTransient(mod) && !field.isAnnotationPresent(GridDirectTransient.class)) +// state++; +// } +// } +// +// fieldCnt.put(superCls, state); +// +// return state; +// } +// +// /** +// * @param code Code lines. +// * @param superMtd Super class method name. +// * @param writeType Whether to write message type. +// */ +// private void start(Collection code, @Nullable String superMtd, boolean writeType) { +// assert code != null; +// +// code.add(builder().a(COMM_STATE_VAR).a(".setBuffer(").a(BUF_VAR).a(");").toString()); +// code.add(EMPTY); +// +// if (superMtd != null) { +// returnFalseIfFailed(code, "super." + superMtd, BUF_VAR); +// +// code.add(EMPTY); +// } +// +// if (writeType) { +// code.add(builder().a("if (!").a(TYPE_WRITTEN_VAR).a(") {").toString()); +// +// indent++; +// +// returnFalseIfFailed(code, COMM_STATE_VAR + ".putByte", "null", "directType()"); +// +// code.add(EMPTY); +// code.add(builder().a(TYPE_WRITTEN_VAR).a(" = true;").toString()); +// +// indent--; +// +// code.add(builder().a("}").toString()); +// code.add(EMPTY); +// } +// +// if (!fields.isEmpty()) +// code.add(builder().a("switch (").a(STATE_VAR).a(") {").toString()); +// } +// +// /** +// * @param code Code lines. +// */ +// private void finish(Collection code) { +// assert code != null; +// +// if (!fields.isEmpty()) { +// code.add(builder().a("}").toString()); +// code.add(EMPTY); +// } +// +// code.add(builder().a("return true;").toString()); +// } +// +// /** +// * @param field Field. +// * @param opt Case option. +// */ +// private void processField(Field field, int opt) { +// assert field != null; +// assert opt >= 0; +// +// GridDirectCollection colAnn = field.getAnnotation(GridDirectCollection.class); +// GridDirectMap mapAnn = field.getAnnotation(GridDirectMap.class); +// +// if (colAnn == null && Collection.class.isAssignableFrom(field.getType())) +// throw new IllegalStateException("@GridDirectCollection annotation is not provided for field: " + +// field.getName()); +// +// if (mapAnn == null && Map.class.isAssignableFrom(field.getType())) +// throw new IllegalStateException("@GridDirectMap annotation is not provided for field: " + field.getName()); +// +// writeField(field, opt, colAnn, mapAnn); +// readField(field, opt, colAnn, mapAnn); +// } +// +// /** +// * @param field Field. +// * @param opt Case option. +// * @param colAnn Collection annotation. +// * @param mapAnn Map annotation. +// */ +// private void writeField(Field field, int opt, @Nullable GridDirectCollection colAnn, +// @Nullable GridDirectMap mapAnn) { +// assert field != null; +// assert opt >= 0; +// +// write.add(builder().a("case ").a(opt).a(":").toString()); +// +// indent++; +// +// returnFalseIfWriteFailed(field.getType(), field.getName(), colAnn != null ? colAnn.value() : null, +// mapAnn != null ? mapAnn.keyType() : null, mapAnn != null ? mapAnn.valueType() : null, false); +// +// write.add(EMPTY); +// write.add(builder().a(STATE_VAR).a("++;").toString()); +// write.add(EMPTY); +// +// indent--; +// } +// +// /** +// * @param field Field. +// * @param opt Case option. +// * @param colAnn Collection annotation. +// * @param mapAnn Map annotation. +// */ +// private void readField(Field field, int opt, @Nullable GridDirectCollection colAnn, +// @Nullable GridDirectMap mapAnn) { +// assert field != null; +// assert opt >= 0; +// +// read.add(builder().a("case ").a(opt).a(":").toString()); +// +// indent++; +// +// returnFalseIfReadFailed(field.getType(), field.getName(), colAnn != null ? colAnn.value() : null, +// mapAnn != null ? mapAnn.keyType() : null, mapAnn != null ? mapAnn.valueType() : null, false); +// +// read.add(EMPTY); +// read.add(builder().a(STATE_VAR).a("++;").toString()); +// read.add(EMPTY); +// +// indent--; +// } +// +// /** +// * @param type Field type. +// * @param name Field name. +// * @param colItemType Collection item type. +// * @param mapKeyType Map key type. +// * @param mapValType Map key value. +// * @param raw Raw write flag. +// */ +// private void returnFalseIfWriteFailed(Class type, String name, @Nullable Class colItemType, +// @Nullable Class mapKeyType, @Nullable Class mapValType, boolean raw) { +// assert type != null; +// assert name != null; +// +// String field = raw ? "null" : '"' + name + '"'; +// +// if (type == byte.class) +// returnFalseIfFailed(write, COMM_STATE_VAR + ".putByte", field, name); +// else if (type == short.class) +// returnFalseIfFailed(write, COMM_STATE_VAR + ".putShort", field, name); +// else if (type == int.class) +// returnFalseIfFailed(write, COMM_STATE_VAR + ".putInt", field, name); +// else if (type == long.class) +// returnFalseIfFailed(write, COMM_STATE_VAR + ".putLong", field, name); +// else if (type == float.class) +// returnFalseIfFailed(write, COMM_STATE_VAR + ".putFloat", field, name); +// else if (type == double.class) +// returnFalseIfFailed(write, COMM_STATE_VAR + ".putDouble", field, name); +// else if (type == char.class) +// returnFalseIfFailed(write, COMM_STATE_VAR + ".putChar", field, name); +// else if (type == boolean.class) +// returnFalseIfFailed(write, COMM_STATE_VAR + ".putBoolean", field, name); +// else if (type == byte[].class) +// returnFalseIfFailed(write, COMM_STATE_VAR + ".putByteArray", field, name); +// else if (type == short[].class) +// returnFalseIfFailed(write, COMM_STATE_VAR + ".putShortArray", field, name); +// else if (type == int[].class) +// returnFalseIfFailed(write, COMM_STATE_VAR + ".putIntArray", field, name); +// else if (type == long[].class) +// returnFalseIfFailed(write, COMM_STATE_VAR + ".putLongArray", field, name); +// else if (type == float[].class) +// returnFalseIfFailed(write, COMM_STATE_VAR + ".putFloatArray", field, name); +// else if (type == double[].class) +// returnFalseIfFailed(write, COMM_STATE_VAR + ".putDoubleArray", field, name); +// else if (type == char[].class) +// returnFalseIfFailed(write, COMM_STATE_VAR + ".putCharArray", field, name); +// else if (type == boolean[].class) +// returnFalseIfFailed(write, COMM_STATE_VAR + ".putBooleanArray", field, name); +// else if (type == UUID.class) +// returnFalseIfFailed(write, COMM_STATE_VAR + ".putUuid", field, name); +// else if (type == ByteBuffer.class) +// returnFalseIfFailed(write, COMM_STATE_VAR + ".putByteBuffer", field, name); +// else if (type == IgniteUuid.class) +// returnFalseIfFailed(write, COMM_STATE_VAR + ".putGridUuid", field, name); +// else if (type == GridClockDeltaVersion.class) +// returnFalseIfFailed(write, COMM_STATE_VAR + ".putClockDeltaVersion", field, name); +// else if (type == GridByteArrayList.class) +// returnFalseIfFailed(write, COMM_STATE_VAR + ".putByteArrayList", field, name); +// else if (type == GridLongList.class) +// returnFalseIfFailed(write, COMM_STATE_VAR + ".putLongList", field, name); +// else if (type == GridCacheVersion.class) +// returnFalseIfFailed(write, COMM_STATE_VAR + ".putCacheVersion", field, name); +// else if (type == GridDhtPartitionExchangeId.class) +// returnFalseIfFailed(write, COMM_STATE_VAR + ".putDhtPartitionExchangeId", field, name); +// else if (type == GridCacheValueBytes.class) +// returnFalseIfFailed(write, COMM_STATE_VAR + ".putValueBytes", field, name); +// //else if (type == GridDrInternalRequestEntry.class) +// // returnFalseIfFailed(write, COMM_STATE_VAR + ".putDrInternalRequestEntry", field, name); +// else if (type == String.class) +// returnFalseIfFailed(write, COMM_STATE_VAR + ".putString", field, name); +// else if (type == BitSet.class) +// returnFalseIfFailed(write, COMM_STATE_VAR + ".putBitSet", field, name); +// else if (type.isEnum()) +// returnFalseIfFailed(write, COMM_STATE_VAR + ".putEnum", field, name); +// else if (BASE_CLS.isAssignableFrom(type)) +// returnFalseIfFailed(write, COMM_STATE_VAR + ".putMessage", field, name); +// else if (type.isArray() || Collection.class.isAssignableFrom(type)) { +// boolean isArr = type.isArray(); +// +// if (isArr) +// colItemType = type.getComponentType(); +// +// assert colItemType != null; +// +// write.add(builder().a("if (").a(name).a(" != null) {").toString()); +// +// indent++; +// +// write.add(builder().a("if (").a(IT_VAR).a(" == null) {").toString()); +// +// indent++; +// +// returnFalseIfFailed(write, COMM_STATE_VAR + ".putInt", "null", name + "." + (isArr ? "length" : "size()")); +// +// write.add(EMPTY); +// write.add(builder().a(IT_VAR).a(" = ").a(isArr ? "arrayIterator(" + name + ")" : name + ".iterator()"). +// a(";").toString()); +// +// indent--; +// +// write.add(builder().a("}").toString()); +// write.add(EMPTY); +// write.add(builder().a("while (").a(IT_VAR).a(".hasNext() || ").a(CUR_VAR).a(" != NULL").a(") {"). +// toString()); +// +// indent++; +// +// write.add(builder().a("if (").a(CUR_VAR).a(" == NULL)").toString()); +// +// indent++; +// +// write.add(builder().a(CUR_VAR).a(" = ").a(IT_VAR).a(".next();").toString()); +// +// indent--; +// +// write.add(EMPTY); +// +// returnFalseIfWriteFailed(colItemType, "(" + colItemType.getSimpleName() + ")" + CUR_VAR, +// null, null, null, true); +// +// write.add(EMPTY); +// write.add(builder().a(CUR_VAR).a(" = NULL;").toString()); +// +// indent--; +// +// write.add(builder().a("}").toString()); +// write.add(EMPTY); +// write.add(builder().a(IT_VAR).a(" = null;").toString()); +// +// indent--; +// +// write.add(builder().a("} else {").toString()); +// +// indent++; +// +// returnFalseIfFailed(write, COMM_STATE_VAR + ".putInt", "null", "-1"); +// +// indent--; +// +// write.add(builder().a("}").toString()); +// } +// else if (Map.class.isAssignableFrom(type)) { +// assert mapKeyType != null; +// assert mapValType != null; +// +// write.add(builder().a("if (").a(name).a(" != null) {").toString()); +// +// indent++; +// +// write.add(builder().a("if (").a(IT_VAR).a(" == null) {").toString()); +// +// indent++; +// +// returnFalseIfFailed(write, COMM_STATE_VAR + ".putInt", "null", name + ".size()"); +// +// write.add(EMPTY); +// write.add(builder().a(IT_VAR).a(" = ").a(name).a(".entrySet().iterator();").toString()); +// +// indent--; +// +// write.add(builder().a("}").toString()); +// write.add(EMPTY); +// write.add(builder().a("while (").a(IT_VAR).a(".hasNext() || ").a(CUR_VAR).a(" != NULL").a(") {"). +// toString()); +// +// indent++; +// +// write.add(builder().a("if (").a(CUR_VAR).a(" == NULL)").toString()); +// +// indent++; +// +// write.add(builder().a(CUR_VAR).a(" = ").a(IT_VAR).a(".next();").toString()); +// +// indent--; +// +// String entryType = "Map.Entry<" + U.box(mapKeyType).getSimpleName() + ", " + +// U.box(mapValType).getSimpleName() + ">"; +// +// write.add(EMPTY); +// write.add(builder().a(entryType).a(" e = (").a(entryType).a(")").a(CUR_VAR).a(";").toString()); +// write.add(EMPTY); +// write.add(builder().a("if (!").a(KEY_DONE_VAR).a(") {").toString()); +// +// indent++; +// +// returnFalseIfWriteFailed(mapKeyType, "e.getKey()", null, null, null, true); +// +// write.add(EMPTY); +// write.add(builder().a(KEY_DONE_VAR).a(" = true;").toString()); +// +// indent--; +// +// write.add(builder().a("}").toString()); +// write.add(EMPTY); +// +// returnFalseIfWriteFailed(mapValType, "e.getValue()", null, null, null, true); +// +// write.add(EMPTY); +// write.add(builder().a(KEY_DONE_VAR).a(" = false;").toString()); +// write.add(EMPTY); +// write.add(builder().a(CUR_VAR).a(" = NULL;").toString()); +// +// indent--; +// +// write.add(builder().a("}").toString()); +// write.add(EMPTY); +// write.add(builder().a(IT_VAR).a(" = null;").toString()); +// +// indent--; +// +// write.add(builder().a("} else {").toString()); +// +// indent++; +// +// returnFalseIfFailed(write, COMM_STATE_VAR + ".putInt", "null", "-1"); +// +// indent--; +// +// write.add(builder().a("}").toString()); +// } +// else +// throw new IllegalStateException("Unsupported type: " + type); +// } +// +// /** +// * @param type Field type. +// * @param name Field name. +// * @param colItemType Collection item type. +// * @param mapKeyType Map key type. +// * @param mapValType Map value type. +// * @param raw Raw read flag. +// */ +// private void returnFalseIfReadFailed(Class type, @Nullable String name, @Nullable Class colItemType, +// @Nullable Class mapKeyType, @Nullable Class mapValType, boolean raw) { +// assert type != null; +// +// String field = raw ? "null" : '"' + name + '"'; +// +// String retType = type.getSimpleName(); +// +// if (type == byte.class) +// returnFalseIfReadFailed("byte", name, null, COMM_STATE_VAR + ".getByte", field, false); +// else if (type == short.class) +// returnFalseIfReadFailed("short", name, null, COMM_STATE_VAR + ".getShort", field, false); +// else if (type == int.class) +// returnFalseIfReadFailed("int", name, null, COMM_STATE_VAR + ".getInt", field, false); +// else if (type == long.class) +// returnFalseIfReadFailed("long", name, null, COMM_STATE_VAR + ".getLong", field, false); +// else if (type == float.class) +// returnFalseIfReadFailed("float", name, null, COMM_STATE_VAR + ".getFloat", field, false); +// else if (type == double.class) +// returnFalseIfReadFailed("double", name, null, COMM_STATE_VAR + ".getDouble", field, false); +// else if (type == char.class) +// returnFalseIfReadFailed("char", name, null, COMM_STATE_VAR + ".getChar", field, false); +// else if (type == boolean.class) +// returnFalseIfReadFailed("boolean", name, null, COMM_STATE_VAR + ".getBoolean", field, false); +// else if (type == byte[].class) +// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getByteArray", field, false); +// else if (type == short[].class) +// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getShortArray", field, false); +// else if (type == int[].class) +// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getIntArray", field, false); +// else if (type == long[].class) +// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getLongArray", field, false); +// else if (type == float[].class) +// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getFloatArray", field, false); +// else if (type == double[].class) +// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getDoubleArray", field, false); +// else if (type == char[].class) +// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getCharArray", field, false); +// else if (type == boolean[].class) +// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getBooleanArray", field, false); +// else if (type == UUID.class) +// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getUuid", field, false); +// else if (type == ByteBuffer.class) +// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getByteBuffer", field, false); +// else if (type == IgniteUuid.class) +// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getGridUuid", field, false); +// else if (type == GridClockDeltaVersion.class) +// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getClockDeltaVersion", field, false); +// else if (type == GridLongList.class) +// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getLongList", field, false); +// else if (type == GridByteArrayList.class) +// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getByteArrayList", field, false); +// else if (type == GridCacheVersion.class) +// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getCacheVersion", field, false); +// else if (type == GridDhtPartitionExchangeId.class) +// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getDhtPartitionExchangeId", field, false); +// else if (type == GridCacheValueBytes.class) +// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getValueBytes", field, false); +// //else if (type == GridDrInternalRequestEntry.class) +// // returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getDrInternalRequestEntry", field, false); +// else if (type == String.class) +// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getString", field, false); +// else if (type == BitSet.class) +// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getBitSet", field, false); +// else if (type.isEnum()) { +// assert name != null; +// +// returnFalseIfReadFailed("byte", null, name + "0", COMM_STATE_VAR + ".getByte", field, false); +// +// read.add(EMPTY); +// read.add(builder().a(name).a(" = ").a(type.getSimpleName()).a(".fromOrdinal(").a(name).a("0);").toString()); +// } +// else if (BASE_CLS.isAssignableFrom(type)) +// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getMessage", field, true); +// else if (type.isArray() || Collection.class.isAssignableFrom(type)) { +// assert name != null; +// +// boolean isArr = type.isArray(); +// +// if (isArr) +// colItemType = type.getComponentType(); +// +// assert colItemType != null; +// +// Class colType = Set.class.isAssignableFrom(type) ? HashSet.class : ArrayList.class; +// +// read.add(builder().a("if (").a(READ_SIZE_VAR).a(" == -1) {").toString()); +// +// indent++; +// +// returnFalseIfReadFailed(int.class, READ_SIZE_VAR, null, null, null, true); +// +// indent--; +// +// read.add(builder().a("}").toString()); +// read.add(EMPTY); +// read.add(builder().a("if (").a(READ_SIZE_VAR).a(" >= 0) {").toString()); +// +// indent++; +// +// read.add(builder().a("if (").a(name).a(" == null)").toString()); +// +// indent++; +// +// if (isArr) { +// String val = colItemType.isArray() ? +// colItemType.getComponentType().getSimpleName() + "[" + READ_SIZE_VAR + "][]" : +// colItemType.getSimpleName() + "[" + READ_SIZE_VAR + "]"; +// +// read.add(builder().a(name).a(" = new ").a(val).a(";"). +// toString()); +// } +// else { +// read.add(builder().a(name).a(" = new ").a(colType.getSimpleName()).a("<>(").a(READ_SIZE_VAR).a(");"). +// toString()); +// } +// +// indent--; +// +// read.add(EMPTY); +// read.add(builder().a("for (int i = ").a(READ_ITEMS_VAR).a("; i < ").a(READ_SIZE_VAR).a("; i++) {"). +// toString()); +// +// indent++; +// +// String var = colItemType.isPrimitive() ? colItemType.getSimpleName() + " " + DFLT_LOC_VAR : null; +// +// returnFalseIfReadFailed(colItemType, var, null, null, null, true); +// +// read.add(EMPTY); +// read.add(builder().a(name).a(isArr ? "[i] = " : ".add(").a("(").a(U.box(colItemType).getSimpleName()). +// a(")").a(DFLT_LOC_VAR).a(isArr ? ";" : ");").toString()); +// read.add(EMPTY); +// read.add(builder().a(READ_ITEMS_VAR).a("++;").toString()); +// +// indent--; +// +// read.add(builder().a("}").toString()); +// +// indent--; +// +// read.add(builder().a("}").toString()); +// read.add(EMPTY); +// read.add(builder().a(READ_SIZE_VAR).a(" = -1;").toString()); +// read.add(builder().a(READ_ITEMS_VAR).a(" = 0;").toString()); +// } +// else if (Map.class.isAssignableFrom(type)) { +// assert name != null; +// assert mapKeyType != null; +// assert mapValType != null; +// +// Class mapType = LinkedHashMap.class.isAssignableFrom(type) ? LinkedHashMap.class : HashMap.class; +// +// read.add(builder().a("if (").a(READ_SIZE_VAR).a(" == -1) {").toString()); +// +// indent++; +// +// returnFalseIfReadFailed(int.class, READ_SIZE_VAR, null, null, null, true); +// +// indent--; +// +// read.add(builder().a("}").toString()); +// read.add(EMPTY); +// read.add(builder().a("if (").a(READ_SIZE_VAR).a(" >= 0) {").toString()); +// +// indent++; +// +// read.add(builder().a("if (").a(name).a(" == null)").toString()); +// +// indent++; +// +// read.add(builder().a(name).a(" = new ").a(mapType.getSimpleName()).a("<>(").a(READ_SIZE_VAR).a(", 1.0f);"). +// toString()); +// +// indent--; +// +// read.add(EMPTY); +// read.add(builder().a("for (int i = ").a(READ_ITEMS_VAR).a("; i < ").a(READ_SIZE_VAR).a("; i++) {"). +// toString()); +// +// indent++; +// +// read.add(builder().a("if (!").a(KEY_DONE_VAR).a(") {").toString()); +// +// indent++; +// +// String var = mapKeyType.isPrimitive() ? mapKeyType.getSimpleName() + " " + DFLT_LOC_VAR : null; +// +// returnFalseIfReadFailed(mapKeyType, var, null, null, null, true); +// +// read.add(EMPTY); +// read.add(builder().a(CUR_VAR).a(" = ").a(DFLT_LOC_VAR).a(";").toString()); +// read.add(builder().a(KEY_DONE_VAR).a(" = true;").toString()); +// +// indent--; +// +// read.add(builder().a("}").toString()); +// read.add(EMPTY); +// +// var = mapValType.isPrimitive() ? mapValType.getSimpleName() + " " + DFLT_LOC_VAR : null; +// +// returnFalseIfReadFailed(mapValType, var, null, null, null, true); +// +// read.add(EMPTY); +// read.add(builder().a(name).a(".put((").a(U.box(mapKeyType).getSimpleName()).a(")").a(CUR_VAR). +// a(", ").a(DFLT_LOC_VAR).a(");").toString()); +// read.add(EMPTY); +// read.add(builder().a(KEY_DONE_VAR).a(" = false;").toString()); +// read.add(EMPTY); +// read.add(builder().a(READ_ITEMS_VAR).a("++;").toString()); +// +// indent--; +// +// read.add(builder().a("}").toString()); +// +// indent--; +// +// read.add(builder().a("}").toString()); +// read.add(EMPTY); +// read.add(builder().a(READ_SIZE_VAR).a(" = -1;").toString()); +// read.add(builder().a(READ_ITEMS_VAR).a(" = 0;").toString()); +// read.add(builder().a(CUR_VAR).a(" = null;").toString()); +// } +// else +// throw new IllegalStateException("Unsupported type: " + type); +// } +// +// /** +// * @param retType Return type. +// * @param var Variable name. +// * @param locVar Local variable name. +// * @param mtd Method name. +// * @param arg Method argument. +// * @param cast Whether cast is needed. +// */ +// private void returnFalseIfReadFailed(String retType, @Nullable String var, @Nullable String locVar, String mtd, +// @Nullable String arg, boolean cast) { +// assert retType != null; +// assert mtd != null; +// +// if (var == null) +// var = retType + " " + (locVar != null ? locVar : DFLT_LOC_VAR); +// +// read.add(builder().a(var).a(" = ").a(cast ? "(" + retType + ")" : "").a(mtd). +// a(arg != null ? "(" + arg + ");" : "();").toString()); +// read.add(EMPTY); +// +// read.add(builder().a("if (!").a(COMM_STATE_VAR).a(".lastRead())").toString()); +// +// indent++; +// +// read.add(builder().a("return false;").toString()); +// +// indent--; +// } +// +// /** +// * @param code Code lines. +// * @param accessor Field or method name. +// * @param args Method arguments. +// */ +// private void returnFalseIfFailed(Collection code, String accessor, @Nullable String... args) { +// assert code != null; +// assert accessor != null; +// +// String argsStr = ""; +// +// if (args != null && args.length > 0) { +// for (String arg : args) +// argsStr += arg + ", "; +// +// argsStr = argsStr.substring(0, argsStr.length() - 2); +// } +// +// code.add(builder().a("if (!").a(accessor).a("(" + argsStr + ")").a(")").toString()); +// +// indent++; +// +// code.add(builder().a("return false;").toString()); +// +// indent--; +// } +// +// /** +// * Creates new builder with correct indent. +// * +// * @return Builder. +// */ +// private SB builder() { +// assert indent > 0; +// +// SB sb = new SB(); +// +// for (int i = 0; i < indent; i++) +// sb.a(TAB); +// +// return sb; +// } +// +// /** +// * Gets all direct marshallable classes. +// * First classes will be classes from {@code classesOrder} with same order +// * as ordered values. Other classes will be at the end and ordered by name +// * (with package prefix). +// * That orders need for saving {@code directType} value. +// * +// * @return Classes. +// * @throws Exception In case of error. +// */ +// private Collection> classes() throws Exception { +// Collection> col = new TreeSet<>( +// new Comparator>() { +// @Override public int compare(Class c1, +// Class c2) { +// return c1.getName().compareTo(c2.getName()); +// } +// }); +// +// URLClassLoader ldr = (URLClassLoader)getClass().getClassLoader(); +// +// for (URL url : ldr.getURLs()) { +// File file = new File(url.toURI()); +// +// int prefixLen = file.getPath().length() + 1; +// +// processFile(file, ldr, prefixLen, col); +// } +// +// return col; +// } +// +// /** +// * Recursively process provided file or directory. +// * +// * @param file File. +// * @param ldr Class loader. +// * @param prefixLen Path prefix length. +// * @param col Classes. +// * @throws Exception In case of error. +// */ +// private void processFile(File file, ClassLoader ldr, int prefixLen, +// Collection> col) throws Exception { +// assert file != null; +// assert ldr != null; +// assert prefixLen > 0; +// assert col != null; +// +// if (!file.exists()) +// throw new FileNotFoundException("File doesn't exist: " + file); +// +// if (file.isDirectory()) { +// for (File f : file.listFiles()) +// processFile(f, ldr, prefixLen, col); +// } +// else { +// assert file.isFile(); +// +// String path = file.getPath(); +// +// if (path.endsWith(".class")) { +// String clsName = path.substring(prefixLen, path.length() - 6).replace(File.separatorChar, '.'); +// +// Class cls = Class.forName(clsName, false, ldr); +// +// if (cls.getDeclaringClass() == null && cls.getEnclosingClass() == null && +// !BASE_CLS.equals(cls) && BASE_CLS.isAssignableFrom(cls)) +// col.add((Class)cls); +// } +// } +// } +//} From dbea639e224e98a0ce57c57d5b9d6fb2fe31e9b4 Mon Sep 17 00:00:00 2001 From: sboikov Date: Thu, 5 Feb 2015 11:52:48 +0300 Subject: [PATCH 21/95] # ignite-57 --- .../org/apache/ignite/cache/CacheProjection.java | 7 +++++++ .../internal/processors/cache/GridCacheAdapter.java | 13 +++++++++++++ .../internal/processors/cache/IgniteCacheProxy.java | 6 ++++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheProjection.java b/modules/core/src/main/java/org/apache/ignite/cache/CacheProjection.java index 2cf10aa7ffd6a..ee469f9961e37 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/CacheProjection.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheProjection.java @@ -1853,6 +1853,13 @@ public void unlockAll(@Nullable Collection keys, */ public int size(); + /** + * @param peekModes Peek modes. + * @return Local cache size. + * @throws IgniteCheckedException If failed. + */ + public int localSize(CachePeekMode... peekModes) throws IgniteCheckedException; + /** * Gets the number of all entries cached across all nodes. *

diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java index 393a3fcc9ff00..8933690f9b16a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java @@ -3867,6 +3867,19 @@ IgniteInternalFuture globalLoadCacheAsync(@Nullable IgniteBiPredicate p return e == null || e.obsolete() ? null : e.wrap(true); } + /** {@inheritDoc} */ + @Override public int localSize(CachePeekMode... peekModes) throws IgniteCheckedException { + boolean primary; + boolean backup; + boolean near; + + boolean heap; + boolean offheap; + boolean swap; + + return 0; + } + /** {@inheritDoc} */ @Override public int size() { return map.publicSize(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java index 43d231ec46ad3..87a4f2d1812c7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java @@ -323,11 +323,13 @@ public GridCacheContext context() { /** {@inheritDoc} */ @Override public int localSize(CachePeekMode... peekModes) { - // TODO IGNITE-1. GridCacheProjectionImpl prev = gate.enter(prj); try { - return delegate.size(); + return delegate.localSize(peekModes); + } + catch (IgniteCheckedException e) { + throw cacheException(e); } finally { gate.leave(prev); From 20f93d6c82e0d57035271f880a1fe3c465e37e46 Mon Sep 17 00:00:00 2001 From: sboikov Date: Thu, 5 Feb 2015 17:59:04 +0300 Subject: [PATCH 22/95] # ignite-57 --- .../apache/ignite/cache/CacheProjection.java | 15 +- .../swapspace/GridSwapSpaceManager.java | 17 ++ .../processors/cache/GridCacheAdapter.java | 237 ++++++++++++++- .../cache/GridCacheProjectionImpl.java | 15 + .../processors/cache/GridCacheProxyImpl.java | 36 +++ .../cache/GridCacheSwapManager.java | 46 +++ .../processors/cache/IgniteCacheProxy.java | 12 +- .../offheap/GridOffHeapProcessor.java | 15 + .../offheap/GridOffHeapPartitionedMap.java | 11 + .../unsafe/GridUnsafePartitionedMap.java | 10 + .../ignite/spi/swapspace/SwapSpaceSpi.java | 11 + .../spi/swapspace/file/FileSwapSpaceSpi.java | 27 ++ .../spi/swapspace/noop/NoopSwapSpaceSpi.java | 5 + .../cache/IgniteCacheAtomicLocalSizeTest.java | 43 +++ .../IgniteCacheAtomicReplicatedSizeTest.java | 32 ++ .../cache/IgniteCacheAtomicSizeTest.java | 49 ++++ .../cache/IgniteCachePeekAbstractTest.java | 6 +- .../cache/IgniteCacheSizeAbstractTest.java | 274 ++++++++++++++++++ .../cache/IgniteCacheTxLocalSizeTest.java | 43 +++ .../IgniteCacheTxReplicatedSizeTest.java | 32 ++ .../cache/IgniteCacheTxSizeTest.java | 49 ++++ .../inmemory/GridTestSwapSpaceSpi.java | 41 +++ .../testsuites/IgniteCacheTestSuite.java | 7 + 23 files changed, 1015 insertions(+), 18 deletions(-) create mode 100644 modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicLocalSizeTest.java create mode 100644 modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicReplicatedSizeTest.java create mode 100644 modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicSizeTest.java create mode 100644 modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSizeAbstractTest.java create mode 100644 modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalSizeTest.java create mode 100644 modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxReplicatedSizeTest.java create mode 100644 modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxSizeTest.java diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheProjection.java b/modules/core/src/main/java/org/apache/ignite/cache/CacheProjection.java index 1c30f7bf8898f..90498076a3a3f 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/CacheProjection.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheProjection.java @@ -1865,7 +1865,20 @@ public void unlockAll(@Nullable Collection keys, * @return Local cache size. * @throws IgniteCheckedException If failed. */ - public int localSize(CachePeekMode... peekModes) throws IgniteCheckedException; + public int localSize(CachePeekMode[] peekModes) throws IgniteCheckedException; + + /** + * @param peekModes Peek modes. + * @return Global cache size. + * @throws IgniteCheckedException If failed. + */ + public int size(CachePeekMode[] peekModes) throws IgniteCheckedException; + + /** + * @param peekModes Peek modes. + * @return Future. + */ + public IgniteInternalFuture sizeAsync(CachePeekMode[] peekModes); /** * Gets the number of all entries cached across all nodes. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManager.java index e97cbc18771f3..84e358857d622 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/swapspace/GridSwapSpaceManager.java @@ -321,6 +321,23 @@ public long swapKeys(@Nullable String spaceName) throws IgniteCheckedException { } } + /** + * Gets number of swap entries for given partitions. + * + * @param spaceName Space name. + * @param parts Partitions. + * @return Number of swap entries for given partitions. + * @throws IgniteCheckedException If failed. + */ + public long swapKeys(@Nullable String spaceName, Set parts) throws IgniteCheckedException { + try { + return getSpi().count(spaceName, parts); + } + catch (IgniteSpiException e) { + throw new IgniteCheckedException("Failed to get swap keys count for space: " + spaceName, e); + } + } + /** * @param spaceName Space name. * @throws IgniteCheckedException If failed. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java index 581a6e63f25fe..abd53608c1fc4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java @@ -4079,16 +4079,163 @@ IgniteInternalFuture globalLoadCacheAsync(@Nullable IgniteBiPredicate p } /** {@inheritDoc} */ - @Override public int localSize(CachePeekMode... peekModes) throws IgniteCheckedException { - boolean primary; - boolean backup; - boolean near; + @Override public int size(CachePeekMode[] peekModes) throws IgniteCheckedException { + if (isLocal()) + return localSize(peekModes); - boolean heap; - boolean offheap; - boolean swap; + return sizeAsync(peekModes).get(); + } - return 0; + /** {@inheritDoc} */ + @Override public IgniteInternalFuture sizeAsync(CachePeekMode[] peekModes) { + assert peekModes != null; + + Collection nodes = ctx.grid().forDataNodes(name()).nodes(); + + if (nodes.isEmpty()) + return new GridFinishedFuture<>(ctx.kernalContext(), 0); + + IgniteInternalFuture> fut = + ctx.closures().broadcastNoFailover(new SizeCallable(ctx.name(), peekModes), null, nodes); + + return fut.chain(new CX1>, Integer>() { + @Override public Integer applyx(IgniteInternalFuture> fut) throws IgniteCheckedException { + Collection res = fut.get(); + + int totalSize = 0; + + for (Integer size : res) + totalSize += size; + + return totalSize; + } + }); + } + + /** {@inheritDoc} */ + @SuppressWarnings("ForLoopReplaceableByForEach") + @Override public int localSize(CachePeekMode[] peekModes) throws IgniteCheckedException { + assert peekModes != null; + + boolean near = false; + boolean primary = false; + boolean backup = false; + + boolean heap = false; + boolean offheap = false; + boolean swap = false; + + if (peekModes.length == 0) { + near = true; + primary = true; + backup = true; + + heap = true; + offheap = true; + swap = true; + } + else { + for (int i = 0; i < peekModes.length; i++) { + CachePeekMode peekMode = peekModes[i]; + + A.notNull(peekMode, "peekMode"); + + switch (peekMode) { + case ALL: + near = true; + primary = true; + backup = true; + + heap = true; + offheap = true; + swap = true; + + break; + + case BACKUP: + backup = true; + + break; + + case PRIMARY: + primary = true; + + break; + + case NEAR: + near = true; + + break; + + case ONHEAP: + heap = true; + + break; + + case OFFHEAP: + offheap = true; + + break; + + case SWAP: + swap = true; + + break; + + default: + assert false : peekMode; + } + } + } + + if (!(heap || offheap || swap)) { + heap = true; + offheap = true; + swap = true; + } + + if (!(primary || backup || near)) { + primary = true; + backup = true; + near = true; + } + + assert heap || offheap || swap; + assert primary || backup || near; + + int size = 0; + + if (heap) { + if (near) + size += nearSize(); + + GridCacheAdapter cache = ctx.isNear() ? ctx.near().dht() : ctx.cache(); + + if (!(primary && backup)) { + if (primary) + size += cache.primarySize(); + + if (backup) + size += (cache.size() - cache.primarySize()); + } + else + size += cache.size(); + } + + // Swap and offheap are disabled for near cache. + if (primary || backup) { + long topVer = ctx.affinity().affinityTopologyVersion(); + + GridCacheSwapManager swapMgr = ctx.isNear() ? ctx.near().dht().context().swap() : ctx.swap(); + + if (swap) + size += swapMgr.swapEntriesCount(primary, backup, topVer); + + if (offheap) + size += swapMgr.offheapEntriesCount(primary, backup, topVer); + } + + return size; } /** {@inheritDoc} */ @@ -5460,7 +5607,79 @@ private GlobalClearAllCallable(String cacheName) { } /** - * Internal callable which performs {@link org.apache.ignite.cache.CacheProjection#size()} or {@link org.apache.ignite.cache.CacheProjection#primarySize()} + * Internal callable for global size calculation. + */ + @GridInternal + private static class SizeCallable extends IgniteClosureX implements Externalizable { + /** */ + private static final long serialVersionUID = 0L; + + /** Cache name. */ + private String cacheName; + + /** Peek modes. */ + private CachePeekMode[] peekModes; + + /** Injected grid instance. */ + @IgniteInstanceResource + private Ignite ignite; + + /** + * Required by {@link Externalizable}. + */ + public SizeCallable() { + // No-op. + } + + /** + * @param cacheName Cache name. + * @param peekModes Cache peek modes. + */ + private SizeCallable(String cacheName, CachePeekMode[] peekModes) { + this.cacheName = cacheName; + this.peekModes = peekModes; + } + + /** {@inheritDoc} */ + @Override public Integer applyx(Object o) throws IgniteCheckedException { + GridCache cache = ((IgniteEx)ignite).cachex(cacheName); + + assert cache != null : cacheName; + + return cache.localSize(peekModes); + } + + /** {@inheritDoc} */ + @SuppressWarnings("ForLoopReplaceableByForEach") + @Override public void writeExternal(ObjectOutput out) throws IOException { + U.writeString(out, cacheName); + + out.writeInt(peekModes.length); + + for (int i = 0; i < peekModes.length; i++) + U.writeEnum(out, peekModes[i]); + } + + /** {@inheritDoc} */ + @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + cacheName = U.readString(in); + + int len = in.readInt(); + + peekModes = new CachePeekMode[len]; + + for (int i = 0; i < len; i++) + peekModes[i] = CachePeekMode.fromOrdinal(in.readByte()); + } + + /** {@inheritDoc} */ + public String toString() { + return S.toString(SizeCallable.class, this); + } + } + + /** + * Internal callable which performs {@link CacheProjection#size()} or {@link CacheProjection#primarySize()} * operation on a cache with the given name. */ @GridInternal diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java index 241c3c760570b..5ed1b7d36f9ec 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java @@ -584,6 +584,21 @@ private IgnitePredicate> visitor(final IgnitePredicate sizeAsync(CachePeekMode[] peekModes) { + return cache.sizeAsync(peekModes); + } + /** {@inheritDoc} */ @Override public int globalSize() throws IgniteCheckedException { return cache.globalSize(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java index 6fba463bd79fd..81617d4919306 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java @@ -1713,6 +1713,42 @@ public GridCacheProjectionImpl gateProjection() { } } + /** {@inheritDoc} */ + @Override public int size(CachePeekMode[] peekModes) throws IgniteCheckedException { + GridCacheProjectionImpl prev = gate.enter(prj); + + try { + return delegate.size(peekModes); + } + finally { + gate.leave(prev); + } + } + + /** {@inheritDoc} */ + @Override public IgniteInternalFuture sizeAsync(CachePeekMode[] peekModes) { + GridCacheProjectionImpl prev = gate.enter(prj); + + try { + return delegate.sizeAsync(peekModes); + } + finally { + gate.leave(prev); + } + } + + /** {@inheritDoc} */ + @Override public int localSize(CachePeekMode[] peekModes) throws IgniteCheckedException { + GridCacheProjectionImpl prev = gate.enter(prj); + + try { + return delegate.localSize(peekModes); + } + finally { + gate.leave(prev); + } + } + /** {@inheritDoc} */ @Override public int globalSize() throws IgniteCheckedException { GridCacheProjectionImpl prev = gate.enter(prj); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java index a0b1ecbcbc12c..419fdf556e77e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java @@ -170,6 +170,52 @@ public long swapSize() throws IgniteCheckedException { return enabled ? swapMgr.swapSize(spaceName) : -1; } + /** + * @param primary If {@code true} includes primary entries. + * @param backup If {@code true} includes backup entries. + * @param topVer Topology version. + * @return Number of swap entries. + * @throws IgniteCheckedException If failed. + */ + public int swapEntriesCount(boolean primary, boolean backup, long topVer) throws IgniteCheckedException { + assert primary || backup; + + if (!swapEnabled) + return 0; + + if (!(primary && backup)) { + Set parts = primary ? cctx.affinity().primaryPartitions(cctx.localNodeId(), topVer) : + cctx.affinity().backupPartitions(cctx.localNodeId(), topVer); + + return (int)swapMgr.swapKeys(spaceName, parts); + } + else + return (int)swapMgr.swapKeys(spaceName); + } + + /** + * @param primary If {@code true} includes primary entries. + * @param backup If {@code true} includes backup entries. + * @param topVer Topology version. + * @return Number of offheap entries. + * @throws IgniteCheckedException If failed. + */ + public int offheapEntriesCount(boolean primary, boolean backup, long topVer) throws IgniteCheckedException { + assert primary || backup; + + if (!offheapEnabled) + return 0; + + if (!(primary && backup)) { + Set parts = primary ? cctx.affinity().primaryPartitions(cctx.localNodeId(), topVer) : + cctx.affinity().backupPartitions(cctx.localNodeId(), topVer); + + return (int)offheap.entriesCount(spaceName, parts); + } + else + return (int)offheap.entriesCount(spaceName); + } + /** * Gets number of swap entries (keys). * diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java index 093f17b3a4269..e022a9446d73c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java @@ -303,14 +303,16 @@ public GridCacheContext context() { /** {@inheritDoc} */ @Override public int size(CachePeekMode... peekModes) throws CacheException { - // TODO IGNITE-1. - if (peekModes.length != 0) - throw new UnsupportedOperationException(); - GridCacheProjectionImpl prev = gate.enter(prj); try { - return ctx.cache().globalSize(); + if (isAsync()) { + setFuture(delegate.sizeAsync(peekModes)); + + return 0; + } + else + return delegate.size(peekModes); } catch (IgniteCheckedException e) { throw cacheException(e); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/offheap/GridOffHeapProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/offheap/GridOffHeapProcessor.java index 5e0e559b53913..123817126bec0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/offheap/GridOffHeapProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/offheap/GridOffHeapProcessor.java @@ -30,6 +30,8 @@ import org.jdk8.backport.*; import org.jetbrains.annotations.*; +import java.util.*; + /** * Manages offheap memory caches. */ @@ -299,6 +301,19 @@ public long entriesCount(@Nullable String spaceName) { return m == null ? -1 : m.size(); } + /** + * Gets number of elements in the given space. + * + * @param spaceName Space name. Optional. + * @param parts Partitions. + * @return Number of elements or {@code -1} if no space with the given name has been found. + */ + public long entriesCount(@Nullable String spaceName, Set parts) { + GridOffHeapPartitionedMap m = offheap(spaceName); + + return m == null ? -1 : m.size(parts); + } + /** * Gets size of a memory allocated for the entries of the given space. * diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/GridOffHeapPartitionedMap.java b/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/GridOffHeapPartitionedMap.java index 06a83a7d6f977..49850abc1e2da 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/GridOffHeapPartitionedMap.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/GridOffHeapPartitionedMap.java @@ -22,6 +22,8 @@ import org.apache.ignite.lang.*; import org.jetbrains.annotations.*; +import java.util.*; + /** * Off-heap map. */ @@ -141,6 +143,15 @@ public interface GridOffHeapPartitionedMap { */ public long size(); + + /** + * Gets number of elements in the map. + * + * @param parts Partitions. + * @return Number of elements in the map. + */ + public long size(Set parts); + /** * Gets total available memory size. * diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafePartitionedMap.java b/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafePartitionedMap.java index 343c08bd317ff..4d4ba61a6015a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafePartitionedMap.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafePartitionedMap.java @@ -208,6 +208,16 @@ private GridOffHeapMap mapFor(int p) { return totalCnt.sum(); } + /** {@inheritDoc} */ + @Override public long size(Set parts) { + int cnt = 0; + + for (Integer part : parts) + cnt += mapFor(part).size(); + + return cnt; + } + /** {@inheritDoc} */ @Override public long memorySize() { return mem.totalSize(); diff --git a/modules/core/src/main/java/org/apache/ignite/spi/swapspace/SwapSpaceSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/swapspace/SwapSpaceSpi.java index 0277407d68170..7ff51cf17473f 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/swapspace/SwapSpaceSpi.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/swapspace/SwapSpaceSpi.java @@ -81,6 +81,17 @@ public interface SwapSpaceSpi extends IgniteSpi { */ public long count(@Nullable String spaceName) throws IgniteSpiException; + /** + * Gets number of stored entries (keys) in data space with given name. If specified + * space does not exist this method returns {@code 0}. + * + * @param spaceName Space name to get number of entries for. + * @param parts Partitions. + * @return Number of stored entries in specified space. + * @throws org.apache.ignite.spi.IgniteSpiException In case of any errors. + */ + public long count(@Nullable String spaceName, Set parts) throws IgniteSpiException; + /** * Reads stored value as array of bytes by key from data space with given name. * If specified space does not exist this method returns {@code null}. diff --git a/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java index fd7048d1fc744..cab688a5b87ca 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java @@ -324,6 +324,16 @@ public void setReadStripesNumber(int readStripesNum) { return space.count(); } + /** {@inheritDoc} */ + @Override public long count(@Nullable String spaceName, Set parts) throws IgniteSpiException { + Space space = space(spaceName, false); + + if (space == null) + return 0; + + return space.count(parts); + } + /** {@inheritDoc} */ @Nullable @Override public byte[] read(@Nullable String spaceName, SwapKey key, SwapContext ctx) throws IgniteSpiException { @@ -1528,6 +1538,23 @@ public long count() { return cnt.get(); } + /** + * @param parts Partitions. + * @return Total count of keys for given partitions. + */ + public long count(Set parts) { + long cnt = 0; + + for (Integer part : parts) { + ConcurrentMap map = partition(part, false); + + if (map != null) + cnt += map.size(); + } + + return cnt; + } + /** * Clears space. * diff --git a/modules/core/src/main/java/org/apache/ignite/spi/swapspace/noop/NoopSwapSpaceSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/swapspace/noop/NoopSwapSpaceSpi.java index 008e2c1e899c3..9c7fd947dfb41 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/swapspace/noop/NoopSwapSpaceSpi.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/swapspace/noop/NoopSwapSpaceSpi.java @@ -63,6 +63,11 @@ public class NoopSwapSpaceSpi extends IgniteSpiAdapter implements SwapSpaceSpi { return 0; } + /** {@inheritDoc} */ + @Override public long count(@Nullable String spaceName, Set parts) throws IgniteSpiException { + return 0; + } + /** {@inheritDoc} */ @Override @Nullable public byte[] read(@Nullable String spaceName, SwapKey key, SwapContext ctx) throws IgniteSpiException { diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicLocalSizeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicLocalSizeTest.java new file mode 100644 index 0000000000000..aaf5a5a768b10 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicLocalSizeTest.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache; + +import org.apache.ignite.cache.*; + +import static org.apache.ignite.cache.CacheAtomicityMode.*; +import static org.apache.ignite.cache.CacheMode.*; + +/** + * + */ +public class IgniteCacheAtomicLocalSizeTest extends IgniteCacheSizeAbstractTest { + /** {@inheritDoc} */ + @Override protected CacheAtomicityMode atomicityMode() { + return ATOMIC; + } + + /** {@inheritDoc} */ + @Override protected int gridCount() { + return 1; + } + + /** {@inheritDoc} */ + @Override protected CacheMode cacheMode() { + return LOCAL; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicReplicatedSizeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicReplicatedSizeTest.java new file mode 100644 index 0000000000000..f4b466a560afc --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicReplicatedSizeTest.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache; + +import org.apache.ignite.cache.*; + +import static org.apache.ignite.cache.CacheMode.*; + +/** + * + */ +public class IgniteCacheAtomicReplicatedSizeTest extends IgniteCacheAtomicSizeTest { + /** {@inheritDoc} */ + @Override protected CacheMode cacheMode() { + return REPLICATED; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicSizeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicSizeTest.java new file mode 100644 index 0000000000000..62b52ff81ba7d --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicSizeTest.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache; + +import org.apache.ignite.cache.*; + +import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.*; +import static org.apache.ignite.cache.CacheAtomicityMode.*; +import static org.apache.ignite.cache.CacheMode.*; + +/** + * + */ +public class IgniteCacheAtomicSizeTest extends IgniteCacheSizeAbstractTest { + /** {@inheritDoc} */ + @Override protected CacheAtomicityMode atomicityMode() { + return ATOMIC; + } + + /** {@inheritDoc} */ + @Override protected int gridCount() { + return 4; + } + + /** {@inheritDoc} */ + @Override protected CacheMode cacheMode() { + return PARTITIONED; + } + + /** {@inheritDoc} */ + @Override protected CacheAtomicWriteOrderMode atomicWriteOrderMode() { + return PRIMARY; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekAbstractTest.java index 006cb8b572dcd..80fec09f25573 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekAbstractTest.java @@ -24,7 +24,7 @@ import org.apache.ignite.configuration.*; import org.apache.ignite.internal.*; import org.apache.ignite.spi.*; -import org.apache.ignite.spi.swapspace.inmemory.*; +import org.apache.ignite.spi.swapspace.file.*; import java.util.*; @@ -43,7 +43,7 @@ public abstract class IgniteCachePeekAbstractTest extends IgniteCacheAbstractTes @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); - cfg.setSwapSpaceSpi(new GridTestSwapSpaceSpi()); + cfg.setSwapSpaceSpi(new FileSwapSpaceSpi()); return cfg; } @@ -215,7 +215,7 @@ private void checkStorage(int nodeIdx) throws Exception { for (Integer key : keys) cache0.put(key, val); - GridTestSwapSpaceSpi swap = (GridTestSwapSpaceSpi)ignite(nodeIdx).configuration().getSwapSpaceSpi(); + FileSwapSpaceSpi swap = (FileSwapSpaceSpi)ignite(nodeIdx).configuration().getSwapSpaceSpi(); Set swapKeys = new HashSet<>(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSizeAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSizeAbstractTest.java new file mode 100644 index 0000000000000..35c3c867ee63b --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSizeAbstractTest.java @@ -0,0 +1,274 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache; + +import org.apache.ignite.*; +import org.apache.ignite.cache.*; +import org.apache.ignite.cache.affinity.*; +import org.apache.ignite.cache.eviction.fifo.*; +import org.apache.ignite.cluster.*; +import org.apache.ignite.configuration.*; +import org.apache.ignite.spi.swapspace.file.*; + +import java.util.*; + +import static org.apache.ignite.cache.CacheDistributionMode.*; +import static org.apache.ignite.cache.CacheMode.*; +import static org.apache.ignite.cache.CachePeekMode.*; + +/** + * + */ +public abstract class IgniteCacheSizeAbstractTest extends IgniteCacheAbstractTest { + /** */ + private static final int HEAP_ENTRIES = 10; + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(gridName); + + cfg.setSwapSpaceSpi(new FileSwapSpaceSpi()); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected CacheDistributionMode distributionMode() { + return PARTITIONED_ONLY; + } + + /** {@inheritDoc} */ + @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception { + CacheConfiguration ccfg = super.cacheConfiguration(gridName); + + ccfg.setMemoryMode(CacheMemoryMode.ONHEAP_TIERED); + + ccfg.setOffHeapMaxMemory(512); + + ccfg.setBackups(1); + + if (gridName.equals(getTestGridName(0))) + ccfg.setDistributionMode(NEAR_PARTITIONED); + + ccfg.setEvictionPolicy(new CacheFifoEvictionPolicy(HEAP_ENTRIES)); + + return ccfg; + } + + /** {@inheritDoc} */ + @Override protected boolean swapEnabled() { + return true; + } + + /** + * @throws Exception If failed. + */ + public void testSize() throws Exception { + for (int i = 0; i < gridCount(); i++) { + IgniteCache cache = jcache(i); + + assertEquals(0, cache.localSize()); + + assertEquals(0, cache.size()); + + for (CachePeekMode peekMode : CachePeekMode.values()) { + assertEquals(0, cache.localSize(peekMode)); + + assertEquals(0, cache.size(peekMode)); + } + } + + if (cacheMode() == LOCAL) { + IgniteCache cache0 = jcache(0); + + IgniteCache cacheAsync0 = cache0.withAsync(); + + for (int i = 0; i < HEAP_ENTRIES; i++) { + cache0.put(i, String.valueOf(i)); + + final int size = i + 1; + + assertEquals(size, cache0.localSize()); + assertEquals(size, cache0.localSize(PRIMARY)); + assertEquals(size, cache0.localSize(BACKUP)); + assertEquals(size, cache0.localSize(NEAR)); + assertEquals(size, cache0.localSize(ALL)); + + assertEquals(size, cache0.size()); + assertEquals(size, cache0.size(PRIMARY)); + assertEquals(size, cache0.size(BACKUP)); + assertEquals(size, cache0.size(NEAR)); + assertEquals(size, cache0.size(ALL)); + + cacheAsync0.size(); + + assertEquals(size, cacheAsync0.future().get()); + + cacheAsync0.size(PRIMARY); + + assertEquals(size, cacheAsync0.future().get()); + } + } + else { + checkSizeAffinityFilter(0); + + checkSizeAffinityFilter(1); + } + } + + /** + * @param nodeIdx Node index. + * @throws Exception If failed. + */ + private void checkSizeAffinityFilter(int nodeIdx) throws Exception { + IgniteCache cache0 = jcache(nodeIdx); + + final int PUT_KEYS = 10; + + List keys = null; + + try { + if (cacheMode() == REPLICATED) { + keys = backupKeys(cache0, 10, 0); + + for (Integer key : keys) + cache0.put(key, String.valueOf(key)); + + assertEquals(PUT_KEYS, cache0.localSize()); + assertEquals(PUT_KEYS, cache0.localSize(BACKUP)); + assertEquals(PUT_KEYS, cache0.localSize(ALL)); + assertEquals(0, cache0.localSize(PRIMARY)); + assertEquals(0, cache0.localSize(NEAR)); + + for (int i = 0; i < gridCount(); i++) { + IgniteCache cache = jcache(i); + + assertEquals(0, cache.size(NEAR)); + assertEquals(PUT_KEYS, cache.size(PRIMARY)); + assertEquals(PUT_KEYS * (gridCount() - 1), cache.size(BACKUP)); + assertEquals(PUT_KEYS * gridCount(), cache.size(PRIMARY, BACKUP)); + assertEquals(PUT_KEYS * gridCount(), cache.size()); // Primary + backups. + } + } + else { + keys = nearKeys(cache0, PUT_KEYS, 0); + + for (Integer key : keys) + cache0.put(key, String.valueOf(key)); + + boolean hasNearCache = nodeIdx == 0 ; + + if (hasNearCache) { + assertEquals(PUT_KEYS, cache0.localSize()); + assertEquals(PUT_KEYS, cache0.localSize(ALL)); + assertEquals(PUT_KEYS, cache0.localSize(NEAR)); + + for (int i = 0; i < gridCount(); i++) { + IgniteCache cache = jcache(i); + + assertEquals(PUT_KEYS, cache.size(NEAR)); + assertEquals(PUT_KEYS, cache.size(BACKUP)); + assertEquals(PUT_KEYS * 2, cache.size(PRIMARY, BACKUP)); + assertEquals(PUT_KEYS * 2 + PUT_KEYS, cache.size()); // Primary + backups + near. + } + } + else { + assertEquals(0, cache0.localSize()); + assertEquals(0, cache0.localSize(ALL)); + assertEquals(0, cache0.localSize(NEAR)); + + for (int i = 0; i < gridCount(); i++) { + IgniteCache cache = jcache(i); + + assertEquals(0, cache.size(NEAR)); + assertEquals(PUT_KEYS, cache.size(BACKUP)); + assertEquals(PUT_KEYS * 2, cache.size(PRIMARY, BACKUP)); + assertEquals(PUT_KEYS * 2, cache.size()); // Primary + backups. + } + } + + assertEquals(0, cache0.localSize(BACKUP)); + assertEquals(0, cache0.localSize(PRIMARY)); + } + + checkPrimarySize(PUT_KEYS); + + CacheAffinity aff = ignite(0).affinity(null); + + for (int i = 0; i < gridCount(); i++) { + if (i == nodeIdx) + continue; + + ClusterNode node = ignite(i).cluster().localNode(); + + int primary = 0; + int backups = 0; + + for (Integer key : keys) { + if (aff.isPrimary(node, key)) + primary++; + else if (aff.isBackup(node, key)) + backups++; + } + + IgniteCache cache = jcache(i); + + assertEquals(primary, cache.localSize(PRIMARY)); + assertEquals(backups, cache.localSize(BACKUP)); + assertEquals(primary + backups, cache.localSize(PRIMARY, BACKUP)); + assertEquals(primary + backups, cache.localSize(BACKUP, PRIMARY)); + assertEquals(primary + backups, cache.localSize(ALL)); + } + } + finally { + if (keys != null) + cache0.removeAll(new HashSet<>(keys)); + } + } + + /** + * @param nodeIdx Node index. + * @throws Exception If failed. + */ + private void checkSizeStorageFilter(int nodeIdx) throws Exception { + + } + + /** + * @param exp Expected size. + */ + private void checkPrimarySize(int exp) { + int size = 0; + + for (int i = 0; i < gridCount(); i++) { + IgniteCache cache = jcache(i); + + IgniteCache cacheAsync = cache.withAsync(); + + assertEquals(exp, cache.size(PRIMARY)); + + size += cache.localSize(PRIMARY); + + cacheAsync.size(PRIMARY); + + assertEquals(exp, cacheAsync.future().get()); + } + + assertEquals(exp, size); + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalSizeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalSizeTest.java new file mode 100644 index 0000000000000..5b0ddf7f0af9d --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalSizeTest.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache; + +import org.apache.ignite.cache.*; + +import static org.apache.ignite.cache.CacheAtomicityMode.*; +import static org.apache.ignite.cache.CacheMode.*; + +/** + * + */ +public class IgniteCacheTxLocalSizeTest extends IgniteCacheSizeAbstractTest { + /** {@inheritDoc} */ + @Override protected CacheAtomicityMode atomicityMode() { + return TRANSACTIONAL; + } + + /** {@inheritDoc} */ + @Override protected int gridCount() { + return 1; + } + + /** {@inheritDoc} */ + @Override protected CacheMode cacheMode() { + return LOCAL; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxReplicatedSizeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxReplicatedSizeTest.java new file mode 100644 index 0000000000000..a971bb8da0ede --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxReplicatedSizeTest.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache; + +import org.apache.ignite.cache.*; + +import static org.apache.ignite.cache.CacheMode.*; + +/** + * + */ +public class IgniteCacheTxReplicatedSizeTest extends IgniteCacheTxSizeTest { + /** {@inheritDoc} */ + @Override protected CacheMode cacheMode() { + return REPLICATED; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxSizeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxSizeTest.java new file mode 100644 index 0000000000000..70ff8b546c203 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxSizeTest.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache; + +import org.apache.ignite.cache.*; + +import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.*; +import static org.apache.ignite.cache.CacheAtomicityMode.*; +import static org.apache.ignite.cache.CacheMode.*; + +/** + * + */ +public class IgniteCacheTxSizeTest extends IgniteCacheSizeAbstractTest { + /** {@inheritDoc} */ + @Override protected CacheAtomicityMode atomicityMode() { + return TRANSACTIONAL; + } + + /** {@inheritDoc} */ + @Override protected int gridCount() { + return 4; + } + + /** {@inheritDoc} */ + @Override protected CacheMode cacheMode() { + return PARTITIONED; + } + + /** {@inheritDoc} */ + @Override protected CacheAtomicWriteOrderMode atomicWriteOrderMode() { + return PRIMARY; + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/spi/swapspace/inmemory/GridTestSwapSpaceSpi.java b/modules/core/src/test/java/org/apache/ignite/spi/swapspace/inmemory/GridTestSwapSpaceSpi.java index 55458488a86e8..456b277b3af38 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/swapspace/inmemory/GridTestSwapSpaceSpi.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/swapspace/inmemory/GridTestSwapSpaceSpi.java @@ -72,6 +72,13 @@ public class GridTestSwapSpaceSpi extends IgniteSpiAdapter implements SwapSpaceS return space != null ? space.count() : 0; } + /** {@inheritDoc} */ + @Override public long count(@Nullable String spaceName, Set parts) throws IgniteSpiException { + Space space = space(spaceName); + + return space.count(parts); + } + /** {@inheritDoc} */ @Override public byte[] read(@Nullable String spaceName, SwapKey key, SwapContext ctx) throws IgniteSpiException { @@ -171,6 +178,11 @@ private Space ensureSpace(String spaceName) { return space; } + /** + * @param evtType Event type. + * @param spaceName Space name. + * @param key Key bytes. + */ private void fireEvent(int evtType, String spaceName, @Nullable byte[] key) { SwapSpaceSpiListener lsnr0 = lsnr; @@ -178,10 +190,14 @@ private void fireEvent(int evtType, String spaceName, @Nullable byte[] key) { lsnr0.onSwapEvent(evtType, spaceName, key); } + /** + * + */ private class Space { /** Data storage. */ private ConcurrentMap data = new ConcurrentHashMap8<>(); + /** */ private final String name; /** @@ -214,6 +230,21 @@ public long count() { return data.size(); } + /** + * @param parts Partitions. + * @return Number of entries for given partitions. + */ + public long count(Set parts) { + int cnt = 0; + + for (SwapKey key : data.keySet()) { + if (parts.contains(key.partition())) + cnt++; + } + + return cnt; + } + /** * @param key Key to read. * @return Read bytes. @@ -318,6 +349,9 @@ public Collection partitions() { return parts; } + /** + * @return Iterator. + */ public IgniteSpiCloseableIterator keyIterator() { final Iterator it = data.keySet().iterator(); @@ -342,6 +376,9 @@ public IgniteSpiCloseableIterator keyIterator() { }; } + /** + * @return Raw iterator. + */ public IgniteSpiCloseableIterator> rawIterator() { final Iterator> it = data.entrySet().iterator(); @@ -378,6 +415,10 @@ public IgniteSpiCloseableIterator> rawIterator() { }; } + /** + * @param part Partition. + * @return Raw iterator for partition. + */ public IgniteSpiCloseableIterator> rawIterator(final int part) { final Iterator> it = data.entrySet().iterator(); diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java index eb4e7ea8a0def..d992295285a97 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java @@ -374,6 +374,13 @@ public static TestSuite suite() throws Exception { suite.addTestSuite(IgniteCacheTxLocalPeekTest.class); suite.addTestSuite(IgniteCacheTxReplicatedPeekTest.class); + suite.addTestSuite(IgniteCacheAtomicSizeTest.class); + suite.addTestSuite(IgniteCacheAtomicReplicatedSizeTest.class); + suite.addTestSuite(IgniteCacheAtomicLocalSizeTest.class); + suite.addTestSuite(IgniteCacheTxSizeTest.class); + suite.addTestSuite(IgniteCacheTxReplicatedSizeTest.class); + suite.addTestSuite(IgniteCacheTxLocalSizeTest.class); + // TODO: IGNITE-114. // suite.addTestSuite(IgniteCacheInvokeReadThroughTest.class); From 0b9ef4661cd90d7f9c4e0e3cab8777b82e0e9ff5 Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Thu, 5 Feb 2015 11:33:56 -0800 Subject: [PATCH 23/95] Merge branch 'ignite-sprint-1' of github.com:ggprivate/ggprivate into ignite-61 --- modules/codegen/pom.xml | 50 + .../CommunicationMessageCodeGenerator.java | 1127 +++++++++++++++++ .../internal/GridJobExecuteRequest.java | 866 ++++++------- modules/tools/pom.xml | 6 - .../CommunicationMessageCodeGenerator.java | 1127 ----------------- pom.xml | 1 + 6 files changed, 1611 insertions(+), 1566 deletions(-) create mode 100644 modules/codegen/pom.xml create mode 100644 modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java delete mode 100644 modules/tools/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java diff --git a/modules/codegen/pom.xml b/modules/codegen/pom.xml new file mode 100644 index 0000000000000..66a4eabc94477 --- /dev/null +++ b/modules/codegen/pom.xml @@ -0,0 +1,50 @@ + + + + + + + 4.0.0 + + + org.apache.ignite + ignite + ${ignite.version} + ../.. + + + ignite-codegen + + + UTF-8 + 1.7 + 1.7 + + + + + org.apache.ignite + ignite-core + ${ignite.version} + + + diff --git a/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java new file mode 100644 index 0000000000000..469b5751ae27f --- /dev/null +++ b/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java @@ -0,0 +1,1127 @@ +/* @java.file.header */ + +/* _________ _____ __________________ _____ +* __ ____/___________(_)______ /__ ____/______ ____(_)_______ +* _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ +* / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / +* \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ +*/ + +package org.apache.ignite.codegen; + +import com.sun.istack.internal.*; +import org.apache.ignite.internal.*; +import org.apache.ignite.internal.processors.cache.*; +import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.*; +import org.apache.ignite.internal.processors.cache.version.*; +import org.apache.ignite.internal.processors.clock.*; +import org.apache.ignite.internal.util.*; +import org.apache.ignite.internal.util.direct.*; +import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.lang.*; + +import java.io.*; +import java.lang.reflect.*; +import java.net.*; +import java.nio.*; +import java.util.*; + +import static java.lang.reflect.Modifier.*; + +/** +* Direct marshallable code generator. +*/ +public class CommunicationMessageCodeGenerator { + /** */ + private static final Comparator FIELD_CMP = new Comparator() { + @Override public int compare(Field f1, Field f2) { + int ver1 = 0; + + GridDirectVersion verAnn1 = f1.getAnnotation(GridDirectVersion.class); + + if (verAnn1 != null) { + ver1 = verAnn1.value(); + + assert ver1 > 0; + } + + int ver2 = 0; + + GridDirectVersion verAnn2 = f2.getAnnotation(GridDirectVersion.class); + + if (verAnn2 != null) { + ver2 = verAnn2.value(); + + assert ver2 > 0; + } + + return ver1 < ver2 ? -1 : ver1 > ver2 ? 1 : f1.getName().compareTo(f2.getName()); + } + }; + + /** */ + private static final String SRC_DIR = U.getGridGainHome() + "/modules/core/src/main/java"; + + /** */ + private static final Class BASE_CLS = GridTcpCommunicationMessageAdapter.class; + + /** */ + private static final String EMPTY = ""; + + /** */ + private static final String TAB = " "; + + /** */ + private static final String COMM_STATE_VAR = "commState"; + + /** */ + private static final String BUF_VAR = "buf"; + + /** */ + private static final String STATE_VAR = COMM_STATE_VAR + "." + "idx"; + + /** */ + private static final String TYPE_WRITTEN_VAR = COMM_STATE_VAR + "." + "typeWritten"; + + /** */ + private static final String IT_VAR = COMM_STATE_VAR + "." + "it"; + + /** */ + private static final String CUR_VAR = COMM_STATE_VAR + "." + "cur"; + + /** */ + private static final String KEY_DONE_VAR = COMM_STATE_VAR + "." + "keyDone"; + + /** */ + private static final String READ_SIZE_VAR = COMM_STATE_VAR + "." + "readSize"; + + /** */ + private static final String READ_ITEMS_VAR = COMM_STATE_VAR + "." + "readItems"; + + /** */ + private static final String DFLT_LOC_VAR = "_val"; + + /** */ + private final Collection write = new ArrayList<>(); + + /** */ + private final Collection read = new ArrayList<>(); + + /** */ + private final Collection clone = new ArrayList<>(); + + /** */ + private final Collection clone0 = new ArrayList<>(); + + /** */ + private final Map, Integer> fieldCnt = new HashMap<>(); + + /** */ + private List fields; + + /** */ + private int indent; + + /** + * @param args Arguments. + */ + public static void main(String[] args) { + CommunicationMessageCodeGenerator gen = new CommunicationMessageCodeGenerator(); + + try { + gen.generateAll(true); + } + catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Generates code for all classes. + * + * @param write Whether to write to file. + * @throws Exception In case of error. + */ + public void generateAll(boolean write) throws Exception { + Collection> classes = classes(); + + byte type = 0; + + for (Class cls : classes) { + boolean isAbstract = Modifier.isAbstract(cls.getModifiers()); + + System.out.println("Processing class: " + cls.getName() + (isAbstract ? " (abstract)" : "")); + + if (write) + generateAndWrite(cls, isAbstract ? -1 : type++); + else + generate(cls); + } + +// type = 0; +// +// for (Class cls : classes) { +// if (Modifier.isAbstract(cls.getModifiers())) +// continue; +// +// System.out.println("case " + type++ + ":"); +// System.out.println(" return new " + cls.getSimpleName() + "();"); +// System.out.println(); +// } + } + + /** + * Generates code for provided class and writes it to source file. + * Note: this method must be called only from {@code generateAll(boolean)} + * and only with updating {@code CLASSES_ORDER_FILE} and other auto generated files. + * + * @param cls Class. + * @throws Exception In case of error. + */ + @SuppressWarnings("ConstantConditions") + private void generateAndWrite(Class cls, byte type) throws Exception { + assert cls != null; + + generate(cls); + + File file = new File(SRC_DIR, cls.getName().replace('.', File.separatorChar) + ".java"); + + if (!file.exists() || !file.isFile()) { + System.out.println(" Source file not found: " + file.getPath()); + + return; + } + + Collection src = new ArrayList<>(); + + BufferedReader rdr = null; + + try { + rdr = new BufferedReader(new FileReader(file)); + + String line; + boolean skip = false; + + boolean writeFound = false; + boolean readFound = false; + boolean cloneFound = false; + boolean clone0Found = false; + + while ((line = rdr.readLine()) != null) { + if (!skip) { + src.add(line); + + if (line.contains("public boolean writeTo(ByteBuffer buf)")) { + src.addAll(write); + + skip = true; + + writeFound = true; + } + else if (line.contains("public boolean readFrom(ByteBuffer buf)")) { + src.addAll(read); + + skip = true; + + readFound = true; + } +// else if (type >= 0 && line.contains("public byte directType()")) { +// src.add(TAB + TAB + "return " + type + ';'); +// +// skip = true; +// } + else if (line.contains("public GridTcpCommunicationMessageAdapter clone()")) { + src.addAll(clone); + + skip = true; + + cloneFound = true; + } + else if (line.contains("protected void clone0(GridTcpCommunicationMessageAdapter _msg)")) { + src.addAll(clone0); + + skip = true; + + clone0Found = true; + } + } + else if (line.startsWith(TAB + "}")) { + src.add(line); + + skip = false; + } + } + + if (!writeFound) + System.out.println(" writeTo method doesn't exist."); + + if (!readFound) + System.out.println(" readFrom method doesn't exist."); + + if (!cloneFound) + System.out.println(" clone method doesn't exist."); + + if (!clone0Found) + System.out.println(" clone0 method doesn't exist."); + } + finally { + if (rdr != null) + rdr.close(); + } + + BufferedWriter wr = null; + + try { + wr = new BufferedWriter(new FileWriter(file)); + + for (String line : src) + wr.write(line + '\n'); + } + finally { + if (wr != null) + wr.close(); + } + } + + /** + * Generates code for provided class. + * + * @param cls Class. + * @throws Exception In case of error. + */ + public void generate(Class cls) throws Exception { + assert cls != null; + + write.clear(); + read.clear(); + clone.clear(); + clone0.clear(); + + fields = new ArrayList<>(); + + Field[] declaredFields = cls.getDeclaredFields(); + + for (Field field : declaredFields) { + int mod = field.getModifiers(); + + if (!isStatic(mod) && !isTransient(mod) && !field.isAnnotationPresent(GridDirectTransient.class)) + fields.add(field); + } + + Collections.sort(fields, FIELD_CMP); + + indent = 2; + + boolean hasSuper = cls.getSuperclass() != BASE_CLS; + + String clsName = cls.getSimpleName(); + + if (!Modifier.isAbstract(cls.getModifiers())) { + clone.add(builder().a(clsName).a(" _clone = new ").a(clsName).a("();").toString()); + clone.add(EMPTY); + clone.add(builder().a("clone0(_clone);").toString()); + clone.add(EMPTY); + clone.add(builder().a("return _clone;").toString()); + } + + if (hasSuper) { + clone0.add(builder().a("super.clone0(_msg);").toString()); + clone0.add(EMPTY); + } + + Collection cloningFields = new ArrayList<>(declaredFields.length); + + for (Field field: declaredFields) + if (!isStatic(field.getModifiers())) + cloningFields.add(field); + + if (!cloningFields.isEmpty()) { + clone0.add(builder().a(clsName).a(" _clone = (").a(clsName).a(")_msg;").toString()); + clone0.add(EMPTY); + + for (Field field : cloningFields) { + String name = field.getName(); + Class type = field.getType(); + + String res = name; + + if (BASE_CLS.isAssignableFrom(type)) + res = name + " != null ? (" + type.getSimpleName() + ")" + name + ".clone() : null"; + + clone0.add(builder().a("_clone.").a(name).a(" = ").a(res).a(";").toString()); + } + } + + start(write, hasSuper ? "writeTo" : null, true); + start(read, hasSuper ? "readFrom" : null, false); + + indent++; + + int state = startState(cls); + + for (Field field : fields) + processField(field, state++); + + indent--; + + finish(write); + finish(read); + } + + /** + * @param cls Message class. + * @return Start state. + */ + private int startState(Class cls) { + assert cls != null; + + Class superCls = cls.getSuperclass(); + + Integer state = fieldCnt.get(superCls); + + if (state != null) + return state; + + state = 0; + + while (cls.getSuperclass() != BASE_CLS) { + cls = cls.getSuperclass(); + + for (Field field : cls.getDeclaredFields()) { + int mod = field.getModifiers(); + + if (!isStatic(mod) && !isTransient(mod) && !field.isAnnotationPresent(GridDirectTransient.class)) + state++; + } + } + + fieldCnt.put(superCls, state); + + return state; + } + + /** + * @param code Code lines. + * @param superMtd Super class method name. + * @param writeType Whether to write message type. + */ + private void start(Collection code, @Nullable String superMtd, boolean writeType) { + assert code != null; + + code.add(builder().a(COMM_STATE_VAR).a(".setBuffer(").a(BUF_VAR).a(");").toString()); + code.add(EMPTY); + + if (superMtd != null) { + returnFalseIfFailed(code, "super." + superMtd, BUF_VAR); + + code.add(EMPTY); + } + + if (writeType) { + code.add(builder().a("if (!").a(TYPE_WRITTEN_VAR).a(") {").toString()); + + indent++; + + returnFalseIfFailed(code, COMM_STATE_VAR + ".putByte", "null", "directType()"); + + code.add(EMPTY); + code.add(builder().a(TYPE_WRITTEN_VAR).a(" = true;").toString()); + + indent--; + + code.add(builder().a("}").toString()); + code.add(EMPTY); + } + + if (!fields.isEmpty()) + code.add(builder().a("switch (").a(STATE_VAR).a(") {").toString()); + } + + /** + * @param code Code lines. + */ + private void finish(Collection code) { + assert code != null; + + if (!fields.isEmpty()) { + code.add(builder().a("}").toString()); + code.add(EMPTY); + } + + code.add(builder().a("return true;").toString()); + } + + /** + * @param field Field. + * @param opt Case option. + */ + private void processField(Field field, int opt) { + assert field != null; + assert opt >= 0; + + GridDirectCollection colAnn = field.getAnnotation(GridDirectCollection.class); + GridDirectMap mapAnn = field.getAnnotation(GridDirectMap.class); + + if (colAnn == null && Collection.class.isAssignableFrom(field.getType())) + throw new IllegalStateException("@GridDirectCollection annotation is not provided for field: " + + field.getName()); + + if (mapAnn == null && Map.class.isAssignableFrom(field.getType())) + throw new IllegalStateException("@GridDirectMap annotation is not provided for field: " + field.getName()); + + writeField(field, opt, colAnn, mapAnn); + readField(field, opt, colAnn, mapAnn); + } + + /** + * @param field Field. + * @param opt Case option. + * @param colAnn Collection annotation. + * @param mapAnn Map annotation. + */ + private void writeField(Field field, int opt, @Nullable GridDirectCollection colAnn, + @Nullable GridDirectMap mapAnn) { + assert field != null; + assert opt >= 0; + + write.add(builder().a("case ").a(opt).a(":").toString()); + + indent++; + + returnFalseIfWriteFailed(field.getType(), field.getName(), colAnn != null ? colAnn.value() : null, + mapAnn != null ? mapAnn.keyType() : null, mapAnn != null ? mapAnn.valueType() : null, false); + + write.add(EMPTY); + write.add(builder().a(STATE_VAR).a("++;").toString()); + write.add(EMPTY); + + indent--; + } + + /** + * @param field Field. + * @param opt Case option. + * @param colAnn Collection annotation. + * @param mapAnn Map annotation. + */ + private void readField(Field field, int opt, @Nullable GridDirectCollection colAnn, + @Nullable GridDirectMap mapAnn) { + assert field != null; + assert opt >= 0; + + read.add(builder().a("case ").a(opt).a(":").toString()); + + indent++; + + returnFalseIfReadFailed(field.getType(), field.getName(), colAnn != null ? colAnn.value() : null, + mapAnn != null ? mapAnn.keyType() : null, mapAnn != null ? mapAnn.valueType() : null, false); + + read.add(EMPTY); + read.add(builder().a(STATE_VAR).a("++;").toString()); + read.add(EMPTY); + + indent--; + } + + /** + * @param type Field type. + * @param name Field name. + * @param colItemType Collection item type. + * @param mapKeyType Map key type. + * @param mapValType Map key value. + * @param raw Raw write flag. + */ + private void returnFalseIfWriteFailed(Class type, String name, @Nullable Class colItemType, + @Nullable Class mapKeyType, @Nullable Class mapValType, boolean raw) { + assert type != null; + assert name != null; + + String field = raw ? "null" : '"' + name + '"'; + + if (type == byte.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putByte", field, name); + else if (type == short.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putShort", field, name); + else if (type == int.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putInt", field, name); + else if (type == long.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putLong", field, name); + else if (type == float.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putFloat", field, name); + else if (type == double.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putDouble", field, name); + else if (type == char.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putChar", field, name); + else if (type == boolean.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putBoolean", field, name); + else if (type == byte[].class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putByteArray", field, name); + else if (type == short[].class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putShortArray", field, name); + else if (type == int[].class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putIntArray", field, name); + else if (type == long[].class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putLongArray", field, name); + else if (type == float[].class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putFloatArray", field, name); + else if (type == double[].class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putDoubleArray", field, name); + else if (type == char[].class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putCharArray", field, name); + else if (type == boolean[].class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putBooleanArray", field, name); + else if (type == UUID.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putUuid", field, name); + else if (type == ByteBuffer.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putByteBuffer", field, name); + else if (type == IgniteUuid.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putGridUuid", field, name); + else if (type == GridClockDeltaVersion.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putClockDeltaVersion", field, name); + else if (type == GridByteArrayList.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putByteArrayList", field, name); + else if (type == GridLongList.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putLongList", field, name); + else if (type == GridCacheVersion.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putCacheVersion", field, name); + else if (type == GridDhtPartitionExchangeId.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putDhtPartitionExchangeId", field, name); + else if (type == GridCacheValueBytes.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putValueBytes", field, name); + //else if (type == GridDrInternalRequestEntry.class) + // returnFalseIfFailed(write, COMM_STATE_VAR + ".putDrInternalRequestEntry", field, name); + else if (type == String.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putString", field, name); + else if (type == BitSet.class) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putBitSet", field, name); + else if (type.isEnum()) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putEnum", field, name); + else if (BASE_CLS.isAssignableFrom(type)) + returnFalseIfFailed(write, COMM_STATE_VAR + ".putMessage", field, name); + else if (type.isArray() || Collection.class.isAssignableFrom(type)) { + boolean isArr = type.isArray(); + + if (isArr) + colItemType = type.getComponentType(); + + assert colItemType != null; + + write.add(builder().a("if (").a(name).a(" != null) {").toString()); + + indent++; + + write.add(builder().a("if (").a(IT_VAR).a(" == null) {").toString()); + + indent++; + + returnFalseIfFailed(write, COMM_STATE_VAR + ".putInt", "null", name + "." + (isArr ? "length" : "size()")); + + write.add(EMPTY); + write.add(builder().a(IT_VAR).a(" = ").a(isArr ? "arrayIterator(" + name + ")" : name + ".iterator()"). + a(";").toString()); + + indent--; + + write.add(builder().a("}").toString()); + write.add(EMPTY); + write.add(builder().a("while (").a(IT_VAR).a(".hasNext() || ").a(CUR_VAR).a(" != NULL").a(") {"). + toString()); + + indent++; + + write.add(builder().a("if (").a(CUR_VAR).a(" == NULL)").toString()); + + indent++; + + write.add(builder().a(CUR_VAR).a(" = ").a(IT_VAR).a(".next();").toString()); + + indent--; + + write.add(EMPTY); + + returnFalseIfWriteFailed(colItemType, "(" + colItemType.getSimpleName() + ")" + CUR_VAR, + null, null, null, true); + + write.add(EMPTY); + write.add(builder().a(CUR_VAR).a(" = NULL;").toString()); + + indent--; + + write.add(builder().a("}").toString()); + write.add(EMPTY); + write.add(builder().a(IT_VAR).a(" = null;").toString()); + + indent--; + + write.add(builder().a("} else {").toString()); + + indent++; + + returnFalseIfFailed(write, COMM_STATE_VAR + ".putInt", "null", "-1"); + + indent--; + + write.add(builder().a("}").toString()); + } + else if (Map.class.isAssignableFrom(type)) { + assert mapKeyType != null; + assert mapValType != null; + + write.add(builder().a("if (").a(name).a(" != null) {").toString()); + + indent++; + + write.add(builder().a("if (").a(IT_VAR).a(" == null) {").toString()); + + indent++; + + returnFalseIfFailed(write, COMM_STATE_VAR + ".putInt", "null", name + ".size()"); + + write.add(EMPTY); + write.add(builder().a(IT_VAR).a(" = ").a(name).a(".entrySet().iterator();").toString()); + + indent--; + + write.add(builder().a("}").toString()); + write.add(EMPTY); + write.add(builder().a("while (").a(IT_VAR).a(".hasNext() || ").a(CUR_VAR).a(" != NULL").a(") {"). + toString()); + + indent++; + + write.add(builder().a("if (").a(CUR_VAR).a(" == NULL)").toString()); + + indent++; + + write.add(builder().a(CUR_VAR).a(" = ").a(IT_VAR).a(".next();").toString()); + + indent--; + + String entryType = "Map.Entry<" + U.box(mapKeyType).getSimpleName() + ", " + + U.box(mapValType).getSimpleName() + ">"; + + write.add(EMPTY); + write.add(builder().a(entryType).a(" e = (").a(entryType).a(")").a(CUR_VAR).a(";").toString()); + write.add(EMPTY); + write.add(builder().a("if (!").a(KEY_DONE_VAR).a(") {").toString()); + + indent++; + + returnFalseIfWriteFailed(mapKeyType, "e.getKey()", null, null, null, true); + + write.add(EMPTY); + write.add(builder().a(KEY_DONE_VAR).a(" = true;").toString()); + + indent--; + + write.add(builder().a("}").toString()); + write.add(EMPTY); + + returnFalseIfWriteFailed(mapValType, "e.getValue()", null, null, null, true); + + write.add(EMPTY); + write.add(builder().a(KEY_DONE_VAR).a(" = false;").toString()); + write.add(EMPTY); + write.add(builder().a(CUR_VAR).a(" = NULL;").toString()); + + indent--; + + write.add(builder().a("}").toString()); + write.add(EMPTY); + write.add(builder().a(IT_VAR).a(" = null;").toString()); + + indent--; + + write.add(builder().a("} else {").toString()); + + indent++; + + returnFalseIfFailed(write, COMM_STATE_VAR + ".putInt", "null", "-1"); + + indent--; + + write.add(builder().a("}").toString()); + } + else + throw new IllegalStateException("Unsupported type: " + type); + } + + /** + * @param type Field type. + * @param name Field name. + * @param colItemType Collection item type. + * @param mapKeyType Map key type. + * @param mapValType Map value type. + * @param raw Raw read flag. + */ + private void returnFalseIfReadFailed(Class type, @Nullable String name, @Nullable Class colItemType, + @Nullable Class mapKeyType, @Nullable Class mapValType, boolean raw) { + assert type != null; + + String field = raw ? "null" : '"' + name + '"'; + + String retType = type.getSimpleName(); + + if (type == byte.class) + returnFalseIfReadFailed("byte", name, null, COMM_STATE_VAR + ".getByte", field, false); + else if (type == short.class) + returnFalseIfReadFailed("short", name, null, COMM_STATE_VAR + ".getShort", field, false); + else if (type == int.class) + returnFalseIfReadFailed("int", name, null, COMM_STATE_VAR + ".getInt", field, false); + else if (type == long.class) + returnFalseIfReadFailed("long", name, null, COMM_STATE_VAR + ".getLong", field, false); + else if (type == float.class) + returnFalseIfReadFailed("float", name, null, COMM_STATE_VAR + ".getFloat", field, false); + else if (type == double.class) + returnFalseIfReadFailed("double", name, null, COMM_STATE_VAR + ".getDouble", field, false); + else if (type == char.class) + returnFalseIfReadFailed("char", name, null, COMM_STATE_VAR + ".getChar", field, false); + else if (type == boolean.class) + returnFalseIfReadFailed("boolean", name, null, COMM_STATE_VAR + ".getBoolean", field, false); + else if (type == byte[].class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getByteArray", field, false); + else if (type == short[].class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getShortArray", field, false); + else if (type == int[].class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getIntArray", field, false); + else if (type == long[].class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getLongArray", field, false); + else if (type == float[].class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getFloatArray", field, false); + else if (type == double[].class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getDoubleArray", field, false); + else if (type == char[].class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getCharArray", field, false); + else if (type == boolean[].class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getBooleanArray", field, false); + else if (type == UUID.class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getUuid", field, false); + else if (type == ByteBuffer.class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getByteBuffer", field, false); + else if (type == IgniteUuid.class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getGridUuid", field, false); + else if (type == GridClockDeltaVersion.class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getClockDeltaVersion", field, false); + else if (type == GridLongList.class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getLongList", field, false); + else if (type == GridByteArrayList.class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getByteArrayList", field, false); + else if (type == GridCacheVersion.class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getCacheVersion", field, false); + else if (type == GridDhtPartitionExchangeId.class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getDhtPartitionExchangeId", field, false); + else if (type == GridCacheValueBytes.class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getValueBytes", field, false); + //else if (type == GridDrInternalRequestEntry.class) + // returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getDrInternalRequestEntry", field, false); + else if (type == String.class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getString", field, false); + else if (type == BitSet.class) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getBitSet", field, false); + else if (type.isEnum()) { + assert name != null; + + returnFalseIfReadFailed("byte", null, name + "0", COMM_STATE_VAR + ".getByte", field, false); + + read.add(EMPTY); + read.add(builder().a(name).a(" = ").a(type.getSimpleName()).a(".fromOrdinal(").a(name).a("0);").toString()); + } + else if (BASE_CLS.isAssignableFrom(type)) + returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getMessage", field, true); + else if (type.isArray() || Collection.class.isAssignableFrom(type)) { + assert name != null; + + boolean isArr = type.isArray(); + + if (isArr) + colItemType = type.getComponentType(); + + assert colItemType != null; + + Class colType = Set.class.isAssignableFrom(type) ? HashSet.class : ArrayList.class; + + read.add(builder().a("if (").a(READ_SIZE_VAR).a(" == -1) {").toString()); + + indent++; + + returnFalseIfReadFailed(int.class, READ_SIZE_VAR, null, null, null, true); + + indent--; + + read.add(builder().a("}").toString()); + read.add(EMPTY); + read.add(builder().a("if (").a(READ_SIZE_VAR).a(" >= 0) {").toString()); + + indent++; + + read.add(builder().a("if (").a(name).a(" == null)").toString()); + + indent++; + + if (isArr) { + String val = colItemType.isArray() ? + colItemType.getComponentType().getSimpleName() + "[" + READ_SIZE_VAR + "][]" : + colItemType.getSimpleName() + "[" + READ_SIZE_VAR + "]"; + + read.add(builder().a(name).a(" = new ").a(val).a(";"). + toString()); + } + else { + read.add(builder().a(name).a(" = new ").a(colType.getSimpleName()).a("<>(").a(READ_SIZE_VAR).a(");"). + toString()); + } + + indent--; + + read.add(EMPTY); + read.add(builder().a("for (int i = ").a(READ_ITEMS_VAR).a("; i < ").a(READ_SIZE_VAR).a("; i++) {"). + toString()); + + indent++; + + String var = colItemType.isPrimitive() ? colItemType.getSimpleName() + " " + DFLT_LOC_VAR : null; + + returnFalseIfReadFailed(colItemType, var, null, null, null, true); + + read.add(EMPTY); + read.add(builder().a(name).a(isArr ? "[i] = " : ".add(").a("(").a(U.box(colItemType).getSimpleName()). + a(")").a(DFLT_LOC_VAR).a(isArr ? ";" : ");").toString()); + read.add(EMPTY); + read.add(builder().a(READ_ITEMS_VAR).a("++;").toString()); + + indent--; + + read.add(builder().a("}").toString()); + + indent--; + + read.add(builder().a("}").toString()); + read.add(EMPTY); + read.add(builder().a(READ_SIZE_VAR).a(" = -1;").toString()); + read.add(builder().a(READ_ITEMS_VAR).a(" = 0;").toString()); + } + else if (Map.class.isAssignableFrom(type)) { + assert name != null; + assert mapKeyType != null; + assert mapValType != null; + + Class mapType = LinkedHashMap.class.isAssignableFrom(type) ? LinkedHashMap.class : HashMap.class; + + read.add(builder().a("if (").a(READ_SIZE_VAR).a(" == -1) {").toString()); + + indent++; + + returnFalseIfReadFailed(int.class, READ_SIZE_VAR, null, null, null, true); + + indent--; + + read.add(builder().a("}").toString()); + read.add(EMPTY); + read.add(builder().a("if (").a(READ_SIZE_VAR).a(" >= 0) {").toString()); + + indent++; + + read.add(builder().a("if (").a(name).a(" == null)").toString()); + + indent++; + + read.add(builder().a(name).a(" = new ").a(mapType.getSimpleName()).a("<>(").a(READ_SIZE_VAR).a(", 1.0f);"). + toString()); + + indent--; + + read.add(EMPTY); + read.add(builder().a("for (int i = ").a(READ_ITEMS_VAR).a("; i < ").a(READ_SIZE_VAR).a("; i++) {"). + toString()); + + indent++; + + read.add(builder().a("if (!").a(KEY_DONE_VAR).a(") {").toString()); + + indent++; + + String var = mapKeyType.isPrimitive() ? mapKeyType.getSimpleName() + " " + DFLT_LOC_VAR : null; + + returnFalseIfReadFailed(mapKeyType, var, null, null, null, true); + + read.add(EMPTY); + read.add(builder().a(CUR_VAR).a(" = ").a(DFLT_LOC_VAR).a(";").toString()); + read.add(builder().a(KEY_DONE_VAR).a(" = true;").toString()); + + indent--; + + read.add(builder().a("}").toString()); + read.add(EMPTY); + + var = mapValType.isPrimitive() ? mapValType.getSimpleName() + " " + DFLT_LOC_VAR : null; + + returnFalseIfReadFailed(mapValType, var, null, null, null, true); + + read.add(EMPTY); + read.add(builder().a(name).a(".put((").a(U.box(mapKeyType).getSimpleName()).a(")").a(CUR_VAR). + a(", ").a(DFLT_LOC_VAR).a(");").toString()); + read.add(EMPTY); + read.add(builder().a(KEY_DONE_VAR).a(" = false;").toString()); + read.add(EMPTY); + read.add(builder().a(READ_ITEMS_VAR).a("++;").toString()); + + indent--; + + read.add(builder().a("}").toString()); + + indent--; + + read.add(builder().a("}").toString()); + read.add(EMPTY); + read.add(builder().a(READ_SIZE_VAR).a(" = -1;").toString()); + read.add(builder().a(READ_ITEMS_VAR).a(" = 0;").toString()); + read.add(builder().a(CUR_VAR).a(" = null;").toString()); + } + else + throw new IllegalStateException("Unsupported type: " + type); + } + + /** + * @param retType Return type. + * @param var Variable name. + * @param locVar Local variable name. + * @param mtd Method name. + * @param arg Method argument. + * @param cast Whether cast is needed. + */ + private void returnFalseIfReadFailed(String retType, @Nullable String var, @Nullable String locVar, String mtd, + @Nullable String arg, boolean cast) { + assert retType != null; + assert mtd != null; + + if (var == null) + var = retType + " " + (locVar != null ? locVar : DFLT_LOC_VAR); + + read.add(builder().a(var).a(" = ").a(cast ? "(" + retType + ")" : "").a(mtd). + a(arg != null ? "(" + arg + ");" : "();").toString()); + read.add(EMPTY); + + read.add(builder().a("if (!").a(COMM_STATE_VAR).a(".lastRead())").toString()); + + indent++; + + read.add(builder().a("return false;").toString()); + + indent--; + } + + /** + * @param code Code lines. + * @param accessor Field or method name. + * @param args Method arguments. + */ + private void returnFalseIfFailed(Collection code, String accessor, @Nullable String... args) { + assert code != null; + assert accessor != null; + + String argsStr = ""; + + if (args != null && args.length > 0) { + for (String arg : args) + argsStr += arg + ", "; + + argsStr = argsStr.substring(0, argsStr.length() - 2); + } + + code.add(builder().a("if (!").a(accessor).a("(" + argsStr + ")").a(")").toString()); + + indent++; + + code.add(builder().a("return false;").toString()); + + indent--; + } + + /** + * Creates new builder with correct indent. + * + * @return Builder. + */ + private SB builder() { + assert indent > 0; + + SB sb = new SB(); + + for (int i = 0; i < indent; i++) + sb.a(TAB); + + return sb; + } + + /** + * Gets all direct marshallable classes. + * First classes will be classes from {@code classesOrder} with same order + * as ordered values. Other classes will be at the end and ordered by name + * (with package prefix). + * That orders need for saving {@code directType} value. + * + * @return Classes. + * @throws Exception In case of error. + */ + private Collection> classes() throws Exception { + Collection> col = new TreeSet<>( + new Comparator>() { + @Override public int compare(Class c1, + Class c2) { + return c1.getName().compareTo(c2.getName()); + } + }); + + URLClassLoader ldr = (URLClassLoader)getClass().getClassLoader(); + + for (URL url : ldr.getURLs()) { + File file = new File(url.toURI()); + + int prefixLen = file.getPath().length() + 1; + + processFile(file, ldr, prefixLen, col); + } + + return col; + } + + /** + * Recursively process provided file or directory. + * + * @param file File. + * @param ldr Class loader. + * @param prefixLen Path prefix length. + * @param col Classes. + * @throws Exception In case of error. + */ + private void processFile(File file, ClassLoader ldr, int prefixLen, + Collection> col) throws Exception { + assert file != null; + assert ldr != null; + assert prefixLen > 0; + assert col != null; + + if (!file.exists()) + throw new FileNotFoundException("File doesn't exist: " + file); + + if (file.isDirectory()) { + for (File f : file.listFiles()) + processFile(f, ldr, prefixLen, col); + } + else { + assert file.isFile(); + + String path = file.getPath(); + + if (path.endsWith(".class")) { + String clsName = path.substring(prefixLen, path.length() - 6).replace(File.separatorChar, '.'); + + Class cls = Class.forName(clsName, false, ldr); + + if (cls.getDeclaringClass() == null && cls.getEnclosingClass() == null && + !BASE_CLS.equals(cls) && BASE_CLS.isAssignableFrom(cls)) + col.add((Class)cls); + } + } + } +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java index d28474929613b..20e4597b997ec 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java @@ -456,202 +456,202 @@ public UUID getSubjectId() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); - - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) - return false; - - commState.typeWritten = true; - } - - switch (commState.idx) { - case 0: - if (!commState.putGridUuid("clsLdrId", clsLdrId)) - return false; - - commState.idx++; - - case 1: - if (!commState.putString("cpSpi", cpSpi)) - return false; - - commState.idx++; - - case 2: - if (!commState.putLong("createTime", createTime)) - return false; - - commState.idx++; - - case 3: - if (!commState.putEnum("depMode", depMode)) - return false; - - commState.idx++; - - case 4: - if (!commState.putBoolean("dynamicSiblings", dynamicSiblings)) - return false; - - commState.idx++; - - case 5: - if (!commState.putBoolean("forceLocDep", forceLocDep)) - return false; - - commState.idx++; - - case 6: - if (!commState.putBoolean("internal", internal)) - return false; - - commState.idx++; - - case 7: - if (!commState.putByteArray("jobAttrsBytes", jobAttrsBytes)) - return false; - - commState.idx++; - - case 8: - if (!commState.putByteArray("jobBytes", jobBytes)) - return false; - - commState.idx++; - - case 9: - if (!commState.putGridUuid("jobId", jobId)) - return false; - - commState.idx++; - - case 9: - if (ldrParticipants != null) { - if (commState.it == null) { - if (!commState.putInt(null, ldrParticipants.size())) - return false; - - commState.it = ldrParticipants.entrySet().iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - Map.Entry e = (Map.Entry)commState.cur; - - if (!commState.keyDone) { - if (!commState.putUuid(null, e.getKey())) - return false; - - commState.keyDone = true; - } - - if (!commState.putGridUuid(null, e.getValue())) - return false; - - commState.keyDone = false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } - - commState.idx++; - - case 11: - if (!commState.putByteArray("sesAttrsBytes", sesAttrsBytes)) - return false; - - commState.idx++; - - case 12: - if (!commState.putBoolean(sesFullSup)) - return false; - - commState.idx++; - - case 13: - if (!commState.putGridUuid("sesId", sesId)) - return false; - - commState.idx++; - - case 14: - if (!commState.putByteArray("siblingsBytes", siblingsBytes)) - return false; - - commState.idx++; - - case 15: - if (!commState.putLong("startTaskTime", startTaskTime)) - return false; - - commState.idx++; - - case 16: - if (!commState.putUuid("subjId", subjId)) - return false; - - commState.idx++; - - case 17: - if (!commState.putString("taskClsName", taskClsName)) - return false; - - commState.idx++; - - case 18: - if (!commState.putString("taskName", taskName)) - return false; - - commState.idx++; - - case 19: - if (!commState.putLong("timeout", timeout)) - return false; - - commState.idx++; - - case 19: - if (top != null) { - if (commState.it == null) { - if (!commState.putInt(null, top.size())) - return false; - - commState.it = top.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putUuid(null, (UUID)commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } - - commState.idx++; - - case 21: - if (!commState.putString("userVer", userVer)) - return false; - - commState.idx++; - - } +// commState.setBuffer(buf); +// +// if (!commState.typeWritten) { +// if (!commState.putByte(null, directType())) +// return false; +// +// commState.typeWritten = true; +// } +// +// switch (commState.idx) { +// case 0: +// if (!commState.putGridUuid("clsLdrId", clsLdrId)) +// return false; +// +// commState.idx++; +// +// case 1: +// if (!commState.putString("cpSpi", cpSpi)) +// return false; +// +// commState.idx++; +// +// case 2: +// if (!commState.putLong("createTime", createTime)) +// return false; +// +// commState.idx++; +// +// case 3: +// if (!commState.putEnum("depMode", depMode)) +// return false; +// +// commState.idx++; +// +// case 4: +// if (!commState.putBoolean("dynamicSiblings", dynamicSiblings)) +// return false; +// +// commState.idx++; +// +// case 5: +// if (!commState.putBoolean("forceLocDep", forceLocDep)) +// return false; +// +// commState.idx++; +// +// case 6: +// if (!commState.putBoolean("internal", internal)) +// return false; +// +// commState.idx++; +// +// case 7: +// if (!commState.putByteArray("jobAttrsBytes", jobAttrsBytes)) +// return false; +// +// commState.idx++; +// +// case 8: +// if (!commState.putByteArray("jobBytes", jobBytes)) +// return false; +// +// commState.idx++; +// +// case 9: +// if (!commState.putGridUuid("jobId", jobId)) +// return false; +// +// commState.idx++; +// +// case 9: +// if (ldrParticipants != null) { +// if (commState.it == null) { +// if (!commState.putInt(null, ldrParticipants.size())) +// return false; +// +// commState.it = ldrParticipants.entrySet().iterator(); +// } +// +// while (commState.it.hasNext() || commState.cur != NULL) { +// if (commState.cur == NULL) +// commState.cur = commState.it.next(); +// +// Map.Entry e = (Map.Entry)commState.cur; +// +// if (!commState.keyDone) { +// if (!commState.putUuid(null, e.getKey())) +// return false; +// +// commState.keyDone = true; +// } +// +// if (!commState.putGridUuid(null, e.getValue())) +// return false; +// +// commState.keyDone = false; +// +// commState.cur = NULL; +// } +// +// commState.it = null; +// } else { +// if (!commState.putInt(null, -1)) +// return false; +// } +// +// commState.idx++; +// +// case 11: +// if (!commState.putByteArray("sesAttrsBytes", sesAttrsBytes)) +// return false; +// +// commState.idx++; +// +// case 12: +// if (!commState.putBoolean(sesFullSup)) +// return false; +// +// commState.idx++; +// +// case 13: +// if (!commState.putGridUuid("sesId", sesId)) +// return false; +// +// commState.idx++; +// +// case 14: +// if (!commState.putByteArray("siblingsBytes", siblingsBytes)) +// return false; +// +// commState.idx++; +// +// case 15: +// if (!commState.putLong("startTaskTime", startTaskTime)) +// return false; +// +// commState.idx++; +// +// case 16: +// if (!commState.putUuid("subjId", subjId)) +// return false; +// +// commState.idx++; +// +// case 17: +// if (!commState.putString("taskClsName", taskClsName)) +// return false; +// +// commState.idx++; +// +// case 18: +// if (!commState.putString("taskName", taskName)) +// return false; +// +// commState.idx++; +// +// case 19: +// if (!commState.putLong("timeout", timeout)) +// return false; +// +// commState.idx++; +// +// case 19: +// if (top != null) { +// if (commState.it == null) { +// if (!commState.putInt(null, top.size())) +// return false; +// +// commState.it = top.iterator(); +// } +// +// while (commState.it.hasNext() || commState.cur != NULL) { +// if (commState.cur == NULL) +// commState.cur = commState.it.next(); +// +// if (!commState.putUuid(null, (UUID)commState.cur)) +// return false; +// +// commState.cur = NULL; +// } +// +// commState.it = null; +// } else { +// if (!commState.putInt(null, -1)) +// return false; +// } +// +// commState.idx++; +// +// case 21: +// if (!commState.putString("userVer", userVer)) +// return false; +// +// commState.idx++; +// +// } return true; } @@ -659,243 +659,243 @@ public UUID getSubjectId() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); - - switch (commState.idx) { - case 0: - clsLdrId = commState.getGridUuid("clsLdrId"); - - if (!commState.lastRead()) - return false; - - commState.idx++; - - case 1: - cpSpi = commState.getString("cpSpi"); - - if (!commState.lastRead()) - return false; - - commState.idx++; - - case 2: - createTime = commState.getLong("createTime"); - - if (!commState.lastRead()) - return false; - - commState.idx++; - - case 3: - byte depMode0 = commState.getByte("depMode"); - - if (!commState.lastRead()) - return false; - - depMode = IgniteDeploymentMode.fromOrdinal(depMode0); - - commState.idx++; - - case 4: - dynamicSiblings = commState.getBoolean("dynamicSiblings"); - - if (!commState.lastRead()) - return false; - - commState.idx++; - - case 5: - forceLocDep = commState.getBoolean("forceLocDep"); - - if (!commState.lastRead()) - return false; - - commState.idx++; - - case 6: - internal = commState.getBoolean("internal"); - - if (!commState.lastRead()) - return false; - - commState.idx++; - - case 7: - jobAttrsBytes = commState.getByteArray("jobAttrsBytes"); - - if (!commState.lastRead()) - return false; - - commState.idx++; - - case 8: - jobBytes = commState.getByteArray("jobBytes"); - - if (!commState.lastRead()) - return false; - - commState.idx++; - - case 9: - jobId = commState.getGridUuid("jobId"); - - if (!commState.lastRead()) - return false; - - commState.idx++; - - case 9: - if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); - - if (!commState.lastRead()) - return false; - } - - if (commState.readSize >= 0) { - if (ldrParticipants == null) - ldrParticipants = new HashMap<>(commState.readSize, 1.0f); - - for (int i = commState.readItems; i < commState.readSize; i++) { - if (!commState.keyDone) { - UUID _val = commState.getUuid(null); - - if (!commState.lastRead()) - return false; - - commState.cur = _val; - commState.keyDone = true; - } - - IgniteUuid _val = commState.getGridUuid(null); - - if (!commState.lastRead()) - return false; - - ldrParticipants.put((UUID)commState.cur, _val); - - commState.keyDone = false; - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; - commState.cur = null; - - commState.idx++; - - case 11: - sesAttrsBytes = commState.getByteArray("sesAttrsBytes"); - - if (!commState.lastRead()) - return false; - - commState.idx++; - - case 12: - sesFullSup = commState.getBoolean("sesFullSup"); - - if (!commState.lastRead()) - return false; - - commState.idx++; - - case 13: - sesId = commState.getGridUuid("sesId"); - - if (!commState.lastRead()) - return false; - - commState.idx++; - - case 14: - siblingsBytes = commState.getByteArray("siblingsBytes"); - - if (!commState.lastRead()) - return false; - - commState.idx++; - - case 15: - startTaskTime = commState.getLong("startTaskTime"); - - if (!commState.lastRead()) - return false; - - commState.idx++; - - case 16: - subjId = commState.getUuid("subjId"); - - if (!commState.lastRead()) - return false; - - commState.idx++; - - case 17: - taskClsName = commState.getString("taskClsName"); - - if (!commState.lastRead()) - return false; - - commState.idx++; - - case 18: - taskName = commState.getString("taskName"); - - if (!commState.lastRead()) - return false; - - commState.idx++; - - case 19: - timeout = commState.getLong("timeout"); - - if (!commState.lastRead()) - return false; - - commState.idx++; - - case 19: - if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); - - if (!commState.lastRead()) - return false; - } - - if (commState.readSize >= 0) { - if (top == null) - top = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - UUID _val = commState.getUuid(null); - - if (!commState.lastRead()) - return false; - - top.add((UUID)_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; - - commState.idx++; - - case 21: - userVer = commState.getString("userVer"); - - if (!commState.lastRead()) - return false; - - commState.idx++; - - } +// commState.setBuffer(buf); +// +// switch (commState.idx) { +// case 0: +// clsLdrId = commState.getGridUuid("clsLdrId"); +// +// if (!commState.lastRead()) +// return false; +// +// commState.idx++; +// +// case 1: +// cpSpi = commState.getString("cpSpi"); +// +// if (!commState.lastRead()) +// return false; +// +// commState.idx++; +// +// case 2: +// createTime = commState.getLong("createTime"); +// +// if (!commState.lastRead()) +// return false; +// +// commState.idx++; +// +// case 3: +// byte depMode0 = commState.getByte("depMode"); +// +// if (!commState.lastRead()) +// return false; +// +// depMode = IgniteDeploymentMode.fromOrdinal(depMode0); +// +// commState.idx++; +// +// case 4: +// dynamicSiblings = commState.getBoolean("dynamicSiblings"); +// +// if (!commState.lastRead()) +// return false; +// +// commState.idx++; +// +// case 5: +// forceLocDep = commState.getBoolean("forceLocDep"); +// +// if (!commState.lastRead()) +// return false; +// +// commState.idx++; +// +// case 6: +// internal = commState.getBoolean("internal"); +// +// if (!commState.lastRead()) +// return false; +// +// commState.idx++; +// +// case 7: +// jobAttrsBytes = commState.getByteArray("jobAttrsBytes"); +// +// if (!commState.lastRead()) +// return false; +// +// commState.idx++; +// +// case 8: +// jobBytes = commState.getByteArray("jobBytes"); +// +// if (!commState.lastRead()) +// return false; +// +// commState.idx++; +// +// case 9: +// jobId = commState.getGridUuid("jobId"); +// +// if (!commState.lastRead()) +// return false; +// +// commState.idx++; +// +// case 9: +// if (commState.readSize == -1) { +// commState.readSize = commState.getInt(null); +// +// if (!commState.lastRead()) +// return false; +// } +// +// if (commState.readSize >= 0) { +// if (ldrParticipants == null) +// ldrParticipants = new HashMap<>(commState.readSize, 1.0f); +// +// for (int i = commState.readItems; i < commState.readSize; i++) { +// if (!commState.keyDone) { +// UUID _val = commState.getUuid(null); +// +// if (!commState.lastRead()) +// return false; +// +// commState.cur = _val; +// commState.keyDone = true; +// } +// +// IgniteUuid _val = commState.getGridUuid(null); +// +// if (!commState.lastRead()) +// return false; +// +// ldrParticipants.put((UUID)commState.cur, _val); +// +// commState.keyDone = false; +// +// commState.readItems++; +// } +// } +// +// commState.readSize = -1; +// commState.readItems = 0; +// commState.cur = null; +// +// commState.idx++; +// +// case 11: +// sesAttrsBytes = commState.getByteArray("sesAttrsBytes"); +// +// if (!commState.lastRead()) +// return false; +// +// commState.idx++; +// +// case 12: +// sesFullSup = commState.getBoolean("sesFullSup"); +// +// if (!commState.lastRead()) +// return false; +// +// commState.idx++; +// +// case 13: +// sesId = commState.getGridUuid("sesId"); +// +// if (!commState.lastRead()) +// return false; +// +// commState.idx++; +// +// case 14: +// siblingsBytes = commState.getByteArray("siblingsBytes"); +// +// if (!commState.lastRead()) +// return false; +// +// commState.idx++; +// +// case 15: +// startTaskTime = commState.getLong("startTaskTime"); +// +// if (!commState.lastRead()) +// return false; +// +// commState.idx++; +// +// case 16: +// subjId = commState.getUuid("subjId"); +// +// if (!commState.lastRead()) +// return false; +// +// commState.idx++; +// +// case 17: +// taskClsName = commState.getString("taskClsName"); +// +// if (!commState.lastRead()) +// return false; +// +// commState.idx++; +// +// case 18: +// taskName = commState.getString("taskName"); +// +// if (!commState.lastRead()) +// return false; +// +// commState.idx++; +// +// case 19: +// timeout = commState.getLong("timeout"); +// +// if (!commState.lastRead()) +// return false; +// +// commState.idx++; +// +// case 19: +// if (commState.readSize == -1) { +// commState.readSize = commState.getInt(null); +// +// if (!commState.lastRead()) +// return false; +// } +// +// if (commState.readSize >= 0) { +// if (top == null) +// top = new ArrayList<>(commState.readSize); +// +// for (int i = commState.readItems; i < commState.readSize; i++) { +// UUID _val = commState.getUuid(null); +// +// if (!commState.lastRead()) +// return false; +// +// top.add((UUID)_val); +// +// commState.readItems++; +// } +// } +// +// commState.readSize = -1; +// commState.readItems = 0; +// +// commState.idx++; +// +// case 21: +// userVer = commState.getString("userVer"); +// +// if (!commState.lastRead()) +// return false; +// +// commState.idx++; +// +// } return true; } diff --git a/modules/tools/pom.xml b/modules/tools/pom.xml index 3a01471a098db..deab202d2059d 100644 --- a/modules/tools/pom.xml +++ b/modules/tools/pom.xml @@ -41,12 +41,6 @@ - - - - - - org.jodd jodd-lagarto diff --git a/modules/tools/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java b/modules/tools/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java deleted file mode 100644 index fdd999146cca6..0000000000000 --- a/modules/tools/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java +++ /dev/null @@ -1,1127 +0,0 @@ -///* @java.file.header */ -// -///* _________ _____ __________________ _____ -// * __ ____/___________(_)______ /__ ____/______ ____(_)_______ -// * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ -// * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / -// * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ -// */ -// -//package org.apache.ignite.codegen; -// -//import com.sun.istack.internal.*; -//import org.apache.ignite.internal.*; -//import org.apache.ignite.internal.processors.cache.*; -//import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.*; -//import org.apache.ignite.internal.processors.cache.version.*; -//import org.apache.ignite.internal.processors.clock.*; -//import org.apache.ignite.internal.util.*; -//import org.apache.ignite.internal.util.direct.*; -//import org.apache.ignite.internal.util.typedef.internal.*; -//import org.apache.ignite.lang.*; -// -//import java.io.*; -//import java.lang.reflect.*; -//import java.net.*; -//import java.nio.*; -//import java.util.*; -// -//import static java.lang.reflect.Modifier.*; -// -///** -// * Direct marshallable code generator. -// */ -//public class CommunicationMessageCodeGenerator { -// /** */ -// private static final Comparator FIELD_CMP = new Comparator() { -// @Override public int compare(Field f1, Field f2) { -// int ver1 = 0; -// -// GridDirectVersion verAnn1 = f1.getAnnotation(GridDirectVersion.class); -// -// if (verAnn1 != null) { -// ver1 = verAnn1.value(); -// -// assert ver1 > 0; -// } -// -// int ver2 = 0; -// -// GridDirectVersion verAnn2 = f2.getAnnotation(GridDirectVersion.class); -// -// if (verAnn2 != null) { -// ver2 = verAnn2.value(); -// -// assert ver2 > 0; -// } -// -// return ver1 < ver2 ? -1 : ver1 > ver2 ? 1 : f1.getName().compareTo(f2.getName()); -// } -// }; -// -// /** */ -// private static final String SRC_DIR = U.getGridGainHome() + "/modules/core/src/main/java"; -// -// /** */ -// private static final Class BASE_CLS = GridTcpCommunicationMessageAdapter.class; -// -// /** */ -// private static final String EMPTY = ""; -// -// /** */ -// private static final String TAB = " "; -// -// /** */ -// private static final String COMM_STATE_VAR = "commState"; -// -// /** */ -// private static final String BUF_VAR = "buf"; -// -// /** */ -// private static final String STATE_VAR = COMM_STATE_VAR + "." + "idx"; -// -// /** */ -// private static final String TYPE_WRITTEN_VAR = COMM_STATE_VAR + "." + "typeWritten"; -// -// /** */ -// private static final String IT_VAR = COMM_STATE_VAR + "." + "it"; -// -// /** */ -// private static final String CUR_VAR = COMM_STATE_VAR + "." + "cur"; -// -// /** */ -// private static final String KEY_DONE_VAR = COMM_STATE_VAR + "." + "keyDone"; -// -// /** */ -// private static final String READ_SIZE_VAR = COMM_STATE_VAR + "." + "readSize"; -// -// /** */ -// private static final String READ_ITEMS_VAR = COMM_STATE_VAR + "." + "readItems"; -// -// /** */ -// private static final String DFLT_LOC_VAR = "_val"; -// -// /** */ -// private final Collection write = new ArrayList<>(); -// -// /** */ -// private final Collection read = new ArrayList<>(); -// -// /** */ -// private final Collection clone = new ArrayList<>(); -// -// /** */ -// private final Collection clone0 = new ArrayList<>(); -// -// /** */ -// private final Map, Integer> fieldCnt = new HashMap<>(); -// -// /** */ -// private List fields; -// -// /** */ -// private int indent; -// -// /** -// * @param args Arguments. -// */ -// public static void main(String[] args) { -// CommunicationMessageCodeGenerator gen = new CommunicationMessageCodeGenerator(); -// -// try { -// gen.generateAll(true); -// } -// catch (Exception e) { -// e.printStackTrace(); -// } -// } -// -// /** -// * Generates code for all classes. -// * -// * @param write Whether to write to file. -// * @throws Exception In case of error. -// */ -// public void generateAll(boolean write) throws Exception { -// Collection> classes = classes(); -// -// byte type = 0; -// -// for (Class cls : classes) { -// boolean isAbstract = Modifier.isAbstract(cls.getModifiers()); -// -// System.out.println("Processing class: " + cls.getName() + (isAbstract ? " (abstract)" : "")); -// -// if (write) -// generateAndWrite(cls, isAbstract ? -1 : type++); -// else -// generate(cls); -// } -// -//// type = 0; -//// -//// for (Class cls : classes) { -//// if (Modifier.isAbstract(cls.getModifiers())) -//// continue; -//// -//// System.out.println("case " + type++ + ":"); -//// System.out.println(" return new " + cls.getSimpleName() + "();"); -//// System.out.println(); -//// } -// } -// -// /** -// * Generates code for provided class and writes it to source file. -// * Note: this method must be called only from {@code generateAll(boolean)} -// * and only with updating {@code CLASSES_ORDER_FILE} and other auto generated files. -// * -// * @param cls Class. -// * @throws Exception In case of error. -// */ -// @SuppressWarnings("ConstantConditions") -// private void generateAndWrite(Class cls, byte type) throws Exception { -// assert cls != null; -// -// generate(cls); -// -// File file = new File(SRC_DIR, cls.getName().replace('.', File.separatorChar) + ".java"); -// -// if (!file.exists() || !file.isFile()) { -// System.out.println(" Source file not found: " + file.getPath()); -// -// return; -// } -// -// Collection src = new ArrayList<>(); -// -// BufferedReader rdr = null; -// -// try { -// rdr = new BufferedReader(new FileReader(file)); -// -// String line; -// boolean skip = false; -// -// boolean writeFound = false; -// boolean readFound = false; -// boolean cloneFound = false; -// boolean clone0Found = false; -// -// while ((line = rdr.readLine()) != null) { -// if (!skip) { -// src.add(line); -// -// if (line.contains("public boolean writeTo(ByteBuffer buf)")) { -// src.addAll(write); -// -// skip = true; -// -// writeFound = true; -// } -// else if (line.contains("public boolean readFrom(ByteBuffer buf)")) { -// src.addAll(read); -// -// skip = true; -// -// readFound = true; -// } -//// else if (type >= 0 && line.contains("public byte directType()")) { -//// src.add(TAB + TAB + "return " + type + ';'); -//// -//// skip = true; -//// } -// else if (line.contains("public GridTcpCommunicationMessageAdapter clone()")) { -// src.addAll(clone); -// -// skip = true; -// -// cloneFound = true; -// } -// else if (line.contains("protected void clone0(GridTcpCommunicationMessageAdapter _msg)")) { -// src.addAll(clone0); -// -// skip = true; -// -// clone0Found = true; -// } -// } -// else if (line.startsWith(TAB + "}")) { -// src.add(line); -// -// skip = false; -// } -// } -// -// if (!writeFound) -// System.out.println(" writeTo method doesn't exist."); -// -// if (!readFound) -// System.out.println(" readFrom method doesn't exist."); -// -// if (!cloneFound) -// System.out.println(" clone method doesn't exist."); -// -// if (!clone0Found) -// System.out.println(" clone0 method doesn't exist."); -// } -// finally { -// if (rdr != null) -// rdr.close(); -// } -// -// BufferedWriter wr = null; -// -// try { -// wr = new BufferedWriter(new FileWriter(file)); -// -// for (String line : src) -// wr.write(line + '\n'); -// } -// finally { -// if (wr != null) -// wr.close(); -// } -// } -// -// /** -// * Generates code for provided class. -// * -// * @param cls Class. -// * @throws Exception In case of error. -// */ -// public void generate(Class cls) throws Exception { -// assert cls != null; -// -// write.clear(); -// read.clear(); -// clone.clear(); -// clone0.clear(); -// -// fields = new ArrayList<>(); -// -// Field[] declaredFields = cls.getDeclaredFields(); -// -// for (Field field : declaredFields) { -// int mod = field.getModifiers(); -// -// if (!isStatic(mod) && !isTransient(mod) && !field.isAnnotationPresent(GridDirectTransient.class)) -// fields.add(field); -// } -// -// Collections.sort(fields, FIELD_CMP); -// -// indent = 2; -// -// boolean hasSuper = cls.getSuperclass() != BASE_CLS; -// -// String clsName = cls.getSimpleName(); -// -// if (!Modifier.isAbstract(cls.getModifiers())) { -// clone.add(builder().a(clsName).a(" _clone = new ").a(clsName).a("();").toString()); -// clone.add(EMPTY); -// clone.add(builder().a("clone0(_clone);").toString()); -// clone.add(EMPTY); -// clone.add(builder().a("return _clone;").toString()); -// } -// -// if (hasSuper) { -// clone0.add(builder().a("super.clone0(_msg);").toString()); -// clone0.add(EMPTY); -// } -// -// Collection cloningFields = new ArrayList<>(declaredFields.length); -// -// for (Field field: declaredFields) -// if (!isStatic(field.getModifiers())) -// cloningFields.add(field); -// -// if (!cloningFields.isEmpty()) { -// clone0.add(builder().a(clsName).a(" _clone = (").a(clsName).a(")_msg;").toString()); -// clone0.add(EMPTY); -// -// for (Field field : cloningFields) { -// String name = field.getName(); -// Class type = field.getType(); -// -// String res = name; -// -// if (BASE_CLS.isAssignableFrom(type)) -// res = name + " != null ? (" + type.getSimpleName() + ")" + name + ".clone() : null"; -// -// clone0.add(builder().a("_clone.").a(name).a(" = ").a(res).a(";").toString()); -// } -// } -// -// start(write, hasSuper ? "writeTo" : null, true); -// start(read, hasSuper ? "readFrom" : null, false); -// -// indent++; -// -// int state = startState(cls); -// -// for (Field field : fields) -// processField(field, state++); -// -// indent--; -// -// finish(write); -// finish(read); -// } -// -// /** -// * @param cls Message class. -// * @return Start state. -// */ -// private int startState(Class cls) { -// assert cls != null; -// -// Class superCls = cls.getSuperclass(); -// -// Integer state = fieldCnt.get(superCls); -// -// if (state != null) -// return state; -// -// state = 0; -// -// while (cls.getSuperclass() != BASE_CLS) { -// cls = cls.getSuperclass(); -// -// for (Field field : cls.getDeclaredFields()) { -// int mod = field.getModifiers(); -// -// if (!isStatic(mod) && !isTransient(mod) && !field.isAnnotationPresent(GridDirectTransient.class)) -// state++; -// } -// } -// -// fieldCnt.put(superCls, state); -// -// return state; -// } -// -// /** -// * @param code Code lines. -// * @param superMtd Super class method name. -// * @param writeType Whether to write message type. -// */ -// private void start(Collection code, @Nullable String superMtd, boolean writeType) { -// assert code != null; -// -// code.add(builder().a(COMM_STATE_VAR).a(".setBuffer(").a(BUF_VAR).a(");").toString()); -// code.add(EMPTY); -// -// if (superMtd != null) { -// returnFalseIfFailed(code, "super." + superMtd, BUF_VAR); -// -// code.add(EMPTY); -// } -// -// if (writeType) { -// code.add(builder().a("if (!").a(TYPE_WRITTEN_VAR).a(") {").toString()); -// -// indent++; -// -// returnFalseIfFailed(code, COMM_STATE_VAR + ".putByte", "null", "directType()"); -// -// code.add(EMPTY); -// code.add(builder().a(TYPE_WRITTEN_VAR).a(" = true;").toString()); -// -// indent--; -// -// code.add(builder().a("}").toString()); -// code.add(EMPTY); -// } -// -// if (!fields.isEmpty()) -// code.add(builder().a("switch (").a(STATE_VAR).a(") {").toString()); -// } -// -// /** -// * @param code Code lines. -// */ -// private void finish(Collection code) { -// assert code != null; -// -// if (!fields.isEmpty()) { -// code.add(builder().a("}").toString()); -// code.add(EMPTY); -// } -// -// code.add(builder().a("return true;").toString()); -// } -// -// /** -// * @param field Field. -// * @param opt Case option. -// */ -// private void processField(Field field, int opt) { -// assert field != null; -// assert opt >= 0; -// -// GridDirectCollection colAnn = field.getAnnotation(GridDirectCollection.class); -// GridDirectMap mapAnn = field.getAnnotation(GridDirectMap.class); -// -// if (colAnn == null && Collection.class.isAssignableFrom(field.getType())) -// throw new IllegalStateException("@GridDirectCollection annotation is not provided for field: " + -// field.getName()); -// -// if (mapAnn == null && Map.class.isAssignableFrom(field.getType())) -// throw new IllegalStateException("@GridDirectMap annotation is not provided for field: " + field.getName()); -// -// writeField(field, opt, colAnn, mapAnn); -// readField(field, opt, colAnn, mapAnn); -// } -// -// /** -// * @param field Field. -// * @param opt Case option. -// * @param colAnn Collection annotation. -// * @param mapAnn Map annotation. -// */ -// private void writeField(Field field, int opt, @Nullable GridDirectCollection colAnn, -// @Nullable GridDirectMap mapAnn) { -// assert field != null; -// assert opt >= 0; -// -// write.add(builder().a("case ").a(opt).a(":").toString()); -// -// indent++; -// -// returnFalseIfWriteFailed(field.getType(), field.getName(), colAnn != null ? colAnn.value() : null, -// mapAnn != null ? mapAnn.keyType() : null, mapAnn != null ? mapAnn.valueType() : null, false); -// -// write.add(EMPTY); -// write.add(builder().a(STATE_VAR).a("++;").toString()); -// write.add(EMPTY); -// -// indent--; -// } -// -// /** -// * @param field Field. -// * @param opt Case option. -// * @param colAnn Collection annotation. -// * @param mapAnn Map annotation. -// */ -// private void readField(Field field, int opt, @Nullable GridDirectCollection colAnn, -// @Nullable GridDirectMap mapAnn) { -// assert field != null; -// assert opt >= 0; -// -// read.add(builder().a("case ").a(opt).a(":").toString()); -// -// indent++; -// -// returnFalseIfReadFailed(field.getType(), field.getName(), colAnn != null ? colAnn.value() : null, -// mapAnn != null ? mapAnn.keyType() : null, mapAnn != null ? mapAnn.valueType() : null, false); -// -// read.add(EMPTY); -// read.add(builder().a(STATE_VAR).a("++;").toString()); -// read.add(EMPTY); -// -// indent--; -// } -// -// /** -// * @param type Field type. -// * @param name Field name. -// * @param colItemType Collection item type. -// * @param mapKeyType Map key type. -// * @param mapValType Map key value. -// * @param raw Raw write flag. -// */ -// private void returnFalseIfWriteFailed(Class type, String name, @Nullable Class colItemType, -// @Nullable Class mapKeyType, @Nullable Class mapValType, boolean raw) { -// assert type != null; -// assert name != null; -// -// String field = raw ? "null" : '"' + name + '"'; -// -// if (type == byte.class) -// returnFalseIfFailed(write, COMM_STATE_VAR + ".putByte", field, name); -// else if (type == short.class) -// returnFalseIfFailed(write, COMM_STATE_VAR + ".putShort", field, name); -// else if (type == int.class) -// returnFalseIfFailed(write, COMM_STATE_VAR + ".putInt", field, name); -// else if (type == long.class) -// returnFalseIfFailed(write, COMM_STATE_VAR + ".putLong", field, name); -// else if (type == float.class) -// returnFalseIfFailed(write, COMM_STATE_VAR + ".putFloat", field, name); -// else if (type == double.class) -// returnFalseIfFailed(write, COMM_STATE_VAR + ".putDouble", field, name); -// else if (type == char.class) -// returnFalseIfFailed(write, COMM_STATE_VAR + ".putChar", field, name); -// else if (type == boolean.class) -// returnFalseIfFailed(write, COMM_STATE_VAR + ".putBoolean", field, name); -// else if (type == byte[].class) -// returnFalseIfFailed(write, COMM_STATE_VAR + ".putByteArray", field, name); -// else if (type == short[].class) -// returnFalseIfFailed(write, COMM_STATE_VAR + ".putShortArray", field, name); -// else if (type == int[].class) -// returnFalseIfFailed(write, COMM_STATE_VAR + ".putIntArray", field, name); -// else if (type == long[].class) -// returnFalseIfFailed(write, COMM_STATE_VAR + ".putLongArray", field, name); -// else if (type == float[].class) -// returnFalseIfFailed(write, COMM_STATE_VAR + ".putFloatArray", field, name); -// else if (type == double[].class) -// returnFalseIfFailed(write, COMM_STATE_VAR + ".putDoubleArray", field, name); -// else if (type == char[].class) -// returnFalseIfFailed(write, COMM_STATE_VAR + ".putCharArray", field, name); -// else if (type == boolean[].class) -// returnFalseIfFailed(write, COMM_STATE_VAR + ".putBooleanArray", field, name); -// else if (type == UUID.class) -// returnFalseIfFailed(write, COMM_STATE_VAR + ".putUuid", field, name); -// else if (type == ByteBuffer.class) -// returnFalseIfFailed(write, COMM_STATE_VAR + ".putByteBuffer", field, name); -// else if (type == IgniteUuid.class) -// returnFalseIfFailed(write, COMM_STATE_VAR + ".putGridUuid", field, name); -// else if (type == GridClockDeltaVersion.class) -// returnFalseIfFailed(write, COMM_STATE_VAR + ".putClockDeltaVersion", field, name); -// else if (type == GridByteArrayList.class) -// returnFalseIfFailed(write, COMM_STATE_VAR + ".putByteArrayList", field, name); -// else if (type == GridLongList.class) -// returnFalseIfFailed(write, COMM_STATE_VAR + ".putLongList", field, name); -// else if (type == GridCacheVersion.class) -// returnFalseIfFailed(write, COMM_STATE_VAR + ".putCacheVersion", field, name); -// else if (type == GridDhtPartitionExchangeId.class) -// returnFalseIfFailed(write, COMM_STATE_VAR + ".putDhtPartitionExchangeId", field, name); -// else if (type == GridCacheValueBytes.class) -// returnFalseIfFailed(write, COMM_STATE_VAR + ".putValueBytes", field, name); -// //else if (type == GridDrInternalRequestEntry.class) -// // returnFalseIfFailed(write, COMM_STATE_VAR + ".putDrInternalRequestEntry", field, name); -// else if (type == String.class) -// returnFalseIfFailed(write, COMM_STATE_VAR + ".putString", field, name); -// else if (type == BitSet.class) -// returnFalseIfFailed(write, COMM_STATE_VAR + ".putBitSet", field, name); -// else if (type.isEnum()) -// returnFalseIfFailed(write, COMM_STATE_VAR + ".putEnum", field, name); -// else if (BASE_CLS.isAssignableFrom(type)) -// returnFalseIfFailed(write, COMM_STATE_VAR + ".putMessage", field, name); -// else if (type.isArray() || Collection.class.isAssignableFrom(type)) { -// boolean isArr = type.isArray(); -// -// if (isArr) -// colItemType = type.getComponentType(); -// -// assert colItemType != null; -// -// write.add(builder().a("if (").a(name).a(" != null) {").toString()); -// -// indent++; -// -// write.add(builder().a("if (").a(IT_VAR).a(" == null) {").toString()); -// -// indent++; -// -// returnFalseIfFailed(write, COMM_STATE_VAR + ".putInt", "null", name + "." + (isArr ? "length" : "size()")); -// -// write.add(EMPTY); -// write.add(builder().a(IT_VAR).a(" = ").a(isArr ? "arrayIterator(" + name + ")" : name + ".iterator()"). -// a(";").toString()); -// -// indent--; -// -// write.add(builder().a("}").toString()); -// write.add(EMPTY); -// write.add(builder().a("while (").a(IT_VAR).a(".hasNext() || ").a(CUR_VAR).a(" != NULL").a(") {"). -// toString()); -// -// indent++; -// -// write.add(builder().a("if (").a(CUR_VAR).a(" == NULL)").toString()); -// -// indent++; -// -// write.add(builder().a(CUR_VAR).a(" = ").a(IT_VAR).a(".next();").toString()); -// -// indent--; -// -// write.add(EMPTY); -// -// returnFalseIfWriteFailed(colItemType, "(" + colItemType.getSimpleName() + ")" + CUR_VAR, -// null, null, null, true); -// -// write.add(EMPTY); -// write.add(builder().a(CUR_VAR).a(" = NULL;").toString()); -// -// indent--; -// -// write.add(builder().a("}").toString()); -// write.add(EMPTY); -// write.add(builder().a(IT_VAR).a(" = null;").toString()); -// -// indent--; -// -// write.add(builder().a("} else {").toString()); -// -// indent++; -// -// returnFalseIfFailed(write, COMM_STATE_VAR + ".putInt", "null", "-1"); -// -// indent--; -// -// write.add(builder().a("}").toString()); -// } -// else if (Map.class.isAssignableFrom(type)) { -// assert mapKeyType != null; -// assert mapValType != null; -// -// write.add(builder().a("if (").a(name).a(" != null) {").toString()); -// -// indent++; -// -// write.add(builder().a("if (").a(IT_VAR).a(" == null) {").toString()); -// -// indent++; -// -// returnFalseIfFailed(write, COMM_STATE_VAR + ".putInt", "null", name + ".size()"); -// -// write.add(EMPTY); -// write.add(builder().a(IT_VAR).a(" = ").a(name).a(".entrySet().iterator();").toString()); -// -// indent--; -// -// write.add(builder().a("}").toString()); -// write.add(EMPTY); -// write.add(builder().a("while (").a(IT_VAR).a(".hasNext() || ").a(CUR_VAR).a(" != NULL").a(") {"). -// toString()); -// -// indent++; -// -// write.add(builder().a("if (").a(CUR_VAR).a(" == NULL)").toString()); -// -// indent++; -// -// write.add(builder().a(CUR_VAR).a(" = ").a(IT_VAR).a(".next();").toString()); -// -// indent--; -// -// String entryType = "Map.Entry<" + U.box(mapKeyType).getSimpleName() + ", " + -// U.box(mapValType).getSimpleName() + ">"; -// -// write.add(EMPTY); -// write.add(builder().a(entryType).a(" e = (").a(entryType).a(")").a(CUR_VAR).a(";").toString()); -// write.add(EMPTY); -// write.add(builder().a("if (!").a(KEY_DONE_VAR).a(") {").toString()); -// -// indent++; -// -// returnFalseIfWriteFailed(mapKeyType, "e.getKey()", null, null, null, true); -// -// write.add(EMPTY); -// write.add(builder().a(KEY_DONE_VAR).a(" = true;").toString()); -// -// indent--; -// -// write.add(builder().a("}").toString()); -// write.add(EMPTY); -// -// returnFalseIfWriteFailed(mapValType, "e.getValue()", null, null, null, true); -// -// write.add(EMPTY); -// write.add(builder().a(KEY_DONE_VAR).a(" = false;").toString()); -// write.add(EMPTY); -// write.add(builder().a(CUR_VAR).a(" = NULL;").toString()); -// -// indent--; -// -// write.add(builder().a("}").toString()); -// write.add(EMPTY); -// write.add(builder().a(IT_VAR).a(" = null;").toString()); -// -// indent--; -// -// write.add(builder().a("} else {").toString()); -// -// indent++; -// -// returnFalseIfFailed(write, COMM_STATE_VAR + ".putInt", "null", "-1"); -// -// indent--; -// -// write.add(builder().a("}").toString()); -// } -// else -// throw new IllegalStateException("Unsupported type: " + type); -// } -// -// /** -// * @param type Field type. -// * @param name Field name. -// * @param colItemType Collection item type. -// * @param mapKeyType Map key type. -// * @param mapValType Map value type. -// * @param raw Raw read flag. -// */ -// private void returnFalseIfReadFailed(Class type, @Nullable String name, @Nullable Class colItemType, -// @Nullable Class mapKeyType, @Nullable Class mapValType, boolean raw) { -// assert type != null; -// -// String field = raw ? "null" : '"' + name + '"'; -// -// String retType = type.getSimpleName(); -// -// if (type == byte.class) -// returnFalseIfReadFailed("byte", name, null, COMM_STATE_VAR + ".getByte", field, false); -// else if (type == short.class) -// returnFalseIfReadFailed("short", name, null, COMM_STATE_VAR + ".getShort", field, false); -// else if (type == int.class) -// returnFalseIfReadFailed("int", name, null, COMM_STATE_VAR + ".getInt", field, false); -// else if (type == long.class) -// returnFalseIfReadFailed("long", name, null, COMM_STATE_VAR + ".getLong", field, false); -// else if (type == float.class) -// returnFalseIfReadFailed("float", name, null, COMM_STATE_VAR + ".getFloat", field, false); -// else if (type == double.class) -// returnFalseIfReadFailed("double", name, null, COMM_STATE_VAR + ".getDouble", field, false); -// else if (type == char.class) -// returnFalseIfReadFailed("char", name, null, COMM_STATE_VAR + ".getChar", field, false); -// else if (type == boolean.class) -// returnFalseIfReadFailed("boolean", name, null, COMM_STATE_VAR + ".getBoolean", field, false); -// else if (type == byte[].class) -// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getByteArray", field, false); -// else if (type == short[].class) -// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getShortArray", field, false); -// else if (type == int[].class) -// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getIntArray", field, false); -// else if (type == long[].class) -// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getLongArray", field, false); -// else if (type == float[].class) -// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getFloatArray", field, false); -// else if (type == double[].class) -// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getDoubleArray", field, false); -// else if (type == char[].class) -// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getCharArray", field, false); -// else if (type == boolean[].class) -// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getBooleanArray", field, false); -// else if (type == UUID.class) -// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getUuid", field, false); -// else if (type == ByteBuffer.class) -// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getByteBuffer", field, false); -// else if (type == IgniteUuid.class) -// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getGridUuid", field, false); -// else if (type == GridClockDeltaVersion.class) -// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getClockDeltaVersion", field, false); -// else if (type == GridLongList.class) -// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getLongList", field, false); -// else if (type == GridByteArrayList.class) -// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getByteArrayList", field, false); -// else if (type == GridCacheVersion.class) -// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getCacheVersion", field, false); -// else if (type == GridDhtPartitionExchangeId.class) -// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getDhtPartitionExchangeId", field, false); -// else if (type == GridCacheValueBytes.class) -// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getValueBytes", field, false); -// //else if (type == GridDrInternalRequestEntry.class) -// // returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getDrInternalRequestEntry", field, false); -// else if (type == String.class) -// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getString", field, false); -// else if (type == BitSet.class) -// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getBitSet", field, false); -// else if (type.isEnum()) { -// assert name != null; -// -// returnFalseIfReadFailed("byte", null, name + "0", COMM_STATE_VAR + ".getByte", field, false); -// -// read.add(EMPTY); -// read.add(builder().a(name).a(" = ").a(type.getSimpleName()).a(".fromOrdinal(").a(name).a("0);").toString()); -// } -// else if (BASE_CLS.isAssignableFrom(type)) -// returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getMessage", field, true); -// else if (type.isArray() || Collection.class.isAssignableFrom(type)) { -// assert name != null; -// -// boolean isArr = type.isArray(); -// -// if (isArr) -// colItemType = type.getComponentType(); -// -// assert colItemType != null; -// -// Class colType = Set.class.isAssignableFrom(type) ? HashSet.class : ArrayList.class; -// -// read.add(builder().a("if (").a(READ_SIZE_VAR).a(" == -1) {").toString()); -// -// indent++; -// -// returnFalseIfReadFailed(int.class, READ_SIZE_VAR, null, null, null, true); -// -// indent--; -// -// read.add(builder().a("}").toString()); -// read.add(EMPTY); -// read.add(builder().a("if (").a(READ_SIZE_VAR).a(" >= 0) {").toString()); -// -// indent++; -// -// read.add(builder().a("if (").a(name).a(" == null)").toString()); -// -// indent++; -// -// if (isArr) { -// String val = colItemType.isArray() ? -// colItemType.getComponentType().getSimpleName() + "[" + READ_SIZE_VAR + "][]" : -// colItemType.getSimpleName() + "[" + READ_SIZE_VAR + "]"; -// -// read.add(builder().a(name).a(" = new ").a(val).a(";"). -// toString()); -// } -// else { -// read.add(builder().a(name).a(" = new ").a(colType.getSimpleName()).a("<>(").a(READ_SIZE_VAR).a(");"). -// toString()); -// } -// -// indent--; -// -// read.add(EMPTY); -// read.add(builder().a("for (int i = ").a(READ_ITEMS_VAR).a("; i < ").a(READ_SIZE_VAR).a("; i++) {"). -// toString()); -// -// indent++; -// -// String var = colItemType.isPrimitive() ? colItemType.getSimpleName() + " " + DFLT_LOC_VAR : null; -// -// returnFalseIfReadFailed(colItemType, var, null, null, null, true); -// -// read.add(EMPTY); -// read.add(builder().a(name).a(isArr ? "[i] = " : ".add(").a("(").a(U.box(colItemType).getSimpleName()). -// a(")").a(DFLT_LOC_VAR).a(isArr ? ";" : ");").toString()); -// read.add(EMPTY); -// read.add(builder().a(READ_ITEMS_VAR).a("++;").toString()); -// -// indent--; -// -// read.add(builder().a("}").toString()); -// -// indent--; -// -// read.add(builder().a("}").toString()); -// read.add(EMPTY); -// read.add(builder().a(READ_SIZE_VAR).a(" = -1;").toString()); -// read.add(builder().a(READ_ITEMS_VAR).a(" = 0;").toString()); -// } -// else if (Map.class.isAssignableFrom(type)) { -// assert name != null; -// assert mapKeyType != null; -// assert mapValType != null; -// -// Class mapType = LinkedHashMap.class.isAssignableFrom(type) ? LinkedHashMap.class : HashMap.class; -// -// read.add(builder().a("if (").a(READ_SIZE_VAR).a(" == -1) {").toString()); -// -// indent++; -// -// returnFalseIfReadFailed(int.class, READ_SIZE_VAR, null, null, null, true); -// -// indent--; -// -// read.add(builder().a("}").toString()); -// read.add(EMPTY); -// read.add(builder().a("if (").a(READ_SIZE_VAR).a(" >= 0) {").toString()); -// -// indent++; -// -// read.add(builder().a("if (").a(name).a(" == null)").toString()); -// -// indent++; -// -// read.add(builder().a(name).a(" = new ").a(mapType.getSimpleName()).a("<>(").a(READ_SIZE_VAR).a(", 1.0f);"). -// toString()); -// -// indent--; -// -// read.add(EMPTY); -// read.add(builder().a("for (int i = ").a(READ_ITEMS_VAR).a("; i < ").a(READ_SIZE_VAR).a("; i++) {"). -// toString()); -// -// indent++; -// -// read.add(builder().a("if (!").a(KEY_DONE_VAR).a(") {").toString()); -// -// indent++; -// -// String var = mapKeyType.isPrimitive() ? mapKeyType.getSimpleName() + " " + DFLT_LOC_VAR : null; -// -// returnFalseIfReadFailed(mapKeyType, var, null, null, null, true); -// -// read.add(EMPTY); -// read.add(builder().a(CUR_VAR).a(" = ").a(DFLT_LOC_VAR).a(";").toString()); -// read.add(builder().a(KEY_DONE_VAR).a(" = true;").toString()); -// -// indent--; -// -// read.add(builder().a("}").toString()); -// read.add(EMPTY); -// -// var = mapValType.isPrimitive() ? mapValType.getSimpleName() + " " + DFLT_LOC_VAR : null; -// -// returnFalseIfReadFailed(mapValType, var, null, null, null, true); -// -// read.add(EMPTY); -// read.add(builder().a(name).a(".put((").a(U.box(mapKeyType).getSimpleName()).a(")").a(CUR_VAR). -// a(", ").a(DFLT_LOC_VAR).a(");").toString()); -// read.add(EMPTY); -// read.add(builder().a(KEY_DONE_VAR).a(" = false;").toString()); -// read.add(EMPTY); -// read.add(builder().a(READ_ITEMS_VAR).a("++;").toString()); -// -// indent--; -// -// read.add(builder().a("}").toString()); -// -// indent--; -// -// read.add(builder().a("}").toString()); -// read.add(EMPTY); -// read.add(builder().a(READ_SIZE_VAR).a(" = -1;").toString()); -// read.add(builder().a(READ_ITEMS_VAR).a(" = 0;").toString()); -// read.add(builder().a(CUR_VAR).a(" = null;").toString()); -// } -// else -// throw new IllegalStateException("Unsupported type: " + type); -// } -// -// /** -// * @param retType Return type. -// * @param var Variable name. -// * @param locVar Local variable name. -// * @param mtd Method name. -// * @param arg Method argument. -// * @param cast Whether cast is needed. -// */ -// private void returnFalseIfReadFailed(String retType, @Nullable String var, @Nullable String locVar, String mtd, -// @Nullable String arg, boolean cast) { -// assert retType != null; -// assert mtd != null; -// -// if (var == null) -// var = retType + " " + (locVar != null ? locVar : DFLT_LOC_VAR); -// -// read.add(builder().a(var).a(" = ").a(cast ? "(" + retType + ")" : "").a(mtd). -// a(arg != null ? "(" + arg + ");" : "();").toString()); -// read.add(EMPTY); -// -// read.add(builder().a("if (!").a(COMM_STATE_VAR).a(".lastRead())").toString()); -// -// indent++; -// -// read.add(builder().a("return false;").toString()); -// -// indent--; -// } -// -// /** -// * @param code Code lines. -// * @param accessor Field or method name. -// * @param args Method arguments. -// */ -// private void returnFalseIfFailed(Collection code, String accessor, @Nullable String... args) { -// assert code != null; -// assert accessor != null; -// -// String argsStr = ""; -// -// if (args != null && args.length > 0) { -// for (String arg : args) -// argsStr += arg + ", "; -// -// argsStr = argsStr.substring(0, argsStr.length() - 2); -// } -// -// code.add(builder().a("if (!").a(accessor).a("(" + argsStr + ")").a(")").toString()); -// -// indent++; -// -// code.add(builder().a("return false;").toString()); -// -// indent--; -// } -// -// /** -// * Creates new builder with correct indent. -// * -// * @return Builder. -// */ -// private SB builder() { -// assert indent > 0; -// -// SB sb = new SB(); -// -// for (int i = 0; i < indent; i++) -// sb.a(TAB); -// -// return sb; -// } -// -// /** -// * Gets all direct marshallable classes. -// * First classes will be classes from {@code classesOrder} with same order -// * as ordered values. Other classes will be at the end and ordered by name -// * (with package prefix). -// * That orders need for saving {@code directType} value. -// * -// * @return Classes. -// * @throws Exception In case of error. -// */ -// private Collection> classes() throws Exception { -// Collection> col = new TreeSet<>( -// new Comparator>() { -// @Override public int compare(Class c1, -// Class c2) { -// return c1.getName().compareTo(c2.getName()); -// } -// }); -// -// URLClassLoader ldr = (URLClassLoader)getClass().getClassLoader(); -// -// for (URL url : ldr.getURLs()) { -// File file = new File(url.toURI()); -// -// int prefixLen = file.getPath().length() + 1; -// -// processFile(file, ldr, prefixLen, col); -// } -// -// return col; -// } -// -// /** -// * Recursively process provided file or directory. -// * -// * @param file File. -// * @param ldr Class loader. -// * @param prefixLen Path prefix length. -// * @param col Classes. -// * @throws Exception In case of error. -// */ -// private void processFile(File file, ClassLoader ldr, int prefixLen, -// Collection> col) throws Exception { -// assert file != null; -// assert ldr != null; -// assert prefixLen > 0; -// assert col != null; -// -// if (!file.exists()) -// throw new FileNotFoundException("File doesn't exist: " + file); -// -// if (file.isDirectory()) { -// for (File f : file.listFiles()) -// processFile(f, ldr, prefixLen, col); -// } -// else { -// assert file.isFile(); -// -// String path = file.getPath(); -// -// if (path.endsWith(".class")) { -// String clsName = path.substring(prefixLen, path.length() - 6).replace(File.separatorChar, '.'); -// -// Class cls = Class.forName(clsName, false, ldr); -// -// if (cls.getDeclaringClass() == null && cls.getEnclosingClass() == null && -// !BASE_CLS.equals(cls) && BASE_CLS.isAssignableFrom(cls)) -// col.add((Class)cls); -// } -// } -// } -//} diff --git a/pom.xml b/pom.xml index 39803671343ca..25d64e8a725c4 100644 --- a/pom.xml +++ b/pom.xml @@ -116,6 +116,7 @@ modules/slf4j modules/jcl modules/schema-load + modules/codegen From a8522ac62ffcbb53034de5653ecff071f0ca7af7 Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Thu, 5 Feb 2015 11:42:03 -0800 Subject: [PATCH 24/95] IGNITE-61 - Fixed compilation --- .../ignite/codegen/CommunicationMessageCodeGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java index 469b5751ae27f..3649830cc955d 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java @@ -9,7 +9,6 @@ package org.apache.ignite.codegen; -import com.sun.istack.internal.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.*; @@ -19,6 +18,7 @@ import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.jetbrains.annotations.*; import java.io.*; import java.lang.reflect.*; From e9e180cbd1cb7b4125b4dcf846c080fa048d600f Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Thu, 5 Feb 2015 11:45:42 -0800 Subject: [PATCH 25/95] IGNITE-61 - Direct marshalling --- .../CommunicationMessageCodeGenerator.java | 10 +- .../internal/GridJobExecuteRequest.java | 852 +++++++++--------- 2 files changed, 424 insertions(+), 438 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java index 3649830cc955d..c833c704c6ea2 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java @@ -129,7 +129,9 @@ public static void main(String[] args) { CommunicationMessageCodeGenerator gen = new CommunicationMessageCodeGenerator(); try { - gen.generateAll(true); + gen.generateAndWrite(GridJobExecuteRequest.class); + + //gen.generateAll(true); } catch (Exception e) { e.printStackTrace(); @@ -145,15 +147,13 @@ public static void main(String[] args) { public void generateAll(boolean write) throws Exception { Collection> classes = classes(); - byte type = 0; - for (Class cls : classes) { boolean isAbstract = Modifier.isAbstract(cls.getModifiers()); System.out.println("Processing class: " + cls.getName() + (isAbstract ? " (abstract)" : "")); if (write) - generateAndWrite(cls, isAbstract ? -1 : type++); + generateAndWrite(cls); else generate(cls); } @@ -179,7 +179,7 @@ public void generateAll(boolean write) throws Exception { * @throws Exception In case of error. */ @SuppressWarnings("ConstantConditions") - private void generateAndWrite(Class cls, byte type) throws Exception { + private void generateAndWrite(Class cls) throws Exception { assert cls != null; generate(cls); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java index 20e4597b997ec..aac47f9445170 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java @@ -456,202 +456,196 @@ public UUID getSubjectId() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { -// commState.setBuffer(buf); -// -// if (!commState.typeWritten) { -// if (!commState.putByte(null, directType())) -// return false; -// -// commState.typeWritten = true; -// } -// -// switch (commState.idx) { -// case 0: -// if (!commState.putGridUuid("clsLdrId", clsLdrId)) -// return false; -// -// commState.idx++; -// -// case 1: -// if (!commState.putString("cpSpi", cpSpi)) -// return false; -// -// commState.idx++; -// -// case 2: -// if (!commState.putLong("createTime", createTime)) -// return false; -// -// commState.idx++; -// -// case 3: -// if (!commState.putEnum("depMode", depMode)) -// return false; -// -// commState.idx++; -// -// case 4: -// if (!commState.putBoolean("dynamicSiblings", dynamicSiblings)) -// return false; -// -// commState.idx++; -// -// case 5: -// if (!commState.putBoolean("forceLocDep", forceLocDep)) -// return false; -// -// commState.idx++; -// -// case 6: -// if (!commState.putBoolean("internal", internal)) -// return false; -// -// commState.idx++; -// -// case 7: -// if (!commState.putByteArray("jobAttrsBytes", jobAttrsBytes)) -// return false; -// -// commState.idx++; -// -// case 8: -// if (!commState.putByteArray("jobBytes", jobBytes)) -// return false; -// -// commState.idx++; -// -// case 9: -// if (!commState.putGridUuid("jobId", jobId)) -// return false; -// -// commState.idx++; -// -// case 9: -// if (ldrParticipants != null) { -// if (commState.it == null) { -// if (!commState.putInt(null, ldrParticipants.size())) -// return false; -// -// commState.it = ldrParticipants.entrySet().iterator(); -// } -// -// while (commState.it.hasNext() || commState.cur != NULL) { -// if (commState.cur == NULL) -// commState.cur = commState.it.next(); -// -// Map.Entry e = (Map.Entry)commState.cur; -// -// if (!commState.keyDone) { -// if (!commState.putUuid(null, e.getKey())) -// return false; -// -// commState.keyDone = true; -// } -// -// if (!commState.putGridUuid(null, e.getValue())) -// return false; -// -// commState.keyDone = false; -// -// commState.cur = NULL; -// } -// -// commState.it = null; -// } else { -// if (!commState.putInt(null, -1)) -// return false; -// } -// -// commState.idx++; -// -// case 11: -// if (!commState.putByteArray("sesAttrsBytes", sesAttrsBytes)) -// return false; -// -// commState.idx++; -// -// case 12: -// if (!commState.putBoolean(sesFullSup)) -// return false; -// -// commState.idx++; -// -// case 13: -// if (!commState.putGridUuid("sesId", sesId)) -// return false; -// -// commState.idx++; -// -// case 14: -// if (!commState.putByteArray("siblingsBytes", siblingsBytes)) -// return false; -// -// commState.idx++; -// -// case 15: -// if (!commState.putLong("startTaskTime", startTaskTime)) -// return false; -// -// commState.idx++; -// -// case 16: -// if (!commState.putUuid("subjId", subjId)) -// return false; -// -// commState.idx++; -// -// case 17: -// if (!commState.putString("taskClsName", taskClsName)) -// return false; -// -// commState.idx++; -// -// case 18: -// if (!commState.putString("taskName", taskName)) -// return false; -// -// commState.idx++; -// -// case 19: -// if (!commState.putLong("timeout", timeout)) -// return false; -// -// commState.idx++; -// -// case 19: -// if (top != null) { -// if (commState.it == null) { -// if (!commState.putInt(null, top.size())) -// return false; -// -// commState.it = top.iterator(); -// } -// -// while (commState.it.hasNext() || commState.cur != NULL) { -// if (commState.cur == NULL) -// commState.cur = commState.it.next(); -// -// if (!commState.putUuid(null, (UUID)commState.cur)) -// return false; -// -// commState.cur = NULL; -// } -// -// commState.it = null; -// } else { -// if (!commState.putInt(null, -1)) -// return false; -// } -// -// commState.idx++; -// -// case 21: -// if (!commState.putString("userVer", userVer)) -// return false; -// -// commState.idx++; -// -// } + commState.setBuffer(buf); + + if (!commState.typeWritten) { + if (!commState.putByte(null, directType())) + return false; + + commState.typeWritten = true; + } + + switch (commState.idx) { + case 0: + if (!commState.putGridUuid("clsLdrId", clsLdrId)) + return false; + + commState.idx++; + + case 1: + if (!commState.putString("cpSpi", cpSpi)) + return false; + + commState.idx++; + + case 2: + if (!commState.putEnum("depMode", depMode)) + return false; + + commState.idx++; + + case 3: + if (!commState.putBoolean("dynamicSiblings", dynamicSiblings)) + return false; + + commState.idx++; + + case 4: + if (!commState.putBoolean("forceLocDep", forceLocDep)) + return false; + + commState.idx++; + + case 5: + if (!commState.putBoolean("internal", internal)) + return false; + + commState.idx++; + + case 6: + if (!commState.putByteArray("jobAttrsBytes", jobAttrsBytes)) + return false; + + commState.idx++; + + case 7: + if (!commState.putByteArray("jobBytes", jobBytes)) + return false; + + commState.idx++; + + case 8: + if (!commState.putGridUuid("jobId", jobId)) + return false; + + commState.idx++; + + case 9: + if (ldrParticipants != null) { + if (commState.it == null) { + if (!commState.putInt(null, ldrParticipants.size())) + return false; + + commState.it = ldrParticipants.entrySet().iterator(); + } + + while (commState.it.hasNext() || commState.cur != NULL) { + if (commState.cur == NULL) + commState.cur = commState.it.next(); + + Map.Entry e = (Map.Entry)commState.cur; + + if (!commState.keyDone) { + if (!commState.putUuid(null, e.getKey())) + return false; + + commState.keyDone = true; + } + + if (!commState.putGridUuid(null, e.getValue())) + return false; + + commState.keyDone = false; + + commState.cur = NULL; + } + + commState.it = null; + } else { + if (!commState.putInt(null, -1)) + return false; + } + + commState.idx++; + + case 10: + if (!commState.putByteArray("sesAttrsBytes", sesAttrsBytes)) + return false; + + commState.idx++; + + case 11: + if (!commState.putBoolean("sesFullSup", sesFullSup)) + return false; + + commState.idx++; + + case 12: + if (!commState.putGridUuid("sesId", sesId)) + return false; + + commState.idx++; + + case 13: + if (!commState.putByteArray("siblingsBytes", siblingsBytes)) + return false; + + commState.idx++; + + case 14: + if (!commState.putLong("startTaskTime", startTaskTime)) + return false; + + commState.idx++; + + case 15: + if (!commState.putUuid("subjId", subjId)) + return false; + + commState.idx++; + + case 16: + if (!commState.putString("taskClsName", taskClsName)) + return false; + + commState.idx++; + + case 17: + if (!commState.putString("taskName", taskName)) + return false; + + commState.idx++; + + case 18: + if (!commState.putLong("timeout", timeout)) + return false; + + commState.idx++; + + case 19: + if (top != null) { + if (commState.it == null) { + if (!commState.putInt(null, top.size())) + return false; + + commState.it = top.iterator(); + } + + while (commState.it.hasNext() || commState.cur != NULL) { + if (commState.cur == NULL) + commState.cur = commState.it.next(); + + if (!commState.putUuid(null, (UUID)commState.cur)) + return false; + + commState.cur = NULL; + } + + commState.it = null; + } else { + if (!commState.putInt(null, -1)) + return false; + } + + commState.idx++; + + case 20: + if (!commState.putString("userVer", userVer)) + return false; + + commState.idx++; + + } return true; } @@ -659,243 +653,235 @@ public UUID getSubjectId() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { -// commState.setBuffer(buf); -// -// switch (commState.idx) { -// case 0: -// clsLdrId = commState.getGridUuid("clsLdrId"); -// -// if (!commState.lastRead()) -// return false; -// -// commState.idx++; -// -// case 1: -// cpSpi = commState.getString("cpSpi"); -// -// if (!commState.lastRead()) -// return false; -// -// commState.idx++; -// -// case 2: -// createTime = commState.getLong("createTime"); -// -// if (!commState.lastRead()) -// return false; -// -// commState.idx++; -// -// case 3: -// byte depMode0 = commState.getByte("depMode"); -// -// if (!commState.lastRead()) -// return false; -// -// depMode = IgniteDeploymentMode.fromOrdinal(depMode0); -// -// commState.idx++; -// -// case 4: -// dynamicSiblings = commState.getBoolean("dynamicSiblings"); -// -// if (!commState.lastRead()) -// return false; -// -// commState.idx++; -// -// case 5: -// forceLocDep = commState.getBoolean("forceLocDep"); -// -// if (!commState.lastRead()) -// return false; -// -// commState.idx++; -// -// case 6: -// internal = commState.getBoolean("internal"); -// -// if (!commState.lastRead()) -// return false; -// -// commState.idx++; -// -// case 7: -// jobAttrsBytes = commState.getByteArray("jobAttrsBytes"); -// -// if (!commState.lastRead()) -// return false; -// -// commState.idx++; -// -// case 8: -// jobBytes = commState.getByteArray("jobBytes"); -// -// if (!commState.lastRead()) -// return false; -// -// commState.idx++; -// -// case 9: -// jobId = commState.getGridUuid("jobId"); -// -// if (!commState.lastRead()) -// return false; -// -// commState.idx++; -// -// case 9: -// if (commState.readSize == -1) { -// commState.readSize = commState.getInt(null); -// -// if (!commState.lastRead()) -// return false; -// } -// -// if (commState.readSize >= 0) { -// if (ldrParticipants == null) -// ldrParticipants = new HashMap<>(commState.readSize, 1.0f); -// -// for (int i = commState.readItems; i < commState.readSize; i++) { -// if (!commState.keyDone) { -// UUID _val = commState.getUuid(null); -// -// if (!commState.lastRead()) -// return false; -// -// commState.cur = _val; -// commState.keyDone = true; -// } -// -// IgniteUuid _val = commState.getGridUuid(null); -// -// if (!commState.lastRead()) -// return false; -// -// ldrParticipants.put((UUID)commState.cur, _val); -// -// commState.keyDone = false; -// -// commState.readItems++; -// } -// } -// -// commState.readSize = -1; -// commState.readItems = 0; -// commState.cur = null; -// -// commState.idx++; -// -// case 11: -// sesAttrsBytes = commState.getByteArray("sesAttrsBytes"); -// -// if (!commState.lastRead()) -// return false; -// -// commState.idx++; -// -// case 12: -// sesFullSup = commState.getBoolean("sesFullSup"); -// -// if (!commState.lastRead()) -// return false; -// -// commState.idx++; -// -// case 13: -// sesId = commState.getGridUuid("sesId"); -// -// if (!commState.lastRead()) -// return false; -// -// commState.idx++; -// -// case 14: -// siblingsBytes = commState.getByteArray("siblingsBytes"); -// -// if (!commState.lastRead()) -// return false; -// -// commState.idx++; -// -// case 15: -// startTaskTime = commState.getLong("startTaskTime"); -// -// if (!commState.lastRead()) -// return false; -// -// commState.idx++; -// -// case 16: -// subjId = commState.getUuid("subjId"); -// -// if (!commState.lastRead()) -// return false; -// -// commState.idx++; -// -// case 17: -// taskClsName = commState.getString("taskClsName"); -// -// if (!commState.lastRead()) -// return false; -// -// commState.idx++; -// -// case 18: -// taskName = commState.getString("taskName"); -// -// if (!commState.lastRead()) -// return false; -// -// commState.idx++; -// -// case 19: -// timeout = commState.getLong("timeout"); -// -// if (!commState.lastRead()) -// return false; -// -// commState.idx++; -// -// case 19: -// if (commState.readSize == -1) { -// commState.readSize = commState.getInt(null); -// -// if (!commState.lastRead()) -// return false; -// } -// -// if (commState.readSize >= 0) { -// if (top == null) -// top = new ArrayList<>(commState.readSize); -// -// for (int i = commState.readItems; i < commState.readSize; i++) { -// UUID _val = commState.getUuid(null); -// -// if (!commState.lastRead()) -// return false; -// -// top.add((UUID)_val); -// -// commState.readItems++; -// } -// } -// -// commState.readSize = -1; -// commState.readItems = 0; -// -// commState.idx++; -// -// case 21: -// userVer = commState.getString("userVer"); -// -// if (!commState.lastRead()) -// return false; -// -// commState.idx++; -// -// } + commState.setBuffer(buf); + + switch (commState.idx) { + case 0: + clsLdrId = commState.getGridUuid("clsLdrId"); + + if (!commState.lastRead()) + return false; + + commState.idx++; + + case 1: + cpSpi = commState.getString("cpSpi"); + + if (!commState.lastRead()) + return false; + + commState.idx++; + + case 2: + byte depMode0 = commState.getByte("depMode"); + + if (!commState.lastRead()) + return false; + + depMode = IgniteDeploymentMode.fromOrdinal(depMode0); + + commState.idx++; + + case 3: + dynamicSiblings = commState.getBoolean("dynamicSiblings"); + + if (!commState.lastRead()) + return false; + + commState.idx++; + + case 4: + forceLocDep = commState.getBoolean("forceLocDep"); + + if (!commState.lastRead()) + return false; + + commState.idx++; + + case 5: + internal = commState.getBoolean("internal"); + + if (!commState.lastRead()) + return false; + + commState.idx++; + + case 6: + jobAttrsBytes = commState.getByteArray("jobAttrsBytes"); + + if (!commState.lastRead()) + return false; + + commState.idx++; + + case 7: + jobBytes = commState.getByteArray("jobBytes"); + + if (!commState.lastRead()) + return false; + + commState.idx++; + + case 8: + jobId = commState.getGridUuid("jobId"); + + if (!commState.lastRead()) + return false; + + commState.idx++; + + case 9: + if (commState.readSize == -1) { + commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; + } + + if (commState.readSize >= 0) { + if (ldrParticipants == null) + ldrParticipants = new HashMap<>(commState.readSize, 1.0f); + + for (int i = commState.readItems; i < commState.readSize; i++) { + if (!commState.keyDone) { + UUID _val = commState.getUuid(null); + + if (!commState.lastRead()) + return false; + + commState.cur = _val; + commState.keyDone = true; + } + + IgniteUuid _val = commState.getGridUuid(null); + + if (!commState.lastRead()) + return false; + + ldrParticipants.put((UUID)commState.cur, _val); + + commState.keyDone = false; + + commState.readItems++; + } + } + + commState.readSize = -1; + commState.readItems = 0; + commState.cur = null; + + commState.idx++; + + case 10: + sesAttrsBytes = commState.getByteArray("sesAttrsBytes"); + + if (!commState.lastRead()) + return false; + + commState.idx++; + + case 11: + sesFullSup = commState.getBoolean("sesFullSup"); + + if (!commState.lastRead()) + return false; + + commState.idx++; + + case 12: + sesId = commState.getGridUuid("sesId"); + + if (!commState.lastRead()) + return false; + + commState.idx++; + + case 13: + siblingsBytes = commState.getByteArray("siblingsBytes"); + + if (!commState.lastRead()) + return false; + + commState.idx++; + + case 14: + startTaskTime = commState.getLong("startTaskTime"); + + if (!commState.lastRead()) + return false; + + commState.idx++; + + case 15: + subjId = commState.getUuid("subjId"); + + if (!commState.lastRead()) + return false; + + commState.idx++; + + case 16: + taskClsName = commState.getString("taskClsName"); + + if (!commState.lastRead()) + return false; + + commState.idx++; + + case 17: + taskName = commState.getString("taskName"); + + if (!commState.lastRead()) + return false; + + commState.idx++; + + case 18: + timeout = commState.getLong("timeout"); + + if (!commState.lastRead()) + return false; + + commState.idx++; + + case 19: + if (commState.readSize == -1) { + commState.readSize = commState.getInt(null); + + if (!commState.lastRead()) + return false; + } + + if (commState.readSize >= 0) { + if (top == null) + top = new ArrayList<>(commState.readSize); + + for (int i = commState.readItems; i < commState.readSize; i++) { + UUID _val = commState.getUuid(null); + + if (!commState.lastRead()) + return false; + + top.add((UUID)_val); + + commState.readItems++; + } + } + + commState.readSize = -1; + commState.readItems = 0; + + commState.idx++; + + case 20: + userVer = commState.getString("userVer"); + + if (!commState.lastRead()) + return false; + + commState.idx++; + + } return true; } From 4078998c9f621c7e8add815eb7ca153c754b9268 Mon Sep 17 00:00:00 2001 From: sboikov Date: Thu, 5 Feb 2015 23:37:55 +0300 Subject: [PATCH 26/95] # ignite-57 --- .../processors/cache/GridCacheAdapter.java | 31 ++- .../internal/util/offheap/GridOffHeapMap.java | 7 + .../util/offheap/unsafe/GridUnsafeMap.java | 12 +- .../IgniteOptimizedObjectInputStream.java | 2 + .../cache/IgniteCacheSizeAbstractTest.java | 248 +++++++++++++++++- .../GridOffHeapMapAbstractSelfTest.java | 52 ++-- 6 files changed, 301 insertions(+), 51 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java index 0a24bb60aef7f..af4f482ed534f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java @@ -4185,21 +4185,30 @@ IgniteInternalFuture globalLoadCacheAsync(@Nullable IgniteBiPredicate p int size = 0; - if (heap) { - if (near) - size += nearSize(); + if (ctx.isLocal()) { + primary = true; + backup = true; - GridCacheAdapter cache = ctx.isNear() ? ctx.near().dht() : ctx.cache(); + if (heap) + size += size(); + } + else { + if (heap) { + if (near) + size += nearSize(); - if (!(primary && backup)) { - if (primary) - size += cache.primarySize(); + GridCacheAdapter cache = ctx.isNear() ? ctx.near().dht() : ctx.cache(); - if (backup) - size += (cache.size() - cache.primarySize()); + if (!(primary && backup)) { + if (primary) + size += cache.primarySize(); + + if (backup) + size += (cache.size() - cache.primarySize()); + } + else + size += cache.size(); } - else - size += cache.size(); } // Swap and offheap are disabled for near cache. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/GridOffHeapMap.java b/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/GridOffHeapMap.java index 9f4e4b4faebe9..d10aa226ccba7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/GridOffHeapMap.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/GridOffHeapMap.java @@ -124,6 +124,13 @@ public interface GridOffHeapMap { */ public void insert(int hash, byte[] keyBytes, byte[] valBytes); + /** + * Gets number of elements in the map. + * + * @return Number of elements in the map. + */ + public long totalSize(); + /** * Gets number of elements in the map. * diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMap.java b/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMap.java index 229f4f28f61da..dc742c710bbd8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMap.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMap.java @@ -329,10 +329,20 @@ private void init(long initCap, int size) { } /** {@inheritDoc} */ - @Override public long size() { + @Override public long totalSize() { return totalCnt.sum(); } + /** {@inheritDoc} */ + @Override public long size() { + long size = 0; + + for (int i = 0; i < segs.length; i++) + size += segs[i].count(); + + return size; + } + /** {@inheritDoc} */ @Override public long memorySize() { return mem.totalSize(); diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/IgniteOptimizedObjectInputStream.java b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/IgniteOptimizedObjectInputStream.java index 690bdd6c938b4..d596af3ac9707 100644 --- a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/IgniteOptimizedObjectInputStream.java +++ b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/IgniteOptimizedObjectInputStream.java @@ -110,6 +110,8 @@ public void in(GridDataInput in) { /** {@inheritDoc} */ @Override public void close() throws IOException { reset(); + + clsLdr = null; } /** {@inheritDoc} */ diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSizeAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSizeAbstractTest.java index 35c3c867ee63b..dbc2e9a02127d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSizeAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSizeAbstractTest.java @@ -23,6 +23,9 @@ import org.apache.ignite.cache.eviction.fifo.*; import org.apache.ignite.cluster.*; import org.apache.ignite.configuration.*; +import org.apache.ignite.internal.*; +import org.apache.ignite.internal.util.typedef.*; +import org.apache.ignite.spi.*; import org.apache.ignite.spi.swapspace.file.*; import java.util.*; @@ -79,19 +82,7 @@ public abstract class IgniteCacheSizeAbstractTest extends IgniteCacheAbstractTes * @throws Exception If failed. */ public void testSize() throws Exception { - for (int i = 0; i < gridCount(); i++) { - IgniteCache cache = jcache(i); - - assertEquals(0, cache.localSize()); - - assertEquals(0, cache.size()); - - for (CachePeekMode peekMode : CachePeekMode.values()) { - assertEquals(0, cache.localSize(peekMode)); - - assertEquals(0, cache.size(peekMode)); - } - } + checkEmpty(); if (cacheMode() == LOCAL) { IgniteCache cache0 = jcache(0); @@ -123,11 +114,74 @@ public void testSize() throws Exception { assertEquals(size, cacheAsync0.future().get()); } + + for (int i = 0; i < HEAP_ENTRIES; i++) { + cache0.remove(i, String.valueOf(i)); + + final int size = HEAP_ENTRIES - i - 1; + + assertEquals(size, cache0.localSize()); + assertEquals(size, cache0.localSize(PRIMARY)); + assertEquals(size, cache0.localSize(BACKUP)); + assertEquals(size, cache0.localSize(NEAR)); + assertEquals(size, cache0.localSize(ALL)); + + assertEquals(size, cache0.size()); + assertEquals(size, cache0.size(PRIMARY)); + assertEquals(size, cache0.size(BACKUP)); + assertEquals(size, cache0.size(NEAR)); + assertEquals(size, cache0.size(ALL)); + + cacheAsync0.size(); + + assertEquals(size, cacheAsync0.future().get()); + } + + checkEmpty(); + + for (int i = 0; i < 200; i++) + cache0.put(i, "test_val"); + + int totalKeys = 200; + + T2 swapKeys = swapKeys(0); + + T2 offheapKeys = offheapKeys(0); + + int totalSwap = swapKeys.get1() + swapKeys.get2(); + int totalOffheap = offheapKeys.get1() + offheapKeys.get2(); + + log.info("Keys [total=" + totalKeys + ", offheap=" + offheapKeys + ", swap=" + swapKeys + ']'); + + assertTrue(totalSwap + totalOffheap < totalKeys); + + assertEquals(totalKeys, cache0.localSize()); + assertEquals(totalKeys, cache0.localSize(ALL)); + + assertEquals(totalOffheap, cache0.localSize(OFFHEAP)); + assertEquals(totalSwap, cache0.localSize(SWAP)); + assertEquals(totalKeys - (totalSwap + totalOffheap), cache0.localSize(ONHEAP)); + + assertEquals(totalOffheap, cache0.size(OFFHEAP)); + assertEquals(totalSwap, cache0.size(SWAP)); + assertEquals(totalKeys - (totalSwap + totalOffheap), cache0.size(ONHEAP)); + + assertEquals(totalOffheap, cache0.localSize(OFFHEAP, PRIMARY)); + assertEquals(totalSwap, cache0.localSize(SWAP, PRIMARY)); + assertEquals(totalKeys - (totalSwap + totalOffheap), cache0.localSize(ONHEAP, PRIMARY)); + + assertEquals(totalOffheap, cache0.localSize(OFFHEAP, BACKUP)); + assertEquals(totalSwap, cache0.localSize(SWAP, BACKUP)); + assertEquals(totalKeys - (totalSwap + totalOffheap), cache0.localSize(ONHEAP, BACKUP)); } else { checkSizeAffinityFilter(0); checkSizeAffinityFilter(1); + + checkSizeStorageFilter(0); + + checkSizeStorageFilter(1); } } @@ -234,11 +288,124 @@ else if (aff.isBackup(node, key)) assertEquals(primary + backups, cache.localSize(BACKUP, PRIMARY)); assertEquals(primary + backups, cache.localSize(ALL)); } + + cache0.remove(keys.get(0)); + + checkPrimarySize(PUT_KEYS - 1); + + if (cacheMode() == REPLICATED) { + assertEquals(PUT_KEYS - 1, cache0.localSize()); + assertEquals(0, cache0.localSize(PRIMARY)); + assertEquals(PUT_KEYS - 1, cache0.localSize(BACKUP)); + } + else { + boolean hasNearCache = nodeIdx == 0; + + if (hasNearCache) + assertEquals(PUT_KEYS - 1, cache0.localSize()); + else + assertEquals(0, cache0.localSize()); + } } finally { if (keys != null) cache0.removeAll(new HashSet<>(keys)); } + + checkEmpty(); + } + + /** + * Checks size is zero. + */ + private void checkEmpty() { + for (int i = 0; i < gridCount(); i++) { + IgniteCache cache = jcache(i); + + assertEquals(0, cache.localSize()); + + assertEquals(0, cache.size()); + + for (CachePeekMode peekMode : CachePeekMode.values()) { + assertEquals(0, cache.localSize(peekMode)); + + assertEquals(0, cache.size(peekMode)); + } + } + + checkPrimarySize(0); + } + + /** + * @param nodeIdx Node index. + * @return Tuple with number of primary and backup keys. + */ + private T2 swapKeys(int nodeIdx) { + FileSwapSpaceSpi swap = (FileSwapSpaceSpi)ignite(nodeIdx).configuration().getSwapSpaceSpi(); + + final String spaceName = "gg-swap-cache-dflt"; + + IgniteSpiCloseableIterator it = swap.keyIterator(spaceName, null); + + assertNotNull(it); + + CacheAffinity aff = ignite(nodeIdx).affinity(null); + + ClusterNode node = ignite(nodeIdx).cluster().localNode(); + + int primary = 0; + int backups = 0; + + while (it.hasNext()) { + Integer key = it.next(); + + if (aff.isPrimary(node, key)) + primary++; + else { + assertTrue(aff.isBackup(node, key)); + + backups++; + } + } + + return new T2<>(primary, backups); + } + + /** + * @param nodeIdx Node index. + * @return Tuple with number of primary and backup keys. + */ + private T2 offheapKeys(int nodeIdx) { + GridCacheAdapter internalCache = + ((IgniteKernal)ignite(nodeIdx)).context().cache().internalCache(); + + Iterator> offheapIt; + + if (internalCache.context().isNear()) + offheapIt = internalCache.context().near().dht().context().swap().lazyOffHeapIterator(); + else + offheapIt = internalCache.context().swap().lazyOffHeapIterator(); + + CacheAffinity aff = ignite(nodeIdx).affinity(null); + + ClusterNode node = ignite(nodeIdx).cluster().localNode(); + + int primary = 0; + int backups = 0; + + while (offheapIt.hasNext()) { + Map.Entry e = offheapIt.next(); + + if (aff.isPrimary(node, e.getKey())) + primary++; + else { + assertTrue(aff.isBackup(node, e.getKey())); + + backups++; + } + } + + return new T2<>(primary, backups); } /** @@ -246,7 +413,62 @@ else if (aff.isBackup(node, key)) * @throws Exception If failed. */ private void checkSizeStorageFilter(int nodeIdx) throws Exception { + IgniteCache cache0 = jcache(nodeIdx); + + List primaryKeys = primaryKeys(cache0, 100, 10_000); + List backupKeys = backupKeys(cache0, 100, 10_000); + + try { + final String val = "test_value"; + + for (int i = 0; i < 100; i++) { + cache0.put(primaryKeys.get(i), val); + cache0.put(backupKeys.get(i), val); + } + + int totalKeys = 200; + + T2 swapKeys = swapKeys(nodeIdx); + + assertTrue(swapKeys.get1() > 0); + assertTrue(swapKeys.get2() > 0); + + T2 offheapKeys = offheapKeys(nodeIdx); + + assertTrue(offheapKeys.get1() > 0); + assertTrue(offheapKeys.get2() > 0); + + int totalSwap = swapKeys.get1() + swapKeys.get2(); + int totalOffheap = offheapKeys.get1() + offheapKeys.get2(); + + log.info("Keys [total=" + totalKeys + ", offheap=" + offheapKeys + ", swap=" + swapKeys + ']'); + + assertTrue(totalSwap + totalOffheap < totalKeys); + + assertEquals(totalKeys, cache0.localSize()); + assertEquals(totalKeys, cache0.localSize(ALL)); + assertEquals(totalOffheap, cache0.localSize(OFFHEAP)); + assertEquals(totalSwap, cache0.localSize(SWAP)); + assertEquals(totalKeys - (totalOffheap + totalSwap), cache0.localSize(ONHEAP)); + assertEquals(totalKeys, cache0.localSize(SWAP, OFFHEAP, ONHEAP)); + + assertEquals(swapKeys.get1(), (Integer)cache0.localSize(SWAP, PRIMARY)); + assertEquals(swapKeys.get2(), (Integer)cache0.localSize(SWAP, BACKUP)); + + assertEquals(offheapKeys.get1(), (Integer)cache0.localSize(OFFHEAP, PRIMARY)); + assertEquals(offheapKeys.get2(), (Integer)cache0.localSize(OFFHEAP, BACKUP)); + + assertEquals(swapKeys.get1() + offheapKeys.get1(), cache0.localSize(SWAP, OFFHEAP, PRIMARY)); + assertEquals(swapKeys.get2() + offheapKeys.get2(), cache0.localSize(SWAP, OFFHEAP, BACKUP)); + + assertEquals(totalSwap + totalOffheap, cache0.localSize(SWAP, OFFHEAP)); + } + finally { + cache0.removeAll(new HashSet<>(primaryKeys)); + cache0.removeAll(new HashSet<>(backupKeys)); + } + checkEmpty(); } /** diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/GridOffHeapMapAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/GridOffHeapMapAbstractSelfTest.java index fd0b8b015c239..8ec97f90facb5 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/GridOffHeapMapAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/util/offheap/GridOffHeapMapAbstractSelfTest.java @@ -148,10 +148,10 @@ public void testInsert() throws Exception { assertTrue("Failed to insert for index: " + i, map.contains(hash(key), key.getBytes())); assertEquals(val, new String(map.get(hash(key), key.getBytes()))); - assertEquals(i + 1, map.size()); + assertEquals(i + 1, map.totalSize()); } - assert map.size() == 10; + assert map.totalSize() == 10; } /** @@ -188,7 +188,7 @@ public void testRehash() throws Exception { assertEquals(val, new String(valBytes)); } - assert map.size() == 10; + assert map.totalSize() == 10; } /** @@ -205,10 +205,10 @@ public void testGet() throws Exception { assertTrue(map.contains(hash(key), key.getBytes())); assertEquals(val, new String(map.get(hash(key), key.getBytes()))); - assertEquals(i + 1, map.size()); + assertEquals(i + 1, map.totalSize()); } - assert map.size() == 10; + assert map.totalSize() == 10; } /** @@ -225,10 +225,10 @@ public void testPut1() throws Exception { assertTrue(map.contains(hash(key), key.getBytes())); assertEquals(val, new String(map.get(hash(key), key.getBytes()))); - assertEquals(i + 1, map.size()); + assertEquals(i + 1, map.totalSize()); } - assertEquals(10, map.size()); + assertEquals(10, map.totalSize()); } /** @@ -247,16 +247,16 @@ public void testPut2() throws Exception { assertTrue(map.contains(hash(key), key.getBytes())); assertEquals(val1, new String(map.get(hash(key), key.getBytes()))); - assertEquals(i + 1, map.size()); + assertEquals(i + 1, map.totalSize()); assertFalse(map.put(hash(key), key.getBytes(), val2.getBytes())); assertTrue(map.contains(hash(key), key.getBytes())); assertEquals(val2, new String(map.get(hash(key), key.getBytes()))); - assertEquals(i + 1, map.size()); + assertEquals(i + 1, map.totalSize()); } - assertEquals(10, map.size()); + assertEquals(10, map.totalSize()); } /** @@ -274,7 +274,7 @@ public void testRemove() throws Exception { assertTrue(map.contains(hash(key), key.getBytes())); assertNotNull(map.get(hash(key), key.getBytes())); assertEquals(new String(map.get(hash(key), key.getBytes())), val); - assertEquals(1, map.size()); + assertEquals(1, map.totalSize()); byte[] val2 = map.remove(hash(key), key.getBytes()); @@ -282,10 +282,10 @@ public void testRemove() throws Exception { assertEquals(val, new String(val2)); assertFalse(map.contains(hash(key), key.getBytes())); assertNull(map.get(hash(key), key.getBytes())); - assertEquals(0, map.size()); + assertEquals(0, map.totalSize()); } - assertEquals(0, map.size()); + assertEquals(0, map.totalSize()); } /** @@ -303,17 +303,17 @@ public void testRemovex() throws Exception { assertTrue(map.contains(hash(key), key.getBytes())); assertNotNull(map.get(hash(key), key.getBytes())); assertEquals(new String(map.get(hash(key), key.getBytes())), val); - assertEquals(1, map.size()); + assertEquals(1, map.totalSize()); boolean rmvd = map.removex(hash(key), key.getBytes()); assertTrue(rmvd); assertFalse(map.contains(hash(key), key.getBytes())); assertNull(map.get(hash(key), key.getBytes())); - assertEquals(0, map.size()); + assertEquals(0, map.totalSize()); } - assertEquals(0, map.size()); + assertEquals(0, map.totalSize()); } /** @@ -377,12 +377,12 @@ public void testIterator() throws Exception { } } - assertEquals(map.size(), cnt); + assertEquals(map.totalSize(), cnt); } - assertEquals(max, map.size()); + assertEquals(max, map.totalSize()); - info("Stats [size=" + map.size() + ", rehashes=" + rehashes + ", releases=" + releases + ']'); + info("Stats [size=" + map.totalSize() + ", rehashes=" + rehashes + ", releases=" + releases + ']'); assertTrue(rehashes.get() > 0); assertEquals(rehashes.get(), releases.get()); @@ -454,9 +454,9 @@ public void testIteratorMultithreaded() throws Exception { } }, threads); - assertEquals(max * threads, map.size()); + assertEquals(max * threads, map.totalSize()); - info("Stats [size=" + map.size() + ", rehashes=" + rehashes + ", releases=" + releases + ']'); + info("Stats [size=" + map.totalSize() + ", rehashes=" + rehashes + ", releases=" + releases + ']'); assertTrue(rehashes.get() > 0); assertEquals(rehashes.get(), releases.get()); @@ -491,7 +491,7 @@ public void testInsertLoad() { assertTrue(map.contains(hash(key), key.getBytes())); assertNotNull(map.get(hash(key), key.getBytes())); assertEquals(new String(map.get(hash(key), key.getBytes())), val); - assertEquals(++cnt, map.size()); + assertEquals(++cnt, map.totalSize()); } } @@ -527,7 +527,7 @@ public void testPutLoad() { assertTrue(map.contains(hash(key), key.getBytes())); assertNotNull(map.get(hash(key), key.getBytes())); assertEquals(new String(map.get(hash(key), key.getBytes())), val); - assertEquals(++cnt, map.size()); + assertEquals(++cnt, map.totalSize()); } } @@ -563,7 +563,7 @@ public void testLru1() { info("Evicted: " + evictCnt); assertEquals(1, evictCnt.get()); - assertEquals(0, map.size()); + assertEquals(0, map.totalSize()); assertTrue(evictCnt.compareAndSet(1, 0)); } @@ -643,7 +643,7 @@ public void testLruMultithreaded() throws Exception { } }, 10); - info("Map stats [evicted=" + evictCnt + ", size=" + map.size() + ", allocated=" + map.allocatedSize() + + info("Map stats [evicted=" + evictCnt + ", size=" + map.totalSize() + ", allocated=" + map.allocatedSize() + ", freeSize=" + map.freeSize() + ']'); assertTrue(map.freeSize() >= 0); @@ -805,7 +805,7 @@ public Void call() throws IgniteCheckedException { for (byte[] key : keys) map.remove(key[0], key); - assertEquals(0, map.size()); + assertEquals(0, map.totalSize()); assertEquals(0, ((GridUnsafeMap)map).lruSize()); assertEquals(zeroAllocated, map.allocatedSize()); From 5de977c64218fa076e7a4384391aced3dd9cf689 Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Thu, 5 Feb 2015 14:10:03 -0800 Subject: [PATCH 27/95] IGNITE-61 - Fixed collections processing --- .../CommunicationMessageCodeGenerator.java | 12 ++++++---- .../internal/GridJobExecuteRequest.java | 6 +++-- .../communication/GridIoUserMessage.java | 3 ++- .../deployment/GridDeploymentInfoBean.java | 3 ++- .../deployment/GridDeploymentRequest.java | 3 ++- .../eventstorage/GridEventStorageMessage.java | 3 ++- .../cache/GridCacheEvictionResponse.java | 3 ++- .../GridCacheTtlUpdateRequest.java | 12 ++++++---- .../GridDistributedBaseMessage.java | 6 +++-- .../GridDistributedLockRequest.java | 6 +++-- .../GridDistributedLockResponse.java | 3 ++- .../GridDistributedTxFinishRequest.java | 6 +++-- .../GridDistributedTxPrepareRequest.java | 6 +++-- .../GridDistributedUnlockRequest.java | 3 ++- .../distributed/dht/GridDhtLockRequest.java | 3 ++- .../distributed/dht/GridDhtLockResponse.java | 9 ++++--- .../dht/GridDhtTxFinishRequest.java | 6 +++-- .../dht/GridDhtTxPrepareRequest.java | 3 ++- .../dht/GridDhtTxPrepareResponse.java | 9 ++++--- .../distributed/dht/GridDhtUnlockRequest.java | 3 ++- .../GridDhtAtomicDeferredUpdateResponse.java | 3 ++- .../atomic/GridDhtAtomicUpdateRequest.java | 24 ++++++++++++------- .../atomic/GridDhtAtomicUpdateResponse.java | 3 ++- .../atomic/GridNearAtomicUpdateRequest.java | 15 ++++++++---- .../atomic/GridNearAtomicUpdateResponse.java | 9 ++++--- .../preloader/GridDhtForceKeysRequest.java | 3 ++- .../preloader/GridDhtForceKeysResponse.java | 3 ++- .../GridDhtPartitionDemandMessage.java | 3 ++- .../GridDhtPartitionSupplyMessage.java | 6 +++-- .../distributed/near/GridNearGetRequest.java | 6 +++-- .../distributed/near/GridNearGetResponse.java | 3 ++- .../distributed/near/GridNearLockRequest.java | 6 +++-- .../near/GridNearLockResponse.java | 9 ++++--- .../near/GridNearTxPrepareRequest.java | 3 ++- .../near/GridNearTxPrepareResponse.java | 9 ++++--- .../cache/query/GridCacheQueryResponse.java | 6 +++-- .../clock/GridClockDeltaSnapshotMessage.java | 3 ++- .../dataload/GridDataLoadRequest.java | 3 ++- .../processors/fs/GridGgfsBlocksMessage.java | 3 ++- .../fs/GridGgfsFragmentizerRequest.java | 3 ++- .../GridStreamerExecutionRequest.java | 3 ++- 41 files changed, 155 insertions(+), 79 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java index c833c704c6ea2..decac328ba263 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java @@ -129,9 +129,7 @@ public static void main(String[] args) { CommunicationMessageCodeGenerator gen = new CommunicationMessageCodeGenerator(); try { - gen.generateAndWrite(GridJobExecuteRequest.class); - - //gen.generateAll(true); + gen.generateAll(true); } catch (Exception e) { e.printStackTrace(); @@ -844,7 +842,9 @@ else if (type.isArray() || Collection.class.isAssignableFrom(type)) { indent++; - returnFalseIfReadFailed(int.class, READ_SIZE_VAR, null, null, null, true); + returnFalseIfReadFailed(int.class, null, null, null, null, true); + + read.add(builder().a(READ_SIZE_VAR).a(" = ").a(DFLT_LOC_VAR).a(";").toString()); indent--; @@ -911,7 +911,9 @@ else if (Map.class.isAssignableFrom(type)) { indent++; - returnFalseIfReadFailed(int.class, READ_SIZE_VAR, null, null, null, true); + returnFalseIfReadFailed(int.class, null, null, null, null, true); + + read.add(builder().a(READ_SIZE_VAR).a(" = ").a(DFLT_LOC_VAR).a(";").toString()); indent--; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java index aac47f9445170..968c3b5b1560b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java @@ -732,10 +732,11 @@ public UUID getSubjectId() { case 9: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { @@ -846,10 +847,11 @@ public UUID getSubjectId() { case 19: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoUserMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoUserMessage.java index 81ceddf886674..0889d6aa66ffd 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoUserMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoUserMessage.java @@ -362,10 +362,11 @@ public void deployment(GridDeployment dep) { case 4: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentInfoBean.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentInfoBean.java index 325d0b15debec..23e92d8cd0e08 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentInfoBean.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentInfoBean.java @@ -272,10 +272,11 @@ public void localDeploymentOwner(boolean locDepOwner) { case 3: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentRequest.java index 62bbcf3d736a8..2a8b6ddf14cb2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentRequest.java @@ -270,10 +270,11 @@ public void nodeIds(Collection nodeIds) { case 2: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java index 904a5fa892bc5..c8c1dade7b328 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java @@ -450,10 +450,11 @@ void exceptionBytes(byte[] exBytes) { case 6: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionResponse.java index 1ff9225f39e93..8bf52d7fe5723 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionResponse.java @@ -237,10 +237,11 @@ boolean error() { case 5: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java index 5c60c0c8d30c6..d860411be49e4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java @@ -343,10 +343,11 @@ public List nearVersions() { switch (commState.idx) { case 3: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { @@ -372,10 +373,11 @@ public List nearVersions() { case 4: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { @@ -401,10 +403,11 @@ public List nearVersions() { case 5: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { @@ -446,10 +449,11 @@ public List nearVersions() { case 8: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedBaseMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedBaseMessage.java index 5597a4a9e18e5..812ed188069a3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedBaseMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedBaseMessage.java @@ -375,10 +375,11 @@ public int keysCount() { case 5: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { @@ -404,10 +405,11 @@ public int keysCount() { case 6: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java index 2f1297ab510cc..c4081c9eaa491 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java @@ -634,10 +634,11 @@ public GridCacheVersion[] drVersions() { switch (commState.idx) { case 8: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { @@ -713,10 +714,11 @@ public GridCacheVersion[] drVersions() { case 15: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java index 26510a48510dc..1c7761570f68d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java @@ -387,10 +387,11 @@ protected int valuesSize() { case 10: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java index dd4d890839809..15d61a382bfa2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java @@ -578,10 +578,11 @@ public boolean groupLock() { case 14: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { @@ -647,10 +648,11 @@ public boolean groupLock() { case 20: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java index 39dcf000de496..428249763f6c7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java @@ -657,10 +657,11 @@ private void writeCollection(ObjectOutput out, Collection> c case 15: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { @@ -726,10 +727,11 @@ private void writeCollection(ObjectOutput out, Collection> c case 21: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedUnlockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedUnlockRequest.java index 45b44cc6e6873..fc5cce251bb21 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedUnlockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedUnlockRequest.java @@ -194,10 +194,11 @@ public void addKey(K key, byte[] bytes, GridCacheContext ctx) throws Ignit switch (commState.idx) { case 8: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java index 72e8c3ce27c02..7b404f5df765b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java @@ -503,10 +503,11 @@ public long accessTtl() { case 27: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java index 4bbd9b35a129b..4894af0680131 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java @@ -342,10 +342,11 @@ public Collection> preloadEntries() { switch (commState.idx) { case 11: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { @@ -379,10 +380,11 @@ public Collection> preloadEntries() { case 13: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { @@ -408,10 +410,11 @@ public Collection> preloadEntries() { case 14: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java index 1ac4fc9786fd4..25ad224be05ff 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java @@ -567,10 +567,11 @@ public GridLongList nearTtls() { case 25: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { @@ -604,10 +605,11 @@ public GridLongList nearTtls() { case 27: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java index 396bd607e96be..7e7ef6647e5cb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java @@ -511,10 +511,11 @@ public Map, GridCacheVersion> owned() { case 27: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java index e25ff6c93c711..7ce598a5d4ec0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java @@ -363,10 +363,11 @@ public void addPreloadEntry(GridCacheEntryInfo info) { case 11: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { @@ -400,10 +401,11 @@ public void addPreloadEntry(GridCacheEntryInfo info) { case 13: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { @@ -429,10 +431,11 @@ public void addPreloadEntry(GridCacheEntryInfo info) { case 14: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java index 91df86208cff2..189cfaf116722 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java @@ -182,10 +182,11 @@ public void addNearKey(K key, byte[] keyBytes, GridCacheSharedContext ctx) switch (commState.idx) { case 9: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicDeferredUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicDeferredUpdateResponse.java index 69daf3b895d6d..92efaab3adb8a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicDeferredUpdateResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicDeferredUpdateResponse.java @@ -150,10 +150,11 @@ public Collection futureVersions() { switch (commState.idx) { case 3: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java index f55a8de23c09a..709b681e3b638 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java @@ -1060,10 +1060,11 @@ public long nearExpireTime(int idx) { case 4: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { @@ -1097,10 +1098,11 @@ public long nearExpireTime(int idx) { case 6: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { @@ -1126,10 +1128,11 @@ public long nearExpireTime(int idx) { case 7: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { @@ -1205,10 +1208,11 @@ public long nearExpireTime(int idx) { case 14: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { @@ -1242,10 +1246,11 @@ public long nearExpireTime(int idx) { case 16: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { @@ -1271,10 +1276,11 @@ public long nearExpireTime(int idx) { case 17: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { @@ -1300,10 +1306,11 @@ public long nearExpireTime(int idx) { case 18: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { @@ -1337,10 +1344,11 @@ public long nearExpireTime(int idx) { case 20: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java index 5fc3ef77c19b4..1747f2f93fb93 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java @@ -304,10 +304,11 @@ public void addNearEvicted(K key, @Nullable byte[] bytes) { case 6: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java index 431744f0b18af..050cb3590cc7a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java @@ -854,10 +854,11 @@ public void forceTransformBackups(boolean forceTransformBackups) { case 5: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { @@ -899,10 +900,11 @@ public void forceTransformBackups(boolean forceTransformBackups) { case 8: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { @@ -944,10 +946,11 @@ public void forceTransformBackups(boolean forceTransformBackups) { case 11: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { @@ -973,10 +976,11 @@ public void forceTransformBackups(boolean forceTransformBackups) { case 12: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { @@ -1046,10 +1050,11 @@ public void forceTransformBackups(boolean forceTransformBackups) { case 18: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java index 2d8f00b8ec6c8..2280943a8cb5d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java @@ -673,10 +673,11 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { case 10: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { @@ -702,10 +703,11 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { case 11: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { @@ -731,10 +733,11 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { case 12: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java index 6582b17aafa6a..176086e93f5ae 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java @@ -269,10 +269,11 @@ private int keyCount() { case 4: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java index 9dc4f251e4bad..dfe30f7ad9ea9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java @@ -289,10 +289,11 @@ public void addInfo(GridCacheEntryInfo info) { case 6: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java index 6931543d0f265..130aca95a5f2d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java @@ -303,10 +303,11 @@ void workerId(int workerId) { switch (commState.idx) { case 3: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java index d7e785f5e2968..aa48d89a2a2fc 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java @@ -425,10 +425,11 @@ public int size() { case 5: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { @@ -454,10 +455,11 @@ public int size() { case 6: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java index d47af023e097d..54315c0027af8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java @@ -439,10 +439,11 @@ public long accessTtl() { case 4: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { @@ -476,10 +477,11 @@ public long accessTtl() { case 6: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java index 1079611387bec..d712db75ba099 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java @@ -345,10 +345,11 @@ public void error(Throwable err) { case 6: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java index 6436cc9b0bec9..8d20405dc0dd0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java @@ -518,10 +518,11 @@ public long accessTtl() { case 25: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { @@ -547,10 +548,11 @@ public long accessTtl() { case 26: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockResponse.java index a321087a35e69..2343255009c23 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockResponse.java @@ -328,10 +328,11 @@ public void addValueBytes( switch (commState.idx) { case 11: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { @@ -365,10 +366,11 @@ public void addValueBytes( case 13: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { @@ -402,10 +404,11 @@ public void addValueBytes( case 15: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java index 5026ea51bd441..9c6135adde416 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java @@ -360,10 +360,11 @@ private Collection> cloneEntries(Collection= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java index 7d90557690ce1..9a5d0fb72f0e2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java @@ -395,10 +395,11 @@ public Collection invalidPartitions() { case 12: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { @@ -432,10 +433,11 @@ public Collection invalidPartitions() { case 14: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { @@ -461,10 +463,11 @@ public Collection invalidPartitions() { case 15: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java index 9738d60e1001d..96d0258c4fbb2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java @@ -338,10 +338,11 @@ public boolean fields() { switch (commState.idx) { case 3: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { @@ -391,10 +392,11 @@ public boolean fields() { case 7: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaSnapshotMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaSnapshotMessage.java index 7874a4cbc68e2..a779c2315c4b5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaSnapshotMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaSnapshotMessage.java @@ -159,10 +159,11 @@ public Map deltas() { switch (commState.idx) { case 0: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadRequest.java index 6cd775dd72365..bc02118f5a4b6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadRequest.java @@ -406,10 +406,11 @@ public boolean forceLocalDeployment() { case 6: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlocksMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlocksMessage.java index 85ec73d3de741..92dcad1b23cd6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlocksMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlocksMessage.java @@ -186,10 +186,11 @@ public Map blocks() { switch (commState.idx) { case 0: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerRequest.java index 55b6b74a8935a..ec89347c111d9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerRequest.java @@ -171,10 +171,11 @@ public Collection fragmentRanges() { case 1: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerExecutionRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerExecutionRequest.java index 203c5bee5a764..14950006e6a59 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerExecutionRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerExecutionRequest.java @@ -306,10 +306,11 @@ public byte[] batchBytes() { case 4: if (commState.readSize == -1) { - commState.readSize = commState.getInt(null); + int _val = commState.getInt(null); if (!commState.lastRead()) return false; + commState.readSize = _val; } if (commState.readSize >= 0) { From 1e868face9af143d87283793a78a29ff6e054bf6 Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Thu, 5 Feb 2015 16:51:50 -0800 Subject: [PATCH 28/95] # IGNITE-61 - Direct marshalling --- .../GridClientConnectionManagerAdapter.java | 6 +- .../GridClientHandshakeRequestWrapper.java | 2 +- .../GridClientHandshakeResponseWrapper.java | 22 +---- .../message/GridClientMessageWrapper.java | 25 +++-- .../message/GridClientPingPacketWrapper.java | 17 +--- .../tcp/GridMemcachedMessageWrapper.java | 17 +--- .../tcp/GridTcpRestDirectParser.java | 9 ++ .../GridTcpCommunicationMessageAdapter.java | 91 ------------------- .../GridTcpCommunicationMessageState.java | 2 - .../spi/communication/GridTestMessage.java | 4 +- 10 files changed, 34 insertions(+), 161 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/client/impl/connection/GridClientConnectionManagerAdapter.java b/modules/core/src/main/java/org/apache/ignite/client/impl/connection/GridClientConnectionManagerAdapter.java index c09be9a241a60..e87d7e27170dc 100644 --- a/modules/core/src/main/java/org/apache/ignite/client/impl/connection/GridClientConnectionManagerAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/client/impl/connection/GridClientConnectionManagerAdapter.java @@ -29,6 +29,7 @@ import org.apache.ignite.internal.util.nio.ssl.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.gridgain.grid.util.direct.*; import org.jetbrains.annotations.*; import javax.net.ssl.*; @@ -670,8 +671,11 @@ private static class NioParser implements GridNioParser { if (msg == null && buf.hasRemaining()) { byte type = buf.get(); - if (type == GridClientMessageWrapper.REQ_HEADER) + if (type == GridClientMessageWrapper.REQ_HEADER) { msg = new GridClientMessageWrapper(); + + msg.setReader(new GridTcpCommunicationMessageReader(null)); + } else throw new IOException("Invalid message type: " + type); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java index e0dd3812f1344..1c0366a99cd8b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java @@ -100,7 +100,7 @@ public byte[] bytes() { /** {@inheritDoc} */ @Override public byte directType() { - return 72; + return HANDSHAKE_HEADER; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java index 00ebc5ff1230c..8bb10a33040e4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java @@ -57,15 +57,6 @@ public GridClientHandshakeResponseWrapper(byte code) { commState.typeWritten = true; } - switch (commState.idx) { - case 0: - if (!commState.putByte("code", code)) - return false; - - commState.idx++; - - } - return true; } @@ -73,23 +64,12 @@ public GridClientHandshakeResponseWrapper(byte code) { @Override public boolean readFrom(ByteBuffer buf) { commState.setBuffer(buf); - switch (commState.idx) { - case 0: - code = commState.getByte("code"); - - if (!commState.lastRead()) - return false; - - commState.idx++; - - } - return true; } /** {@inheritDoc} */ @Override public byte directType() { - return 73; + return code; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMessageWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMessageWrapper.java index 04edfc76de36b..4ba6a4fc7059a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMessageWrapper.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMessageWrapper.java @@ -141,31 +141,31 @@ public void message(ByteBuffer msg) { switch (commState.idx) { case 0: - if (!commState.putUuid("clientId", clientId)) + if (!commState.putInt("msgSize", msgSize)) return false; commState.idx++; case 1: - if (!commState.putUuid("destId", destId)) + if (!commState.putLong("reqId", reqId)) return false; commState.idx++; case 2: - if (!commState.putByteBuffer("msg", msg)) + if (!commState.putUuid("clientId", clientId)) return false; commState.idx++; case 3: - if (!commState.putInt("msgSize", msgSize)) + if (!commState.putUuid("destId", destId)) return false; commState.idx++; case 4: - if (!commState.putLong("reqId", reqId)) + if (!commState.putByteBuffer("msg", msg)) return false; commState.idx++; @@ -181,7 +181,7 @@ public void message(ByteBuffer msg) { switch (commState.idx) { case 0: - clientId = commState.getUuid("clientId"); + msgSize = commState.getInt("msgSize"); if (!commState.lastRead()) return false; @@ -189,7 +189,7 @@ public void message(ByteBuffer msg) { commState.idx++; case 1: - destId = commState.getUuid("destId"); + reqId = commState.getLong("reqId"); if (!commState.lastRead()) return false; @@ -197,7 +197,7 @@ public void message(ByteBuffer msg) { commState.idx++; case 2: - msg = commState.getByteBuffer("msg"); + clientId = commState.getUuid("clientId"); if (!commState.lastRead()) return false; @@ -205,7 +205,7 @@ public void message(ByteBuffer msg) { commState.idx++; case 3: - msgSize = commState.getInt("msgSize"); + destId = commState.getUuid("destId"); if (!commState.lastRead()) return false; @@ -213,13 +213,12 @@ public void message(ByteBuffer msg) { commState.idx++; case 4: - reqId = commState.getLong("reqId"); + msg = commState.getByteBuffer("msg"); if (!commState.lastRead()) return false; commState.idx++; - } return true; @@ -227,7 +226,7 @@ public void message(ByteBuffer msg) { /** {@inheritDoc} */ @Override public byte directType() { - return 74; + return REQ_HEADER; } /** {@inheritDoc} */ @@ -244,8 +243,8 @@ public void message(ByteBuffer msg) { @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { GridClientMessageWrapper _clone = (GridClientMessageWrapper)_msg; - _clone.msgSize = msgSize; _clone.reqId = reqId; + _clone.msgSize = msgSize; _clone.clientId = clientId; _clone.destId = destId; _clone.msg = msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacketWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacketWrapper.java index 9e42be0080a81..6591bd102489f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacketWrapper.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacketWrapper.java @@ -57,25 +57,12 @@ public class GridClientPingPacketWrapper extends GridTcpCommunicationMessageAdap /** {@inheritDoc} */ @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); - - switch (commState.idx) { - case 0: - size = commState.getInt("size"); - - if (!commState.lastRead()) - return false; - - commState.idx++; - - } - - return true; + throw new UnsupportedOperationException(); } /** {@inheritDoc} */ @Override public byte directType() { - return 75; + return GridClientMessageWrapper.REQ_HEADER; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java index 6223e5ea37b62..e2583752e43e6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java @@ -86,25 +86,12 @@ public GridMemcachedMessageWrapper(GridMemcachedMessage msg, IgniteMarshaller jd /** {@inheritDoc} */ @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); - - switch (commState.idx) { - case 0: - bytes = commState.getByteArray("bytes"); - - if (!commState.lastRead()) - return false; - - commState.idx++; - - } - - return true; + throw new UnsupportedOperationException(); } /** {@inheritDoc} */ @Override public byte directType() { - return 78; + return MEMCACHE_RES_FLAG; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestDirectParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestDirectParser.java index 7a95fb2677f77..1fc7a0d8d45d7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestDirectParser.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestDirectParser.java @@ -23,6 +23,8 @@ import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.nio.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; +import org.gridgain.grid.util.direct.*; import org.jetbrains.annotations.*; import java.io.*; @@ -43,6 +45,9 @@ public class GridTcpRestDirectParser implements GridNioParser { /** Message metadata key. */ private static final int MSG_META_KEY = GridNioSessionMetaKey.nextUniqueKey(); + /** Message reader. */ + private final MessageReader rdr = new GridTcpCommunicationMessageReader(null); + /** Protocol handler. */ private final GridTcpRestProtocol proto; @@ -78,11 +83,15 @@ public GridTcpRestDirectParser(GridTcpRestProtocol proto) { buf.get(); msg = new GridClientMessageWrapper(); + + msg.setReader(rdr); } else if (type == GridClientHandshakeRequestWrapper.HANDSHAKE_HEADER) { buf.get(); msg = new GridClientHandshakeRequestWrapper(); + + msg.setReader(rdr); } else if (type == MEMCACHE_REQ_FLAG) { state = new ParserState(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageAdapter.java index 3580cb70bce1d..e414f55cb1cf8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageAdapter.java @@ -17,20 +17,12 @@ package org.apache.ignite.internal.util.direct; -import org.apache.ignite.internal.processors.cache.*; -import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.*; -import org.apache.ignite.internal.processors.cache.version.*; -import org.apache.ignite.internal.processors.clock.*; -import org.apache.ignite.internal.util.*; -import org.apache.ignite.lang.*; import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; import java.util.*; -import static org.apache.ignite.events.IgniteEventType.*; - /** * Communication message adapter. */ @@ -38,89 +30,6 @@ public abstract class GridTcpCommunicationMessageAdapter implements Serializable /** */ private static final long serialVersionUID = 0L; - /** */ - public static final byte[] BYTE_ARR_NOT_READ = new byte[0]; - - /** */ - public static final short[] SHORT_ARR_NOT_READ = new short[0]; - - /** */ - public static final int[] INT_ARR_NOT_READ = new int[0]; - - /** */ - public static final long[] LONG_ARR_NOT_READ = new long[0]; - - /** */ - public static final float[] FLOAT_ARR_NOT_READ = new float[0]; - - /** */ - public static final double[] DOUBLE_ARR_NOT_READ = new double[0]; - - /** */ - public static final char[] CHAR_ARR_NOT_READ = new char[0]; - - /** */ - public static final boolean[] BOOLEAN_ARR_NOT_READ = new boolean[0]; - - /** */ - public static final UUID UUID_NOT_READ = new UUID(0, 0); - - /** */ - public static final ByteBuffer BYTE_BUF_NOT_READ = ByteBuffer.allocate(0); - - /** */ - public static final IgniteUuid GRID_UUID_NOT_READ = new IgniteUuid(new UUID(0, 0), 0); - - /** */ - public static final GridClockDeltaVersion CLOCK_DELTA_VER_NOT_READ = new GridClockDeltaVersion(0, 0); - - /** */ - public static final GridByteArrayList BYTE_ARR_LIST_NOT_READ = new GridByteArrayList(new byte[0]); - - /** */ - public static final GridLongList LONG_LIST_NOT_READ = new GridLongList(0); - - /** */ - public static final GridCacheVersion CACHE_VER_NOT_READ = new GridCacheVersion(0, 0, 0, 0); - - /** */ - public static final GridDhtPartitionExchangeId DHT_PART_EXCHANGE_ID_NOT_READ = - new GridDhtPartitionExchangeId(new UUID(0, 0), EVT_NODE_LEFT, 1); - - /** */ - public static final GridCacheValueBytes VAL_BYTES_NOT_READ = new GridCacheValueBytes(); - - /** */ - @SuppressWarnings("RedundantStringConstructorCall") - public static final String STR_NOT_READ = new String(); - - /** */ - public static final BitSet BIT_SET_NOT_READ = new BitSet(); - - /** */ - public static final GridTcpCommunicationMessageAdapter MSG_NOT_READ = new GridTcpCommunicationMessageAdapter() { - @SuppressWarnings("CloneDoesntCallSuperClone") - @Override public GridTcpCommunicationMessageAdapter clone() { - throw new UnsupportedOperationException(); - } - - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { - throw new UnsupportedOperationException(); - } - - @Override public boolean writeTo(ByteBuffer buf) { - throw new UnsupportedOperationException(); - } - - @Override public boolean readFrom(ByteBuffer buf) { - throw new UnsupportedOperationException(); - } - - @Override public byte directType() { - throw new UnsupportedOperationException(); - } - }; - /** */ protected static final Object NULL = new Object(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageState.java b/modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageState.java index f0ac50ee71bca..66a8394650218 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageState.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageState.java @@ -381,8 +381,6 @@ public final boolean putByteBuffer(String name, @Nullable ByteBuffer buf) { if (buf != null) { ByteBuffer buf0 = buf.duplicate(); - buf0.flip(); - arr = new byte[buf0.remaining()]; buf0.get(arr); diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/GridTestMessage.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/GridTestMessage.java index 945cb133347ea..f36fa588a97a1 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/GridTestMessage.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/GridTestMessage.java @@ -163,7 +163,7 @@ public byte[] payload() { case 0: srcNodeId = commState.getUuid(null); - if (srcNodeId == UUID_NOT_READ) + if (!commState.lastRead()) return false; commState.idx++; @@ -187,7 +187,7 @@ public byte[] payload() { case 3: payload = commState.getByteArray(null); - if (payload == BYTE_ARR_NOT_READ) + if (!commState.lastRead()) return false; commState.idx++; From 888e8ed2a380ed8d5dbc71d7b28c0bba866c5be3 Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Thu, 5 Feb 2015 17:10:37 -0800 Subject: [PATCH 29/95] # IGNITE-61 - Direct marshalling --- .../apache/ignite/testframework/GridSpiTestContext.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java b/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java index 69cd4e081c633..fadd59e3e84d1 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java @@ -29,6 +29,7 @@ import org.apache.ignite.plugin.security.*; import org.apache.ignite.spi.*; import org.apache.ignite.spi.swapspace.*; +import org.gridgain.grid.util.direct.*; import org.jetbrains.annotations.*; import java.io.*; @@ -519,7 +520,11 @@ public void triggerEvent(IgniteEvent evt) { @Override public GridTcpMessageFactory messageFactory() { return new GridTcpMessageFactory() { @Override public GridTcpCommunicationMessageAdapter create(byte type) { - return GridTcpCommunicationMessageFactory.create(type); + GridTcpCommunicationMessageAdapter msg = GridTcpCommunicationMessageFactory.create(type); + + msg.setReader(new GridTcpCommunicationMessageReader(null)); + + return msg; } }; } From 9c0255beac1a2fe1787c0c3ba8ab38e6af471b3b Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Thu, 5 Feb 2015 19:25:09 -0800 Subject: [PATCH 30/95] IGNITE-61 - Direct marshalling --- .../direct/GridTcpCommunicationByteBufferStream.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationByteBufferStream.java b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationByteBufferStream.java index 379cc466923c7..0ffefb4994e60 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationByteBufferStream.java +++ b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationByteBufferStream.java @@ -205,7 +205,7 @@ public class GridTcpCommunicationByteBufferStream { private long baseOff; /** */ - private int arrOff; + private int arrOff = -1; /** */ private Object tmpArr; @@ -572,11 +572,13 @@ private boolean writeArray(Object arr, long off, int len, int bytes) { assert bytes >= 0; assert bytes >= arrOff; - if (arrOff == 0) { + if (arrOff == -1) { if (remaining() < 4) return false; writeInt(len); + + arrOff = 0; } int toWrite = bytes - arrOff; @@ -590,7 +592,7 @@ private boolean writeArray(Object arr, long off, int len, int bytes) { buf.position(pos); - arrOff = 0; + arrOff = -1; return true; } @@ -623,7 +625,7 @@ private T readArray(ArrayCreator creator, int lenShift, long off) { return null; } - int len = readInt(); + int len = readInt(); switch (len) { case -1: From 52b140b5659ec315e3a4d485fa77468daf5108be Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Thu, 5 Feb 2015 20:06:28 -0800 Subject: [PATCH 31/95] IGNITE-61 - Direct marshalling --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 25d64e8a725c4..7b226160d41f8 100644 --- a/pom.xml +++ b/pom.xml @@ -826,7 +826,7 @@ http://hadoop.apache.org/docs/current/api/ assembly/docfiles/javadoc.css - com.*:org.jetbrains.*:org.pcollections:*.jdk8:*.tests:*.tools:*.typedef:*.examples:*.client:*.kernal:*.internal:*.util:*.dr:*.compute.gridify.aop:*.spi.authentication:*.spi.securesession:*.spi.discovery.tcp.messages:*.spi.discovery.tcp.internal:*.spi.deployment.uri.scanners:*.spi.deployment.uri.tasks:*.spi.indexing.h2.opt:org.apache.ignite.portables:org.apache.ignite.yardstick:org.apache.ignite.schema.* + com.*:org.jetbrains.*:org.pcollections:*.jdk8:*.tests:*.tools:*.typedef:*.examples:*.client:*.kernal:*.internal:*.util:*.dr:*.compute.gridify.aop:*.spi.authentication:*.spi.securesession:*.spi.discovery.tcp.messages:*.spi.discovery.tcp.internal:*.spi.deployment.uri.scanners:*.spi.deployment.uri.tasks:*.spi.indexing.h2.opt:org.apache.ignite.portables:org.apache.ignite.yardstick:org.apache.ignite.schema.*:org.apache.ignite.codegen Common Grid APIs From f125cfb404be35175acd06ba91a87d8a386051d1 Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Thu, 5 Feb 2015 22:18:57 -0800 Subject: [PATCH 32/95] # IGNITE-61 - Direct marshalling --- .../tcp/GridMemcachedMessageWrapper.java | 21 +++++++------- .../GridTcpCommunicationByteBufferStream.java | 29 +++++++++++++++++-- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java index e2583752e43e6..906efa2c8a093 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java @@ -22,6 +22,7 @@ import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.marshaller.*; +import org.gridgain.grid.util.direct.*; import java.io.*; import java.nio.*; @@ -40,6 +41,9 @@ public class GridMemcachedMessageWrapper extends GridTcpCommunicationMessageAdap /** UTF-8 charset. */ private static final Charset UTF_8 = Charset.forName("UTF-8"); + /** Stream. */ + private final GridTcpCommunicationByteBufferStream stream = new GridTcpCommunicationByteBufferStream(null); + /** * Memcached message bytes. */ @@ -63,25 +67,20 @@ public GridMemcachedMessageWrapper(GridMemcachedMessage msg, IgniteMarshaller jd /** {@inheritDoc} */ @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + stream.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!buf.hasRemaining()) return false; + stream.writeByte(directType()); + commState.typeWritten = true; } - switch (commState.idx) { - case 0: - if (!commState.putByteArray("bytes", bytes)) - return false; - - commState.idx++; - - } + stream.writeByteArrayNoLength(bytes); - return true; + return stream.lastFinished(); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationByteBufferStream.java b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationByteBufferStream.java index 0ffefb4994e60..ea4a36f611f59 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationByteBufferStream.java +++ b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationByteBufferStream.java @@ -273,6 +273,15 @@ public void writeByteArray(byte[] val) { lastFinished = writeArray(val, BYTE_ARR_OFF, val.length, val.length); } + /** + * @param val Array. + */ + public void writeByteArrayNoLength(byte[] val) { + assert val != null; + + lastFinished = writeArray(val, BYTE_ARR_OFF, val.length, val.length, true); + } + /** {@inheritDoc} */ public void writeBoolean(boolean val) { int pos = buf.position(); @@ -565,6 +574,18 @@ public GridTcpCommunicationMessageAdapter readMessage() { * @return Whether array was fully written */ private boolean writeArray(Object arr, long off, int len, int bytes) { + return writeArray(arr, off, len, bytes, false); + } + + /** + * @param arr Array. + * @param off Offset. + * @param len Length. + * @param bytes Length in bytes. + * @param skipLen {@code true} if length should not be written. + * @return Whether array was fully written + */ + private boolean writeArray(Object arr, long off, int len, int bytes, boolean skipLen) { assert arr != null; assert arr.getClass().isArray() && arr.getClass().getComponentType().isPrimitive(); assert off > 0; @@ -573,10 +594,12 @@ private boolean writeArray(Object arr, long off, int len, int bytes) { assert bytes >= arrOff; if (arrOff == -1) { - if (remaining() < 4) - return false; + if (!skipLen) { + if (remaining() < 4) + return false; - writeInt(len); + writeInt(len); + } arrOff = 0; } From 1b9c34674784c2724fcb7b20a2fd5ca4ce840554 Mon Sep 17 00:00:00 2001 From: sboikov Date: Fri, 6 Feb 2015 10:00:18 +0300 Subject: [PATCH 33/95] # ignite-57 --- .../apache/ignite/cache/CacheProjection.java | 9 + .../processors/cache/GridCacheAdapter.java | 473 +++++++++--------- .../cache/GridCacheProjectionImpl.java | 6 + .../processors/cache/GridCacheProxyImpl.java | 13 + .../processors/cache/IgniteCacheProxy.java | 14 +- ... IgniteCacheAtomicLocalPeekModesTest.java} | 2 +- .../cache/IgniteCacheAtomicLocalSizeTest.java | 43 -- ...va => IgniteCacheAtomicPeekModesTest.java} | 2 +- ...teCacheAtomicReplicatedPeekModesTest.java} | 2 +- .../IgniteCacheAtomicReplicatedPeekTest.java | 32 -- .../IgniteCacheAtomicReplicatedSizeTest.java | 32 -- .../cache/IgniteCacheAtomicSizeTest.java | 49 -- ... => IgniteCachePeekModesAbstractTest.java} | 382 +++++++++++++- ...a => IgniteCacheTxLocalPeekModesTest.java} | 2 +- .../cache/IgniteCacheTxLocalSizeTest.java | 43 -- ...t.java => IgniteCacheTxPeekModesTest.java} | 2 +- ...IgniteCacheTxReplicatedPeekModesTest.java} | 2 +- .../cache/IgniteCacheTxSizeTest.java | 49 -- .../testsuites/IgniteCacheTestSuite.java | 19 +- 19 files changed, 632 insertions(+), 544 deletions(-) rename modules/core/src/test/java/org/apache/ignite/internal/processors/cache/{IgniteCacheAtomicLocalPeekTest.java => IgniteCacheAtomicLocalPeekModesTest.java} (93%) delete mode 100644 modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicLocalSizeTest.java rename modules/core/src/test/java/org/apache/ignite/internal/processors/cache/{IgniteCacheAtomicPeekTest.java => IgniteCacheAtomicPeekModesTest.java} (94%) rename modules/core/src/test/java/org/apache/ignite/internal/processors/cache/{IgniteCacheTxReplicatedSizeTest.java => IgniteCacheAtomicReplicatedPeekModesTest.java} (91%) delete mode 100644 modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicReplicatedPeekTest.java delete mode 100644 modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicReplicatedSizeTest.java delete mode 100644 modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicSizeTest.java rename modules/core/src/test/java/org/apache/ignite/internal/processors/cache/{IgniteCacheSizeAbstractTest.java => IgniteCachePeekModesAbstractTest.java} (52%) rename modules/core/src/test/java/org/apache/ignite/internal/processors/cache/{IgniteCacheTxLocalPeekTest.java => IgniteCacheTxLocalPeekModesTest.java} (93%) delete mode 100644 modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalSizeTest.java rename modules/core/src/test/java/org/apache/ignite/internal/processors/cache/{IgniteCacheTxPeekTest.java => IgniteCacheTxPeekModesTest.java} (94%) rename modules/core/src/test/java/org/apache/ignite/internal/processors/cache/{IgniteCacheTxReplicatedPeekTest.java => IgniteCacheTxReplicatedPeekModesTest.java} (92%) delete mode 100644 modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxSizeTest.java diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheProjection.java b/modules/core/src/main/java/org/apache/ignite/cache/CacheProjection.java index 3b664bd70ebda..54a85d90b8c9d 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/CacheProjection.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheProjection.java @@ -28,6 +28,7 @@ import org.apache.ignite.transactions.*; import org.jetbrains.annotations.*; +import javax.cache.*; import java.sql.*; import java.util.*; import java.util.Date; @@ -476,9 +477,17 @@ public interface CacheProjection extends Iterable> { * @param key Key. * @param peekModes Peek modes. * @return Value. + * @throws IgniteCheckedException If failed. */ @Nullable public V localPeek(K key, CachePeekMode[] peekModes) throws IgniteCheckedException; + /** + * @param peekModes Peek modes. + * @return Entries iterable. + * @throws IgniteCheckedException If failed. + */ + public Iterable> localEntries(CachePeekMode[] peekModes) throws IgniteCheckedException; + /** * Peeks at cached value using optional set of peek modes. This method will sequentially * iterate over given peek modes in the order passed in, and try to peek at value using diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java index af4f482ed534f..be74645141e3d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java @@ -656,102 +656,27 @@ public IgniteInternalFuture containsKeyAsync(K key, @Nullable IgnitePre } /** {@inheritDoc} */ - @SuppressWarnings("ForLoopReplaceableByForEach") - @Nullable @Override public V localPeek(K key, CachePeekMode[] peekModes) throws IgniteCheckedException { - A.notNull(key, "key"); - + @Override public Iterable> localEntries(CachePeekMode[] peekModes) throws IgniteCheckedException { assert peekModes != null; - if (keyCheck) - validateCacheKey(key); - ctx.checkSecurity(GridSecurityPermission.CACHE_READ); - boolean near = false; - boolean primary = false; - boolean backup = false; - - boolean heap = false; - boolean offheap = false; - boolean swap = false; - - if (peekModes.length == 0) { - near = true; - primary = true; - backup = true; - - heap = true; - offheap = true; - swap = true; - } - else { - for (int i = 0; i < peekModes.length; i++) { - CachePeekMode peekMode = peekModes[i]; - - A.notNull(peekMode, "peekMode"); - - switch (peekMode) { - case ALL: - near = true; - primary = true; - backup = true; - - heap = true; - offheap = true; - swap = true; - - break; - - case BACKUP: - backup = true; - - break; - - case PRIMARY: - primary = true; - - break; - - case NEAR: - near = true; + PeekModes modes = parsePeekModes(peekModes); - break; - - case ONHEAP: - heap = true; - - break; - - case OFFHEAP: - offheap = true; - - break; - - case SWAP: - swap = true; - - break; + return null; + } - default: - assert false : peekMode; - } - } - } + /** {@inheritDoc} */ + @SuppressWarnings("ForLoopReplaceableByForEach") + @Nullable @Override public V localPeek(K key, CachePeekMode[] peekModes) throws IgniteCheckedException { + A.notNull(key, "key"); - if (!(heap || offheap || swap)) { - heap = true; - offheap = true; - swap = true; - } + if (keyCheck) + validateCacheKey(key); - if (!(primary || backup || near)) { - primary = true; - backup = true; - near = true; - } + ctx.checkSecurity(GridSecurityPermission.CACHE_READ); - assert heap || offheap || swap; - assert primary || backup || near; + PeekModes modes = parsePeekModes(peekModes); try { if (ctx.portableEnabled()) @@ -766,11 +691,11 @@ public IgniteInternalFuture containsKeyAsync(K key, @Nullable IgnitePre boolean nearKey; - if (!(near && primary && backup)) { + if (!(modes.near && modes.primary && modes.backup)) { boolean keyPrimary = ctx.affinity().primary(ctx.localNode(), part, topVer); if (keyPrimary) { - if (!primary) + if (!modes.primary) return null; nearKey = false; @@ -779,20 +704,20 @@ public IgniteInternalFuture containsKeyAsync(K key, @Nullable IgnitePre boolean keyBackup = ctx.affinity().belongs(ctx.localNode(), part, topVer); if (keyBackup) { - if (!backup) + if (!modes.backup) return null; nearKey = false; } else { - if (!near) + if (!modes.near) return null; nearKey = true; // Swap and offheap are disabled for near cache. - offheap = false; - swap = false; + modes.offheap = false; + modes.swap = false; } } } @@ -801,36 +726,36 @@ public IgniteInternalFuture containsKeyAsync(K key, @Nullable IgnitePre if (nearKey) { // Swap and offheap are disabled for near cache. - offheap = false; - swap = false; + modes.offheap = false; + modes.swap = false; } } if (nearKey && !ctx.isNear()) return null; - if (heap) { + if (modes.heap) { GridCacheEntryEx e = nearKey ? peekEx(key) : (ctx.isNear() ? ctx.near().dht().peekEx(key) : peekEx(key)); if (e != null) { - val = e.peek(heap, offheap, swap, topVer); + val = e.peek(modes.heap, modes.offheap, modes.swap, topVer); - offheap = false; - swap = false; + modes.offheap = false; + modes.swap = false; } } - if (offheap || swap) { + if (modes.offheap || modes.swap) { GridCacheSwapManager swapMgr = ctx.isNear() ? ctx.near().dht().context().swap() : ctx.swap(); - GridCacheSwapEntry swapEntry = swapMgr.read(key, offheap, swap); + GridCacheSwapEntry swapEntry = swapMgr.read(key, modes.offheap, modes.swap); val = swapEntry != null ? swapEntry.value() : null; } } else - val = localCachePeek0(key, heap, offheap, swap); + val = localCachePeek0(key, modes.heap, modes.offheap, modes.swap); if (ctx.portableEnabled()) val = (V)ctx.unwrapPortableIfNeeded(val, ctx.keepPortable()); @@ -1323,22 +1248,22 @@ public Set> allEntries() { /** {@inheritDoc} */ @Override public Set> primaryEntrySet() { - return primaryEntrySet((IgnitePredicate>[])null); + return primaryEntrySet((IgnitePredicate>[]) null); } /** {@inheritDoc} */ @Override public Set keySet() { - return keySet((IgnitePredicate>[])null); + return keySet((IgnitePredicate>[]) null); } /** {@inheritDoc} */ @Override public Set primaryKeySet() { - return primaryKeySet((IgnitePredicate>[])null); + return primaryKeySet((IgnitePredicate>[]) null); } /** {@inheritDoc} */ @Override public Collection values() { - return values((IgnitePredicate>[])null); + return values((IgnitePredicate>[]) null); } /** {@inheritDoc} */ @@ -1612,7 +1537,8 @@ private boolean evictx(K key, GridCacheVersion ver, return getAllAsync(Collections.singletonList(key), /*force primary*/true, /*skip tx*/false, null, null, taskName, true).chain(new CX1>, V>() { - @Override public V applyx(IgniteInternalFuture> e) throws IgniteCheckedException { + @Override + public V applyx(IgniteInternalFuture> e) throws IgniteCheckedException { return e.get().get(key); } }); @@ -1634,7 +1560,7 @@ private boolean evictx(K key, GridCacheVersion ver, /** {@inheritDoc} */ @Nullable @Override public V reload(K key) throws IgniteCheckedException { - return reload(key, (IgnitePredicate>[])null); + return reload(key, (IgnitePredicate>[]) null); } /** {@inheritDoc} */ @@ -1663,7 +1589,7 @@ private boolean evictx(K key, GridCacheVersion ver, @Override public IgniteInternalFuture reloadAllAsync() { ctx.denyOnFlags(F.asList(LOCAL, READ)); - return reloadAllAsync(keySet(), (IgnitePredicate>[])null); + return reloadAllAsync(keySet(), (IgnitePredicate>[]) null); } /** @@ -1684,7 +1610,9 @@ public IgniteInternalFuture readThroughAllAsync(final Collection vis) { return ctx.closures().callLocalSafe(new GPC() { - @Nullable @Override public Object call() { + @Nullable + @Override + public Object call() { try { ctx.store().loadAllFromStore(tx, keys, vis); } @@ -1895,7 +1823,7 @@ public IgniteInternalFuture> reloadAllAsync(@Nullable Collection keys) { - evictAll(keys, (IgnitePredicate>[])null); + evictAll(keys, (IgnitePredicate>[]) null); } /** {@inheritDoc} */ @@ -1929,8 +1857,9 @@ public IgniteInternalFuture> reloadAllAsync(@Nullable Collection, V>() { - @Override public V applyx(IgniteInternalFuture f) throws IgniteCheckedException { - return (V)ctx.config().getInterceptor().onGet(key, f.get()); + @Override + public V applyx(IgniteInternalFuture f) throws IgniteCheckedException { + return (V) ctx.config().getInterceptor().onGet(key, f.get()); } }); @@ -2502,11 +2431,13 @@ public String toString() { ctx.denyOnLocalRead(); return asyncOp(new AsyncInOp(drMap.keySet()) { - @Override public IgniteInternalFuture inOp(IgniteTxLocalAdapter tx) { + @Override + public IgniteInternalFuture inOp(IgniteTxLocalAdapter tx) { return tx.putAllDrAsync(ctx, drMap); } - @Override public String toString() { + @Override + public String toString() { return "putAllDrAsync [drMap=" + drMap + ']'; } }); @@ -2528,7 +2459,7 @@ public String toString() { @Nullable @Override public EntryProcessorResult op(IgniteTxLocalAdapter tx) throws IgniteCheckedException { Map> invokeMap = - Collections.singletonMap(key, (EntryProcessor)entryProcessor); + Collections.singletonMap(key, (EntryProcessor) entryProcessor); IgniteInternalFuture>>> fut = tx.invokeAsync(ctx, invokeMap, args); @@ -2560,10 +2491,13 @@ public String toString() { ctx.denyOnLocalRead(); return syncOp(new SyncOp>>(keys.size() == 1) { - @Nullable @Override public Map> op(IgniteTxLocalAdapter tx) + @Nullable + @Override + public Map> op(IgniteTxLocalAdapter tx) throws IgniteCheckedException { Map> invokeMap = F.viewAsMap(keys, new C1>() { - @Override public EntryProcessor apply(K k) { + @Override + public EntryProcessor apply(K k) { return entryProcessor; } }); @@ -2594,7 +2528,7 @@ public String toString() { IgniteInternalFuture fut = asyncOp(new AsyncInOp(key) { @Override public IgniteInternalFuture>>> inOp(IgniteTxLocalAdapter tx) { Map> invokeMap = - Collections.singletonMap(key, (EntryProcessor)entryProcessor); + Collections.singletonMap(key, (EntryProcessor) entryProcessor); return tx.invokeAsync(ctx, invokeMap, args); } @@ -2693,7 +2627,8 @@ public String toString() { (IgniteInternalFuture>>>)fut; return fut0.chain(new CX1>>>, Map>>() { - @Override public Map> applyx( + @Override + public Map> applyx( IgniteInternalFuture>>> fut) throws IgniteCheckedException { GridCacheReturn>> ret = fut.get(); @@ -2755,12 +2690,14 @@ public String toString() { ctx.denyOnLocalRead(); return asyncOp(new AsyncOp(key) { - @Override public IgniteInternalFuture op(IgniteTxLocalAdapter tx) { + @Override + public IgniteInternalFuture op(IgniteTxLocalAdapter tx) { return tx.putAllAsync(ctx, F.t(key, val), false, entry, ttl, filter).chain( - (IgniteClosure>, Boolean>)RET2FLAG); + (IgniteClosure>, Boolean>) RET2FLAG); } - @Override public String toString() { + @Override + public String toString() { return "putxAsync [key=" + key + ", val=" + val + ", filter=" + Arrays.toString(filter) + ']'; } }); @@ -2804,12 +2741,14 @@ public String toString() { ctx.denyOnLocalRead(); IgniteInternalFuture fut = ctx.wrapClone(asyncOp(new AsyncOp(key) { - @Override public IgniteInternalFuture op(IgniteTxLocalAdapter tx) { + @Override + public IgniteInternalFuture op(IgniteTxLocalAdapter tx) { return tx.putAllAsync(ctx, F.t(key, val), true, null, -1, ctx.noPeekArray()) - .chain((IgniteClosure>, V>)RET2VAL); + .chain((IgniteClosure>, V>) RET2VAL); } - @Override public String toString() { + @Override + public String toString() { return "putIfAbsentAsync [key=" + key + ", val=" + val + ']'; } })); @@ -2836,11 +2775,13 @@ public String toString() { ctx.denyOnLocalRead(); Boolean stored = syncOp(new SyncOp(true) { - @Override public Boolean op(IgniteTxLocalAdapter tx) throws IgniteCheckedException { + @Override + public Boolean op(IgniteTxLocalAdapter tx) throws IgniteCheckedException { return tx.putAllAsync(ctx, F.t(key, val), false, null, -1, ctx.noPeekArray()).get().success(); } - @Override public String toString() { + @Override + public String toString() { return "putxIfAbsent [key=" + key + ", val=" + val + ']'; } }); @@ -2949,11 +2890,13 @@ public String toString() { ctx.denyOnLocalRead(); return syncOp(new SyncOp(true) { - @Override public Boolean op(IgniteTxLocalAdapter tx) throws IgniteCheckedException { + @Override + public Boolean op(IgniteTxLocalAdapter tx) throws IgniteCheckedException { return tx.putAllAsync(ctx, F.t(key, val), false, null, -1, ctx.hasPeekArray()).get().success(); } - @Override public String toString() { + @Override + public String toString() { return "replacex [key=" + key + ", val=" + val + ']'; } }); @@ -2971,12 +2914,14 @@ public String toString() { ctx.denyOnLocalRead(); return asyncOp(new AsyncOp(key) { - @Override public IgniteInternalFuture op(IgniteTxLocalAdapter tx) { + @Override + public IgniteInternalFuture op(IgniteTxLocalAdapter tx) { return tx.putAllAsync(ctx, F.t(key, val), false, null, -1, ctx.hasPeekArray()).chain( - (IgniteClosure>, Boolean>)RET2FLAG); + (IgniteClosure>, Boolean>) RET2FLAG); } - @Override public String toString() { + @Override + public String toString() { return "replacexAsync [key=" + key + ", val=" + val + ']'; } }); @@ -3100,11 +3045,13 @@ public String toString() { ctx.denyOnLocalRead(); return asyncOp(new AsyncInOp(m.keySet()) { - @Override public IgniteInternalFuture inOp(IgniteTxLocalAdapter tx) { + @Override + public IgniteInternalFuture inOp(IgniteTxLocalAdapter tx) { return tx.putAllAsync(ctx, m, false, null, -1, filter); } - @Override public String toString() { + @Override + public String toString() { return "putAllAsync [map=" + m + ", filter=" + Arrays.toString(filter) + ']'; } }); @@ -3131,16 +3078,18 @@ public String toString() { validateCacheKey(key); V prevVal = ctx.cloneOnFlag(syncOp(new SyncOp(true) { - @Override public V op(IgniteTxLocalAdapter tx) throws IgniteCheckedException { + @Override + public V op(IgniteTxLocalAdapter tx) throws IgniteCheckedException { V ret = tx.removeAllAsync(ctx, Collections.singletonList(key), entry, true, filter).get().value(); if (ctx.config().getInterceptor() != null) - return (V)ctx.config().getInterceptor().onBeforeRemove(key, ret).get2(); + return (V) ctx.config().getInterceptor().onBeforeRemove(key, ret).get2(); return ret; } - @Override public String toString() { + @Override + public String toString() { return "remove [key=" + key + ", filter=" + Arrays.toString(filter) + ']'; } })); @@ -3255,11 +3204,13 @@ public String toString() { ctx.denyOnLocalRead(); IgniteInternalFuture fut = asyncOp(new AsyncInOp(keys) { - @Override public IgniteInternalFuture inOp(IgniteTxLocalAdapter tx) { + @Override + public IgniteInternalFuture inOp(IgniteTxLocalAdapter tx) { return tx.removeAllAsync(ctx, keys, null, false, filter); } - @Override public String toString() { + @Override + public String toString() { return "removeAllAsync [keys=" + keys + ", filter=" + Arrays.toString(filter) + ']'; } }); @@ -3409,11 +3360,13 @@ public String toString() { ctx.dr().onReceiveCacheEntriesReceived(drMap.size()); return asyncOp(new AsyncInOp(drMap.keySet()) { - @Override public IgniteInternalFuture inOp(IgniteTxLocalAdapter tx) { + @Override + public IgniteInternalFuture inOp(IgniteTxLocalAdapter tx) { return tx.removeAllDrAsync(ctx, drMap); } - @Override public String toString() { + @Override + public String toString() { return "removeAllDrASync [drMap=" + drMap + ']'; } }); @@ -3429,7 +3382,8 @@ public String toString() { ctx.denyOnLocalRead(); return syncOp(new SyncOp>(true) { - @Override public GridCacheReturn op(IgniteTxLocalAdapter tx) throws IgniteCheckedException { + @Override + public GridCacheReturn op(IgniteTxLocalAdapter tx) throws IgniteCheckedException { // Register before hiding in the filter. if (ctx.deploymentEnabled()) ctx.deploy().registerClass(oldVal); @@ -3437,7 +3391,8 @@ public String toString() { return tx.putAllAsync(ctx, F.t(key, newVal), true, null, -1, ctx.equalsPeekArray(oldVal)).get(); } - @Override public String toString() { + @Override + public String toString() { return "replace [key=" + key + ", oldVal=" + oldVal + ", newVal=" + newVal + ']'; } }); @@ -3518,7 +3473,8 @@ public String toString() { validateCacheValue(val); boolean removed = syncOp(new SyncOp(true) { - @Override public Boolean op(IgniteTxLocalAdapter tx) throws IgniteCheckedException { + @Override + public Boolean op(IgniteTxLocalAdapter tx) throws IgniteCheckedException { // Register before hiding in the filter. if (ctx.deploymentEnabled()) ctx.deploy().registerClass(val); @@ -3526,13 +3482,14 @@ public String toString() { K key0 = key; if (ctx.portableEnabled()) - key0 = (K)ctx.marshalToPortable(key); + key0 = (K) ctx.marshalToPortable(key); return tx.removeAllAsync(ctx, Collections.singletonList(key0), null, false, ctx.vararg(F.cacheContainsPeek(val))).get().success(); } - @Override public String toString() { + @Override + public String toString() { return "remove [key=" + key + ", val=" + val + ']'; } }); @@ -4095,115 +4052,29 @@ IgniteInternalFuture globalLoadCacheAsync(@Nullable IgniteBiPredicate p /** {@inheritDoc} */ @SuppressWarnings("ForLoopReplaceableByForEach") @Override public int localSize(CachePeekMode[] peekModes) throws IgniteCheckedException { - assert peekModes != null; - - boolean near = false; - boolean primary = false; - boolean backup = false; - - boolean heap = false; - boolean offheap = false; - boolean swap = false; - - if (peekModes.length == 0) { - near = true; - primary = true; - backup = true; - - heap = true; - offheap = true; - swap = true; - } - else { - for (int i = 0; i < peekModes.length; i++) { - CachePeekMode peekMode = peekModes[i]; - - A.notNull(peekMode, "peekMode"); - - switch (peekMode) { - case ALL: - near = true; - primary = true; - backup = true; - - heap = true; - offheap = true; - swap = true; - - break; - - case BACKUP: - backup = true; - - break; - - case PRIMARY: - primary = true; - - break; - - case NEAR: - near = true; - - break; - - case ONHEAP: - heap = true; - - break; - - case OFFHEAP: - offheap = true; - - break; - - case SWAP: - swap = true; - - break; - - default: - assert false : peekMode; - } - } - } - - if (!(heap || offheap || swap)) { - heap = true; - offheap = true; - swap = true; - } - - if (!(primary || backup || near)) { - primary = true; - backup = true; - near = true; - } - - assert heap || offheap || swap; - assert primary || backup || near; + PeekModes modes = parsePeekModes(peekModes); int size = 0; if (ctx.isLocal()) { - primary = true; - backup = true; + modes.primary = true; + modes.backup = true; - if (heap) + if (modes.heap) size += size(); } else { - if (heap) { - if (near) + if (modes.heap) { + if (modes.near) size += nearSize(); GridCacheAdapter cache = ctx.isNear() ? ctx.near().dht() : ctx.cache(); - if (!(primary && backup)) { - if (primary) + if (!(modes.primary && modes.backup)) { + if (modes.primary) size += cache.primarySize(); - if (backup) + if (modes.backup) size += (cache.size() - cache.primarySize()); } else @@ -4212,16 +4083,16 @@ IgniteInternalFuture globalLoadCacheAsync(@Nullable IgniteBiPredicate p } // Swap and offheap are disabled for near cache. - if (primary || backup) { + if (modes.primary || modes.backup) { long topVer = ctx.affinity().affinityTopologyVersion(); GridCacheSwapManager swapMgr = ctx.isNear() ? ctx.near().dht().context().swap() : ctx.swap(); - if (swap) - size += swapMgr.swapEntriesCount(primary, backup, topVer); + if (modes.swap) + size += swapMgr.swapEntriesCount(modes.primary, modes.backup, topVer); - if (offheap) - size += swapMgr.offheapEntriesCount(primary, backup, topVer); + if (modes.offheap) + size += swapMgr.offheapEntriesCount(modes.primary, modes.backup, topVer); } return size; @@ -5402,6 +5273,114 @@ protected void validateCacheKeys(Iterable keys) { } } + /** + * + */ + private static class PeekModes { + boolean near; + boolean primary; + boolean backup; + + boolean heap; + boolean offheap; + boolean swap; + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(PeekModes.class, this); + } + } + + /** + * @param peekModes Cache peek modes array. + * @return Peek modes flags. + */ + private static PeekModes parsePeekModes(CachePeekMode[] peekModes) { + assert peekModes != null; + + PeekModes modes = new PeekModes(); + + if (peekModes.length == 0) { + modes.near = true; + modes.primary = true; + modes.backup = true; + + modes.heap = true; + modes.offheap = true; + modes.swap = true; + } + else { + for (int i = 0; i < peekModes.length; i++) { + CachePeekMode peekMode = peekModes[i]; + + A.notNull(peekMode, "peekMode"); + + switch (peekMode) { + case ALL: + modes.near = true; + modes.primary = true; + modes.backup = true; + + modes.heap = true; + modes.offheap = true; + modes.swap = true; + + break; + + case BACKUP: + modes.backup = true; + + break; + + case PRIMARY: + modes.primary = true; + + break; + + case NEAR: + modes.near = true; + + break; + + case ONHEAP: + modes.heap = true; + + break; + + case OFFHEAP: + modes.offheap = true; + + break; + + case SWAP: + modes.swap = true; + + break; + + default: + assert false : peekMode; + } + } + } + + if (!(modes.heap || modes.offheap || modes.swap)) { + modes.heap = true; + modes.offheap = true; + modes.swap = true; + } + + if (!(modes.primary || modes.backup || modes.near)) { + modes.primary = true; + modes.backup = true; + modes.near = true; + } + + assert modes.heap || modes.offheap || modes.swap; + assert modes.primary || modes.backup || modes.near; + + return modes; + } + /** * @param plc Explicitly specified expiry policy for cache operation. * @return Expiry policy wrapper. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java index 008b8293da44f..80b73419649df 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java @@ -36,6 +36,7 @@ import org.apache.ignite.transactions.*; import org.jetbrains.annotations.*; +import javax.cache.*; import javax.cache.expiry.*; import javax.cache.processor.*; import java.io.*; @@ -1024,6 +1025,11 @@ private IgnitePredicate> visitor(final IgnitePredicate> localEntries(CachePeekMode[] peekModes) throws IgniteCheckedException { + return cache.localEntries(peekModes); + } + /** {@inheritDoc} */ @Override public V peek(K key, @Nullable Collection modes) throws IgniteCheckedException { V val = cache.peek(key, modes); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java index 566f7168df791..8fd125ebfc48f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java @@ -35,6 +35,7 @@ import org.apache.ignite.transactions.*; import org.jetbrains.annotations.*; +import javax.cache.*; import javax.cache.expiry.*; import javax.cache.processor.*; import java.io.*; @@ -1229,6 +1230,18 @@ public GridCacheProjectionImpl gateProjection() { } } + /** {@inheritDoc} */ + @Override public Iterable> localEntries(CachePeekMode[] peekModes) throws IgniteCheckedException { + GridCacheProjectionImpl prev = gate.enter(prj); + + try { + return delegate.localEntries(peekModes); + } + finally { + gate.leave(prev); + } + } + /** {@inheritDoc} */ @Nullable @Override public V peek(K key, @Nullable Collection modes) throws IgniteCheckedException { GridCacheProjectionImpl prev = gate.enter(prj); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java index 3b24831ee8ce0..dc62f191e3245 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java @@ -241,8 +241,17 @@ public GridCacheContext context() { /** {@inheritDoc} */ @Override public Iterable> localEntries(CachePeekMode... peekModes) throws CacheException { - // TODO IGNITE-1. - throw new UnsupportedOperationException(); + GridCacheProjectionImpl prev = gate.enter(prj); + + try { + return delegate.localEntries(peekModes); + } + catch (IgniteCheckedException e) { + throw cacheException(e); + } + finally { + gate.leave(prev); + } } /** {@inheritDoc} */ @@ -736,7 +745,6 @@ public Set> entrySetx(IgnitePredicate>... filt /** {@inheritDoc} */ @Override public void clear() { - // TODO IGNITE-1. GridCacheProjectionImpl prev = gate.enter(prj); try { diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicLocalPeekTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicLocalPeekModesTest.java similarity index 93% rename from modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicLocalPeekTest.java rename to modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicLocalPeekModesTest.java index 4c3eb6a2205e0..024774b7d19d0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicLocalPeekTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicLocalPeekModesTest.java @@ -25,7 +25,7 @@ /** * */ -public class IgniteCacheAtomicLocalPeekTest extends IgniteCachePeekAbstractTest { +public class IgniteCacheAtomicLocalPeekModesTest extends IgniteCachePeekModesAbstractTest { /** {@inheritDoc} */ @Override protected CacheAtomicityMode atomicityMode() { return ATOMIC; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicLocalSizeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicLocalSizeTest.java deleted file mode 100644 index aaf5a5a768b10..0000000000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicLocalSizeTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.cache; - -import org.apache.ignite.cache.*; - -import static org.apache.ignite.cache.CacheAtomicityMode.*; -import static org.apache.ignite.cache.CacheMode.*; - -/** - * - */ -public class IgniteCacheAtomicLocalSizeTest extends IgniteCacheSizeAbstractTest { - /** {@inheritDoc} */ - @Override protected CacheAtomicityMode atomicityMode() { - return ATOMIC; - } - - /** {@inheritDoc} */ - @Override protected int gridCount() { - return 1; - } - - /** {@inheritDoc} */ - @Override protected CacheMode cacheMode() { - return LOCAL; - } -} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicPeekTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicPeekModesTest.java similarity index 94% rename from modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicPeekTest.java rename to modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicPeekModesTest.java index c2085ecaf6fdd..bf595f004a87c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicPeekTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicPeekModesTest.java @@ -26,7 +26,7 @@ /** * */ -public class IgniteCacheAtomicPeekTest extends IgniteCachePeekAbstractTest { +public class IgniteCacheAtomicPeekModesTest extends IgniteCachePeekModesAbstractTest { /** {@inheritDoc} */ @Override protected int gridCount() { return 4; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxReplicatedSizeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicReplicatedPeekModesTest.java similarity index 91% rename from modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxReplicatedSizeTest.java rename to modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicReplicatedPeekModesTest.java index a971bb8da0ede..7286ba301eead 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxReplicatedSizeTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicReplicatedPeekModesTest.java @@ -24,7 +24,7 @@ /** * */ -public class IgniteCacheTxReplicatedSizeTest extends IgniteCacheTxSizeTest { +public class IgniteCacheAtomicReplicatedPeekModesTest extends IgniteCacheAtomicPeekModesTest { /** {@inheritDoc} */ @Override protected CacheMode cacheMode() { return REPLICATED; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicReplicatedPeekTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicReplicatedPeekTest.java deleted file mode 100644 index 4d348274f8fea..0000000000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicReplicatedPeekTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.cache; - -import org.apache.ignite.cache.*; - -import static org.apache.ignite.cache.CacheMode.*; - -/** - * - */ -public class IgniteCacheAtomicReplicatedPeekTest extends IgniteCacheAtomicPeekTest { - /** {@inheritDoc} */ - @Override protected CacheMode cacheMode() { - return REPLICATED; - } -} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicReplicatedSizeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicReplicatedSizeTest.java deleted file mode 100644 index f4b466a560afc..0000000000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicReplicatedSizeTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.cache; - -import org.apache.ignite.cache.*; - -import static org.apache.ignite.cache.CacheMode.*; - -/** - * - */ -public class IgniteCacheAtomicReplicatedSizeTest extends IgniteCacheAtomicSizeTest { - /** {@inheritDoc} */ - @Override protected CacheMode cacheMode() { - return REPLICATED; - } -} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicSizeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicSizeTest.java deleted file mode 100644 index 62b52ff81ba7d..0000000000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicSizeTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.cache; - -import org.apache.ignite.cache.*; - -import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.*; -import static org.apache.ignite.cache.CacheAtomicityMode.*; -import static org.apache.ignite.cache.CacheMode.*; - -/** - * - */ -public class IgniteCacheAtomicSizeTest extends IgniteCacheSizeAbstractTest { - /** {@inheritDoc} */ - @Override protected CacheAtomicityMode atomicityMode() { - return ATOMIC; - } - - /** {@inheritDoc} */ - @Override protected int gridCount() { - return 4; - } - - /** {@inheritDoc} */ - @Override protected CacheMode cacheMode() { - return PARTITIONED; - } - - /** {@inheritDoc} */ - @Override protected CacheAtomicWriteOrderMode atomicWriteOrderMode() { - return PRIMARY; - } -} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSizeAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekModesAbstractTest.java similarity index 52% rename from modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSizeAbstractTest.java rename to modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekModesAbstractTest.java index dbc2e9a02127d..653b064a23223 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheSizeAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekModesAbstractTest.java @@ -35,9 +35,15 @@ import static org.apache.ignite.cache.CachePeekMode.*; /** - * + * Tests for methods using {@link CachePeekMode}: + *
    + *
  • {@link IgniteCache#localPeek(Object, CachePeekMode...)}
  • + *
  • {@link IgniteCache#localSize(CachePeekMode...)}
  • + *
  • {@link IgniteCache#size(CachePeekMode...)}
  • + *
  • {@link IgniteCache#localEntries(CachePeekMode...)}
  • + *
*/ -public abstract class IgniteCacheSizeAbstractTest extends IgniteCacheAbstractTest { +public abstract class IgniteCachePeekModesAbstractTest extends IgniteCacheAbstractTest { /** */ private static final int HEAP_ENTRIES = 10; @@ -78,6 +84,260 @@ public abstract class IgniteCacheSizeAbstractTest extends IgniteCacheAbstractTes return true; } + /** + * @throws Exception If failed. + */ + public void testLocalPeek() throws Exception { + if (cacheMode() == LOCAL) { + checkAffinityLocalCache(); + + checkStorage(0); + } + else { + checkAffinityPeek(0); + + checkAffinityPeek(1); + + checkStorage(0); + + checkStorage(1); + } + } + + /** + * @throws Exception If failed. + */ + private void checkAffinityLocalCache() throws Exception { + IgniteCache cache0 = jcache(0); + + final String val = "1"; + + for (int i = 0; i < HEAP_ENTRIES; i++) + cache0.put(i, val); + + try { + for (int i = 0; i < HEAP_ENTRIES; i++) { + assertEquals(val, cache0.localPeek(i)); + assertEquals(val, cache0.localPeek(i, ALL)); + assertEquals(val, cache0.localPeek(i, PRIMARY)); + assertEquals(val, cache0.localPeek(i, BACKUP)); + assertEquals(val, cache0.localPeek(i, NEAR)); + } + } + finally { + for (int i = 0; i < HEAP_ENTRIES; i++) + cache0.remove(i); + } + } + + /** + * @param nodeIdx Node index. + * @throws Exception If failed. + */ + private void checkAffinityPeek(int nodeIdx) throws Exception { + IgniteCache cache0 = jcache(nodeIdx); + + final String val = "1"; + + Integer key = null; + + try { + if (cacheMode() == REPLICATED) { + key = backupKey(cache0); + + cache0.put(key, val); + + assertEquals(val, cache0.localPeek(key, ALL)); + assertEquals(val, cache0.localPeek(key, BACKUP)); + assertNull(cache0.localPeek(key, NEAR)); + assertNull(cache0.localPeek(key, PRIMARY)); + } + else { + key = nearKey(cache0); + + cache0.put(key, val); + + boolean hasNearCache = nodeIdx == 0 ; + + if (hasNearCache) { + assertEquals(val, cache0.localPeek(key, NEAR)); + assertEquals(val, cache0.localPeek(key, ALL)); + } + else { + assertNull(cache0.localPeek(key, NEAR)); + assertNull(cache0.localPeek(key, ALL)); + } + + assertNull(cache0.localPeek(key, PRIMARY)); + assertNull(cache0.localPeek(key, BACKUP)); + } + + CacheAffinity aff = ignite(0).affinity(null); + + for (int i = 0; i < gridCount(); i++) { + if (i == nodeIdx) + continue; + + IgniteCache cache = jcache(i); + + assertNull(cache.localPeek(key, NEAR)); + + if (aff.isPrimary(ignite(i).cluster().localNode(), key)) { + assertEquals(val, cache.localPeek(key, PRIMARY)); + assertEquals(val, cache.localPeek(key, ALL)); + assertNull(cache.localPeek(key, BACKUP)); + assertNull(cache.localPeek(key, NEAR)); + } + else if (aff.isBackup(ignite(i).cluster().localNode(), key)) { + assertEquals(val, cache.localPeek(key, BACKUP)); + assertEquals(val, cache.localPeek(key, ALL)); + assertNull(cache.localPeek(key, PRIMARY)); + assertNull(cache.localPeek(key, NEAR)); + } + else { + assertNull(cache.localPeek(key, ALL)); + assertNull(cache.localPeek(key, PRIMARY)); + assertNull(cache.localPeek(key, BACKUP)); + assertNull(cache.localPeek(key, NEAR)); + } + } + } + finally { + if (key != null) + cache0.remove(key); + } + } + + /** + * @param nodeIdx Node index. + * @throws Exception If failed. + */ + private void checkStorage(int nodeIdx) throws Exception { + IgniteCache cache0 = jcache(nodeIdx); + + List keys = primaryKeys(cache0, 100, 10_000); + + try { + final String val = "test_value"; + + for (Integer key : keys) + cache0.put(key, val); + + FileSwapSpaceSpi swap = (FileSwapSpaceSpi)ignite(nodeIdx).configuration().getSwapSpaceSpi(); + + Set swapKeys = new HashSet<>(); + + final String spaceName = "gg-swap-cache-dflt"; + + IgniteSpiCloseableIterator it = swap.keyIterator(spaceName, null); + + assertNotNull(it); + + while (it.hasNext()) + assertTrue(swapKeys.add(it.next())); + + assertFalse(swapKeys.isEmpty()); + + assertTrue(swapKeys.size() + HEAP_ENTRIES < 100); + + Set offheapKeys = new HashSet<>(); + + GridCacheAdapter internalCache = + ((IgniteKernal)ignite(nodeIdx)).context().cache().internalCache(); + + Iterator> offheapIt; + + if (internalCache.context().isNear()) + offheapIt = internalCache.context().near().dht().context().swap().lazyOffHeapIterator(); + else + offheapIt = internalCache.context().swap().lazyOffHeapIterator(); + + while (offheapIt.hasNext()) { + Map.Entry e = offheapIt.next(); + + assertTrue(offheapKeys.add(e.getKey())); + + assertFalse(swapKeys.contains(e.getKey())); + } + + assertFalse(offheapKeys.isEmpty()); + + Set heapKeys = new HashSet<>(keys); + + heapKeys.removeAll(offheapKeys); + heapKeys.removeAll(swapKeys); + + assertFalse(heapKeys.isEmpty()); + + log.info("Keys [swap=" + swapKeys.size() + + ", offheap=" + offheapKeys.size() + + ", heap=" + heapKeys.size() + ']'); + + assertEquals(100, swapKeys.size() + offheapKeys.size() + heapKeys.size()); + + for (Integer key : swapKeys) { + assertEquals(val, cache0.localPeek(key, SWAP)); + assertEquals(val, cache0.localPeek(key, PRIMARY, SWAP)); + assertEquals(val, cache0.localPeek(key, ONHEAP, SWAP)); + assertEquals(val, cache0.localPeek(key, ONHEAP, OFFHEAP, SWAP)); + assertEquals(val, cache0.localPeek(key, PRIMARY, ONHEAP, SWAP)); + assertEquals(val, cache0.localPeek(key, PRIMARY, ONHEAP, OFFHEAP, SWAP)); + + if (cacheMode() == LOCAL) { + assertEquals(val, cache0.localPeek(key, SWAP, BACKUP)); + assertEquals(val, cache0.localPeek(key, SWAP, NEAR)); + } + else { + assertNull(cache0.localPeek(key, SWAP, BACKUP)); + assertNull(cache0.localPeek(key, SWAP, NEAR)); + } + + assertNull(cache0.localPeek(key, ONHEAP)); + assertNull(cache0.localPeek(key, OFFHEAP)); + } + + for (Integer key : offheapKeys) { + assertEquals(val, cache0.localPeek(key, OFFHEAP)); + assertEquals(val, cache0.localPeek(key, ONHEAP, OFFHEAP)); + assertEquals(val, cache0.localPeek(key, ONHEAP, SWAP, OFFHEAP)); + assertEquals(val, cache0.localPeek(key, PRIMARY, OFFHEAP)); + + if (cacheMode() == LOCAL) { + assertEquals(val, cache0.localPeek(key, OFFHEAP, BACKUP)); + assertEquals(val, cache0.localPeek(key, OFFHEAP, NEAR)); + } + else { + assertNull(cache0.localPeek(key, OFFHEAP, BACKUP)); + assertNull(cache0.localPeek(key, OFFHEAP, NEAR)); + } + + assertNull(cache0.localPeek(key, ONHEAP)); + assertNull(cache0.localPeek(key, SWAP)); + } + + for (Integer key : heapKeys) { + assertEquals(val, cache0.localPeek(key, ONHEAP)); + assertEquals(val, cache0.localPeek(key, SWAP, ONHEAP)); + assertEquals(val, cache0.localPeek(key, SWAP, OFFHEAP, ONHEAP)); + assertEquals(val, cache0.localPeek(key, PRIMARY, ONHEAP)); + + if (cacheMode() == LOCAL) { + assertEquals(val, cache0.localPeek(key, ONHEAP, BACKUP)); + assertEquals(val, cache0.localPeek(key, ONHEAP, NEAR)); + } + else { + assertNull(cache0.localPeek(key, ONHEAP, BACKUP)); + assertNull(cache0.localPeek(key, ONHEAP, NEAR)); + } + + assertNull(cache0.localPeek(key, SWAP)); + assertNull(cache0.localPeek(key, OFFHEAP)); + } + } + finally { + cache0.removeAll(new HashSet<>(keys)); + } + } /** * @throws Exception If failed. */ @@ -139,45 +399,55 @@ public void testSize() throws Exception { checkEmpty(); - for (int i = 0; i < 200; i++) + Set keys = new HashSet<>(); + + for (int i = 0; i < 200; i++) { cache0.put(i, "test_val"); - int totalKeys = 200; + keys.add(i); + } - T2 swapKeys = swapKeys(0); + try { + int totalKeys = 200; - T2 offheapKeys = offheapKeys(0); + T2 swapKeys = swapKeys(0); - int totalSwap = swapKeys.get1() + swapKeys.get2(); - int totalOffheap = offheapKeys.get1() + offheapKeys.get2(); + T2 offheapKeys = offheapKeys(0); - log.info("Keys [total=" + totalKeys + ", offheap=" + offheapKeys + ", swap=" + swapKeys + ']'); + int totalSwap = swapKeys.get1() + swapKeys.get2(); + int totalOffheap = offheapKeys.get1() + offheapKeys.get2(); - assertTrue(totalSwap + totalOffheap < totalKeys); + log.info("Keys [total=" + totalKeys + ", offheap=" + offheapKeys + ", swap=" + swapKeys + ']'); - assertEquals(totalKeys, cache0.localSize()); - assertEquals(totalKeys, cache0.localSize(ALL)); + assertTrue(totalSwap + totalOffheap < totalKeys); - assertEquals(totalOffheap, cache0.localSize(OFFHEAP)); - assertEquals(totalSwap, cache0.localSize(SWAP)); - assertEquals(totalKeys - (totalSwap + totalOffheap), cache0.localSize(ONHEAP)); + assertEquals(totalKeys, cache0.localSize()); + assertEquals(totalKeys, cache0.localSize(ALL)); + + assertEquals(totalOffheap, cache0.localSize(OFFHEAP)); + assertEquals(totalSwap, cache0.localSize(SWAP)); + assertEquals(totalKeys - (totalSwap + totalOffheap), cache0.localSize(ONHEAP)); - assertEquals(totalOffheap, cache0.size(OFFHEAP)); - assertEquals(totalSwap, cache0.size(SWAP)); - assertEquals(totalKeys - (totalSwap + totalOffheap), cache0.size(ONHEAP)); + assertEquals(totalOffheap, cache0.size(OFFHEAP)); + assertEquals(totalSwap, cache0.size(SWAP)); + assertEquals(totalKeys - (totalSwap + totalOffheap), cache0.size(ONHEAP)); - assertEquals(totalOffheap, cache0.localSize(OFFHEAP, PRIMARY)); - assertEquals(totalSwap, cache0.localSize(SWAP, PRIMARY)); - assertEquals(totalKeys - (totalSwap + totalOffheap), cache0.localSize(ONHEAP, PRIMARY)); + assertEquals(totalOffheap, cache0.localSize(OFFHEAP, PRIMARY)); + assertEquals(totalSwap, cache0.localSize(SWAP, PRIMARY)); + assertEquals(totalKeys - (totalSwap + totalOffheap), cache0.localSize(ONHEAP, PRIMARY)); - assertEquals(totalOffheap, cache0.localSize(OFFHEAP, BACKUP)); - assertEquals(totalSwap, cache0.localSize(SWAP, BACKUP)); - assertEquals(totalKeys - (totalSwap + totalOffheap), cache0.localSize(ONHEAP, BACKUP)); + assertEquals(totalOffheap, cache0.localSize(OFFHEAP, BACKUP)); + assertEquals(totalSwap, cache0.localSize(SWAP, BACKUP)); + assertEquals(totalKeys - (totalSwap + totalOffheap), cache0.localSize(ONHEAP, BACKUP)); + } + finally { + cache0.removeAll(keys); + } } else { - checkSizeAffinityFilter(0); + //checkSizeAffinityFilter(0); - checkSizeAffinityFilter(1); + //checkSizeAffinityFilter(1); checkSizeStorageFilter(0); @@ -441,7 +711,7 @@ private void checkSizeStorageFilter(int nodeIdx) throws Exception { int totalSwap = swapKeys.get1() + swapKeys.get2(); int totalOffheap = offheapKeys.get1() + offheapKeys.get2(); - log.info("Keys [total=" + totalKeys + ", offheap=" + offheapKeys + ", swap=" + swapKeys + ']'); + log.info("Local keys [total=" + totalKeys + ", offheap=" + offheapKeys + ", swap=" + swapKeys + ']'); assertTrue(totalSwap + totalOffheap < totalKeys); @@ -462,6 +732,64 @@ private void checkSizeStorageFilter(int nodeIdx) throws Exception { assertEquals(swapKeys.get2() + offheapKeys.get2(), cache0.localSize(SWAP, OFFHEAP, BACKUP)); assertEquals(totalSwap + totalOffheap, cache0.localSize(SWAP, OFFHEAP)); + + int globalSwapPrimary = 0; + int globalSwapBackup = 0; + + int globalOffheapPrimary = 0; + int globalOffheapBackup = 0; + + for (int i = 0; i < gridCount(); i++) { + T2 swap = swapKeys(i); + + globalSwapPrimary += swap.get1(); + globalSwapBackup += swap.get2(); + + T2 offheap = offheapKeys(i); + + globalOffheapPrimary += offheap.get1(); + globalOffheapBackup += offheap.get2(); + } + + int backups; + + if (cacheMode() == LOCAL) + backups = 0; + else if (cacheMode() == PARTITIONED) + backups = 1; + else // REPLICATED. + backups = gridCount() - 1; + + int globalTotal = totalKeys + totalKeys * backups; + int globalTotalSwap = globalSwapPrimary + globalSwapBackup; + int globalTotalOffheap = globalOffheapPrimary + globalOffheapBackup; + + log.info("Global keys [total=" + globalTotal + + ", offheap=" + globalTotalOffheap + + ", swap=" + globalTotalSwap + ']'); + + for (int i = 0; i < gridCount(); i++) { + IgniteCache cache = jcache(i); + + assertEquals(globalTotal, cache.size()); + assertEquals(globalTotal, cache.size(ALL)); + assertEquals(globalTotal, cache.size(ONHEAP, OFFHEAP, SWAP)); + assertEquals(globalTotal, cache.size(ONHEAP, OFFHEAP, SWAP, PRIMARY, BACKUP)); + + assertEquals(globalTotalSwap, cache.size(SWAP)); + assertEquals(globalSwapPrimary, cache.size(SWAP, PRIMARY)); + assertEquals(globalSwapBackup, cache.size(SWAP, BACKUP)); + + assertEquals(globalTotalOffheap, cache.size(OFFHEAP)); + assertEquals(globalOffheapPrimary, cache.size(OFFHEAP, PRIMARY)); + assertEquals(globalOffheapBackup, cache.size(OFFHEAP, BACKUP)); + + assertEquals(globalTotalSwap + globalTotalOffheap, cache.size(SWAP, OFFHEAP)); + assertEquals(globalSwapPrimary + globalOffheapPrimary, cache.size(SWAP, OFFHEAP, PRIMARY)); + assertEquals(globalSwapBackup + globalOffheapBackup, cache.size(SWAP, OFFHEAP, BACKUP)); + + assertEquals(globalTotal - (globalTotalOffheap + globalTotalSwap), cache.size(ONHEAP)); + } } finally { cache0.removeAll(new HashSet<>(primaryKeys)); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalPeekTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalPeekModesTest.java similarity index 93% rename from modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalPeekTest.java rename to modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalPeekModesTest.java index f4b70cfb85941..234d5013e8ea0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalPeekTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalPeekModesTest.java @@ -25,7 +25,7 @@ /** * */ -public class IgniteCacheTxLocalPeekTest extends IgniteCachePeekAbstractTest { +public class IgniteCacheTxLocalPeekModesTest extends IgniteCachePeekModesAbstractTest { /** {@inheritDoc} */ @Override protected CacheAtomicityMode atomicityMode() { return TRANSACTIONAL; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalSizeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalSizeTest.java deleted file mode 100644 index 5b0ddf7f0af9d..0000000000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalSizeTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.cache; - -import org.apache.ignite.cache.*; - -import static org.apache.ignite.cache.CacheAtomicityMode.*; -import static org.apache.ignite.cache.CacheMode.*; - -/** - * - */ -public class IgniteCacheTxLocalSizeTest extends IgniteCacheSizeAbstractTest { - /** {@inheritDoc} */ - @Override protected CacheAtomicityMode atomicityMode() { - return TRANSACTIONAL; - } - - /** {@inheritDoc} */ - @Override protected int gridCount() { - return 1; - } - - /** {@inheritDoc} */ - @Override protected CacheMode cacheMode() { - return LOCAL; - } -} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxPeekTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxPeekModesTest.java similarity index 94% rename from modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxPeekTest.java rename to modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxPeekModesTest.java index 0ddeaaf107d5a..08a2c7d777ff2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxPeekTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxPeekModesTest.java @@ -26,7 +26,7 @@ /** * */ -public class IgniteCacheTxPeekTest extends IgniteCachePeekAbstractTest { +public class IgniteCacheTxPeekModesTest extends IgniteCachePeekModesAbstractTest { /** {@inheritDoc} */ @Override protected int gridCount() { return 4; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxReplicatedPeekTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxReplicatedPeekModesTest.java similarity index 92% rename from modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxReplicatedPeekTest.java rename to modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxReplicatedPeekModesTest.java index 3b0f0f6939e0f..616ca3a10f064 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxReplicatedPeekTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxReplicatedPeekModesTest.java @@ -24,7 +24,7 @@ /** * */ -public class IgniteCacheTxReplicatedPeekTest extends IgniteCacheTxPeekTest { +public class IgniteCacheTxReplicatedPeekModesTest extends IgniteCacheTxPeekModesTest { /** {@inheritDoc} */ @Override protected CacheMode cacheMode() { return REPLICATED; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxSizeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxSizeTest.java deleted file mode 100644 index 70ff8b546c203..0000000000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxSizeTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.cache; - -import org.apache.ignite.cache.*; - -import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.*; -import static org.apache.ignite.cache.CacheAtomicityMode.*; -import static org.apache.ignite.cache.CacheMode.*; - -/** - * - */ -public class IgniteCacheTxSizeTest extends IgniteCacheSizeAbstractTest { - /** {@inheritDoc} */ - @Override protected CacheAtomicityMode atomicityMode() { - return TRANSACTIONAL; - } - - /** {@inheritDoc} */ - @Override protected int gridCount() { - return 4; - } - - /** {@inheritDoc} */ - @Override protected CacheMode cacheMode() { - return PARTITIONED; - } - - /** {@inheritDoc} */ - @Override protected CacheAtomicWriteOrderMode atomicWriteOrderMode() { - return PRIMARY; - } -} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java index d992295285a97..0bb95a5af0c93 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java @@ -367,19 +367,12 @@ public static TestSuite suite() throws Exception { suite.addTestSuite(IgniteCacheTxNearEnabledNoWriteThroughTest.class); suite.addTestSuite(IgniteCacheTxLocalNoWriteThroughTest.class); - suite.addTestSuite(IgniteCacheAtomicPeekTest.class); - suite.addTestSuite(IgniteCacheAtomicReplicatedPeekTest.class); - suite.addTestSuite(IgniteCacheAtomicLocalPeekTest.class); - suite.addTestSuite(IgniteCacheTxPeekTest.class); - suite.addTestSuite(IgniteCacheTxLocalPeekTest.class); - suite.addTestSuite(IgniteCacheTxReplicatedPeekTest.class); - - suite.addTestSuite(IgniteCacheAtomicSizeTest.class); - suite.addTestSuite(IgniteCacheAtomicReplicatedSizeTest.class); - suite.addTestSuite(IgniteCacheAtomicLocalSizeTest.class); - suite.addTestSuite(IgniteCacheTxSizeTest.class); - suite.addTestSuite(IgniteCacheTxReplicatedSizeTest.class); - suite.addTestSuite(IgniteCacheTxLocalSizeTest.class); + suite.addTestSuite(IgniteCacheAtomicPeekModesTest.class); + suite.addTestSuite(IgniteCacheAtomicReplicatedPeekModesTest.class); + suite.addTestSuite(IgniteCacheAtomicLocalPeekModesTest.class); + suite.addTestSuite(IgniteCacheTxPeekModesTest.class); + suite.addTestSuite(IgniteCacheTxLocalPeekModesTest.class); + suite.addTestSuite(IgniteCacheTxReplicatedPeekModesTest.class); // TODO: IGNITE-114. // suite.addTestSuite(IgniteCacheInvokeReadThroughTest.class); From b1959a30ec3beccb925e65cc7d0fb46f42f7b66a Mon Sep 17 00:00:00 2001 From: sboikov Date: Fri, 6 Feb 2015 14:44:57 +0300 Subject: [PATCH 34/95] # ignite-57 --- .../processors/cache/CacheEntryImpl0.java | 60 +++ .../cache/CacheWeakQueryIteratorsHolder.java | 4 +- .../processors/cache/GridCacheAdapter.java | 142 ++++++- .../cache/GridCacheSwapManager.java | 160 ++++++++ .../distributed/dht/GridDhtCacheAdapter.java | 80 +++- .../near/GridNearCacheAdapter.java | 8 + .../ignite/internal/util/lang/GridFunc.java | 149 ++++++++ .../IgniteCachePeekModesAbstractTest.java | 359 ++++++++++++++++-- 8 files changed, 933 insertions(+), 29 deletions(-) create mode 100644 modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImpl0.java diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImpl0.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImpl0.java new file mode 100644 index 0000000000000..05c30c35edd92 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImpl0.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache; + +import javax.cache.*; +import java.util.*; + +/** + * + */ +public class CacheEntryImpl0 implements Cache.Entry { + /** */ + private final Map.Entry e; + + /** + * @param e Entry. + */ + public CacheEntryImpl0(Map.Entry e) { + this.e = e; + } + + /** {@inheritDoc} */ + @Override public K getKey() { + return e.getKey(); + } + + /** {@inheritDoc} */ + @Override public V getValue() { + return e.getValue(); + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override public T unwrap(Class cls) { + if (!cls.equals(getClass())) + throw new IllegalArgumentException("Unwrapping to class is not supported: " + cls); + + return (T)this; + } + + /** {@inheritDoc} */ + public String toString() { + return "CacheEntry [key=" + getKey() + ", val=" + getValue() + ']'; + } +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheWeakQueryIteratorsHolder.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheWeakQueryIteratorsHolder.java index 902cf12479caf..4e19a0c9b41e6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheWeakQueryIteratorsHolder.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheWeakQueryIteratorsHolder.java @@ -123,7 +123,8 @@ public class WeakQueryFutureIterator extends GridCloseableIteratorAdapter /** Weak reference. */ private final WeakReference> weakRef; - CacheIteratorConverter convert; + /** */ + private final CacheIteratorConverter convert; /** Init flag. */ private boolean init; @@ -136,6 +137,7 @@ public class WeakQueryFutureIterator extends GridCloseableIteratorAdapter /** * @param fut GridCacheQueryFuture to iterate. + * @param convert Converter. */ WeakQueryFutureIterator(CacheQueryFuture fut, CacheIteratorConverter convert) { this.fut = fut; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java index be74645141e3d..68b846bb746ca 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java @@ -663,7 +663,50 @@ public IgniteInternalFuture containsKeyAsync(K key, @Nullable IgnitePre PeekModes modes = parsePeekModes(peekModes); - return null; + List>> its = new ArrayList<>(); + + if (ctx.isLocal()) { + modes.primary = true; + modes.backup = true; + + if (modes.heap) + its.add(iterator(map.entries0().iterator(), !ctx.keepPortable())); + } + else if (modes.heap) { + if (modes.near && ctx.isNear()) + its.add(ctx.near().nearEntriesIterator()); + + if (modes.primary || modes.backup) { + GridDhtCacheAdapter cache = ctx.isNear() ? ctx.near().dht() : ctx.dht(); + + its.add(cache.localEntriesIterator(modes.primary, modes.backup)); + } + } + + // Swap and offheap are disabled for near cache. + if (modes.primary || modes.backup) { + long topVer = ctx.affinity().affinityTopologyVersion(); + + GridCacheSwapManager swapMgr = ctx.isNear() ? ctx.near().dht().context().swap() : ctx.swap(); + + if (modes.swap) + its.add(swapMgr.swapIterator(modes.primary, modes.backup, topVer)); + + if (modes.offheap) + its.add(swapMgr.offheapIterator(modes.primary, modes.backup, topVer)); + } + + final Iterator> it = F.flatIterators(its); + + return new Iterable>() { + @Override public Iterator> iterator() { + return it; + } + + public String toString() { + return "CacheLocalEntries []"; + } + }; } /** {@inheritDoc} */ @@ -5273,16 +5316,113 @@ protected void validateCacheKeys(Iterable keys) { } } + /** + * @param it Internal entry iterator. + * @param deserializePortable Deserialize portable flag. + * @return Public API iterator. + */ + protected Iterator> iterator(final Iterator> it, + final boolean deserializePortable) { + return new Iterator>() { + { + advance(); + } + + /** */ + private Cache.Entry next; + + @Override public boolean hasNext() { + return next != null; + } + + @Override public Cache.Entry next() { + if (next == null) + throw new NoSuchElementException(); + + Cache.Entry e = next; + + advance(); + + return e; + } + + @Override public void remove() { + throw new UnsupportedOperationException(); + } + + /** + * Switch to next entry. + */ + private void advance() { + next = null; + + while (it.hasNext()) { + GridCacheEntryEx entry = it.next(); + + try { + V val = entry.innerGet( + null, + false, + false, + false, + true, + false, + false, + false, + null, + null, + null, + null, + null); + + if (val == null) + continue; + + K key = entry.key(); + + if (deserializePortable && ctx.portableEnabled()) { + key = (K)ctx.unwrapPortableIfNeeded(key, true); + val = (V)ctx.unwrapPortableIfNeeded(val, true); + } + + next = new CacheEntryImpl<>(key, val); + + break; + } + catch (IgniteCheckedException e) { + throw U.convertToCacheException(e); + } + catch (GridCacheEntryRemovedException ignore) { + // No-op. + } + catch (GridCacheFilterFailedException ignore) { + assert false; + } + } + } + }; + } + /** * */ private static class PeekModes { + /** */ boolean near; + + /** */ boolean primary; + + /** */ boolean backup; + /** */ boolean heap; + + /** */ boolean offheap; + + /** */ boolean swap; /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java index 419fdf556e77e..affd27ced47cb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java @@ -33,6 +33,7 @@ import org.jdk8.backport.*; import org.jetbrains.annotations.*; +import javax.cache.*; import java.lang.ref.*; import java.nio.*; import java.util.*; @@ -1510,6 +1511,66 @@ public GridCloseableIterator> rawSwapIterator() throws return swapMgr.rawIterator(spaceName); } + /** + * @param primary If {@code true} includes primary entries. + * @param backup If {@code true} includes backup entries. + * @param topVer Topology version. + * @return Swap entries iterator. + * @throws IgniteCheckedException If failed. + */ + public Iterator> swapIterator(boolean primary, boolean backup, long topVer) + throws IgniteCheckedException + { + assert primary || backup; + + if (!swapEnabled) + return F.emptyIterator(); + + if (primary && backup) + return cacheEntryIterator(lazySwapIterator()); + + Set parts = primary ? cctx.affinity().primaryPartitions(cctx.localNodeId(), topVer) : + cctx.affinity().backupPartitions(cctx.localNodeId(), topVer); + + return new PartitionsIterator(parts) { + @Override protected GridCloseableIterator> partitionIterator(int part) + throws IgniteCheckedException + { + return swapMgr.rawIterator(spaceName, part); + } + }; + } + + /** + * @param primary If {@code true} includes primary entries. + * @param backup If {@code true} includes backup entries. + * @param topVer Topology version. + * @return Offheap entries iterator. + * @throws IgniteCheckedException If failed. + */ + public Iterator> offheapIterator(boolean primary, boolean backup, long topVer) + throws IgniteCheckedException + { + assert primary || backup; + + if (!offheapEnabled) + return F.emptyIterator(); + + if (primary && backup) + return cacheEntryIterator(lazyOffHeapIterator()); + + Set parts = primary ? cctx.affinity().primaryPartitions(cctx.localNodeId(), topVer) : + cctx.affinity().backupPartitions(cctx.localNodeId(), topVer); + + return new PartitionsIterator(parts) { + @Override protected GridCloseableIterator> partitionIterator(int part) + throws IgniteCheckedException + { + return offheap.iterator(spaceName, part); + } + }; + } + /** * @param ldr Undeployed class loader. * @return Undeploy count. @@ -1610,6 +1671,19 @@ int iteratorSetSize() { return itSet.size(); } + /** + * @param it Map.Entry iterator. + * @return Cache.Entry iterator. + */ + private static Iterator> cacheEntryIterator(Iterator> it) { + return F.iterator(it, new C1, Cache.Entry>() { + @Override public Cache.Entry apply(Map.Entry e) { + // Create Cache.Entry over Map.Entry to do not deserialize key/values if not needed. + return new CacheEntryImpl0<>(e); + } + }, true); + } + /** * */ @@ -1688,4 +1762,90 @@ private static class KeySwapListener implements GridCacheSwapListener> { + /** */ + private Iterator partIt; + + /** */ + private Iterator> curIt; + + /** */ + private Cache.Entry next; + + /** + * @param parts Partitions + */ + public PartitionsIterator(Collection parts) { + this.partIt = parts.iterator(); + + advance(); + } + + /** {@inheritDoc} */ + @Override public boolean hasNext() { + return next != null; + } + + /** {@inheritDoc} */ + @Override public Cache.Entry next() { + if (next == null) + throw new NoSuchElementException(); + + Cache.Entry e = next; + + advance(); + + return e; + } + + /** {@inheritDoc} */ + @Override public void remove() { + throw new UnsupportedOperationException(); + } + + /** + * Switches to next element. + */ + private void advance() { + next = null; + + do { + if (curIt == null) { + if (partIt.hasNext()) { + int part = partIt.next(); + + try { + curIt = cacheEntryIterator(lazyIterator(partitionIterator(part))); + } + catch (IgniteCheckedException e) { + throw new IgniteException(e); + } + } + } + + if (curIt != null) { + if (curIt.hasNext()) { + next = curIt.next(); + + break; + } + else + curIt = null; + } + } + while (partIt.hasNext()); + } + + /** + * @param part Partition. + * @return Iterator for given partition. + * @throws IgniteCheckedException If failed. + */ + abstract protected GridCloseableIterator> partitionIterator(int part) + throws IgniteCheckedException; + } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java index e67364194c83e..f4d2d0e54b6e7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java @@ -35,6 +35,7 @@ import org.jdk8.backport.*; import org.jetbrains.annotations.*; +import javax.cache.*; import java.io.*; import java.util.*; import java.util.concurrent.*; @@ -720,7 +721,7 @@ public void sendTtlUpdateRequest(@Nullable final IgniteCacheExpiryPolicy expiryP ctx.io().send(req.getKey(), req.getValue()); } catch (IgniteCheckedException e) { - log.error("Failed to send TTL update request.", e); + U.error(log, "Failed to send TTL update request.", e); } } } @@ -910,6 +911,83 @@ private PartitionEntrySet(int partId) { } } + /** + * @param primary If {@code true} includes primary entries. + * @param backup If {@code true} includes backup entries. + * @return Local entries iterator. + */ + public Iterator> localEntriesIterator(final boolean primary, final boolean backup) { + assert primary || backup; + + if (primary && backup) + return iterator(map.entries0().iterator(), !ctx.keepPortable()); + else { + final long topVer = ctx.affinity().affinityTopologyVersion(); + + final Iterator> partIt = topology().currentLocalPartitions().iterator(); + + Iterator> it = new Iterator>() { + private GridCacheEntryEx next; + + private Iterator> curIt; + + { + advance(); + } + + @Override public boolean hasNext() { + return next != null; + } + + @Override public GridCacheEntryEx next() { + if (next == null) + throw new NoSuchElementException(); + + GridCacheEntryEx e = next; + + advance(); + + return e; + } + + @Override public void remove() { + throw new UnsupportedOperationException(); + } + + private void advance() { + next = null; + + do { + if (curIt == null) { + while (partIt.hasNext()) { + GridDhtLocalPartition part = partIt.next(); + + if (primary == part.primary(topVer)) { + curIt = part.entries().iterator(); + + break; + } + } + } + + if (curIt != null) { + if (curIt.hasNext()) { + next = curIt.next(); + + break; + } + else + curIt = null; + } + } + while (partIt.hasNext()); + } + }; + + return iterator(it, !ctx.keepPortable()); + } + } + /** * Complex partition iterator for both partition and swap iteration. */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java index abb16942af115..74d0f1ec410c5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java @@ -32,6 +32,7 @@ import org.apache.ignite.lang.*; import org.jetbrains.annotations.*; +import javax.cache.*; import javax.cache.expiry.*; import java.io.*; import java.util.*; @@ -780,6 +781,13 @@ private EntryIterator(Iterator> nearIter, Iterator> nearEntriesIterator() { + return iterator(map.entries0().iterator(), !ctx.keepPortable()); + } + /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridNearCacheAdapter.class, this); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java index 77df627081fec..6f319766cbbad 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java @@ -3090,6 +3090,65 @@ public static GridIterator flat(@Nullable final Iterable Iterator flatIterators(@Nullable final Iterable> c) { + return isEmpty(c) ? GridFunc.emptyIterator() : new GridIteratorAdapter() { + /** */ + private Iterator> a = c.iterator(); + + /** */ + private Iterator b; + + /** */ + private boolean moved = true; + + /** */ + private boolean more; + + @Override public boolean hasNextX() { + if (!moved) + return more; + + moved = false; + + if (b != null && b.hasNext()) + return more = true; + + while (a.hasNext()) { + b = a.next(); + + if (b.hasNext()) + return more = true; + } + + return more = false; + } + + @Override public T nextX() { + if (hasNext()) { + moved = true; + + return b.next(); + } + + throw new NoSuchElementException(); + } + + @Override public void removeX() { + assert b != null; + + b.remove(); + } + }; + } + /** * Flattens given set objects into a single collection. Unrolls {@link Collection}, * {@link Iterable} and {@code Object[]} objects. @@ -4312,6 +4371,96 @@ public static GridIterator iterator(final Iterable c, }; } + /** + * @param c Input iterator. + * @param trans Transforming closure to convert from T1 to T2. + * @param readOnly If {@code true}, then resulting iterator will not allow modifications + * to the underlying collection. + * @param p Optional filtering predicates. + * @return Iterator from given iterator and optional filtering predicate. + */ + public static Iterator iterator(final Iterator c, + final IgniteClosure trans, + final boolean readOnly, + @Nullable final IgnitePredicate... p) + { + A.notNull(c, "c", trans, "trans"); + + if (isAlwaysFalse(p)) + return F.emptyIterator(); + + return new GridIteratorAdapter() { + /** */ + private T1 elem; + + /** */ + private boolean moved = true; + + /** */ + private boolean more; + + /** */ + private Iterator iter = c; + + @Override public boolean hasNextX() { + if (isEmpty(p)) + return iter.hasNext(); + else { + if (!moved) + return more; + else { + more = false; + + while (iter.hasNext()) { + elem = iter.next(); + + boolean isAll = true; + + for (IgnitePredicate r : p) + if (r != null && !r.apply(elem)) { + isAll = false; + + break; + } + + if (isAll) { + more = true; + moved = false; + + return true; + } + } + + elem = null; // Give to GC. + + return false; + } + } + } + + @Nullable @Override public T2 nextX() { + if (isEmpty(p)) + return trans.apply(iter.next()); + else { + if (hasNext()) { + moved = true; + + return trans.apply(elem); + } + else + throw new NoSuchElementException(); + } + } + + @Override public void removeX() { + if (readOnly) + throw new UnsupportedOperationException("Cannot modify read-only iterator."); + + iter.remove(); + } + }; + } + /** * Gets predicate that always returns {@code true}. This method returns * constant predicate. diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekModesAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekModesAbstractTest.java index 653b064a23223..b1fd1673ac246 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekModesAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekModesAbstractTest.java @@ -28,6 +28,7 @@ import org.apache.ignite.spi.*; import org.apache.ignite.spi.swapspace.file.*; +import javax.cache.*; import java.util.*; import static org.apache.ignite.cache.CacheDistributionMode.*; @@ -45,7 +46,10 @@ */ public abstract class IgniteCachePeekModesAbstractTest extends IgniteCacheAbstractTest { /** */ - private static final int HEAP_ENTRIES = 10; + private static final String SPACE_NAME = "gg-swap-cache-dflt"; + + /** */ + private static final int HEAP_ENTRIES = 30; /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { @@ -227,9 +231,7 @@ private void checkStorage(int nodeIdx) throws Exception { Set swapKeys = new HashSet<>(); - final String spaceName = "gg-swap-cache-dflt"; - - IgniteSpiCloseableIterator it = swap.keyIterator(spaceName, null); + IgniteSpiCloseableIterator it = swap.keyIterator(SPACE_NAME, null); assertNotNull(it); @@ -338,6 +340,7 @@ private void checkStorage(int nodeIdx) throws Exception { cache0.removeAll(new HashSet<>(keys)); } } + /** * @throws Exception If failed. */ @@ -410,9 +413,9 @@ public void testSize() throws Exception { try { int totalKeys = 200; - T2 swapKeys = swapKeys(0); + T2 swapKeys = swapKeysCount(0); - T2 offheapKeys = offheapKeys(0); + T2 offheapKeys = offheapKeysCount(0); int totalSwap = swapKeys.get1() + swapKeys.get2(); int totalOffheap = offheapKeys.get1() + offheapKeys.get2(); @@ -445,9 +448,9 @@ public void testSize() throws Exception { } } else { - //checkSizeAffinityFilter(0); + checkSizeAffinityFilter(0); - //checkSizeAffinityFilter(1); + checkSizeAffinityFilter(1); checkSizeStorageFilter(0); @@ -608,14 +611,12 @@ private void checkEmpty() { /** * @param nodeIdx Node index. - * @return Tuple with number of primary and backup keys. + * @return Tuple with primary and backup keys. */ - private T2 swapKeys(int nodeIdx) { + private T2, List> swapKeys(int nodeIdx) { FileSwapSpaceSpi swap = (FileSwapSpaceSpi)ignite(nodeIdx).configuration().getSwapSpaceSpi(); - final String spaceName = "gg-swap-cache-dflt"; - - IgniteSpiCloseableIterator it = swap.keyIterator(spaceName, null); + IgniteSpiCloseableIterator it = swap.keyIterator(SPACE_NAME, null); assertNotNull(it); @@ -623,18 +624,18 @@ private T2 swapKeys(int nodeIdx) { ClusterNode node = ignite(nodeIdx).cluster().localNode(); - int primary = 0; - int backups = 0; + List primary = new ArrayList<>(); + List backups = new ArrayList<>(); while (it.hasNext()) { Integer key = it.next(); if (aff.isPrimary(node, key)) - primary++; + primary.add(key); else { assertTrue(aff.isBackup(node, key)); - backups++; + backups.add(key); } } @@ -645,7 +646,17 @@ private T2 swapKeys(int nodeIdx) { * @param nodeIdx Node index. * @return Tuple with number of primary and backup keys. */ - private T2 offheapKeys(int nodeIdx) { + private T2 swapKeysCount(int nodeIdx) { + T2, List> keys = swapKeys(nodeIdx); + + return new T2<>(keys.get1().size(), keys.get2().size()); + } + + /** + * @param nodeIdx Node index. + * @return Tuple with primary and backup keys. + */ + private T2, List> offheapKeys(int nodeIdx) { GridCacheAdapter internalCache = ((IgniteKernal)ignite(nodeIdx)).context().cache().internalCache(); @@ -660,24 +671,34 @@ private T2 offheapKeys(int nodeIdx) { ClusterNode node = ignite(nodeIdx).cluster().localNode(); - int primary = 0; - int backups = 0; + List primary = new ArrayList<>(); + List backups = new ArrayList<>(); while (offheapIt.hasNext()) { Map.Entry e = offheapIt.next(); if (aff.isPrimary(node, e.getKey())) - primary++; + primary.add(e.getKey()); else { assertTrue(aff.isBackup(node, e.getKey())); - backups++; + backups.add(e.getKey()); } } return new T2<>(primary, backups); } + /** + * @param nodeIdx Node index. + * @return Tuple with number of primary and backup keys. + */ + private T2 offheapKeysCount(int nodeIdx) { + T2, List> keys = offheapKeys(nodeIdx); + + return new T2<>(keys.get1().size(), keys.get2().size()); + } + /** * @param nodeIdx Node index. * @throws Exception If failed. @@ -698,12 +719,12 @@ private void checkSizeStorageFilter(int nodeIdx) throws Exception { int totalKeys = 200; - T2 swapKeys = swapKeys(nodeIdx); + T2 swapKeys = swapKeysCount(nodeIdx); assertTrue(swapKeys.get1() > 0); assertTrue(swapKeys.get2() > 0); - T2 offheapKeys = offheapKeys(nodeIdx); + T2 offheapKeys = offheapKeysCount(nodeIdx); assertTrue(offheapKeys.get1() > 0); assertTrue(offheapKeys.get2() > 0); @@ -740,12 +761,12 @@ private void checkSizeStorageFilter(int nodeIdx) throws Exception { int globalOffheapBackup = 0; for (int i = 0; i < gridCount(); i++) { - T2 swap = swapKeys(i); + T2 swap = swapKeysCount(i); globalSwapPrimary += swap.get1(); globalSwapBackup += swap.get2(); - T2 offheap = offheapKeys(i); + T2 offheap = offheapKeysCount(i); globalOffheapPrimary += offheap.get1(); globalOffheapBackup += offheap.get2(); @@ -821,4 +842,290 @@ private void checkPrimarySize(int exp) { assertEquals(exp, size); } + + /** + * @throws Exception If failed. + */ + public void testLocalEntries() throws Exception { + if (cacheMode() == LOCAL) { + IgniteCache cache0 = jcache(0); + + Set keys = new HashSet<>(); + + try { + for (int i = 0; i < HEAP_ENTRIES; i++) { + cache0.put(i, String.valueOf(i)); + + keys.add(i); + } + + checkLocalEntries(cache0.localEntries(), keys); + checkLocalEntries(cache0.localEntries(ALL), keys); + checkLocalEntries(cache0.localEntries(NEAR), keys); + checkLocalEntries(cache0.localEntries(PRIMARY), keys); + checkLocalEntries(cache0.localEntries(BACKUP), keys); + } + finally { + cache0.removeAll(keys); + } + + checkLocalEntries(cache0.localEntries()); + + final String val = "test-val-"; + + keys = new HashSet<>(); + + for (int i = 0; i < 200; i++) { + cache0.put(i, val + i); + + keys.add(i); + } + + try { + int totalKeys = 200; + + T2, List> swapKeys = swapKeys(0); + + T2, List> offheapKeys = offheapKeys(0); + + List swap = new ArrayList<>(); + + swap.addAll(swapKeys.get1()); + swap.addAll(swapKeys.get2()); + + assertFalse(swap.isEmpty()); + + List offheap = new ArrayList<>(); + + offheap.addAll(offheapKeys.get1()); + offheap.addAll(offheapKeys.get2()); + + assertFalse(offheap.isEmpty()); + + log.info("Keys [total=" + totalKeys + + ", offheap=" + offheap.size() + + ", swap=" + swap.size() + ']'); + + assertTrue(swap.size() + offheap.size() < totalKeys); + + List heap = new ArrayList<>(keys); + + heap.removeAll(swap); + heap.removeAll(offheap); + + assertFalse(heap.isEmpty()); + + checkLocalEntries(cache0.localEntries(), val, keys); + checkLocalEntries(cache0.localEntries(ALL), val, keys); + + checkLocalEntries(cache0.localEntries(OFFHEAP), val, offheap); + checkLocalEntries(cache0.localEntries(SWAP), val, swap); + checkLocalEntries(cache0.localEntries(ONHEAP), val, heap); + + checkLocalEntries(cache0.localEntries(OFFHEAP, PRIMARY), val, offheap); + checkLocalEntries(cache0.localEntries(SWAP, PRIMARY), val, swap); + checkLocalEntries(cache0.localEntries(ONHEAP, PRIMARY), val, heap); + + checkLocalEntries(cache0.localEntries(OFFHEAP, BACKUP), val, offheap); + checkLocalEntries(cache0.localEntries(SWAP, BACKUP), val, swap); + checkLocalEntries(cache0.localEntries(ONHEAP, BACKUP), val, heap); + + checkLocalEntries(cache0.localEntries(OFFHEAP, NEAR), val, offheap); + checkLocalEntries(cache0.localEntries(SWAP, NEAR), val, swap); + checkLocalEntries(cache0.localEntries(ONHEAP, NEAR), val, heap); + } + finally { + cache0.removeAll(keys); + } + } + else { + //checkLocalEntriesAffinityFilter(0); + + //checkLocalEntriesAffinityFilter(1); + + checkLocalEntriesStorageFilter(0); + + checkLocalEntriesStorageFilter(1); + } + } + + /** + * @param nodeIdx Node index. + * @throws Exception If failed. + */ + private void checkLocalEntriesStorageFilter(int nodeIdx) throws Exception { + IgniteCache cache0 = jcache(nodeIdx); + + List primaryKeys = primaryKeys(cache0, 100, 10_000); + List backupKeys = backupKeys(cache0, 100, 10_000); + + try { + final String val = "test_value-"; + + for (int i = 0; i < 100; i++) { + cache0.put(primaryKeys.get(i), val + primaryKeys.get(i)); + cache0.put(backupKeys.get(i), val + backupKeys.get(i)); + } + + int totalKeys = 200; + + T2, List> swapKeys = swapKeys(nodeIdx); + + assertTrue(swapKeys.get1().size() > 0); + assertTrue(swapKeys.get2().size() > 0); + + T2, List> offheapKeys = offheapKeys(nodeIdx); + + assertTrue(offheapKeys.get1().size() > 0); + assertTrue(offheapKeys.get2().size() > 0); + + List swap = new ArrayList<>(); + + swap.addAll(swapKeys.get1()); + swap.addAll(swapKeys.get2()); + + assertFalse(swap.isEmpty()); + + List offheap = new ArrayList<>(); + + offheap.addAll(offheapKeys.get1()); + offheap.addAll(offheapKeys.get2()); + + assertFalse(offheap.isEmpty()); + + List heap = new ArrayList<>(); + + heap.addAll(primaryKeys); + heap.addAll(backupKeys); + + heap.removeAll(swap); + heap.removeAll(offheap); + + log.info("Keys [total=" + totalKeys + + ", offheap=" + offheap.size() + + ", swap=" + swap.size() + ']'); + + assertFalse(heap.isEmpty()); + + checkLocalEntries(cache0.localEntries(), val, primaryKeys, backupKeys); + checkLocalEntries(cache0.localEntries(ALL), val, primaryKeys, backupKeys); + checkLocalEntries(cache0.localEntries(ONHEAP, OFFHEAP, SWAP), val, primaryKeys, backupKeys); + + checkLocalEntries(cache0.localEntries(SWAP), val, swap); + checkLocalEntries(cache0.localEntries(OFFHEAP), val, offheap); + checkLocalEntries(cache0.localEntries(ONHEAP), val, heap); + + checkLocalEntries(cache0.localEntries(SWAP, OFFHEAP), val, swap, offheap); + checkLocalEntries(cache0.localEntries(SWAP, ONHEAP), val, swap, heap); + + checkLocalEntries(cache0.localEntries(SWAP, PRIMARY), val, swapKeys.get1()); + checkLocalEntries(cache0.localEntries(SWAP, BACKUP), val, swapKeys.get2()); + checkLocalEntries(cache0.localEntries(OFFHEAP, PRIMARY), val, offheapKeys.get1()); + checkLocalEntries(cache0.localEntries(OFFHEAP, BACKUP), val, offheapKeys.get2()); + + checkLocalEntries(cache0.localEntries(SWAP, OFFHEAP, PRIMARY), val, swapKeys.get1(), offheapKeys.get1()); + checkLocalEntries(cache0.localEntries(SWAP, OFFHEAP, BACKUP), val, swapKeys.get2(), offheapKeys.get2()); + checkLocalEntries(cache0.localEntries(SWAP, OFFHEAP, PRIMARY, BACKUP), val, swap, offheap); + } + finally { + cache0.removeAll(new HashSet<>(primaryKeys)); + cache0.removeAll(new HashSet<>(backupKeys)); + } + } + + /** + * @param nodeIdx Node index. + * @throws Exception If failed. + */ + private void checkLocalEntriesAffinityFilter(int nodeIdx) throws Exception { + IgniteCache cache0 = jcache(nodeIdx); + + final int PUT_KEYS = 10; + + List primaryKeys = null; + List backupKeys = null; + List nearKeys = null; + + try { + primaryKeys = primaryKeys(cache0, PUT_KEYS, 0); + backupKeys = backupKeys(cache0, PUT_KEYS, 0); + + for (Integer key : primaryKeys) + cache0.put(key, String.valueOf(key)); + for (Integer key : backupKeys) + cache0.put(key, String.valueOf(key)); + + nearKeys = cacheMode() == PARTITIONED ? nearKeys(cache0, PUT_KEYS, 0) : Collections.emptyList(); + + for (Integer key : nearKeys) + cache0.put(key, String.valueOf(key)); + + log.info("Keys [near=" + nearKeys + ", primary=" + primaryKeys + ", backup=" + backupKeys + ']'); + + boolean hasNearCache = nodeIdx == 0 && cacheMode() == PARTITIONED; + + if (hasNearCache) { + checkLocalEntries(cache0.localEntries(), nearKeys, primaryKeys, backupKeys); + checkLocalEntries(cache0.localEntries(ALL), nearKeys, primaryKeys, backupKeys); + checkLocalEntries(cache0.localEntries(NEAR), nearKeys); + checkLocalEntries(cache0.localEntries(PRIMARY, BACKUP, NEAR), nearKeys, primaryKeys, backupKeys); + checkLocalEntries(cache0.localEntries(NEAR, PRIMARY), nearKeys, primaryKeys); + checkLocalEntries(cache0.localEntries(NEAR, BACKUP), nearKeys, backupKeys); + } + else { + checkLocalEntries(cache0.localEntries(), primaryKeys, backupKeys); + checkLocalEntries(cache0.localEntries(ALL), primaryKeys, backupKeys); + checkLocalEntries(cache0.localEntries(NEAR)); + checkLocalEntries(cache0.localEntries(NEAR, PRIMARY), primaryKeys); + checkLocalEntries(cache0.localEntries(NEAR, BACKUP), backupKeys); + checkLocalEntries(cache0.localEntries(PRIMARY, BACKUP, NEAR), primaryKeys, backupKeys); + } + + checkLocalEntries(cache0.localEntries(PRIMARY), primaryKeys); + checkLocalEntries(cache0.localEntries(BACKUP), backupKeys); + checkLocalEntries(cache0.localEntries(PRIMARY, BACKUP), primaryKeys, backupKeys); + } + finally { + if (primaryKeys != null) + cache0.removeAll(new HashSet<>(primaryKeys)); + + if (backupKeys != null) + cache0.removeAll(new HashSet<>(backupKeys)); + + if (nearKeys != null) + cache0.removeAll(new HashSet<>(nearKeys)); + } + } + + /** + * @param entries Entries. + * @param exp Expected entries. + */ + private void checkLocalEntries(Iterable> entries, Collection... exp) { + checkLocalEntries(entries, "", exp); + } + + /** + * @param entries Entries. + * @param expVal Expected value. + * @param exp Expected keys. + */ + private void checkLocalEntries(Iterable> entries, + String expVal, + Collection... exp) { + Set allExp = new HashSet<>(); + + for (Collection col : exp) + assertTrue(allExp.addAll(col)); + + for (Cache.Entry e : entries) { + assertNotNull(e.getKey()); + assertNotNull(e.getValue()); + assertEquals(expVal + e.getKey(), e.getValue()); + + assertTrue("Unexpected entry: " + e, allExp.remove(e.getKey())); + } + + assertTrue("Expected entries not found: " + allExp, allExp.isEmpty()); + } } From 724a3f1b2d93d67d59e16b810fbd3483edab25f2 Mon Sep 17 00:00:00 2001 From: sboikov Date: Fri, 6 Feb 2015 16:31:38 +0300 Subject: [PATCH 35/95] # ignite-57 --- .../processors/cache/IgniteCachePeekModesAbstractTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekModesAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekModesAbstractTest.java index b1fd1673ac246..96cc9af8cc380 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekModesAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekModesAbstractTest.java @@ -939,9 +939,9 @@ public void testLocalEntries() throws Exception { } } else { - //checkLocalEntriesAffinityFilter(0); + checkLocalEntriesAffinityFilter(0); - //checkLocalEntriesAffinityFilter(1); + checkLocalEntriesAffinityFilter(1); checkLocalEntriesStorageFilter(0); From 7d9dbf72d18fbebe885529accb3d02e16453085e Mon Sep 17 00:00:00 2001 From: sboikov Date: Fri, 6 Feb 2015 16:55:52 +0300 Subject: [PATCH 36/95] # ignite-57 --- .../processors/cache/GridCacheAdapter.java | 102 +++++++++++++----- .../processors/cache/IgniteCacheProxy.java | 13 ++- 2 files changed, 85 insertions(+), 30 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java index 68b846bb746ca..0f2158e8736f4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java @@ -4058,6 +4058,31 @@ IgniteInternalFuture globalLoadCacheAsync(@Nullable IgniteBiPredicate p return e == null || e.obsolete() ? null : e.wrap(true); } + /** + * @return Random entry. + * @throws IgniteCheckedException If failed. + */ + public Cache.Entry randomCacheEntry() throws IgniteCheckedException { + boolean keepPortable = ctx.keepPortable(); + + while (true) { + GridCacheMapEntry e = map.randomEntry(); + + if (e == null) + return null; + + try { + Cache.Entry entry = toCacheEntry(e, !keepPortable); + + if (entry != null) + return entry; + } + catch (GridCacheEntryRemovedException ignore) { + // No-op. + } + } + } + /** {@inheritDoc} */ @Override public int size(CachePeekMode[] peekModes) throws IgniteCheckedException { if (isLocal()) @@ -5360,32 +5385,10 @@ private void advance() { GridCacheEntryEx entry = it.next(); try { - V val = entry.innerGet( - null, - false, - false, - false, - true, - false, - false, - false, - null, - null, - null, - null, - null); - - if (val == null) - continue; + next = toCacheEntry(entry, deserializePortable); - K key = entry.key(); - - if (deserializePortable && ctx.portableEnabled()) { - key = (K)ctx.unwrapPortableIfNeeded(key, true); - val = (V)ctx.unwrapPortableIfNeeded(val, true); - } - - next = new CacheEntryImpl<>(key, val); + if (next == null) + continue; break; } @@ -5395,14 +5398,57 @@ private void advance() { catch (GridCacheEntryRemovedException ignore) { // No-op. } - catch (GridCacheFilterFailedException ignore) { - assert false; - } } } }; } + /** + * @param entry Internal entry. + * @param deserializePortable Deserialize portable flag. + * @return Public API entry. + * @throws IgniteCheckedException If failed. + * @throws GridCacheEntryRemovedException If entry removed. + */ + @Nullable private Cache.Entry toCacheEntry(GridCacheEntryEx entry, + boolean deserializePortable) + throws IgniteCheckedException, GridCacheEntryRemovedException + { + try { + V val = entry.innerGet( + null, + false, + false, + false, + true, + false, + false, + false, + null, + null, + null, + null, + null); + + if (val == null) + return null; + + K key = entry.key(); + + if (deserializePortable && ctx.portableEnabled()) { + key = (K)ctx.unwrapPortableIfNeeded(key, true); + val = (V)ctx.unwrapPortableIfNeeded(val, true); + } + + return new CacheEntryImpl<>(key, val); + } + catch (GridCacheFilterFailedException ignore) { + assert false; + + return null; + } + } + /** * */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java index 42c0705175717..c6166af730912 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java @@ -131,8 +131,17 @@ public GridCacheContext context() { /** {@inheritDoc} */ @Nullable @Override public Entry randomEntry() { - // TODO IGNITE-1. - throw new UnsupportedOperationException(); + GridCacheProjectionImpl prev = gate.enter(prj); + + try { + return ctx.cache().randomCacheEntry(); + } + catch (IgniteCheckedException e) { + throw cacheException(e); + } + finally { + gate.leave(prev); + } } /** {@inheritDoc} */ From 9140a08747366186778382a09674c0e95b03d53a Mon Sep 17 00:00:00 2001 From: sboikov Date: Fri, 6 Feb 2015 21:43:11 +0300 Subject: [PATCH 37/95] # ignite-57 async support for removeAll() --- .../apache/ignite/cache/CacheProjection.java | 5 ++ .../cache/GridCacheProjectionImpl.java | 5 ++ .../processors/cache/GridCacheProxyImpl.java | 12 ++++ .../processors/cache/IgniteCacheProxy.java | 5 +- .../GridDistributedCacheAdapter.java | 60 +++++++++++++++-- .../distributed/near/GridNearAtomicCache.java | 5 ++ .../cache/local/GridLocalCache.java | 12 ++++ .../local/atomic/GridLocalAtomicCache.java | 11 ++++ .../GridCacheAbstractFullApiSelfTest.java | 64 +++++++++++++++---- 9 files changed, 159 insertions(+), 20 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheProjection.java b/modules/core/src/main/java/org/apache/ignite/cache/CacheProjection.java index 84c2839b13a42..bca1ae4be850c 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/CacheProjection.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheProjection.java @@ -1677,6 +1677,11 @@ public IgniteInternalFuture removeAllAsync(@Nullable Collection */ public void removeAll() throws IgniteCheckedException; + /** + * @return Remove future. + */ + public IgniteInternalFuture removeAllAsync(); + /** * Asynchronously removes mappings from cache for entries for which the optionally passed in filters do * pass. If passed in filters are {@code null}, then all entries in cache will be enrolled diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java index 80b73419649df..b4ac195aab614 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java @@ -1205,6 +1205,11 @@ private IgnitePredicate> visitor(final IgnitePredicate removeAllAsync() { + return cache.removeAllAsync(); + } + /** {@inheritDoc} */ @Override public IgniteInternalFuture removeAllAsync(@Nullable IgnitePredicate>... filter) { return cache.removeAllAsync(and(filter, false)); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java index 8fd125ebfc48f..ee8a89fed80ad 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java @@ -1613,6 +1613,18 @@ public GridCacheProjectionImpl gateProjection() { } } + /** {@inheritDoc} */ + @Override public IgniteInternalFuture removeAllAsync() { + GridCacheProjectionImpl prev = gate.enter(prj); + + try { + return delegate.removeAllAsync(); + } + finally { + gate.leave(prev); + } + } + /** {@inheritDoc} */ @Override public IgniteInternalFuture removeAllAsync(@Nullable IgnitePredicate>[] filter) { GridCacheProjectionImpl prev = gate.enter(prj); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java index c6166af730912..a733ed2167821 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java @@ -736,7 +736,10 @@ public Set> entrySetx(IgnitePredicate>... filt GridCacheProjectionImpl prev = gate.enter(prj); try { - delegate.removeAll(); + if (isAsync()) + setFuture(delegate.removeAllAsync()); + else + delegate.removeAll(); } catch (IgniteCheckedException e) { throw cacheException(e); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheAdapter.java index 5365ec326c0b9..c0ec962a74e2c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheAdapter.java @@ -29,6 +29,7 @@ import org.apache.ignite.internal.processors.cache.transactions.*; import org.apache.ignite.internal.processors.cache.version.*; import org.apache.ignite.internal.processors.task.*; +import org.apache.ignite.internal.util.future.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; import org.apache.ignite.resources.*; @@ -141,7 +142,7 @@ public void removeVersionedEntry(K key, GridCacheVersion ver) { do { topVer = ctx.affinity().affinityTopologyVersion(); - // Send job to all nodes. + // Send job to all data nodes. Collection nodes = ctx.grid().forDataNodes(name()).nodes(); if (!nodes.isEmpty()) { @@ -155,12 +156,61 @@ public void removeVersionedEntry(K key, GridCacheVersion ver) { if (log.isDebugEnabled()) log.debug("All remote nodes left while cache remove [cacheName=" + name() + "]"); } - catch (ComputeTaskTimeoutCheckedException e) { - U.warn(log, "Timed out waiting for remote nodes to finish cache remove (consider increasing " + - "'networkTimeout' configuration property) [cacheName=" + name() + "]"); + } + + /** {@inheritDoc} */ + @Override public IgniteInternalFuture removeAllAsync() { + GridFutureAdapter opFut = new GridFutureAdapter<>(); + + long topVer = ctx.affinity().affinityTopologyVersion(); + + removeAllAsync(opFut, topVer); + + return opFut; + } + + /** + * @param opFut Future. + * @param topVer Topology version. + */ + private void removeAllAsync(final GridFutureAdapter opFut, final long topVer) { + Collection nodes = ctx.grid().forDataNodes(name()).nodes(); - throw e; + if (!nodes.isEmpty()) { + IgniteInternalFuture rmvFut = ctx.closures().callAsyncNoFailover(BROADCAST, + new GlobalRemoveAllCallable<>(name(), topVer), nodes, true); + + rmvFut.listenAsync(new IgniteInClosure>() { + @Override public void apply(IgniteInternalFuture fut) { + try { + fut.get(); + + long topVer0 = ctx.affinity().affinityTopologyVersion(); + + if (topVer0 == topVer) + opFut.onDone(); + else + removeAllAsync(opFut, topVer0); + } + catch (ClusterGroupEmptyCheckedException ignore) { + if (log.isDebugEnabled()) + log.debug("All remote nodes left while cache remove [cacheName=" + name() + "]"); + + opFut.onDone(); + } + catch (IgniteCheckedException e) { + opFut.onDone(e); + } + catch (Error e) { + opFut.onDone(e); + + throw e; + } + } + }); } + else + opFut.onDone(); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java index 335f2684e19ff..62a59a7d55246 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java @@ -634,6 +634,11 @@ public void processDhtAtomicUpdateRequest( dht.removeAll(); } + /** {@inheritDoc} */ + @Override public IgniteInternalFuture removeAllAsync() { + return dht.removeAllAsync(); + } + /** {@inheritDoc} */ @Override public IgniteInternalFuture removeAllAsync(IgnitePredicate>[] filter) { return dht.removeAllAsync(keySet(filter)); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCache.java index b4bc3a59d5607..845f697102238 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCache.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCache.java @@ -31,6 +31,7 @@ import java.io.*; import java.util.*; +import java.util.concurrent.*; /** * Local cache implementation. @@ -196,6 +197,17 @@ public IgniteInternalFuture lockAllAsync(Collection keys, removeAll(keySet()); } + /** {@inheritDoc} */ + @Override public IgniteInternalFuture removeAllAsync() { + return ctx.closures().callLocalSafe(new Callable() { + @Override public Void call() throws Exception { + removeAll(); + + return null; + } + }); + } + /** {@inheritDoc} */ @Override public void onDeferredDelete(GridCacheEntryEx entry, GridCacheVersion ver) { assert false : "Should not be called"; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java index 4a268d4ad88fc..109667ec7af5a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java @@ -471,6 +471,17 @@ public GridLocalAtomicCache(GridCacheContext ctx) { removeAll(keySet()); } + /** {@inheritDoc} */ + @Override public IgniteInternalFuture removeAllAsync() { + return ctx.closures().callLocalSafe(new Callable() { + @Override public Void call() throws Exception { + removeAll(); + + return null; + } + }); + } + /** {@inheritDoc} */ @Override public IgniteInternalFuture removeAllAsync(IgnitePredicate>[] filter) { return removeAllAsync(keySet(filter), filter); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java index 0d66b15703f55..ce06330e85d5f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java @@ -2098,14 +2098,36 @@ public void testRemovexAsync() throws Exception { /** * @throws Exception In case of error. */ - public void testRemoveAll() throws Exception { - cache().put("key1", 1); - cache().put("key2", 2); - cache().put("key3", 3); + public void testGlobalRemoveAll() throws Exception { + globalRemoveAll(false); + } + + /** + * @throws Exception In case of error. + */ + public void testGlobalRemoveAllAsync() throws Exception { + globalRemoveAll(true); + } + + /** + * @throws Exception In case of error. + */ + private void globalRemoveAll(boolean async) throws Exception { + jcache().put("key1", 1); + jcache().put("key2", 2); + jcache().put("key3", 3); checkSize(F.asSet("key1", "key2", "key3")); - cache().removeAll(F.asList("key1", "key2")); + IgniteCache asyncCache = jcache().withAsync(); + + if (async) { + asyncCache.removeAll(F.asSet("key1", "key2")); + + asyncCache.future().get(); + } + else + jcache().removeAll(F.asSet("key1", "key2")); checkSize(F.asSet("key3")); @@ -2114,24 +2136,38 @@ public void testRemoveAll() throws Exception { checkContainsKey(true, "key3"); // Put values again. - cache().put("key1", 1); - cache().put("key2", 2); - cache().put("key3", 3); + jcache().put("key1", 1); + jcache().put("key2", 2); + jcache().put("key3", 3); + + if (async) { + IgniteCache asyncCache0 = jcache(gridCount() > 1 ? 1 : 0).withAsync(); - cache(gridCount() > 1 ? 1 : 0).removeAll(); + asyncCache0.removeAll(); + + asyncCache0.future().get(); + } + else + jcache(gridCount() > 1 ? 1 : 0).removeAll(); assert cache().isEmpty(); - long entryCount = hugeRemoveAllEntryCount(); + long entryCnt = hugeRemoveAllEntryCount(); - for (int i = 0; i < entryCount; i++) + for (int i = 0; i < entryCnt; i++) cache().put(String.valueOf(i), i); - for (int i = 0; i < entryCount; i++) + for (int i = 0; i < entryCnt; i++) assertEquals(Integer.valueOf(i), cache().get(String.valueOf(i))); - cache().removeAll(); + if (async) { + asyncCache.removeAll(); + + asyncCache.future().get(); + } + else + cache().removeAll(); - for (int i = 0; i < entryCount; i++) + for (int i = 0; i < entryCnt; i++) assertNull(cache().get(String.valueOf(i))); } From f659b3f107216035977991e0a7350bc6ae172f84 Mon Sep 17 00:00:00 2001 From: sboikov Date: Fri, 6 Feb 2015 22:01:06 +0300 Subject: [PATCH 38/95] # ignite-57 async support for clear() --- .../java/org/apache/ignite/IgniteCache.java | 2 -- .../apache/ignite/cache/CacheProjection.java | 5 ++++ .../processors/cache/GridCacheAdapter.java | 26 ++++++++++++++++++ .../cache/GridCacheProjectionImpl.java | 5 ++++ .../processors/cache/GridCacheProxyImpl.java | 12 +++++++++ .../processors/cache/IgniteCacheProxy.java | 9 +++---- .../GridCacheAbstractFullApiSelfTest.java | 27 +++++++++++++++++-- ...CacheNearOnlyMultiNodeFullApiSelfTest.java | 17 +++++++++--- 8 files changed, 91 insertions(+), 12 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java index ce0f4b49668df..73cb87ab183a1 100644 --- a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java +++ b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java @@ -390,8 +390,6 @@ public interface IgniteCache extends javax.cache.Cache, IgniteAsyncS @IgniteAsyncSupported @Override public void clear(); - public boolean clear(Collection keys); - /** {@inheritDoc} */ @IgniteAsyncSupported @Override public T invoke(K key, EntryProcessor entryProcessor, Object... arguments); diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheProjection.java b/modules/core/src/main/java/org/apache/ignite/cache/CacheProjection.java index bca1ae4be850c..2a9ac69843350 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/CacheProjection.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheProjection.java @@ -1416,6 +1416,11 @@ public IgniteTx txStartPartition(int partId, IgniteTxConcurrency concurrency, */ public void clear() throws IgniteCheckedException; + /** + * @return Clear future. + */ + public IgniteInternalFuture clearAsync(); + /** * Clears cache on all nodes that store it's data. That is, caches are cleared on remote * nodes and local node, as opposed to {@link CacheProjection#clearLocally()} method which only diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java index 0f2158e8736f4..dc2c28b54997c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java @@ -1502,6 +1502,32 @@ private boolean clearLocally(GridCacheVersion obsoleteVer, K key, } } + /** {@inheritDoc} */ + @Override public IgniteInternalFuture clearAsync() { + Collection nodes = ctx.grid().forCacheNodes(name()).nodes(); + + if (!nodes.isEmpty()) { + IgniteInternalFuture fut = + ctx.closures().callAsyncNoFailover(BROADCAST, new GlobalClearAllCallable(name()), nodes, true); + + return fut.chain(new CX1, Object>() { + @Override public Object applyx(IgniteInternalFuture fut) throws IgniteCheckedException { + try { + return fut.get(); + } + catch (ClusterGroupEmptyCheckedException ignore) { + if (log.isDebugEnabled()) + log.debug("All remote nodes left while cache clearLocally [cacheName=" + name() + "]"); + + return null; + } + } + }); + } + else + return new GridFinishedFuture<>(ctx.kernalContext()); + } + /** {@inheritDoc} */ @Override public boolean compact(K key) throws IgniteCheckedException { return compact(key, (IgnitePredicate>[])null); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java index b4ac195aab614..d36d0134671bb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java @@ -1072,6 +1072,11 @@ private IgnitePredicate> visitor(final IgnitePredicate clearAsync() { + return cache.clearAsync(); + } + /** {@inheritDoc} */ @Override public void clear(long timeout) throws IgniteCheckedException { cache.clear(timeout); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java index ee8a89fed80ad..cf9701746f6e6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java @@ -1326,6 +1326,18 @@ public GridCacheProjectionImpl gateProjection() { } } + /** {@inheritDoc} */ + @Override public IgniteInternalFuture clearAsync() { + GridCacheProjectionImpl prev = gate.enter(prj); + + try { + return delegate.clearAsync(); + } + finally { + gate.leave(prev); + } + } + /** {@inheritDoc} */ @Override public void clear(long timeout) throws IgniteCheckedException { GridCacheProjectionImpl prev = gate.enter(prj); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java index a733ed2167821..50abfb959efd7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java @@ -754,7 +754,10 @@ public Set> entrySetx(IgnitePredicate>... filt GridCacheProjectionImpl prev = gate.enter(prj); try { - delegate.clear(); + if (isAsync()) + setFuture(delegate.clearAsync()); + else + delegate.clear(); } catch (IgniteCheckedException e) { throw cacheException(e); @@ -764,10 +767,6 @@ public Set> entrySetx(IgnitePredicate>... filt } } - @Override public boolean clear(Collection keys) { - throw new UnsupportedOperationException(); - } - /** {@inheritDoc} */ @Override public T invoke(K key, EntryProcessor entryProcessor, Object... args) throws EntryProcessorException { diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java index ce06330e85d5f..eef0470ef1599 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java @@ -2495,9 +2495,24 @@ public void testClear() throws Exception { } /** - * @throws Exception In case of error. + * @throws Exception If failed. */ public void testGlobalClearAll() throws Exception { + globalClearAll(false); + } + + /** + * @throws Exception If failed. + */ + public void testGlobalClearAllAsync() throws Exception { + globalClearAll(true); + } + + /** + * @param async If {@code true} uses async method. + * @throws Exception If failed. + */ + protected void globalClearAll(boolean async) throws Exception { // Save entries only on their primary nodes. If we didn't do so, clearLocally() will not remove all entries // because some of them were blocked due to having readers. for (int i = 0; i < gridCount(); i++) { @@ -2505,7 +2520,15 @@ public void testGlobalClearAll() throws Exception { jcache(i).put(key, 1); } - jcache().clear(); + if (async) { + IgniteCache asyncCache = jcache().withAsync(); + + asyncCache.clear(); + + asyncCache.future().get(); + } + else + jcache().clear(); for (int i = 0; i < gridCount(); i++) assert jcache(i).localSize() == 0; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java index 715d53fc38d85..483a87802216a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java @@ -241,8 +241,11 @@ protected IgniteCache fullCache() { } } - /** {@inheritDoc} */ - @Override public void testGlobalClearAll() throws Exception { + /** + * @param async If {@code true} uses async method. + * @throws Exception If failed. + */ + @Override protected void globalClearAll(boolean async) throws Exception { // Save entries only on their primary nodes. If we didn't do so, clearLocally() will not remove all entries // because some of them were blocked due to having readers. for (int i = 0; i < gridCount(); i++) { @@ -251,7 +254,15 @@ protected IgniteCache fullCache() { jcache(i).put(key, 1); } - jcache().clear(); + if (async) { + IgniteCache asyncCache = jcache().withAsync(); + + asyncCache.clear(); + + asyncCache.future().get(); + } + else + jcache().clear(); for (int i = 0; i < gridCount(); i++) assertTrue(String.valueOf(jcache(i)), jcache(i).localSize() == 0); From b8e35888876125c8ffeda7428ffe2da09fa3c8bd Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Fri, 6 Feb 2015 14:11:54 -0800 Subject: [PATCH 39/95] IGNITE-61 - Client fixes --- .../CommunicationMessageCodeGenerator.java | 2 +- .../GridClientHandshakeRequestWrapper.java | 36 ++++------- .../GridClientHandshakeResponseWrapper.java | 2 - .../message/GridClientMessageWrapper.java | 64 ++++++++++++------- .../tcp/GridMemcachedMessageWrapper.java | 2 +- .../internal/util/GridClientByteUtils.java | 3 +- .../GridTcpCommunicationByteBufferStream.java | 35 ++++++++-- 7 files changed, 85 insertions(+), 59 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java index decac328ba263..b861806a6f367 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java @@ -60,7 +60,7 @@ public class CommunicationMessageCodeGenerator { }; /** */ - private static final String SRC_DIR = U.getGridGainHome() + "/modules/core/src/main/java"; + private static final String SRC_DIR = U.getIgniteHome() + "/modules/core/src/main/java"; /** */ private static final Class BASE_CLS = GridTcpCommunicationMessageAdapter.class; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java index 1c0366a99cd8b..b7b986fe9833c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java @@ -19,6 +19,7 @@ import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.gridgain.grid.util.direct.*; import java.nio.*; @@ -32,6 +33,9 @@ public class GridClientHandshakeRequestWrapper extends GridTcpCommunicationMessa /** Signal char. */ public static final byte HANDSHAKE_HEADER = (byte)0x91; + /** Stream. */ + private final GridTcpCommunicationByteBufferStream stream = new GridTcpCommunicationByteBufferStream(null); + /** Handshake bytes. */ private byte[] bytes; @@ -59,43 +63,29 @@ public byte[] bytes() { /** {@inheritDoc} */ @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + stream.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!buf.hasRemaining()) return false; + stream.writeByte(directType()); + commState.typeWritten = true; } - switch (commState.idx) { - case 0: - if (!commState.putByteArray("bytes", bytes)) - return false; - - commState.idx++; - - } + stream.writeByteArray(bytes, 0, bytes.length); - return true; + return stream.lastFinished(); } /** {@inheritDoc} */ @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + stream.setBuffer(buf); - switch (commState.idx) { - case 0: - bytes = commState.getByteArray("bytes"); - - if (!commState.lastRead()) - return false; - - commState.idx++; - - } + bytes = stream.readByteArray(GridClientHandshakeRequest.PACKET_SIZE); - return true; + return stream.lastFinished(); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java index 8bb10a33040e4..7ce67b4784901 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java @@ -62,8 +62,6 @@ public GridClientHandshakeResponseWrapper(byte code) { /** {@inheritDoc} */ @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); - return true; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMessageWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMessageWrapper.java index 4ba6a4fc7059a..fe3246833657d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMessageWrapper.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMessageWrapper.java @@ -19,6 +19,7 @@ import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.gridgain.grid.util.direct.*; import java.nio.*; import java.util.*; @@ -33,6 +34,9 @@ public class GridClientMessageWrapper extends GridTcpCommunicationMessageAdapter /** Client request header. */ public static final byte REQ_HEADER = (byte)0x90; + /** Stream. */ + private final GridTcpCommunicationByteBufferStream stream = new GridTcpCommunicationByteBufferStream(null); + /** */ private int msgSize; @@ -130,43 +134,52 @@ public void message(ByteBuffer msg) { /** {@inheritDoc} */ @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + stream.setBuffer(buf); if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (stream.remaining() < 1) return false; + stream.writeByte(directType()); + commState.typeWritten = true; } switch (commState.idx) { case 0: - if (!commState.putInt("msgSize", msgSize)) + if (stream.remaining() < 4) return false; + stream.writeInt(msgSize); + commState.idx++; case 1: - if (!commState.putLong("reqId", reqId)) + if (stream.remaining() < 8) return false; + stream.writeLong(reqId); + commState.idx++; case 2: - if (!commState.putUuid("clientId", clientId)) + if (stream.remaining() < 16) return false; + stream.writeByteArray(U.uuidToBytes(clientId), 0, 16); + commState.idx++; case 3: - if (!commState.putUuid("destId", destId)) + if (stream.remaining() < 16) return false; + stream.writeByteArray(U.uuidToBytes(destId), 0, 16); + commState.idx++; case 4: - if (!commState.putByteBuffer("msg", msg)) - return false; + stream.writeByteArray(msg.array(), msg.position(), msg.remaining()); commState.idx++; @@ -177,47 +190,52 @@ public void message(ByteBuffer msg) { /** {@inheritDoc} */ @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + stream.setBuffer(buf); switch (commState.idx) { case 0: - msgSize = commState.getInt("msgSize"); - - if (!commState.lastRead()) + if (stream.remaining() < 4) return false; + msgSize = stream.readInt(); + + if (msgSize == 0) // Ping message. + return true; + commState.idx++; case 1: - reqId = commState.getLong("reqId"); - - if (!commState.lastRead()) + if (stream.remaining() < 8) return false; + reqId = stream.readLong(); + commState.idx++; case 2: - clientId = commState.getUuid("clientId"); - - if (!commState.lastRead()) + if (stream.remaining() < 16) return false; + clientId = U.bytesToUuid(stream.readByteArray(16), 0); + commState.idx++; case 3: - destId = commState.getUuid("destId"); - - if (!commState.lastRead()) + if (stream.remaining() < 16) return false; + destId = U.bytesToUuid(stream.readByteArray(16), 0); + commState.idx++; case 4: - msg = commState.getByteBuffer("msg"); + byte[] msg0 = stream.readByteArray(msgSize); - if (!commState.lastRead()) + if (!stream.lastFinished()) return false; + msg = ByteBuffer.wrap(msg0); + commState.idx++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java index 906efa2c8a093..7d93503cd77f5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java @@ -78,7 +78,7 @@ public GridMemcachedMessageWrapper(GridMemcachedMessage msg, IgniteMarshaller jd commState.typeWritten = true; } - stream.writeByteArrayNoLength(bytes); + stream.writeByteArray(bytes, 0, bytes.length); return stream.lastFinished(); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridClientByteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridClientByteUtils.java index f15e13bf10afd..1c7cbd92e25ef 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridClientByteUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridClientByteUtils.java @@ -106,7 +106,7 @@ public static int longToBytes(long l, byte[] bytes, int off) { * @return Encoded into byte array {@link UUID}. */ public static byte[] uuidToBytes(UUID uuid) { - byte[] bytes = new byte[(Long.SIZE >> 3)* 2]; + byte[] bytes = new byte[(Long.SIZE >> 3) * 2]; uuidToBytes(uuid, bytes, 0); @@ -122,7 +122,6 @@ public static byte[] uuidToBytes(UUID uuid) { * @return Number of bytes overwritten in {@code bytes} array. */ public static int uuidToBytes(UUID uuid, byte[] bytes, int off) { - ByteBuffer buf = ByteBuffer.wrap(bytes, off, 16); buf.order(ByteOrder.BIG_ENDIAN); diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationByteBufferStream.java b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationByteBufferStream.java index ea4a36f611f59..76b6eb78e1d0d 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationByteBufferStream.java +++ b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationByteBufferStream.java @@ -276,10 +276,10 @@ public void writeByteArray(byte[] val) { /** * @param val Array. */ - public void writeByteArrayNoLength(byte[] val) { + public void writeByteArray(byte[] val, int off, int len) { assert val != null; - lastFinished = writeArray(val, BYTE_ARR_OFF, val.length, val.length, true); + lastFinished = writeArray(val, BYTE_ARR_OFF + off, len, len, true); } /** {@inheritDoc} */ @@ -419,6 +419,14 @@ public byte[] readByteArray() { return readArray(BYTE_ARR_CREATOR, 0, BYTE_ARR_OFF); } + /** + * @param len Length. + * @return Array. + */ + public byte[] readByteArray(int len) { + return readArray(BYTE_ARR_CREATOR, 0, BYTE_ARR_OFF, len); + } + /** {@inheritDoc} */ public boolean readBoolean() { assert buf.hasRemaining(); @@ -639,16 +647,29 @@ private boolean writeArray(Object arr, long off, int len, int bytes, boolean ski * @return Array or special value if it was not fully read. */ private T readArray(ArrayCreator creator, int lenShift, long off) { + return readArray(creator, lenShift, off, -1); + } + + /** + * @param creator Array creator. + * @param lenShift Array length shift size. + * @param off Base offset. + * @param len Length. + * @return Array or special value if it was not fully read. + */ + private T readArray(ArrayCreator creator, int lenShift, long off, int len) { assert creator != null; if (tmpArr == null) { - if (remaining() < 4) { - lastFinished = false; + if (len == -1) { + if (remaining() < 4) { + lastFinished = false; - return null; - } + return null; + } - int len = readInt(); + len = readInt(); + } switch (len) { case -1: From 08643445b3859e679be51e792cc3bac78747e6c9 Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Fri, 6 Feb 2015 14:48:28 -0800 Subject: [PATCH 40/95] IGNITE-61 - Client fixes --- .../ignite/internal/processors/rest/TestBinaryClient.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/TestBinaryClient.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/TestBinaryClient.java index 0103622ca270c..21e5f8c172239 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/TestBinaryClient.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/TestBinaryClient.java @@ -274,6 +274,8 @@ private byte[] createPacket(GridClientMessage msg) throws IOException { ByteBuffer slice = res.slice(); + slice.order(ByteOrder.LITTLE_ENDIAN); + slice.put((byte)0x90); slice.putInt(res.remaining() - 5); slice.putLong(msg.requestId()); From 415902ea2cdfd76623b2e345e545a217e4eca352 Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Fri, 6 Feb 2015 22:12:44 -0800 Subject: [PATCH 41/95] IGNITE-61 - Direct marshalling --- .../ClientAbstractMultiNodeSelfTest.java | 4 +- .../CommunicationMessageCodeGenerator.java | 32 +- .../GridClientConnectionManagerAdapter.java | 8 +- .../ignite/internal/GridJobCancelRequest.java | 8 +- .../internal/GridJobExecuteRequest.java | 8 +- .../internal/GridJobExecuteResponse.java | 8 +- .../internal/GridJobSiblingsRequest.java | 8 +- .../internal/GridJobSiblingsResponse.java | 8 +- .../ignite/internal/GridPluginContext.java | 2 +- .../internal/GridTaskCancelRequest.java | 8 +- .../internal/GridTaskSessionRequest.java | 8 +- .../direct/DirectByteBufferStream.java} | 630 +++++++++++++----- .../internal/direct/DirectMessageReader.java} | 144 ++-- .../internal/direct/DirectMessageWriter.java | 173 +++++ .../ignite/internal/direct/DirectUtils.java | 346 ++++++++++ .../GridTcpCommunicationMessageFactory.java | 9 +- .../GridTcpCommunicationMessageProducer.java | 6 +- .../GridTcpCommunicationMessageState.java | 72 +- .../direct/GridTcpMessageFactory.java | 6 +- .../internal/managers/GridManagerAdapter.java | 7 +- .../checkpoint/GridCheckpointRequest.java | 8 +- .../managers/communication/GridIoManager.java | 37 +- .../managers/communication/GridIoMessage.java | 16 +- .../communication/GridIoUserMessage.java | 8 +- .../GridDeploymentCommunication.java | 6 +- .../deployment/GridDeploymentInfoBean.java | 8 +- .../deployment/GridDeploymentRequest.java | 8 +- .../deployment/GridDeploymentResponse.java | 8 +- .../eventstorage/GridEventStorageMessage.java | 8 +- .../cache/GridCacheEvictionRequest.java | 6 +- .../cache/GridCacheEvictionResponse.java | 6 +- .../processors/cache/GridCacheMessage.java | 6 +- .../processors/cache/GridCacheValueBytes.java | 30 +- ...CacheOptimisticCheckPreparedTxRequest.java | 6 +- ...acheOptimisticCheckPreparedTxResponse.java | 6 +- ...chePessimisticCheckCommittedTxRequest.java | 6 +- ...hePessimisticCheckCommittedTxResponse.java | 6 +- .../GridCacheTtlUpdateRequest.java | 6 +- .../GridDistributedBaseMessage.java | 4 +- .../GridDistributedLockRequest.java | 6 +- .../GridDistributedLockResponse.java | 6 +- .../GridDistributedTxFinishRequest.java | 6 +- .../GridDistributedTxFinishResponse.java | 6 +- .../GridDistributedTxPrepareRequest.java | 6 +- .../GridDistributedTxPrepareResponse.java | 6 +- .../GridDistributedUnlockRequest.java | 6 +- .../dht/GridDhtAffinityAssignmentRequest.java | 6 +- .../GridDhtAffinityAssignmentResponse.java | 6 +- .../distributed/dht/GridDhtLockRequest.java | 6 +- .../distributed/dht/GridDhtLockResponse.java | 6 +- .../dht/GridDhtTxFinishRequest.java | 6 +- .../dht/GridDhtTxFinishResponse.java | 6 +- .../dht/GridDhtTxPrepareRequest.java | 6 +- .../dht/GridDhtTxPrepareResponse.java | 6 +- .../distributed/dht/GridDhtUnlockRequest.java | 6 +- .../GridDhtAtomicDeferredUpdateResponse.java | 6 +- .../atomic/GridDhtAtomicUpdateRequest.java | 6 +- .../atomic/GridDhtAtomicUpdateResponse.java | 6 +- .../atomic/GridNearAtomicUpdateRequest.java | 6 +- .../atomic/GridNearAtomicUpdateResponse.java | 6 +- .../preloader/GridDhtForceKeysRequest.java | 6 +- .../preloader/GridDhtForceKeysResponse.java | 6 +- .../GridDhtPartitionDemandMessage.java | 6 +- .../preloader/GridDhtPartitionExchangeId.java | 30 +- .../GridDhtPartitionSupplyMessage.java | 6 +- .../GridDhtPartitionsAbstractMessage.java | 4 +- .../GridDhtPartitionsFullMessage.java | 6 +- .../GridDhtPartitionsSingleMessage.java | 6 +- .../GridDhtPartitionsSingleRequest.java | 6 +- .../distributed/near/GridNearGetRequest.java | 6 +- .../distributed/near/GridNearGetResponse.java | 6 +- .../distributed/near/GridNearLockRequest.java | 6 +- .../near/GridNearLockResponse.java | 6 +- .../near/GridNearTxFinishRequest.java | 6 +- .../near/GridNearTxFinishResponse.java | 6 +- .../near/GridNearTxPrepareRequest.java | 6 +- .../near/GridNearTxPrepareResponse.java | 6 +- .../near/GridNearUnlockRequest.java | 6 +- .../cache/query/GridCacheQueryRequest.java | 6 +- .../cache/query/GridCacheQueryResponse.java | 6 +- .../cache/version/GridCacheVersion.java | 30 +- .../clock/GridClockDeltaSnapshotMessage.java | 8 +- .../clock/GridClockDeltaVersion.java | 29 +- .../continuous/GridContinuousMessage.java | 8 +- .../dataload/GridDataLoadRequest.java | 8 +- .../dataload/GridDataLoadResponse.java | 8 +- .../processors/fs/GridGgfsAckMessage.java | 6 +- .../processors/fs/GridGgfsBlockKey.java | 8 +- .../processors/fs/GridGgfsBlocksMessage.java | 6 +- .../fs/GridGgfsCommunicationMessage.java | 6 +- .../processors/fs/GridGgfsDeleteMessage.java | 6 +- .../fs/GridGgfsFileAffinityRange.java | 8 +- .../fs/GridGgfsFragmentizerRequest.java | 6 +- .../fs/GridGgfsFragmentizerResponse.java | 6 +- .../processors/fs/GridGgfsSyncMessage.java | 6 +- .../processors/fs/IgniteFsProcessor.java | 5 +- .../GridClientHandshakeRequestWrapper.java | 12 +- .../GridClientHandshakeResponseWrapper.java | 8 +- .../message/GridClientMessageWrapper.java | 12 +- .../message/GridClientPingPacketWrapper.java | 8 +- .../handlers/task/GridTaskResultRequest.java | 8 +- .../handlers/task/GridTaskResultResponse.java | 8 +- .../tcp/GridMemcachedMessageWrapper.java | 12 +- .../tcp/GridTcpRestDirectParser.java | 7 +- .../streamer/GridStreamerCancelRequest.java | 8 +- .../GridStreamerExecutionRequest.java | 8 +- .../streamer/GridStreamerResponse.java | 8 +- .../streamer/IgniteStreamerImpl.java | 6 +- .../version/GridVersionConverter.java | 2 +- .../ignite/internal/util/IgniteUtils.java | 12 +- .../internal/util/ipc/IpcToNioAdapter.java | 6 +- .../util/nio/GridCommunicationClient.java | 4 +- .../internal/util/nio/GridDirectParser.java | 5 +- .../util/nio/GridNioMessageReader.java | 5 +- .../util/nio/GridNioMessageWriter.java | 6 +- .../internal/util/nio/GridNioServer.java | 20 +- .../nio/GridShmemCommunicationClient.java | 4 +- .../util/nio/GridTcpCommunicationClient.java | 4 +- .../nio/GridTcpNioCommunicationClient.java | 4 +- .../apache/ignite/plugin/PluginContext.java | 2 +- .../communication/MessageAdapter.java} | 40 +- .../communication/MessageReader.java | 12 +- .../communication/MessageReaderFactory.java | 4 +- .../communication/MessageWriter.java | 12 +- .../communication/MessageWriterFactory.java | 4 +- .../apache/ignite/spi/IgniteSpiAdapter.java | 2 +- .../apache/ignite/spi/IgniteSpiContext.java | 2 +- .../jobstealing/JobStealingRequest.java | 8 +- .../tcp/TcpCommunicationSpi.java | 60 +- .../GridTcpCommunicationMessageWriter.java | 262 -------- .../GridJobMasterLeaveAwareSelfTest.java | 6 +- .../GridCommunicationSendMessageSelfTest.java | 11 +- .../communication/GridIoManagerSelfTest.java | 10 +- .../GridDeploymentMessageCountSelfTest.java | 4 +- .../GridCacheAtomicMessageCountSelfTest.java | 4 +- ...dCacheReplicatedSynchronousCommitTest.java | 4 +- .../IgniteTxReentryAbstractSelfTest.java | 4 +- .../GridCacheAtomicTimeoutSelfTest.java | 4 +- ...riginatingNodeFailureAbstractSelfTest.java | 4 +- ...riginatingNodeFailureAbstractSelfTest.java | 4 +- .../GridCacheDhtPreloadMessageCountTest.java | 4 +- ...tomicInvalidPartitionHandlingSelfTest.java | 4 +- ...GridCacheReplicatedInvalidateSelfTest.java | 4 +- .../GridIoManagerBenchmark0.java | 8 +- .../communication/GridTestMessage.java | 8 +- .../GridAbstractCommunicationSelfTest.java | 23 +- .../spi/communication/GridTestMessage.java | 8 +- .../tcp/GridCacheDhtLockBackupSelfTest.java | 6 +- ...unicationSpiConcurrentConnectSelfTest.java | 17 +- .../tcp/GridTcpCommunicationSpiLanTest.java | 6 +- ...CommunicationSpiMultithreadedSelfTest.java | 23 +- ...cpCommunicationSpiRecoveryAckSelfTest.java | 11 +- ...idTcpCommunicationSpiRecoverySelfTest.java | 11 +- .../testframework/GridSpiTestContext.java | 10 +- .../tcp/GridOrderedMessageCancelSelfTest.java | 4 +- 155 files changed, 1748 insertions(+), 1145 deletions(-) rename modules/core/src/main/java/org/{gridgain/grid/util/direct/GridTcpCommunicationByteBufferStream.java => apache/ignite/internal/direct/DirectByteBufferStream.java} (54%) rename modules/core/src/main/java/org/{gridgain/grid/util/direct/GridTcpCommunicationMessageReader.java => apache/ignite/internal/direct/DirectMessageReader.java} (54%) create mode 100644 modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java create mode 100644 modules/core/src/main/java/org/apache/ignite/internal/direct/DirectUtils.java rename modules/core/src/main/java/org/apache/ignite/internal/{util => }/direct/GridTcpCommunicationMessageFactory.java (97%) rename modules/core/src/main/java/org/apache/ignite/internal/{util => }/direct/GridTcpCommunicationMessageProducer.java (87%) rename modules/core/src/main/java/org/apache/ignite/internal/{util => }/direct/GridTcpCommunicationMessageState.java (90%) rename modules/core/src/main/java/org/apache/ignite/internal/{util => }/direct/GridTcpMessageFactory.java (86%) rename modules/core/src/main/java/org/apache/ignite/{internal/util/direct/GridTcpCommunicationMessageAdapter.java => plugin/extensions/communication/MessageAdapter.java} (77%) delete mode 100644 modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageWriter.java diff --git a/modules/clients/src/test/java/org/apache/ignite/client/integration/ClientAbstractMultiNodeSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/client/integration/ClientAbstractMultiNodeSelfTest.java index cfa0cc6794ca4..caa9d56b797a3 100644 --- a/modules/clients/src/test/java/org/apache/ignite/client/integration/ClientAbstractMultiNodeSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/client/integration/ClientAbstractMultiNodeSelfTest.java @@ -31,9 +31,9 @@ import org.apache.ignite.internal.processors.cache.distributed.*; import org.apache.ignite.internal.processors.cache.transactions.*; import org.apache.ignite.internal.processors.cache.version.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.resources.*; import org.apache.ignite.spi.*; import org.apache.ignite.spi.communication.tcp.*; @@ -761,7 +761,7 @@ private static class TestTask extends ComputeTaskSplitAdapter { @SuppressWarnings("unchecked") private static class TestCommunicationSpi extends TcpCommunicationSpi { /** {@inheritDoc} */ - @Override public void sendMessage(ClusterNode node, GridTcpCommunicationMessageAdapter msg) + @Override public void sendMessage(ClusterNode node, MessageAdapter msg) throws IgniteSpiException { checkSyncFlags((GridIoMessage)msg); diff --git a/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java index b861806a6f367..b43434f0d7840 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java @@ -15,9 +15,9 @@ import org.apache.ignite.internal.processors.cache.version.*; import org.apache.ignite.internal.processors.clock.*; import org.apache.ignite.internal.util.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.io.*; @@ -63,7 +63,7 @@ public class CommunicationMessageCodeGenerator { private static final String SRC_DIR = U.getIgniteHome() + "/modules/core/src/main/java"; /** */ - private static final Class BASE_CLS = GridTcpCommunicationMessageAdapter.class; + private static final Class BASE_CLS = MessageAdapter.class; /** */ private static final String EMPTY = ""; @@ -143,9 +143,9 @@ public static void main(String[] args) { * @throws Exception In case of error. */ public void generateAll(boolean write) throws Exception { - Collection> classes = classes(); + Collection> classes = classes(); - for (Class cls : classes) { + for (Class cls : classes) { boolean isAbstract = Modifier.isAbstract(cls.getModifiers()); System.out.println("Processing class: " + cls.getName() + (isAbstract ? " (abstract)" : "")); @@ -158,7 +158,7 @@ public void generateAll(boolean write) throws Exception { // type = 0; // -// for (Class cls : classes) { +// for (Class cls : classes) { // if (Modifier.isAbstract(cls.getModifiers())) // continue; // @@ -177,7 +177,7 @@ public void generateAll(boolean write) throws Exception { * @throws Exception In case of error. */ @SuppressWarnings("ConstantConditions") - private void generateAndWrite(Class cls) throws Exception { + private void generateAndWrite(Class cls) throws Exception { assert cls != null; generate(cls); @@ -228,14 +228,14 @@ else if (line.contains("public boolean readFrom(ByteBuffer buf)")) { // // skip = true; // } - else if (line.contains("public GridTcpCommunicationMessageAdapter clone()")) { + else if (line.contains("public MessageAdapter clone()")) { src.addAll(clone); skip = true; cloneFound = true; } - else if (line.contains("protected void clone0(GridTcpCommunicationMessageAdapter _msg)")) { + else if (line.contains("protected void clone0(MessageAdapter _msg)")) { src.addAll(clone0); skip = true; @@ -287,7 +287,7 @@ else if (line.startsWith(TAB + "}")) { * @param cls Class. * @throws Exception In case of error. */ - public void generate(Class cls) throws Exception { + public void generate(Class cls) throws Exception { assert cls != null; write.clear(); @@ -1065,11 +1065,11 @@ private SB builder() { * @return Classes. * @throws Exception In case of error. */ - private Collection> classes() throws Exception { - Collection> col = new TreeSet<>( - new Comparator>() { - @Override public int compare(Class c1, - Class c2) { + private Collection> classes() throws Exception { + Collection> col = new TreeSet<>( + new Comparator>() { + @Override public int compare(Class c1, + Class c2) { return c1.getName().compareTo(c2.getName()); } }); @@ -1097,7 +1097,7 @@ private Collection> classes( * @throws Exception In case of error. */ private void processFile(File file, ClassLoader ldr, int prefixLen, - Collection> col) throws Exception { + Collection> col) throws Exception { assert file != null; assert ldr != null; assert prefixLen > 0; @@ -1122,7 +1122,7 @@ private void processFile(File file, ClassLoader ldr, int prefixLen, if (cls.getDeclaringClass() == null && cls.getEnclosingClass() == null && !BASE_CLS.equals(cls) && BASE_CLS.isAssignableFrom(cls)) - col.add((Class)cls); + col.add((Class)cls); } } } diff --git a/modules/core/src/main/java/org/apache/ignite/client/impl/connection/GridClientConnectionManagerAdapter.java b/modules/core/src/main/java/org/apache/ignite/client/impl/connection/GridClientConnectionManagerAdapter.java index 9a47c301ee28a..476d9c5658de9 100644 --- a/modules/core/src/main/java/org/apache/ignite/client/impl/connection/GridClientConnectionManagerAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/client/impl/connection/GridClientConnectionManagerAdapter.java @@ -18,18 +18,18 @@ package org.apache.ignite.client.impl.connection; import org.apache.ignite.*; +import org.apache.ignite.internal.direct.*; import org.apache.ignite.logger.java.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.plugin.security.*; import org.apache.ignite.client.*; import org.apache.ignite.client.impl.*; import org.apache.ignite.client.util.*; import org.apache.ignite.internal.processors.rest.client.message.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.nio.*; import org.apache.ignite.internal.util.nio.ssl.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; -import org.gridgain.grid.util.direct.*; import org.jetbrains.annotations.*; import javax.net.ssl.*; @@ -666,7 +666,7 @@ private static class NioParser implements GridNioParser { return new GridClientHandshakeResponse(code); } - GridTcpCommunicationMessageAdapter msg = ses.removeMeta(MSG_META_KEY); + MessageAdapter msg = ses.removeMeta(MSG_META_KEY); if (msg == null && buf.hasRemaining()) { byte type = buf.get(); @@ -674,7 +674,7 @@ private static class NioParser implements GridNioParser { if (type == GridClientMessageWrapper.REQ_HEADER) { msg = new GridClientMessageWrapper(); - msg.setReader(new GridTcpCommunicationMessageReader(null)); + msg.setReader(new DirectMessageReader(null)); } else throw new IOException("Invalid message type: " + type); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridJobCancelRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/GridJobCancelRequest.java index d5a27ab5a6b1d..d55e205bdefff 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridJobCancelRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridJobCancelRequest.java @@ -17,9 +17,9 @@ package org.apache.ignite.internal; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.io.*; @@ -28,7 +28,7 @@ /** * Job cancellation request. */ -public class GridJobCancelRequest extends GridTcpCommunicationMessageAdapter { +public class GridJobCancelRequest extends MessageAdapter { /** */ private static final long serialVersionUID = 0L; @@ -111,7 +111,7 @@ public boolean system() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridJobCancelRequest _clone = new GridJobCancelRequest(); clone0(_clone); @@ -120,7 +120,7 @@ public boolean system() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { GridJobCancelRequest _clone = (GridJobCancelRequest)_msg; _clone.sesId = sesId; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java index c97ed55f32aee..cdc6dfaa3c918 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java @@ -19,10 +19,10 @@ import org.apache.ignite.compute.*; import org.apache.ignite.configuration.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.io.*; @@ -32,7 +32,7 @@ /** * Job execution request. */ -public class GridJobExecuteRequest extends GridTcpCommunicationMessageAdapter implements GridTaskMessage { +public class GridJobExecuteRequest extends MessageAdapter implements GridTaskMessage { /** */ private static final long serialVersionUID = 0L; @@ -413,7 +413,7 @@ public UUID getSubjectId() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridJobExecuteRequest _clone = new GridJobExecuteRequest(); clone0(_clone); @@ -422,7 +422,7 @@ public UUID getSubjectId() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { GridJobExecuteRequest _clone = (GridJobExecuteRequest)_msg; _clone.subjId = subjId; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteResponse.java index db03158414b7a..5d936c8f64461 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteResponse.java @@ -18,10 +18,10 @@ package org.apache.ignite.internal; import org.apache.ignite.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.io.*; @@ -31,7 +31,7 @@ /** * Job execution response. */ -public class GridJobExecuteResponse extends GridTcpCommunicationMessageAdapter implements GridTaskMessage { +public class GridJobExecuteResponse extends MessageAdapter implements GridTaskMessage { /** */ private static final long serialVersionUID = 0L; @@ -206,7 +206,7 @@ public void setFakeException(IgniteException fakeEx) { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridJobExecuteResponse _clone = new GridJobExecuteResponse(); clone0(_clone); @@ -215,7 +215,7 @@ public void setFakeException(IgniteException fakeEx) { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { GridJobExecuteResponse _clone = (GridJobExecuteResponse)_msg; _clone.nodeId = nodeId; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsRequest.java index 6b39365df190d..db27003c465bc 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsRequest.java @@ -17,9 +17,9 @@ package org.apache.ignite.internal; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -27,7 +27,7 @@ /** * Job siblings request. */ -public class GridJobSiblingsRequest extends GridTcpCommunicationMessageAdapter { +public class GridJobSiblingsRequest extends MessageAdapter { /** */ private static final long serialVersionUID = 0L; @@ -85,7 +85,7 @@ public byte[] topicBytes() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridJobSiblingsRequest _clone = new GridJobSiblingsRequest(); clone0(_clone); @@ -94,7 +94,7 @@ public byte[] topicBytes() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { GridJobSiblingsRequest _clone = (GridJobSiblingsRequest)_msg; _clone.sesId = sesId; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java index 671a1494fd702..0dad8d914ab09 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java @@ -19,9 +19,9 @@ import org.apache.ignite.*; import org.apache.ignite.compute.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.marshaller.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.io.*; @@ -31,7 +31,7 @@ /** * Job siblings response. */ -public class GridJobSiblingsResponse extends GridTcpCommunicationMessageAdapter { +public class GridJobSiblingsResponse extends MessageAdapter { /** */ private static final long serialVersionUID = 0L; @@ -78,7 +78,7 @@ public void unmarshalSiblings(Marshaller marsh) throws IgniteCheckedException { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridJobSiblingsResponse _clone = new GridJobSiblingsResponse(); clone0(_clone); @@ -87,7 +87,7 @@ public void unmarshalSiblings(Marshaller marsh) throws IgniteCheckedException { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { GridJobSiblingsResponse _clone = (GridJobSiblingsResponse)_msg; _clone.siblings = siblings; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridPluginContext.java b/modules/core/src/main/java/org/apache/ignite/internal/GridPluginContext.java index 6d7c8828ab377..24e080ebaf49d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridPluginContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridPluginContext.java @@ -20,7 +20,7 @@ import org.apache.ignite.*; import org.apache.ignite.cluster.*; import org.apache.ignite.configuration.*; -import org.apache.ignite.internal.util.direct.*; +import org.apache.ignite.internal.direct.*; import org.apache.ignite.plugin.*; import org.apache.ignite.spi.*; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridTaskCancelRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/GridTaskCancelRequest.java index 321799bfdb097..21153af7c1df4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridTaskCancelRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridTaskCancelRequest.java @@ -17,9 +17,9 @@ package org.apache.ignite.internal; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -27,7 +27,7 @@ /** * Request for cancelling tasks. */ -public class GridTaskCancelRequest extends GridTcpCommunicationMessageAdapter { +public class GridTaskCancelRequest extends MessageAdapter { /** */ private static final long serialVersionUID = 0L; @@ -62,7 +62,7 @@ public IgniteUuid sessionId() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridTaskCancelRequest _clone = new GridTaskCancelRequest(); clone0(_clone); @@ -71,7 +71,7 @@ public IgniteUuid sessionId() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { GridTaskCancelRequest _clone = (GridTaskCancelRequest)_msg; _clone.sesId = sesId; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridTaskSessionRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/GridTaskSessionRequest.java index a43b13b7dcecb..f33e97ad966d6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridTaskSessionRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridTaskSessionRequest.java @@ -17,9 +17,9 @@ package org.apache.ignite.internal; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -28,7 +28,7 @@ /** * Task session request. */ -public class GridTaskSessionRequest extends GridTcpCommunicationMessageAdapter implements GridTaskMessage { +public class GridTaskSessionRequest extends MessageAdapter implements GridTaskMessage { /** */ private static final long serialVersionUID = 0L; @@ -99,7 +99,7 @@ public IgniteUuid getJobId() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridTaskSessionRequest _clone = new GridTaskSessionRequest(); clone0(_clone); @@ -108,7 +108,7 @@ public IgniteUuid getJobId() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { GridTaskSessionRequest _clone = (GridTaskSessionRequest)_msg; _clone.sesId = sesId; diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationByteBufferStream.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java similarity index 54% rename from modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationByteBufferStream.java rename to modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java index 76b6eb78e1d0d..0f6a6f9e70f2e 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationByteBufferStream.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java @@ -1,26 +1,38 @@ -/* @java.file.header */ - -/* _________ _____ __________________ _____ - * __ ____/___________(_)______ /__ ____/______ ____(_)_______ - * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ - * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / - * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ -package org.gridgain.grid.util.direct; +package org.apache.ignite.internal.direct; import org.apache.ignite.internal.util.*; -import org.apache.ignite.internal.util.direct.*; +import org.apache.ignite.internal.util.typedef.*; +import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import sun.misc.*; import sun.nio.ch.*; import java.nio.*; +import java.util.*; /** * Portable stream based on {@link ByteBuffer}. */ -public class GridTcpCommunicationByteBufferStream { +public class DirectByteBufferStream { /** */ private static final Unsafe UNSAFE = GridUnsafe.unsafe(); @@ -192,6 +204,23 @@ public class GridTcpCommunicationByteBufferStream { } }; + /** */ + private static final Object NULL = new Object(); + + /** */ + private static final Map, IgniteInClosure> WRITERS = U.newHashMap(8); + + /** */ + private static final Map, IgniteOutClosure> READERS = U.newHashMap(8); + + static { + WRITERS.put(byte.class, new CI1() { + @Override public void apply(Object o) { + + } + }); + } + /** */ private final GridTcpMessageFactory msgFactory; @@ -220,7 +249,28 @@ public class GridTcpCommunicationByteBufferStream { private boolean msgTypeDone; /** */ - private GridTcpCommunicationMessageAdapter msg; + private MessageAdapter msg; + + /** */ + private Iterator it; + + /** */ + private Object cur = NULL; + + /** */ + private boolean keyDone; + + /** */ + private int readSize = -1; + + /** */ + private int readItems; + + /** */ + private Collection col; + + /** */ + private Map map; /** */ private boolean lastFinished; @@ -228,7 +278,7 @@ public class GridTcpCommunicationByteBufferStream { /** * @param msgFactory Message factory. */ - public GridTcpCommunicationByteBufferStream(@Nullable GridTcpMessageFactory msgFactory) { + public DirectByteBufferStream(@Nullable GridTcpMessageFactory msgFactory) { this.msgFactory = msgFactory; } @@ -259,263 +309,408 @@ public boolean lastFinished() { /** {@inheritDoc} */ public void writeByte(byte val) { - int pos = buf.position(); + lastFinished = buf.remaining() >= 1; - UNSAFE.putByte(heapArr, baseOff + pos, val); + if (lastFinished) { + int pos = buf.position(); - buf.position(pos + 1); + UNSAFE.putByte(heapArr, baseOff + pos, val); + + buf.position(pos + 1); + } } /** {@inheritDoc} */ - public void writeByteArray(byte[] val) { - assert val != null; + public void writeShort(short val) { + lastFinished = buf.remaining() >= 2; - lastFinished = writeArray(val, BYTE_ARR_OFF, val.length, val.length); - } + if (lastFinished) { + int pos = buf.position(); - /** - * @param val Array. - */ - public void writeByteArray(byte[] val, int off, int len) { - assert val != null; + UNSAFE.putShort(heapArr, baseOff + pos, val); - lastFinished = writeArray(val, BYTE_ARR_OFF + off, len, len, true); + buf.position(pos + 2); + } } /** {@inheritDoc} */ - public void writeBoolean(boolean val) { - int pos = buf.position(); + public void writeInt(int val) { + lastFinished = buf.remaining() >= 4; - UNSAFE.putBoolean(heapArr, baseOff + pos, val); + if (lastFinished) { + int pos = buf.position(); - buf.position(pos + 1); + UNSAFE.putInt(heapArr, baseOff + pos, val); + + buf.position(pos + 4); + } } /** {@inheritDoc} */ - public void writeBooleanArray(boolean[] val) { - assert val != null; + public void writeLong(long val) { + lastFinished = buf.remaining() >= 8; + + if (lastFinished) { + int pos = buf.position(); + + UNSAFE.putLong(heapArr, baseOff + pos, val); - lastFinished = writeArray(val, BOOLEAN_ARR_OFF, val.length, val.length); + buf.position(pos + 8); + } } /** {@inheritDoc} */ - public void writeShort(short val) { - int pos = buf.position(); + public void writeFloat(float val) { + lastFinished = buf.remaining() >= 4; + + if (lastFinished) { + int pos = buf.position(); - UNSAFE.putShort(heapArr, baseOff + pos, val); + UNSAFE.putFloat(heapArr, baseOff + pos, val); - buf.position(pos + 2); + buf.position(pos + 4); + } } /** {@inheritDoc} */ - public void writeShortArray(short[] val) { - assert val != null; + public void writeDouble(double val) { + lastFinished = buf.remaining() >= 8; + + if (lastFinished) { + int pos = buf.position(); - lastFinished = writeArray(val, SHORT_ARR_OFF, val.length, val.length << 1); + UNSAFE.putDouble(heapArr, baseOff + pos, val); + + buf.position(pos + 8); + } } /** {@inheritDoc} */ public void writeChar(char val) { - int pos = buf.position(); + lastFinished = buf.remaining() >= 2; - UNSAFE.putChar(heapArr, baseOff + pos, val); + if (lastFinished) { + int pos = buf.position(); - buf.position(pos + 2); + UNSAFE.putChar(heapArr, baseOff + pos, val); + + buf.position(pos + 2); + } } /** {@inheritDoc} */ - public void writeCharArray(char[] val) { - assert val != null; + public void writeBoolean(boolean val) { + lastFinished = buf.remaining() >= 1; + + if (lastFinished) { + int pos = buf.position(); + + UNSAFE.putBoolean(heapArr, baseOff + pos, val); - lastFinished = writeArray(val, CHAR_ARR_OFF, val.length, val.length << 1); + buf.position(pos + 1); + } } /** {@inheritDoc} */ - public void writeInt(int val) { - int pos = buf.position(); + public void writeByteArray(byte[] val) { + if (val != null) + lastFinished = writeArray(val, BYTE_ARR_OFF, val.length, val.length); + else + writeInt(-1); + } - UNSAFE.putInt(heapArr, baseOff + pos, val); + /** + * @param val Array. + */ + public void writeByteArray(byte[] val, int off, int len) { + if (val != null) + lastFinished = writeArray(val, BYTE_ARR_OFF + off, len, len, true); + else + writeInt(-1); + } - buf.position(pos + 4); + /** {@inheritDoc} */ + public void writeShortArray(short[] val) { + if (val != null) + lastFinished = writeArray(val, SHORT_ARR_OFF, val.length, val.length << 1); + else + writeInt(-1); } /** {@inheritDoc} */ public void writeIntArray(int[] val) { - assert val != null; - - lastFinished = writeArray(val, INT_ARR_OFF, val.length, val.length << 2); + if (val != null) + lastFinished = writeArray(val, INT_ARR_OFF, val.length, val.length << 2); + else + writeInt(-1); } /** {@inheritDoc} */ - public void writeFloat(float val) { - int pos = buf.position(); - - UNSAFE.putFloat(heapArr, baseOff + pos, val); - - buf.position(pos + 4); + public void writeLongArray(long[] val) { + if (val != null) + lastFinished = writeArray(val, LONG_ARR_OFF, val.length, val.length << 3); + else + writeInt(-1); } /** {@inheritDoc} */ public void writeFloatArray(float[] val) { - assert val != null; - - lastFinished = writeArray(val, FLOAT_ARR_OFF, val.length, val.length << 2); + if (val != null) + lastFinished = writeArray(val, FLOAT_ARR_OFF, val.length, val.length << 2); + else + writeInt(-1); } /** {@inheritDoc} */ - public void writeLong(long val) { - int pos = buf.position(); - - UNSAFE.putLong(heapArr, baseOff + pos, val); + public void writeDoubleArray(double[] val) { + if (val != null) + lastFinished = writeArray(val, DOUBLE_ARR_OFF, val.length, val.length << 3); + else + writeInt(-1); + } - buf.position(pos + 8); + /** {@inheritDoc} */ + public void writeCharArray(char[] val) { + if (val != null) + lastFinished = writeArray(val, CHAR_ARR_OFF, val.length, val.length << 1); + else + writeInt(-1); } /** {@inheritDoc} */ - public void writeLongArray(long[] val) { - assert val != null; + public void writeBooleanArray(boolean[] val) { + if (val != null) + lastFinished = writeArray(val, BOOLEAN_ARR_OFF, val.length, val.length); + else + writeInt(-1); + } - lastFinished = writeArray(val, LONG_ARR_OFF, val.length, val.length << 3); + /** + * @param msg Message. + */ + public void writeMessage(MessageAdapter msg) { + if (msg != null) + lastFinished = buf.hasRemaining() && msg.writeTo(buf); + else + writeByte(Byte.MIN_VALUE); } - /** {@inheritDoc} */ - public void writeDouble(double val) { - int pos = buf.position(); + public void writeCollection(Collection col, Class itemCls) { + if (col != null) { + if (it == null) { + writeInt(col.size()); - UNSAFE.putDouble(heapArr, baseOff + pos, val); + if (!lastFinished) + return; - buf.position(pos + 8); - } + it = col.iterator(); + } - /** {@inheritDoc} */ - public void writeDoubleArray(double[] val) { - assert val != null; + IgniteInClosure itemWriter = WRITERS.get(itemCls); - lastFinished = writeArray(val, DOUBLE_ARR_OFF, val.length, val.length << 3); - } + while (it.hasNext() || cur != NULL) { + if (cur == NULL) + cur = it.next(); - /** - * @param msg Message. - */ - public void writeMessage(GridTcpCommunicationMessageAdapter msg) { - assert msg != null; + itemWriter.apply(cur); - lastFinished = buf.hasRemaining() && msg.writeTo(buf); + if (!lastFinished) + return; + + cur = NULL; + } + + it = null; + } + else + writeInt(-1); } - /** {@inheritDoc} */ - public byte readByte() { - assert buf.hasRemaining(); + public void writeMap(Map map, Class keyCls, Class valCls) { + if (map != null) { + if (it == null) { + writeInt(map.size()); - int pos = buf.position(); + if (!lastFinished) + return; - buf.position(pos + 1); + it = map.entrySet().iterator(); + } - return UNSAFE.getByte(heapArr, baseOff + pos); - } + IgniteInClosure keyWriter = WRITERS.get(keyCls); + IgniteInClosure valWriter = WRITERS.get(valCls); - /** {@inheritDoc} */ - public byte[] readByteArray() { - return readArray(BYTE_ARR_CREATOR, 0, BYTE_ARR_OFF); - } + while (it.hasNext() || cur != NULL) { + if (cur == NULL) + cur = it.next(); - /** - * @param len Length. - * @return Array. - */ - public byte[] readByteArray(int len) { - return readArray(BYTE_ARR_CREATOR, 0, BYTE_ARR_OFF, len); - } + Map.Entry e = (Map.Entry)cur; - /** {@inheritDoc} */ - public boolean readBoolean() { - assert buf.hasRemaining(); + if (!keyDone) { + keyWriter.apply(e.getKey()); - int pos = buf.position(); + if (!lastFinished) + return; + + keyDone = true; + } + + valWriter.apply(e.getValue()); - buf.position(pos + 1); + if (!lastFinished) + return; - return UNSAFE.getBoolean(heapArr, baseOff + pos); + cur = NULL; + keyDone = false; + } + + it = null; + } + else + writeInt(-1); } /** {@inheritDoc} */ - public boolean[] readBooleanArray() { - return readArray(BOOLEAN_ARR_CREATOR, 0, BOOLEAN_ARR_OFF); + public byte readByte() { + lastFinished = buf.remaining() >= 1; + + if (lastFinished) { + int pos = buf.position(); + + buf.position(pos + 1); + + return UNSAFE.getByte(heapArr, baseOff + pos); + } + else + return 0; } /** {@inheritDoc} */ public short readShort() { - assert buf.remaining() >= 2; + lastFinished = buf.remaining() >= 2; - int pos = buf.position(); + if (lastFinished) { + int pos = buf.position(); - buf.position(pos + 2); + buf.position(pos + 2); - return UNSAFE.getShort(heapArr, baseOff + pos); + return UNSAFE.getShort(heapArr, baseOff + pos); + } + else + return 0; } /** {@inheritDoc} */ - public short[] readShortArray() { - return readArray(SHORT_ARR_CREATOR, 1, SHORT_ARR_OFF); + public int readInt() { + lastFinished = buf.remaining() >= 4; + + if (lastFinished) { + int pos = buf.position(); + + buf.position(pos + 4); + + return UNSAFE.getInt(heapArr, baseOff + pos); + } + else + return 0; } /** {@inheritDoc} */ - public char readChar() { - assert buf.remaining() >= 2; + public long readLong() { + lastFinished = buf.remaining() >= 8; - int pos = buf.position(); + if (lastFinished) { + int pos = buf.position(); - buf.position(pos + 2); + buf.position(pos + 8); - return UNSAFE.getChar(heapArr, baseOff + pos); + return UNSAFE.getLong(heapArr, baseOff + pos); + } + else + return 0; } /** {@inheritDoc} */ - public char[] readCharArray() { - return readArray(CHAR_ARR_CREATOR, 1, CHAR_ARR_OFF); + public float readFloat() { + lastFinished = buf.remaining() >= 4; + + if (lastFinished) { + int pos = buf.position(); + + buf.position(pos + 4); + + return UNSAFE.getFloat(heapArr, baseOff + pos); + } + else + return 0; } /** {@inheritDoc} */ - public int readInt() { - assert buf.remaining() >= 4; + public double readDouble() { + lastFinished = buf.remaining() >= 8; - int pos = buf.position(); + if (lastFinished) { + int pos = buf.position(); - buf.position(pos + 4); + buf.position(pos + 8); - return UNSAFE.getInt(heapArr, baseOff + pos); + return UNSAFE.getDouble(heapArr, baseOff + pos); + } + else + return 0; } /** {@inheritDoc} */ - public int[] readIntArray() { - return readArray(INT_ARR_CREATOR, 2, INT_ARR_OFF); + public char readChar() { + lastFinished = buf.remaining() >= 2; + + if (lastFinished) { + int pos = buf.position(); + + buf.position(pos + 2); + + return UNSAFE.getChar(heapArr, baseOff + pos); + } + else + return 0; } /** {@inheritDoc} */ - public float readFloat() { - assert buf.remaining() >= 4; + public boolean readBoolean() { + lastFinished = buf.hasRemaining(); - int pos = buf.position(); + if (lastFinished) { + int pos = buf.position(); - buf.position(pos + 4); + buf.position(pos + 1); - return UNSAFE.getFloat(heapArr, baseOff + pos); + return UNSAFE.getBoolean(heapArr, baseOff + pos); + } + else + return false; } /** {@inheritDoc} */ - public float[] readFloatArray() { - return readArray(FLOAT_ARR_CREATOR, 2, FLOAT_ARR_OFF); + public byte[] readByteArray() { + return readArray(BYTE_ARR_CREATOR, 0, BYTE_ARR_OFF); } - /** {@inheritDoc} */ - public long readLong() { - assert buf.remaining() >= 8; - - int pos = buf.position(); + /** + * @param len Length. + * @return Array. + */ + public byte[] readByteArray(int len) { + return readArray(BYTE_ARR_CREATOR, 0, BYTE_ARR_OFF, len); + } - buf.position(pos + 8); + /** {@inheritDoc} */ + public short[] readShortArray() { + return readArray(SHORT_ARR_CREATOR, 1, SHORT_ARR_OFF); + } - return UNSAFE.getLong(heapArr, baseOff + pos); + /** {@inheritDoc} */ + public int[] readIntArray() { + return readArray(INT_ARR_CREATOR, 2, INT_ARR_OFF); } /** {@inheritDoc} */ @@ -524,14 +719,8 @@ public long[] readLongArray() { } /** {@inheritDoc} */ - public double readDouble() { - assert buf.remaining() >= 8; - - int pos = buf.position(); - - buf.position(pos + 8); - - return UNSAFE.getDouble(heapArr, baseOff + pos); + public float[] readFloatArray() { + return readArray(FLOAT_ARR_CREATOR, 2, FLOAT_ARR_OFF); } /** {@inheritDoc} */ @@ -539,10 +728,20 @@ public double[] readDoubleArray() { return readArray(DOUBLE_ARR_CREATOR, 3, DOUBLE_ARR_OFF); } + /** {@inheritDoc} */ + public char[] readCharArray() { + return readArray(CHAR_ARR_CREATOR, 1, CHAR_ARR_OFF); + } + + /** {@inheritDoc} */ + public boolean[] readBooleanArray() { + return readArray(BOOLEAN_ARR_CREATOR, 0, BOOLEAN_ARR_OFF); + } + /** * @return Message. */ - public GridTcpCommunicationMessageAdapter readMessage() { + public MessageAdapter readMessage() { if (!msgTypeDone) { if (!buf.hasRemaining()) { lastFinished = false; @@ -557,21 +756,100 @@ public GridTcpCommunicationMessageAdapter readMessage() { msgTypeDone = true; } - if (msg == null || msg.readFrom(buf)) { - GridTcpCommunicationMessageAdapter msg0 = msg; + lastFinished = msg == null || msg.readFrom(buf); + + if (lastFinished) { + MessageAdapter msg0 = msg; msgTypeDone = false; msg = null; - lastFinished = true; - return msg0; } - else { - lastFinished = false; - + else return null; + } + + public Collection readCollection(Class itemCls) { + if (readSize == -1) { + int size = readInt(); + + if (!lastFinished) + return null; + + readSize = size; } + + if (readSize >= 0) { + if (col == null) + col = new ArrayList<>(readSize); + + IgniteOutClosure itemReader = READERS.get(itemCls); + + for (int i = readItems; i < readSize; i++) { + Object item = itemReader.apply(); + + if (!lastFinished) + return null; + + col.add(item); + + readItems++; + } + } + + readSize = -1; + readItems = 0; + + return (Collection)col; + } + + public Map readMap(Class keyCls, Class valCls) { + if (readSize == -1) { + int size = readInt(); + + if (!lastFinished) + return null; + + readSize = size; + } + + if (readSize >= 0) { + if (map == null) + map = U.newHashMap(readSize); + + IgniteOutClosure keyReader = READERS.get(keyCls); + IgniteOutClosure valReader = READERS.get(valCls); + + for (int i = readItems; i < readSize; i++) { + if (!keyDone) { + Object key = keyReader.apply(); + + if (!lastFinished) + return null; + + cur = key; + keyDone = true; + } + + Object val = valReader.apply(); + + if (!lastFinished) + return null; + + map.put(cur, val); + + keyDone = false; + + readItems++; + } + } + + readSize = -1; + readItems = 0; + cur = null; + + return (Map)map; } /** @@ -603,7 +881,7 @@ private boolean writeArray(Object arr, long off, int len, int bytes, boolean ski if (arrOff == -1) { if (!skipLen) { - if (remaining() < 4) + if (buf.remaining() < 4) return false; writeInt(len); @@ -662,7 +940,7 @@ private T readArray(ArrayCreator creator, int lenShift, long off, int len if (tmpArr == null) { if (len == -1) { - if (remaining() < 4) { + if (buf.remaining() < 4) { lastFinished = false; return null; @@ -692,18 +970,9 @@ private T readArray(ArrayCreator creator, int lenShift, long off, int len int remaining = buf.remaining(); int pos = buf.position(); - if (remaining < toRead) { - UNSAFE.copyMemory(heapArr, baseOff + pos, tmpArr, off + tmpArrOff, remaining); - - buf.position(pos + remaining); - - tmpArrOff += remaining; + lastFinished = toRead <= remaining; - lastFinished = false; - - return null; - } - else { + if (lastFinished) { UNSAFE.copyMemory(heapArr, baseOff + pos, tmpArr, off + tmpArrOff, toRead); buf.position(pos + toRead); @@ -714,10 +983,17 @@ private T readArray(ArrayCreator creator, int lenShift, long off, int len tmpArrBytes = 0; tmpArrOff = 0; - lastFinished = true; - return arr; } + else { + UNSAFE.copyMemory(heapArr, baseOff + pos, tmpArr, off + tmpArrOff, remaining); + + buf.position(pos + remaining); + + tmpArrOff += remaining; + + return null; + } } /** diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageReader.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java similarity index 54% rename from modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageReader.java rename to modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java index 574378f54f73f..60c04d20adb5e 100644 --- a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageReader.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java @@ -1,26 +1,34 @@ -/* @java.file.header */ - -/* _________ _____ __________________ _____ - * __ ____/___________(_)______ /__ ____/______ ____(_)_______ - * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ - * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / - * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ -package org.gridgain.grid.util.direct; +package org.apache.ignite.internal.direct; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.nio.*; +import java.util.*; /** * Portable reader implementation. */ -public class GridTcpCommunicationMessageReader implements MessageReader { +public class DirectMessageReader implements MessageReader { /** Stream. */ - private final GridTcpCommunicationByteBufferStream stream; + private final DirectByteBufferStream stream; /** Whether last field was fully read. */ private boolean lastRead; @@ -28,8 +36,8 @@ public class GridTcpCommunicationMessageReader implements MessageReader { /** * @param msgFactory Message factory. */ - public GridTcpCommunicationMessageReader(GridTcpMessageFactory msgFactory) { - this.stream = new GridTcpCommunicationByteBufferStream(msgFactory); + public DirectMessageReader(GridTcpMessageFactory msgFactory) { + this.stream = new DirectByteBufferStream(msgFactory); } /** {@inheritDoc} */ @@ -39,114 +47,74 @@ public GridTcpCommunicationMessageReader(GridTcpMessageFactory msgFactory) { /** {@inheritDoc} */ @Override public byte readByte(String name) { - if (stream.remaining() < 1) { - lastRead = false; + byte val = stream.readByte(); - return 0; - } - else { - lastRead = true; + lastRead = stream.lastFinished(); - return stream.readByte(); - } + return val; } /** {@inheritDoc} */ @Override public short readShort(String name) { - if (stream.remaining() < 2) { - lastRead = false; + short val = stream.readShort(); - return 0; - } - else { - lastRead = true; + lastRead = stream.lastFinished(); - return stream.readShort(); - } + return val; } /** {@inheritDoc} */ @Override public int readInt(String name) { - if (stream.remaining() < 4) { - lastRead = false; + int val = stream.readInt(); - return 0; - } - else { - lastRead = true; + lastRead = stream.lastFinished(); - return stream.readInt(); - } + return val; } /** {@inheritDoc} */ @Override public long readLong(String name) { - if (stream.remaining() < 8) { - lastRead = false; + long val = stream.readLong(); - return 0; - } - else { - lastRead = true; + lastRead = stream.lastFinished(); - return stream.readLong(); - } + return val; } /** {@inheritDoc} */ @Override public float readFloat(String name) { - if (stream.remaining() < 4) { - lastRead = false; + float val = stream.readFloat(); - return 0; - } - else { - lastRead = true; + lastRead = stream.lastFinished(); - return stream.readFloat(); - } + return val; } /** {@inheritDoc} */ @Override public double readDouble(String name) { - if (stream.remaining() < 8) { - lastRead = false; + double val = stream.readDouble(); - return 0; - } - else { - lastRead = true; + lastRead = stream.lastFinished(); - return stream.readDouble(); - } + return val; } /** {@inheritDoc} */ @Override public char readChar(String name) { - if (stream.remaining() < 2) { - lastRead = false; + char val = stream.readChar(); - return 0; - } - else { - lastRead = true; + lastRead = stream.lastFinished(); - return stream.readChar(); - } + return val; } /** {@inheritDoc} */ @Override public boolean readBoolean(String name) { - if (stream.remaining() < 1) { - lastRead = false; + boolean val = stream.readBoolean(); - return false; - } - else { - lastRead = true; + lastRead = stream.lastFinished(); - return stream.readBoolean(); - } + return val; } /** {@inheritDoc} */ @@ -222,14 +190,32 @@ public GridTcpCommunicationMessageReader(GridTcpMessageFactory msgFactory) { } /** {@inheritDoc} */ - @Nullable @Override public GridTcpCommunicationMessageAdapter readMessage(String name) { - GridTcpCommunicationMessageAdapter msg = stream.readMessage(); + @Nullable @Override public MessageAdapter readMessage(String name) { + MessageAdapter msg = stream.readMessage(); lastRead = stream.lastFinished(); return msg; } + /** {@inheritDoc} */ + @Override public Collection readCollection(String name, Class itemCls) { + Collection col = stream.readCollection(itemCls); + + lastRead = stream.lastFinished(); + + return col; + } + + /** {@inheritDoc} */ + @Override public Map readMap(String name, Class keyCls, Class valCls) { + Map map = stream.readMap(keyCls, valCls); + + lastRead = stream.lastFinished(); + + return map; + } + /** {@inheritDoc} */ @Override public boolean isLastRead() { return lastRead; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java new file mode 100644 index 0000000000000..120b1489b6334 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java @@ -0,0 +1,173 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.direct; + +import org.apache.ignite.plugin.extensions.communication.*; +import org.jetbrains.annotations.*; + +import java.nio.*; +import java.util.*; + +/** + * Portable writer implementation. + */ +public class DirectMessageWriter implements MessageWriter { + /** Stream. */ + private final DirectByteBufferStream stream = new DirectByteBufferStream(null); + + /** {@inheritDoc} */ + @Override public void setBuffer(ByteBuffer buf) { + stream.setBuffer(buf); + } + + /** {@inheritDoc} */ + @Override public boolean writeByte(String name, byte val) { + stream.writeByte(val); + + return stream.lastFinished(); + } + + /** {@inheritDoc} */ + @Override public boolean writeShort(String name, short val) { + stream.writeShort(val); + + return stream.lastFinished(); + } + + /** {@inheritDoc} */ + @Override public boolean writeInt(String name, int val) { + stream.writeInt(val); + + return stream.lastFinished(); + } + + /** {@inheritDoc} */ + @Override public boolean writeLong(String name, long val) { + stream.writeLong(val); + + return stream.lastFinished(); + } + + /** {@inheritDoc} */ + @Override public boolean writeFloat(String name, float val) { + stream.writeFloat(val); + + return stream.lastFinished(); + } + + /** {@inheritDoc} */ + @Override public boolean writeDouble(String name, double val) { + stream.writeDouble(val); + + return stream.lastFinished(); + } + + /** {@inheritDoc} */ + @Override public boolean writeChar(String name, char val) { + stream.writeChar(val); + + return stream.lastFinished(); + } + + /** {@inheritDoc} */ + @Override public boolean writeBoolean(String name, boolean val) { + stream.writeBoolean(val); + + return stream.lastFinished(); + } + + /** {@inheritDoc} */ + @Override public boolean writeByteArray(String name, @Nullable byte[] val) { + stream.writeByteArray(val); + + return stream.lastFinished(); + } + + /** {@inheritDoc} */ + @Override public boolean writeShortArray(String name, @Nullable short[] val) { + stream.writeShortArray(val); + + return stream.lastFinished(); + } + + /** {@inheritDoc} */ + @Override public boolean writeIntArray(String name, @Nullable int[] val) { + stream.writeIntArray(val); + + return stream.lastFinished(); + } + + /** {@inheritDoc} */ + @Override public boolean writeLongArray(String name, @Nullable long[] val) { + stream.writeLongArray(val); + + return stream.lastFinished(); + } + + /** {@inheritDoc} */ + @Override public boolean writeFloatArray(String name, @Nullable float[] val) { + stream.writeFloatArray(val); + + return stream.lastFinished(); + } + + /** {@inheritDoc} */ + @Override public boolean writeDoubleArray(String name, @Nullable double[] val) { + stream.writeDoubleArray(val); + + return stream.lastFinished(); + } + + /** {@inheritDoc} */ + @Override public boolean writeCharArray(String name, @Nullable char[] val) { + stream.writeCharArray(val); + + return stream.lastFinished(); + } + + /** {@inheritDoc} */ + @Override public boolean writeBooleanArray(String name, @Nullable boolean[] val) { + stream.writeBooleanArray(val); + + return stream.lastFinished(); + } + + /** {@inheritDoc} */ + @Override public boolean writeMessage(String name, @Nullable MessageAdapter msg) { + if (msg != null) + msg.setWriter(this); + + stream.writeMessage(msg); + + return stream.lastFinished(); + } + + /** {@inheritDoc} */ + @Override public boolean writeCollection(String name, Collection col, Class itemCls) { + stream.writeCollection(col, itemCls); + + return stream.lastFinished(); + } + + /** {@inheritDoc} */ + @Override public boolean writeMap(String name, Map map, Class keyCls, Class valCls) { + stream.writeMap(map, keyCls, valCls); + + return stream.lastFinished(); + } +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectUtils.java new file mode 100644 index 0000000000000..d0d966fc87c58 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectUtils.java @@ -0,0 +1,346 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.direct; + +import org.apache.ignite.internal.processors.cache.*; +import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.*; +import org.apache.ignite.internal.processors.cache.version.*; +import org.apache.ignite.internal.processors.clock.*; +import org.apache.ignite.internal.util.*; +import org.apache.ignite.lang.*; +import sun.misc.*; + +import java.util.*; + +/** + * Direct marshalling utility methods. + */ +public class DirectUtils { + /** */ + private static final Unsafe UNSAFE = GridUnsafe.unsafe(); + + /** */ + private static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class); + + /** + * Do not instantiate. + */ + private DirectUtils() { + // No-op. + } + + /** + * @param uuid {@link UUID}. + * @return Array. + */ + public static byte[] uuidToArray(UUID uuid) { + byte[] arr = null; + + if (uuid != null) { + arr = new byte[16]; + + UNSAFE.putLong(arr, BYTE_ARR_OFF, uuid.getMostSignificantBits()); + UNSAFE.putLong(arr, BYTE_ARR_OFF + 8, uuid.getLeastSignificantBits()); + } + + return arr; + } + + /** + * @param arr Array. + * @return {@link UUID}. + */ + public static UUID arrayToUuid(byte[] arr) { + if (arr == null) + return null; + else { + long most = UNSAFE.getLong(arr, BYTE_ARR_OFF); + long least = UNSAFE.getLong(arr, BYTE_ARR_OFF + 8); + + return new UUID(most, least); + } + } + + /** + * @param uuid {@link IgniteUuid}. + * @return Array. + */ + public static byte[] gridUuidToArray(IgniteUuid uuid) { + byte[] arr = null; + + if (uuid != null) { + arr = new byte[24]; + + UNSAFE.putLong(arr, BYTE_ARR_OFF, uuid.globalId().getMostSignificantBits()); + UNSAFE.putLong(arr, BYTE_ARR_OFF + 8, uuid.globalId().getLeastSignificantBits()); + UNSAFE.putLong(arr, BYTE_ARR_OFF + 16, uuid.localId()); + } + + return arr; + } + + /** + * @param arr Array. + * @return {@link IgniteUuid}. + */ + public static IgniteUuid arrayToIgniteUuid(byte[] arr) { + if (arr == null) + return null; + else { + long most = UNSAFE.getLong(arr, BYTE_ARR_OFF); + long least = UNSAFE.getLong(arr, BYTE_ARR_OFF + 8); + long loc = UNSAFE.getLong(arr, BYTE_ARR_OFF + 16); + + return new IgniteUuid(new UUID(most, least), loc); + } + } + + /** + * @param ver {@link GridClockDeltaVersion}. + * @return Array. + */ + public static byte[] clockDeltaVersionToArray(GridClockDeltaVersion ver) { + byte[] arr = null; + + if (ver != null) { + arr = new byte[16]; + + UNSAFE.putLong(arr, BYTE_ARR_OFF, ver.version()); + UNSAFE.putLong(arr, BYTE_ARR_OFF + 8, ver.topologyVersion()); + } + + return arr; + } + + /** + * @param arr Array. + * @return {@link GridClockDeltaVersion}. + */ + public static GridClockDeltaVersion arrayToClockDeltaVersion(byte[] arr) { + if (arr == null) + return null; + else { + long ver = UNSAFE.getLong(arr, BYTE_ARR_OFF); + long topVer = UNSAFE.getLong(arr, BYTE_ARR_OFF + 8); + + return new GridClockDeltaVersion(ver, topVer); + } + } + + /** + * @param list {@link GridByteArrayList}. + * @return Array. + */ + public static byte[] byteArrayListToArray(GridByteArrayList list) { + return list != null ? list.array() : null; + } + + /** + * @param arr Array. + * @return {@link GridByteArrayList}. + */ + public static GridByteArrayList arrayToByteArrayList(byte[] arr) { + return arr != null ? new GridByteArrayList(arr) : null; + } + + /** + * @param list {@link GridLongList}. + * @return Array. + */ + public static long[] longListToArray(GridLongList list) { + return list != null ? list.array() : null; + } + + /** + * @param arr Array. + * @return {@link GridLongList}. + */ + public static GridLongList arrayToLongList(long[] arr) { + return arr != null ? new GridLongList(arr) : null; + } + + /** + * @param ver {@link GridCacheVersion}. + * @return Array. + */ + public static byte[] cacheVersionToArray(GridCacheVersion ver) { + byte[] arr = null; + + if (ver != null) { + arr = new byte[24]; + + UNSAFE.putInt(arr, BYTE_ARR_OFF, ver.topologyVersion()); + UNSAFE.putInt(arr, BYTE_ARR_OFF + 4, ver.nodeOrderAndDrIdRaw()); + UNSAFE.putLong(arr, BYTE_ARR_OFF + 8, ver.globalTime()); + UNSAFE.putLong(arr, BYTE_ARR_OFF + 16, ver.order()); + } + + return arr; + } + + /** + * @param arr Array. + * @return {@link GridCacheVersion}. + */ + public static GridCacheVersion arrayToCacheVersion(byte[] arr) { + if (arr == null) + return null; + else { + int topVerDrId = UNSAFE.getInt(arr, BYTE_ARR_OFF); + int nodeOrder = UNSAFE.getInt(arr, BYTE_ARR_OFF + 4); + long globalTime = UNSAFE.getLong(arr, BYTE_ARR_OFF + 8); + long order = UNSAFE.getLong(arr, BYTE_ARR_OFF + 16); + + return new GridCacheVersion(topVerDrId, nodeOrder, globalTime, order); + } + } + + /** + * @param id {@link GridDhtPartitionExchangeId}. + * @return Array. + */ + public static byte[] dhtPartitionExchangeIdToArray(GridDhtPartitionExchangeId id) { + byte[] arr = null; + + if (id != null) { + arr = new byte[28]; + + UNSAFE.putLong(arr, BYTE_ARR_OFF, id.nodeId().getMostSignificantBits()); + UNSAFE.putLong(arr, BYTE_ARR_OFF + 8, id.nodeId().getLeastSignificantBits()); + UNSAFE.putInt(arr, BYTE_ARR_OFF + 16, id.event()); + UNSAFE.putLong(arr, BYTE_ARR_OFF + 20, id.topologyVersion()); + } + + return arr; + } + + /** + * @param arr Array. + * @return {@link GridDhtPartitionExchangeId}. + */ + public static GridDhtPartitionExchangeId arrayToDhtPartitionExchangeId(byte[] arr) { + if (arr == null) + return null; + else { + long most = UNSAFE.getLong(arr, BYTE_ARR_OFF); + long least = UNSAFE.getLong(arr, BYTE_ARR_OFF + 8); + int evt = UNSAFE.getInt(arr, BYTE_ARR_OFF + 16); + long topVer = UNSAFE.getLong(arr, BYTE_ARR_OFF + 20); + + return new GridDhtPartitionExchangeId(new UUID(most, least), evt, topVer); + } + } + + /** + * @param bytes {@link GridCacheValueBytes}. + * @return Array. + */ + public static byte[] valueBytesToArray(GridCacheValueBytes bytes) { + byte[] arr = null; + + if (bytes != null) { + byte[] bytes0 = bytes.get(); + + if (bytes0 != null) { + int len = bytes0.length; + + arr = new byte[len + 2]; + + UNSAFE.putBoolean(arr, BYTE_ARR_OFF, true); + UNSAFE.copyMemory(bytes0, BYTE_ARR_OFF, arr, BYTE_ARR_OFF + 1, len); + UNSAFE.putBoolean(arr, BYTE_ARR_OFF + 1 + len, bytes.isPlain()); + } + else { + arr = new byte[1]; + + UNSAFE.putBoolean(arr, BYTE_ARR_OFF, false); + } + } + + return arr; + } + + /** + * @param arr Array. + * @return {@link GridCacheValueBytes}. + */ + public static GridCacheValueBytes arrayToValueBytes(byte[] arr) { + if (arr == null) + return null; + else { + boolean notNull = UNSAFE.getBoolean(arr, BYTE_ARR_OFF); + + if (notNull) { + int len = arr.length - 2; + + assert len >= 0 : len; + + byte[] bytesArr = new byte[len]; + + UNSAFE.copyMemory(arr, BYTE_ARR_OFF + 1, bytesArr, BYTE_ARR_OFF, len); + + boolean isPlain = UNSAFE.getBoolean(arr, BYTE_ARR_OFF + 1 + len); + + return new GridCacheValueBytes(bytesArr, isPlain); + } + else + return new GridCacheValueBytes(); + } + } + + /** + * @param str {@link String}. + * @return Array. + */ + public static byte[] stringToArray(String str) { + return str != null ? str.getBytes() : null; + } + + /** + * @param arr Array. + * @return {@link String}. + */ + public static String arrayToString(byte[] arr) { + return arr != null ? new String(arr) : null; + } + + /** + * @param bits {@link BitSet}. + * @return Array. + */ + public static long[] bitSetToArray(BitSet bits) { + return bits != null ? bits.toLongArray() : null; + } + + /** + * @param arr Array. + * @return {@link BitSet}. + */ + public static BitSet arrayToBitSet(long[] arr) { + return arr != null ? BitSet.valueOf(arr) : null; + } + +// /** +// * @param name Field name. +// * @param e Enum. +// * @return Whether value was fully written. +// */ +// protected boolean putEnum(String name, @Nullable Enum e) { +// return writer.writeByte(name, e != null ? (byte)e.ordinal() : -1); +// } +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageFactory.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/GridTcpCommunicationMessageFactory.java similarity index 97% rename from modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageFactory.java rename to modules/core/src/main/java/org/apache/ignite/internal/direct/GridTcpCommunicationMessageFactory.java index ddcbdddc005d3..d3091e6ed804e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageFactory.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/GridTcpCommunicationMessageFactory.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.ignite.internal.util.direct; +package org.apache.ignite.internal.direct; import org.apache.ignite.internal.*; import org.apache.ignite.internal.managers.checkpoint.*; @@ -36,6 +36,7 @@ import org.apache.ignite.internal.processors.rest.handlers.task.*; import org.apache.ignite.internal.processors.rest.protocols.tcp.*; import org.apache.ignite.internal.processors.streamer.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.spi.collision.jobstealing.*; import org.apache.ignite.spi.communication.tcp.*; import org.jdk8.backport.*; @@ -59,7 +60,7 @@ public class GridTcpCommunicationMessageFactory { static { registerCommon(new GridTcpCommunicationMessageProducer() { - @Override public GridTcpCommunicationMessageAdapter create(byte type) { + @Override public MessageAdapter create(byte type) { switch (type) { case 0: return new GridJobCancelRequest(); @@ -305,7 +306,7 @@ public class GridTcpCommunicationMessageFactory { * @param type Message type. * @return New message. */ - public static GridTcpCommunicationMessageAdapter create(byte type) { + public static MessageAdapter create(byte type) { if (type == TcpCommunicationSpi.NODE_ID_MSG_TYPE) return new TcpCommunicationSpi.NodeIdMessage(); else if (type == TcpCommunicationSpi.RECOVERY_LAST_ID_MSG_TYPE) @@ -320,7 +321,7 @@ else if (type == TcpCommunicationSpi.HANDSHAKE_MSG_TYPE) * @param type Message type. * @return New message. */ - private static GridTcpCommunicationMessageAdapter create0(byte type) { + private static MessageAdapter create0(byte type) { if (type >= 0 && type < COMMON.length) { GridTcpCommunicationMessageProducer producer = COMMON[type]; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageProducer.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/GridTcpCommunicationMessageProducer.java similarity index 87% rename from modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageProducer.java rename to modules/core/src/main/java/org/apache/ignite/internal/direct/GridTcpCommunicationMessageProducer.java index a856603108a90..29320027e7443 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageProducer.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/GridTcpCommunicationMessageProducer.java @@ -15,7 +15,9 @@ * limitations under the License. */ -package org.apache.ignite.internal.util.direct; +package org.apache.ignite.internal.direct; + +import org.apache.ignite.plugin.extensions.communication.*; /** * Message producer. Each component have to register it's own message producer. @@ -27,5 +29,5 @@ public interface GridTcpCommunicationMessageProducer { * @param type Message type. * @return Communication message. */ - public GridTcpCommunicationMessageAdapter create(byte type); + public MessageAdapter create(byte type); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageState.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/GridTcpCommunicationMessageState.java similarity index 90% rename from modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageState.java rename to modules/core/src/main/java/org/apache/ignite/internal/direct/GridTcpCommunicationMessageState.java index 66a8394650218..ad9542a6b5a1a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageState.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/GridTcpCommunicationMessageState.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.ignite.internal.util.direct; +package org.apache.ignite.internal.direct; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.*; @@ -24,14 +24,13 @@ import org.apache.ignite.internal.util.*; import org.apache.ignite.lang.*; import org.apache.ignite.plugin.extensions.communication.*; -import org.gridgain.grid.util.direct.*; import org.jetbrains.annotations.*; import sun.misc.*; import java.nio.*; import java.util.*; -import static org.apache.ignite.internal.util.direct.GridTcpCommunicationMessageAdapter.*; +import static org.apache.ignite.plugin.extensions.communication.MessageAdapter.*; /** * Communication message state. @@ -45,7 +44,7 @@ public class GridTcpCommunicationMessageState { private static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class); /** */ - private final MessageWriter writer = new GridTcpCommunicationMessageWriter(); + private final MessageWriter writer = new DirectMessageWriter(); /** */ private MessageReader reader; @@ -60,7 +59,7 @@ public class GridTcpCommunicationMessageState { public Iterator it; /** */ - public Object cur = NULL; + public Object cur; /** */ public boolean keyDone; @@ -370,37 +369,6 @@ public final boolean[] getBooleanArray(String name) { return reader.readBooleanArray(name); } - /** - * @param name Field name. - * @param buf Buffer. - * @return Whether value was fully written. - */ - public final boolean putByteBuffer(String name, @Nullable ByteBuffer buf) { - byte[] arr = null; - - if (buf != null) { - ByteBuffer buf0 = buf.duplicate(); - - arr = new byte[buf0.remaining()]; - - buf0.get(arr); - } - - return putByteArray(name, arr); - } - - /** - * @param name Field name. - * @return {@link ByteBuffer}. - */ - public final ByteBuffer getByteBuffer(String name) { - byte[] arr = getByteArray(name); - - if (arr == null) - return null; - else - return ByteBuffer.wrap(arr); - } /** * @param name Field name. @@ -522,14 +490,10 @@ public final boolean putByteArrayList(String name, @Nullable GridByteArrayList l * @param name Field name. * @return {@link GridByteArrayList}. */ - @SuppressWarnings("IfMayBeConditional") public final GridByteArrayList getByteArrayList(String name) { byte[] arr = getByteArray(name); - if (arr == null) - return null; - else - return new GridByteArrayList(arr); + return arr != null ? new GridByteArrayList(arr) : null; } /** @@ -545,14 +509,10 @@ public final boolean putLongList(String name, @Nullable GridLongList list) { * @param name Field name. * @return {@link GridLongList}. */ - @SuppressWarnings("IfMayBeConditional") public final GridLongList getLongList(String name) { long[] arr = getLongArray(name); - if (arr == null) - return null; - else - return new GridLongList(arr); + return arr != null ? new GridLongList(arr) : null; } /** @@ -706,14 +666,10 @@ public final boolean putString(String name, @Nullable String str) { * @param name Field name. * @return {@link String}. */ - @SuppressWarnings("IfMayBeConditional") public final String getString(String name) { byte[] arr = getByteArray(name); - if (arr == null) - return null; - else - return new String(arr); + return arr != null ? new String(arr) : null; } /** @@ -729,14 +685,10 @@ public final boolean putBitSet(String name, @Nullable BitSet bits) { * @param name Field name. * @return {@link BitSet}. */ - @SuppressWarnings("IfMayBeConditional") public final BitSet getBitSet(String name) { long[] arr = getLongArray(name); - if (arr == null) - return null; - else - return BitSet.valueOf(arr); + return arr != null ? BitSet.valueOf(arr) : null; } /** @@ -750,10 +702,10 @@ public final boolean putEnum(String name, @Nullable Enum e) { /** * @param name Field name. - * @param msg {@link GridTcpCommunicationMessageAdapter}. + * @param msg {@link MessageAdapter}. * @return Whether value was fully written. */ - public final boolean putMessage(String name, @Nullable GridTcpCommunicationMessageAdapter msg) { + public final boolean putMessage(String name, @Nullable MessageAdapter msg) { if (msg != null) msg.setWriter(writer); @@ -762,9 +714,9 @@ public final boolean putMessage(String name, @Nullable GridTcpCommunicationMessa /** * @param name Field name. - * @return {@link GridTcpCommunicationMessageAdapter}. + * @return {@link MessageAdapter}. */ - public final GridTcpCommunicationMessageAdapter getMessage(String name) { + public final MessageAdapter getMessage(String name) { return reader.readMessage(name); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpMessageFactory.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/GridTcpMessageFactory.java similarity index 86% rename from modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpMessageFactory.java rename to modules/core/src/main/java/org/apache/ignite/internal/direct/GridTcpMessageFactory.java index 7f33cd14fd4a1..5c66a04b9a6fc 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpMessageFactory.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/GridTcpMessageFactory.java @@ -15,7 +15,9 @@ * limitations under the License. */ -package org.apache.ignite.internal.util.direct; +package org.apache.ignite.internal.direct; + +import org.apache.ignite.plugin.extensions.communication.*; /** * @@ -25,5 +27,5 @@ public interface GridTcpMessageFactory { * @param type Message type. * @return Message instance. */ - public GridTcpCommunicationMessageAdapter create(byte type); + public MessageAdapter create(byte type); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/GridManagerAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/GridManagerAdapter.java index 7143cfe300b53..58b84b2a53c34 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/GridManagerAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/GridManagerAdapter.java @@ -22,6 +22,7 @@ import org.apache.ignite.cluster.*; import org.apache.ignite.events.*; import org.apache.ignite.internal.*; +import org.apache.ignite.internal.direct.*; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.lang.*; import org.apache.ignite.plugin.extensions.communication.*; @@ -29,9 +30,7 @@ import org.apache.ignite.spi.*; import org.apache.ignite.internal.managers.communication.*; import org.apache.ignite.internal.managers.eventstorage.*; -import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.spi.swapspace.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; @@ -319,8 +318,8 @@ protected final String stopInfo() { A.notNull(topic, "topic"); try { - if (msg instanceof GridTcpCommunicationMessageAdapter) - ctx.io().send(node, topic, (GridTcpCommunicationMessageAdapter)msg, SYSTEM_POOL); + if (msg instanceof MessageAdapter) + ctx.io().send(node, topic, (MessageAdapter)msg, SYSTEM_POOL); else ctx.io().sendUserMessage(asList(node), msg, topic, false, 0); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointRequest.java index 9bcd89b35169d..fda129a4d8f6d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointRequest.java @@ -17,9 +17,9 @@ package org.apache.ignite.internal.managers.checkpoint; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -27,7 +27,7 @@ /** * This class defines checkpoint request. */ -public class GridCheckpointRequest extends GridTcpCommunicationMessageAdapter { +public class GridCheckpointRequest extends MessageAdapter { /** */ private static final long serialVersionUID = 0L; @@ -85,7 +85,7 @@ public String getCheckpointSpi() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridCheckpointRequest _clone = new GridCheckpointRequest(); clone0(_clone); @@ -94,7 +94,7 @@ public String getCheckpointSpi() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { GridCheckpointRequest _clone = (GridCheckpointRequest)_msg; _clone.sesId = sesId; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java index 70ab41dd8aa0e..69026170d2a6f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java @@ -21,12 +21,12 @@ import org.apache.ignite.cluster.*; import org.apache.ignite.events.*; import org.apache.ignite.internal.*; +import org.apache.ignite.internal.direct.*; import org.apache.ignite.internal.managers.*; import org.apache.ignite.internal.managers.deployment.*; import org.apache.ignite.internal.managers.eventstorage.*; import org.apache.ignite.internal.processors.timeout.*; import org.apache.ignite.internal.util.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; @@ -36,7 +36,6 @@ import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.spi.*; import org.apache.ignite.spi.communication.*; -import org.gridgain.grid.util.direct.*; import org.jdk8.backport.*; import org.jetbrains.annotations.*; @@ -202,8 +201,8 @@ public void initMessageFactory() { producers = common; msgFactory = new GridTcpMessageFactory() { - @Override public GridTcpCommunicationMessageAdapter create(byte type) { - GridTcpCommunicationMessageAdapter msg; + @Override public MessageAdapter create(byte type) { + MessageAdapter msg; if (type < 0 || type >= producers.length) msg = GridTcpCommunicationMessageFactory.create(type); @@ -275,7 +274,7 @@ public void resetMetrics() { else { writerFactory = new MessageWriterFactory() { @Override public MessageWriter writer() { - return new GridTcpCommunicationMessageWriter(); + return new DirectMessageWriter(); } }; } @@ -287,7 +286,7 @@ public void resetMetrics() { else { readerFactory = new MessageReaderFactory() { @Override public MessageReader reader() { - return new GridTcpCommunicationMessageReader(msgFactory); + return new DirectMessageReader(msgFactory); } }; } @@ -950,7 +949,7 @@ private void send( ClusterNode node, Object topic, int topicOrd, - GridTcpCommunicationMessageAdapter msg, + MessageAdapter msg, GridIoPolicy plc, boolean ordered, long timeout, @@ -1001,7 +1000,7 @@ private void send( * @param plc Type of processing. * @throws IgniteCheckedException Thrown in case of any errors. */ - public void send(UUID nodeId, Object topic, GridTcpCommunicationMessageAdapter msg, GridIoPolicy plc) + public void send(UUID nodeId, Object topic, MessageAdapter msg, GridIoPolicy plc) throws IgniteCheckedException { ClusterNode node = ctx.discovery().node(nodeId); @@ -1019,7 +1018,7 @@ public void send(UUID nodeId, Object topic, GridTcpCommunicationMessageAdapter m * @throws IgniteCheckedException Thrown in case of any errors. */ @SuppressWarnings("TypeMayBeWeakened") - public void send(UUID nodeId, GridTopic topic, GridTcpCommunicationMessageAdapter msg, GridIoPolicy plc) + public void send(UUID nodeId, GridTopic topic, MessageAdapter msg, GridIoPolicy plc) throws IgniteCheckedException { ClusterNode node = ctx.discovery().node(nodeId); @@ -1036,7 +1035,7 @@ public void send(UUID nodeId, GridTopic topic, GridTcpCommunicationMessageAdapte * @param plc Type of processing. * @throws IgniteCheckedException Thrown in case of any errors. */ - public void send(ClusterNode node, Object topic, GridTcpCommunicationMessageAdapter msg, GridIoPolicy plc) + public void send(ClusterNode node, Object topic, MessageAdapter msg, GridIoPolicy plc) throws IgniteCheckedException { send(node, topic, -1, msg, plc, false, 0, false); } @@ -1048,7 +1047,7 @@ public void send(ClusterNode node, Object topic, GridTcpCommunicationMessageAdap * @param plc Type of processing. * @throws IgniteCheckedException Thrown in case of any errors. */ - public void send(ClusterNode node, GridTopic topic, GridTcpCommunicationMessageAdapter msg, GridIoPolicy plc) + public void send(ClusterNode node, GridTopic topic, MessageAdapter msg, GridIoPolicy plc) throws IgniteCheckedException { send(node, topic, topic.ordinal(), msg, plc, false, 0, false); } @@ -1065,7 +1064,7 @@ public void send(ClusterNode node, GridTopic topic, GridTcpCommunicationMessageA public void sendOrderedMessage( ClusterNode node, Object topic, - GridTcpCommunicationMessageAdapter msg, + MessageAdapter msg, GridIoPolicy plc, long timeout, boolean skipOnTimeout @@ -1087,7 +1086,7 @@ public void sendOrderedMessage( public void sendOrderedMessage( UUID nodeId, Object topic, - GridTcpCommunicationMessageAdapter msg, + MessageAdapter msg, GridIoPolicy plc, long timeout, boolean skipOnTimeout @@ -1114,7 +1113,7 @@ public void sendOrderedMessage( public void sendOrderedMessage( Collection nodes, Object topic, - GridTcpCommunicationMessageAdapter msg, + MessageAdapter msg, GridIoPolicy plc, long timeout, boolean skipOnTimeout @@ -1135,7 +1134,7 @@ public void sendOrderedMessage( public void send( Collection nodes, Object topic, - GridTcpCommunicationMessageAdapter msg, + MessageAdapter msg, GridIoPolicy plc ) throws IgniteCheckedException { send(nodes, topic, -1, msg, plc, false, 0, false); @@ -1151,7 +1150,7 @@ public void send( public void send( Collection nodes, GridTopic topic, - GridTcpCommunicationMessageAdapter msg, + MessageAdapter msg, GridIoPolicy plc ) throws IgniteCheckedException { send(nodes, topic, topic.ordinal(), msg, plc, false, 0, false); @@ -1211,7 +1210,7 @@ public void sendUserMessage(Collection nodes, Object msg, depClsName = cls0.getName(); } - GridTcpCommunicationMessageAdapter ioMsg = new GridIoUserMessage( + MessageAdapter ioMsg = new GridIoUserMessage( msg, serMsg, depClsName, @@ -1284,7 +1283,7 @@ private void send( Collection nodes, Object topic, int topicOrd, - GridTcpCommunicationMessageAdapter msg, + MessageAdapter msg, GridIoPolicy plc, boolean ordered, long timeout, @@ -1306,7 +1305,7 @@ private void send( boolean first = true; for (ClusterNode node : nodes) { - GridTcpCommunicationMessageAdapter msg0 = first ? msg : msg.clone(); + MessageAdapter msg0 = first ? msg : msg.clone(); first = false; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java index bd41580abd0d8..cf908e80ef989 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java @@ -18,9 +18,9 @@ package org.apache.ignite.internal.managers.communication; import org.apache.ignite.internal.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -28,7 +28,7 @@ /** * Wrapper for all grid messages. */ -public class GridIoMessage extends GridTcpCommunicationMessageAdapter { +public class GridIoMessage extends MessageAdapter { /** */ private static final long serialVersionUID = 0L; @@ -56,7 +56,7 @@ public class GridIoMessage extends GridTcpCommunicationMessageAdapter { private boolean skipOnTimeout; /** Message. */ - private GridTcpCommunicationMessageAdapter msg; + private MessageAdapter msg; /** * No-op constructor to support {@link Externalizable} interface. @@ -79,7 +79,7 @@ public GridIoMessage( GridIoPolicy plc, Object topic, int topicOrd, - GridTcpCommunicationMessageAdapter msg, + MessageAdapter msg, boolean ordered, long timeout, boolean skipOnTimeout @@ -180,7 +180,7 @@ boolean isOrdered() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridIoMessage _clone = new GridIoMessage(); clone0(_clone); @@ -190,7 +190,7 @@ boolean isOrdered() { /** {@inheritDoc} */ @SuppressWarnings("RedundantCast") - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { GridIoMessage _clone = (GridIoMessage)_msg; _clone.plc = plc; @@ -200,7 +200,7 @@ boolean isOrdered() { _clone.ordered = ordered; _clone.timeout = timeout; _clone.skipOnTimeout = skipOnTimeout; - _clone.msg = msg != null ? (GridTcpCommunicationMessageAdapter)msg.clone() : null; + _clone.msg = msg != null ? (MessageAdapter)msg.clone() : null; } /** {@inheritDoc} */ @@ -270,7 +270,7 @@ boolean isOrdered() { switch (commState.idx) { case 0: - msg = (GridTcpCommunicationMessageAdapter)commState.getMessage("msg"); + msg = (MessageAdapter)commState.getMessage("msg"); if (!commState.lastRead()) return false; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoUserMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoUserMessage.java index fa1ebfaa0f216..44039a32d1169 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoUserMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoUserMessage.java @@ -20,10 +20,10 @@ import org.apache.ignite.configuration.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.managers.deployment.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.io.*; @@ -33,7 +33,7 @@ /** * User message wrapper. */ -public class GridIoUserMessage extends GridTcpCommunicationMessageAdapter { +public class GridIoUserMessage extends MessageAdapter { /** */ private static final long serialVersionUID = 0L; @@ -204,7 +204,7 @@ public void deployment(GridDeployment dep) { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridIoUserMessage _clone = new GridIoUserMessage(); clone0(_clone); @@ -213,7 +213,7 @@ public void deployment(GridDeployment dep) { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { GridIoUserMessage _clone = (GridIoUserMessage)_msg; _clone.body = body; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java index aa1b288b3424a..d9a7d9bdb71a7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentCommunication.java @@ -24,13 +24,13 @@ import org.apache.ignite.internal.managers.communication.*; import org.apache.ignite.internal.managers.eventstorage.*; import org.apache.ignite.internal.util.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.lang.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; import org.apache.ignite.marshaller.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.util.*; @@ -282,7 +282,7 @@ private void processResourceRequest(UUID nodeId, GridDeploymentRequest req) { * @param topic Response topic. * @param res Response. */ - private void sendResponse(UUID nodeId, Object topic, GridTcpCommunicationMessageAdapter res) { + private void sendResponse(UUID nodeId, Object topic, MessageAdapter res) { ClusterNode node = ctx.discovery().node(nodeId); if (node != null) { @@ -314,7 +314,7 @@ else if (log.isDebugEnabled()) void sendUndeployRequest(String rsrcName, Collection rmtNodes) throws IgniteCheckedException { assert !rmtNodes.contains(ctx.discovery().localNode()); - GridTcpCommunicationMessageAdapter req = new GridDeploymentRequest(null, null, rsrcName, true); + MessageAdapter req = new GridDeploymentRequest(null, null, rsrcName, true); if (!rmtNodes.isEmpty()) { ctx.io().send( diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentInfoBean.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentInfoBean.java index 5d9a1049517af..c0698d06f91a2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentInfoBean.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentInfoBean.java @@ -19,10 +19,10 @@ import org.apache.ignite.configuration.*; import org.apache.ignite.internal.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -31,7 +31,7 @@ /** * Deployment info bean. */ -public class GridDeploymentInfoBean extends GridTcpCommunicationMessageAdapter implements GridDeploymentInfo, +public class GridDeploymentInfoBean extends MessageAdapter implements GridDeploymentInfo, Externalizable { /** */ private static final long serialVersionUID = 0L; @@ -139,7 +139,7 @@ public void localDeploymentOwner(boolean locDepOwner) { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridDeploymentInfoBean _clone = new GridDeploymentInfoBean(); clone0(_clone); @@ -148,7 +148,7 @@ public void localDeploymentOwner(boolean locDepOwner) { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { GridDeploymentInfoBean _clone = (GridDeploymentInfoBean)_msg; _clone.clsLdrId = clsLdrId; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentRequest.java index 2a8b6ddf14cb2..86019b9a6e132 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentRequest.java @@ -18,10 +18,10 @@ package org.apache.ignite.internal.managers.deployment; import org.apache.ignite.internal.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -30,7 +30,7 @@ /** * Deployment request. */ -public class GridDeploymentRequest extends GridTcpCommunicationMessageAdapter { +public class GridDeploymentRequest extends MessageAdapter { /** */ private static final long serialVersionUID = 0L; @@ -157,7 +157,7 @@ public void nodeIds(Collection nodeIds) { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridDeploymentRequest _clone = new GridDeploymentRequest(); clone0(_clone); @@ -166,7 +166,7 @@ public void nodeIds(Collection nodeIds) { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { GridDeploymentRequest _clone = (GridDeploymentRequest)_msg; _clone.resTopic = resTopic; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentResponse.java index d281a4fa7a0a0..de50cc973e305 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentResponse.java @@ -18,8 +18,8 @@ package org.apache.ignite.internal.managers.deployment; import org.apache.ignite.internal.util.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -27,7 +27,7 @@ /** * Grid deployment response containing requested resource bytes. */ -public class GridDeploymentResponse extends GridTcpCommunicationMessageAdapter { +public class GridDeploymentResponse extends MessageAdapter { /** */ private static final long serialVersionUID = 0L; @@ -107,7 +107,7 @@ void errorMessage(String errMsg) { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridDeploymentResponse _clone = new GridDeploymentResponse(); clone0(_clone); @@ -116,7 +116,7 @@ void errorMessage(String errMsg) { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { GridDeploymentResponse _clone = (GridDeploymentResponse)_msg; _clone.success = success; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java index 5b0c62f045c1c..1658b88337bc7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java @@ -20,10 +20,10 @@ import org.apache.ignite.configuration.*; import org.apache.ignite.events.*; import org.apache.ignite.internal.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.nio.*; @@ -32,7 +32,7 @@ /** * Event storage message. */ -public class GridEventStorageMessage extends GridTcpCommunicationMessageAdapter { +public class GridEventStorageMessage extends MessageAdapter { /** */ private static final long serialVersionUID = 0L; @@ -262,7 +262,7 @@ void exceptionBytes(byte[] exBytes) { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridEventStorageMessage _clone = new GridEventStorageMessage(); clone0(_clone); @@ -271,7 +271,7 @@ void exceptionBytes(byte[] exBytes) { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { GridEventStorageMessage _clone = (GridEventStorageMessage)_msg; _clone.resTopic = resTopic; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionRequest.java index 9059d75cdc1f0..bb63b86e20a33 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionRequest.java @@ -20,11 +20,11 @@ import org.apache.ignite.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.version.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.lang.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -141,7 +141,7 @@ void addKey(K key, GridCacheVersion ver, boolean near) { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridCacheEvictionRequest _clone = new GridCacheEvictionRequest(); clone0(_clone); @@ -150,7 +150,7 @@ void addKey(K key, GridCacheVersion ver, boolean near) { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridCacheEvictionRequest _clone = (GridCacheEvictionRequest)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionResponse.java index 8bf52d7fe5723..819902058e011 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionResponse.java @@ -19,9 +19,9 @@ import org.apache.ignite.*; import org.apache.ignite.internal.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -130,7 +130,7 @@ boolean error() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridCacheEvictionResponse _clone = new GridCacheEvictionResponse(); clone0(_clone); @@ -139,7 +139,7 @@ boolean error() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridCacheEvictionResponse _clone = (GridCacheEvictionResponse)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java index eb2929750d6b5..78028b0d5c2a3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java @@ -22,11 +22,11 @@ import org.apache.ignite.internal.*; import org.apache.ignite.internal.managers.deployment.*; import org.apache.ignite.internal.processors.cache.transactions.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; import org.apache.ignite.marshaller.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.nio.*; @@ -36,7 +36,7 @@ /** * Parent of all cache messages. */ -public abstract class GridCacheMessage extends GridTcpCommunicationMessageAdapter { +public abstract class GridCacheMessage extends MessageAdapter { /** */ private static final long serialVersionUID = 0L; @@ -644,7 +644,7 @@ protected final void unmarshalTx(Iterable> txEntries, } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { GridCacheMessage _clone = (GridCacheMessage)_msg; _clone.msgId = msgId; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheValueBytes.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheValueBytes.java index 4fc23a404c30c..aba1c18d59fd0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheValueBytes.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheValueBytes.java @@ -18,12 +18,15 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; +import java.nio.*; + /** * Wrapped value bytes of cache entry. */ -public class GridCacheValueBytes { +public class GridCacheValueBytes extends MessageAdapter { /** Null instance. */ private static final GridCacheValueBytes NULL = new GridCacheValueBytes(); @@ -113,6 +116,31 @@ public boolean isNull() { return bytes == null; } + /** {@inheritDoc} */ + @Override public boolean writeTo(ByteBuffer buf) { + return false; // TODO: implement. + } + + /** {@inheritDoc} */ + @Override public boolean readFrom(ByteBuffer buf) { + return false; // TODO: implement. + } + + /** {@inheritDoc} */ + @Override public byte directType() { + return 0; // TODO: implement. + } + + /** {@inheritDoc} */ + @Override public MessageAdapter clone() { + return null; // TODO: implement. + } + + /** {@inheritDoc} */ + @Override protected void clone0(MessageAdapter _msg) { + // TODO: implement. + } + /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridCacheValueBytes.class, this, "len", bytes != null ? bytes.length : -1); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxRequest.java index 5d2de3714e419..e021408985679 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxRequest.java @@ -19,9 +19,9 @@ import org.apache.ignite.internal.processors.cache.transactions.*; import org.apache.ignite.internal.processors.cache.version.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -98,7 +98,7 @@ public int transactions() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridCacheOptimisticCheckPreparedTxRequest _clone = new GridCacheOptimisticCheckPreparedTxRequest(); clone0(_clone); @@ -107,7 +107,7 @@ public int transactions() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridCacheOptimisticCheckPreparedTxRequest _clone = (GridCacheOptimisticCheckPreparedTxRequest)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxResponse.java index d3ae3f715c8b9..bba1efb84ce48 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxResponse.java @@ -18,9 +18,9 @@ package org.apache.ignite.internal.processors.cache.distributed; import org.apache.ignite.internal.processors.cache.version.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -86,7 +86,7 @@ public boolean success() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridCacheOptimisticCheckPreparedTxResponse _clone = new GridCacheOptimisticCheckPreparedTxResponse(); clone0(_clone); @@ -95,7 +95,7 @@ public boolean success() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridCacheOptimisticCheckPreparedTxResponse _clone = (GridCacheOptimisticCheckPreparedTxResponse)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxRequest.java index 9fe4cfb49f010..4eb5624da5598 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxRequest.java @@ -20,9 +20,9 @@ import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.transactions.*; import org.apache.ignite.internal.processors.cache.version.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -131,7 +131,7 @@ public boolean nearOnlyCheck() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridCachePessimisticCheckCommittedTxRequest _clone = new GridCachePessimisticCheckCommittedTxRequest(); clone0(_clone); @@ -140,7 +140,7 @@ public boolean nearOnlyCheck() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridCachePessimisticCheckCommittedTxRequest _clone = (GridCachePessimisticCheckCommittedTxRequest)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxResponse.java index 41e28ca4ba482..68495f3003a51 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxResponse.java @@ -21,9 +21,9 @@ import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.version.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.io.*; @@ -117,7 +117,7 @@ public GridCacheCommittedTxInfo committedTxInfo() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridCachePessimisticCheckCommittedTxResponse _clone = new GridCachePessimisticCheckCommittedTxResponse(); clone0(_clone); @@ -126,7 +126,7 @@ public GridCacheCommittedTxInfo committedTxInfo() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridCachePessimisticCheckCommittedTxResponse _clone = (GridCachePessimisticCheckCommittedTxResponse)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java index d860411be49e4..f8f9870dca9ab 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java @@ -21,9 +21,9 @@ import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.version.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.nio.*; import java.util.*; @@ -185,7 +185,7 @@ public List nearVersions() { /** {@inheritDoc} */ @SuppressWarnings("CloneDoesntCallSuperClone") - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridCacheTtlUpdateRequest _clone = new GridCacheTtlUpdateRequest(); clone0(_clone); @@ -483,7 +483,7 @@ public List nearVersions() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridCacheTtlUpdateRequest _clone = (GridCacheTtlUpdateRequest)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedBaseMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedBaseMessage.java index 812ed188069a3..55e5250c245a4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedBaseMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedBaseMessage.java @@ -21,9 +21,9 @@ import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.version.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.io.*; @@ -240,7 +240,7 @@ public int keysCount() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridDistributedBaseMessage _clone = (GridDistributedBaseMessage)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java index c4081c9eaa491..3c94d51d39eca 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java @@ -22,10 +22,10 @@ import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.transactions.*; import org.apache.ignite.internal.processors.cache.version.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.transactions.*; import org.jetbrains.annotations.*; @@ -428,7 +428,7 @@ public GridCacheVersion[] drVersions() { /** {@inheritDoc} */ @SuppressWarnings({"CloneCallsConstructors", "OverriddenMethodCallDuringObjectConstruction", "CloneDoesntCallSuperClone"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridDistributedLockRequest _clone = new GridDistributedLockRequest(); clone0(_clone); @@ -437,7 +437,7 @@ public GridCacheVersion[] drVersions() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridDistributedLockRequest _clone = (GridDistributedLockRequest)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java index 1c7761570f68d..32c73e6541298 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java @@ -21,11 +21,11 @@ import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.version.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.io.*; @@ -279,7 +279,7 @@ protected int valuesSize() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors", "OverriddenMethodCallDuringObjectConstruction"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridDistributedLockResponse _clone = new GridDistributedLockResponse(); clone0(_clone); @@ -288,7 +288,7 @@ protected int valuesSize() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridDistributedLockResponse _clone = (GridDistributedLockResponse)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java index 15d61a382bfa2..9a93a5ed125ba 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java @@ -22,11 +22,11 @@ import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.transactions.*; import org.apache.ignite.internal.processors.cache.version.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.io.*; @@ -346,7 +346,7 @@ public boolean groupLock() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors", "OverriddenMethodCallDuringObjectConstruction"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridDistributedTxFinishRequest _clone = new GridDistributedTxFinishRequest(); clone0(_clone); @@ -355,7 +355,7 @@ public boolean groupLock() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridDistributedTxFinishRequest _clone = (GridDistributedTxFinishRequest)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishResponse.java index 557ed8866cbfe..b94daa63b9eb9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishResponse.java @@ -19,9 +19,9 @@ import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.version.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -76,7 +76,7 @@ public IgniteUuid futureId() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors", "OverriddenMethodCallDuringObjectConstruction"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridDistributedTxFinishResponse _clone = new GridDistributedTxFinishResponse(); clone0(_clone); @@ -85,7 +85,7 @@ public IgniteUuid futureId() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridDistributedTxFinishResponse _clone = (GridDistributedTxFinishResponse)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java index 428249763f6c7..2623188c46fc2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java @@ -22,9 +22,9 @@ import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.transactions.*; import org.apache.ignite.internal.processors.cache.version.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.transactions.*; import org.jetbrains.annotations.*; @@ -404,7 +404,7 @@ private void writeCollection(ObjectOutput out, Collection> c /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors", "OverriddenMethodCallDuringObjectConstruction"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridDistributedTxPrepareRequest _clone = new GridDistributedTxPrepareRequest(); clone0(_clone); @@ -413,7 +413,7 @@ private void writeCollection(ObjectOutput out, Collection> c } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridDistributedTxPrepareRequest _clone = (GridDistributedTxPrepareRequest)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java index d7d2ce82c7142..057916c7fd154 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java @@ -21,9 +21,9 @@ import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.version.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.io.*; @@ -151,7 +151,7 @@ public void candidates(Map>> cands) { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors", "OverriddenMethodCallDuringObjectConstruction"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridDistributedTxPrepareResponse _clone = new GridDistributedTxPrepareResponse(); clone0(_clone); @@ -160,7 +160,7 @@ public void candidates(Map>> cands) { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridDistributedTxPrepareResponse _clone = (GridDistributedTxPrepareResponse)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedUnlockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedUnlockRequest.java index fc5cce251bb21..d865208ae3235 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedUnlockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedUnlockRequest.java @@ -20,9 +20,9 @@ import org.apache.ignite.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -117,7 +117,7 @@ public void addKey(K key, byte[] bytes, GridCacheContext ctx) throws Ignit /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors", "OverriddenMethodCallDuringObjectConstruction"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridDistributedUnlockRequest _clone = new GridDistributedUnlockRequest(); clone0(_clone); @@ -126,7 +126,7 @@ public void addKey(K key, byte[] bytes, GridCacheContext ctx) throws Ignit } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridDistributedUnlockRequest _clone = (GridDistributedUnlockRequest)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java index 0e101c262f1a2..1ba375351b58d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java @@ -18,8 +18,8 @@ package org.apache.ignite.internal.processors.cache.distributed.dht; import org.apache.ignite.internal.processors.cache.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.nio.*; @@ -68,7 +68,7 @@ public GridDhtAffinityAssignmentRequest(int cacheId, long topVer) { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridDhtAffinityAssignmentRequest _clone = new GridDhtAffinityAssignmentRequest(); clone0(_clone); @@ -77,7 +77,7 @@ public GridDhtAffinityAssignmentRequest(int cacheId, long topVer) { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridDhtAffinityAssignmentRequest _clone = (GridDhtAffinityAssignmentRequest)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java index a107a44c6e127..14d70e8d17a3b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java @@ -21,9 +21,9 @@ import org.apache.ignite.cluster.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.nio.*; import java.util.*; @@ -90,7 +90,7 @@ public List> affinityAssignment() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridDhtAffinityAssignmentResponse _clone = new GridDhtAffinityAssignmentResponse(); clone0(_clone); @@ -99,7 +99,7 @@ public List> affinityAssignment() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridDhtAffinityAssignmentResponse _clone = (GridDhtAffinityAssignmentResponse)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java index 7b404f5df765b..3c72a2f83046a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java @@ -24,11 +24,11 @@ import org.apache.ignite.internal.processors.cache.transactions.*; import org.apache.ignite.internal.processors.cache.version.*; import org.apache.ignite.internal.util.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.transactions.*; import org.jetbrains.annotations.*; @@ -345,7 +345,7 @@ public long accessTtl() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridDhtLockRequest _clone = new GridDhtLockRequest(); clone0(_clone); @@ -354,7 +354,7 @@ public long accessTtl() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridDhtLockRequest _clone = (GridDhtLockRequest)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java index 4894af0680131..eea4b85b17769 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java @@ -24,10 +24,10 @@ import org.apache.ignite.internal.processors.cache.transactions.*; import org.apache.ignite.internal.processors.cache.version.*; import org.apache.ignite.internal.util.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -201,7 +201,7 @@ public Collection> preloadEntries() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridDhtLockResponse _clone = new GridDhtLockResponse(); clone0(_clone); @@ -210,7 +210,7 @@ public Collection> preloadEntries() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridDhtLockResponse _clone = (GridDhtLockResponse)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java index 25ad224be05ff..1a53250228a2f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java @@ -24,10 +24,10 @@ import org.apache.ignite.internal.processors.cache.transactions.*; import org.apache.ignite.internal.processors.cache.version.*; import org.apache.ignite.internal.util.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.transactions.*; import org.jetbrains.annotations.*; @@ -351,7 +351,7 @@ public GridLongList nearTtls() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridDhtTxFinishRequest _clone = new GridDhtTxFinishRequest(); clone0(_clone); @@ -360,7 +360,7 @@ public GridLongList nearTtls() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridDhtTxFinishRequest _clone = (GridDhtTxFinishRequest)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java index 88bc14a45409a..590f06a7153da 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java @@ -19,9 +19,9 @@ import org.apache.ignite.internal.processors.cache.distributed.*; import org.apache.ignite.internal.processors.cache.version.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -70,7 +70,7 @@ public IgniteUuid miniId() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridDhtTxFinishResponse _clone = new GridDhtTxFinishResponse(); clone0(_clone); @@ -79,7 +79,7 @@ public IgniteUuid miniId() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridDhtTxFinishResponse _clone = (GridDhtTxFinishResponse)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java index 7e7ef6647e5cb..47c2a48bdfdb8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java @@ -24,10 +24,10 @@ import org.apache.ignite.internal.processors.cache.transactions.*; import org.apache.ignite.internal.processors.cache.version.*; import org.apache.ignite.internal.util.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.io.*; @@ -316,7 +316,7 @@ public Map, GridCacheVersion> owned() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridDhtTxPrepareRequest _clone = new GridDhtTxPrepareRequest(); clone0(_clone); @@ -325,7 +325,7 @@ public Map, GridCacheVersion> owned() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridDhtTxPrepareRequest _clone = (GridDhtTxPrepareRequest)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java index 7ce598a5d4ec0..51d179faf3215 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java @@ -23,10 +23,10 @@ import org.apache.ignite.internal.processors.cache.distributed.*; import org.apache.ignite.internal.processors.cache.transactions.*; import org.apache.ignite.internal.processors.cache.version.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -207,7 +207,7 @@ public void addPreloadEntry(GridCacheEntryInfo info) { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridDhtTxPrepareResponse _clone = new GridDhtTxPrepareResponse(); clone0(_clone); @@ -216,7 +216,7 @@ public void addPreloadEntry(GridCacheEntryInfo info) { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridDhtTxPrepareResponse _clone = (GridDhtTxPrepareResponse)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java index 189cfaf116722..19a9dce6b4452 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java @@ -21,8 +21,8 @@ import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.distributed.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -105,7 +105,7 @@ public void addNearKey(K key, byte[] keyBytes, GridCacheSharedContext ctx) /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridDhtUnlockRequest _clone = new GridDhtUnlockRequest(); clone0(_clone); @@ -114,7 +114,7 @@ public void addNearKey(K key, byte[] keyBytes, GridCacheSharedContext ctx) } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridDhtUnlockRequest _clone = (GridDhtUnlockRequest)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicDeferredUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicDeferredUpdateResponse.java index 92efaab3adb8a..07ba0bbcd3d6e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicDeferredUpdateResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicDeferredUpdateResponse.java @@ -20,8 +20,8 @@ import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.version.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -74,7 +74,7 @@ public Collection futureVersions() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridDhtAtomicDeferredUpdateResponse _clone = new GridDhtAtomicDeferredUpdateResponse(); clone0(_clone); @@ -83,7 +83,7 @@ public Collection futureVersions() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridDhtAtomicDeferredUpdateResponse _clone = (GridDhtAtomicDeferredUpdateResponse)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java index 709b681e3b638..8d4d36e064d23 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java @@ -23,9 +23,9 @@ import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.version.*; import org.apache.ignite.internal.util.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import javax.cache.processor.*; @@ -689,7 +689,7 @@ public long nearExpireTime(int idx) { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridDhtAtomicUpdateRequest _clone = new GridDhtAtomicUpdateRequest(); clone0(_clone); @@ -698,7 +698,7 @@ public long nearExpireTime(int idx) { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridDhtAtomicUpdateRequest _clone = (GridDhtAtomicUpdateRequest)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java index 1747f2f93fb93..41a48a1631be1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java @@ -21,9 +21,9 @@ import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.version.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.io.*; @@ -180,7 +180,7 @@ public void addNearEvicted(K key, @Nullable byte[] bytes) { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridDhtAtomicUpdateResponse _clone = new GridDhtAtomicUpdateResponse(); clone0(_clone); @@ -189,7 +189,7 @@ public void addNearEvicted(K key, @Nullable byte[] bytes) { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridDhtAtomicUpdateResponse _clone = (GridDhtAtomicUpdateResponse)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java index 050cb3590cc7a..2726a6d0581b2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java @@ -24,10 +24,10 @@ import org.apache.ignite.internal.processors.cache.distributed.*; import org.apache.ignite.internal.processors.cache.version.*; import org.apache.ignite.internal.util.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import javax.cache.expiry.*; @@ -546,7 +546,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridNearAtomicUpdateRequest _clone = new GridNearAtomicUpdateRequest(); clone0(_clone); @@ -555,7 +555,7 @@ public void forceTransformBackups(boolean forceTransformBackups) { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridNearAtomicUpdateRequest _clone = (GridNearAtomicUpdateRequest)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java index 2280943a8cb5d..fdfde264fc650 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java @@ -22,9 +22,9 @@ import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.version.*; import org.apache.ignite.internal.util.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.io.*; @@ -423,7 +423,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridNearAtomicUpdateResponse _clone = new GridNearAtomicUpdateResponse(); clone0(_clone); @@ -432,7 +432,7 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridNearAtomicUpdateResponse _clone = (GridNearAtomicUpdateResponse)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java index 176086e93f5ae..66a6ad156fb6c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java @@ -20,11 +20,11 @@ import org.apache.ignite.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -163,7 +163,7 @@ private int keyCount() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridDhtForceKeysRequest _clone = new GridDhtForceKeysRequest(); clone0(_clone); @@ -172,7 +172,7 @@ private int keyCount() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridDhtForceKeysRequest _clone = (GridDhtForceKeysRequest)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java index dfe30f7ad9ea9..626cb1fe93c9e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java @@ -20,10 +20,10 @@ import org.apache.ignite.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -166,7 +166,7 @@ public void addInfo(GridCacheEntryInfo info) { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridDhtForceKeysResponse _clone = new GridDhtForceKeysResponse(); clone0(_clone); @@ -175,7 +175,7 @@ public void addInfo(GridCacheEntryInfo info) { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridDhtForceKeysResponse _clone = (GridDhtForceKeysResponse)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java index 130aca95a5f2d..59eb2bdfe8b67 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java @@ -20,9 +20,9 @@ import org.apache.ignite.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -191,7 +191,7 @@ void workerId(int workerId) { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridDhtPartitionDemandMessage _clone = new GridDhtPartitionDemandMessage(); clone0(_clone); @@ -200,7 +200,7 @@ void workerId(int workerId) { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridDhtPartitionDemandMessage _clone = (GridDhtPartitionDemandMessage)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionExchangeId.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionExchangeId.java index d64a68612aa10..dc9d26c1bce01 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionExchangeId.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionExchangeId.java @@ -19,8 +19,10 @@ import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; +import java.nio.*; import java.util.*; import static org.apache.ignite.events.EventType.*; @@ -28,7 +30,8 @@ /** * Exchange ID. */ -public class GridDhtPartitionExchangeId implements Comparable, Externalizable { +public class GridDhtPartitionExchangeId extends MessageAdapter implements Comparable, + Externalizable { /** */ private static final long serialVersionUID = 0L; @@ -142,6 +145,31 @@ public boolean isLeft() { return evt == id.evt && topVer == id.topVer && nodeId.equals(id.nodeId); } + /** {@inheritDoc} */ + @Override public boolean writeTo(ByteBuffer buf) { + return false; // TODO: implement. + } + + /** {@inheritDoc} */ + @Override public boolean readFrom(ByteBuffer buf) { + return false; // TODO: implement. + } + + /** {@inheritDoc} */ + @Override public byte directType() { + return 0; // TODO: implement. + } + + /** {@inheritDoc} */ + @Override public MessageAdapter clone() { + return null; // TODO: implement. + } + + /** {@inheritDoc} */ + @Override protected void clone0(MessageAdapter _msg) { + // TODO: implement. + } + /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridDhtPartitionExchangeId.class, this, diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java index aa48d89a2a2fc..8b953a986e1b5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java @@ -20,9 +20,9 @@ import org.apache.ignite.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -274,7 +274,7 @@ public int size() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridDhtPartitionSupplyMessage _clone = new GridDhtPartitionSupplyMessage(); clone0(_clone); @@ -283,7 +283,7 @@ public int size() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridDhtPartitionSupplyMessage _clone = (GridDhtPartitionSupplyMessage)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsAbstractMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsAbstractMessage.java index 1eb069e6180b2..b8905f9c0b1d1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsAbstractMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsAbstractMessage.java @@ -19,8 +19,8 @@ import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.version.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.io.*; @@ -75,7 +75,7 @@ public GridDhtPartitionExchangeId exchangeId() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridDhtPartitionsAbstractMessage _clone = (GridDhtPartitionsAbstractMessage)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java index fa67ac08da7a1..fad32399887e7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java @@ -22,9 +22,9 @@ import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.version.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.io.*; @@ -144,7 +144,7 @@ public void affinityAssignment(List> affAssignment) { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridDhtPartitionsFullMessage _clone = new GridDhtPartitionsFullMessage(); clone0(_clone); @@ -153,7 +153,7 @@ public void affinityAssignment(List> affAssignment) { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridDhtPartitionsFullMessage _clone = (GridDhtPartitionsFullMessage)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java index 57888bc1eee36..94efd43eedd28 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java @@ -21,9 +21,9 @@ import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.version.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.io.*; @@ -96,7 +96,7 @@ public Map partitions() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridDhtPartitionsSingleMessage _clone = new GridDhtPartitionsSingleMessage(); clone0(_clone); @@ -105,7 +105,7 @@ public Map partitions() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridDhtPartitionsSingleMessage _clone = (GridDhtPartitionsSingleMessage)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleRequest.java index 9cbd7d47e27d7..d7a091bc628c4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleRequest.java @@ -17,8 +17,8 @@ package org.apache.ignite.internal.processors.cache.distributed.dht.preloader; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -46,7 +46,7 @@ public GridDhtPartitionsSingleRequest() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridDhtPartitionsSingleRequest _clone = new GridDhtPartitionsSingleRequest(); clone0(_clone); @@ -55,7 +55,7 @@ public GridDhtPartitionsSingleRequest() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java index 54315c0027af8..c99a65e9f85ec 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java @@ -22,11 +22,11 @@ import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.version.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -251,7 +251,7 @@ public long accessTtl() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridNearGetRequest _clone = new GridNearGetRequest(); clone0(_clone); @@ -260,7 +260,7 @@ public long accessTtl() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridNearGetRequest _clone = (GridNearGetRequest)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java index d712db75ba099..cc2a48a82d593 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java @@ -22,10 +22,10 @@ import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.version.*; import org.apache.ignite.internal.util.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -201,7 +201,7 @@ public void error(Throwable err) { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridNearGetResponse _clone = new GridNearGetResponse(); clone0(_clone); @@ -210,7 +210,7 @@ public void error(Throwable err) { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridNearGetResponse _clone = (GridNearGetResponse)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java index 8d20405dc0dd0..d6455dd57bd79 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java @@ -24,10 +24,10 @@ import org.apache.ignite.internal.processors.cache.distributed.*; import org.apache.ignite.internal.processors.cache.transactions.*; import org.apache.ignite.internal.processors.cache.version.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.transactions.*; import org.jetbrains.annotations.*; @@ -335,7 +335,7 @@ public long accessTtl() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridNearLockRequest _clone = new GridNearLockRequest(); clone0(_clone); @@ -344,7 +344,7 @@ public long accessTtl() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridNearLockRequest _clone = (GridNearLockRequest)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockResponse.java index 2343255009c23..9a62b025b3edc 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockResponse.java @@ -22,10 +22,10 @@ import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.distributed.*; import org.apache.ignite.internal.processors.cache.version.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.io.*; @@ -182,7 +182,7 @@ public void addValueBytes( /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridNearLockResponse _clone = new GridNearLockResponse(); clone0(_clone); @@ -191,7 +191,7 @@ public void addValueBytes( } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridNearLockResponse _clone = (GridNearLockResponse)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java index 3a48eac7d6d54..e2be31245e231 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java @@ -21,9 +21,9 @@ import org.apache.ignite.internal.processors.cache.distributed.*; import org.apache.ignite.internal.processors.cache.transactions.*; import org.apache.ignite.internal.processors.cache.version.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.io.*; @@ -162,7 +162,7 @@ public int taskNameHash() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridNearTxFinishRequest _clone = new GridNearTxFinishRequest(); clone0(_clone); @@ -171,7 +171,7 @@ public int taskNameHash() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridNearTxFinishRequest _clone = (GridNearTxFinishRequest)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java index d855665a67780..5532b883ab6b9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java @@ -22,9 +22,9 @@ import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.distributed.*; import org.apache.ignite.internal.processors.cache.version.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.io.*; @@ -115,7 +115,7 @@ public long threadId() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridNearTxFinishResponse _clone = new GridNearTxFinishResponse(); clone0(_clone); @@ -124,7 +124,7 @@ public long threadId() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridNearTxFinishResponse _clone = (GridNearTxFinishResponse)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java index 9c6135adde416..f0ffa4e49c4d9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java @@ -21,10 +21,10 @@ import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.distributed.*; import org.apache.ignite.internal.processors.cache.transactions.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.io.*; @@ -219,7 +219,7 @@ private Collection> cloneEntries(Collection> cloneEntries(Collection invalidPartitions() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridNearTxPrepareResponse _clone = new GridNearTxPrepareResponse(); clone0(_clone); @@ -234,7 +234,7 @@ public Collection invalidPartitions() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridNearTxPrepareResponse _clone = (GridNearTxPrepareResponse)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearUnlockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearUnlockRequest.java index 8df4302ac20ff..86f839bc3cd3e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearUnlockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearUnlockRequest.java @@ -18,8 +18,8 @@ package org.apache.ignite.internal.processors.cache.distributed.near; import org.apache.ignite.internal.processors.cache.distributed.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -48,7 +48,7 @@ public GridNearUnlockRequest(int cacheId, int keyCnt) { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridNearUnlockRequest _clone = new GridNearUnlockRequest(); clone0(_clone); @@ -57,7 +57,7 @@ public GridNearUnlockRequest(int cacheId, int keyCnt) { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java index 7c052460ba230..5f1552f2818d7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java @@ -21,11 +21,11 @@ import org.apache.ignite.cache.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; import org.apache.ignite.marshaller.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -445,7 +445,7 @@ public int taskHash() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridCacheQueryRequest _clone = new GridCacheQueryRequest(); clone0(_clone); @@ -454,7 +454,7 @@ public int taskHash() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridCacheQueryRequest _clone = (GridCacheQueryRequest)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java index 96d0258c4fbb2..fe18c8c3a9937 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java @@ -21,10 +21,10 @@ import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.query.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.io.*; @@ -203,7 +203,7 @@ public boolean fields() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridCacheQueryResponse _clone = new GridCacheQueryResponse(); clone0(_clone); @@ -212,7 +212,7 @@ public boolean fields() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridCacheQueryResponse _clone = (GridCacheQueryResponse)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersion.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersion.java index 891af09f0907b..15e84acb1236b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersion.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersion.java @@ -20,15 +20,18 @@ import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; import org.apache.ignite.marshaller.optimized.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.io.*; +import java.nio.*; import java.util.*; /** * Grid unique version. */ -public class GridCacheVersion implements Comparable, Externalizable, OptimizedMarshallable { +public class GridCacheVersion extends MessageAdapter implements Comparable, Externalizable, + OptimizedMarshallable { /** */ private static final long serialVersionUID = 0L; @@ -249,6 +252,31 @@ public IgniteUuid asGridUuid() { return topologyVersion() < other.topologyVersion() ? -1 : 1; } + /** {@inheritDoc} */ + @Override public boolean writeTo(ByteBuffer buf) { + return false; // TODO: implement. + } + + /** {@inheritDoc} */ + @Override public boolean readFrom(ByteBuffer buf) { + return false; // TODO: implement. + } + + /** {@inheritDoc} */ + @Override public byte directType() { + return 0; // TODO: implement. + } + + /** {@inheritDoc} */ + @Override public MessageAdapter clone() { + return null; // TODO: implement. + } + + /** {@inheritDoc} */ + @Override protected void clone0(MessageAdapter _msg) { + // TODO: implement. + } + /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridCacheVersion.class, this); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaSnapshotMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaSnapshotMessage.java index a779c2315c4b5..dd576e3f5403c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaSnapshotMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaSnapshotMessage.java @@ -18,9 +18,9 @@ package org.apache.ignite.internal.processors.clock; import org.apache.ignite.internal.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -29,7 +29,7 @@ /** * Message containing time delta map for all nodes. */ -public class GridClockDeltaSnapshotMessage extends GridTcpCommunicationMessageAdapter { +public class GridClockDeltaSnapshotMessage extends MessageAdapter { /** */ private static final long serialVersionUID = 0L; @@ -73,7 +73,7 @@ public Map deltas() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridClockDeltaSnapshotMessage _clone = new GridClockDeltaSnapshotMessage(); clone0(_clone); @@ -82,7 +82,7 @@ public Map deltas() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { GridClockDeltaSnapshotMessage _clone = (GridClockDeltaSnapshotMessage)_msg; _clone.snapVer = snapVer; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaVersion.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaVersion.java index aa03c88801fb1..852f9f0eea83b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaVersion.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaVersion.java @@ -18,13 +18,15 @@ package org.apache.ignite.internal.processors.clock; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; +import java.nio.*; /** * Version for time delta snapshot. */ -public class GridClockDeltaVersion implements Comparable, Externalizable { +public class GridClockDeltaVersion extends MessageAdapter implements Comparable, Externalizable { /** */ private static final long serialVersionUID = 0L; @@ -110,6 +112,31 @@ public long topologyVersion() { topVer = in.readLong(); } + /** {@inheritDoc} */ + @Override public boolean writeTo(ByteBuffer buf) { + return false; // TODO: implement. + } + + /** {@inheritDoc} */ + @Override public boolean readFrom(ByteBuffer buf) { + return false; // TODO: implement. + } + + /** {@inheritDoc} */ + @Override public byte directType() { + return 0; // TODO: implement. + } + + /** {@inheritDoc} */ + @Override public MessageAdapter clone() { + return null; // TODO: implement. + } + + /** {@inheritDoc} */ + @Override protected void clone0(MessageAdapter _msg) { + // TODO: implement. + } + /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridClockDeltaVersion.class, this); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousMessage.java index 3c39742279947..a6a62d750ca42 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousMessage.java @@ -18,10 +18,10 @@ package org.apache.ignite.internal.processors.continuous; import org.apache.ignite.internal.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.io.*; @@ -33,7 +33,7 @@ /** * Continuous processor message. */ -public class GridContinuousMessage extends GridTcpCommunicationMessageAdapter { +public class GridContinuousMessage extends MessageAdapter { /** */ private static final long serialVersionUID = 0L; @@ -132,7 +132,7 @@ public void dataBytes(byte[] dataBytes) { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridContinuousMessage _clone = new GridContinuousMessage(); clone0(_clone); @@ -141,7 +141,7 @@ public void dataBytes(byte[] dataBytes) { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { GridContinuousMessage _clone = (GridContinuousMessage)_msg; _clone.type = type; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadRequest.java index 2b89fea9a3e0d..4690f82a8a162 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadRequest.java @@ -19,10 +19,10 @@ import org.apache.ignite.configuration.*; import org.apache.ignite.internal.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.nio.*; @@ -31,7 +31,7 @@ /** * */ -public class GridDataLoadRequest extends GridTcpCommunicationMessageAdapter { +public class GridDataLoadRequest extends MessageAdapter { /** */ private static final long serialVersionUID = 0L; @@ -506,7 +506,7 @@ public boolean forceLocalDeployment() { } /** {@inheritDoc} */ - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridDataLoadRequest _clone = new GridDataLoadRequest(); clone0(_clone); @@ -515,7 +515,7 @@ public boolean forceLocalDeployment() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { GridDataLoadRequest _clone = (GridDataLoadRequest)_msg; _clone.reqId = reqId; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadResponse.java index faff1d7c222ab..2b8c0ee9b838d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadResponse.java @@ -17,15 +17,15 @@ package org.apache.ignite.internal.processors.dataload; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.nio.*; /** * */ -public class GridDataLoadResponse extends GridTcpCommunicationMessageAdapter { +public class GridDataLoadResponse extends MessageAdapter { /** */ private static final long serialVersionUID = 0L; @@ -84,7 +84,7 @@ public boolean forceLocalDeployment() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridDataLoadResponse _clone = new GridDataLoadResponse(); clone0(_clone); @@ -93,7 +93,7 @@ public boolean forceLocalDeployment() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { GridDataLoadResponse _clone = (GridDataLoadResponse)_msg; _clone.reqId = reqId; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsAckMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsAckMessage.java index e5c91de0507d6..496a114da24bb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsAckMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsAckMessage.java @@ -19,9 +19,9 @@ import org.apache.ignite.*; import org.apache.ignite.internal.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.lang.*; import org.apache.ignite.marshaller.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.io.*; @@ -104,7 +104,7 @@ public IgniteCheckedException error() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridGgfsAckMessage _clone = new GridGgfsAckMessage(); clone0(_clone); @@ -113,7 +113,7 @@ public IgniteCheckedException error() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridGgfsAckMessage _clone = (GridGgfsAckMessage)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlockKey.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlockKey.java index 5530db0147368..bbcbf4241b59e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlockKey.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlockKey.java @@ -18,10 +18,10 @@ package org.apache.ignite.internal.processors.fs; import org.apache.ignite.internal.processors.task.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.io.*; @@ -31,7 +31,7 @@ * File's binary data block key. */ @GridInternal -public final class GridGgfsBlockKey extends GridTcpCommunicationMessageAdapter +public final class GridGgfsBlockKey extends MessageAdapter implements Externalizable, Comparable { /** */ private static final long serialVersionUID = 0L; @@ -160,7 +160,7 @@ public long getBlockId() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridGgfsBlockKey _clone = new GridGgfsBlockKey(); clone0(_clone); @@ -169,7 +169,7 @@ public long getBlockId() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { GridGgfsBlockKey _clone = (GridGgfsBlockKey)_msg; _clone.fileId = fileId; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlocksMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlocksMessage.java index 92dcad1b23cd6..632104227ddd5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlocksMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlocksMessage.java @@ -18,8 +18,8 @@ package org.apache.ignite.internal.processors.fs; import org.apache.ignite.internal.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -85,7 +85,7 @@ public Map blocks() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridGgfsBlocksMessage _clone = new GridGgfsBlocksMessage(); clone0(_clone); @@ -94,7 +94,7 @@ public Map blocks() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridGgfsBlocksMessage _clone = (GridGgfsBlocksMessage)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsCommunicationMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsCommunicationMessage.java index d60a3a1ccb5e9..b08d64ae754df 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsCommunicationMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsCommunicationMessage.java @@ -18,8 +18,8 @@ package org.apache.ignite.internal.processors.fs; import org.apache.ignite.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.marshaller.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.nio.*; @@ -27,12 +27,12 @@ /** * Base class for all GGFS communication messages sent between nodes. */ -public abstract class GridGgfsCommunicationMessage extends GridTcpCommunicationMessageAdapter { +public abstract class GridGgfsCommunicationMessage extends MessageAdapter { /** */ private static final long serialVersionUID = 0L; /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsDeleteMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsDeleteMessage.java index e6e2c6005d2db..6be821a95ca0b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsDeleteMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsDeleteMessage.java @@ -19,10 +19,10 @@ import org.apache.ignite.*; import org.apache.ignite.internal.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; import org.apache.ignite.marshaller.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.io.*; @@ -108,7 +108,7 @@ public IgniteCheckedException error() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridGgfsDeleteMessage _clone = new GridGgfsDeleteMessage(); clone0(_clone); @@ -117,7 +117,7 @@ public IgniteCheckedException error() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridGgfsDeleteMessage _clone = (GridGgfsDeleteMessage)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFileAffinityRange.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFileAffinityRange.java index a522e6f86dc46..04c822e19ea4c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFileAffinityRange.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFileAffinityRange.java @@ -17,10 +17,10 @@ package org.apache.ignite.internal.processors.fs; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.io.*; @@ -30,7 +30,7 @@ /** * Affinity range. */ -public class GridGgfsFileAffinityRange extends GridTcpCommunicationMessageAdapter implements Externalizable { +public class GridGgfsFileAffinityRange extends MessageAdapter implements Externalizable { /** */ private static final long serialVersionUID = 0L; @@ -264,7 +264,7 @@ public boolean regionEqual(GridGgfsFileAffinityRange other) { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridGgfsFileAffinityRange _clone = new GridGgfsFileAffinityRange(); clone0(_clone); @@ -273,7 +273,7 @@ public boolean regionEqual(GridGgfsFileAffinityRange other) { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { GridGgfsFileAffinityRange _clone = (GridGgfsFileAffinityRange)_msg; _clone.affKey = affKey; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerRequest.java index ec89347c111d9..3ecac2f3a70cc 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerRequest.java @@ -18,10 +18,10 @@ package org.apache.ignite.internal.processors.fs; import org.apache.ignite.internal.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -80,7 +80,7 @@ public Collection fragmentRanges() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridGgfsFragmentizerRequest _clone = new GridGgfsFragmentizerRequest(); clone0(_clone); @@ -89,7 +89,7 @@ public Collection fragmentRanges() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridGgfsFragmentizerRequest _clone = (GridGgfsFragmentizerRequest)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerResponse.java index af5a27ced8525..a842e9c98c9da 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerResponse.java @@ -17,8 +17,8 @@ package org.apache.ignite.internal.processors.fs; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -56,7 +56,7 @@ public IgniteUuid fileId() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridGgfsFragmentizerResponse _clone = new GridGgfsFragmentizerResponse(); clone0(_clone); @@ -65,7 +65,7 @@ public IgniteUuid fileId() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridGgfsFragmentizerResponse _clone = (GridGgfsFragmentizerResponse)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsSyncMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsSyncMessage.java index 8251242bbc52f..a632e02363681 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsSyncMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsSyncMessage.java @@ -17,8 +17,8 @@ package org.apache.ignite.internal.processors.fs; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -73,7 +73,7 @@ public boolean response() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridGgfsSyncMessage _clone = new GridGgfsSyncMessage(); clone0(_clone); @@ -82,7 +82,7 @@ public boolean response() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { super.clone0(_msg); GridGgfsSyncMessage _clone = (GridGgfsSyncMessage)_msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/IgniteFsProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/IgniteFsProcessor.java index 7265a043bc606..9920d99240e94 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/IgniteFsProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/IgniteFsProcessor.java @@ -26,13 +26,14 @@ import org.apache.ignite.ignitefs.*; import org.apache.ignite.ignitefs.mapreduce.*; import org.apache.ignite.internal.*; +import org.apache.ignite.internal.direct.*; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.license.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.ipc.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jdk8.backport.*; import org.jetbrains.annotations.*; @@ -83,7 +84,7 @@ public IgniteFsProcessor(GridKernalContext ctx) { // Register GGFS messages. GridTcpCommunicationMessageFactory.registerCommon(new GridTcpCommunicationMessageProducer() { @Override - public GridTcpCommunicationMessageAdapter create(byte type) { + public MessageAdapter create(byte type) { switch (type) { case 64: return new GridGgfsAckMessage(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java index b7b986fe9833c..6223639f1e873 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java @@ -17,16 +17,16 @@ package org.apache.ignite.internal.processors.rest.client.message; -import org.apache.ignite.internal.util.direct.*; +import org.apache.ignite.internal.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; -import org.gridgain.grid.util.direct.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.nio.*; /** * Client handshake wrapper for direct marshalling. */ -public class GridClientHandshakeRequestWrapper extends GridTcpCommunicationMessageAdapter { +public class GridClientHandshakeRequestWrapper extends MessageAdapter { /** */ private static final long serialVersionUID = -5705048094821942662L; @@ -34,7 +34,7 @@ public class GridClientHandshakeRequestWrapper extends GridTcpCommunicationMessa public static final byte HANDSHAKE_HEADER = (byte)0x91; /** Stream. */ - private final GridTcpCommunicationByteBufferStream stream = new GridTcpCommunicationByteBufferStream(null); + private final DirectByteBufferStream stream = new DirectByteBufferStream(null); /** Handshake bytes. */ private byte[] bytes; @@ -95,7 +95,7 @@ public byte[] bytes() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridClientHandshakeRequestWrapper _clone = new GridClientHandshakeRequestWrapper(); clone0(_clone); @@ -104,7 +104,7 @@ public byte[] bytes() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { GridClientHandshakeRequestWrapper _clone = (GridClientHandshakeRequestWrapper)_msg; _clone.bytes = bytes; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java index 7ce67b4784901..57f2bd163a752 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java @@ -17,15 +17,15 @@ package org.apache.ignite.internal.processors.rest.client.message; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.nio.*; /** * Client handshake wrapper for direct marshalling. */ -public class GridClientHandshakeResponseWrapper extends GridTcpCommunicationMessageAdapter { +public class GridClientHandshakeResponseWrapper extends MessageAdapter { /** */ private static final long serialVersionUID = -1529807975073967381L; @@ -72,7 +72,7 @@ public GridClientHandshakeResponseWrapper(byte code) { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridClientHandshakeResponseWrapper _clone = new GridClientHandshakeResponseWrapper(); clone0(_clone); @@ -81,7 +81,7 @@ public GridClientHandshakeResponseWrapper(byte code) { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { GridClientHandshakeResponseWrapper _clone = (GridClientHandshakeResponseWrapper)_msg; _clone.code = code; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMessageWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMessageWrapper.java index fe3246833657d..4d40c3ed8ae1f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMessageWrapper.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMessageWrapper.java @@ -17,9 +17,9 @@ package org.apache.ignite.internal.processors.rest.client.message; -import org.apache.ignite.internal.util.direct.*; +import org.apache.ignite.internal.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; -import org.gridgain.grid.util.direct.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.nio.*; import java.util.*; @@ -27,7 +27,7 @@ /** * Client message wrapper for direct marshalling. */ -public class GridClientMessageWrapper extends GridTcpCommunicationMessageAdapter { +public class GridClientMessageWrapper extends MessageAdapter { /** */ private static final long serialVersionUID = 5284375300887454697L; @@ -35,7 +35,7 @@ public class GridClientMessageWrapper extends GridTcpCommunicationMessageAdapter public static final byte REQ_HEADER = (byte)0x90; /** Stream. */ - private final GridTcpCommunicationByteBufferStream stream = new GridTcpCommunicationByteBufferStream(null); + private final DirectByteBufferStream stream = new DirectByteBufferStream(null); /** */ private int msgSize; @@ -249,7 +249,7 @@ public void message(ByteBuffer msg) { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridClientMessageWrapper _clone = new GridClientMessageWrapper(); clone0(_clone); @@ -258,7 +258,7 @@ public void message(ByteBuffer msg) { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { GridClientMessageWrapper _clone = (GridClientMessageWrapper)_msg; _clone.reqId = reqId; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacketWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacketWrapper.java index 6591bd102489f..be953672259e8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacketWrapper.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacketWrapper.java @@ -17,15 +17,15 @@ package org.apache.ignite.internal.processors.rest.client.message; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.nio.*; /** * Ping packet wrapper for direct marshalling. */ -public class GridClientPingPacketWrapper extends GridTcpCommunicationMessageAdapter { +public class GridClientPingPacketWrapper extends MessageAdapter { /** */ private static final long serialVersionUID = -3956036611004055629L; @@ -67,7 +67,7 @@ public class GridClientPingPacketWrapper extends GridTcpCommunicationMessageAdap /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridClientPingPacketWrapper _clone = new GridClientPingPacketWrapper(); clone0(_clone); @@ -76,7 +76,7 @@ public class GridClientPingPacketWrapper extends GridTcpCommunicationMessageAdap } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { GridClientPingPacketWrapper _clone = (GridClientPingPacketWrapper)_msg; _clone.size = size; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultRequest.java index e78c5fedc0873..8df3008fd3ccd 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultRequest.java @@ -18,8 +18,8 @@ package org.apache.ignite.internal.processors.rest.handlers.task; import org.apache.ignite.internal.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -27,7 +27,7 @@ /** * Task result request. */ -public class GridTaskResultRequest extends GridTcpCommunicationMessageAdapter { +public class GridTaskResultRequest extends MessageAdapter { /** */ private static final long serialVersionUID = 0L; @@ -100,7 +100,7 @@ public void topic(String topic) { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridTaskResultRequest _clone = new GridTaskResultRequest(); clone0(_clone); @@ -109,7 +109,7 @@ public void topic(String topic) { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { GridTaskResultRequest _clone = (GridTaskResultRequest)_msg; _clone.taskId = taskId; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java index caa42ddfa568f..6808f1adeb6be 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java @@ -18,7 +18,7 @@ package org.apache.ignite.internal.processors.rest.handlers.task; import org.apache.ignite.internal.*; -import org.apache.ignite.internal.util.direct.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.nio.*; @@ -26,7 +26,7 @@ /** * Task result response. */ -public class GridTaskResultResponse extends GridTcpCommunicationMessageAdapter { +public class GridTaskResultResponse extends MessageAdapter { /** */ private static final long serialVersionUID = 0L; @@ -118,7 +118,7 @@ public void error(String err) { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridTaskResultResponse _clone = new GridTaskResultResponse(); clone0(_clone); @@ -127,7 +127,7 @@ public void error(String err) { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { GridTaskResultResponse _clone = (GridTaskResultResponse)_msg; _clone.res = res; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java index 2d0d82fc7c69d..ae0d6385528dc 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java @@ -18,11 +18,11 @@ package org.apache.ignite.internal.processors.rest.protocols.tcp; import org.apache.ignite.*; +import org.apache.ignite.internal.direct.*; import org.apache.ignite.internal.util.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.marshaller.*; -import org.gridgain.grid.util.direct.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -34,7 +34,7 @@ /** * Memcached message wrapper for direct marshalling. */ -public class GridMemcachedMessageWrapper extends GridTcpCommunicationMessageAdapter { +public class GridMemcachedMessageWrapper extends MessageAdapter { /** */ private static final long serialVersionUID = 3053626103006980626L; @@ -42,7 +42,7 @@ public class GridMemcachedMessageWrapper extends GridTcpCommunicationMessageAdap private static final Charset UTF_8 = Charset.forName("UTF-8"); /** Stream. */ - private final GridTcpCommunicationByteBufferStream stream = new GridTcpCommunicationByteBufferStream(null); + private final DirectByteBufferStream stream = new DirectByteBufferStream(null); /** * Memcached message bytes. @@ -95,7 +95,7 @@ public GridMemcachedMessageWrapper(GridMemcachedMessage msg, Marshaller jdkMarsh /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridMemcachedMessageWrapper _clone = new GridMemcachedMessageWrapper(); clone0(_clone); @@ -104,7 +104,7 @@ public GridMemcachedMessageWrapper(GridMemcachedMessage msg, Marshaller jdkMarsh } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { GridMemcachedMessageWrapper _clone = (GridMemcachedMessageWrapper)_msg; _clone.bytes = bytes; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestDirectParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestDirectParser.java index 1fc7a0d8d45d7..b743e66c275bc 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestDirectParser.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestDirectParser.java @@ -19,12 +19,11 @@ import org.apache.ignite.*; import org.apache.ignite.client.marshaller.*; +import org.apache.ignite.internal.direct.*; import org.apache.ignite.internal.processors.rest.client.message.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.nio.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.plugin.extensions.communication.*; -import org.gridgain.grid.util.direct.*; import org.jetbrains.annotations.*; import java.io.*; @@ -46,7 +45,7 @@ public class GridTcpRestDirectParser implements GridNioParser { private static final int MSG_META_KEY = GridNioSessionMetaKey.nextUniqueKey(); /** Message reader. */ - private final MessageReader rdr = new GridTcpCommunicationMessageReader(null); + private final MessageReader rdr = new DirectMessageReader(null); /** Protocol handler. */ private final GridTcpRestProtocol proto; @@ -74,7 +73,7 @@ public GridTcpRestDirectParser(GridTcpRestProtocol proto) { return memcacheMsg; } - GridTcpCommunicationMessageAdapter msg = ses.removeMeta(MSG_META_KEY); + MessageAdapter msg = ses.removeMeta(MSG_META_KEY); if (msg == null && buf.hasRemaining()) { byte type = buf.get(buf.position()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerCancelRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerCancelRequest.java index e256dd0a218cc..aba17f31c6ef2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerCancelRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerCancelRequest.java @@ -17,8 +17,8 @@ package org.apache.ignite.internal.processors.streamer; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -26,7 +26,7 @@ /** * Streamer cancel request. */ -public class GridStreamerCancelRequest extends GridTcpCommunicationMessageAdapter { +public class GridStreamerCancelRequest extends MessageAdapter { /** */ private static final long serialVersionUID = 0L; @@ -56,7 +56,7 @@ public IgniteUuid cancelledFutureId() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridStreamerCancelRequest _clone = new GridStreamerCancelRequest(); clone0(_clone); @@ -65,7 +65,7 @@ public IgniteUuid cancelledFutureId() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { GridStreamerCancelRequest _clone = (GridStreamerCancelRequest)_msg; _clone.cancelledFutId = cancelledFutId; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerExecutionRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerExecutionRequest.java index d81b46d3202b1..e10ef047d0478 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerExecutionRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerExecutionRequest.java @@ -19,10 +19,10 @@ import org.apache.ignite.configuration.*; import org.apache.ignite.internal.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.nio.*; @@ -31,7 +31,7 @@ /** * */ -public class GridStreamerExecutionRequest extends GridTcpCommunicationMessageAdapter { +public class GridStreamerExecutionRequest extends MessageAdapter { /** */ private static final long serialVersionUID = 0L; @@ -151,7 +151,7 @@ public byte[] batchBytes() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridStreamerExecutionRequest _clone = new GridStreamerExecutionRequest(); clone0(_clone); @@ -160,7 +160,7 @@ public byte[] batchBytes() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { GridStreamerExecutionRequest _clone = (GridStreamerExecutionRequest)_msg; _clone.forceLocDep = forceLocDep; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerResponse.java index 9b1ef21e8dd1c..a9c05c55ba571 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerResponse.java @@ -17,9 +17,9 @@ package org.apache.ignite.internal.processors.streamer; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.nio.*; @@ -27,7 +27,7 @@ /** * */ -public class GridStreamerResponse extends GridTcpCommunicationMessageAdapter { +public class GridStreamerResponse extends MessageAdapter { /** */ private static final long serialVersionUID = 0L; @@ -76,7 +76,7 @@ public byte[] errorBytes() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridStreamerResponse _clone = new GridStreamerResponse(); clone0(_clone); @@ -85,7 +85,7 @@ public byte[] errorBytes() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { GridStreamerResponse _clone = (GridStreamerResponse)_msg; _clone.futId = futId; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/IgniteStreamerImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/IgniteStreamerImpl.java index 0af18a1906cbb..7ca3f9b5f4c37 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/IgniteStreamerImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/IgniteStreamerImpl.java @@ -25,7 +25,6 @@ import org.apache.ignite.internal.managers.deployment.*; import org.apache.ignite.internal.managers.eventstorage.*; import org.apache.ignite.internal.util.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.future.*; import org.apache.ignite.internal.util.lang.*; import org.apache.ignite.internal.util.tostring.*; @@ -33,6 +32,7 @@ import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.internal.util.worker.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.streamer.*; import org.apache.ignite.streamer.router.*; import org.apache.ignite.thread.*; @@ -1037,7 +1037,7 @@ private void unwindUndeploys(ClassLoader undeployedClsLdr, boolean info) { * @return Execution request. * @throws IgniteCheckedException If failed. */ - private GridTcpCommunicationMessageAdapter createExecutionRequest(GridStreamerExecutionBatch batch) + private MessageAdapter createExecutionRequest(GridStreamerExecutionBatch batch) throws IgniteCheckedException { boolean depEnabled = ctx.deploy().enabled(); @@ -1111,7 +1111,7 @@ private GridStreamerExecutionBatch executionBatch(UUID nodeId, GridStreamerExecu * @param msg Message to send. * @throws IgniteCheckedException If failed. */ - private void sendWithRetries(UUID dstNodeId, GridTcpCommunicationMessageAdapter msg) throws IgniteCheckedException { + private void sendWithRetries(UUID dstNodeId, MessageAdapter msg) throws IgniteCheckedException { for (int i = 0; i < SEND_RETRY_COUNT; i++) { try { ctx.io().send(dstNodeId, topic, msg, GridIoPolicy.SYSTEM_POOL); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/version/GridVersionConverter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/version/GridVersionConverter.java index ef7a4df29419f..9895f431eb5e6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/version/GridVersionConverter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/version/GridVersionConverter.java @@ -17,7 +17,7 @@ package org.apache.ignite.internal.processors.version; -import org.apache.ignite.internal.util.direct.*; +import org.apache.ignite.internal.direct.*; import java.nio.*; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java index f4b7ca3b25e57..a35a357c631c7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java @@ -31,12 +31,11 @@ import org.apache.ignite.internal.mxbean.*; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.version.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.lang.*; import org.apache.ignite.lifecycle.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.portables.*; import org.apache.ignite.spi.*; -import org.apache.ignite.internal.managers.deployment.*; import org.apache.ignite.internal.processors.streamer.*; import org.apache.ignite.internal.transactions.*; import org.apache.ignite.internal.util.io.*; @@ -44,10 +43,6 @@ import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.internal.util.worker.*; -import org.apache.ignite.lang.*; -import org.apache.ignite.lifecycle.*; -import org.apache.ignite.portables.*; -import org.apache.ignite.spi.*; import org.apache.ignite.spi.discovery.*; import org.apache.ignite.transactions.*; import org.jdk8.backport.*; @@ -9231,12 +9226,11 @@ public static String calculateMD5(InputStream in) throws NoSuchAlgorithmExceptio * * @param msg Message. * @param out Stream to write to. - * @param buf Byte buffer that will be passed to {@link GridTcpCommunicationMessageAdapter#writeTo(ByteBuffer)} - * method. + * @param buf Byte buffer that will be passed to {@link MessageAdapter#writeTo(ByteBuffer)} method. * @return Number of written bytes. * @throws IOException In case of error. */ - public static int writeMessageFully(GridTcpCommunicationMessageAdapter msg, OutputStream out, ByteBuffer buf) + public static int writeMessageFully(MessageAdapter msg, OutputStream out, ByteBuffer buf) throws IOException { assert msg != null; assert out != null; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/IpcToNioAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/IpcToNioAdapter.java index 043e2bb4b039a..1e9d98d4ba9b2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/IpcToNioAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/IpcToNioAdapter.java @@ -18,9 +18,9 @@ package org.apache.ignite.internal.util.ipc; import org.apache.ignite.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.nio.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -143,7 +143,7 @@ else if (read < 0) { * @param msg Buffer to send. * @return Send result. */ - private GridNioFuture send(GridTcpCommunicationMessageAdapter msg) { + private GridNioFuture send(MessageAdapter msg) { assert writeBuf.hasArray(); try { @@ -188,7 +188,7 @@ protected HeadFilter() { @Override public GridNioFuture onSessionWrite(GridNioSession ses, Object msg) { assert ses == IpcToNioAdapter.this.ses; - return send((GridTcpCommunicationMessageAdapter)msg); + return send((MessageAdapter)msg); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridCommunicationClient.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridCommunicationClient.java index e8ddb7d0d997d..6084e09f78c3a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridCommunicationClient.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridCommunicationClient.java @@ -18,8 +18,8 @@ package org.apache.ignite.internal.util.nio; import org.apache.ignite.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.io.*; @@ -97,7 +97,7 @@ public interface GridCommunicationClient { * @throws IgniteCheckedException If failed. * @return {@code True} if should try to resend message. */ - boolean sendMessage(@Nullable UUID nodeId, GridTcpCommunicationMessageAdapter msg) throws IgniteCheckedException; + boolean sendMessage(@Nullable UUID nodeId, MessageAdapter msg) throws IgniteCheckedException; /** * @param timeout Timeout. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java index b87236ce7f139..00719426ea8ce 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java @@ -18,7 +18,8 @@ package org.apache.ignite.internal.util.nio; import org.apache.ignite.*; -import org.apache.ignite.internal.util.direct.*; +import org.apache.ignite.internal.direct.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.spi.*; import org.jetbrains.annotations.*; @@ -50,7 +51,7 @@ public GridDirectParser(IgniteSpiAdapter spi) { if (msgFactory == null) msgFactory = spi.getSpiContext().messageFactory(); - GridTcpCommunicationMessageAdapter msg = ses.removeMeta(MSG_META_KEY); + MessageAdapter msg = ses.removeMeta(MSG_META_KEY); if (msg == null && buf.hasRemaining()) msg = msgFactory.create(buf.get()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioMessageReader.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioMessageReader.java index c4c3bb4da2b4e..17249fafb9d18 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioMessageReader.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioMessageReader.java @@ -17,7 +17,8 @@ package org.apache.ignite.internal.util.nio; -import org.apache.ignite.internal.util.direct.*; +import org.apache.ignite.internal.direct.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.nio.*; @@ -33,7 +34,7 @@ public interface GridNioMessageReader { * @param buf Buffer. * @return Whether message was fully read. */ - public boolean read(@Nullable UUID nodeId, GridTcpCommunicationMessageAdapter msg, ByteBuffer buf); + public boolean read(@Nullable UUID nodeId, MessageAdapter msg, ByteBuffer buf); /** * @return Optional message factory. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioMessageWriter.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioMessageWriter.java index 38ce18c81eac3..e517b3c95f0db 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioMessageWriter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioMessageWriter.java @@ -17,7 +17,7 @@ package org.apache.ignite.internal.util.nio; -import org.apache.ignite.internal.util.direct.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.io.*; @@ -34,7 +34,7 @@ public interface GridNioMessageWriter { * @param buf Buffer. * @return Whether message was fully written. */ - public boolean write(@Nullable UUID nodeId, GridTcpCommunicationMessageAdapter msg, ByteBuffer buf); + public boolean write(@Nullable UUID nodeId, MessageAdapter msg, ByteBuffer buf); /** * @param nodeId Node ID. @@ -44,6 +44,6 @@ public interface GridNioMessageWriter { * @return Number of bytes written. * @throws IOException In case of error. */ - public int writeFully(@Nullable UUID nodeId, GridTcpCommunicationMessageAdapter msg, OutputStream out, + public int writeFully(@Nullable UUID nodeId, MessageAdapter msg, OutputStream out, ByteBuffer buf) throws IOException; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java index 2438e1481d926..9ec25f6d61c25 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java @@ -21,13 +21,13 @@ import org.apache.ignite.configuration.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.util.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.nio.ssl.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.internal.util.worker.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.thread.*; import org.jdk8.backport.*; import org.jetbrains.annotations.*; @@ -339,7 +339,7 @@ GridNioFuture send(GridNioSession ses, ByteBuffer msg) { * @param msg Message. * @return Future for operation. */ - GridNioFuture send(GridNioSession ses, GridTcpCommunicationMessageAdapter msg) { + GridNioFuture send(GridNioSession ses, MessageAdapter msg) { assert ses instanceof GridSelectorNioSessionImpl; GridSelectorNioSessionImpl impl = (GridSelectorNioSessionImpl)ses; @@ -378,7 +378,7 @@ else if (msgCnt == 1) * @param msg Message. * @return Future. */ - public GridNioFuture sendSystem(GridNioSession ses, GridTcpCommunicationMessageAdapter msg) { + public GridNioFuture sendSystem(GridNioSession ses, MessageAdapter msg) { return sendSystem(ses, msg, null); } @@ -391,7 +391,7 @@ public GridNioFuture sendSystem(GridNioSession ses, GridTcpCommunicationMessa * @return Future. */ public GridNioFuture sendSystem(GridNioSession ses, - GridTcpCommunicationMessageAdapter msg, + MessageAdapter msg, @Nullable IgniteInClosure> lsnr) { assert ses instanceof GridSelectorNioSessionImpl; @@ -868,7 +868,7 @@ private void processWriteSsl(SelectionKey key) throws IOException { } } - GridTcpCommunicationMessageAdapter msg; + MessageAdapter msg; boolean finished = false; if (req != null) { @@ -1005,7 +1005,7 @@ private void processWrite0(SelectionKey key) throws IOException { } } - GridTcpCommunicationMessageAdapter msg; + MessageAdapter msg; boolean finished = false; if (req != null) { @@ -1744,7 +1744,7 @@ private static class NioOperationFuture extends GridNioFutureImpl { private ByteBuffer msg; /** Direct message. */ - private GridTcpCommunicationMessageAdapter commMsg; + private MessageAdapter commMsg; /** */ private boolean accepted; @@ -1820,7 +1820,7 @@ private static class NioOperationFuture extends GridNioFutureImpl { * @param commMsg Direct message. */ NioOperationFuture(GridSelectorNioSessionImpl ses, NioOperation op, - GridTcpCommunicationMessageAdapter commMsg) { + MessageAdapter commMsg) { assert ses != null; assert op != null; assert op != NioOperation.REGISTER; @@ -1848,7 +1848,7 @@ private ByteBuffer message() { /** * @return Direct message. */ - private GridTcpCommunicationMessageAdapter directMessage() { + private MessageAdapter directMessage() { return commMsg; } @@ -1959,7 +1959,7 @@ protected HeadFilter() { return null; } else - return send(ses, (GridTcpCommunicationMessageAdapter)msg); + return send(ses, (MessageAdapter)msg); } else return send(ses, (ByteBuffer)msg); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridShmemCommunicationClient.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridShmemCommunicationClient.java index c7bc5709044e7..5413f4a1a3fc3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridShmemCommunicationClient.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridShmemCommunicationClient.java @@ -18,10 +18,10 @@ package org.apache.ignite.internal.util.nio; import org.apache.ignite.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.ipc.shmem.*; import org.apache.ignite.internal.util.lang.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.io.*; @@ -102,7 +102,7 @@ public GridShmemCommunicationClient(GridNioMetricsListener metricsLsnr, int port } /** {@inheritDoc} */ - @Override public synchronized boolean sendMessage(@Nullable UUID nodeId, GridTcpCommunicationMessageAdapter msg) + @Override public synchronized boolean sendMessage(@Nullable UUID nodeId, MessageAdapter msg) throws IgniteCheckedException { if (closed()) throw new IgniteCheckedException("Communication client was closed: " + this); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridTcpCommunicationClient.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridTcpCommunicationClient.java index a6d09075eb4a1..6b36f880b5759 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridTcpCommunicationClient.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridTcpCommunicationClient.java @@ -18,9 +18,9 @@ package org.apache.ignite.internal.util.nio; import org.apache.ignite.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.lang.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.io.*; @@ -183,7 +183,7 @@ public GridTcpCommunicationClient( } /** {@inheritDoc} */ - @Override public boolean sendMessage(@Nullable UUID nodeId, GridTcpCommunicationMessageAdapter msg) + @Override public boolean sendMessage(@Nullable UUID nodeId, MessageAdapter msg) throws IgniteCheckedException { if (closed()) throw new IgniteCheckedException("Client was closed: " + this); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridTcpNioCommunicationClient.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridTcpNioCommunicationClient.java index 2b71d61aa3ea8..46d0646b44958 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridTcpNioCommunicationClient.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridTcpNioCommunicationClient.java @@ -18,9 +18,9 @@ package org.apache.ignite.internal.util.nio; import org.apache.ignite.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.lang.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.io.*; @@ -103,7 +103,7 @@ public GridNioSession session() { } /** {@inheritDoc} */ - @Override public boolean sendMessage(@Nullable UUID nodeId, GridTcpCommunicationMessageAdapter msg) + @Override public boolean sendMessage(@Nullable UUID nodeId, MessageAdapter msg) throws IgniteCheckedException { // Node ID is never provided in asynchronous send mode. assert nodeId == null; diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/PluginContext.java b/modules/core/src/main/java/org/apache/ignite/plugin/PluginContext.java index ee90976e1af7c..a59d7abbc48a5 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/PluginContext.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/PluginContext.java @@ -20,7 +20,7 @@ import org.apache.ignite.*; import org.apache.ignite.cluster.*; import org.apache.ignite.configuration.*; -import org.apache.ignite.internal.util.direct.*; +import org.apache.ignite.internal.direct.*; import org.apache.ignite.spi.*; import java.util.*; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageAdapter.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageAdapter.java similarity index 77% rename from modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageAdapter.java rename to modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageAdapter.java index e414f55cb1cf8..89d26fc52ddd5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/direct/GridTcpCommunicationMessageAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageAdapter.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.ignite.internal.util.direct; +package org.apache.ignite.plugin.extensions.communication; -import org.apache.ignite.plugin.extensions.communication.*; +import org.apache.ignite.internal.direct.*; import java.io.*; import java.nio.*; @@ -26,32 +26,46 @@ /** * Communication message adapter. */ -public abstract class GridTcpCommunicationMessageAdapter implements Serializable, Cloneable { - /** */ - private static final long serialVersionUID = 0L; - +public abstract class MessageAdapter implements Serializable, Cloneable { /** */ + // TODO: remove protected static final Object NULL = new Object(); /** */ + // TODO: remove protected final GridTcpCommunicationMessageState commState = new GridTcpCommunicationMessageState(); + /** Writer. */ + protected MessageWriter writer; + + /** Reader. */ + protected MessageReader reader; + /** * @param writer Writer. */ public final void setWriter(MessageWriter writer) { - assert writer != null; - - commState.setWriter(writer); + if (this.writer == null) + this.writer = writer; } /** * @param reader Reader. */ public final void setReader(MessageReader reader) { - assert reader != null; + if (this.reader == null) + this.reader = reader; + } + + /** + * @param buf Buffer. + */ + public final void setBuffer(ByteBuffer buf) { + if (writer != null) + writer.setBuffer(buf); - commState.setReader(reader); + if (reader != null) + reader.setBuffer(buf); } /** @@ -73,14 +87,14 @@ public final void setReader(MessageReader reader) { /** {@inheritDoc} */ @SuppressWarnings("CloneDoesntDeclareCloneNotSupportedException") - @Override public abstract GridTcpCommunicationMessageAdapter clone(); + @Override public abstract MessageAdapter clone(); /** * Clones all fields of the provided message to {@code this}. * * @param _msg Message to clone from. */ - protected abstract void clone0(GridTcpCommunicationMessageAdapter _msg); + protected abstract void clone0(MessageAdapter _msg); /** * @return {@code True} if should skip recovery for this message. diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java index 1431738f05c4f..d09f00c13e31d 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java @@ -9,15 +9,13 @@ package org.apache.ignite.plugin.extensions.communication; -import org.apache.ignite.internal.util.direct.*; -import org.apache.ignite.plugin.*; - import java.nio.*; +import java.util.*; /** * TODO */ -public interface MessageReader extends IgniteExtension { +public interface MessageReader { public void setBuffer(ByteBuffer buf); public byte readByte(String name); @@ -52,7 +50,11 @@ public interface MessageReader extends IgniteExtension { public boolean[] readBooleanArray(String name); - public GridTcpCommunicationMessageAdapter readMessage(String name); + public MessageAdapter readMessage(String name); + + public Collection readCollection(String name, Class itemCls); + + public Map readMap(String name, Class keyCls, Class valCls); public boolean isLastRead(); } diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReaderFactory.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReaderFactory.java index 51e51a95aba50..70dc3dcecbf13 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReaderFactory.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReaderFactory.java @@ -9,9 +9,11 @@ package org.apache.ignite.plugin.extensions.communication; +import org.apache.ignite.plugin.*; + /** * TODO */ -public interface MessageReaderFactory { +public interface MessageReaderFactory extends IgniteExtension { public MessageReader reader(); } diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java index 125c84cb54bca..5f7ddf9163abf 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java @@ -9,15 +9,13 @@ package org.apache.ignite.plugin.extensions.communication; -import org.apache.ignite.internal.util.direct.*; -import org.apache.ignite.plugin.*; - import java.nio.*; +import java.util.*; /** * TODO */ -public interface MessageWriter extends IgniteExtension { +public interface MessageWriter { public void setBuffer(ByteBuffer buf); public boolean writeByte(String name, byte val); @@ -52,5 +50,9 @@ public interface MessageWriter extends IgniteExtension { public boolean writeBooleanArray(String name, boolean[] val); - public boolean writeMessage(String name, GridTcpCommunicationMessageAdapter val); + public boolean writeMessage(String name, MessageAdapter val); + + public boolean writeCollection(String name, Collection col, Class itemCls); + + public boolean writeMap(String name, Map map, Class keyCls, Class valCls); } diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriterFactory.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriterFactory.java index 613f312a034cb..47b5a34f26706 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriterFactory.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriterFactory.java @@ -9,9 +9,11 @@ package org.apache.ignite.plugin.extensions.communication; +import org.apache.ignite.plugin.*; + /** * TODO */ -public interface MessageWriterFactory { +public interface MessageWriterFactory extends IgniteExtension { public MessageWriter writer(); } diff --git a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java index 27fbb75754f0f..21f75a876386f 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java @@ -21,7 +21,7 @@ import org.apache.ignite.cluster.*; import org.apache.ignite.events.*; import org.apache.ignite.internal.*; -import org.apache.ignite.internal.util.direct.*; +import org.apache.ignite.internal.direct.*; import org.apache.ignite.resources.*; import org.apache.ignite.spi.authentication.*; import org.apache.ignite.internal.managers.communication.*; diff --git a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiContext.java b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiContext.java index b030a2daca014..06004c5ef1981 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiContext.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiContext.java @@ -20,9 +20,9 @@ import org.apache.ignite.*; import org.apache.ignite.cluster.*; import org.apache.ignite.events.*; +import org.apache.ignite.internal.direct.*; import org.apache.ignite.internal.managers.communication.*; import org.apache.ignite.internal.managers.eventstorage.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.plugin.security.*; import org.apache.ignite.spi.swapspace.*; import org.jetbrains.annotations.*; diff --git a/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java b/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java index 0653dcd9b63ec..d468c281a8736 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java @@ -17,8 +17,8 @@ package org.apache.ignite.spi.collision.jobstealing; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -26,7 +26,7 @@ /** * Job stealing request. */ -public class JobStealingRequest extends GridTcpCommunicationMessageAdapter { +public class JobStealingRequest extends MessageAdapter { /** */ private static final long serialVersionUID = 0L; @@ -56,7 +56,7 @@ int delta() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { JobStealingRequest _clone = new JobStealingRequest(); clone0(_clone); @@ -65,7 +65,7 @@ int delta() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { JobStealingRequest _clone = (JobStealingRequest)_msg; _clone.delta = delta; diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java index 3ca4d4b34256c..4db4ef8e411b2 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java @@ -24,13 +24,12 @@ import org.apache.ignite.internal.*; import org.apache.ignite.internal.util.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.resources.*; import org.apache.ignite.spi.*; import org.apache.ignite.spi.communication.*; import org.apache.ignite.thread.*; import org.apache.ignite.internal.managers.eventstorage.*; -import org.apache.ignite.internal.util.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.future.*; import org.apache.ignite.internal.util.ipc.*; import org.apache.ignite.internal.util.ipc.shmem.*; @@ -39,11 +38,6 @@ import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.internal.util.worker.*; -import org.apache.ignite.lang.*; -import org.apache.ignite.resources.*; -import org.apache.ignite.spi.*; -import org.apache.ignite.spi.communication.*; -import org.apache.ignite.thread.*; import org.jdk8.backport.*; import org.jetbrains.annotations.*; @@ -150,7 +144,7 @@ @IgniteSpiMultipleInstancesSupport(true) @IgniteSpiConsistencyChecked(optional = false) public class TcpCommunicationSpi extends IgniteSpiAdapter - implements CommunicationSpi, TcpCommunicationSpiMBean { + implements CommunicationSpi, TcpCommunicationSpiMBean { /** IPC error message. */ public static final String OUT_OF_RESOURCES_TCP_MSG = "Failed to allocate shared memory segment " + "(switching to TCP, may be slower). For troubleshooting see " + @@ -245,8 +239,8 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter public static final byte HANDSHAKE_MSG_TYPE = -3; /** Server listener. */ - private final GridNioServerListener srvLsnr = - new GridNioServerListenerAdapter() { + private final GridNioServerListener srvLsnr = + new GridNioServerListenerAdapter() { @Override public void onSessionWriteTimeout(GridNioSession ses) { LT.warn(log, null, "Communication SPI Session write timed out (consider increasing " + "'socketWriteTimeout' " + "configuration property) [remoteAddr=" + ses.remoteAddress() + @@ -298,14 +292,14 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter } } - CommunicationListener lsnr0 = lsnr; + CommunicationListener lsnr0 = lsnr; if (lsnr0 != null) lsnr0.onDisconnected(id); } } - @Override public void onMessage(GridNioSession ses, GridTcpCommunicationMessageAdapter msg) { + @Override public void onMessage(GridNioSession ses, MessageAdapter msg) { UUID sndId = ses.meta(NODE_ID_META); if (sndId == null) { @@ -685,7 +679,7 @@ class ConnectClosure implements IgniteInClosure { private double bufSizeRatio = IgniteSystemProperties.getDouble(IGNITE_COMMUNICATION_BUF_RESIZE_RATIO, 0.8); /** NIO server. */ - private GridNioServer nioSrvr; + private GridNioServer nioSrvr; /** Shared memory server. */ private IpcSharedMemoryServerEndpoint shmemSrv; @@ -724,7 +718,7 @@ class ConnectClosure implements IgniteInClosure { private final ConcurrentMap clients = GridConcurrentFactory.newMap(); /** SPI listener. */ - private volatile CommunicationListener lsnr; + private volatile CommunicationListener lsnr; /** Bound port. */ private int boundTcpPort = -1; @@ -1233,7 +1227,7 @@ public void setBufferSizeRatio(double bufSizeRatio) { } /** {@inheritDoc} */ - @Override public void setListener(CommunicationListener lsnr) { + @Override public void setListener(CommunicationListener lsnr) { this.lsnr = lsnr; } @@ -1467,7 +1461,7 @@ public CommunicationListener getListener() { * @return Server instance. * @throws IgniteCheckedException Thrown if it's not possible to create server. */ - private GridNioServer resetNioServer() throws IgniteCheckedException { + private GridNioServer resetNioServer() throws IgniteCheckedException { if (boundTcpPort >= 0) throw new IgniteCheckedException("Tcp NIO server was already created on port " + boundTcpPort); @@ -1476,8 +1470,8 @@ private GridNioServer resetNioServer() throw // If configured TCP port is busy, find first available in range. for (int port = locPort; port < locPort + locPortRange; port++) { try { - GridNioServer srvr = - GridNioServer.builder() + GridNioServer srvr = + GridNioServer.builder() .address(locHost) .port(port) .listener(srvLsnr) @@ -1673,7 +1667,7 @@ private void checkAttributePresence(ClusterNode node, String attrName) { } /** {@inheritDoc} */ - @Override public void sendMessage(ClusterNode node, GridTcpCommunicationMessageAdapter msg) throws IgniteSpiException { + @Override public void sendMessage(ClusterNode node, MessageAdapter msg) throws IgniteSpiException { assert node != null; assert msg != null; @@ -2255,8 +2249,8 @@ else if (log.isDebugEnabled()) * @param msg Communication message. * @param msgC Closure to call when message processing finished. */ - protected void notifyListener(UUID sndId, GridTcpCommunicationMessageAdapter msg, IgniteRunnable msgC) { - CommunicationListener lsnr = this.lsnr; + protected void notifyListener(UUID sndId, MessageAdapter msg, IgniteRunnable msgC) { + CommunicationListener lsnr = this.lsnr; if (lsnr != null) // Notify listener of a new message. @@ -2420,7 +2414,7 @@ private ShmemWorker(IpcEndpoint endpoint) { /** {@inheritDoc} */ @Override protected void body() throws InterruptedException { try { - IpcToNioAdapter adapter = new IpcToNioAdapter<>( + IpcToNioAdapter adapter = new IpcToNioAdapter<>( metricsLsnr, log, endpoint, @@ -2944,7 +2938,7 @@ else if (log.isDebugEnabled()) * Handshake message. */ @SuppressWarnings("PublicInnerClass") - public static class HandshakeMessage extends GridTcpCommunicationMessageAdapter { + public static class HandshakeMessage extends MessageAdapter { /** */ private static final long serialVersionUID = 0L; @@ -2958,7 +2952,7 @@ public static class HandshakeMessage extends GridTcpCommunicationMessageAdapter private long connectCnt; /** - * Default constructor required by {@link GridTcpCommunicationMessageAdapter}. + * Default constructor required by {@link MessageAdapter}. */ public HandshakeMessage() { // No-op. @@ -3044,12 +3038,12 @@ public UUID nodeId() { /** {@inheritDoc} */ @SuppressWarnings("CloneDoesntCallSuperClone") - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { throw new UnsupportedOperationException(); } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter msg) { + @Override protected void clone0(MessageAdapter msg) { // No-op. } @@ -3063,7 +3057,7 @@ public UUID nodeId() { * Recovery acknowledgment message. */ @SuppressWarnings("PublicInnerClass") - public static class RecoveryLastReceivedMessage extends GridTcpCommunicationMessageAdapter { + public static class RecoveryLastReceivedMessage extends MessageAdapter { /** */ private static final long serialVersionUID = 0L; @@ -3071,7 +3065,7 @@ public static class RecoveryLastReceivedMessage extends GridTcpCommunicationMess private long rcvCnt; /** - * Default constructor required by {@link GridTcpCommunicationMessageAdapter}. + * Default constructor required by {@link MessageAdapter}. */ public RecoveryLastReceivedMessage() { // No-op. @@ -3120,12 +3114,12 @@ public long received() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { throw new UnsupportedOperationException(); } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter msg) { + @Override protected void clone0(MessageAdapter msg) { // No-op. } @@ -3144,7 +3138,7 @@ public long received() { * Node ID message. */ @SuppressWarnings("PublicInnerClass") - public static class NodeIdMessage extends GridTcpCommunicationMessageAdapter { + public static class NodeIdMessage extends MessageAdapter { /** */ private static final long serialVersionUID = 0L; @@ -3204,12 +3198,12 @@ private NodeIdMessage(UUID nodeId) { /** {@inheritDoc} */ @SuppressWarnings("CloneDoesntCallSuperClone") - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { throw new UnsupportedOperationException(); } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { // No-op. } diff --git a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageWriter.java b/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageWriter.java deleted file mode 100644 index 82ad4f81c33ea..0000000000000 --- a/modules/core/src/main/java/org/gridgain/grid/util/direct/GridTcpCommunicationMessageWriter.java +++ /dev/null @@ -1,262 +0,0 @@ -/* @java.file.header */ - -/* _________ _____ __________________ _____ - * __ ____/___________(_)______ /__ ____/______ ____(_)_______ - * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ - * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / - * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ - */ - -package org.gridgain.grid.util.direct; - -import org.apache.ignite.internal.util.direct.*; -import org.apache.ignite.plugin.extensions.communication.*; -import org.jetbrains.annotations.*; - -import java.nio.*; - -/** - * Portable writer implementation. - */ -public class GridTcpCommunicationMessageWriter implements MessageWriter { - /** Stream. */ - private final GridTcpCommunicationByteBufferStream stream = new GridTcpCommunicationByteBufferStream(null); - - /** {@inheritDoc} */ - @Override public void setBuffer(ByteBuffer buf) { - stream.setBuffer(buf); - } - - /** {@inheritDoc} */ - @Override public boolean writeByte(String name, byte val) { - if (stream.remaining() < 1) - return false; - - stream.writeByte(val); - - return true; - } - - /** {@inheritDoc} */ - @Override public boolean writeShort(String name, short val) { - if (stream.remaining() < 2) - return false; - - stream.writeShort(val); - - return true; - } - - /** {@inheritDoc} */ - @Override public boolean writeInt(String name, int val) { - if (stream.remaining() < 4) - return false; - - stream.writeInt(val); - - return true; - } - - /** {@inheritDoc} */ - @Override public boolean writeLong(String name, long val) { - if (stream.remaining() < 8) - return false; - - stream.writeLong(val); - - return true; - } - - /** {@inheritDoc} */ - @Override public boolean writeFloat(String name, float val) { - if (stream.remaining() < 4) - return false; - - stream.writeFloat(val); - - return true; - } - - /** {@inheritDoc} */ - @Override public boolean writeDouble(String name, double val) { - if (stream.remaining() < 8) - return false; - - stream.writeDouble(val); - - return true; - } - - /** {@inheritDoc} */ - @Override public boolean writeChar(String name, char val) { - if (stream.remaining() < 2) - return false; - - stream.writeChar(val); - - return true; - } - - /** {@inheritDoc} */ - @Override public boolean writeBoolean(String name, boolean val) { - if (stream.remaining() < 1) - return false; - - stream.writeBoolean(val); - - return true; - } - - /** {@inheritDoc} */ - @Override public boolean writeByteArray(String name, @Nullable byte[] val) { - if (val != null) { - stream.writeByteArray(val); - - return stream.lastFinished(); - } - else { - if (stream.remaining() < 4) - return false; - - stream.writeInt(-1); - - return true; - } - } - - /** {@inheritDoc} */ - @Override public boolean writeShortArray(String name, @Nullable short[] val) { - if (val != null) { - stream.writeShortArray(val); - - return stream.lastFinished(); - } - else { - if (stream.remaining() < 4) - return false; - - stream.writeInt(-1); - - return true; - } - } - - /** {@inheritDoc} */ - @Override public boolean writeIntArray(String name, @Nullable int[] val) { - if (val != null) { - stream.writeIntArray(val); - - return stream.lastFinished(); - } - else { - if (stream.remaining() < 4) - return false; - - stream.writeInt(-1); - - return true; - } - } - - /** {@inheritDoc} */ - @Override public boolean writeLongArray(String name, @Nullable long[] val) { - if (val != null) { - stream.writeLongArray(val); - - return stream.lastFinished(); - } - else { - if (stream.remaining() < 4) - return false; - - stream.writeInt(-1); - - return true; - } - } - - /** {@inheritDoc} */ - @Override public boolean writeFloatArray(String name, @Nullable float[] val) { - if (val != null) { - stream.writeFloatArray(val); - - return stream.lastFinished(); - } - else { - if (stream.remaining() < 4) - return false; - - stream.writeInt(-1); - - return true; - } - } - - /** {@inheritDoc} */ - @Override public boolean writeDoubleArray(String name, @Nullable double[] val) { - if (val != null) { - stream.writeDoubleArray(val); - - return stream.lastFinished(); - } - else { - if (stream.remaining() < 4) - return false; - - stream.writeInt(-1); - - return true; - } - } - - /** {@inheritDoc} */ - @Override public boolean writeCharArray(String name, @Nullable char[] val) { - if (val != null) { - stream.writeCharArray(val); - - return stream.lastFinished(); - } - else { - if (stream.remaining() < 4) - return false; - - stream.writeInt(-1); - - return true; - } - } - - /** {@inheritDoc} */ - @Override public boolean writeBooleanArray(String name, @Nullable boolean[] val) { - if (val != null) { - stream.writeBooleanArray(val); - - return stream.lastFinished(); - } - else { - if (stream.remaining() < 4) - return false; - - stream.writeInt(-1); - - return true; - } - } - - /** {@inheritDoc} */ - @Override public boolean writeMessage(String name, @Nullable GridTcpCommunicationMessageAdapter msg) { - if (msg != null) { - stream.writeMessage(msg); - - return stream.lastFinished(); - } - else { - if (stream.remaining() < 1) - return false; - - stream.writeByte(Byte.MIN_VALUE); - - return true; - } - } -} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridJobMasterLeaveAwareSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridJobMasterLeaveAwareSelfTest.java index 4e817a3c33fc6..c9ec0e01827eb 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/GridJobMasterLeaveAwareSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridJobMasterLeaveAwareSelfTest.java @@ -23,11 +23,11 @@ import org.apache.ignite.compute.*; import org.apache.ignite.configuration.*; import org.apache.ignite.internal.managers.communication.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; import org.apache.ignite.marshaller.optimized.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.resources.*; import org.apache.ignite.spi.*; import org.apache.ignite.spi.communication.tcp.*; @@ -732,7 +732,7 @@ private static class CommunicationSpi extends TcpCommunicationSpi { private CountDownLatch waitLatch = new CountDownLatch(1); /** {@inheritDoc} */ - @Override public void sendMessage(ClusterNode node, GridTcpCommunicationMessageAdapter msg) + @Override public void sendMessage(ClusterNode node, MessageAdapter msg) throws IgniteSpiException { sendMessage0(node, msg); } @@ -745,7 +745,7 @@ private static class CommunicationSpi extends TcpCommunicationSpi { * @param msg Message to be sent. * @throws org.apache.ignite.spi.IgniteSpiException If failed. */ - private void sendMessage0(ClusterNode node, GridTcpCommunicationMessageAdapter msg) throws IgniteSpiException { + private void sendMessage0(ClusterNode node, MessageAdapter msg) throws IgniteSpiException { if (msg instanceof GridIoMessage) { GridIoMessage msg0 = (GridIoMessage)msg; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridCommunicationSendMessageSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridCommunicationSendMessageSelfTest.java index 13762fb4428e2..ce1d7654cec5c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridCommunicationSendMessageSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridCommunicationSendMessageSelfTest.java @@ -19,7 +19,8 @@ import org.apache.ignite.configuration.*; import org.apache.ignite.internal.*; -import org.apache.ignite.internal.util.direct.*; +import org.apache.ignite.internal.direct.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.spi.communication.tcp.*; import org.apache.ignite.spi.discovery.tcp.*; import org.apache.ignite.spi.discovery.tcp.ipfinder.*; @@ -50,7 +51,7 @@ public class GridCommunicationSendMessageSelfTest extends GridCommonAbstractTest static { GridTcpCommunicationMessageFactory.registerCustom(new GridTcpCommunicationMessageProducer() { - @Override public GridTcpCommunicationMessageAdapter create(byte type) { + @Override public MessageAdapter create(byte type) { return new TestMessage(); } }, DIRECT_TYPE); @@ -141,15 +142,15 @@ private void doSend() throws Exception { } /** */ - private static class TestMessage extends GridTcpCommunicationMessageAdapter { + private static class TestMessage extends MessageAdapter { /** {@inheritDoc} */ @SuppressWarnings("CloneDoesntCallSuperClone") - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { throw new UnsupportedOperationException(); } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { // No-op. } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridIoManagerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridIoManagerSelfTest.java index cf89a1f0e67de..d125375517084 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridIoManagerSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridIoManagerSelfTest.java @@ -22,9 +22,9 @@ import org.apache.ignite.cluster.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.managers.discovery.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.marshaller.jdk.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.spi.communication.tcp.*; import org.apache.ignite.testframework.*; import org.apache.ignite.testframework.junits.*; @@ -183,7 +183,7 @@ private static class TestGridIoManager extends GridIoManager { } /** {@inheritDoc} */ - @Override public void send(ClusterNode node, GridTopic topic, GridTcpCommunicationMessageAdapter msg, + @Override public void send(ClusterNode node, GridTopic topic, MessageAdapter msg, GridIoPolicy plc) throws IgniteCheckedException { // No-op. } @@ -218,15 +218,15 @@ private static class IsEqualCollection extends ArgumentMatcher, AtomicInteger> cntMap = new HashMap<>(); /** {@inheritDoc} */ - @Override public void sendMessage(ClusterNode node, GridTcpCommunicationMessageAdapter msg) + @Override public void sendMessage(ClusterNode node, MessageAdapter msg) throws IgniteSpiException { AtomicInteger cntr = cntMap.get(((GridIoMessage)msg).message().getClass()); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReplicatedSynchronousCommitTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReplicatedSynchronousCommitTest.java index d37eab5ba4f9f..85ba6ce07d2a3 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReplicatedSynchronousCommitTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReplicatedSynchronousCommitTest.java @@ -24,7 +24,7 @@ import org.apache.ignite.internal.*; import org.apache.ignite.internal.managers.communication.*; import org.apache.ignite.internal.processors.cache.distributed.*; -import org.apache.ignite.internal.util.direct.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.spi.*; import org.apache.ignite.spi.communication.tcp.*; import org.apache.ignite.spi.discovery.tcp.*; @@ -185,7 +185,7 @@ public int messagesCount() { } /** {@inheritDoc} */ - @Override public void sendMessage(ClusterNode node, GridTcpCommunicationMessageAdapter msg) + @Override public void sendMessage(ClusterNode node, MessageAdapter msg) throws IgniteSpiException { Object obj = ((GridIoMessage)msg).message(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxReentryAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxReentryAbstractSelfTest.java index 254cf5aac1225..2442c8b2d77da 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxReentryAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxReentryAbstractSelfTest.java @@ -24,7 +24,7 @@ import org.apache.ignite.internal.processors.cache.distributed.*; import org.apache.ignite.internal.processors.cache.distributed.dht.*; import org.apache.ignite.internal.processors.cache.distributed.near.*; -import org.apache.ignite.internal.util.direct.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.spi.*; import org.apache.ignite.spi.communication.tcp.*; import org.apache.ignite.spi.discovery.tcp.*; @@ -134,7 +134,7 @@ protected static class CountingCommunicationSpi extends TcpCommunicationSpi { private AtomicInteger dhtLocks = new AtomicInteger(); /** {@inheritDoc} */ - @Override public void sendMessage(ClusterNode node, GridTcpCommunicationMessageAdapter msg) + @Override public void sendMessage(ClusterNode node, MessageAdapter msg) throws IgniteSpiException { countMsg((GridIoMessage)msg); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAtomicTimeoutSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAtomicTimeoutSelfTest.java index 6d62a84a189bf..55d1068e1dd3f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAtomicTimeoutSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAtomicTimeoutSelfTest.java @@ -26,10 +26,10 @@ import org.apache.ignite.internal.managers.communication.*; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.nio.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.spi.*; import org.apache.ignite.spi.communication.tcp.*; import org.apache.ignite.testframework.*; @@ -274,7 +274,7 @@ private static class TestCommunicationSpi extends TcpCommunicationSpi { private boolean skipDhtResponse; /** {@inheritDoc} */ - @Override public void sendMessage(ClusterNode node, GridTcpCommunicationMessageAdapter msg) + @Override public void sendMessage(ClusterNode node, MessageAdapter msg) throws IgniteSpiException { if (!skipMessage((GridIoMessage)msg)) super.sendMessage(node, msg); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxOriginatingNodeFailureAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxOriginatingNodeFailureAbstractSelfTest.java index 7c860e105626f..f6931794a59b6 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxOriginatingNodeFailureAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxOriginatingNodeFailureAbstractSelfTest.java @@ -25,10 +25,10 @@ import org.apache.ignite.internal.managers.communication.*; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.transactions.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.lang.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.resources.*; import org.apache.ignite.spi.*; import org.apache.ignite.spi.communication.tcp.*; @@ -239,7 +239,7 @@ protected void testTxOriginatingNodeFails(Collection keys, final boolea IgniteConfiguration cfg = super.getConfiguration(gridName); cfg.setCommunicationSpi(new TcpCommunicationSpi() { - @Override public void sendMessage(ClusterNode node, GridTcpCommunicationMessageAdapter msg) + @Override public void sendMessage(ClusterNode node, MessageAdapter msg) throws IgniteSpiException { if (!F.eq(ignoreMsgNodeId, node.id()) || !ignoredMessage((GridIoMessage)msg)) super.sendMessage(node, msg); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest.java index e4bda2585fa56..9568789f41278 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest.java @@ -26,10 +26,10 @@ import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.distributed.near.*; import org.apache.ignite.internal.processors.cache.transactions.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.lang.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.resources.*; import org.apache.ignite.spi.*; import org.apache.ignite.spi.communication.tcp.*; @@ -418,7 +418,7 @@ private Collection allNodeIds() { IgniteConfiguration cfg = super.getConfiguration(gridName); cfg.setCommunicationSpi(new TcpCommunicationSpi() { - @Override public void sendMessage(ClusterNode node, GridTcpCommunicationMessageAdapter msg) + @Override public void sendMessage(ClusterNode node, MessageAdapter msg) throws IgniteSpiException { if (getSpiContext().localNode().id().equals(failingNodeId)) { if (ignoredMessage((GridIoMessage)msg) && ignoreMsgNodeIds != null) { diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadMessageCountTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadMessageCountTest.java index 53987013ffc26..e621847db6f55 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadMessageCountTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadMessageCountTest.java @@ -24,8 +24,8 @@ import org.apache.ignite.configuration.*; import org.apache.ignite.internal.managers.communication.*; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.spi.*; import org.apache.ignite.spi.communication.tcp.*; import org.apache.ignite.spi.discovery.tcp.*; @@ -141,7 +141,7 @@ private static class TestCommunicationSpi extends TcpCommunicationSpi { private Collection sentMsgs = new ConcurrentLinkedQueue<>(); /** {@inheritDoc} */ - @Override public void sendMessage(ClusterNode node, GridTcpCommunicationMessageAdapter msg) + @Override public void sendMessage(ClusterNode node, MessageAdapter msg) throws IgniteSpiException { recordMessage((GridIoMessage)msg); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridCacheAtomicInvalidPartitionHandlingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridCacheAtomicInvalidPartitionHandlingSelfTest.java index 1e83921ff22bc..9fc882eceedd0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridCacheAtomicInvalidPartitionHandlingSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridCacheAtomicInvalidPartitionHandlingSelfTest.java @@ -24,8 +24,8 @@ import org.apache.ignite.internal.managers.communication.*; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.version.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.spi.*; import org.apache.ignite.spi.communication.tcp.*; import org.apache.ignite.spi.discovery.tcp.*; @@ -296,7 +296,7 @@ private void checkRestarts(CacheAtomicWriteOrderMode writeOrder, CacheWriteSynch */ private static class DelayCommunicationSpi extends TcpCommunicationSpi { /** {@inheritDoc} */ - @Override public void sendMessage(ClusterNode node, GridTcpCommunicationMessageAdapter msg) + @Override public void sendMessage(ClusterNode node, MessageAdapter msg) throws IgniteSpiException { try { if (delayMessage((GridIoMessage)msg)) diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedInvalidateSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedInvalidateSelfTest.java index cfd1b877fc519..5d8545f563c61 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedInvalidateSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedInvalidateSelfTest.java @@ -24,7 +24,7 @@ import org.apache.ignite.internal.managers.communication.*; import org.apache.ignite.internal.processors.clock.*; import org.apache.ignite.internal.transactions.*; -import org.apache.ignite.internal.util.direct.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.spi.*; import org.apache.ignite.spi.communication.tcp.*; import org.apache.ignite.spi.discovery.tcp.*; @@ -224,7 +224,7 @@ public void clearCounts() { } /** {@inheritDoc} */ - @Override public void sendMessage(ClusterNode destNode, GridTcpCommunicationMessageAdapter msg) + @Override public void sendMessage(ClusterNode destNode, MessageAdapter msg) throws IgniteSpiException { Object msg0 = ((GridIoMessage)msg).message(); diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/communication/GridIoManagerBenchmark0.java b/modules/core/src/test/java/org/apache/ignite/loadtests/communication/GridIoManagerBenchmark0.java index 78b1aca24a649..94b8a879f3c05 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/communication/GridIoManagerBenchmark0.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/communication/GridIoManagerBenchmark0.java @@ -22,10 +22,10 @@ import org.apache.ignite.configuration.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.managers.communication.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.spi.communication.*; import org.apache.ignite.spi.communication.tcp.*; import org.apache.ignite.spi.discovery.tcp.*; @@ -123,7 +123,7 @@ public void testThroughput() throws Exception { new GridMessageListener() { @Override public void onMessage(UUID nodeId, Object msg) { try { - rcv.send(sndNode, topic, (GridTcpCommunicationMessageAdapter)msg, PUBLIC_POOL); + rcv.send(sndNode, topic, (MessageAdapter)msg, PUBLIC_POOL); } catch (IgniteCheckedException e) { error("Failed to send message.", e); @@ -217,7 +217,7 @@ public void testLatency() throws Exception { new GridMessageListener() { @Override public void onMessage(UUID nodeId, Object msg) { try { - rcv.send(sndNode, topic, (GridTcpCommunicationMessageAdapter)msg, PUBLIC_POOL); + rcv.send(sndNode, topic, (MessageAdapter)msg, PUBLIC_POOL); } catch (IgniteCheckedException e) { error("Failed to send message.", e); @@ -317,7 +317,7 @@ public void testVariableLoad() throws Exception { new GridMessageListener() { @Override public void onMessage(UUID nodeId, Object msg) { try { - rcv.send(sndNode, topic, (GridTcpCommunicationMessageAdapter)msg, PUBLIC_POOL); + rcv.send(sndNode, topic, (MessageAdapter)msg, PUBLIC_POOL); } catch (IgniteCheckedException e) { error("Failed to send message.", e); diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/communication/GridTestMessage.java b/modules/core/src/test/java/org/apache/ignite/loadtests/communication/GridTestMessage.java index 03926434fdbe0..1c63e60b2db8b 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/communication/GridTestMessage.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/communication/GridTestMessage.java @@ -17,9 +17,9 @@ package org.apache.ignite.loadtests.communication; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -27,7 +27,7 @@ /** * */ -class GridTestMessage extends GridTcpCommunicationMessageAdapter implements Externalizable { +class GridTestMessage extends MessageAdapter implements Externalizable { /** */ private IgniteUuid id; @@ -109,12 +109,12 @@ public void bytes(byte[] bytes) { /** {@inheritDoc} */ @SuppressWarnings("CloneDoesntCallSuperClone") - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { throw new UnsupportedOperationException(); } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { // No-op. } diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/GridAbstractCommunicationSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/GridAbstractCommunicationSelfTest.java index 1eb9f47adbc8b..1aabf89f770e3 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/GridAbstractCommunicationSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/GridAbstractCommunicationSelfTest.java @@ -19,10 +19,11 @@ import org.apache.ignite.*; import org.apache.ignite.cluster.*; -import org.apache.ignite.internal.util.direct.*; +import org.apache.ignite.internal.direct.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.testframework.*; import org.apache.ignite.testframework.junits.*; import org.apache.ignite.testframework.junits.spi.*; @@ -49,7 +50,7 @@ public abstract class GridAbstractCommunicationSelfTest> msgDestMap = new HashMap<>(); /** */ - protected static final Map> spis = new HashMap<>(); + protected static final Map> spis = new HashMap<>(); /** */ protected static final Collection nodes = new ArrayList<>(); @@ -62,7 +63,7 @@ public abstract class GridAbstractCommunicationSelfTest { + private class MessageListener implements CommunicationListener { /** */ private final UUID locNodeId; @@ -84,7 +85,7 @@ private class MessageListener implements CommunicationListener spi : spis.values()) { + for (CommunicationSpi spi : spis.values()) { spi.onContextDestroyed(); spi.setListener(null); diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/GridTestMessage.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/GridTestMessage.java index f36fa588a97a1..e1244a0b69a0c 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/GridTestMessage.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/GridTestMessage.java @@ -17,8 +17,8 @@ package org.apache.ignite.spi.communication; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.nio.*; import java.util.*; @@ -26,7 +26,7 @@ /** * Test message for communication SPI tests. */ -public class GridTestMessage extends GridTcpCommunicationMessageAdapter { +public class GridTestMessage extends MessageAdapter { /** */ public static final byte DIRECT_TYPE = (byte)200; @@ -95,7 +95,7 @@ public byte[] payload() { /** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public GridTcpCommunicationMessageAdapter clone() { + @Override public MessageAdapter clone() { GridTestMessage msg = new GridTestMessage(); clone0(msg); @@ -104,7 +104,7 @@ public byte[] payload() { } /** {@inheritDoc} */ - @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) { + @Override protected void clone0(MessageAdapter _msg) { GridTestMessage _clone = (GridTestMessage)_msg; _clone.srcNodeId = srcNodeId; diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridCacheDhtLockBackupSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridCacheDhtLockBackupSelfTest.java index f0ee2fe6ccb41..27c98c9a56125 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridCacheDhtLockBackupSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridCacheDhtLockBackupSelfTest.java @@ -22,11 +22,11 @@ import org.apache.ignite.configuration.*; import org.apache.ignite.internal.managers.communication.*; import org.apache.ignite.internal.processors.cache.distributed.near.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; import org.apache.ignite.marshaller.*; import org.apache.ignite.marshaller.jdk.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.spi.communication.*; import org.apache.ignite.spi.discovery.tcp.*; import org.apache.ignite.spi.discovery.tcp.ipfinder.*; @@ -259,7 +259,7 @@ private TestCommunicationSpi(Class delayedMsgCls, int delayTime) { * @param obj Message being sent. * @param srcNodeId Sender node id. */ - private void checkAwaitMessageType(GridTcpCommunicationMessageAdapter obj, UUID srcNodeId) { + private void checkAwaitMessageType(MessageAdapter obj, UUID srcNodeId) { try { GridIoMessage plainMsg = (GridIoMessage)obj; @@ -277,7 +277,7 @@ private void checkAwaitMessageType(GridTcpCommunicationMessageAdapter obj, UUID } /** {@inheritDoc} */ - @Override protected void notifyListener(UUID sndId, GridTcpCommunicationMessageAdapter msg, + @Override protected void notifyListener(UUID sndId, MessageAdapter msg, IgniteRunnable msgC) { checkAwaitMessageType(msg, sndId); diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConcurrentConnectSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConcurrentConnectSelfTest.java index 4892db0b8fea2..39bfe373a4170 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConcurrentConnectSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConcurrentConnectSelfTest.java @@ -20,11 +20,12 @@ import org.apache.ignite.*; import org.apache.ignite.cluster.*; import org.apache.ignite.internal.*; -import org.apache.ignite.internal.util.direct.*; +import org.apache.ignite.internal.direct.*; import org.apache.ignite.internal.util.lang.*; import org.apache.ignite.internal.util.nio.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.spi.communication.*; import org.apache.ignite.testframework.*; import org.apache.ignite.testframework.junits.*; @@ -52,7 +53,7 @@ public class GridTcpCommunicationSpiConcurrentConnectSelfTest spiRsrcs = new ArrayList<>(); /** */ - protected static final List> spis = new ArrayList<>(); + protected static final List> spis = new ArrayList<>(); /** */ protected static final List nodes = new ArrayList<>(); @@ -66,7 +67,7 @@ public class GridTcpCommunicationSpiConcurrentConnectSelfTest { + private static class MessageListener implements CommunicationListener { /** */ private final CountDownLatch latch; @@ -100,7 +101,7 @@ private static class MessageListener implements CommunicationListener spi : spis) { + for (CommunicationSpi spi : spis) { spi.onContextDestroyed(); spi.setListener(null); diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiLanTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiLanTest.java index 0e974b0598f5c..1c682644bcd78 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiLanTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiLanTest.java @@ -20,9 +20,9 @@ import mx4j.tools.adaptor.http.*; import org.apache.ignite.*; import org.apache.ignite.internal.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.spi.communication.*; import org.apache.ignite.testframework.*; import org.apache.ignite.testframework.config.*; @@ -79,7 +79,7 @@ public GridTcpCommunicationSpiLanTest() { * Accumulating listener. */ @SuppressWarnings({"deprecation"}) - private class MessageListener implements CommunicationListener { + private class MessageListener implements CommunicationListener { /** Node id of local node. */ private final UUID locNodeId; @@ -100,7 +100,7 @@ private class MessageListener implements CommunicationListener spiRsrcs = new ArrayList<>(); /** SPIs */ - private static final Map> spis = + private static final Map> spis = new ConcurrentHashMap<>(); /** Listeners. */ @@ -74,7 +75,7 @@ public abstract class GridTcpCommunicationSpiMultithreadedSelfTest extends GridS static { GridTcpCommunicationMessageFactory.registerCustom(new GridTcpCommunicationMessageProducer() { - @Override public GridTcpCommunicationMessageAdapter create(byte type) { + @Override public MessageAdapter create(byte type) { return new GridTestMessage(); } }, GridTestMessage.DIRECT_TYPE); @@ -93,7 +94,7 @@ protected GridTcpCommunicationSpiMultithreadedSelfTest(boolean useShmem) { * Accumulating listener. */ @SuppressWarnings({"deprecation"}) - private static class MessageListener implements CommunicationListener { + private static class MessageListener implements CommunicationListener { /** Node id of local node. */ private final UUID locNodeId; @@ -113,7 +114,7 @@ private static class MessageListener implements CommunicationListener spi : spis.values()) { + for (CommunicationSpi spi : spis.values()) { GridNioServer srv = U.field(spi, "nioSrvr"); Collection sessions = GridTestUtils.getFieldValue(srv, "sessions"); @@ -376,7 +377,7 @@ public void testPassThroughPerformance() throws Exception { ClusterNode to = nodes.get(1); - CommunicationSpi spi = spis.get(from.id()); + CommunicationSpi spi = spis.get(from.id()); while (cntr.getAndIncrement() < msgCnt) { GridTestMessage msg = new GridTestMessage(from.id(), msgId.getAndIncrement(), 0); @@ -414,7 +415,7 @@ private ClusterNode randomNode(Random rnd) { /** * @return Spi. */ - private CommunicationSpi newCommunicationSpi() { + private CommunicationSpi newCommunicationSpi() { TcpCommunicationSpi spi = new TcpCommunicationSpi(); if (!useShmem) @@ -445,7 +446,7 @@ private int getSpiCount() { Map ctxs = new HashMap<>(); for (int i = 0; i < getSpiCount(); i++) { - CommunicationSpi spi = newCommunicationSpi(); + CommunicationSpi spi = newCommunicationSpi(); GridTestUtils.setFieldValue(spi, "gridName", "grid-" + i); @@ -520,7 +521,7 @@ private int getSpiCount() { /** {@inheritDoc} */ @Override protected void afterTestsStopped() throws Exception { - for (CommunicationSpi spi : spis.values()) { + for (CommunicationSpi spi : spis.values()) { spi.onContextDestroyed(); spi.setListener(null); diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoveryAckSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoveryAckSelfTest.java index 641805d91e17c..78e1b817f3ecd 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoveryAckSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoveryAckSelfTest.java @@ -19,11 +19,12 @@ import org.apache.ignite.*; import org.apache.ignite.cluster.*; -import org.apache.ignite.internal.util.direct.*; +import org.apache.ignite.internal.direct.*; import org.apache.ignite.internal.util.lang.*; import org.apache.ignite.internal.util.nio.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.spi.communication.*; import org.apache.ignite.testframework.*; import org.apache.ignite.testframework.junits.*; @@ -57,7 +58,7 @@ public class GridTcpCommunicationSpiRecoveryAckSelfTest { + private class TestListener implements CommunicationListener { /** */ private ConcurrentHashSet msgIds = new ConcurrentHashSet<>(); @@ -80,7 +81,7 @@ private class TestListener implements CommunicationListener spi : spis) { + for (CommunicationSpi spi : spis) { spi.onContextDestroyed(); spi.setListener(null); diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoverySelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoverySelfTest.java index cdd6ef6f92957..c2c16762a7f4a 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoverySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoverySelfTest.java @@ -20,11 +20,12 @@ import org.apache.ignite.*; import org.apache.ignite.cluster.*; import org.apache.ignite.internal.*; -import org.apache.ignite.internal.util.direct.*; +import org.apache.ignite.internal.direct.*; import org.apache.ignite.internal.util.lang.*; import org.apache.ignite.internal.util.nio.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.spi.*; import org.apache.ignite.spi.communication.*; import org.apache.ignite.testframework.*; @@ -65,7 +66,7 @@ public class GridTcpCommunicationSpiRecoverySelfTest */ static { GridTcpCommunicationMessageFactory.registerCustom(new GridTcpCommunicationMessageProducer() { - @Override public GridTcpCommunicationMessageAdapter create(byte type) { + @Override public MessageAdapter create(byte type) { return new GridTestMessage(); } }, GridTestMessage.DIRECT_TYPE); @@ -80,7 +81,7 @@ public GridTcpCommunicationSpiRecoverySelfTest() { /** */ @SuppressWarnings({"deprecation"}) - private class TestListener implements CommunicationListener { + private class TestListener implements CommunicationListener { /** */ private boolean block; @@ -94,7 +95,7 @@ private class TestListener implements CommunicationListener spi : spis) { + for (CommunicationSpi spi : spis) { spi.onContextDestroyed(); spi.setListener(null); diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java b/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java index 137adf2dfaaa4..48d9e2d9b4e59 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java @@ -21,15 +21,15 @@ import org.apache.ignite.cluster.*; import org.apache.ignite.events.*; import org.apache.ignite.internal.*; +import org.apache.ignite.internal.direct.*; import org.apache.ignite.internal.managers.communication.*; import org.apache.ignite.internal.managers.eventstorage.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.plugin.security.*; import org.apache.ignite.spi.*; import org.apache.ignite.spi.swapspace.*; -import org.gridgain.grid.util.direct.*; import org.jetbrains.annotations.*; import java.io.*; @@ -519,10 +519,10 @@ public void triggerEvent(Event evt) { /** {@inheritDoc} */ @Override public GridTcpMessageFactory messageFactory() { return new GridTcpMessageFactory() { - @Override public GridTcpCommunicationMessageAdapter create(byte type) { - GridTcpCommunicationMessageAdapter msg = GridTcpCommunicationMessageFactory.create(type); + @Override public MessageAdapter create(byte type) { + MessageAdapter msg = GridTcpCommunicationMessageFactory.create(type); - msg.setReader(new GridTcpCommunicationMessageReader(null)); + msg.setReader(new DirectMessageReader(null)); return msg; } diff --git a/modules/indexing/src/test/java/org/apache/ignite/spi/communication/tcp/GridOrderedMessageCancelSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/spi/communication/tcp/GridOrderedMessageCancelSelfTest.java index a2b7ddf93937c..e9bc33e6ccaf8 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/spi/communication/tcp/GridOrderedMessageCancelSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/spi/communication/tcp/GridOrderedMessageCancelSelfTest.java @@ -24,9 +24,9 @@ import org.apache.ignite.internal.*; import org.apache.ignite.internal.managers.communication.*; import org.apache.ignite.internal.processors.cache.query.*; -import org.apache.ignite.internal.util.direct.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.spi.discovery.tcp.*; import org.apache.ignite.spi.discovery.tcp.ipfinder.*; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*; @@ -165,7 +165,7 @@ private void testMessageSet(IgniteInternalFuture fut) throws Exception { */ private static class CommunicationSpi extends TcpCommunicationSpi { /** {@inheritDoc} */ - @Override protected void notifyListener(UUID sndId, GridTcpCommunicationMessageAdapter msg, + @Override protected void notifyListener(UUID sndId, MessageAdapter msg, IgniteRunnable msgC) { try { GridIoMessage ioMsg = (GridIoMessage)msg; From dff026be8dc1d511003fb14e89b8f2b18b2f862f Mon Sep 17 00:00:00 2001 From: Alexey Goncharuk Date: Sat, 7 Feb 2015 13:55:52 -0800 Subject: [PATCH 42/95] IGNITE-51 - Got rid of portables in code, tests need to be fixed. --- .../ignite/client/ClientTestPortable.java | 490 ------------------ .../ClientTestPortableAffinityKeyTask.java | 2 +- .../src/test/resources/spring-cache.xml | 6 +- .../src/test/resources/spring-server-node.xml | 12 +- .../test/resources/spring-server-ssl-node.xml | 6 +- .../main/java/org/apache/ignite/Ignite.java | 7 - .../java/org/apache/ignite/IgniteCache.java | 2 +- .../org/apache/ignite/IgnitePortables.java | 364 ------------- .../apache/ignite/cache/CacheProjection.java | 2 +- .../apache/ignite/cache/store/CacheStore.java | 10 +- .../ignite/client/GridClientCacheFlag.java | 2 +- .../client/GridClientConfiguration.java | 23 - .../configuration/CacheConfiguration.java | 64 --- .../configuration/IgniteConfiguration.java | 19 - .../ignite/internal/GridPortablesImpl.java | 174 ------- .../apache/ignite/internal/IgniteKernal.java | 13 - .../apache/ignite/internal/IgnitionEx.java | 3 - .../affinity/GridAffinityAssignmentCache.java | 3 +- .../affinity/GridAffinityProcessor.java | 2 +- .../processors/cache/GridCacheAdapter.java | 21 +- .../processors/cache/GridCacheAttributes.java | 11 - .../processors/cache/GridCacheContext.java | 123 +---- .../GridCacheDefaultAffinityKeyMapper.java | 34 +- .../processors/cache/GridCacheProcessor.java | 7 - .../cache/GridCacheProjectionImpl.java | 10 - .../cache/GridCacheStoreManager.java | 4 +- .../IgniteCacheOsSerializationManager.java} | 42 +- .../cache/affinity/GridCacheAffinityImpl.java | 3 +- .../IgniteCacheSerializationManager.java | 51 ++ .../transactions/IgniteTxLocalAdapter.java | 7 +- .../dataload/IgniteDataLoaderImpl.java | 6 +- .../plugin/IgnitePluginProcessor.java | 4 +- .../portable/GridPortableProcessor.java | 88 ++-- .../portable/os/GridOsPortableProcessor.java | 48 +- .../processors/query/GridQueryProcessor.java | 33 +- .../processors/rest/GridRestProcessor.java | 10 +- .../message/GridClientAbstractMessage.java | 17 +- .../GridClientAuthenticationRequest.java | 19 - .../message/GridClientCacheQueryRequest.java | 45 -- .../message/GridClientCacheRequest.java | 48 -- .../message/GridClientGetMetaDataRequest.java | 64 --- .../client/message/GridClientLogRequest.java | 23 - .../message/GridClientMetaDataResponse.java | 57 -- .../client/message/GridClientNodeBean.java | 40 +- .../message/GridClientNodeMetricsBean.java | 120 +---- .../message/GridClientPortableMetaData.java | 23 +- .../message/GridClientPutMetaDataRequest.java | 64 --- .../client/message/GridClientResponse.java | 23 - .../client/message/GridClientTaskRequest.java | 28 - .../message/GridClientTaskResultBean.java | 28 +- .../message/GridClientTopologyRequest.java | 25 - .../cache/GridCacheClientQueryResult.java | 24 +- .../metadata/GridPortableMetadataHandler.java | 103 ---- .../handlers/task/GridTaskCommandHandler.java | 3 +- .../protocols/tcp/GridTcpRestNioListener.java | 14 - .../GridRestPortableGetMetaDataRequest.java | 44 -- .../GridRestPortablePutMetaDataRequest.java | 44 -- .../ignite/internal/util/IgniteUtils.java | 72 --- .../util/portable/PortableRawReaderEx.java | 32 -- .../util/portable/PortableRawWriterEx.java | 43 -- .../visor/portable/VisorPortableMetadata.java | 72 --- .../VisorPortableMetadataCollectorTask.java | 94 ---- .../portable/VisorPortableMetadataField.java | 71 --- .../apache/ignite/plugin/PluginProvider.java | 2 +- .../security/GridSecurityCredentials.java | 20 +- .../ignite/portables/PortableBuilder.java | 137 ----- .../portables/PortableConfiguration.java | 189 ------- .../ignite/portables/PortableException.java | 57 -- .../ignite/portables/PortableIdMapper.java | 55 -- .../PortableInvalidClassException.java | 58 --- .../portables/PortableMarshalAware.java | 48 -- .../ignite/portables/PortableMetadata.java | 61 --- .../ignite/portables/PortableObject.java | 160 ------ .../ignite/portables/PortableRawReader.java | 235 --------- .../ignite/portables/PortableRawWriter.java | 218 -------- .../ignite/portables/PortableReader.java | 286 ---------- .../ignite/portables/PortableSerializer.java | 47 -- .../portables/PortableTypeConfiguration.java | 195 ------- .../ignite/portables/PortableWriter.java | 265 ---------- .../org/apache/ignite/portables/package.html | 24 - .../cache/GridCacheAbstractSelfTest.java | 8 - .../cache/GridCacheMemoryModeSelfTest.java | 8 - ...apMultiThreadedUpdateAbstractSelfTest.java | 1 - ...ridCacheOffHeapTieredAbstractSelfTest.java | 2 +- ...OffHeapTieredEvictionAbstractSelfTest.java | 2 +- .../cache/IgniteCacheAbstractTest.java | 8 - ...actDistributedByteArrayValuesSelfTest.java | 10 - ...actPartitionedByteArrayValuesSelfTest.java | 3 - ...ridCacheSwapScanQueryAbstractSelfTest.java | 66 +-- .../query/GridCacheSwapScanQuerySelfTest.java | 4 - .../testframework/junits/IgniteMock.java | 5 - 91 files changed, 240 insertions(+), 4880 deletions(-) delete mode 100644 modules/clients/src/test/java/org/apache/ignite/client/ClientTestPortable.java delete mode 100644 modules/core/src/main/java/org/apache/ignite/IgnitePortables.java delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/GridPortablesImpl.java rename modules/{clients/src/test/java/org/apache/ignite/client/ClientPortableArgumentTask.java => core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOsSerializationManager.java} (51%) create mode 100644 modules/core/src/main/java/org/apache/ignite/internal/processors/cache/serialization/IgniteCacheSerializationManager.java delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientGetMetaDataRequest.java delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMetaDataResponse.java delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPutMetaDataRequest.java delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/metadata/GridPortableMetadataHandler.java delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestPortableGetMetaDataRequest.java delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestPortablePutMetaDataRequest.java delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/util/portable/PortableRawReaderEx.java delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/util/portable/PortableRawWriterEx.java delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/visor/portable/VisorPortableMetadata.java delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/visor/portable/VisorPortableMetadataCollectorTask.java delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/visor/portable/VisorPortableMetadataField.java delete mode 100644 modules/core/src/main/java/org/apache/ignite/portables/PortableBuilder.java delete mode 100644 modules/core/src/main/java/org/apache/ignite/portables/PortableConfiguration.java delete mode 100644 modules/core/src/main/java/org/apache/ignite/portables/PortableException.java delete mode 100644 modules/core/src/main/java/org/apache/ignite/portables/PortableIdMapper.java delete mode 100644 modules/core/src/main/java/org/apache/ignite/portables/PortableInvalidClassException.java delete mode 100644 modules/core/src/main/java/org/apache/ignite/portables/PortableMarshalAware.java delete mode 100644 modules/core/src/main/java/org/apache/ignite/portables/PortableMetadata.java delete mode 100644 modules/core/src/main/java/org/apache/ignite/portables/PortableObject.java delete mode 100644 modules/core/src/main/java/org/apache/ignite/portables/PortableRawReader.java delete mode 100644 modules/core/src/main/java/org/apache/ignite/portables/PortableRawWriter.java delete mode 100644 modules/core/src/main/java/org/apache/ignite/portables/PortableReader.java delete mode 100644 modules/core/src/main/java/org/apache/ignite/portables/PortableSerializer.java delete mode 100644 modules/core/src/main/java/org/apache/ignite/portables/PortableTypeConfiguration.java delete mode 100644 modules/core/src/main/java/org/apache/ignite/portables/PortableWriter.java delete mode 100644 modules/core/src/main/java/org/apache/ignite/portables/package.html diff --git a/modules/clients/src/test/java/org/apache/ignite/client/ClientTestPortable.java b/modules/clients/src/test/java/org/apache/ignite/client/ClientTestPortable.java deleted file mode 100644 index 07d61776982ae..0000000000000 --- a/modules/clients/src/test/java/org/apache/ignite/client/ClientTestPortable.java +++ /dev/null @@ -1,490 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.client; - -import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.portables.*; - -import java.io.*; -import java.util.*; - -/** - * Test portable object. - */ -@SuppressWarnings("PublicField") -public class ClientTestPortable implements PortableMarshalAware, Serializable { - /** */ - public byte b; - - /** */ - public byte bRaw; - - /** */ - public short s; - - /** */ - public short sRaw; - - /** */ - public int i; - - /** */ - public int iRaw; - - /** */ - public long l; - - /** */ - public long lRaw; - - /** */ - public float f; - - /** */ - public float fRaw; - - /** */ - public double d; - - /** */ - public double dRaw; - - /** */ - public char c; - - /** */ - public char cRaw; - - /** */ - public boolean bool; - - /** */ - public boolean boolRaw; - - /** */ - public String str; - - /** */ - public String strRaw; - - /** */ - public UUID uuid; - - /** */ - public UUID uuidRaw; - - /** */ - public Date date; - - /** */ - public Date dateRaw; - - /** */ - public TestEnum e; - - /** */ - public TestEnum eRaw; - - /** */ - public byte[] bArr; - - /** */ - public byte[] bArrRaw; - - /** */ - public short[] sArr; - - /** */ - public short[] sArrRaw; - - /** */ - public int[] iArr; - - /** */ - public int[] iArrRaw; - - /** */ - public long[] lArr; - - /** */ - public long[] lArrRaw; - - /** */ - public float[] fArr; - - /** */ - public float[] fArrRaw; - - /** */ - public double[] dArr; - - /** */ - public double[] dArrRaw; - - /** */ - public char[] cArr; - - /** */ - public char[] cArrRaw; - - /** */ - public boolean[] boolArr; - - /** */ - public boolean[] boolArrRaw; - - /** */ - public String[] strArr; - - /** */ - public String[] strArrRaw; - - /** */ - public UUID[] uuidArr; - - /** */ - public UUID[] uuidArrRaw; - - /** */ - public Date[] dateArr; - - /** */ - public Date[] dateArrRaw; - - /** */ - public TestEnum[] eArr; - - /** */ - public TestEnum[] eArrRaw; - - /** */ - public Object[] objArr; - - /** */ - public Object[] objArrRaw; - - /** */ - public Collection col; - - /** */ - public Collection colRaw; - - /** */ - public Map map; - - /** */ - public Map mapRaw; - - /** */ - public ClientTestPortable portable1; - - /** */ - public ClientTestPortable portable2; - - /** */ - public ClientTestPortable portableRaw1; - - /** */ - public ClientTestPortable portableRaw2; - - /** - */ - public ClientTestPortable() { - // No-op. - } - - /** - * @param val Value. - * @param createInner If {@code true} creates nested object. - */ - public ClientTestPortable(int val, boolean createInner) { - b = (byte)val; - bRaw = (byte)(val + 1); - - s = (short)val; - sRaw = (short)(val + 1); - - i = val; - iRaw = i + 1; - - l = val; - lRaw = i + 1; - - f = val + 0.5f; - fRaw = f + 1; - - d = val + 0.5f; - dRaw = d + 1; - - c = (char)val; - cRaw = (char)(val + 1); - - bool = true; - boolRaw = false; - - str = String.valueOf(i); - strRaw = String.valueOf(iRaw); - - uuid = new UUID(i, i); - uuidRaw = new UUID(iRaw, iRaw); - - date = new Date(i); - dateRaw = new Date(iRaw); - - e = enumValue(i); - eRaw = enumValue(iRaw); - - bArr = new byte[]{b, (byte)(b + 1)}; - bArrRaw = new byte[]{bRaw, (byte)(bRaw + 1)}; - - sArr = new short[]{s, (short)(s + 1)}; - sArrRaw = new short[]{sRaw, (short)(sRaw + 1)}; - - iArr = new int[]{i, i + 1}; - iArrRaw = new int[]{iRaw, iRaw + 1}; - - lArr = new long[]{l, l + 1}; - lArrRaw = new long[]{lRaw, lRaw + 1}; - - fArr = new float[]{f, f + 1}; - fArrRaw = new float[]{fRaw, fRaw + 1}; - - dArr = new double[]{d, d + 1}; - dArrRaw = new double[]{dRaw, dRaw + 1}; - - cArr = new char[]{c, (char)(c + 1)}; - cArrRaw = new char[]{cRaw, (char)(cRaw + 1)}; - - boolArr = new boolean[]{true, true}; - boolArrRaw = new boolean[]{true, true}; - - strArr = new String[]{str, str + "1"}; - strArrRaw = new String[]{strRaw, strRaw + "1"}; - - uuidArr = new UUID[]{uuid, new UUID(uuid.getMostSignificantBits() + 1, uuid.getLeastSignificantBits() + 1)}; - uuidArrRaw = new UUID[]{uuidRaw, - new UUID(uuidRaw.getMostSignificantBits() + 1, uuidRaw.getLeastSignificantBits() + 1)}; - - dateArr = new Date[]{date, new Date(date.getTime() + 1)}; - dateArrRaw = new Date[]{dateRaw, new Date(dateRaw.getTime() + 1)}; - - eArr = new TestEnum[]{enumValue(i), enumValue(i + 1)}; - eArrRaw = new TestEnum[]{enumValue(iRaw), enumValue(iRaw + 1)}; - - objArr = new Object[]{uuid, new UUID(uuid.getMostSignificantBits() + 1, uuid.getLeastSignificantBits() + 1)}; - objArrRaw = new Object[]{uuidRaw, - new UUID(uuidRaw.getMostSignificantBits() + 1, uuidRaw.getLeastSignificantBits() + 1)}; - - col = Arrays.asList(str, str + "1"); - colRaw = Arrays.asList(strRaw, strRaw + "1"); - - map = new HashMap<>(); - map.put(1, str); - map.put(2, str + "1"); - - mapRaw = new HashMap<>(); - mapRaw.put(1, strRaw); - mapRaw.put(2, strRaw + "1"); - - if (createInner) { - portable1 = new ClientTestPortable(val + 1, false); - portable2 = portable1; - - portableRaw1 = new ClientTestPortable(val + 2, false); - portableRaw2 = portableRaw1; - } - } - - /** {@inheritDoc} */ - @Override public void writePortable(PortableWriter writer) throws PortableException { - writer.writeByte("_b", b); - writer.writeShort("_s", s); - writer.writeInt("_i", i); - writer.writeLong("_l", l); - writer.writeFloat("_f", f); - writer.writeDouble("_d", d); - writer.writeChar("_c", c); - writer.writeBoolean("_bool", bool); - writer.writeString("_str", str); - writer.writeUuid("_uuid", uuid); - writer.writeDate("_date", date); - writer.writeEnum("_enum", e); - writer.writeByteArray("_bArr", bArr); - writer.writeShortArray("_sArr", sArr); - writer.writeIntArray("_iArr", iArr); - writer.writeLongArray("_lArr", lArr); - writer.writeFloatArray("_fArr", fArr); - writer.writeDoubleArray("_dArr", dArr); - writer.writeCharArray("_cArr", cArr); - writer.writeBooleanArray("_boolArr", boolArr); - writer.writeStringArray("_strArr", strArr); - writer.writeUuidArray("_uuidArr", uuidArr); - writer.writeDateArray("_dateArr", dateArr); - writer.writeEnumArray("_eArr", eArr); - writer.writeObjectArray("_objArr", objArr); - writer.writeCollection("_col", col); - writer.writeMap("_map", map); - writer.writeObject("_portable1", portable1); - writer.writeObject("_portable2", portable2); - - PortableRawWriter raw = writer.rawWriter(); - - raw.writeByte(bRaw); - raw.writeShort(sRaw); - raw.writeInt(iRaw); - raw.writeLong(lRaw); - raw.writeFloat(fRaw); - raw.writeDouble(dRaw); - raw.writeChar(cRaw); - raw.writeBoolean(boolRaw); - raw.writeString(strRaw); - raw.writeUuid(uuidRaw); - raw.writeDate(dateRaw); - raw.writeEnum(eRaw); - raw.writeByteArray(bArrRaw); - raw.writeShortArray(sArrRaw); - raw.writeIntArray(iArrRaw); - raw.writeLongArray(lArrRaw); - raw.writeFloatArray(fArrRaw); - raw.writeDoubleArray(dArrRaw); - raw.writeCharArray(cArrRaw); - raw.writeBooleanArray(boolArrRaw); - raw.writeStringArray(strArrRaw); - raw.writeUuidArray(uuidArrRaw); - raw.writeDateArray(dateArrRaw); - raw.writeEnumArray(eArrRaw); - raw.writeObjectArray(objArrRaw); - raw.writeCollection(colRaw); - raw.writeMap(mapRaw); - raw.writeObject(portableRaw1); - raw.writeObject(portableRaw2); - } - - /** {@inheritDoc} */ - @Override public void readPortable(PortableReader reader) throws PortableException { - b = reader.readByte("_b"); - s = reader.readShort("_s"); - i = reader.readInt("_i"); - l = reader.readLong("_l"); - f = reader.readFloat("_f"); - d = reader.readDouble("_d"); - c = reader.readChar("_c"); - bool = reader.readBoolean("_bool"); - str = reader.readString("_str"); - uuid = reader.readUuid("_uuid"); - date = reader.readDate("_date"); - e = reader.readEnum("_enum", TestEnum.class); - bArr = reader.readByteArray("_bArr"); - sArr = reader.readShortArray("_sArr"); - iArr = reader.readIntArray("_iArr"); - lArr = reader.readLongArray("_lArr"); - fArr = reader.readFloatArray("_fArr"); - dArr = reader.readDoubleArray("_dArr"); - cArr = reader.readCharArray("_cArr"); - boolArr = reader.readBooleanArray("_boolArr"); - strArr = reader.readStringArray("_strArr"); - uuidArr = reader.readUuidArray("_uuidArr"); - dateArr = reader.readDateArray("_dateArr"); - eArr = reader.readEnumArray("_eArr", TestEnum.class); - objArr = reader.readObjectArray("_objArr"); - col = reader.readCollection("_col"); - map = reader.readMap("_map"); - portable1 = (ClientTestPortable)reader.readObject("_portable1"); - portable2 = (ClientTestPortable)reader.readObject("_portable2"); - - PortableRawReader raw = reader.rawReader(); - - bRaw = raw.readByte(); - sRaw = raw.readShort(); - iRaw = raw.readInt(); - lRaw = raw.readLong(); - fRaw = raw.readFloat(); - dRaw = raw.readDouble(); - cRaw = raw.readChar(); - boolRaw = raw.readBoolean(); - strRaw = raw.readString(); - uuidRaw = raw.readUuid(); - dateRaw = raw.readDate(); - eRaw = raw.readEnum(TestEnum.class); - bArrRaw = raw.readByteArray(); - sArrRaw = raw.readShortArray(); - iArrRaw = raw.readIntArray(); - lArrRaw = raw.readLongArray(); - fArrRaw = raw.readFloatArray(); - dArrRaw = raw.readDoubleArray(); - cArrRaw = raw.readCharArray(); - boolArrRaw = raw.readBooleanArray(); - strArrRaw = raw.readStringArray(); - uuidArrRaw = raw.readUuidArray(); - dateArrRaw = raw.readDateArray(); - eArrRaw = raw.readEnumArray(TestEnum.class); - objArrRaw = raw.readObjectArray(); - colRaw = raw.readCollection(); - mapRaw = raw.readMap(); - portableRaw1 = (ClientTestPortable)raw.readObject(); - portableRaw2 = (ClientTestPortable)raw.readObject(); - } - - /** - * @param idx Value index. - * @return Enum value. - */ - static TestEnum enumValue(int idx) { - return TestEnum.values()[idx % TestEnum.values().length]; - } - - /** - * Test enum. - */ - private enum TestEnum { - /** */ - VAL1, - - /** */ - VAL2, - - /** */ - VAl3, - - /** */ - VAL4, - - /** */ - VAL5, - - /** */ - VAL6, - - /** */ - VAL7, - - /** */ - VAL8, - - /** */ - VAL9, - - /** */ - VAL10 - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(ClientTestPortable.class, this); - } -} diff --git a/modules/clients/src/test/java/org/apache/ignite/client/ClientTestPortableAffinityKeyTask.java b/modules/clients/src/test/java/org/apache/ignite/client/ClientTestPortableAffinityKeyTask.java index cde3a0deeeb00..0c459f5a01ba8 100644 --- a/modules/clients/src/test/java/org/apache/ignite/client/ClientTestPortableAffinityKeyTask.java +++ b/modules/clients/src/test/java/org/apache/ignite/client/ClientTestPortableAffinityKeyTask.java @@ -20,7 +20,7 @@ import org.apache.ignite.*; import org.apache.ignite.cluster.*; import org.apache.ignite.compute.*; -import org.apache.ignite.portables.*; +import org.gridgain.grid.portables.*; import org.apache.ignite.resources.*; import org.jetbrains.annotations.*; diff --git a/modules/clients/src/test/resources/spring-cache.xml b/modules/clients/src/test/resources/spring-cache.xml index 4f980be33e29b..4df7806d50707 100644 --- a/modules/clients/src/test/resources/spring-cache.xml +++ b/modules/clients/src/test/resources/spring-cache.xml @@ -229,11 +229,11 @@ - + - - + + diff --git a/modules/clients/src/test/resources/spring-server-node.xml b/modules/clients/src/test/resources/spring-server-node.xml index 3b7fb066040ee..9ef4dc8f5b244 100644 --- a/modules/clients/src/test/resources/spring-server-node.xml +++ b/modules/clients/src/test/resources/spring-server-node.xml @@ -76,19 +76,19 @@ - + - - + + - + - + - + diff --git a/modules/clients/src/test/resources/spring-server-ssl-node.xml b/modules/clients/src/test/resources/spring-server-ssl-node.xml index f0da77cbd45a3..f05a6259b99b9 100644 --- a/modules/clients/src/test/resources/spring-server-ssl-node.xml +++ b/modules/clients/src/test/resources/spring-server-ssl-node.xml @@ -324,11 +324,11 @@ - + - - + + diff --git a/modules/core/src/main/java/org/apache/ignite/Ignite.java b/modules/core/src/main/java/org/apache/ignite/Ignite.java index df75d044e5d47..26bb08e58783b 100644 --- a/modules/core/src/main/java/org/apache/ignite/Ignite.java +++ b/modules/core/src/main/java/org/apache/ignite/Ignite.java @@ -196,13 +196,6 @@ public interface Ignite extends AutoCloseable { */ public GridSecurity security(); - /** - * Gets an instance of {@code GridPortables} interface. Available in enterprise edition only. - * - * @return Instance of {@code GridPortables} interface. - */ - public IgnitePortables portables(); - /** * Gets the cache instance for the given name, if one does not * exist {@link IllegalArgumentException} will be thrown. diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java index d6a54fc14b42b..ab44fd12cbb25 100644 --- a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java +++ b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java @@ -294,7 +294,7 @@ public interface IgniteCache extends javax.cache.Cache, IgniteAsyncS * so keys and values will be returned from cache API methods without changes. Therefore, * signature of the projection can contain only following types: *
    - *
  • {@link org.apache.ignite.portables.PortableObject} for portable classes
  • + *
  • {@link org.gridgain.grid.portables.PortableObject} for portable classes
  • *
  • All primitives (byte, int, ...) and there boxed versions (Byte, Integer, ...)
  • *
  • Arrays of primitives (byte[], int[], ...)
  • *
  • {@link String} and array of {@link String}s
  • diff --git a/modules/core/src/main/java/org/apache/ignite/IgnitePortables.java b/modules/core/src/main/java/org/apache/ignite/IgnitePortables.java deleted file mode 100644 index 68579616ff43e..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/IgnitePortables.java +++ /dev/null @@ -1,364 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite; - -import org.apache.ignite.portables.*; -import org.jetbrains.annotations.*; - -import java.sql.*; -import java.util.*; -import java.util.Date; - -/** - * Defines portable objects functionality. With portable objects you are able to: - *
      - *
    • Seamlessly interoperate between Java, .NET, and C++.
    • - *
    • Make any object portable with zero code change to your existing code.
    • - *
    • Nest portable objects within each other.
    • - *
    • Automatically handle {@code circular} or {@code null} references.
    • - *
    • Automatically convert collections and maps between Java, .NET, and C++.
    • - *
    • - * Optionally avoid deserialization of objects on the server side - * (objects are stored in {@link org.apache.ignite.portables.PortableObject} format). - *
    • - *
    • Avoid need to have concrete class definitions on the server side.
    • - *
    • Dynamically change structure of the classes without having to restart the cluster.
    • - *
    • Index into portable objects for querying purposes.
    • - *
    - *

    Working With Portables Directly

    - * Once an object is defined as portable, - * Ignite will always store it in memory in the portable (i.e. binary) format. - * User can choose to work either with the portable format or with the deserialized form - * (assuming that class definitions are present in the classpath). - *

    - * To work with the portable format directly, user should create a special cache projection - * using {@link org.apache.ignite.cache.CacheProjection#keepPortable()} method and then retrieve individual fields as needed: - *

    - * CacheProjection<GridPortableObject.class, GridPortableObject.class> prj = cache.keepPortable();
    - *
    - * // Convert instance of MyKey to portable format.
    - * // We could also use GridPortableBuilder to create
    - * // the key in portable format directly.
    - * GridPortableObject key = grid.portables().toPortable(new MyKey());
    - *
    - * GridPortableObject val = prj.get(key);
    - *
    - * String field = val.field("myFieldName");
    - * 
    - * Alternatively, if we have class definitions in the classpath, we may choose to work with deserialized - * typed objects at all times. In this case we do incur the deserialization cost, however, - * Ignite will only deserialize on the first access and will cache the deserialized object, - * so it does not have to be deserialized again: - *
    - * CacheProjection<MyKey.class, MyValue.class> prj =
    - *     cache.projection(MyKey.class, MyValue.class);
    - *
    - * MyValue val = prj.get(new MyKey());
    - *
    - * // Normal java getter.
    - * String fieldVal = val.getMyFieldName();
    - * 
    - * If we used, for example, one of the automatically handled portable types for a key, like integer, - * and still wanted to work with binary portable format for values, then we would declare cache projection - * as follows: - *
    - * CacheProjection<Integer.class, GridPortableObject.class> prj = cache.keepPortable();
    - * 
    - *

    Automatic Portable Types

    - * Note that only portable classes are converted to {@link org.apache.ignite.portables.PortableObject} format. Following - * classes are never converted (e.g., {@link #toPortable(Object)} method will return original - * object, and instances of these classes will be stored in cache without changes): - *
      - *
    • All primitives (byte, int, ...) and there boxed versions (Byte, Integer, ...)
    • - *
    • Arrays of primitives (byte[], int[], ...)
    • - *
    • {@link String} and array of {@link String}s
    • - *
    • {@link UUID} and array of {@link UUID}s
    • - *
    • {@link Date} and array of {@link Date}s
    • - *
    • {@link Timestamp} and array of {@link Timestamp}s
    • - *
    • Enums and array of enums
    • - *
    • - * Maps, collections and array of objects (but objects inside - * them will still be converted if they are portable) - *
    • - *
    - *

    Working With Maps and Collections

    - * All maps and collections in the portable objects are serialized automatically. When working - * with different platforms, e.g. C++ or .NET, Ignite will automatically pick the most - * adequate collection or map in either language. For example, {@link ArrayList} in Java will become - * {@code List} in C#, {@link LinkedList} in Java is {@link LinkedList} in C#, {@link HashMap} - * in Java is {@code Dictionary} in C#, and {@link TreeMap} in Java becomes {@code SortedDictionary} - * in C#, etc. - *

    Building Portable Objects

    - * Ignite comes with {@link org.apache.ignite.portables.PortableBuilder} which allows to build portable objects dynamically: - *
    - * GridPortableBuilder builder = Ignition.ignite().portables().builder();
    - *
    - * builder.typeId("MyObject");
    - *
    - * builder.stringField("fieldA", "A");
    - * build.intField("fieldB", "B");
    - *
    - * GridPortableObject portableObj = builder.build();
    - * 
    - * For the cases when class definition is present - * in the class path, it is also possible to populate a standard POJO and then - * convert it to portable format, like so: - *
    - * MyObject obj = new MyObject();
    - *
    - * obj.setFieldA("A");
    - * obj.setFieldB(123);
    - *
    - * GridPortableObject portableObj = Ignition.ignite().portables().toPortable(obj);
    - * 
    - * NOTE: you don't need to convert typed objects to portable format before storing - * them in cache, Ignite will do that automatically. - *

    Portable Metadata

    - * Even though Ignite portable protocol only works with hash codes for type and field names - * to achieve better performance, Ignite provides metadata for all portable types which - * can be queried ar runtime via any of the {@link IgnitePortables#metadata(Class) GridPortables.metadata(...)} - * methods. Having metadata also allows for proper formatting of {@code GridPortableObject.toString()} method, - * even when portable objects are kept in binary format only, which may be necessary for audit reasons. - *

    Dynamic Structure Changes

    - * Since objects are always cached in the portable binary format, server does not need to - * be aware of the class definitions. Moreover, if class definitions are not present or not - * used on the server, then clients can continuously change the structure of the portable - * objects without having to restart the cluster. For example, if one client stores a - * certain class with fields A and B, and another client stores the same class with - * fields B and C, then the server-side portable object will have the fields A, B, and C. - * As the structure of a portable object changes, the new fields become available for SQL queries - * automatically. - *

    Configuration

    - * To make any object portable, you have to specify it in {@link org.apache.ignite.portables.PortableConfiguration} - * at startup. The only requirement Ignite imposes is that your object has an empty - * constructor. Note, that since server side does not have to know the class definition, - * you only need to list portable objects in configuration on the client side. However, if you - * list them on the server side as well, then you get the ability to deserialize portable objects - * into concrete types on the server as well as on the client. - *

    - * Here is an example of portable configuration (note that star (*) notation is supported): - *

    - * ...
    - * <!-- Portable objects configuration. -->
    - * <property name="portableConfiguration">
    - *     <bean class="org.apache.ignite.portables.PortableConfiguration">
    - *         <property name="classNames">
    - *             <list>
    - *                 <value>my.package.for.portable.objects.*</value>
    - *                 <value>org.apache.ignite.examples.client.portable.Employee</value>
    - *             </list>
    - *         </property>
    - *     </bean>
    - * </property>
    - * ...
    - * 
    - * or from code: - *
    - * GridConfiguration gridCfg = new GridConfiguration();
    - *
    - * GridPortableConfiguration portCfg = new GridPortableConfiguration();
    - *
    - * portCfg.setClassNames(Arrays.asList(
    - *     Employee.class.getName(),
    - *     Address.class.getName())
    - * );
    - *
    - * gridCfg.setPortableConfiguration(portCfg);
    - * 
    - * You can also specify class name for a portable object via {@link org.apache.ignite.portables.PortableTypeConfiguration}. - * Do it in case if you need to override other configuration properties on per-type level, like - * ID-mapper, or serializer. - *

    Custom Affinity Keys

    - * Often you need to specify an alternate key (not the cache key) for affinity routing whenever - * storing objects in cache. For example, if you are caching {@code Employee} object with - * {@code Organization}, and want to colocate employees with organization they work for, - * so you can process them together, you need to specify an alternate affinity key. - * With portable objects you would have to do it as following: - *
    - * <property name="portableConfiguration">
    - *     <bean class="org.apache.ignite.portables.PortableConfiguration">
    - *         ...
    - *         <property name="typeConfigurations">
    - *             <list>
    - *                 <bean class="org.apache.ignite.portables.PortableTypeConfiguration">
    - *                     <property name="className" value="org.apache.ignite.examples.client.portable.EmployeeKey"/>
    - *                     <property name="affinityKeyFieldName" value="organizationId"/>
    - *                 </bean>
    - *             </list>
    - *         </property>
    - *         ...
    - *     </bean>
    - * </property>
    - * 
    - *

    Serialization

    - * Once portable object is specified in {@link org.apache.ignite.portables.PortableConfiguration}, Ignite will - * be able to serialize and deserialize it. However, you can provide your own custom - * serialization logic by optionally implementing {@link org.apache.ignite.portables.PortableMarshalAware} interface, like so: - *
    - * public class Address implements GridPortableMarshalAware {
    - *     private String street;
    - *     private int zip;
    - *
    - *     // Empty constructor required for portable deserialization.
    - *     public Address() {}
    - *
    - *     @Override public void writePortable(GridPortableWriter writer) throws GridPortableException {
    - *         writer.writeString("street", street);
    - *         writer.writeInt("zip", zip);
    - *     }
    - *
    - *     @Override public void readPortable(GridPortableReader reader) throws GridPortableException {
    - *         street = reader.readString("street");
    - *         zip = reader.readInt("zip");
    - *     }
    - * }
    - * 
    - * Alternatively, if you cannot change class definitions, you can provide custom serialization - * logic in {@link org.apache.ignite.portables.PortableSerializer} either globally in {@link org.apache.ignite.portables.PortableConfiguration} or - * for a specific type via {@link org.apache.ignite.portables.PortableTypeConfiguration} instance. - *

    - * Similar to java serialization you can use {@code writeReplace()} and {@code readResolve()} methods. - *

      - *
    • - * {@code readResolve} is defined as follows: {@code ANY-ACCESS-MODIFIER Object readResolve()}. - * It may be used to replace the de-serialized object by another one of your choice. - *
    • - *
    • - * {@code writeReplace} is defined as follows: {@code ANY-ACCESS-MODIFIER Object writeReplace()}. This method allows the - * developer to provide a replacement object that will be serialized instead of the original one. - *
    • - *
    - * - *

    Custom ID Mappers

    - * Ignite implementation uses name hash codes to generate IDs for class names or field names - * internally. However, in cases when you want to provide your own ID mapping schema, - * you can provide your own {@link org.apache.ignite.portables.PortableIdMapper} implementation. - *

    - * ID-mapper may be provided either globally in {@link org.apache.ignite.portables.PortableConfiguration}, - * or for a specific type via {@link org.apache.ignite.portables.PortableTypeConfiguration} instance. - *

    Query Indexing

    - * Portable objects can be indexed for querying by specifying index fields in - * {@link org.apache.ignite.cache.CacheTypeMetadata} inside of specific {@link org.apache.ignite.configuration.CacheConfiguration} instance, - * like so: - *
    - * ...
    - * <bean class="org.apache.ignite.cache.CacheConfiguration">
    - *     ...
    - *     <property name="queryConfiguration">
    - *         <bean class="CacheQueryConfiguration">
    - *             <property name="typeMetadata">
    - *                 <list>
    - *                     <bean class="CacheTypeMetadata">
    - *                         <property name="type" value="Employee"/>
    - *
    - *                         <!-- Fields to index in ascending order. -->
    - *                         <property name="ascendingFields">
    - *                             <map>
    - *                             	<entry key="name" value="java.lang.String"/>
    - *
    - *                                 <!-- Nested portable objects can also be indexed. -->
    - *                                 <entry key="address.zip" value="java.lang.Integer"/>
    - *                             </map>
    - *                         </property>
    - *                     </bean>
    - *                 </list>
    - *             </property>
    - *         </bean>
    - *     </property>
    - * </bean>
    - * 
    - */ -public interface IgnitePortables { - /** - * Gets type ID for given type name. - * - * @param typeName Type name. - * @return Type ID. - */ - public int typeId(String typeName); - - /** - * Converts provided object to instance of {@link org.apache.ignite.portables.PortableObject}. - *

    - * Note that object's type needs to be configured in {@link org.apache.ignite.portables.PortableConfiguration}. - * - * @param obj Object to convert. - * @return Converted object. - * @throws org.apache.ignite.portables.PortableException In case of error. - */ - public T toPortable(@Nullable Object obj) throws PortableException; - - /** - * Creates new portable builder. - * - * @param typeId ID of the type. - * @return Newly portable builder. - */ - public PortableBuilder builder(int typeId); - - /** - * Creates new portable builder. - * - * @param typeName Type name. - * @return Newly portable builder. - */ - public PortableBuilder builder(String typeName); - - /** - * Creates portable builder initialized by existing portable object. - * - * @param portableObj Portable object to initialize builder. - * @return Portable builder. - */ - public PortableBuilder builder(PortableObject portableObj); - - /** - * Gets metadata for provided class. - * - * @param cls Class. - * @return Metadata. - * @throws org.apache.ignite.portables.PortableException In case of error. - */ - @Nullable public PortableMetadata metadata(Class cls) throws PortableException; - - /** - * Gets metadata for provided class name. - * - * @param typeName Type name. - * @return Metadata. - * @throws org.apache.ignite.portables.PortableException In case of error. - */ - @Nullable public PortableMetadata metadata(String typeName) throws PortableException; - - /** - * Gets metadata for provided type ID. - * - * @param typeId Type ID. - * @return Metadata. - * @throws org.apache.ignite.portables.PortableException In case of error. - */ - @Nullable public PortableMetadata metadata(int typeId) throws PortableException; - - /** - * Gets metadata for all known types. - * - * @return Metadata. - * @throws org.apache.ignite.portables.PortableException In case of error. - */ - public Collection metadata() throws PortableException; -} diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheProjection.java b/modules/core/src/main/java/org/apache/ignite/cache/CacheProjection.java index 014c50858aa5e..1ca705a24a813 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/CacheProjection.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheProjection.java @@ -289,7 +289,7 @@ public interface CacheProjection extends Iterable> { * so keys and values will be returned from cache API methods without changes. Therefore, * signature of the projection can contain only following types: *

      - *
    • {@link org.apache.ignite.portables.PortableObject} for portable classes
    • + *
    • {@link org.gridgain.grid.portables.PortableObject} for portable classes
    • *
    • All primitives (byte, int, ...) and there boxed versions (Byte, Integer, ...)
    • *
    • Arrays of primitives (byte[], int[], ...)
    • *
    • {@link String} and array of {@link String}s
    • diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStore.java b/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStore.java index 367773fe6d33e..114b56e77eb66 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStore.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStore.java @@ -20,7 +20,6 @@ import org.apache.ignite.*; import org.apache.ignite.cache.store.jdbc.*; import org.apache.ignite.lang.*; -import org.apache.ignite.portables.*; import org.apache.ignite.resources.*; import org.apache.ignite.transactions.*; import org.jetbrains.annotations.*; @@ -69,8 +68,8 @@ * } * *

      Working With Portable Objects

      - * When portables are enabled for cache by setting {@link org.apache.ignite.configuration.CacheConfiguration#isPortableEnabled()} to - * {@code true}), all portable keys and values are converted to instances of {@link PortableObject}. + * When portables are enabled for cache by setting {@code org.apache.ignite.configuration.CacheConfiguration#isPortableEnabled()} to + * {@code true}), all portable keys and values are converted to instances of {@code PortableObject}. * Therefore, all cache store methods will take parameters in portable format. To avoid class * cast exceptions, store must have signature compatible with portables. E.g., if you use {@link Integer} * as a key and {@code Value} class as a value (which will be converted to portable format), cache store @@ -84,7 +83,7 @@ * ... * } * - * This behavior can be overridden by setting {@link org.apache.ignite.configuration.CacheConfiguration#setKeepPortableInStore(boolean)} + * This behavior can be overridden by setting {@code org.apache.ignite.configuration.CacheConfiguration#setKeepPortableInStore(boolean)} * flag value to {@code false}. In this case, Ignite will deserialize keys and values stored in portable * format before they are passed to cache store, so that you can use the following cache store signature instead: *
      @@ -100,7 +99,7 @@
        * due to additional serializations and deserializations of portable objects. You will also need to have key
        * and value classes on all nodes since portables will be deserialized when store is invoked.
        * 

      - * Note that only portable classes are converted to {@link PortableObject} format. Following + * Note that only portable classes are converted to {@code PortableObject} format. Following * types are stored in cache without changes and therefore should not affect cache store signature: *

        *
      • All primitives (byte, int, ...) and there boxed versions (Byte, Integer, ...)
      • @@ -116,7 +115,6 @@ * *
      * - * @see IgnitePortables * @see CacheStoreSession */ public abstract class CacheStore implements CacheLoader, CacheWriter { diff --git a/modules/core/src/main/java/org/apache/ignite/client/GridClientCacheFlag.java b/modules/core/src/main/java/org/apache/ignite/client/GridClientCacheFlag.java index 9cf307ed54d39..eeba6583dc84e 100644 --- a/modules/core/src/main/java/org/apache/ignite/client/GridClientCacheFlag.java +++ b/modules/core/src/main/java/org/apache/ignite/client/GridClientCacheFlag.java @@ -43,7 +43,7 @@ public enum GridClientCacheFlag { * Disable deserialization of portable objects on get operations. * If set and portable marshaller is used, {@link GridClientData#get(Object)} * and {@link GridClientData#getAll(Collection)} methods will return - * instances of {@link org.apache.ignite.portables.PortableObject} class instead of user objects. + * instances of {@link org.gridgain.grid.portables.PortableObject} class instead of user objects. * Use this flag if you don't have corresponding class on your client of * if you want to get access to some individual fields, but do not want to * fully deserialize the object. diff --git a/modules/core/src/main/java/org/apache/ignite/client/GridClientConfiguration.java b/modules/core/src/main/java/org/apache/ignite/client/GridClientConfiguration.java index d571f470a6ea3..bf3a01374dc94 100644 --- a/modules/core/src/main/java/org/apache/ignite/client/GridClientConfiguration.java +++ b/modules/core/src/main/java/org/apache/ignite/client/GridClientConfiguration.java @@ -25,7 +25,6 @@ import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.plugin.security.*; -import org.apache.ignite.portables.*; import org.jetbrains.annotations.*; import java.net.*; @@ -117,9 +116,6 @@ public class GridClientConfiguration { /** Daemon flag. */ private boolean daemon; - /** Portable configuration. */ - private PortableConfiguration portableCfg; - /** * Creates default configuration. */ @@ -154,7 +150,6 @@ public GridClientConfiguration(GridClientConfiguration cfg) { topRefreshFreq = cfg.getTopologyRefreshFrequency(); daemon = cfg.isDaemon(); marshaller = cfg.getMarshaller(); - portableCfg = cfg.getPortableConfiguration(); setDataConfigurations(cfg.getDataConfigurations()); } @@ -631,24 +626,6 @@ public void setMarshaller(GridClientMarshaller marshaller) { this.marshaller = marshaller; } - /** - * Gets portable configuration. - * - * @return Portable configuration. - */ - public PortableConfiguration getPortableConfiguration() { - return portableCfg; - } - - /** - * Sets portable configuration. - * - * @param portableCfg Portable configuration. - */ - public void setPortableConfiguration(@Nullable PortableConfiguration portableCfg) { - this.portableCfg = portableCfg; - } - /** * Load client configuration from the properties map. * diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java index 4358fa4c11936..b57b4356c1f4a 100644 --- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java +++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java @@ -25,7 +25,6 @@ import org.apache.ignite.cache.query.*; import org.apache.ignite.cache.store.*; import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.portables.*; import org.apache.ignite.spi.indexing.*; import org.jetbrains.annotations.*; @@ -312,12 +311,6 @@ public class CacheConfiguration extends MutableConfiguration { /** */ private CacheInterceptor interceptor; - /** */ - private boolean portableEnabled; - - /** */ - private boolean keepPortableInStore = true; - /** Query configuration. */ private CacheQueryConfiguration qryCfg; @@ -379,7 +372,6 @@ public CacheConfiguration(CompleteConfiguration cfg) { invalidate = cc.isInvalidate(); isReadThrough = cc.isReadThrough(); isWriteThrough = cc.isWriteThrough(); - keepPortableInStore = cc.isKeepPortableInStore(); listenerConfigurations = cc.listenerConfigurations; loadPrevVal = cc.isLoadPreviousValue(); offHeapMaxMem = cc.getOffHeapMaxMemory(); @@ -389,7 +381,6 @@ public CacheConfiguration(CompleteConfiguration cfg) { name = cc.getName(); nearStartSize = cc.getNearStartSize(); nearEvictPlc = cc.getNearEvictionPolicy(); - portableEnabled = cc.isPortableEnabled(); preloadMode = cc.getPreloadMode(); preloadBatchSize = cc.getPreloadBatchSize(); preloadDelay = cc.getPreloadPartitionedDelay(); @@ -1603,61 +1594,6 @@ public void setInterceptor(CacheInterceptor interceptor) { this.interceptor = interceptor; } - /** - * Flag indicating whether Ignite should store portable keys and values - * as instances of {@link PortableObject}. - * - * @return Portable enabled flag. - */ - public boolean isPortableEnabled() { - return portableEnabled; - } - - /** - * Gets portable enabled flag value. - * - * @param portableEnabled Portable enabled flag value. - */ - public void setPortableEnabled(boolean portableEnabled) { - this.portableEnabled = portableEnabled; - } - - /** - * Flag indicating that {@link CacheStore} implementation - * is working with portable objects instead of Java objects - * if portable mode for this cache is enabled ({@link #isPortableEnabled()} - * flag is {@code true}). Default value of this flag is {@code true}, - * because this is recommended behavior from performance standpoint. - *

      - * If set to {@code false}, Ignite will deserialize keys and - * values stored in portable format before they are passed - * to cache store. - *

      - * Note that setting this flag to {@code false} can simplify - * store implementation in some cases, but it can cause performance - * degradation due to additional serializations and deserializations - * of portable objects. You will also need to have key and value - * classes on all nodes since portables will be deserialized when - * store is called. - *

      - * This flag is ignored if portable mode is disabled for this - * cache ({@link #isPortableEnabled()} flag is {@code false}). - * - * @return Keep portables in store flag. - */ - public boolean isKeepPortableInStore() { - return keepPortableInStore; - } - - /** - * Sets keep portables in store flag. - * - * @param keepPortableInStore Keep portables in store flag. - */ - public void setKeepPortableInStore(boolean keepPortableInStore) { - this.keepPortableInStore = keepPortableInStore; - } - /** * Gets collection of type metadata objects. * diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java index 5ec0924d3bf8c..014daba2aedbd 100644 --- a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java +++ b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java @@ -28,7 +28,6 @@ import org.apache.ignite.services.*; import org.apache.ignite.marshaller.*; import org.apache.ignite.plugin.*; -import org.apache.ignite.portables.*; import org.apache.ignite.spi.authentication.*; import org.apache.ignite.spi.indexing.*; import org.apache.ignite.streamer.*; @@ -512,9 +511,6 @@ public class IgniteConfiguration { /** Client access configuration. */ private ClientConnectionConfiguration clientCfg; - /** Portable configuration. */ - private PortableConfiguration portableCfg; - /** Warmup closure. Will be invoked before actual grid start. */ private IgniteInClosure warmupClos; @@ -606,7 +602,6 @@ public IgniteConfiguration(IgniteConfiguration cfg) { p2pSvc = cfg.getPeerClassLoadingExecutorService(); p2pSvcShutdown = cfg.getPeerClassLoadingExecutorServiceShutdown(); pluginCfgs = cfg.getPluginConfigurations(); - portableCfg = cfg.getPortableConfiguration(); qryCfg = cfg.getQueryConfiguration(); restAccessibleFolders = cfg.getRestAccessibleFolders(); restEnabled = cfg.isRestEnabled(); @@ -3039,20 +3034,6 @@ public void setClientConnectionConfiguration(ClientConnectionConfiguration clien this.clientCfg = clientCfg; } - /** - * @return Portable configuration. - */ - public PortableConfiguration getPortableConfiguration() { - return portableCfg; - } - - /** - * @param portableCfg Portable configuration. - */ - public void setPortableConfiguration(PortableConfiguration portableCfg) { - this.portableCfg = portableCfg; - } - /** * Gets configurations for services to be deployed on the grid. * diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridPortablesImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/GridPortablesImpl.java deleted file mode 100644 index 8dedc4dadf1eb..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridPortablesImpl.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal; - -import org.apache.ignite.*; -import org.apache.ignite.internal.processors.portable.*; -import org.apache.ignite.portables.*; -import org.jetbrains.annotations.*; - -import java.util.*; - -/** - * {@link org.apache.ignite.IgnitePortables} implementation. - */ -public class GridPortablesImpl implements IgnitePortables { - /** */ - private GridKernalContext ctx; - - /** */ - private GridPortableProcessor proc; - - /** - * @param ctx Context. - */ - public GridPortablesImpl(GridKernalContext ctx) { - this.ctx = ctx; - - proc = ctx.portable(); - } - - /** {@inheritDoc} */ - @Override public int typeId(String typeName) { - guard(); - - try { - return proc.typeId(typeName); - } - finally { - unguard(); - } - } - - /** {@inheritDoc} */ - @Override public T toPortable(@Nullable Object obj) throws PortableException { - guard(); - - try { - return (T)proc.marshalToPortable(obj); - } - finally { - unguard(); - } - } - - /** {@inheritDoc} */ - @Override public PortableBuilder builder(int typeId) { - guard(); - - try { - return proc.builder(typeId); - } - finally { - unguard(); - } - } - - /** {@inheritDoc} */ - @Override public PortableBuilder builder(String typeName) { - guard(); - - try { - return proc.builder(typeName); - } - finally { - unguard(); - } - } - - /** {@inheritDoc} */ - @Override public PortableBuilder builder(PortableObject portableObj) { - guard(); - - try { - return proc.builder(portableObj); - } - finally { - unguard(); - } - } - - /** {@inheritDoc} */ - @Nullable @Override public PortableMetadata metadata(Class cls) throws PortableException { - guard(); - - try { - return proc.metadata(proc.typeId(cls.getName())); - } - finally { - unguard(); - } - } - - /** {@inheritDoc} */ - @Nullable @Override public PortableMetadata metadata(String typeName) throws PortableException { - guard(); - - try { - return proc.metadata(proc.typeId(typeName)); - } - finally { - unguard(); - } - } - - /** {@inheritDoc} */ - @Nullable @Override public PortableMetadata metadata(int typeId) throws PortableException { - guard(); - - try { - return proc.metadata(typeId); - } - finally { - unguard(); - } - } - - /** {@inheritDoc} */ - @Override public Collection metadata() throws PortableException { - guard(); - - try { - return proc.metadata(); - } - finally { - unguard(); - } - } - - /** - * @return Portable processor. - */ - public GridPortableProcessor processor() { - return proc; - } - - /** - * ctx.gateway().readLock() - */ - private void guard() { - ctx.gateway().readLock(); - } - - /** - * ctx.gateway().readUnlock() - */ - private void unguard() { - ctx.gateway().readUnlock(); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java index 7425813d8ac1a..c24235bd3c365 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java @@ -212,10 +212,6 @@ public class IgniteKernal extends ClusterGroupAdapter implements IgniteEx, Ignit @GridToStringExclude private GridSecurity security; - /** Portables instance. */ - @GridToStringExclude - private IgnitePortables portables; - /** Kernal gateway. */ @GridToStringExclude private final AtomicReference gw = new AtomicReference<>(); @@ -772,7 +768,6 @@ public void start(final IgniteConfiguration cfg, ExecutorService utilityCachePoo if (ctx.isEnterprise()) { security = new GridSecurityImpl(ctx); - portables = new GridPortablesImpl(ctx); } gw.writeLock(); @@ -3245,14 +3240,6 @@ private boolean runNextNodeCallable(final ConcurrentLinkedQueue compatibleVersions() { return compatibleVers; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java index c2bab47a66eeb..6ef59730ac1bb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java @@ -1795,9 +1795,6 @@ else if (marsh instanceof OptimizedMarshaller && !U.isHotSpot()) { // REST configuration. myCfg.setClientConnectionConfiguration(clientCfg); - // Portable configuration. - myCfg.setPortableConfiguration(cfg.getPortableConfiguration()); - // Hadoop configuration. myCfg.setHadoopConfiguration(cfg.getHadoopConfiguration()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java index ff44528819921..a5261e03ace69 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java @@ -27,7 +27,6 @@ import org.apache.ignite.internal.util.future.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.portables.*; import org.jdk8.backport.*; import org.jetbrains.annotations.*; @@ -277,7 +276,7 @@ public int partition(Object key) { try { key = ctx.marshalToPortable(key); } - catch (PortableException e) { + catch (IgniteException e) { U.error(log, "Failed to marshal key to portable: " + key, e); } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java index 5ee9826714eda..cf268fd0b76f9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java @@ -397,7 +397,7 @@ private AffinityInfo affinityInfoFromNode(@Nullable String cacheName, long topVe f.reset(); m.reset(); - Boolean portableEnabled = U.portableEnabled(n, cacheName); + Boolean portableEnabled = ctx.portable().portableEnabled(n, cacheName); return new AffinityInfo(f, m, t.get3(), portableEnabled != null && portableEnabled); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java index 342220ae998c7..1071d8feaf98d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java @@ -45,7 +45,6 @@ import org.apache.ignite.lang.*; import org.apache.ignite.mxbean.*; import org.apache.ignite.plugin.security.*; -import org.apache.ignite.portables.*; import org.apache.ignite.resources.*; import org.apache.ignite.transactions.*; import org.jdk8.backport.*; @@ -458,10 +457,6 @@ public GridCacheProjectionImpl keepPortable0() { Class keyType, Class valType ) { - if (PortableObject.class.isAssignableFrom(keyType) || PortableObject.class.isAssignableFrom(valType)) - throw new IllegalStateException("Failed to create cache projection for portable objects. " + - "Use keepPortable() method instead."); - if (ctx.deploymentEnabled()) { try { ctx.deploy().registerClasses(keyType, valType); @@ -1564,7 +1559,7 @@ private boolean evictx(K key, GridCacheVersion ver, try { key = (K)ctx.marshalToPortable(key); } - catch (PortableException e) { + catch (IgniteException e) { throw new IgniteException(e); } } @@ -3575,7 +3570,7 @@ public String toString() { try { key0 = (K)ctx.marshalToPortable(key); } - catch (PortableException e) { + catch (IgniteException e) { return new GridFinishedFuture<>(ctx.kernalContext(), e); } } @@ -3843,7 +3838,7 @@ protected void checkJta() throws IgniteCheckedException { ctx.store().loadCache(new CIX3() { @Override public void applyx(K key, V val, @Nullable GridCacheVersion ver) - throws PortableException { + throws IgniteException { assert ver == null; loadEntry(key, val, ver0, p, topVer, replicate, ttl); @@ -4774,14 +4769,8 @@ public boolean containsKey(K key, @Nullable IgnitePredicate> fi if (keyCheck) validateCacheKey(key); - if (ctx.portableEnabled()) { - try { - key = (K)ctx.marshalToPortable(key); - } - catch (PortableException e) { - throw new IgniteException(e); - } - } + if (ctx.portableEnabled()) + key = (K)ctx.marshalToPortable(key); GridCacheEntryEx e = peekEx(key); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAttributes.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAttributes.java index 999ad66df80ba..b0cfb6b0db212 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAttributes.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAttributes.java @@ -157,9 +157,6 @@ public class GridCacheAttributes implements Externalizable { /** Store load previous value flag. */ private boolean loadPrevVal; - /** Portable enabled flag. */ - private boolean portableEnabled; - /** * @param cfg Cache configuration. * @param store Cache store. @@ -176,7 +173,6 @@ public GridCacheAttributes(CacheConfiguration cfg, @Nullable CacheStore st loadPrevVal = cfg.isLoadPreviousValue(); name = cfg.getName(); partDistro = GridCacheUtils.distributionMode(cfg); - portableEnabled = cfg.isPortableEnabled(); preloadBatchSize = cfg.getPreloadBatchSize(); preloadMode = cfg.getPreloadMode(); qryIdxEnabled = cfg.isQueryIndexEnabled(); @@ -521,13 +517,6 @@ public String indexingSpiName() { return indexingSpiName; } - /** - * @return Portable enabled flag. - */ - public boolean portableEnabled() { - return portableEnabled; - } - /** {@inheritDoc} */ @Override public void writeExternal(ObjectOutput out) throws IOException { U.writeEnum(out, atomicityMode); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java index 6b3b084f6f5a9..5370a302aa41d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java @@ -37,6 +37,7 @@ import org.apache.ignite.internal.processors.cache.local.*; import org.apache.ignite.internal.processors.cache.query.*; import org.apache.ignite.internal.processors.cache.query.continuous.*; +import org.apache.ignite.internal.processors.cache.serialization.*; import org.apache.ignite.internal.processors.cache.transactions.*; import org.apache.ignite.internal.processors.cache.version.*; import org.apache.ignite.internal.processors.closure.*; @@ -52,7 +53,6 @@ import org.apache.ignite.lang.*; import org.apache.ignite.marshaller.*; import org.apache.ignite.plugin.security.*; -import org.apache.ignite.portables.*; import org.jetbrains.annotations.*; import javax.cache.configuration.*; @@ -130,6 +130,9 @@ public class GridCacheContext implements Externalizable { /** Replication manager. */ private GridCacheDrManager drMgr; + /** Serialization manager. */ + private IgniteCacheSerializationManager serMgr; + /** JTA manager. */ private CacheJtaManagerAdapter jtaMgr; @@ -1609,7 +1612,7 @@ public void onDeferredDelete(GridCacheEntryEx entry, GridCacheVersion ver) } /** - * @param interceptorRes Result of {@link org.apache.ignite.cache.CacheInterceptor#onBeforeRemove} callback. + * @param interceptorRes Result of {@link CacheInterceptor#onBeforeRemove} callback. * @return {@code True} if interceptor cancels remove. */ public boolean cancelRemove(@Nullable IgniteBiTuple interceptorRes) { @@ -1641,7 +1644,14 @@ public GridPortableProcessor portable() { * @return Portable enabled flag. */ public boolean portableEnabled() { - return cacheCfg.isPortableEnabled(); + return serMgr.portableEnabled(); + } + + /** + * @return Keep portable in store flag. + */ + public boolean keepPortableInStore() { + return serMgr.keepPortableInStore(); } /** @@ -1687,15 +1697,15 @@ public byte[] convertPortableBytes(byte[] bytes) throws IgniteCheckedException { /** * @param obj Object. * @return Portable object. - * @throws PortableException In case of error. + * @throws IgniteException In case of error. */ - @Nullable public Object marshalToPortable(@Nullable Object obj) throws PortableException { + @Nullable public Object marshalToPortable(@Nullable Object obj) throws IgniteException { assert portableEnabled(); if (obj == null) return null; - if (obj instanceof PortableObject || obj instanceof GridCacheInternal) + if (ctx.portable().isPortableObject(obj) || obj instanceof GridCacheInternal) return obj; GridPortableProcessor proc = kernalContext().portable(); @@ -1713,58 +1723,7 @@ public byte[] convertPortableBytes(byte[] bytes) throws IgniteCheckedException { * @return Unwrapped collection. */ public Collection unwrapPortablesIfNeeded(Collection col, boolean keepPortable) { - if (keepPortable || !config().isPortableEnabled()) - return col; - - if (col instanceof ArrayList) - return unwrapPortables((ArrayList)col); - - Collection col0 = new ArrayList<>(col.size()); - - for (Object obj : col) - col0.add(unwrapPortable(obj)); - - return col0; - } - - /** - * Unwraps map. - * - * @param map Map to unwrap. - * @param keepPortable Keep portable flag. - * @return Unwrapped collection. - */ - public Map unwrapPortablesIfNeeded(Map map, boolean keepPortable) { - if (keepPortable || !config().isPortableEnabled()) - return map; - - Map map0 = U.newHashMap(map.size()); - - for (Map.Entry e : map.entrySet()) - map0.put(unwrapPortable(e.getKey()), unwrapPortable(e.getValue())); - - return map0; - } - - /** - * Unwraps array list. - * - * @param col List to unwrap. - * @return Unwrapped list. - */ - private Collection unwrapPortables(ArrayList col) { - int size = col.size(); - - for (int i = 0; i < size; i++) { - Object o = col.get(i); - - Object unwrapped = unwrapPortable(o); - - if (o != unwrapped) - col.set(i, unwrapped); - } - - return col; + return serMgr.unwrapPortablesIfNeeded(col, keepPortable); } /** @@ -1776,53 +1735,7 @@ private Collection unwrapPortables(ArrayList col) { */ @SuppressWarnings("IfMayBeConditional") public Object unwrapPortableIfNeeded(Object o, boolean keepPortable) { - assert !portableEnabled() || o == null || U.isPortableOrCollectionType(o.getClass()); - - if (o == null) - return null; - - if (keepPortable || !portableEnabled()) - return o; - - return unwrapPortable(o); - } - - /** - * @param o Object to unwrap. - * @return Unwrapped object. - */ - private Object unwrapPortable(Object o) { - if (o instanceof Map.Entry) { - Map.Entry entry = (Map.Entry)o; - - Object key = entry.getKey(); - - boolean unwrapped = false; - - if (key instanceof PortableObject) { - key = ((PortableObject)key).deserialize(); - - unwrapped = true; - } - - Object val = entry.getValue(); - - if (val instanceof PortableObject) { - val = ((PortableObject)val).deserialize(); - - unwrapped = true; - } - - return unwrapped ? F.t(key, val) : o; - } - else if (o instanceof Collection) - return unwrapPortablesIfNeeded((Collection)o, false); - else if (o instanceof Map) - return unwrapPortablesIfNeeded((Map)o, false); - else if (o instanceof PortableObject) - return ((PortableObject)o).deserialize(); - - return o; + return serMgr.unwrapPortableIfNeeded(o, keepPortable); } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDefaultAffinityKeyMapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDefaultAffinityKeyMapper.java index d89c9fcbfc4bf..2b6bfc94d0ccf 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDefaultAffinityKeyMapper.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDefaultAffinityKeyMapper.java @@ -19,30 +19,35 @@ import org.apache.ignite.*; import org.apache.ignite.cache.affinity.*; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.internal.*; import org.apache.ignite.internal.util.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.portables.*; import org.apache.ignite.resources.*; import java.lang.annotation.*; import java.lang.reflect.*; /** - * Default key affinity mapper. If key class has annotation {@link org.apache.ignite.cache.affinity.CacheAffinityKeyMapped}, + * Default key affinity mapper. If key class has annotation {@link CacheAffinityKeyMapped}, * then the value of annotated method or field will be used to get affinity value instead * of the key itself. If there is no annotation, then the key is used as is. *

      - * Convenience affinity key adapter, {@link org.apache.ignite.cache.affinity.CacheAffinityKey} can be used in + * Convenience affinity key adapter, {@link CacheAffinityKey} can be used in * conjunction with this mapper to automatically provide custom affinity keys for cache keys. *

      * If non-default affinity mapper is used, is should be provided via - * {@link org.apache.ignite.configuration.CacheConfiguration#getAffinityMapper()} configuration property. + * {@link CacheConfiguration#getAffinityMapper()} configuration property. */ public class GridCacheDefaultAffinityKeyMapper implements CacheAffinityKeyMapper { /** */ private static final long serialVersionUID = 0L; + /** Injected ignite instance. */ + @IgniteInstanceResource + private Ignite ignite; + /** Reflection cache. */ private GridReflectionCache reflectCache = new GridReflectionCache( new P1() { @@ -74,7 +79,7 @@ public class GridCacheDefaultAffinityKeyMapper implements CacheAffinityKeyMapper private transient IgniteLogger log; /** - * If key class has annotation {@link org.apache.ignite.cache.affinity.CacheAffinityKeyMapped}, + * If key class has annotation {@link CacheAffinityKeyMapped}, * then the value of annotated method or field will be used to get affinity value instead * of the key itself. If there is no annotation, then the key is returned as is. * @@ -84,23 +89,10 @@ public class GridCacheDefaultAffinityKeyMapper implements CacheAffinityKeyMapper @Override public Object affinityKey(Object key) { GridArgumentCheck.notNull(key, "key"); - if (key instanceof PortableObject) { - PortableObject po = (PortableObject)key; - - try { - PortableMetadata meta = po.metaData(); - - if (meta != null) { - String affKeyFieldName = meta.affinityKeyFieldName(); + IgniteKernal kernal = (IgniteKernal)ignite; - if (affKeyFieldName != null) - return po.field(affKeyFieldName); - } - } - catch (PortableException e) { - U.error(log, "Failed to get affinity field from portable object: " + key, e); - } - } + if (kernal.context().portable().isPortableObject(key)) + return kernal.context().portable().affinityKey(key); else { try { Object o = reflectCache.firstFieldValue(key); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java index 4efebf9520772..968cc4c72ef45 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java @@ -450,10 +450,6 @@ else if (cc.getPreloadMode() == SYNC) { if (cc.getAtomicityMode() == ATOMIC) assertParameter(cc.getTransactionManagerLookupClassName() == null, "transaction manager can not be used with ATOMIC cache"); - - if (cc.isPortableEnabled() && !ctx.isEnterprise()) - throw new IgniteCheckedException("Portable mode for cache is supported only in Enterprise edition " + - "(set 'portableEnabled' property to 'false') [cacheName=" + cc.getName() + ']'); } /** @@ -1175,9 +1171,6 @@ private void checkCache(ClusterNode rmt) throws IgniteCheckedException { CU.checkAttributeMismatch(log, rmtAttr.cacheName(), rmt, "queryIndexEnabled", "Query index enabled", locAttr.queryIndexEnabled(), rmtAttr.queryIndexEnabled(), true); - CU.checkAttributeMismatch(log, rmtAttr.cacheName(), rmt, "portableEnabled", - "Portables enabled", locAttr.portableEnabled(), rmtAttr.portableEnabled(), true); - if (locAttr.cacheMode() == PARTITIONED) { CU.checkAttributeMismatch(log, rmtAttr.cacheName(), rmt, "evictSynchronized", "Eviction synchronized", locAttr.evictSynchronized(), rmtAttr.evictSynchronized(), diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java index 5e441e17d47c8..b99def7ea1860 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java @@ -32,7 +32,6 @@ import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; -import org.apache.ignite.portables.*; import org.apache.ignite.transactions.*; import org.jetbrains.annotations.*; @@ -416,15 +415,6 @@ private IgnitePredicate> visitor(final IgnitePredicate extends GridCacheManagerAdapter + implements IgniteCacheSerializationManager { /** {@inheritDoc} */ - @Override protected Object executeJob(int gridSize, Object arg) { - Collection args = (Collection)arg; - - Iterator it = args.iterator(); - - assert args.size() == 2 : args.size(); - - boolean expPortable = (Boolean)it.next(); - - ClientTestPortable p; - - if (expPortable) { - PortableObject obj = (PortableObject)it.next(); + @Override public boolean portableEnabled() { + return false; + } - p = obj.deserialize(); - } - else - p = (ClientTestPortable)it.next(); + /** {@inheritDoc} */ + @Override public boolean keepPortableInStore() { + return false; + } - assert p != null; + /** {@inheritDoc} */ + @Override public Object unwrapPortableIfNeeded(Object o, boolean keepPortable) { + return o; + } - return new ClientTestPortable(p.i + 1, true); + /** {@inheritDoc} */ + @Override public Collection unwrapPortablesIfNeeded(Collection col, boolean keepPortable) { + return col; } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/affinity/GridCacheAffinityImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/affinity/GridCacheAffinityImpl.java index 53c933fd4956b..3b2d073f34bd6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/affinity/GridCacheAffinityImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/affinity/GridCacheAffinityImpl.java @@ -23,7 +23,6 @@ import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.portables.*; import org.jetbrains.annotations.*; import java.util.*; @@ -152,7 +151,7 @@ public GridCacheAffinityImpl(GridCacheContext cctx) { try { key = (K)cctx.marshalToPortable(key); } - catch (PortableException e) { + catch (IgniteException e) { U.error(log, "Failed to marshal key to portable: " + key, e); } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/serialization/IgniteCacheSerializationManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/serialization/IgniteCacheSerializationManager.java new file mode 100644 index 0000000000000..974cfd7b26e94 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/serialization/IgniteCacheSerializationManager.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache.serialization; + +import org.apache.ignite.internal.processors.cache.*; + +import java.util.*; + +/** + * + */ +public interface IgniteCacheSerializationManager extends GridCacheManager { + /** + * TODO this method should be removed from Ignite internals as a part of work on cache objects. + * + * @return Portable enabled flag for cache. + */ + public boolean portableEnabled(); + + /** + * @return {@code True} if portable format should be preserved when passing values to cache store. + */ + public boolean keepPortableInStore(); + + + public Object unwrapPortableIfNeeded(Object o, boolean keepPortable); + + /** + * Unwraps collection. + * + * @param col Collection to unwrap. + * @param keepPortable Keep portable flag. + * @return Unwrapped collection. + */ + public Collection unwrapPortablesIfNeeded(Collection col, boolean keepPortable); +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java index 8b98d41af33b3..71eda9730863c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java @@ -34,7 +34,6 @@ import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; import org.apache.ignite.plugin.security.*; -import org.apache.ignite.portables.*; import org.apache.ignite.transactions.*; import org.jetbrains.annotations.*; @@ -2515,7 +2514,7 @@ else if (cacheCtx.portableEnabled()) { map0.put(key, val); } } - catch (PortableException e) { + catch (IgniteException e) { return new GridFinishedFuture<>(cctx.kernalContext(), e); } } @@ -2532,7 +2531,7 @@ else if (cacheCtx.portableEnabled()) { invokeMap0.put(key, e.getValue()); } } - catch (PortableException e) { + catch (IgniteException e) { return new GridFinishedFuture<>(cctx.kernalContext(), e); } } @@ -2736,7 +2735,7 @@ else if (cacheCtx.portableEnabled()) { else keys0 = null; } - catch (PortableException e) { + catch (IgniteException e) { return new GridFinishedFuture<>(cctx.kernalContext(), e); } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/IgniteDataLoaderImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/IgniteDataLoaderImpl.java index ca9d1a1893695..c7002f8c91654 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/IgniteDataLoaderImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/IgniteDataLoaderImpl.java @@ -176,11 +176,7 @@ public IgniteDataLoaderImpl( if (node == null) throw new IllegalStateException("Cache doesn't exist: " + cacheName); - GridCacheAttributes attrs = U.cacheAttributes(node, cacheName); - - assert attrs != null : cacheName; - - portableEnabled = attrs.portableEnabled(); + portableEnabled = ctx.portable().portableEnabled(node, cacheName); discoLsnr = new GridLocalEventListener() { @Override public void onEvent(Event evt) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/IgnitePluginProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/IgnitePluginProcessor.java index 9c6dc0e2636e8..7ac8a7350fd6c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/IgnitePluginProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/IgnitePluginProcessor.java @@ -161,7 +161,9 @@ public T pluginContextForProvider(PluginProvider provi */ public T createComponent(Class cls) { for (PluginProvider plugin : plugins.values()) { - T comp = (T)plugin.createComponent(cls); + PluginContext ctx = pluginContextForProvider(plugin); + + T comp = (T)plugin.createComponent(ctx, cls); if (comp != null) return comp; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/portable/GridPortableProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/portable/GridPortableProcessor.java index 594b7679860fb..8dc3fa9263a5d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/portable/GridPortableProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/portable/GridPortableProcessor.java @@ -17,13 +17,13 @@ package org.apache.ignite.internal.processors.portable; +import org.apache.ignite.*; import org.apache.ignite.client.marshaller.*; +import org.apache.ignite.cluster.*; import org.apache.ignite.internal.processors.*; -import org.apache.ignite.portables.*; import org.jetbrains.annotations.*; import java.nio.*; -import java.util.*; /** * Portable processor. @@ -35,45 +35,51 @@ public interface GridPortableProcessor extends GridProcessor { */ public int typeId(String typeName); + /** + * @param obj Object to get type ID for. + * @return Type ID. + */ + public int typeId(Object obj); + /** * @param obj Object to marshal. * @param trim If {@code true} trims result byte buffer. * @return Object bytes. - * @throws org.apache.ignite.portables.PortableException In case of error. + * @throws IgniteException In case of error. */ - public ByteBuffer marshal(@Nullable Object obj, boolean trim) throws PortableException; + public ByteBuffer marshal(@Nullable Object obj, boolean trim) throws IgniteException; /** * @param arr Byte array. * @param off Offset. * @return Unmarshalled object. - * @throws org.apache.ignite.portables.PortableException In case of error. + * @throws IgniteException In case of error. */ - public Object unmarshal(byte[] arr, int off) throws PortableException; + public Object unmarshal(byte[] arr, int off) throws IgniteException; /** * @param ptr Offheap pointer. * @param forceHeap If {@code true} creates heap-based object. * @return Unmarshalled object. - * @throws org.apache.ignite.portables.PortableException In case of error. + * @throws IgniteException In case of error. */ - public Object unmarshal(long ptr, boolean forceHeap) throws PortableException; + public Object unmarshal(long ptr, boolean forceHeap) throws IgniteException; /** * Converts temporary offheap object to heap-based. * * @param obj Object. * @return Heap-based object. - * @throws org.apache.ignite.portables.PortableException In case of error. + * @throws IgniteException In case of error. */ - @Nullable public Object unwrapTemporary(@Nullable Object obj) throws PortableException; + @Nullable public Object unwrapTemporary(@Nullable Object obj) throws IgniteException; /** * @param obj Object to marshal. * @return Portable object. - * @throws org.apache.ignite.portables.PortableException In case of error. + * @throws IgniteException In case of error. */ - public Object marshalToPortable(@Nullable Object obj) throws PortableException; + public Object marshalToPortable(@Nullable Object obj) throws IgniteException; /** * @param obj Object (portable or not). @@ -94,57 +100,31 @@ public interface GridPortableProcessor extends GridProcessor { public boolean isPortable(GridClientMarshaller marsh); /** - * @return Builder. + * @param node Node to check. + * @param cacheName Cache name to check. + * @return {@code True} if portable enabled for the specified cache, {@code false} otherwise. */ - public PortableBuilder builder(int typeId); + public boolean portableEnabled(ClusterNode node, String cacheName); /** - * @return Builder. - */ - public PortableBuilder builder(String clsName); - - /** - * Creates builder initialized by existing portable object. + * Checks whether object is portable object. * - * @param portableObj Portable object to edit. - * @return Portable builder. - */ - public PortableBuilder builder(PortableObject portableObj); - - /** - * @param typeId Type ID. - * @param newMeta New meta data. - * @throws org.apache.ignite.portables.PortableException In case of error. - */ - public void addMeta(int typeId, final PortableMetadata newMeta) throws PortableException; - - /** - * @param typeId Type ID. - * @param typeName Type name. - * @param affKeyFieldName Affinity key field name. - * @param fieldTypeIds Fields map. - * @throws org.apache.ignite.portables.PortableException In case of error. + * @param obj Object to check. + * @return {@code True} if object is already a portable object, {@code false} otherwise. */ - public void updateMetaData(int typeId, String typeName, @Nullable String affKeyFieldName, - Map fieldTypeIds) throws PortableException; + public boolean isPortableObject(Object obj); /** - * @param typeId Type ID. - * @return Meta data. - * @throws org.apache.ignite.portables.PortableException In case of error. - */ - @Nullable public PortableMetadata metadata(int typeId) throws PortableException; - - /** - * @param typeIds Type ID. - * @return Meta data. - * @throws org.apache.ignite.portables.PortableException In case of error. + * Gets affinity key of portable object. + * + * @param obj Object to get affinity key for. + * @return Affinity key. */ - public Map metadata(Collection typeIds) throws PortableException; + public Object affinityKey(Object obj); /** - * @return Metadata for all types. - * @throws org.apache.ignite.portables.PortableException In case of error. + * @param obj Portable object to get field from. + * @return Field value. */ - public Collection metadata() throws PortableException; + public Object field(Object obj, String fieldName); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/portable/os/GridOsPortableProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/portable/os/GridOsPortableProcessor.java index 46bc955f9df23..2442eb2486ac8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/portable/os/GridOsPortableProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/portable/os/GridOsPortableProcessor.java @@ -17,15 +17,15 @@ package org.apache.ignite.internal.processors.portable.os; +import org.apache.ignite.*; import org.apache.ignite.client.marshaller.*; +import org.apache.ignite.cluster.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.*; import org.apache.ignite.internal.processors.portable.*; -import org.apache.ignite.portables.*; import org.jetbrains.annotations.*; import java.nio.*; -import java.util.*; /** * No-op implementation of {@link GridPortableProcessor}. @@ -44,27 +44,27 @@ public GridOsPortableProcessor(GridKernalContext ctx) { } /** {@inheritDoc} */ - @Override public ByteBuffer marshal(@Nullable Object obj, boolean trim) throws PortableException { + @Override public ByteBuffer marshal(@Nullable Object obj, boolean trim) throws IgniteException { return null; } /** {@inheritDoc} */ - @Nullable @Override public Object unmarshal(byte[] arr, int off) throws PortableException { + @Nullable @Override public Object unmarshal(byte[] arr, int off) throws IgniteException { return null; } /** {@inheritDoc} */ - @Override public Object unmarshal(long ptr, boolean forceHeap) throws PortableException { + @Override public Object unmarshal(long ptr, boolean forceHeap) throws IgniteException { return null; } /** {@inheritDoc} */ - @Override public Object unwrapTemporary(Object obj) throws PortableException { + @Override public Object unwrapTemporary(Object obj) throws IgniteException { return null; } /** {@inheritDoc} */ - @Nullable @Override public Object marshalToPortable(@Nullable Object obj) throws PortableException { + @Nullable @Override public Object marshalToPortable(@Nullable Object obj) throws IgniteException { return obj; } @@ -84,43 +84,27 @@ public GridOsPortableProcessor(GridKernalContext ctx) { } /** {@inheritDoc} */ - @Override public PortableBuilder builder(int typeId) { - return null; - } - - /** {@inheritDoc} */ - @Override public PortableBuilder builder(String clsName) { - return null; - } - - /** {@inheritDoc} */ - @Override public PortableBuilder builder(PortableObject portableObj) { - return null; + @Override public boolean portableEnabled(ClusterNode node, String cacheName) { + return false; } /** {@inheritDoc} */ - @Override public void addMeta(int typeId, PortableMetadata newMeta) throws PortableException { - // No-op. + @Override public boolean isPortableObject(Object obj) { + return false; } /** {@inheritDoc} */ - @Override public void updateMetaData(int typeId, String typeName, String affKeyFieldName, - Map fieldTypeIds) throws PortableException { - // No-op. + @Override public Object affinityKey(Object obj) { + return obj; } /** {@inheritDoc} */ - @Nullable @Override public PortableMetadata metadata(int typeId) { - return null; + @Override public int typeId(Object obj) { + return 0; } /** {@inheritDoc} */ - @Override public Map metadata(Collection typeIds) { + @Override public Object field(Object obj, String fieldName) { return null; } - - /** {@inheritDoc} */ - @Override public Collection metadata() throws PortableException { - return Collections.emptyList(); - } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java index d1fb0c1aadf4d..af92335093a52 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java @@ -32,7 +32,6 @@ import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.internal.util.worker.*; import org.apache.ignite.lang.*; -import org.apache.ignite.portables.*; import org.apache.ignite.spi.indexing.*; import org.jdk8.backport.*; import org.jetbrains.annotations.*; @@ -290,10 +289,8 @@ public void store(final String space, final K key, @Nullable byte[] keyBy } if (id == null) { - if (val instanceof PortableObject) { - PortableObject portable = (PortableObject)val; - - int typeId = portable.typeId(); + if (ctx.portable().isPortableObject(val)) { + int typeId = ctx.portable().typeId(val); String typeName = portableName(typeId); @@ -325,13 +322,13 @@ public void store(final String space, final K key, @Nullable byte[] keyBy d.keyClass(keyCls); d.valueClass(valCls); - if (key instanceof PortableObject) { - PortableObject portableKey = (PortableObject)key; + if (ctx.portable().isPortableObject(key)) { + int typeId = ctx.portable().typeId(key); - String typeName = portableName(portableKey.typeId()); + String typeName = portableName(typeId); if (typeName != null) { - CacheTypeMetadata keyMeta = declaredType(space, portableKey.typeId()); + CacheTypeMetadata keyMeta = declaredType(space, typeId); if (keyMeta != null) processPortableMeta(true, keyMeta, d); @@ -346,13 +343,13 @@ public void store(final String space, final K key, @Nullable byte[] keyBy processClassMeta(true, d.keyCls, keyMeta, d); } - if (val instanceof PortableObject) { - PortableObject portableVal = (PortableObject)val; + if (ctx.portable().isPortableObject(val)) { + int typeId = ctx.portable().typeId(val); - String typeName = portableName(portableVal.typeId()); + String typeName = portableName(typeId); if (typeName != null) { - CacheTypeMetadata valMeta = declaredType(space, portableVal.typeId()); + CacheTypeMetadata valMeta = declaredType(space, typeId); d.name(typeName); @@ -922,7 +919,7 @@ static void processClassMeta(boolean key, Class cls, CacheTypeMetadata meta, * @param d Type descriptor. * @throws IgniteCheckedException If failed. */ - static void processPortableMeta(boolean key, CacheTypeMetadata meta, TypeDescriptor d) + private void processPortableMeta(boolean key, CacheTypeMetadata meta, TypeDescriptor d) throws IgniteCheckedException { for (Map.Entry> entry : meta.getAscendingFields().entrySet()) { PortableProperty prop = buildPortableProperty(entry.getKey(), entry.getValue()); @@ -996,7 +993,7 @@ static void processPortableMeta(boolean key, CacheTypeMetadata meta, TypeDescrip * @param resType Result type. * @return Portable property. */ - static PortableProperty buildPortableProperty(String pathStr, Class resType) { + private PortableProperty buildPortableProperty(String pathStr, Class resType) { String[] path = pathStr.split("\\."); PortableProperty res = null; @@ -1240,7 +1237,7 @@ public boolean knowsClass(Class cls) { /** * */ - private static class PortableProperty extends Property { + private class PortableProperty extends Property { /** Property name. */ private String propName; @@ -1271,11 +1268,11 @@ private PortableProperty(String propName, PortableProperty parent, Class type if (obj == null) return null; - if (!(obj instanceof PortableObject)) + if (!ctx.portable().isPortableObject(obj)) throw new IgniteCheckedException("Non-portable object received as a result of property extraction " + "[parent=" + parent + ", propName=" + propName + ", obj=" + obj + ']'); - return ((PortableObject)obj).field(propName); + return ctx.portable().field(obj, propName); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java index f20bf043100b0..9c8bcc3262999 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java @@ -28,7 +28,6 @@ import org.apache.ignite.internal.processors.rest.handlers.cache.*; import org.apache.ignite.internal.processors.rest.handlers.datastructures.*; import org.apache.ignite.internal.processors.rest.handlers.log.*; -import org.apache.ignite.internal.processors.rest.handlers.metadata.*; import org.apache.ignite.internal.processors.rest.handlers.task.*; import org.apache.ignite.internal.processors.rest.handlers.top.*; import org.apache.ignite.internal.processors.rest.handlers.version.*; @@ -255,7 +254,6 @@ public GridRestProcessor(GridKernalContext ctx) { addHandler(new GridTopologyCommandHandler(ctx)); addHandler(new GridVersionCommandHandler(ctx)); addHandler(new GridLogCommandHandler(ctx)); - addHandler(new GridPortableMetadataHandler(ctx)); addHandler(new DataStructuresCommandHandler(ctx)); // Start protocols. @@ -331,8 +329,8 @@ public GridRestProcessor(GridKernalContext ctx) { } /** - * Applies {@link org.apache.ignite.configuration.ClientMessageInterceptor} - * from {@link org.apache.ignite.configuration.ClientConnectionConfiguration#getClientMessageInterceptor()} + * Applies {@link ClientMessageInterceptor} + * from {@link ClientConnectionConfiguration#getClientMessageInterceptor()} * to all user parameters in the request. * * @param req Client request. @@ -378,8 +376,8 @@ else if (req instanceof GridRestTaskRequest) { } /** - * Applies {@link org.apache.ignite.configuration.ClientMessageInterceptor} from - * {@link org.apache.ignite.configuration.ClientConnectionConfiguration#getClientMessageInterceptor()} + * Applies {@link ClientMessageInterceptor} from + * {@link ClientConnectionConfiguration#getClientMessageInterceptor()} * to all user objects in the response. * * @param res Response. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientAbstractMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientAbstractMessage.java index 9f49377a2adfc..c6557bc7971e0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientAbstractMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientAbstractMessage.java @@ -18,7 +18,6 @@ package org.apache.ignite.internal.processors.rest.client.message; import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.portables.*; import java.io.*; import java.util.*; @@ -26,7 +25,7 @@ /** * This class provides implementation for commit message fields and cannot be used directly. */ -public abstract class GridClientAbstractMessage implements GridClientMessage, Externalizable, PortableMarshalAware { +public abstract class GridClientAbstractMessage implements GridClientMessage, Externalizable { /** */ private static final long serialVersionUID = 0L; @@ -96,20 +95,6 @@ public abstract class GridClientAbstractMessage implements GridClientMessage, Ex sesTok = U.readByteArray(in); } - /** {@inheritDoc} */ - @Override public void writePortable(PortableWriter writer) throws PortableException { - PortableRawWriter raw = writer.rawWriter(); - - raw.writeByteArray(sesTok); - } - - /** {@inheritDoc} */ - @Override public void readPortable(PortableReader reader) throws PortableException { - PortableRawReader raw = reader.rawReader(); - - sesTok = raw.readByteArray(); - } - /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridClientAbstractMessage.class, this, super.toString()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientAuthenticationRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientAuthenticationRequest.java index c9f28fc09ec79..8eed15756f7b8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientAuthenticationRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientAuthenticationRequest.java @@ -18,7 +18,6 @@ package org.apache.ignite.internal.processors.rest.client.message; import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.portables.*; import java.io.*; @@ -60,24 +59,6 @@ public void credentials(Object cred) { cred = in.readObject(); } - /** {@inheritDoc} */ - @Override public void writePortable(PortableWriter writer) throws PortableException { - super.writePortable(writer); - - PortableRawWriter raw = writer.rawWriter(); - - raw.writeObject(cred); - } - - /** {@inheritDoc} */ - @Override public void readPortable(PortableReader reader) throws PortableException { - super.readPortable(reader); - - PortableRawReader raw = reader.rawReader(); - - cred = raw.readObject(); - } - /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridClientAuthenticationRequest.class, this, super.toString()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientCacheQueryRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientCacheQueryRequest.java index f689b691d3410..b62d2b535a37c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientCacheQueryRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientCacheQueryRequest.java @@ -18,7 +18,6 @@ package org.apache.ignite.internal.processors.rest.client.message; import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.portables.*; import org.jetbrains.annotations.*; import java.io.*; @@ -320,50 +319,6 @@ public void queryArguments(Object[] qryArgs) { this.qryArgs = qryArgs; } - /** {@inheritDoc} */ - @Override public void readPortable(PortableReader reader) throws PortableException { - super.readPortable(reader); - - PortableRawReader rawReader = reader.rawReader(); - - qryId = rawReader.readLong(); - op = GridQueryOperation.fromOrdinal(rawReader.readInt()); - type = GridQueryType.fromOrdinal(rawReader.readInt()); - cacheName = rawReader.readString(); - clause = rawReader.readString(); - pageSize = rawReader.readInt(); - timeout = rawReader.readLong(); - includeBackups = rawReader.readBoolean(); - enableDedup = rawReader.readBoolean(); - keepPortable = rawReader.readBoolean(); - clsName = rawReader.readString(); - rmtReducerClsName = rawReader.readString(); - rmtTransformerClsName = rawReader.readString(); - qryArgs = rawReader.readObjectArray(); - } - - /** {@inheritDoc} */ - @Override public void writePortable(PortableWriter writer) throws PortableException { - super.writePortable(writer); - - PortableRawWriter rawWriter = writer.rawWriter(); - - rawWriter.writeLong(qryId); - rawWriter.writeInt(op.ordinal()); - rawWriter.writeInt(type == null ? -1 : type.ordinal()); - rawWriter.writeString(cacheName); - rawWriter.writeString(clause); - rawWriter.writeInt(pageSize); - rawWriter.writeLong(timeout); - rawWriter.writeBoolean(includeBackups); - rawWriter.writeBoolean(enableDedup); - rawWriter.writeBoolean(keepPortable); - rawWriter.writeString(clsName); - rawWriter.writeString(rmtReducerClsName); - rawWriter.writeString(rmtTransformerClsName); - rawWriter.writeObjectArray(qryArgs); - } - /** {@inheritDoc} */ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { super.readExternal(in); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientCacheRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientCacheRequest.java index 0bfe08a11ca14..58e973b399113 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientCacheRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientCacheRequest.java @@ -17,9 +17,7 @@ package org.apache.ignite.internal.processors.rest.client.message; -import org.apache.ignite.internal.util.portable.*; import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.portables.*; import org.jetbrains.annotations.*; import java.io.*; @@ -229,52 +227,6 @@ public int cacheFlagsOn() { return cacheFlagsOn; } - /** {@inheritDoc} */ - @Override public void writePortable(PortableWriter writer) throws PortableException { - super.writePortable(writer); - - PortableRawWriterEx raw = (PortableRawWriterEx)writer.rawWriter(); - - raw.writeInt(op.ordinal()); - raw.writeString(cacheName); - raw.writeInt(cacheFlagsOn); - raw.writeObjectDetached(key); - raw.writeObjectDetached(val); - raw.writeObjectDetached(val2); - - raw.writeInt(vals != null ? vals.size() : -1); - - if (vals != null) { - for (Map.Entry e : vals.entrySet()) { - raw.writeObjectDetached(e.getKey()); - raw.writeObjectDetached(e.getValue()); - } - } - } - - /** {@inheritDoc} */ - @Override public void readPortable(PortableReader reader) throws PortableException { - super.readPortable(reader); - - PortableRawReaderEx raw = (PortableRawReaderEx)reader.rawReader(); - - op = GridCacheOperation.fromOrdinal(raw.readInt()); - cacheName = raw.readString(); - cacheFlagsOn = raw.readInt(); - key = raw.readObjectDetached(); - val = raw.readObjectDetached(); - val2 = raw.readObjectDetached(); - - int valsSize = raw.readInt(); - - if (valsSize >= 0) { - vals = U.newHashMap(valsSize); - - for (int i = 0; i < valsSize; i++) - vals.put(raw.readObjectDetached(), raw.readObjectDetached()); - } - } - /** {@inheritDoc} */ @SuppressWarnings("deprecation") @Override public void writeExternal(ObjectOutput out) throws IOException { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientGetMetaDataRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientGetMetaDataRequest.java deleted file mode 100644 index b4ee5dc3e9149..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientGetMetaDataRequest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.rest.client.message; - -import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.portables.*; - -import java.util.*; - -/** - * Metadata request. - */ -public class GridClientGetMetaDataRequest extends GridClientAbstractMessage { - /** */ - private static final long serialVersionUID = 0L; - - /** */ - private Collection typeIds; - - /** - * @return Type IDs. - */ - public Collection typeIds() { - return typeIds; - } - - /** {@inheritDoc} */ - @Override public void writePortable(PortableWriter writer) throws PortableException { - super.writePortable(writer); - - PortableRawWriter raw = writer.rawWriter(); - - raw.writeCollection(typeIds); - } - - /** {@inheritDoc} */ - @Override public void readPortable(PortableReader reader) throws PortableException { - super.readPortable(reader); - - PortableRawReader raw = reader.rawReader(); - - typeIds = raw.readCollection(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(GridClientGetMetaDataRequest.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientLogRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientLogRequest.java index 2bd8735e1d6b2..af931c8bbcb74 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientLogRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientLogRequest.java @@ -18,7 +18,6 @@ package org.apache.ignite.internal.processors.rest.client.message; import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.portables.*; import java.io.*; @@ -80,28 +79,6 @@ public void to(int to) { this.to = to; } - /** {@inheritDoc} */ - @Override public void writePortable(PortableWriter writer) throws PortableException { - super.writePortable(writer); - - PortableRawWriter raw = writer.rawWriter(); - - raw.writeString(path); - raw.writeInt(from); - raw.writeInt(to); - } - - /** {@inheritDoc} */ - @Override public void readPortable(PortableReader reader) throws PortableException { - super.readPortable(reader); - - PortableRawReader raw = reader.rawReader(); - - path = raw.readString(); - from = raw.readInt(); - to = raw.readInt(); - } - /** {@inheritDoc} */ @Override public void writeExternal(ObjectOutput out) throws IOException { super.writeExternal(out); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMetaDataResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMetaDataResponse.java deleted file mode 100644 index b74d922997c37..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMetaDataResponse.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.rest.client.message; - -import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.portables.*; - -import java.util.*; - -/** - * Metadata response. - */ -public class GridClientMetaDataResponse implements PortableMarshalAware { - /** */ - private Map meta; - - /** - * @param meta Portable objects metadata. - */ - public void metaData(Map meta) { - this.meta = meta; - } - - /** {@inheritDoc} */ - @Override public void writePortable(PortableWriter writer) throws PortableException { - PortableRawWriter raw = writer.rawWriter(); - - raw.writeMap(meta); - } - - /** {@inheritDoc} */ - @Override public void readPortable(PortableReader reader) throws PortableException { - PortableRawReader raw = reader.rawReader(); - - meta = raw.readMap(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(GridClientMetaDataResponse.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientNodeBean.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientNodeBean.java index bedbb97df4a12..6605a151fc29d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientNodeBean.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientNodeBean.java @@ -18,7 +18,6 @@ package org.apache.ignite.internal.processors.rest.client.message; import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.portables.*; import java.io.*; import java.util.*; @@ -26,7 +25,7 @@ /** * Node bean. */ -public class GridClientNodeBean implements Externalizable, PortableMarshalAware { +public class GridClientNodeBean implements Externalizable { /** */ private static final long serialVersionUID = 0L; @@ -254,43 +253,6 @@ public void setTcpPort(int tcpPort) { return nodeId == null ? other.nodeId == null : nodeId.equals(other.nodeId); } - /** {@inheritDoc} */ - @Override public void writePortable(PortableWriter writer) throws PortableException { - PortableRawWriter raw = writer.rawWriter(); - - raw.writeInt(tcpPort); - raw.writeInt(replicaCnt); - raw.writeString(dfltCacheMode); - raw.writeMap(attrs); - raw.writeMap(caches); - raw.writeCollection(tcpAddrs); - raw.writeCollection(tcpHostNames); - raw.writeUuid(nodeId); - raw.writeObject(consistentId); - raw.writeObject(metrics); - } - - /** {@inheritDoc} */ - @Override public void readPortable(PortableReader reader) throws PortableException { - PortableRawReader raw = reader.rawReader(); - - tcpPort = raw.readInt(); - replicaCnt = raw.readInt(); - - dfltCacheMode = raw.readString(); - - attrs = raw.readMap(); - caches = raw.readMap(); - - tcpAddrs = raw.readCollection(); - tcpHostNames = raw.readCollection(); - - nodeId = raw.readUuid(); - - consistentId = raw.readObject(); - metrics = (GridClientNodeMetricsBean)raw.readObject(); - } - /** {@inheritDoc} */ @Override public void writeExternal(ObjectOutput out) throws IOException { out.writeInt(tcpPort); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientNodeMetricsBean.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientNodeMetricsBean.java index 98a499a47d5ab..91bfd6a13de49 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientNodeMetricsBean.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientNodeMetricsBean.java @@ -17,14 +17,12 @@ package org.apache.ignite.internal.processors.rest.client.message; -import org.apache.ignite.portables.*; - import java.io.*; /** * Node metrics bean. */ -public class GridClientNodeMetricsBean implements Externalizable, PortableMarshalAware { +public class GridClientNodeMetricsBean implements Externalizable { /** */ private static final long serialVersionUID = 0L; @@ -1348,122 +1346,6 @@ public boolean equals(Object obj) { toString(); } - /** {@inheritDoc} */ - @Override public void writePortable(PortableWriter writer) throws PortableException { - PortableRawWriter raw = writer.rawWriter(); - - raw.writeLong(lastUpdateTime); - raw.writeInt(maxActiveJobs); - raw.writeInt(curActiveJobs); - raw.writeFloat(avgActiveJobs); - raw.writeInt(maxWaitingJobs); - raw.writeInt(curWaitingJobs); - raw.writeFloat(avgWaitingJobs); - raw.writeInt(maxRejectedJobs); - raw.writeInt(curRejectedJobs); - raw.writeFloat(avgRejectedJobs); - raw.writeInt(maxCancelledJobs); - raw.writeInt(curCancelledJobs); - raw.writeFloat(avgCancelledJobs); - raw.writeInt(totalRejectedJobs); - raw.writeInt(totalCancelledJobs); - raw.writeInt(totalExecutedJobs); - raw.writeLong(maxJobWaitTime); - raw.writeLong(curJobWaitTime); - raw.writeDouble(avgJobWaitTime); - raw.writeLong(maxJobExecTime); - raw.writeLong(curJobExecTime); - raw.writeDouble(avgJobExecTime); - raw.writeInt(totalExecTasks); - raw.writeLong(totalIdleTime); - raw.writeLong(curIdleTime); - raw.writeInt(availProcs); - raw.writeDouble(load); - raw.writeDouble(avgLoad); - raw.writeDouble(gcLoad); - raw.writeLong(heapInit); - raw.writeLong(heapUsed); - raw.writeLong(heapCommitted); - raw.writeLong(heapMax); - raw.writeLong(nonHeapInit); - raw.writeLong(nonHeapUsed); - raw.writeLong(nonHeapCommitted); - raw.writeLong(nonHeapMax); - raw.writeLong(upTime); - raw.writeLong(startTime); - raw.writeLong(nodeStartTime); - raw.writeInt(threadCnt); - raw.writeInt(peakThreadCnt); - raw.writeLong(startedThreadCnt); - raw.writeInt(daemonThreadCnt); - raw.writeLong(fileSysFreeSpace); - raw.writeLong(fileSysTotalSpace); - raw.writeLong(fileSysUsableSpace); - raw.writeLong(lastDataVer); - raw.writeInt(sentMsgsCnt); - raw.writeLong(sentBytesCnt); - raw.writeInt(rcvdMsgsCnt); - raw.writeLong(rcvdBytesCnt); - } - - /** {@inheritDoc} */ - @Override public void readPortable(PortableReader reader) throws PortableException { - PortableRawReader raw = reader.rawReader(); - - lastUpdateTime = raw.readLong(); - maxActiveJobs = raw.readInt(); - curActiveJobs = raw.readInt(); - avgActiveJobs = raw.readFloat(); - maxWaitingJobs = raw.readInt(); - curWaitingJobs = raw.readInt(); - avgWaitingJobs = raw.readFloat(); - maxRejectedJobs = raw.readInt(); - curRejectedJobs = raw.readInt(); - avgRejectedJobs = raw.readFloat(); - maxCancelledJobs = raw.readInt(); - curCancelledJobs = raw.readInt(); - avgCancelledJobs = raw.readFloat(); - totalRejectedJobs = raw.readInt(); - totalCancelledJobs = raw.readInt(); - totalExecutedJobs = raw.readInt(); - maxJobWaitTime = raw.readLong(); - curJobWaitTime = raw.readLong(); - avgJobWaitTime = raw.readDouble(); - maxJobExecTime = raw.readLong(); - curJobExecTime = raw.readLong(); - avgJobExecTime = raw.readDouble(); - totalExecTasks = raw.readInt(); - totalIdleTime = raw.readLong(); - curIdleTime = raw.readLong(); - availProcs = raw.readInt(); - load = raw.readDouble(); - avgLoad = raw.readDouble(); - gcLoad = raw.readDouble(); - heapInit = raw.readLong(); - heapUsed = raw.readLong(); - heapCommitted = raw.readLong(); - heapMax = raw.readLong(); - nonHeapInit = raw.readLong(); - nonHeapUsed = raw.readLong(); - nonHeapCommitted = raw.readLong(); - nonHeapMax = raw.readLong(); - upTime = raw.readLong(); - startTime = raw.readLong(); - nodeStartTime = raw.readLong(); - threadCnt = raw.readInt(); - peakThreadCnt = raw.readInt(); - startedThreadCnt = raw.readLong(); - daemonThreadCnt = raw.readInt(); - fileSysFreeSpace = raw.readLong(); - fileSysTotalSpace = raw.readLong(); - fileSysUsableSpace = raw.readLong(); - lastDataVer = raw.readLong(); - sentMsgsCnt = raw.readInt(); - sentBytesCnt = raw.readLong(); - rcvdMsgsCnt = raw.readInt(); - rcvdBytesCnt = raw.readLong(); - } - /** {@inheritDoc} */ @Override public void writeExternal(ObjectOutput out) throws IOException { out.writeLong(lastUpdateTime); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPortableMetaData.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPortableMetaData.java index 5b9a2f6844367..e96baf5e11ce5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPortableMetaData.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPortableMetaData.java @@ -18,14 +18,13 @@ package org.apache.ignite.internal.processors.rest.client.message; import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.portables.*; import java.util.*; /** * Portable meta data sent from client. */ -public class GridClientPortableMetaData implements PortableMarshalAware { +public class GridClientPortableMetaData { /** */ private int typeId; @@ -66,26 +65,6 @@ public String affinityKeyFieldName() { return affKeyFieldName; } - /** {@inheritDoc} */ - @Override public void writePortable(PortableWriter writer) throws PortableException { - PortableRawWriter raw = writer.rawWriter(); - - raw.writeInt(typeId); - raw.writeString(typeName); - raw.writeString(affKeyFieldName); - raw.writeMap(fields); - } - - /** {@inheritDoc} */ - @Override public void readPortable(PortableReader reader) throws PortableException { - PortableRawReader raw = reader.rawReader(); - - typeId = raw.readInt(); - typeName = raw.readString(); - affKeyFieldName = raw.readString(); - fields = raw.readMap(); - } - /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridClientPortableMetaData.class, this); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPutMetaDataRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPutMetaDataRequest.java deleted file mode 100644 index 487da7ad6acd5..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPutMetaDataRequest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.rest.client.message; - -import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.portables.*; - -import java.util.*; - -/** - * Metadata put request. - */ -public class GridClientPutMetaDataRequest extends GridClientAbstractMessage { - /** */ - private static final long serialVersionUID = 0L; - - /** */ - private Collection meta; - - /** - * @return Type IDs. - */ - public Collection metaData() { - return meta; - } - - /** {@inheritDoc} */ - @Override public void writePortable(PortableWriter writer) throws PortableException { - super.writePortable(writer); - - PortableRawWriter raw = writer.rawWriter(); - - raw.writeCollection(meta); - } - - /** {@inheritDoc} */ - @Override public void readPortable(PortableReader reader) throws PortableException { - super.readPortable(reader); - - PortableRawReader raw = reader.rawReader(); - - meta = raw.readCollection(); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(GridClientPutMetaDataRequest.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientResponse.java index 09e542f237be4..c9a7263baadcf 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientResponse.java @@ -18,7 +18,6 @@ package org.apache.ignite.internal.processors.rest.client.message; import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.portables.*; import java.io.*; @@ -92,28 +91,6 @@ public void result(Object res) { this.res = res; } - /** {@inheritDoc} */ - @Override public void writePortable(PortableWriter writer) throws PortableException { - super.writePortable(writer); - - PortableRawWriter raw = writer.rawWriter(); - - raw.writeInt(successStatus); - raw.writeString(errorMsg); - raw.writeObject(res); - } - - /** {@inheritDoc} */ - @Override public void readPortable(PortableReader reader) throws PortableException { - super.readPortable(reader); - - PortableRawReader raw = reader.rawReader(); - - successStatus = raw.readInt(); - errorMsg = raw.readString(); - res = raw.readObject(); - } - /** {@inheritDoc} */ @Override public void writeExternal(ObjectOutput out) throws IOException { super.writeExternal(out); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientTaskRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientTaskRequest.java index 8a43030dfab16..a7fa86e914693 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientTaskRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientTaskRequest.java @@ -17,9 +17,7 @@ package org.apache.ignite.internal.processors.rest.client.message; -import org.apache.ignite.internal.util.portable.*; import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.portables.*; import java.io.*; @@ -101,32 +99,6 @@ public void keepPortables(boolean keepPortables) { 31 * (arg == null ? 0 : arg.hashCode()); } - /** {@inheritDoc} */ - @Override public void writePortable(PortableWriter writer) throws PortableException { - super.writePortable(writer); - - PortableRawWriterEx raw = (PortableRawWriterEx)writer.rawWriter(); - - raw.writeString(taskName); - raw.writeBoolean(keepPortables); - - if (keepPortables) - raw.writeObjectDetached(arg); - else - raw.writeObject(arg); - } - - /** {@inheritDoc} */ - @Override public void readPortable(PortableReader reader) throws PortableException { - super.readPortable(reader); - - PortableRawReaderEx raw = (PortableRawReaderEx)reader.rawReader(); - - taskName = raw.readString(); - keepPortables = raw.readBoolean(); - arg = keepPortables ? raw.readObjectDetached() : raw.readObject(); - } - /** {@inheritDoc} */ @Override public void writeExternal(ObjectOutput out) throws IOException { super.writeExternal(out); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientTaskResultBean.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientTaskResultBean.java index 12f4fdf1f7430..696ac034d7cfc 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientTaskResultBean.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientTaskResultBean.java @@ -17,16 +17,14 @@ package org.apache.ignite.internal.processors.rest.client.message; -import org.apache.ignite.internal.util.portable.*; import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.portables.*; import java.io.*; /** * Task result. */ -public class GridClientTaskResultBean implements Externalizable, PortableMarshalAware { +public class GridClientTaskResultBean implements Externalizable { /** */ private static final long serialVersionUID = 0L; @@ -99,30 +97,6 @@ public void setError(String error) { this.error = error; } - /** {@inheritDoc} */ - @Override public void writePortable(PortableWriter writer) throws PortableException { - PortableRawWriterEx raw = (PortableRawWriterEx)writer.rawWriter(); - - raw.writeString(id); - raw.writeBoolean(finished); - - raw.writeObject(res); - - raw.writeString(error); - } - - /** {@inheritDoc} */ - @Override public void readPortable(PortableReader reader) throws PortableException { - PortableRawReaderEx raw = (PortableRawReaderEx)reader.rawReader(); - - id = raw.readString(); - finished = raw.readBoolean(); - - res = raw.readObject(); - - error = raw.readString(); - } - /** {@inheritDoc} */ @Override public void writeExternal(ObjectOutput out) throws IOException { U.writeString(out, id); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientTopologyRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientTopologyRequest.java index 5a817c2bd7300..8b27084b62ac5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientTopologyRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientTopologyRequest.java @@ -18,7 +18,6 @@ package org.apache.ignite.internal.processors.rest.client.message; import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.portables.*; import java.io.*; import java.util.*; @@ -118,30 +117,6 @@ public void nodeIp(String nodeIp) { (includeAttrs ? 1 : 0); } - /** {@inheritDoc} */ - @Override public void writePortable(PortableWriter writer) throws PortableException { - super.writePortable(writer); - - PortableRawWriter raw = writer.rawWriter(); - - raw.writeUuid(nodeId); - raw.writeString(nodeIp); - raw.writeBoolean(includeMetrics); - raw.writeBoolean(includeAttrs); - } - - /** {@inheritDoc} */ - @Override public void readPortable(PortableReader reader) throws PortableException { - super.readPortable(reader); - - PortableRawReader raw = reader.rawReader(); - - nodeId = raw.readUuid(); - nodeIp = raw.readString(); - includeMetrics = raw.readBoolean(); - includeAttrs = raw.readBoolean(); - } - /** {@inheritDoc} */ @Override public void writeExternal(ObjectOutput out) throws IOException { super.writeExternal(out); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheClientQueryResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheClientQueryResult.java index cd16cb862a35c..b994caeb4f413 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheClientQueryResult.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheClientQueryResult.java @@ -17,15 +17,13 @@ package org.apache.ignite.internal.processors.rest.handlers.cache; -import org.apache.ignite.portables.*; - import java.io.*; import java.util.*; /** * Client query result. */ -public class GridCacheClientQueryResult implements PortableMarshalAware, Serializable { +public class GridCacheClientQueryResult implements Serializable { /** */ private static final long serialVersionUID = 0L; @@ -96,24 +94,4 @@ public UUID nodeId() { public void nodeId(UUID nodeId) { this.nodeId = nodeId; } - - /** {@inheritDoc} */ - @Override public void writePortable(PortableWriter writer) throws PortableException { - PortableRawWriter rawWriter = writer.rawWriter(); - - rawWriter.writeBoolean(last); - rawWriter.writeLong(qryId); - rawWriter.writeUuid(nodeId); - rawWriter.writeCollection(items); - } - - /** {@inheritDoc} */ - @Override public void readPortable(PortableReader reader) throws PortableException { - PortableRawReader rawReader = reader.rawReader(); - - last = rawReader.readBoolean(); - qryId = rawReader.readLong(); - nodeId = rawReader.readUuid(); - items = rawReader.readCollection(); - } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/metadata/GridPortableMetadataHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/metadata/GridPortableMetadataHandler.java deleted file mode 100644 index 1c53a9d945d46..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/metadata/GridPortableMetadataHandler.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.rest.handlers.metadata; - -import org.apache.ignite.*; -import org.apache.ignite.internal.*; -import org.apache.ignite.internal.processors.rest.*; -import org.apache.ignite.internal.processors.rest.client.message.*; -import org.apache.ignite.internal.processors.rest.handlers.*; -import org.apache.ignite.internal.processors.rest.request.*; -import org.apache.ignite.internal.util.future.*; -import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.portables.*; - -import java.util.*; - -import static org.apache.ignite.internal.processors.rest.GridRestCommand.*; - -/** - * Portable metadata handler. - */ -public class GridPortableMetadataHandler extends GridRestCommandHandlerAdapter { - /** Supported commands. */ - private static final Collection SUPPORTED_COMMANDS = U.sealList( - PUT_PORTABLE_METADATA, - GET_PORTABLE_METADATA - ); - - /** - * @param ctx Context. - */ - public GridPortableMetadataHandler(GridKernalContext ctx) { - super(ctx); - } - - /** {@inheritDoc} */ - @Override public Collection supportedCommands() { - return SUPPORTED_COMMANDS; - } - - /** {@inheritDoc} */ - @Override public IgniteInternalFuture handleAsync(GridRestRequest req) { - assert SUPPORTED_COMMANDS.contains(req.command()) : req.command(); - - try { - if (req.command() == GET_PORTABLE_METADATA) { - GridRestPortableGetMetaDataRequest metaReq = (GridRestPortableGetMetaDataRequest)req; - - GridRestResponse res = new GridRestResponse(); - - Map meta = ctx.portable().metadata(metaReq.typeIds()); - - GridClientMetaDataResponse metaRes = new GridClientMetaDataResponse(); - - metaRes.metaData(meta); - - res.setResponse(metaRes); - - return new GridFinishedFuture<>(ctx, res); - } - else { - assert req.command() == PUT_PORTABLE_METADATA; - - GridRestPortablePutMetaDataRequest metaReq = (GridRestPortablePutMetaDataRequest)req; - - for (GridClientPortableMetaData meta : metaReq.metaData()) - ctx.portable().updateMetaData(meta.typeId(), - meta.typeName(), - meta.affinityKeyFieldName(), - meta.fields()); - - GridRestResponse res = new GridRestResponse(); - - res.setResponse(true); - - return new GridFinishedFuture<>(ctx, res); - } - } - catch (IgniteException e) { - return new GridFinishedFuture<>(ctx, e); - } - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(GridPortableMetadataHandler.class, this, super.toString()); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskCommandHandler.java index a3e2311a46037..f9004c305e51e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskCommandHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskCommandHandler.java @@ -34,7 +34,6 @@ import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; -import org.apache.ignite.portables.*; import org.apache.ignite.resources.*; import org.jetbrains.annotations.*; @@ -263,7 +262,7 @@ private IgniteInternalFuture handleAsyncUnsafe(final GridRestR res.setResponse(taskRestRes); fut.onDone(res); } - catch (PortableException e) { + catch (IgniteException e) { fut.onDone(new IgniteCheckedException("Failed to marshal task result: " + desc.result(), e)); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestNioListener.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestNioListener.java index 12dc711268eb7..9407ce1df6a39 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestNioListener.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestNioListener.java @@ -313,20 +313,6 @@ else if (msg instanceof GridClientTaskRequest) { restReq = restTaskReq; } - else if (msg instanceof GridClientGetMetaDataRequest) { - GridClientGetMetaDataRequest req = (GridClientGetMetaDataRequest)msg; - - restReq = new GridRestPortableGetMetaDataRequest(req); - - restReq.command(GET_PORTABLE_METADATA); - } - else if (msg instanceof GridClientPutMetaDataRequest) { - GridClientPutMetaDataRequest req = (GridClientPutMetaDataRequest)msg; - - restReq = new GridRestPortablePutMetaDataRequest(req); - - restReq.command(PUT_PORTABLE_METADATA); - } else if (msg instanceof GridClientTopologyRequest) { GridClientTopologyRequest req = (GridClientTopologyRequest) msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestPortableGetMetaDataRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestPortableGetMetaDataRequest.java deleted file mode 100644 index 6205a0ea568ce..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestPortableGetMetaDataRequest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.rest.request; - -import org.apache.ignite.internal.processors.rest.client.message.*; - -import java.util.*; - -/** - * Portable get metadata request. - */ -public class GridRestPortableGetMetaDataRequest extends GridRestRequest { - /** */ - private final GridClientGetMetaDataRequest msg; - - /** - * @param msg Client message. - */ - public GridRestPortableGetMetaDataRequest(GridClientGetMetaDataRequest msg) { - this.msg = msg; - } - - /** - * @return Type IDs. - */ - public Collection typeIds() { - return msg.typeIds(); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestPortablePutMetaDataRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestPortablePutMetaDataRequest.java deleted file mode 100644 index 7acee3932536b..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestPortablePutMetaDataRequest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.rest.request; - -import org.apache.ignite.internal.processors.rest.client.message.*; - -import java.util.*; - -/** - * Portable get metadata request. - */ -public class GridRestPortablePutMetaDataRequest extends GridRestRequest { - /** */ - private final GridClientPutMetaDataRequest msg; - - /** - * @param msg Client message. - */ - public GridRestPortablePutMetaDataRequest(GridClientPutMetaDataRequest msg) { - this.msg = msg; - } - - /** - * @return Type IDs. - */ - public Collection metaData() { - return msg.metaData(); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java index 171e0f1c67b99..7a686277b29e6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java @@ -40,7 +40,6 @@ import org.apache.ignite.internal.util.worker.*; import org.apache.ignite.lang.*; import org.apache.ignite.lifecycle.*; -import org.apache.ignite.portables.*; import org.apache.ignite.spi.*; import org.apache.ignite.spi.discovery.*; import org.apache.ignite.transactions.*; @@ -283,9 +282,6 @@ public abstract class IgniteUtils { public static final String MAC_INVALID_ARG_MSG = "On MAC OS you may have too many file descriptors open " + "(simple restart usually solves the issue)"; - /** Portable classes. */ - private static final Collection> PORTABLE_CLS = new HashSet<>(); - /** Ignite Logging Directory. */ public static final String IGNITE_LOG_DIR = System.getenv(IgniteSystemProperties.IGNITE_LOG_DIR); @@ -519,31 +515,6 @@ else if (archStr.contains("sparc")) } } - PORTABLE_CLS.add(Byte.class); - PORTABLE_CLS.add(Short.class); - PORTABLE_CLS.add(Integer.class); - PORTABLE_CLS.add(Long.class); - PORTABLE_CLS.add(Float.class); - PORTABLE_CLS.add(Double.class); - PORTABLE_CLS.add(Character.class); - PORTABLE_CLS.add(Boolean.class); - PORTABLE_CLS.add(String.class); - PORTABLE_CLS.add(UUID.class); - PORTABLE_CLS.add(Date.class); - PORTABLE_CLS.add(Timestamp.class); - PORTABLE_CLS.add(byte[].class); - PORTABLE_CLS.add(short[].class); - PORTABLE_CLS.add(int[].class); - PORTABLE_CLS.add(long[].class); - PORTABLE_CLS.add(float[].class); - PORTABLE_CLS.add(double[].class); - PORTABLE_CLS.add(char[].class); - PORTABLE_CLS.add(boolean[].class); - PORTABLE_CLS.add(String[].class); - PORTABLE_CLS.add(UUID[].class); - PORTABLE_CLS.add(Date[].class); - PORTABLE_CLS.add(Timestamp[].class); - exceptionConverters = Collections.unmodifiableMap(exceptionConverters()); } @@ -7214,19 +7185,6 @@ public static GridCacheAttributes[] cacheAttributes(ClusterNode n) { return null; } - /** - * Gets portable enabled flag from the given node for the given cache name. - * - * @param n Node. - * @param cacheName Cache name. - * @return Portable enabled flag. - */ - @Nullable public static Boolean portableEnabled(ClusterNode n, @Nullable String cacheName) { - GridCacheAttributes attrs = cacheAttributes(n, cacheName); - - return attrs == null ? false : attrs.portableEnabled(); - } - /** * Gets view on all cache names started on the node. * @@ -8779,36 +8737,6 @@ public static ClusterNode youngest(Collection c, @Nullable IgnitePr return youngest; } - /** - * Tells whether provided type is portable. - * - * @param cls Class to check. - * @return Whether type is portable. - */ - public static boolean isPortableType(Class cls) { - assert cls != null; - - return PortableObject.class.isAssignableFrom(cls) || - PORTABLE_CLS.contains(cls) || - cls.isEnum() || - (cls.isArray() && cls.getComponentType().isEnum()); - } - /** - * Tells whether provided type is portable or a collection. - * - * @param cls Class to check. - * @return Whether type is portable or a collection. - */ - public static boolean isPortableOrCollectionType(Class cls) { - assert cls != null; - - return isPortableType(cls) || - cls == Object[].class || - Collection.class.isAssignableFrom(cls) || - Map.class.isAssignableFrom(cls) || - Map.Entry.class.isAssignableFrom(cls); - } - /** * @param arr Array. * @param off Offset. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/portable/PortableRawReaderEx.java b/modules/core/src/main/java/org/apache/ignite/internal/util/portable/PortableRawReaderEx.java deleted file mode 100644 index 1cb5749dce18e..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/portable/PortableRawReaderEx.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.util.portable; - -import org.apache.ignite.portables.*; -import org.jetbrains.annotations.*; - -/** - * Extended reader interface. - */ -public interface PortableRawReaderEx extends PortableRawReader { - /** - * @return Object. - * @throws org.apache.ignite.portables.PortableException In case of error. - */ - @Nullable public Object readObjectDetached() throws PortableException; -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/portable/PortableRawWriterEx.java b/modules/core/src/main/java/org/apache/ignite/internal/util/portable/PortableRawWriterEx.java deleted file mode 100644 index df7c83ce8627f..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/portable/PortableRawWriterEx.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.util.portable; - -import org.apache.ignite.internal.processors.portable.*; -import org.apache.ignite.portables.*; -import org.jetbrains.annotations.*; - -/** - * Extended writer interface. - */ -public interface PortableRawWriterEx extends PortableRawWriter, AutoCloseable { - /** - * @param obj Object to write. - * @throws org.apache.ignite.portables.PortableException In case of error. - */ - public void writeObjectDetached(@Nullable Object obj) throws PortableException; - - /** - * @return Output stream. - */ - public GridPortableOutputStream out(); - - /** - * Cleans resources. - */ - @Override public void close(); -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/portable/VisorPortableMetadata.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/portable/VisorPortableMetadata.java deleted file mode 100644 index 74a39971301fc..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/portable/VisorPortableMetadata.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.visor.portable; - -import org.apache.ignite.internal.util.typedef.internal.*; - -import java.io.*; -import java.util.*; - -/** - * Portable object metadata to show in Visor. - */ -public class VisorPortableMetadata implements Serializable { - /** */ - private static final long serialVersionUID = 0L; - - /** Type name */ - private String typeName; - - /** Type Id */ - private Integer typeId; - - /** Filed list */ - private Collection fields; - - /** Type name */ - public String typeName() { - return typeName; - } - - public void typeName(String typeName) { - this.typeName = typeName; - } - - /** Type Id */ - public Integer typeId() { - return typeId; - } - - public void typeId(Integer typeId) { - this.typeId = typeId; - } - - /** Fields list */ - public Collection fields() { - return fields; - } - - public void fields(Collection fields) { - this.fields = fields; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorPortableMetadata.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/portable/VisorPortableMetadataCollectorTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/portable/VisorPortableMetadataCollectorTask.java deleted file mode 100644 index 8fc967a43d1d1..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/portable/VisorPortableMetadataCollectorTask.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.visor.portable; - -import org.apache.ignite.*; -import org.apache.ignite.internal.processors.task.*; -import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.internal.visor.*; -import org.apache.ignite.lang.*; -import org.apache.ignite.portables.*; - -import java.util.*; - -/** - * Task that collects portables metadata. - */ -@GridInternal -public class VisorPortableMetadataCollectorTask extends VisorOneNodeTask>> { - /** */ - private static final long serialVersionUID = 0L; - - /** {@inheritDoc} */ - @Override protected VisorPortableCollectMetadataJob job(Long lastUpdate) { - return new VisorPortableCollectMetadataJob(lastUpdate, debug); - } - - /** Job that collect portables metadata on node. */ - private static class VisorPortableCollectMetadataJob extends VisorJob>> { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Create job with given argument. - * - * @param lastUpdate Time data was collected last time. - * @param debug Debug flag. - */ - private VisorPortableCollectMetadataJob(Long lastUpdate, boolean debug) { - super(lastUpdate, debug); - } - - /** {@inheritDoc} */ - @Override protected IgniteBiTuple> run(Long lastUpdate) { - final IgnitePortables p = g.portables(); - - final Collection data = new ArrayList<>(p.metadata().size()); - - for(PortableMetadata metadata: p.metadata()) { - final VisorPortableMetadata type = new VisorPortableMetadata(); - - type.typeName(metadata.typeName()); - - type.typeId(p.typeId(metadata.typeName())); - - final Collection fields = new ArrayList<>(metadata.fields().size()); - - for (String fieldName: metadata.fields()) { - final VisorPortableMetadataField field = new VisorPortableMetadataField(); - - field.fieldName(fieldName); - field.fieldTypeName(metadata.fieldTypeName(fieldName)); - - fields.add(field); - } - - type.fields(fields); - - data.add(type); - } - - return new IgniteBiTuple<>(0L, data); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorPortableCollectMetadataJob.class, this); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/portable/VisorPortableMetadataField.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/portable/VisorPortableMetadataField.java deleted file mode 100644 index d5cbac47ebeb7..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/portable/VisorPortableMetadataField.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.visor.portable; - -import org.apache.ignite.internal.util.typedef.internal.*; - -import java.io.*; - -/** - * Portable object metadata field information. - */ -public class VisorPortableMetadataField implements Serializable { - /** */ - private static final long serialVersionUID = 0L; - - /** Field name. */ - private String fieldName; - - /** Field type name. */ - private String fieldTypeName; - - /** Field id. */ - private Integer fieldId; - - /** Field name. */ - public String fieldName() { - return fieldName; - } - - public void fieldName(String fieldName) { - this.fieldName = fieldName; - } - - /** Field type name. */ - public String fieldTypeName() { - return fieldTypeName; - } - - public void fieldTypeName(String fieldTypeName) { - this.fieldTypeName = fieldTypeName; - } - - /** Field id. */ - public Integer fieldId() { - return fieldId; - } - - public void fieldId(Integer fieldId) { - this.fieldId = fieldId; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(VisorPortableMetadataField.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/PluginProvider.java b/modules/core/src/main/java/org/apache/ignite/plugin/PluginProvider.java index 9e5bb2c7e35ca..7be8dcc0b7a09 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/PluginProvider.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/PluginProvider.java @@ -51,7 +51,7 @@ public interface PluginProvider { * @param cls Ignite component class. * @return Ignite component or {@code null} if component is not supported. */ - @Nullable public T createComponent(Class cls); + @Nullable public T createComponent(PluginContext ctx, Class cls); /** * Register extensions. diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/security/GridSecurityCredentials.java b/modules/core/src/main/java/org/apache/ignite/plugin/security/GridSecurityCredentials.java index 78f7abc4c453a..79dafd36517fe 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/security/GridSecurityCredentials.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/security/GridSecurityCredentials.java @@ -17,10 +17,10 @@ package org.apache.ignite.plugin.security; +import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.portables.*; import org.jetbrains.annotations.*; import java.io.*; @@ -31,7 +31,7 @@ * client or node startup in configuration. *

      * For grid node, security credentials provider is specified in - * {@link org.apache.ignite.configuration.IgniteConfiguration#setSecurityCredentialsProvider(GridSecurityCredentialsProvider)} + * {@link IgniteConfiguration#setSecurityCredentialsProvider(GridSecurityCredentialsProvider)} * configuration property. For Java clients, you can provide credentials in * {@code GridClientConfiguration.setSecurityCredentialsProvider(...)} method. *

      @@ -45,7 +45,7 @@ * specifying {@link #setUserObject(Object) userObject} as well, which can be used * to pass in any additional information required for authentication. */ -public class GridSecurityCredentials implements Externalizable, PortableMarshalAware { +public class GridSecurityCredentials implements Externalizable { /** */ private static final long serialVersionUID = -2655741071578326256L; @@ -183,20 +183,6 @@ public void setUserObject(@Nullable Object userObj) { return res; } - /** {@inheritDoc} */ - @Override public void writePortable(PortableWriter writer) throws PortableException { - writer.rawWriter().writeObject(login); - writer.rawWriter().writeObject(password); - writer.rawWriter().writeObject(userObj); - } - - /** {@inheritDoc} */ - @Override public void readPortable(PortableReader reader) throws PortableException { - login = reader.rawReader().readObject(); - password = reader.rawReader().readObject(); - userObj = reader.rawReader().readObject(); - } - /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridSecurityCredentials.class, this); diff --git a/modules/core/src/main/java/org/apache/ignite/portables/PortableBuilder.java b/modules/core/src/main/java/org/apache/ignite/portables/PortableBuilder.java deleted file mode 100644 index 619081c844d24..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/portables/PortableBuilder.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.portables; - -import org.jetbrains.annotations.*; - -/** - * Portable object builder. Provides ability to build portable objects dynamically - * without having class definitions. - *

      - * Here is an example of how a portable object can be built dynamically: - *

      - * GridPortableBuilder builder = Ignition.ignite().portables().builder("org.project.MyObject");
      - *
      - * builder.setField("fieldA", "A");
      - * builder.setField("fieldB", "B");
      - *
      - * GridPortableObject portableObj = builder.build();
      - * 
      - * - *

      - * Also builder can be initialized by existing portable object. This allows changing some fields without affecting - * other fields. - *

      - * GridPortableBuilder builder = Ignition.ignite().portables().builder(person);
      - *
      - * builder.setField("name", "John");
      - *
      - * person = builder.build();
      - * 
      - *

      - * - * If you need to modify nested portable object you can get builder for nested object using - * {@link #getField(String)}, changes made on nested builder will affect parent object, - * for example: - * - *
      - * GridPortableBuilder personBuilder = grid.portables().createBuilder(personPortableObj);
      - * GridPortableBuilder addressBuilder = personBuilder.setField("address");
      - *
      - * addressBuilder.setField("city", "New York");
      - *
      - * personPortableObj = personBuilder.build();
      - *
      - * // Should be "New York".
      - * String city = personPortableObj.getField("address").getField("city");
      - * 
      - * - * @see org.apache.ignite.IgnitePortables#builder(int) - * @see org.apache.ignite.IgnitePortables#builder(String) - * @see org.apache.ignite.IgnitePortables#builder(PortableObject) - */ -public interface PortableBuilder { - /** - * Returns value assigned to the specified field. - * If the value is a portable object instance of {@code GridPortableBuilder} will be returned, - * which can be modified. - *

      - * Collections and maps returned from this method are modifiable. - * - * @param name Field name. - * @return Filed value. - */ - public T getField(String name); - - /** - * Sets field value. - * - * @param name Field name. - * @param val Field value (cannot be {@code null}). - * @see PortableObject#metaData() - */ - public PortableBuilder setField(String name, Object val); - - /** - * Sets field value with value type specification. - *

      - * Field type is needed for proper metadata update. - * - * @param name Field name. - * @param val Field value. - * @param type Field type. - * @see PortableObject#metaData() - */ - public PortableBuilder setField(String name, @Nullable T val, Class type); - - /** - * Sets field value. - *

      - * This method should be used if field is portable object. - * - * @param name Field name. - * @param builder Builder for object field. - */ - public PortableBuilder setField(String name, @Nullable PortableBuilder builder); - - /** - * Removes field from this builder. - * - * @param fieldName Field name. - * @return {@code this} instance for chaining. - */ - public PortableBuilder removeField(String fieldName); - - /** - * Sets hash code for resulting portable object returned by {@link #build()} method. - *

      - * If not set {@code 0} is used. - * - * @param hashCode Hash code. - * @return {@code this} instance for chaining. - */ - public PortableBuilder hashCode(int hashCode); - - /** - * Builds portable object. - * - * @return Portable object. - * @throws PortableException In case of error. - */ - public PortableObject build() throws PortableException; -} diff --git a/modules/core/src/main/java/org/apache/ignite/portables/PortableConfiguration.java b/modules/core/src/main/java/org/apache/ignite/portables/PortableConfiguration.java deleted file mode 100644 index 967f8cdd4556d..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/portables/PortableConfiguration.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.portables; - -import org.apache.ignite.internal.util.typedef.internal.*; - -import java.sql.*; -import java.util.*; - -/** - * Defines configuration for Ignite portable functionality. All configuration - * properties defined here can be overridden on per-type level in - * {@link PortableTypeConfiguration}. Type configurations are provided via - * {@link #getTypeConfigurations()} method. - */ -public class PortableConfiguration { - /** Class names. */ - private Collection clsNames; - - /** ID mapper. */ - private PortableIdMapper idMapper; - - /** Serializer. */ - private PortableSerializer serializer; - - /** Types. */ - private Collection typeCfgs; - - /** Use timestamp flag. */ - private boolean useTs = true; - - /** Meta data enabled flag. */ - private boolean metaDataEnabled = true; - - /** Keep deserialized flag. */ - private boolean keepDeserialized = true; - - /** - * Gets class names. - * - * @return Class names. - */ - public Collection getClassNames() { - return clsNames; - } - - /** - * Sets class names. - * - * @param clsNames Class names. - */ - public void setClassNames(Collection clsNames) { - this.clsNames = clsNames; - } - - /** - * Gets ID mapper. - * - * @return ID mapper. - */ - public PortableIdMapper getIdMapper() { - return idMapper; - } - - /** - * Sets ID mapper. - * - * @param idMapper ID mapper. - */ - public void setIdMapper(PortableIdMapper idMapper) { - this.idMapper = idMapper; - } - - /** - * Gets serializer. - * - * @return Serializer. - */ - public PortableSerializer getSerializer() { - return serializer; - } - - /** - * Sets serializer. - * - * @param serializer Serializer. - */ - public void setSerializer(PortableSerializer serializer) { - this.serializer = serializer; - } - - /** - * Gets types configuration. - * - * @return Types configuration. - */ - public Collection getTypeConfigurations() { - return typeCfgs; - } - - /** - * Sets type configurations. - * - * @param typeCfgs Type configurations. - */ - public void setTypeConfigurations(Collection typeCfgs) { - this.typeCfgs = typeCfgs; - } - - /** - * If {@code true} then date values converted to {@link Timestamp} on deserialization. - *

      - * Default value is {@code true}. - * - * @return Flag indicating whether date values converted to {@link Timestamp} during unmarshalling. - */ - public boolean isUseTimestamp() { - return useTs; - } - - /** - * @param useTs Flag indicating whether date values converted to {@link Timestamp} during unmarshalling. - */ - public void setUseTimestamp(boolean useTs) { - this.useTs = useTs; - } - - /** - * If {@code true}, meta data will be collected or all types. If you need to override this behaviour for - * some specific type, use {@link PortableTypeConfiguration#setMetaDataEnabled(Boolean)} method. - *

      - * Default value if {@code true}. - * - * @return Whether meta data is collected. - */ - public boolean isMetaDataEnabled() { - return metaDataEnabled; - } - - /** - * @param metaDataEnabled Whether meta data is collected. - */ - public void setMetaDataEnabled(boolean metaDataEnabled) { - this.metaDataEnabled = metaDataEnabled; - } - - /** - * If {@code true}, {@link PortableObject} will cache deserialized instance after - * {@link PortableObject#deserialize()} is called. All consequent calls of this - * method on the same instance of {@link PortableObject} will return that cached - * value without actually deserializing portable object. If you need to override this - * behaviour for some specific type, use {@link PortableTypeConfiguration#setKeepDeserialized(Boolean)} - * method. - *

      - * Default value if {@code true}. - * - * @return Whether deserialized value is kept. - */ - public boolean isKeepDeserialized() { - return keepDeserialized; - } - - /** - * @param keepDeserialized Whether deserialized value is kept. - */ - public void setKeepDeserialized(boolean keepDeserialized) { - this.keepDeserialized = keepDeserialized; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(PortableConfiguration.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/portables/PortableException.java b/modules/core/src/main/java/org/apache/ignite/portables/PortableException.java deleted file mode 100644 index 63ac1e5acec42..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/portables/PortableException.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.portables; - -import org.apache.ignite.*; -import org.jetbrains.annotations.*; - -/** - * Exception indicating portable object serialization error. - */ -public class PortableException extends IgniteException { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Creates portable exception with error message. - * - * @param msg Error message. - */ - public PortableException(String msg) { - super(msg); - } - - /** - * Creates portable exception with {@link Throwable} as a cause. - * - * @param cause Cause. - */ - public PortableException(Throwable cause) { - super(cause); - } - - /** - * Creates portable exception with error message and {@link Throwable} as a cause. - * - * @param msg Error message. - * @param cause Cause. - */ - public PortableException(String msg, @Nullable Throwable cause) { - super(msg, cause); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/portables/PortableIdMapper.java b/modules/core/src/main/java/org/apache/ignite/portables/PortableIdMapper.java deleted file mode 100644 index f3316de4e81b9..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/portables/PortableIdMapper.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.portables; - -/** - * Type and field ID mapper for portable objects. Ignite never writes full - * strings for field or type names. Instead, for performance reasons, Ignite - * writes integer hash codes for type and field names. It has been tested that - * hash code conflicts for the type names or the field names - * within the same type are virtually non-existent and, to gain performance, it is safe - * to work with hash codes. For the cases when hash codes for different types or fields - * actually do collide {@code GridPortableIdMapper} allows to override the automatically - * generated hash code IDs for the type and field names. - *

      - * Portable ID mapper can be configured for all portable objects via - * {@link PortableConfiguration#getIdMapper()} method, or for a specific - * portable type via {@link PortableTypeConfiguration#getIdMapper()} method. - */ -public interface PortableIdMapper { - /** - * Gets type ID for provided class name. - *

      - * If {@code 0} is returned, hash code of class simple name will be used. - * - * @param clsName Class name. - * @return Type ID. - */ - public int typeId(String clsName); - - /** - * Gets ID for provided field. - *

      - * If {@code 0} is returned, hash code of field name will be used. - * - * @param typeId Type ID. - * @param fieldName Field name. - * @return Field ID. - */ - public int fieldId(int typeId, String fieldName); -} diff --git a/modules/core/src/main/java/org/apache/ignite/portables/PortableInvalidClassException.java b/modules/core/src/main/java/org/apache/ignite/portables/PortableInvalidClassException.java deleted file mode 100644 index 01500ec1e8136..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/portables/PortableInvalidClassException.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.portables; - -import org.jetbrains.annotations.*; - -/** - * Exception indicating that class needed for deserialization of portable object does not exist. - *

      - * Thrown from {@link PortableObject#deserialize()} method. - */ -public class PortableInvalidClassException extends PortableException { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Creates invalid class exception with error message. - * - * @param msg Error message. - */ - public PortableInvalidClassException(String msg) { - super(msg); - } - - /** - * Creates invalid class exception with {@link Throwable} as a cause. - * - * @param cause Cause. - */ - public PortableInvalidClassException(Throwable cause) { - super(cause); - } - - /** - * Creates invalid class exception with error message and {@link Throwable} as a cause. - * - * @param msg Error message. - * @param cause Cause. - */ - public PortableInvalidClassException(String msg, @Nullable Throwable cause) { - super(msg, cause); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/portables/PortableMarshalAware.java b/modules/core/src/main/java/org/apache/ignite/portables/PortableMarshalAware.java deleted file mode 100644 index b2813a58e0f9e..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/portables/PortableMarshalAware.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.portables; - -/** - * Interface that allows to implement custom serialization - * logic for portable objects. Portable objects are not required - * to implement this interface, in which case Ignite will automatically - * serialize portable objects using reflection. - *

      - * This interface, in a way, is analogous to {@link java.io.Externalizable} - * interface, which allows users to override default serialization logic, - * usually for performance reasons. The only difference here is that portable - * serialization is already very fast and implementing custom serialization - * logic for portables does not provide significant performance gains. - */ -public interface PortableMarshalAware { - /** - * Writes fields to provided writer. - * - * @param writer Portable object writer. - * @throws PortableException In case of error. - */ - public void writePortable(PortableWriter writer) throws PortableException; - - /** - * Reads fields from provided reader. - * - * @param reader Portable object reader. - * @throws PortableException In case of error. - */ - public void readPortable(PortableReader reader) throws PortableException; -} diff --git a/modules/core/src/main/java/org/apache/ignite/portables/PortableMetadata.java b/modules/core/src/main/java/org/apache/ignite/portables/PortableMetadata.java deleted file mode 100644 index 25daf94dacc0d..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/portables/PortableMetadata.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.portables; - -import org.jetbrains.annotations.*; - -import java.util.*; - -/** - * Portable type meta data. Metadata for portable types can be accessed from any of the - * {@link org.apache.ignite.IgnitePortables#metadata(String) GridPortables.metadata(...)} methods. - * Having metadata also allows for proper formatting of {@code GridPortableObject.toString()} method, - * even when portable objects are kept in binary format only, which may be necessary for audit reasons. - */ -public interface PortableMetadata { - /** - * Gets portable type name. - * - * @return Portable type name. - */ - public String typeName(); - - /** - * Gets collection of all field names for this portable type. - * - * @return Collection of all field names for this portable type. - */ - public Collection fields(); - - /** - * Gets name of the field type for a given field. - * - * @param fieldName Field name. - * @return Field type name. - */ - @Nullable public String fieldTypeName(String fieldName); - - /** - * Portable objects can optionally specify custom key-affinity mapping in the - * configuration. This method returns the name of the field which should be - * used for the key-affinity mapping. - * - * @return Affinity key field name. - */ - @Nullable public String affinityKeyFieldName(); -} diff --git a/modules/core/src/main/java/org/apache/ignite/portables/PortableObject.java b/modules/core/src/main/java/org/apache/ignite/portables/PortableObject.java deleted file mode 100644 index 40deabf25f6c8..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/portables/PortableObject.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.portables; - -import org.jetbrains.annotations.*; - -import java.io.*; -import java.util.*; - -/** - * Wrapper for portable object in portable binary format. Once an object is defined as portable, - * Ignite will always store it in memory in the portable (i.e. binary) format. - * User can choose to work either with the portable format or with the deserialized form - * (assuming that class definitions are present in the classpath). - *

      - * NOTE: user does not need to (and should not) implement this interface directly. - *

      - * To work with the portable format directly, user should create a cache projection - * over {@code GridPortableObject} class and then retrieve individual fields as needed: - *

      - * CacheProjection<GridPortableObject.class, GridPortableObject.class> prj =
      - *     cache.projection(GridPortableObject.class, GridPortableObject.class);
      - *
      - * // Convert instance of MyKey to portable format.
      - * // We could also use GridPortableBuilder to create
      - * // the key in portable format directly.
      - * GridPortableObject key = grid.portables().toPortable(new MyKey());
      - *
      - * GridPortableObject val = prj.get(key);
      - *
      - * String field = val.field("myFieldName");
      - * 
      - * Alternatively, we could also choose a hybrid approach, where, for example, - * the keys are concrete deserialized objects and the values are returned in portable - * format, like so: - *
      - * CacheProjection<MyKey.class, GridPortableObject.class> prj =
      - *     cache.projection(MyKey.class, GridPortableObject.class);
      - *
      - * GridPortableObject val = prj.get(new MyKey());
      - *
      - * String field = val.field("myFieldName");
      - * 
      - * We could also have the values as concrete deserialized objects and the keys in portable format, - * but such use case is a lot less common because cache keys are usually a lot smaller than values, and - * it may be very cheap to deserialize the keys, but not the values. - *

      - * And finally, if we have class definitions in the classpath, we may choose to work with deserialized - * typed objects at all times. In this case we do incur the deserialization cost, however, - * Ignite will only deserialize on the first access and will cache the deserialized object, - * so it does not have to be deserialized again: - *

      - * CacheProjection<MyKey.class, MyValue.class> prj =
      - *     cache.projection(MyKey.class, MyValue.class);
      - *
      - * MyValue val = prj.get(new MyKey());
      - *
      - * // Normal java getter.
      - * String fieldVal = val.getMyFieldName();
      - * 
      - *

      Working With Maps and Collections

      - * All maps and collections in the portable objects are serialized automatically. When working - * with different platforms, e.g. C++ or .NET, Ignite will automatically pick the most - * adequate collection or map in either language. For example, {@link ArrayList} in Java will become - * {@code List} in C#, {@link LinkedList} in Java is {@link LinkedList} in C#, {@link HashMap} - * in Java is {@code Dictionary} in C#, and {@link TreeMap} in Java becomes {@code SortedDictionary} - * in C#, etc. - *

      Dynamic Structure Changes

      - * Since objects are always cached in the portable binary format, server does not need to - * be aware of the class definitions. Moreover, if class definitions are not present or not - * used on the server, then clients can continuously change the structure of the portable - * objects without having to restart the cluster. For example, if one client stores a - * certain class with fields A and B, and another client stores the same class with - * fields B and C, then the server-side portable object will have the fields A, B, and C. - * As the structure of a portable object changes, the new fields become available for SQL queries - * automatically. - *

      Building Portable Objects

      - * Ignite comes with {@link PortableBuilder} which allows to build portable objects dynamically: - *
      - * GridPortableBuilder builder = Ignition.ignite().portables().builder("org.project.MyObject");
      - *
      - * builder.setField("fieldA", "A");
      - * builder.setField("fieldB", "B");
      - *
      - * GridPortableObject portableObj = builder.build();
      - * 
      - * For the cases when class definition is present - * in the class path, it is also possible to populate a standard POJO and then - * convert it to portable format, like so: - *
      - * MyObject obj = new MyObject();
      - *
      - * obj.setFieldA("A");
      - * obj.setFieldB(123);
      - *
      - * GridPortableObject portableObj = Ignition.ignite().portables().toPortable(obj);
      - * 
      - *

      Portable Metadata

      - * Even though Ignite portable protocol only works with hash codes for type and field names - * to achieve better performance, Ignite provides metadata for all portable types which - * can be queried ar runtime via any of the {@link org.apache.ignite.IgnitePortables#metadata(Class) GridPortables.metadata(...)} - * methods. Having metadata also allows for proper formatting of {@code GridPortableObject.toString()} method, - * even when portable objects are kept in binary format only, which may be necessary for audit reasons. - */ -public interface PortableObject extends Serializable, Cloneable { - /** - * Gets portable object type ID. - * - * @return Type ID. - */ - public int typeId(); - - /** - * Gets meta data for this portable object. - * - * @return Meta data. - * @throws PortableException In case of error. - */ - @Nullable public PortableMetadata metaData() throws PortableException; - - /** - * Gets field value. - * - * @param fieldName Field name. - * @return Field value. - * @throws PortableException In case of any other error. - */ - @Nullable public F field(String fieldName) throws PortableException; - - /** - * Gets fully deserialized instance of portable object. - * - * @return Fully deserialized instance of portable object. - * @throws PortableInvalidClassException If class doesn't exist. - * @throws PortableException In case of any other error. - */ - @Nullable public T deserialize() throws PortableException; - - /** - * Copies this portable object. - * - * @return Copy of this portable object. - */ - public PortableObject clone() throws CloneNotSupportedException; -} diff --git a/modules/core/src/main/java/org/apache/ignite/portables/PortableRawReader.java b/modules/core/src/main/java/org/apache/ignite/portables/PortableRawReader.java deleted file mode 100644 index 5801aa87b2ed2..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/portables/PortableRawReader.java +++ /dev/null @@ -1,235 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.portables; - -import org.jetbrains.annotations.*; - -import java.math.*; -import java.sql.*; -import java.util.*; -import java.util.Date; - -/** - * Raw reader for portable objects. Raw reader does not use field name hash codes, therefore, - * making the format even more compact. However, if the raw reader is used, - * dynamic structure changes to the portable objects are not supported. - */ -public interface PortableRawReader { - /** - * @return Byte value. - * @throws PortableException In case of error. - */ - public byte readByte() throws PortableException; - - /** - * @return Short value. - * @throws PortableException In case of error. - */ - public short readShort() throws PortableException; - - /** - * @return Integer value. - * @throws PortableException In case of error. - */ - public int readInt() throws PortableException; - - /** - * @return Long value. - * @throws PortableException In case of error. - */ - public long readLong() throws PortableException; - - /** - * @return Float value. - * @throws PortableException In case of error. - */ - public float readFloat() throws PortableException; - - /** - * @return Double value. - * @throws PortableException In case of error. - */ - public double readDouble() throws PortableException; - - /** - * @return Char value. - * @throws PortableException In case of error. - */ - public char readChar() throws PortableException; - - /** - * @return Boolean value. - * @throws PortableException In case of error. - */ - public boolean readBoolean() throws PortableException; - - /** - * @return Decimal value. - * @throws PortableException In case of error. - */ - @Nullable public BigDecimal readDecimal() throws PortableException; - - /** - * @return String value. - * @throws PortableException In case of error. - */ - @Nullable public String readString() throws PortableException; - - /** - * @return UUID. - * @throws PortableException In case of error. - */ - @Nullable public UUID readUuid() throws PortableException; - - /** - * @return Date. - * @throws PortableException In case of error. - */ - @Nullable public Date readDate() throws PortableException; - - /** - * @return Timestamp. - * @throws PortableException In case of error. - */ - @Nullable public Timestamp readTimestamp() throws PortableException; - - /** - * @return Object. - * @throws PortableException In case of error. - */ - @Nullable public T readObject() throws PortableException; - - /** - * @return Byte array. - * @throws PortableException In case of error. - */ - @Nullable public byte[] readByteArray() throws PortableException; - - /** - * @return Short array. - * @throws PortableException In case of error. - */ - @Nullable public short[] readShortArray() throws PortableException; - - /** - * @return Integer array. - * @throws PortableException In case of error. - */ - @Nullable public int[] readIntArray() throws PortableException; - - /** - * @return Long array. - * @throws PortableException In case of error. - */ - @Nullable public long[] readLongArray() throws PortableException; - - /** - * @return Float array. - * @throws PortableException In case of error. - */ - @Nullable public float[] readFloatArray() throws PortableException; - - /** - * @return Byte array. - * @throws PortableException In case of error. - */ - @Nullable public double[] readDoubleArray() throws PortableException; - - /** - * @return Char array. - * @throws PortableException In case of error. - */ - @Nullable public char[] readCharArray() throws PortableException; - - /** - * @return Boolean array. - * @throws PortableException In case of error. - */ - @Nullable public boolean[] readBooleanArray() throws PortableException; - - /** - * @return Decimal array. - * @throws PortableException In case of error. - */ - @Nullable public BigDecimal[] readDecimalArray() throws PortableException; - - /** - * @return String array. - * @throws PortableException In case of error. - */ - @Nullable public String[] readStringArray() throws PortableException; - - /** - * @return UUID array. - * @throws PortableException In case of error. - */ - @Nullable public UUID[] readUuidArray() throws PortableException; - - /** - * @return Date array. - * @throws PortableException In case of error. - */ - @Nullable public Date[] readDateArray() throws PortableException; - - /** - * @return Object array. - * @throws PortableException In case of error. - */ - @Nullable public Object[] readObjectArray() throws PortableException; - - /** - * @return Collection. - * @throws PortableException In case of error. - */ - @Nullable public Collection readCollection() throws PortableException; - - /** - * @param colCls Collection class. - * @return Collection. - * @throws PortableException In case of error. - */ - @Nullable public Collection readCollection(Class> colCls) - throws PortableException; - - /** - * @return Map. - * @throws PortableException In case of error. - */ - @Nullable public Map readMap() throws PortableException; - - /** - * @param mapCls Map class. - * @return Map. - * @throws PortableException In case of error. - */ - @Nullable public Map readMap(Class> mapCls) throws PortableException; - - /** - * @param enumCls Enum class. - * @return Value. - * @throws PortableException In case of error. - */ - @Nullable public > T readEnum(Class enumCls) throws PortableException; - - /** - * @param enumCls Enum class. - * @return Value. - * @throws PortableException In case of error. - */ - @Nullable public > T[] readEnumArray(Class enumCls) throws PortableException; -} diff --git a/modules/core/src/main/java/org/apache/ignite/portables/PortableRawWriter.java b/modules/core/src/main/java/org/apache/ignite/portables/PortableRawWriter.java deleted file mode 100644 index b8bd48797881f..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/portables/PortableRawWriter.java +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.portables; - -import org.jetbrains.annotations.*; - -import java.math.*; -import java.sql.*; -import java.util.*; -import java.util.Date; - -/** - * Raw writer for portable object. Raw writer does not write field name hash codes, therefore, - * making the format even more compact. However, if the raw writer is used, - * dynamic structure changes to the portable objects are not supported. - */ -public interface PortableRawWriter { - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeByte(byte val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeShort(short val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeInt(int val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeLong(long val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeFloat(float val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeDouble(double val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeChar(char val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeBoolean(boolean val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeDecimal(@Nullable BigDecimal val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeString(@Nullable String val) throws PortableException; - - /** - * @param val UUID to write. - * @throws PortableException In case of error. - */ - public void writeUuid(@Nullable UUID val) throws PortableException; - - /** - * @param val Date to write. - * @throws PortableException In case of error. - */ - public void writeDate(@Nullable Date val) throws PortableException; - - /** - * @param val Timestamp to write. - * @throws PortableException In case of error. - */ - public void writeTimestamp(@Nullable Timestamp val) throws PortableException; - - /** - * @param obj Value to write. - * @throws PortableException In case of error. - */ - public void writeObject(@Nullable Object obj) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeByteArray(@Nullable byte[] val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeShortArray(@Nullable short[] val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeIntArray(@Nullable int[] val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeLongArray(@Nullable long[] val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeFloatArray(@Nullable float[] val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeDoubleArray(@Nullable double[] val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeCharArray(@Nullable char[] val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeBooleanArray(@Nullable boolean[] val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeDecimalArray(@Nullable BigDecimal[] val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeStringArray(@Nullable String[] val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeUuidArray(@Nullable UUID[] val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeDateArray(@Nullable Date[] val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeObjectArray(@Nullable Object[] val) throws PortableException; - - /** - * @param col Collection to write. - * @throws PortableException In case of error. - */ - public void writeCollection(@Nullable Collection col) throws PortableException; - - /** - * @param map Map to write. - * @throws PortableException In case of error. - */ - public void writeMap(@Nullable Map map) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public > void writeEnum(T val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public > void writeEnumArray(T[] val) throws PortableException; -} diff --git a/modules/core/src/main/java/org/apache/ignite/portables/PortableReader.java b/modules/core/src/main/java/org/apache/ignite/portables/PortableReader.java deleted file mode 100644 index 8059389a0e5bc..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/portables/PortableReader.java +++ /dev/null @@ -1,286 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.portables; - -import org.jetbrains.annotations.*; - -import java.math.*; -import java.sql.*; -import java.util.*; -import java.util.Date; - -/** - * Reader for portable objects used in {@link PortableMarshalAware} implementations. - * Useful for the cases when user wants a fine-grained control over serialization. - *

      - * Note that Ignite never writes full strings for field or type names. Instead, - * for performance reasons, Ignite writes integer hash codes for type and field names. - * It has been tested that hash code conflicts for the type names or the field names - * within the same type are virtually non-existent and, to gain performance, it is safe - * to work with hash codes. For the cases when hash codes for different types or fields - * actually do collide, Ignite provides {@link PortableIdMapper} which - * allows to override the automatically generated hash code IDs for the type and field names. - */ -public interface PortableReader { - /** - * @param fieldName Field name. - * @return Byte value. - * @throws PortableException In case of error. - */ - public byte readByte(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Short value. - * @throws PortableException In case of error. - */ - public short readShort(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Integer value. - * @throws PortableException In case of error. - */ - public int readInt(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Long value. - * @throws PortableException In case of error. - */ - public long readLong(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @throws PortableException In case of error. - * @return Float value. - */ - public float readFloat(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Double value. - * @throws PortableException In case of error. - */ - public double readDouble(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Char value. - * @throws PortableException In case of error. - */ - public char readChar(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Boolean value. - * @throws PortableException In case of error. - */ - public boolean readBoolean(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Decimal value. - * @throws PortableException In case of error. - */ - @Nullable public BigDecimal readDecimal(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return String value. - * @throws PortableException In case of error. - */ - @Nullable public String readString(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return UUID. - * @throws PortableException In case of error. - */ - @Nullable public UUID readUuid(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Date. - * @throws PortableException In case of error. - */ - @Nullable public Date readDate(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Timestamp. - * @throws PortableException In case of error. - */ - @Nullable public Timestamp readTimestamp(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Object. - * @throws PortableException In case of error. - */ - @Nullable public T readObject(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Byte array. - * @throws PortableException In case of error. - */ - @Nullable public byte[] readByteArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Short array. - * @throws PortableException In case of error. - */ - @Nullable public short[] readShortArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Integer array. - * @throws PortableException In case of error. - */ - @Nullable public int[] readIntArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Long array. - * @throws PortableException In case of error. - */ - @Nullable public long[] readLongArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Float array. - * @throws PortableException In case of error. - */ - @Nullable public float[] readFloatArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Byte array. - * @throws PortableException In case of error. - */ - @Nullable public double[] readDoubleArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Char array. - * @throws PortableException In case of error. - */ - @Nullable public char[] readCharArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Boolean array. - * @throws PortableException In case of error. - */ - @Nullable public boolean[] readBooleanArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Decimal array. - * @throws PortableException In case of error. - */ - @Nullable public BigDecimal[] readDecimalArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return String array. - * @throws PortableException In case of error. - */ - @Nullable public String[] readStringArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return UUID array. - * @throws PortableException In case of error. - */ - @Nullable public UUID[] readUuidArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Date array. - * @throws PortableException In case of error. - */ - @Nullable public Date[] readDateArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Object array. - * @throws PortableException In case of error. - */ - @Nullable public Object[] readObjectArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Collection. - * @throws PortableException In case of error. - */ - @Nullable public Collection readCollection(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @param colCls Collection class. - * @return Collection. - * @throws PortableException In case of error. - */ - @Nullable public Collection readCollection(String fieldName, Class> colCls) - throws PortableException; - - /** - * @param fieldName Field name. - * @return Map. - * @throws PortableException In case of error. - */ - @Nullable public Map readMap(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @param mapCls Map class. - * @return Map. - * @throws PortableException In case of error. - */ - @Nullable public Map readMap(String fieldName, Class> mapCls) - throws PortableException; - - /** - * @param fieldName Field name. - * @param enumCls Enum class. - * @return Value. - * @throws PortableException In case of error. - */ - @Nullable public > T readEnum(String fieldName, Class enumCls) throws PortableException; - - /** - * @param fieldName Field name. - * @param enumCls Enum class. - * @return Value. - * @throws PortableException In case of error. - */ - @Nullable public > T[] readEnumArray(String fieldName, Class enumCls) - throws PortableException; - - /** - * Gets raw reader. Raw reader does not use field name hash codes, therefore, - * making the format even more compact. However, if the raw reader is used, - * dynamic structure changes to the portable objects are not supported. - * - * @return Raw reader. - */ - public PortableRawReader rawReader(); -} diff --git a/modules/core/src/main/java/org/apache/ignite/portables/PortableSerializer.java b/modules/core/src/main/java/org/apache/ignite/portables/PortableSerializer.java deleted file mode 100644 index 6b343a09f777f..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/portables/PortableSerializer.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.portables; - -/** - * Interface that allows to implement custom serialization logic for portable objects. - * Can be used instead of {@link PortableMarshalAware} in case if the class - * cannot be changed directly. - *

      - * Portable serializer can be configured for all portable objects via - * {@link PortableConfiguration#getSerializer()} method, or for a specific - * portable type via {@link PortableTypeConfiguration#getSerializer()} method. - */ -public interface PortableSerializer { - /** - * Writes fields to provided writer. - * - * @param obj Empty object. - * @param writer Portable object writer. - * @throws PortableException In case of error. - */ - public void writePortable(Object obj, PortableWriter writer) throws PortableException; - - /** - * Reads fields from provided reader. - * - * @param obj Empty object - * @param reader Portable object reader. - * @throws PortableException In case of error. - */ - public void readPortable(Object obj, PortableReader reader) throws PortableException; -} diff --git a/modules/core/src/main/java/org/apache/ignite/portables/PortableTypeConfiguration.java b/modules/core/src/main/java/org/apache/ignite/portables/PortableTypeConfiguration.java deleted file mode 100644 index 1af4097cc44f9..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/portables/PortableTypeConfiguration.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.portables; - -import org.apache.ignite.internal.util.typedef.internal.*; - -import java.sql.*; - -/** - * Defines configuration properties for a specific portable type. Providing per-type - * configuration is optional, as it is generally enough to provide global - * portable configuration in {@link PortableConfiguration} instance. However, - * this class allows you to change configuration properties for a specific - * portable type without affecting configuration for other portable types. - *

      - * Per-type portable configuration can be specified in - * {@link PortableConfiguration#getTypeConfigurations()} method. - */ -public class PortableTypeConfiguration { - /** Class name. */ - private String clsName; - - /** ID mapper. */ - private PortableIdMapper idMapper; - - /** Serializer. */ - private PortableSerializer serializer; - - /** Use timestamp flag. */ - private Boolean useTs; - - /** Meta data enabled flag. */ - private Boolean metaDataEnabled; - - /** Keep deserialized flag. */ - private Boolean keepDeserialized; - - /** Affinity key field name. */ - private String affKeyFieldName; - - /** - */ - public PortableTypeConfiguration() { - // No-op. - } - - /** - * @param clsName Class name. - */ - public PortableTypeConfiguration(String clsName) { - this.clsName = clsName; - } - - /** - * Gets type name. - * - * @return Type name. - */ - public String getClassName() { - return clsName; - } - - /** - * Sets type name. - * - * @param clsName Type name. - */ - public void setClassName(String clsName) { - this.clsName = clsName; - } - - /** - * Gets ID mapper. - * - * @return ID mapper. - */ - public PortableIdMapper getIdMapper() { - return idMapper; - } - - /** - * Sets ID mapper. - * - * @param idMapper ID mapper. - */ - public void setIdMapper(PortableIdMapper idMapper) { - this.idMapper = idMapper; - } - - /** - * Gets serializer. - * - * @return Serializer. - */ - public PortableSerializer getSerializer() { - return serializer; - } - - /** - * Sets serializer. - * - * @param serializer Serializer. - */ - public void setSerializer(PortableSerializer serializer) { - this.serializer = serializer; - } - - /** - * If {@code true} then date values converted to {@link Timestamp} during unmarshalling. - * - * @return Flag indicating whether date values converted to {@link Timestamp} during unmarshalling. - */ - public Boolean isUseTimestamp() { - return useTs; - } - - /** - * @param useTs Flag indicating whether date values converted to {@link Timestamp} during unmarshalling. - */ - public void setUseTimestamp(Boolean useTs) { - this.useTs = useTs; - } - - /** - * Defines whether meta data is collected for this type. If provided, this value will override - * {@link PortableConfiguration#isMetaDataEnabled()} property. - * - * @return Whether meta data is collected. - */ - public Boolean isMetaDataEnabled() { - return metaDataEnabled; - } - - /** - * @param metaDataEnabled Whether meta data is collected. - */ - public void setMetaDataEnabled(Boolean metaDataEnabled) { - this.metaDataEnabled = metaDataEnabled; - } - - /** - * Defines whether {@link PortableObject} should cache deserialized instance. If provided, - * this value will override {@link PortableConfiguration#isKeepDeserialized()} property. - * - * @return Whether deserialized value is kept. - */ - public Boolean isKeepDeserialized() { - return keepDeserialized; - } - - /** - * @param keepDeserialized Whether deserialized value is kept. - */ - public void setKeepDeserialized(Boolean keepDeserialized) { - this.keepDeserialized = keepDeserialized; - } - - /** - * Gets affinity key field name. - * - * @return Affinity key field name. - */ - public String getAffinityKeyFieldName() { - return affKeyFieldName; - } - - /** - * Sets affinity key field name. - * - * @param affKeyFieldName Affinity key field name. - */ - public void setAffinityKeyFieldName(String affKeyFieldName) { - this.affKeyFieldName = affKeyFieldName; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(PortableTypeConfiguration.class, this, super.toString()); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/portables/PortableWriter.java b/modules/core/src/main/java/org/apache/ignite/portables/PortableWriter.java deleted file mode 100644 index 1b44aa3b857f7..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/portables/PortableWriter.java +++ /dev/null @@ -1,265 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.portables; - -import org.jetbrains.annotations.*; - -import java.math.*; -import java.sql.*; -import java.util.*; -import java.util.Date; - -/** - * Writer for portable object used in {@link PortableMarshalAware} implementations. - * Useful for the cases when user wants a fine-grained control over serialization. - *

      - * Note that Ignite never writes full strings for field or type names. Instead, - * for performance reasons, Ignite writes integer hash codes for type and field names. - * It has been tested that hash code conflicts for the type names or the field names - * within the same type are virtually non-existent and, to gain performance, it is safe - * to work with hash codes. For the cases when hash codes for different types or fields - * actually do collide, Ignite provides {@link PortableIdMapper} which - * allows to override the automatically generated hash code IDs for the type and field names. - */ -public interface PortableWriter { - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeByte(String fieldName, byte val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeShort(String fieldName, short val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeInt(String fieldName, int val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeLong(String fieldName, long val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeFloat(String fieldName, float val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeDouble(String fieldName, double val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeChar(String fieldName, char val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeBoolean(String fieldName, boolean val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeDecimal(String fieldName, @Nullable BigDecimal val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeString(String fieldName, @Nullable String val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val UUID to write. - * @throws PortableException In case of error. - */ - public void writeUuid(String fieldName, @Nullable UUID val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Date to write. - * @throws PortableException In case of error. - */ - public void writeDate(String fieldName, @Nullable Date val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Timestamp to write. - * @throws PortableException In case of error. - */ - public void writeTimestamp(String fieldName, @Nullable Timestamp val) throws PortableException; - - /** - * @param fieldName Field name. - * @param obj Value to write. - * @throws PortableException In case of error. - */ - public void writeObject(String fieldName, @Nullable Object obj) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeByteArray(String fieldName, @Nullable byte[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeShortArray(String fieldName, @Nullable short[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeIntArray(String fieldName, @Nullable int[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeLongArray(String fieldName, @Nullable long[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeFloatArray(String fieldName, @Nullable float[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeDoubleArray(String fieldName, @Nullable double[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeCharArray(String fieldName, @Nullable char[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeBooleanArray(String fieldName, @Nullable boolean[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeDecimalArray(String fieldName, @Nullable BigDecimal[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeStringArray(String fieldName, @Nullable String[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeUuidArray(String fieldName, @Nullable UUID[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeDateArray(String fieldName, @Nullable Date[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeObjectArray(String fieldName, @Nullable Object[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param col Collection to write. - * @throws PortableException In case of error. - */ - public void writeCollection(String fieldName, @Nullable Collection col) throws PortableException; - - /** - * @param fieldName Field name. - * @param map Map to write. - * @throws PortableException In case of error. - */ - public void writeMap(String fieldName, @Nullable Map map) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public > void writeEnum(String fieldName, T val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public > void writeEnumArray(String fieldName, T[] val) throws PortableException; - - /** - * Gets raw writer. Raw writer does not write field name hash codes, therefore, - * making the format even more compact. However, if the raw writer is used, - * dynamic structure changes to the portable objects are not supported. - * - * @return Raw writer. - */ - public PortableRawWriter rawWriter(); -} diff --git a/modules/core/src/main/java/org/apache/ignite/portables/package.html b/modules/core/src/main/java/org/apache/ignite/portables/package.html deleted file mode 100644 index 4c645bed3366c..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/portables/package.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - Contains Portable Objects related functionality. - - diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java index 2fe8b85bd84e8..fe4fc15914501 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java @@ -255,7 +255,6 @@ protected CacheConfiguration cacheConfiguration(String gridName) throws Exceptio cfg.setAtomicityMode(atomicityMode()); cfg.setWriteSynchronizationMode(writeSynchronization()); cfg.setDistributionMode(distributionMode()); - cfg.setPortableEnabled(portableEnabled()); if (cacheMode() == PARTITIONED) cfg.setBackups(1); @@ -344,13 +343,6 @@ protected boolean lockingEnabled() { return true; } - /** - * @return Whether portable mode is enabled. - */ - protected boolean portableEnabled() { - return false; - } - /** * @return {@code True} for partitioned caches. */ diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMemoryModeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMemoryModeSelfTest.java index c1a84c32e6ce9..842468bfeea2d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMemoryModeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMemoryModeSelfTest.java @@ -87,7 +87,6 @@ public class GridCacheMemoryModeSelfTest extends GridCommonAbstractTest { cacheCfg.setAtomicityMode(atomicity); cacheCfg.setOffHeapMaxMemory(offheapSize); cacheCfg.setQueryIndexEnabled(memoryMode != CacheMemoryMode.OFFHEAP_VALUES); - cacheCfg.setPortableEnabled(portableEnabled()); cfg.setCacheConfiguration(cacheCfg); cfg.setMarshaller(new OptimizedMarshaller(false)); @@ -95,13 +94,6 @@ public class GridCacheMemoryModeSelfTest extends GridCommonAbstractTest { return cfg; } - /** - * @return Portable enabled flag. - */ - protected boolean portableEnabled() { - return false; - } - /** * @throws Exception If failed. */ diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapMultiThreadedUpdateAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapMultiThreadedUpdateAbstractSelfTest.java index 064c033f2b440..e168f2bfb3bff 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapMultiThreadedUpdateAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapMultiThreadedUpdateAbstractSelfTest.java @@ -57,7 +57,6 @@ public abstract class GridCacheOffHeapMultiThreadedUpdateAbstractSelfTest extend ccfg.setOffHeapMaxMemory(1024 * 1024); ccfg.setWriteSynchronizationMode(FULL_SYNC); ccfg.setAtomicWriteOrderMode(PRIMARY); - ccfg.setPortableEnabled(portableEnabled()); return ccfg; } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapTieredAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapTieredAbstractSelfTest.java index bf607b4ac0a0d..4d6162e2856cf 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapTieredAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapTieredAbstractSelfTest.java @@ -21,7 +21,7 @@ import org.apache.ignite.cache.*; import org.apache.ignite.configuration.*; import org.apache.ignite.lang.*; -import org.apache.ignite.portables.*; +import org.gridgain.grid.portables.*; import org.apache.ignite.transactions.*; import org.jetbrains.annotations.*; import org.junit.*; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapTieredEvictionAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapTieredEvictionAbstractSelfTest.java index b760af8638a3b..bc43dec730297 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapTieredEvictionAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapTieredEvictionAbstractSelfTest.java @@ -22,7 +22,7 @@ import org.apache.ignite.configuration.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.portables.*; +import org.gridgain.grid.portables.*; import org.apache.ignite.testframework.*; import javax.cache.processor.*; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractTest.java index f704a7553a8f9..0a4596eaf76b1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractTest.java @@ -121,7 +121,6 @@ protected CacheConfiguration cacheConfiguration(String gridName) throws Exceptio cfg.setWriteSynchronizationMode(writeSynchronization()); cfg.setDistributionMode(distributionMode()); - cfg.setPortableEnabled(portableEnabled()); cfg.setCacheLoaderFactory(loaderFactory()); @@ -198,13 +197,6 @@ protected CacheWriteSynchronizationMode writeSynchronization() { return FULL_SYNC; } - /** - * @return Whether portable mode is enabled. - */ - protected boolean portableEnabled() { - return false; - } - /** * @return {@code true} if swap should be enabled. */ diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractDistributedByteArrayValuesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractDistributedByteArrayValuesSelfTest.java index fceba6df7d613..0bc842dbf24da 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractDistributedByteArrayValuesSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractDistributedByteArrayValuesSelfTest.java @@ -68,13 +68,6 @@ public abstract class GridCacheAbstractDistributedByteArrayValuesSelfTest extend */ protected abstract boolean peerClassLoading(); - /** - * @return Whether portable mode is enabled. - */ - protected boolean portableEnabled() { - return false; - } - /** * @return How many grids to start. */ @@ -89,7 +82,6 @@ protected CacheConfiguration cacheConfiguration() { CacheConfiguration cfg = cacheConfiguration0(); cfg.setName(CACHE_REGULAR); - cfg.setPortableEnabled(portableEnabled()); return cfg; } @@ -106,7 +98,6 @@ protected CacheConfiguration offheapCacheConfiguration() { CacheConfiguration cfg = offheapCacheConfiguration0(); cfg.setName(CACHE_OFFHEAP); - cfg.setPortableEnabled(portableEnabled()); return cfg; } @@ -118,7 +109,6 @@ protected CacheConfiguration offheapTieredCacheConfiguration() { CacheConfiguration cfg = offheapTieredCacheConfiguration0(); cfg.setName(CACHE_OFFHEAP_TIERED); - cfg.setPortableEnabled(portableEnabled()); return cfg; } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractPartitionedByteArrayValuesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractPartitionedByteArrayValuesSelfTest.java index c5fadafa5a4f8..485f95ca8e47c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractPartitionedByteArrayValuesSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractPartitionedByteArrayValuesSelfTest.java @@ -54,7 +54,6 @@ public abstract class GridCacheAbstractPartitionedByteArrayValuesSelfTest extend cfg.setSwapEnabled(true); cfg.setEvictSynchronized(false); cfg.setEvictNearSynchronized(false); - cfg.setPortableEnabled(portableEnabled()); return cfg; } @@ -71,7 +70,6 @@ public abstract class GridCacheAbstractPartitionedByteArrayValuesSelfTest extend cfg.setMemoryMode(OFFHEAP_VALUES); cfg.setOffHeapMaxMemory(100 * 1024 * 1024); cfg.setQueryIndexEnabled(false); - cfg.setPortableEnabled(portableEnabled()); return cfg; } @@ -88,7 +86,6 @@ public abstract class GridCacheAbstractPartitionedByteArrayValuesSelfTest extend cfg.setMemoryMode(OFFHEAP_TIERED); cfg.setOffHeapMaxMemory(100 * 1024 * 1024); cfg.setQueryIndexEnabled(false); - cfg.setPortableEnabled(portableEnabled()); return cfg; } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/GridCacheSwapScanQueryAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/GridCacheSwapScanQueryAbstractSelfTest.java index df305c13ce042..62f02372520d7 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/GridCacheSwapScanQueryAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/GridCacheSwapScanQueryAbstractSelfTest.java @@ -22,7 +22,6 @@ import org.apache.ignite.configuration.*; import org.apache.ignite.lang.*; import org.apache.ignite.marshaller.optimized.*; -import org.apache.ignite.portables.*; import org.apache.ignite.spi.discovery.tcp.*; import org.apache.ignite.spi.discovery.tcp.ipfinder.*; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*; @@ -69,14 +68,6 @@ public abstract class GridCacheSwapScanQueryAbstractSelfTest extends GridCommonA cfg.setCacheConfiguration(cacheConfiguration(ATOMIC_CACHE_NAME, ATOMIC), cacheConfiguration(TRANSACTIONAL_CACHE_NAME, TRANSACTIONAL)); - if (portableEnabled()) { - PortableConfiguration pCfg = new PortableConfiguration(); - - pCfg.setClassNames(Arrays.asList(Key.class.getName(), Person.class.getName())); - - cfg.setPortableConfiguration(pCfg); - } - return cfg; } @@ -102,18 +93,11 @@ private CacheConfiguration cacheConfiguration(String name, CacheAtomicityMode at ccfg.setAtomicWriteOrderMode(PRIMARY); - ccfg.setPortableEnabled(portableEnabled()); - ccfg.setWriteSynchronizationMode(FULL_SYNC); return ccfg; } - /** - * @return Portable enabled flag. - */ - protected abstract boolean portableEnabled(); - /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { startGrids(4); @@ -192,36 +176,7 @@ private void checkQuery(GridCache cache) throws Exception { */ @SuppressWarnings({"unchecked", "IfMayBeConditional"}) private void checkProjectionFilter(GridCache cache, int expCnt) throws Exception { - CacheProjection prj; - - if (portableEnabled()) { - prj = cache.projection(new IgnitePredicate>() { - @Override public boolean apply(CacheEntry e) { - Key key = e.getKey().deserialize(); - Person val = e.peek().deserialize(); - - assertNotNull(e.version()); - - assertEquals(key.id, (Integer)val.salary); - - return key.id % 100 != 0; - } - }); - } - else { - prj = cache.projection(new IgnitePredicate>() { - @Override public boolean apply(CacheEntry e) { - Key key = e.getKey(); - Person val = e.peek(); - - assertNotNull(e.version()); - - assertEquals(key.id, (Integer)val.salary); - - return key.id % 100 != 0; - } - }); - } + CacheProjection prj = createProjectionForFilter(cache); CacheQuery> qry = prj.queries().createScanQuery( new IgniteBiPredicate() { @@ -238,6 +193,25 @@ private void checkProjectionFilter(GridCache cache, int expCnt) throws Exception assertEquals(expCnt, res.size()); } + /** + * @param cache Cache. + * @return Projection. + */ + protected CacheProjection createProjectionForFilter(GridCache cache) { + return cache.projection(new IgnitePredicate>() { + @Override public boolean apply(CacheEntry e) { + Key key = e.getKey(); + Person val = e.peek(); + + assertNotNull(e.version()); + + assertEquals(key.id, (Integer)val.salary); + + return key.id % 100 != 0; + } + }); + } + /** * @param cache Cache. * @param expCnt Expected entries in query result. diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/GridCacheSwapScanQuerySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/GridCacheSwapScanQuerySelfTest.java index c15cd5beae716..61f921ceef5e5 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/GridCacheSwapScanQuerySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/GridCacheSwapScanQuerySelfTest.java @@ -21,8 +21,4 @@ * */ public class GridCacheSwapScanQuerySelfTest extends GridCacheSwapScanQueryAbstractSelfTest { - /** {@inheritDoc} */ - @Override protected boolean portableEnabled() { - return false; - } } diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java index 4c28bc577339e..19ea25014a230 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java @@ -167,11 +167,6 @@ public IgniteMock( return null; } - /** {@inheritDoc} */ - @Override public IgnitePortables portables() { - return null; - } - /** {@inheritDoc} */ @Override public GridCache cache(@Nullable String name) { return null; From e8302ce92a9a3bd8477f3e6696aa8436341bb418 Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Sat, 7 Feb 2015 20:12:53 -0800 Subject: [PATCH 43/95] IGNITE-61 - Direct marshalling --- .../CommunicationMessageCodeGenerator.java | 218 ++------- .../direct/DirectByteBufferStream.java | 460 +++++++++++++++++- .../internal/direct/DirectMessageReader.java | 46 ++ .../internal/direct/DirectMessageWriter.java | 36 ++ .../internal/util/GridByteArrayList.java | 28 +- .../ignite/internal/util/GridLongList.java | 29 +- .../ignite/internal/util/IgniteUtils.java | 26 +- ...ridUuidCache.java => IgniteUuidCache.java} | 6 +- .../communication/MessageReader.java | 12 + .../communication/MessageWriter.java | 12 + 10 files changed, 651 insertions(+), 222 deletions(-) rename modules/core/src/main/java/org/apache/ignite/internal/util/{GridUuidCache.java => IgniteUuidCache.java} (92%) diff --git a/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java index b43434f0d7840..7296cccf61b90 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java @@ -155,17 +155,6 @@ public void generateAll(boolean write) throws Exception { else generate(cls); } - -// type = 0; -// -// for (Class cls : classes) { -// if (Modifier.isAbstract(cls.getModifiers())) -// continue; -// -// System.out.println("case " + type++ + ":"); -// System.out.println(" return new " + cls.getSimpleName() + "();"); -// System.out.println(); -// } } /** @@ -223,11 +212,6 @@ else if (line.contains("public boolean readFrom(ByteBuffer buf)")) { readFound = true; } -// else if (type >= 0 && line.contains("public byte directType()")) { -// src.add(TAB + TAB + "return " + type + ';'); -// -// skip = true; -// } else if (line.contains("public MessageAdapter clone()")) { src.addAll(clone); @@ -537,208 +521,66 @@ private void returnFalseIfWriteFailed(Class type, String name, @Nullable Clas String field = raw ? "null" : '"' + name + '"'; if (type == byte.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putByte", field, name); + returnFalseIfFailed(write, "writer.writeByte", field, name); else if (type == short.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putShort", field, name); + returnFalseIfFailed(write, "writer.writeShort", field, name); else if (type == int.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putInt", field, name); + returnFalseIfFailed(write, "writer.writeInt", field, name); else if (type == long.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putLong", field, name); + returnFalseIfFailed(write, "writer.writeLong", field, name); else if (type == float.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putFloat", field, name); + returnFalseIfFailed(write, "writer.writeFloat", field, name); else if (type == double.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putDouble", field, name); + returnFalseIfFailed(write, "writer.writeDouble", field, name); else if (type == char.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putChar", field, name); + returnFalseIfFailed(write, "writer.writeChar", field, name); else if (type == boolean.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putBoolean", field, name); + returnFalseIfFailed(write, "writer.writeBoolean", field, name); else if (type == byte[].class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putByteArray", field, name); + returnFalseIfFailed(write, "writer.writeByteArray", field, name); else if (type == short[].class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putShortArray", field, name); + returnFalseIfFailed(write, "writer.writeShortArray", field, name); else if (type == int[].class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putIntArray", field, name); + returnFalseIfFailed(write, "writer.writeIntArray", field, name); else if (type == long[].class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putLongArray", field, name); + returnFalseIfFailed(write, "writer.writeLongArray", field, name); else if (type == float[].class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putFloatArray", field, name); + returnFalseIfFailed(write, "writer.writeFloatArray", field, name); else if (type == double[].class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putDoubleArray", field, name); + returnFalseIfFailed(write, "writer.writeDoubleArray", field, name); else if (type == char[].class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putCharArray", field, name); + returnFalseIfFailed(write, "writer.writeCharArray", field, name); else if (type == boolean[].class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putBooleanArray", field, name); + returnFalseIfFailed(write, "writer.writeBooleanArray", field, name); else if (type == UUID.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putUuid", field, name); - else if (type == ByteBuffer.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putByteBuffer", field, name); + returnFalseIfFailed(write, "writer.writeByteArray", field, "U.uuidToBytes(" + name + ")"); else if (type == IgniteUuid.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putGridUuid", field, name); - else if (type == GridClockDeltaVersion.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putClockDeltaVersion", field, name); + returnFalseIfFailed(write, "writer.writeByteArray", field, "U.igniteUuidToBytes(" + name + ")"); else if (type == GridByteArrayList.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putByteArrayList", field, name); + returnFalseIfFailed(write, "writer.writeByteArray", field, name); else if (type == GridLongList.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putLongList", field, name); - else if (type == GridCacheVersion.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putCacheVersion", field, name); - else if (type == GridDhtPartitionExchangeId.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putDhtPartitionExchangeId", field, name); - else if (type == GridCacheValueBytes.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putValueBytes", field, name); - //else if (type == GridDrInternalRequestEntry.class) - // returnFalseIfFailed(write, COMM_STATE_VAR + ".putDrInternalRequestEntry", field, name); + returnFalseIfFailed(write, "writer.writeLongList", field, name); else if (type == String.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putString", field, name); + returnFalseIfFailed(write, "writer.writeString", field, name); else if (type == BitSet.class) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putBitSet", field, name); + returnFalseIfFailed(write, "writer.writeBitSet", field, name); else if (type.isEnum()) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putEnum", field, name); + returnFalseIfFailed(write, "writer.writeEnum", field, name); else if (BASE_CLS.isAssignableFrom(type)) - returnFalseIfFailed(write, COMM_STATE_VAR + ".putMessage", field, name); - else if (type.isArray() || Collection.class.isAssignableFrom(type)) { - boolean isArr = type.isArray(); - - if (isArr) - colItemType = type.getComponentType(); - + returnFalseIfFailed(write, "writer.writeMessage", field, name); + else if (type.isArray()) + returnFalseIfFailed(write, "writer.writeArray", field, name); + else if (Collection.class.isAssignableFrom(type)) { assert colItemType != null; - write.add(builder().a("if (").a(name).a(" != null) {").toString()); - - indent++; - - write.add(builder().a("if (").a(IT_VAR).a(" == null) {").toString()); - - indent++; - - returnFalseIfFailed(write, COMM_STATE_VAR + ".putInt", "null", name + "." + (isArr ? "length" : "size()")); - - write.add(EMPTY); - write.add(builder().a(IT_VAR).a(" = ").a(isArr ? "arrayIterator(" + name + ")" : name + ".iterator()"). - a(";").toString()); - - indent--; - - write.add(builder().a("}").toString()); - write.add(EMPTY); - write.add(builder().a("while (").a(IT_VAR).a(".hasNext() || ").a(CUR_VAR).a(" != NULL").a(") {"). - toString()); - - indent++; - - write.add(builder().a("if (").a(CUR_VAR).a(" == NULL)").toString()); - - indent++; - - write.add(builder().a(CUR_VAR).a(" = ").a(IT_VAR).a(".next();").toString()); - - indent--; - - write.add(EMPTY); - - returnFalseIfWriteFailed(colItemType, "(" + colItemType.getSimpleName() + ")" + CUR_VAR, - null, null, null, true); - - write.add(EMPTY); - write.add(builder().a(CUR_VAR).a(" = NULL;").toString()); - - indent--; - - write.add(builder().a("}").toString()); - write.add(EMPTY); - write.add(builder().a(IT_VAR).a(" = null;").toString()); - - indent--; - - write.add(builder().a("} else {").toString()); - - indent++; - - returnFalseIfFailed(write, COMM_STATE_VAR + ".putInt", "null", "-1"); - - indent--; - - write.add(builder().a("}").toString()); + returnFalseIfFailed(write, "writer.writeCollection", field, name, colItemType.getSimpleName() + ".class"); } else if (Map.class.isAssignableFrom(type)) { assert mapKeyType != null; assert mapValType != null; - write.add(builder().a("if (").a(name).a(" != null) {").toString()); - - indent++; - - write.add(builder().a("if (").a(IT_VAR).a(" == null) {").toString()); - - indent++; - - returnFalseIfFailed(write, COMM_STATE_VAR + ".putInt", "null", name + ".size()"); - - write.add(EMPTY); - write.add(builder().a(IT_VAR).a(" = ").a(name).a(".entrySet().iterator();").toString()); - - indent--; - - write.add(builder().a("}").toString()); - write.add(EMPTY); - write.add(builder().a("while (").a(IT_VAR).a(".hasNext() || ").a(CUR_VAR).a(" != NULL").a(") {"). - toString()); - - indent++; - - write.add(builder().a("if (").a(CUR_VAR).a(" == NULL)").toString()); - - indent++; - - write.add(builder().a(CUR_VAR).a(" = ").a(IT_VAR).a(".next();").toString()); - - indent--; - - String entryType = "Map.Entry<" + U.box(mapKeyType).getSimpleName() + ", " + - U.box(mapValType).getSimpleName() + ">"; - - write.add(EMPTY); - write.add(builder().a(entryType).a(" e = (").a(entryType).a(")").a(CUR_VAR).a(";").toString()); - write.add(EMPTY); - write.add(builder().a("if (!").a(KEY_DONE_VAR).a(") {").toString()); - - indent++; - - returnFalseIfWriteFailed(mapKeyType, "e.getKey()", null, null, null, true); - - write.add(EMPTY); - write.add(builder().a(KEY_DONE_VAR).a(" = true;").toString()); - - indent--; - - write.add(builder().a("}").toString()); - write.add(EMPTY); - - returnFalseIfWriteFailed(mapValType, "e.getValue()", null, null, null, true); - - write.add(EMPTY); - write.add(builder().a(KEY_DONE_VAR).a(" = false;").toString()); - write.add(EMPTY); - write.add(builder().a(CUR_VAR).a(" = NULL;").toString()); - - indent--; - - write.add(builder().a("}").toString()); - write.add(EMPTY); - write.add(builder().a(IT_VAR).a(" = null;").toString()); - - indent--; - - write.add(builder().a("} else {").toString()); - - indent++; - - returnFalseIfFailed(write, COMM_STATE_VAR + ".putInt", "null", "-1"); - - indent--; - - write.add(builder().a("}").toString()); + returnFalseIfFailed(write, "writer.writeMap", field, name, mapKeyType.getSimpleName() + ".class", + mapValType.getSimpleName() + ".class"); } else throw new IllegalStateException("Unsupported type: " + type); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java index 0f6a6f9e70f2e..cbb8d4c826233 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java @@ -18,7 +18,6 @@ package org.apache.ignite.internal.direct; import org.apache.ignite.internal.util.*; -import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; import org.apache.ignite.plugin.extensions.communication.*; @@ -208,17 +207,38 @@ public class DirectByteBufferStream { private static final Object NULL = new Object(); /** */ - private static final Map, IgniteInClosure> WRITERS = U.newHashMap(8); - - /** */ - private static final Map, IgniteOutClosure> READERS = U.newHashMap(8); + private static final Map, Type> TYPES = U.newHashMap(30); static { - WRITERS.put(byte.class, new CI1() { - @Override public void apply(Object o) { - - } - }); + TYPES.put(byte.class, Type.BYTE); + TYPES.put(Byte.class, Type.BYTE); + TYPES.put(short.class, Type.SHORT); + TYPES.put(Short.class, Type.SHORT); + TYPES.put(int.class, Type.INT); + TYPES.put(Integer.class, Type.INT); + TYPES.put(long.class, Type.LONG); + TYPES.put(Long.class, Type.LONG); + TYPES.put(float.class, Type.FLOAT); + TYPES.put(Float.class, Type.FLOAT); + TYPES.put(double.class, Type.DOUBLE); + TYPES.put(Double.class, Type.DOUBLE); + TYPES.put(char.class, Type.CHAR); + TYPES.put(Character.class, Type.CHAR); + TYPES.put(boolean.class, Type.BOOLEAN); + TYPES.put(Boolean.class, Type.BOOLEAN); + TYPES.put(byte[].class, Type.BYTE_ARR); + TYPES.put(short[].class, Type.SHORT_ARR); + TYPES.put(int[].class, Type.INT_ARR); + TYPES.put(long[].class, Type.LONG_ARR); + TYPES.put(float[].class, Type.FLOAT_ARR); + TYPES.put(double[].class, Type.DOUBLE_ARR); + TYPES.put(char[].class, Type.CHAR_ARR); + TYPES.put(boolean[].class, Type.BOOLEAN_ARR); + TYPES.put(String.class, Type.STRING); + TYPES.put(BitSet.class, Type.BIT_SET); + TYPES.put(UUID.class, Type.UUID); + TYPES.put(IgniteUuid.class, Type.IGNITE_UUID); + TYPES.put(MessageAdapter.class, Type.MSG); } /** */ @@ -266,6 +286,9 @@ public class DirectByteBufferStream { /** */ private int readItems; + /** */ + private Object[] objArr; + /** */ private Collection col; @@ -485,6 +508,22 @@ public void writeBooleanArray(boolean[] val) { writeInt(-1); } + public void writeString(String val) { + writeByteArray(val != null ? val.getBytes() : null); + } + + public void writeBitSet(BitSet val) { + writeLongArray(val != null ? val.toLongArray() : null); + } + + public void writeUuid(UUID val) { + writeByteArray(val != null ? U.uuidToBytes(val) : null); + } + + public void writeIgniteUuid(IgniteUuid val) { + writeByteArray(val != null ? U.igniteUuidToBytes(val) : null); + } + /** * @param msg Message. */ @@ -495,6 +534,39 @@ public void writeMessage(MessageAdapter msg) { writeByte(Byte.MIN_VALUE); } + public void writeObjectArray(T[] arr, Class itemCls) { + if (arr != null) { + if (it == null) { + writeInt(arr.length); + + if (!lastFinished) + return; + + it = arrayIterator(arr); + } + + Type itemType = TYPES.get(itemCls); + + assert itemType != null; + + while (it.hasNext() || cur != NULL) { + if (cur == NULL) + cur = it.next(); + + write(itemType, cur); + + if (!lastFinished) + return; + + cur = NULL; + } + + it = null; + } + else + writeInt(-1); + } + public void writeCollection(Collection col, Class itemCls) { if (col != null) { if (it == null) { @@ -506,13 +578,15 @@ public void writeCollection(Collection col, Class itemCls) { it = col.iterator(); } - IgniteInClosure itemWriter = WRITERS.get(itemCls); + Type itemType = TYPES.get(itemCls); + + assert itemType != null; while (it.hasNext() || cur != NULL) { if (cur == NULL) cur = it.next(); - itemWriter.apply(cur); + write(itemType, cur); if (!lastFinished) return; @@ -526,6 +600,7 @@ public void writeCollection(Collection col, Class itemCls) { writeInt(-1); } + @SuppressWarnings("unchecked") public void writeMap(Map map, Class keyCls, Class valCls) { if (map != null) { if (it == null) { @@ -537,8 +612,11 @@ public void writeMap(Map map, Class keyCls, Class valCls) { it = map.entrySet().iterator(); } - IgniteInClosure keyWriter = WRITERS.get(keyCls); - IgniteInClosure valWriter = WRITERS.get(valCls); + Type keyType = TYPES.get(keyCls); + Type valType = TYPES.get(valCls); + + assert keyType != null; + assert valType != null; while (it.hasNext() || cur != NULL) { if (cur == NULL) @@ -547,7 +625,7 @@ public void writeMap(Map map, Class keyCls, Class valCls) { Map.Entry e = (Map.Entry)cur; if (!keyDone) { - keyWriter.apply(e.getKey()); + write(keyType, e.getKey()); if (!lastFinished) return; @@ -555,7 +633,7 @@ public void writeMap(Map map, Class keyCls, Class valCls) { keyDone = true; } - valWriter.apply(e.getValue()); + write(valType, e.getValue()); if (!lastFinished) return; @@ -738,6 +816,30 @@ public boolean[] readBooleanArray() { return readArray(BOOLEAN_ARR_CREATOR, 0, BOOLEAN_ARR_OFF); } + public String readString() { + byte[] arr = readByteArray(); + + return arr != null ? new String(arr) : null; + } + + public BitSet readBitSet() { + long[] arr = readLongArray(); + + return arr != null ? BitSet.valueOf(arr) : null; + } + + public UUID readUuid() { + byte[] arr = readByteArray(); + + return arr != null ? U.bytesToUuid(arr, 0) : null; + } + + public IgniteUuid readIgniteUuid() { + byte[] arr = readByteArray(); + + return arr != null ? U.bytesToIgniteUuid(arr, 0) : null; + } + /** * @return Message. */ @@ -770,6 +872,49 @@ public MessageAdapter readMessage() { return null; } + @SuppressWarnings("unchecked") + public T[] readObjectArray(Class itemCls) { + if (readSize == -1) { + int size = readInt(); + + if (!lastFinished) + return null; + + readSize = size; + } + + if (readSize >= 0) { + if (objArr == null) + objArr = new Object[readSize]; + + Type itemType = TYPES.get(itemCls); + + assert itemType != null; + + for (int i = readItems; i < readSize; i++) { + Object item = read(itemType); + + if (!lastFinished) + return null; + + objArr[i] = item; + + readItems++; + } + } + + readSize = -1; + readItems = 0; + cur = null; + + T[] objArr0 = (T[])objArr; + + objArr = null; + + return objArr0; + } + + @SuppressWarnings("unchecked") public Collection readCollection(Class itemCls) { if (readSize == -1) { int size = readInt(); @@ -784,10 +929,12 @@ public Collection readCollection(Class itemCls) { if (col == null) col = new ArrayList<>(readSize); - IgniteOutClosure itemReader = READERS.get(itemCls); + Type itemType = TYPES.get(itemCls); + + assert itemType != null; for (int i = readItems; i < readSize; i++) { - Object item = itemReader.apply(); + Object item = read(itemType); if (!lastFinished) return null; @@ -800,10 +947,16 @@ public Collection readCollection(Class itemCls) { readSize = -1; readItems = 0; + cur = null; + + Collection col0 = (Collection)col; + + col = null; - return (Collection)col; + return col0; } + @SuppressWarnings("unchecked") public Map readMap(Class keyCls, Class valCls) { if (readSize == -1) { int size = readInt(); @@ -818,12 +971,15 @@ public Map readMap(Class keyCls, Class valCls) { if (map == null) map = U.newHashMap(readSize); - IgniteOutClosure keyReader = READERS.get(keyCls); - IgniteOutClosure valReader = READERS.get(valCls); + Type keyType = TYPES.get(keyCls); + Type valType = TYPES.get(valCls); + + assert keyType != null; + assert valType != null; for (int i = readItems; i < readSize; i++) { if (!keyDone) { - Object key = keyReader.apply(); + Object key = read(keyType); if (!lastFinished) return null; @@ -832,7 +988,7 @@ public Map readMap(Class keyCls, Class valCls) { keyDone = true; } - Object val = valReader.apply(); + Object val = read(valType); if (!lastFinished) return null; @@ -849,7 +1005,11 @@ public Map readMap(Class keyCls, Class valCls) { readItems = 0; cur = null; - return (Map)map; + Map map0 = (Map)map; + + map = null; + + return map0; } /** @@ -935,6 +1095,7 @@ private T readArray(ArrayCreator creator, int lenShift, long off) { * @param len Length. * @return Array or special value if it was not fully read. */ + @SuppressWarnings("unchecked") private T readArray(ArrayCreator creator, int lenShift, long off, int len) { assert creator != null; @@ -996,6 +1157,213 @@ private T readArray(ArrayCreator creator, int lenShift, long off, int len } } + private void write(Type type, Object val) { + switch (type) { + case BYTE: + writeByte((Byte)val); + + break; + + case SHORT: + writeShort((Short)val); + + break; + + case INT: + writeInt((Integer)val); + + break; + + case LONG: + writeLong((Long)val); + + break; + + case FLOAT: + writeFloat((Float)val); + + break; + + case DOUBLE: + writeDouble((Double)val); + + break; + + case CHAR: + writeChar((Character)val); + + break; + + case BOOLEAN: + writeBoolean((Boolean)val); + + break; + + case BYTE_ARR: + writeByteArray((byte[])val); + + break; + + case SHORT_ARR: + writeShortArray((short[])val); + + break; + + case INT_ARR: + writeIntArray((int[])val); + + break; + + case LONG_ARR: + writeLongArray((long[])val); + + break; + + case FLOAT_ARR: + writeFloatArray((float[])val); + + break; + + case DOUBLE_ARR: + writeDoubleArray((double[])val); + + break; + + case CHAR_ARR: + writeCharArray((char[])val); + + break; + + case BOOLEAN_ARR: + writeBooleanArray((boolean[])val); + + break; + + case STRING: + writeString((String)val); + + break; + + case BIT_SET: + writeBitSet((BitSet)val); + + break; + + case UUID: + writeUuid((UUID)val); + + break; + + case IGNITE_UUID: + writeIgniteUuid((IgniteUuid)val); + + break; + + case MSG: + writeMessage((MessageAdapter)val); + + break; + + default: + throw new IllegalArgumentException("Unknown type: " + type); + } + } + + private Object read(Type type) { + switch (type) { + case BYTE: + return readByte(); + + case SHORT: + return readShort(); + + case INT: + return readInt(); + + case LONG: + return readLong(); + + case FLOAT: + return readFloat(); + + case DOUBLE: + return readDouble(); + + case CHAR: + return readChar(); + + case BOOLEAN: + return readBoolean(); + + case BYTE_ARR: + return readByteArray(); + + case SHORT_ARR: + return readShortArray(); + + case INT_ARR: + return readIntArray(); + + case LONG_ARR: + return readLongArray(); + + case FLOAT_ARR: + return readFloatArray(); + + case DOUBLE_ARR: + return readDoubleArray(); + + case CHAR_ARR: + return readCharArray(); + + case BOOLEAN_ARR: + return readBooleanArray(); + + case STRING: + return readString(); + + case BIT_SET: + return readBitSet(); + + case UUID: + return readUuid(); + + case IGNITE_UUID: + return readIgniteUuid(); + + case MSG: + return readMessage(); + + default: + throw new IllegalArgumentException("Unknown type: " + type); + } + } + + /** + * @param arr Array. + * @return Array iterator. + */ + private Iterator arrayIterator(final Object[] arr) { + return new Iterator() { + private int idx; + + @Override public boolean hasNext() { + return idx < arr.length; + } + + @Override public Object next() { + if (!hasNext()) + throw new NoSuchElementException(); + + return arr[idx++]; + } + + @Override public void remove() { + throw new UnsupportedOperationException(); + } + }; + } + /** * Array creator. */ @@ -1006,4 +1374,48 @@ private static interface ArrayCreator { */ public T create(int len); } + + private enum Type { + BYTE, + + SHORT, + + INT, + + LONG, + + FLOAT, + + DOUBLE, + + CHAR, + + BOOLEAN, + + BYTE_ARR, + + SHORT_ARR, + + INT_ARR, + + LONG_ARR, + + FLOAT_ARR, + + DOUBLE_ARR, + + CHAR_ARR, + + BOOLEAN_ARR, + + STRING, + + BIT_SET, + + UUID, + + IGNITE_UUID, + + MSG + } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java index 60c04d20adb5e..547c71a27bae7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java @@ -17,6 +17,7 @@ package org.apache.ignite.internal.direct; +import org.apache.ignite.lang.*; import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; @@ -189,6 +190,42 @@ public DirectMessageReader(GridTcpMessageFactory msgFactory) { return arr; } + /** {@inheritDoc} */ + @Override public String readString(String name) { + String val = stream.readString(); + + lastRead = stream.lastFinished(); + + return val; + } + + /** {@inheritDoc} */ + @Override public BitSet readBitSet(String name) { + BitSet val = stream.readBitSet(); + + lastRead = stream.lastFinished(); + + return val; + } + + /** {@inheritDoc} */ + @Override public UUID readUuid(String name) { + UUID val = stream.readUuid(); + + lastRead = stream.lastFinished(); + + return val; + } + + /** {@inheritDoc} */ + @Override public IgniteUuid readIgniteUuid(String name) { + IgniteUuid val = stream.readIgniteUuid(); + + lastRead = stream.lastFinished(); + + return val; + } + /** {@inheritDoc} */ @Nullable @Override public MessageAdapter readMessage(String name) { MessageAdapter msg = stream.readMessage(); @@ -198,6 +235,15 @@ public DirectMessageReader(GridTcpMessageFactory msgFactory) { return msg; } + /** {@inheritDoc} */ + @Override public T[] readObjectArray(String name, Class itemCls) { + T[] msg = stream.readObjectArray(itemCls); + + lastRead = stream.lastFinished(); + + return msg; + } + /** {@inheritDoc} */ @Override public Collection readCollection(String name, Class itemCls) { Collection col = stream.readCollection(itemCls); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java index 120b1489b6334..d7c679d5a3426 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java @@ -17,6 +17,7 @@ package org.apache.ignite.internal.direct; +import org.apache.ignite.lang.*; import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; @@ -147,6 +148,34 @@ public class DirectMessageWriter implements MessageWriter { return stream.lastFinished(); } + /** {@inheritDoc} */ + @Override public boolean writeString(String name, String val) { + stream.writeString(val); + + return stream.lastFinished(); + } + + /** {@inheritDoc} */ + @Override public boolean writeBitSet(String name, BitSet val) { + stream.writeBitSet(val); + + return stream.lastFinished(); + } + + /** {@inheritDoc} */ + @Override public boolean writeUuid(String name, UUID val) { + stream.writeUuid(val); + + return stream.lastFinished(); + } + + /** {@inheritDoc} */ + @Override public boolean writeIgniteUuid(String name, IgniteUuid val) { + stream.writeIgniteUuid(val); + + return stream.lastFinished(); + } + /** {@inheritDoc} */ @Override public boolean writeMessage(String name, @Nullable MessageAdapter msg) { if (msg != null) @@ -157,6 +186,13 @@ public class DirectMessageWriter implements MessageWriter { return stream.lastFinished(); } + /** {@inheritDoc} */ + @Override public boolean writeObjectArray(String name, T[] arr, Class itemCls) { + stream.writeObjectArray(arr, itemCls); + + return stream.lastFinished(); + } + /** {@inheritDoc} */ @Override public boolean writeCollection(String name, Collection col, Class itemCls) { stream.writeCollection(col, itemCls); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridByteArrayList.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridByteArrayList.java index a9b7ffc632562..9cff49ca0a41e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridByteArrayList.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridByteArrayList.java @@ -20,6 +20,7 @@ import org.apache.ignite.internal.util.io.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import java.io.*; import java.nio.*; @@ -28,7 +29,7 @@ /** * Re-sizable array implementation of the byte list (eliminating auto-boxing of primitive byte type). */ -public class GridByteArrayList implements Externalizable { +public class GridByteArrayList extends MessageAdapter implements Externalizable { /** */ private static final long serialVersionUID = 0L; @@ -405,6 +406,31 @@ public InputStream inputStream() { in.readFully(data, 0, size); } + /** {@inheritDoc} */ + @Override public boolean writeTo(ByteBuffer buf) { + return false; // TODO: implement. + } + + /** {@inheritDoc} */ + @Override public boolean readFrom(ByteBuffer buf) { + return false; // TODO: implement. + } + + /** {@inheritDoc} */ + @Override public byte directType() { + return 0; // TODO: implement. + } + + /** {@inheritDoc} */ + @Override public MessageAdapter clone() { + return null; // TODO: implement. + } + + /** {@inheritDoc} */ + @Override protected void clone0(MessageAdapter _msg) { + // TODO: implement. + } + /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridByteArrayList.class, this); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridLongList.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridLongList.java index d167e557090dd..25254676ed32c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridLongList.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridLongList.java @@ -19,16 +19,18 @@ import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; import java.io.*; +import java.nio.*; import java.util.*; /** * Minimal list API to work with primitive longs. This list exists * to avoid boxing/unboxing when using standard list from Java. */ -public class GridLongList implements Externalizable { +public class GridLongList extends MessageAdapter implements Externalizable { /** */ private static final long serialVersionUID = 0L; @@ -501,4 +503,29 @@ public void pop(int cnt) { else idx -= cnt; } + + /** {@inheritDoc} */ + @Override public boolean writeTo(ByteBuffer buf) { + return false; // TODO: implement. + } + + /** {@inheritDoc} */ + @Override public boolean readFrom(ByteBuffer buf) { + return false; // TODO: implement. + } + + /** {@inheritDoc} */ + @Override public byte directType() { + return 0; // TODO: implement. + } + + /** {@inheritDoc} */ + @Override public MessageAdapter clone() { + return null; // TODO: implement. + } + + /** {@inheritDoc} */ + @Override protected void clone0(MessageAdapter _msg) { + // TODO: implement. + } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java index a35a357c631c7..33a6e99044796 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java @@ -4423,7 +4423,7 @@ public static void writeUuid(DataOutput out, UUID uid) throws IOException { long most = in.readLong(); long least = in.readLong(); - return GridUuidCache.onGridUuidRead(new UUID(most, least)); + return IgniteUuidCache.onIgniteUuidRead(new UUID(most, least)); } return null; @@ -4463,7 +4463,7 @@ public static void writeGridUuid(DataOutput out, IgniteUuid uid) throws IOExcept long most = in.readLong(); long least = in.readLong(); - UUID globalId = GridUuidCache.onGridUuidRead(new UUID(most, least)); + UUID globalId = IgniteUuidCache.onIgniteUuidRead(new UUID(most, least)); long locId = in.readLong(); @@ -4473,6 +4473,22 @@ public static void writeGridUuid(DataOutput out, IgniteUuid uid) throws IOExcept return null; } + /** + * Converts GridUuid to bytes. + * + * @param uuid GridUuid to convert. + * @return Bytes. + */ + public static byte[] igniteUuidToBytes(IgniteUuid uuid) { + assert uuid != null; + + byte[] out = new byte[24]; + + igniteUuidToBytes(uuid, out, 0); + + return out; + } + /** * Converts GridUuid to bytes. * @@ -4480,7 +4496,7 @@ public static void writeGridUuid(DataOutput out, IgniteUuid uid) throws IOExcept * @param out Output array to write to. * @param off Offset from which to write. */ - public static void gridUuidToBytes(IgniteUuid uuid, byte[] out, int off) { + public static void igniteUuidToBytes(IgniteUuid uuid, byte[] out, int off) { assert uuid != null; U.longToBytes(uuid.globalId().getMostSignificantBits(), out, off); @@ -4495,12 +4511,12 @@ public static void gridUuidToBytes(IgniteUuid uuid, byte[] out, int off) { * @param off Offset from which start reading. * @return GridUuid instance. */ - public static IgniteUuid bytesToGridUuid(byte[] in, int off) { + public static IgniteUuid bytesToIgniteUuid(byte[] in, int off) { long most = U.bytesToLong(in, off); long least = U.bytesToLong(in, off + 8); long locId = U.bytesToLong(in, off + 16); - return new IgniteUuid(GridUuidCache.onGridUuidRead(new UUID(most, least)), locId); + return new IgniteUuid(IgniteUuidCache.onIgniteUuidRead(new UUID(most, least)), locId); } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridUuidCache.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUuidCache.java similarity index 92% rename from modules/core/src/main/java/org/apache/ignite/internal/util/GridUuidCache.java rename to modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUuidCache.java index bbcb7db32fa2e..045589c73a87d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridUuidCache.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUuidCache.java @@ -23,7 +23,7 @@ /** * */ -public final class GridUuidCache { +public final class IgniteUuidCache { /** Maximum cache size. */ private static final int MAX = 1024; @@ -37,7 +37,7 @@ public final class GridUuidCache { * @param id Read UUID. * @return Cached UUID equivalent to the read one. */ - public static UUID onGridUuidRead(UUID id) { + public static UUID onIgniteUuidRead(UUID id) { UUID cached = cache.get(id); if (cached == null) { @@ -53,7 +53,7 @@ public static UUID onGridUuidRead(UUID id) { /** * Ensure singleton. */ - private GridUuidCache() { + private IgniteUuidCache() { // No-op. } } diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java index d09f00c13e31d..aa1c09b9b4e4c 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java @@ -9,6 +9,8 @@ package org.apache.ignite.plugin.extensions.communication; +import org.apache.ignite.lang.*; + import java.nio.*; import java.util.*; @@ -50,8 +52,18 @@ public interface MessageReader { public boolean[] readBooleanArray(String name); + public String readString(String name); + + public BitSet readBitSet(String name); + + public UUID readUuid(String name); + + public IgniteUuid readIgniteUuid(String name); + public MessageAdapter readMessage(String name); + public T[] readObjectArray(String name, Class itemCls); + public Collection readCollection(String name, Class itemCls); public Map readMap(String name, Class keyCls, Class valCls); diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java index 5f7ddf9163abf..19bb268272640 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java @@ -9,6 +9,8 @@ package org.apache.ignite.plugin.extensions.communication; +import org.apache.ignite.lang.*; + import java.nio.*; import java.util.*; @@ -50,8 +52,18 @@ public interface MessageWriter { public boolean writeBooleanArray(String name, boolean[] val); + public boolean writeString(String name, String val); + + public boolean writeBitSet(String name, BitSet val); + + public boolean writeUuid(String name, UUID val); + + public boolean writeIgniteUuid(String name, IgniteUuid val); + public boolean writeMessage(String name, MessageAdapter val); + public boolean writeObjectArray(String name, T[] arr, Class itemCls); + public boolean writeCollection(String name, Collection col, Class itemCls); public boolean writeMap(String name, Map map, Class keyCls, Class valCls); From 43e19ee9b01cb6450348090de2a924cce466f603 Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Sat, 7 Feb 2015 21:00:55 -0800 Subject: [PATCH 44/95] IGNITE-61 - Direct marshalling --- .../CommunicationMessageCodeGenerator.java | 296 ++++-------------- .../ignite/internal/GridDirectVersion.java | 32 -- .../managers/communication/GridIoMessage.java | 2 +- ...chePessimisticCheckCommittedTxRequest.java | 2 - .../distributed/dht/GridDhtLockRequest.java | 3 - .../distributed/dht/GridDhtLockResponse.java | 1 - .../dht/GridDhtTxFinishRequest.java | 2 - .../dht/GridDhtTxPrepareRequest.java | 3 - .../dht/GridDhtTxPrepareResponse.java | 1 - .../atomic/GridDhtAtomicUpdateRequest.java | 7 - .../atomic/GridDhtAtomicUpdateResponse.java | 1 - .../atomic/GridNearAtomicUpdateRequest.java | 3 - .../atomic/GridNearAtomicUpdateResponse.java | 4 - .../distributed/near/GridNearGetRequest.java | 2 - .../distributed/near/GridNearLockRequest.java | 3 - .../near/GridNearTxFinishRequest.java | 3 - .../near/GridNearTxPrepareRequest.java | 2 - .../cache/query/GridCacheQueryRequest.java | 3 - .../communication/MessageReaderFactory.java | 2 +- .../communication/MessageWriterFactory.java | 2 +- 20 files changed, 59 insertions(+), 315 deletions(-) delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/GridDirectVersion.java diff --git a/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java index 7296cccf61b90..b828d73d952a4 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java @@ -10,11 +10,6 @@ package org.apache.ignite.codegen; import org.apache.ignite.internal.*; -import org.apache.ignite.internal.processors.cache.*; -import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.*; -import org.apache.ignite.internal.processors.cache.version.*; -import org.apache.ignite.internal.processors.clock.*; -import org.apache.ignite.internal.util.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; import org.apache.ignite.plugin.extensions.communication.*; @@ -23,7 +18,6 @@ import java.io.*; import java.lang.reflect.*; import java.net.*; -import java.nio.*; import java.util.*; import static java.lang.reflect.Modifier.*; @@ -35,27 +29,7 @@ public class CommunicationMessageCodeGenerator { /** */ private static final Comparator FIELD_CMP = new Comparator() { @Override public int compare(Field f1, Field f2) { - int ver1 = 0; - - GridDirectVersion verAnn1 = f1.getAnnotation(GridDirectVersion.class); - - if (verAnn1 != null) { - ver1 = verAnn1.value(); - - assert ver1 > 0; - } - - int ver2 = 0; - - GridDirectVersion verAnn2 = f2.getAnnotation(GridDirectVersion.class); - - if (verAnn2 != null) { - ver2 = verAnn2.value(); - - assert ver2 > 0; - } - - return ver1 < ver2 ? -1 : ver1 > ver2 ? 1 : f1.getName().compareTo(f2.getName()); + return f1.getName().compareTo(f2.getName()); } }; @@ -552,24 +526,22 @@ else if (type == char[].class) returnFalseIfFailed(write, "writer.writeCharArray", field, name); else if (type == boolean[].class) returnFalseIfFailed(write, "writer.writeBooleanArray", field, name); - else if (type == UUID.class) - returnFalseIfFailed(write, "writer.writeByteArray", field, "U.uuidToBytes(" + name + ")"); - else if (type == IgniteUuid.class) - returnFalseIfFailed(write, "writer.writeByteArray", field, "U.igniteUuidToBytes(" + name + ")"); - else if (type == GridByteArrayList.class) - returnFalseIfFailed(write, "writer.writeByteArray", field, name); - else if (type == GridLongList.class) - returnFalseIfFailed(write, "writer.writeLongList", field, name); else if (type == String.class) returnFalseIfFailed(write, "writer.writeString", field, name); else if (type == BitSet.class) returnFalseIfFailed(write, "writer.writeBitSet", field, name); + else if (type == UUID.class) + returnFalseIfFailed(write, "writer.writeUuid", field, name); + else if (type == IgniteUuid.class) + returnFalseIfFailed(write, "writer.writeIgniteUuid", field, name); else if (type.isEnum()) returnFalseIfFailed(write, "writer.writeEnum", field, name); else if (BASE_CLS.isAssignableFrom(type)) returnFalseIfFailed(write, "writer.writeMessage", field, name); - else if (type.isArray()) - returnFalseIfFailed(write, "writer.writeArray", field, name); + else if (type.isArray()) { + returnFalseIfFailed(write, "writer.writeObjectArray", field, name, + type.getComponentType().getSimpleName() + ".class"); + } else if (Collection.class.isAssignableFrom(type)) { assert colItemType != null; @@ -603,223 +575,65 @@ private void returnFalseIfReadFailed(Class type, @Nullable String name, @Null String retType = type.getSimpleName(); if (type == byte.class) - returnFalseIfReadFailed("byte", name, null, COMM_STATE_VAR + ".getByte", field, false); + returnFalseIfReadFailed("byte", name, "reader.readByte", field); else if (type == short.class) - returnFalseIfReadFailed("short", name, null, COMM_STATE_VAR + ".getShort", field, false); + returnFalseIfReadFailed("short", name, "reader.readShort", field); else if (type == int.class) - returnFalseIfReadFailed("int", name, null, COMM_STATE_VAR + ".getInt", field, false); + returnFalseIfReadFailed("int", name, "reader.readInt", field); else if (type == long.class) - returnFalseIfReadFailed("long", name, null, COMM_STATE_VAR + ".getLong", field, false); + returnFalseIfReadFailed("long", name, "reader.readLong", field); else if (type == float.class) - returnFalseIfReadFailed("float", name, null, COMM_STATE_VAR + ".getFloat", field, false); + returnFalseIfReadFailed("float", name, "reader.readFloat", field); else if (type == double.class) - returnFalseIfReadFailed("double", name, null, COMM_STATE_VAR + ".getDouble", field, false); + returnFalseIfReadFailed("double", name, "reader.readDouble", field); else if (type == char.class) - returnFalseIfReadFailed("char", name, null, COMM_STATE_VAR + ".getChar", field, false); + returnFalseIfReadFailed("char", name, "reader.readChar", field); else if (type == boolean.class) - returnFalseIfReadFailed("boolean", name, null, COMM_STATE_VAR + ".getBoolean", field, false); + returnFalseIfReadFailed("boolean", name, "reader.readBoolean", field); else if (type == byte[].class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getByteArray", field, false); + returnFalseIfReadFailed(retType, name, "reader.readByteArray", field); else if (type == short[].class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getShortArray", field, false); + returnFalseIfReadFailed(retType, name, "reader.readShortArray", field); else if (type == int[].class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getIntArray", field, false); + returnFalseIfReadFailed(retType, name, "reader.readIntArray", field); else if (type == long[].class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getLongArray", field, false); + returnFalseIfReadFailed(retType, name, "reader.readLongArray", field); else if (type == float[].class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getFloatArray", field, false); + returnFalseIfReadFailed(retType, name, "reader.readFloatArray", field); else if (type == double[].class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getDoubleArray", field, false); + returnFalseIfReadFailed(retType, name, "reader.readDoubleArray", field); else if (type == char[].class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getCharArray", field, false); + returnFalseIfReadFailed(retType, name, "reader.readCharArray", field); else if (type == boolean[].class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getBooleanArray", field, false); - else if (type == UUID.class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getUuid", field, false); - else if (type == ByteBuffer.class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getByteBuffer", field, false); - else if (type == IgniteUuid.class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getGridUuid", field, false); - else if (type == GridClockDeltaVersion.class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getClockDeltaVersion", field, false); - else if (type == GridLongList.class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getLongList", field, false); - else if (type == GridByteArrayList.class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getByteArrayList", field, false); - else if (type == GridCacheVersion.class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getCacheVersion", field, false); - else if (type == GridDhtPartitionExchangeId.class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getDhtPartitionExchangeId", field, false); - else if (type == GridCacheValueBytes.class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getValueBytes", field, false); - //else if (type == GridDrInternalRequestEntry.class) - // returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getDrInternalRequestEntry", field, false); + returnFalseIfReadFailed(retType, name, "reader.readBooleanArray", field); else if (type == String.class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getString", field, false); + returnFalseIfReadFailed(retType, name, "reader.readString", field); else if (type == BitSet.class) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getBitSet", field, false); - else if (type.isEnum()) { - assert name != null; - - returnFalseIfReadFailed("byte", null, name + "0", COMM_STATE_VAR + ".getByte", field, false); - - read.add(EMPTY); - read.add(builder().a(name).a(" = ").a(type.getSimpleName()).a(".fromOrdinal(").a(name).a("0);").toString()); - } + returnFalseIfReadFailed(retType, name, "reader.readBitSet", field); + else if (type == UUID.class) + returnFalseIfReadFailed(retType, name, "reader.readUuid", field); + else if (type == IgniteUuid.class) + returnFalseIfReadFailed(retType, name, "reader.readGridUuid", field); + else if (type.isEnum()) + returnFalseIfReadFailed(retType, name, "reader.readEnum", field); else if (BASE_CLS.isAssignableFrom(type)) - returnFalseIfReadFailed(retType, name, null, COMM_STATE_VAR + ".getMessage", field, true); - else if (type.isArray() || Collection.class.isAssignableFrom(type)) { - assert name != null; - - boolean isArr = type.isArray(); - - if (isArr) - colItemType = type.getComponentType(); - + returnFalseIfReadFailed(retType, name, "reader.readMessage", field); + else if (type.isArray()) { + returnFalseIfReadFailed(retType, name, "reader.readObjectArray", field, + type.getComponentType().getSimpleName() + ".class"); + } + else if (Collection.class.isAssignableFrom(type)) { assert colItemType != null; - Class colType = Set.class.isAssignableFrom(type) ? HashSet.class : ArrayList.class; - - read.add(builder().a("if (").a(READ_SIZE_VAR).a(" == -1) {").toString()); - - indent++; - - returnFalseIfReadFailed(int.class, null, null, null, null, true); - - read.add(builder().a(READ_SIZE_VAR).a(" = ").a(DFLT_LOC_VAR).a(";").toString()); - - indent--; - - read.add(builder().a("}").toString()); - read.add(EMPTY); - read.add(builder().a("if (").a(READ_SIZE_VAR).a(" >= 0) {").toString()); - - indent++; - - read.add(builder().a("if (").a(name).a(" == null)").toString()); - - indent++; - - if (isArr) { - String val = colItemType.isArray() ? - colItemType.getComponentType().getSimpleName() + "[" + READ_SIZE_VAR + "][]" : - colItemType.getSimpleName() + "[" + READ_SIZE_VAR + "]"; - - read.add(builder().a(name).a(" = new ").a(val).a(";"). - toString()); - } - else { - read.add(builder().a(name).a(" = new ").a(colType.getSimpleName()).a("<>(").a(READ_SIZE_VAR).a(");"). - toString()); - } - - indent--; - - read.add(EMPTY); - read.add(builder().a("for (int i = ").a(READ_ITEMS_VAR).a("; i < ").a(READ_SIZE_VAR).a("; i++) {"). - toString()); - - indent++; - - String var = colItemType.isPrimitive() ? colItemType.getSimpleName() + " " + DFLT_LOC_VAR : null; - - returnFalseIfReadFailed(colItemType, var, null, null, null, true); - - read.add(EMPTY); - read.add(builder().a(name).a(isArr ? "[i] = " : ".add(").a("(").a(U.box(colItemType).getSimpleName()). - a(")").a(DFLT_LOC_VAR).a(isArr ? ";" : ");").toString()); - read.add(EMPTY); - read.add(builder().a(READ_ITEMS_VAR).a("++;").toString()); - - indent--; - - read.add(builder().a("}").toString()); - - indent--; - - read.add(builder().a("}").toString()); - read.add(EMPTY); - read.add(builder().a(READ_SIZE_VAR).a(" = -1;").toString()); - read.add(builder().a(READ_ITEMS_VAR).a(" = 0;").toString()); + returnFalseIfReadFailed(retType, name, "reader.readCollection", field, + colItemType.getSimpleName() + ".class"); } else if (Map.class.isAssignableFrom(type)) { - assert name != null; assert mapKeyType != null; assert mapValType != null; - Class mapType = LinkedHashMap.class.isAssignableFrom(type) ? LinkedHashMap.class : HashMap.class; - - read.add(builder().a("if (").a(READ_SIZE_VAR).a(" == -1) {").toString()); - - indent++; - - returnFalseIfReadFailed(int.class, null, null, null, null, true); - - read.add(builder().a(READ_SIZE_VAR).a(" = ").a(DFLT_LOC_VAR).a(";").toString()); - - indent--; - - read.add(builder().a("}").toString()); - read.add(EMPTY); - read.add(builder().a("if (").a(READ_SIZE_VAR).a(" >= 0) {").toString()); - - indent++; - - read.add(builder().a("if (").a(name).a(" == null)").toString()); - - indent++; - - read.add(builder().a(name).a(" = new ").a(mapType.getSimpleName()).a("<>(").a(READ_SIZE_VAR).a(", 1.0f);"). - toString()); - - indent--; - - read.add(EMPTY); - read.add(builder().a("for (int i = ").a(READ_ITEMS_VAR).a("; i < ").a(READ_SIZE_VAR).a("; i++) {"). - toString()); - - indent++; - - read.add(builder().a("if (!").a(KEY_DONE_VAR).a(") {").toString()); - - indent++; - - String var = mapKeyType.isPrimitive() ? mapKeyType.getSimpleName() + " " + DFLT_LOC_VAR : null; - - returnFalseIfReadFailed(mapKeyType, var, null, null, null, true); - - read.add(EMPTY); - read.add(builder().a(CUR_VAR).a(" = ").a(DFLT_LOC_VAR).a(";").toString()); - read.add(builder().a(KEY_DONE_VAR).a(" = true;").toString()); - - indent--; - - read.add(builder().a("}").toString()); - read.add(EMPTY); - - var = mapValType.isPrimitive() ? mapValType.getSimpleName() + " " + DFLT_LOC_VAR : null; - - returnFalseIfReadFailed(mapValType, var, null, null, null, true); - - read.add(EMPTY); - read.add(builder().a(name).a(".put((").a(U.box(mapKeyType).getSimpleName()).a(")").a(CUR_VAR). - a(", ").a(DFLT_LOC_VAR).a(");").toString()); - read.add(EMPTY); - read.add(builder().a(KEY_DONE_VAR).a(" = false;").toString()); - read.add(EMPTY); - read.add(builder().a(READ_ITEMS_VAR).a("++;").toString()); - - indent--; - - read.add(builder().a("}").toString()); - - indent--; - - read.add(builder().a("}").toString()); - read.add(EMPTY); - read.add(builder().a(READ_SIZE_VAR).a(" = -1;").toString()); - read.add(builder().a(READ_ITEMS_VAR).a(" = 0;").toString()); - read.add(builder().a(CUR_VAR).a(" = null;").toString()); + returnFalseIfReadFailed(retType, name, "reader.readMap", field, mapKeyType.getSimpleName() + ".class", + mapValType.getSimpleName() + ".class"); } else throw new IllegalStateException("Unsupported type: " + type); @@ -828,24 +642,26 @@ else if (Map.class.isAssignableFrom(type)) { /** * @param retType Return type. * @param var Variable name. - * @param locVar Local variable name. * @param mtd Method name. - * @param arg Method argument. - * @param cast Whether cast is needed. + * @param args Method arguments. */ - private void returnFalseIfReadFailed(String retType, @Nullable String var, @Nullable String locVar, String mtd, - @Nullable String arg, boolean cast) { + private void returnFalseIfReadFailed(String retType, String var, String mtd, @Nullable String... args) { assert retType != null; assert mtd != null; - if (var == null) - var = retType + " " + (locVar != null ? locVar : DFLT_LOC_VAR); + String argsStr = ""; + + if (args != null && args.length > 0) { + for (String arg : args) + argsStr += arg + ", "; + + argsStr = argsStr.substring(0, argsStr.length() - 2); + } - read.add(builder().a(var).a(" = ").a(cast ? "(" + retType + ")" : "").a(mtd). - a(arg != null ? "(" + arg + ");" : "();").toString()); + read.add(builder().a(var).a(" = ").a(mtd).a("(").a(argsStr).a(");").toString()); read.add(EMPTY); - read.add(builder().a("if (!").a(COMM_STATE_VAR).a(".lastRead())").toString()); + read.add(builder().a("if (!reader.lastRead())").toString()); indent++; @@ -872,7 +688,7 @@ private void returnFalseIfFailed(Collection code, String accessor, @Null argsStr = argsStr.substring(0, argsStr.length() - 2); } - code.add(builder().a("if (!").a(accessor).a("(" + argsStr + ")").a(")").toString()); + code.add(builder().a("if (!").a(accessor).a("(").a(argsStr).a("))").toString()); indent++; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridDirectVersion.java b/modules/core/src/main/java/org/apache/ignite/internal/GridDirectVersion.java deleted file mode 100644 index b9566c54d8c0d..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridDirectVersion.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal; - -import java.lang.annotation.*; - -/** - * Assigns version to a field. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface GridDirectVersion { - /** - * @return Version index (must be above zero). - */ - int value(); -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java index cf908e80ef989..5dc52d86ebb23 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java @@ -270,7 +270,7 @@ boolean isOrdered() { switch (commState.idx) { case 0: - msg = (MessageAdapter)commState.getMessage("msg"); + msg = commState.getMessage("msg"); if (!commState.lastRead()) return false; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxRequest.java index 4eb5624da5598..bd5f826c9b012 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxRequest.java @@ -17,7 +17,6 @@ package org.apache.ignite.internal.processors.cache.distributed; -import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.transactions.*; import org.apache.ignite.internal.processors.cache.version.*; import org.apache.ignite.internal.util.typedef.internal.*; @@ -52,7 +51,6 @@ public class GridCachePessimisticCheckCommittedTxRequest extends GridDistr private long originatingThreadId; /** Flag indicating that this is near-only check. */ - @GridDirectVersion(1) private boolean nearOnlyCheck; /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java index 3c72a2f83046a..7a997209b589f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java @@ -71,15 +71,12 @@ public class GridDhtLockRequest extends GridDistributedLockRequest { private long topVer; /** Subject ID. */ - @GridDirectVersion(1) private UUID subjId; /** Task name hash. */ - @GridDirectVersion(2) private int taskNameHash; /** Indexes of keys needed to be preloaded. */ - @GridDirectVersion(3) private BitSet preloadKeys; /** TTL for read operation. */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java index eea4b85b17769..f301a8fb93f14 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java @@ -63,7 +63,6 @@ public class GridDhtLockResponse extends GridDistributedLockResponse /** */ @GridDirectCollection(byte[].class) - @GridDirectVersion(1) private List preloadEntriesBytes; /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java index 1a53250228a2f..f814c5d597ac8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java @@ -78,11 +78,9 @@ public class GridDhtTxFinishRequest extends GridDistributedTxFinishRequest private GridCacheVersion writeVer; /** Subject ID. */ - @GridDirectVersion(1) private UUID subjId; /** Task name hash. */ - @GridDirectVersion(2) private int taskNameHash; /** TTLs for optimistic transaction. */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java index 47c2a48bdfdb8..d7af7808c11a1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java @@ -80,14 +80,11 @@ public class GridDhtTxPrepareRequest extends GridDistributedTxPrepareReque private boolean last; /** Subject ID. */ - @GridDirectVersion(1) private UUID subjId; /** Task name hash. */ - @GridDirectVersion(2) private int taskNameHash; - @GridDirectVersion(3) /** Preload keys. */ private BitSet preloadKeys; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java index 51d179faf3215..fd6c0b44ed40f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java @@ -65,7 +65,6 @@ public class GridDhtTxPrepareResponse extends GridDistributedTxPrepareResp /** */ @GridDirectCollection(byte[].class) - @GridDirectVersion(1) private List preloadEntriesBytes; /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java index 8d4d36e064d23..c69fc6e6036ca 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java @@ -102,7 +102,6 @@ public class GridDhtAtomicUpdateRequest extends GridCacheMessage imp /** Key bytes. */ @GridToStringInclude @GridDirectCollection(byte[].class) - @GridDirectVersion(1) private List nearKeyBytes; /** Values to update. */ @@ -113,11 +112,9 @@ public class GridDhtAtomicUpdateRequest extends GridCacheMessage imp /** Value bytes. */ @GridToStringInclude @GridDirectCollection(GridCacheValueBytes.class) - @GridDirectVersion(1) private List nearValBytes; /** Force transform backups flag. */ - @GridDirectVersion(2) private boolean forceTransformBackups; /** Entry processors. */ @@ -126,7 +123,6 @@ public class GridDhtAtomicUpdateRequest extends GridCacheMessage imp /** Entry processors bytes. */ @GridDirectCollection(byte[].class) - @GridDirectVersion(2) private List entryProcessorsBytes; /** Near entry processors. */ @@ -135,7 +131,6 @@ public class GridDhtAtomicUpdateRequest extends GridCacheMessage imp /** Near entry processors bytes. */ @GridDirectCollection(byte[].class) - @GridDirectVersion(2) private List nearEntryProcessorsBytes; /** Optional arguments for entry processor. */ @@ -146,11 +141,9 @@ public class GridDhtAtomicUpdateRequest extends GridCacheMessage imp private byte[][] invokeArgsBytes; /** Subject ID. */ - @GridDirectVersion(3) private UUID subjId; /** Task name hash. */ - @GridDirectVersion(4) private int taskNameHash; /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java index 41a48a1631be1..afd013c8fea8f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java @@ -65,7 +65,6 @@ public class GridDhtAtomicUpdateResponse extends GridCacheMessage im /** Evicted reader key bytes. */ @GridDirectCollection(byte[].class) - @GridDirectVersion(1) private Collection nearEvictedBytes; /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java index 2726a6d0581b2..f700649dd4924 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java @@ -125,15 +125,12 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage im private boolean hasPrimary; /** Force transform backups flag. */ - @GridDirectVersion(2) private boolean forceTransformBackups; /** Subject ID. */ - @GridDirectVersion(3) private UUID subjId; /** Task name hash. */ - @GridDirectVersion(4) private int taskNameHash; /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java index fdfde264fc650..d91e8001818df 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java @@ -81,12 +81,10 @@ public class GridNearAtomicUpdateResponse extends GridCacheMessage i /** Indexes of keys for which values were generated on primary node (used if originating node has near cache). */ @GridDirectCollection(int.class) - @GridDirectVersion(1) private List nearValsIdxs; /** Indexes of keys for which update was skipped (used if originating node has near cache). */ @GridDirectCollection(int.class) - @GridDirectVersion(1) private List nearSkipIdxs; /** Values generated on primary node which should be put to originating node's near cache. */ @@ -97,11 +95,9 @@ public class GridNearAtomicUpdateResponse extends GridCacheMessage i /** Serialized values generated on primary node which should be put to originating node's near cache. */ @GridToStringInclude @GridDirectCollection(GridCacheValueBytes.class) - @GridDirectVersion(1) private List nearValBytes; /** Version generated on primary node to be used for originating node's near cache update. */ - @GridDirectVersion(1) private GridCacheVersion nearVer; /** Near TTLs. */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java index c99a65e9f85ec..f8c5cc270f683 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java @@ -76,11 +76,9 @@ public class GridNearGetRequest extends GridCacheMessage implements private IgnitePredicate>[] filter; /** Subject ID. */ - @GridDirectVersion(1) private UUID subjId; /** Task name hash. */ - @GridDirectVersion(2) private int taskNameHash; /** TTL for read operation. */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java index d6455dd57bd79..da008ac3522cb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java @@ -69,15 +69,12 @@ public class GridNearLockRequest extends GridDistributedLockRequest private GridCacheVersion[] dhtVers; /** Subject ID. */ - @GridDirectVersion(1) private UUID subjId; /** Task name hash. */ - @GridDirectVersion(2) private int taskNameHash; /** Has transforms flag. */ - @GridDirectVersion(3) private boolean hasTransforms; /** Sync commit flag. */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java index e2be31245e231..a462751ab25a5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java @@ -17,7 +17,6 @@ package org.apache.ignite.internal.processors.cache.distributed.near; -import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.distributed.*; import org.apache.ignite.internal.processors.cache.transactions.*; import org.apache.ignite.internal.processors.cache.version.*; @@ -50,11 +49,9 @@ public class GridNearTxFinishRequest extends GridDistributedTxFinishReques private long topVer; /** Subject ID. */ - @GridDirectVersion(1) private UUID subjId; /** Task name hash. */ - @GridDirectVersion(2) private int taskNameHash; /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java index f0ffa4e49c4d9..1cd7ce06d9cf1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java @@ -58,11 +58,9 @@ public class GridNearTxPrepareRequest extends GridDistributedTxPrepareRequ private Collection lastBackups; /** Subject ID. */ - @GridDirectVersion(1) private UUID subjId; /** Task name hash. */ - @GridDirectVersion(2) private int taskNameHash; /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java index 5f1552f2818d7..2893f4f6c24f6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java @@ -109,15 +109,12 @@ public class GridCacheQueryRequest extends GridCacheMessage implemen private boolean all; /** */ - @GridDirectVersion(1) private boolean keepPortable; /** */ - @GridDirectVersion(2) private UUID subjId; /** */ - @GridDirectVersion(2) private int taskHash; /** diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReaderFactory.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReaderFactory.java index 70dc3dcecbf13..65c4a334fd8cd 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReaderFactory.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReaderFactory.java @@ -14,6 +14,6 @@ /** * TODO */ -public interface MessageReaderFactory extends IgniteExtension { +public interface MessageReaderFactory extends Extension { public MessageReader reader(); } diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriterFactory.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriterFactory.java index 47b5a34f26706..92143378b8844 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriterFactory.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriterFactory.java @@ -14,6 +14,6 @@ /** * TODO */ -public interface MessageWriterFactory extends IgniteExtension { +public interface MessageWriterFactory extends Extension { public MessageWriter writer(); } From 39fcfb630672dff86780d4c7826af6f27429990b Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Sat, 7 Feb 2015 21:52:24 -0800 Subject: [PATCH 45/95] IGNITE-61 - Direct marshalling --- .../CommunicationMessageCodeGenerator.java | 58 +++++++------------ .../direct/DirectByteBufferStream.java | 11 ++++ .../internal/direct/DirectMessageReader.java | 9 +++ .../internal/direct/DirectMessageWriter.java | 7 +++ .../communication/MessageAdapter.java | 6 ++ .../communication/MessageReader.java | 2 + .../communication/MessageWriter.java | 2 + 7 files changed, 58 insertions(+), 37 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java index b828d73d952a4..b8c6aa91c7634 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java @@ -33,6 +33,12 @@ public class CommunicationMessageCodeGenerator { } }; + /** */ + private static final String[] EXCLUDED_PACKAGES = new String[] { + "org.apache.ignite.internal.processors.rest.client.message", + "org.apache.ignite.internal.processors.rest.protocols.tcp" + }; + /** */ private static final String SRC_DIR = U.getIgniteHome() + "/modules/core/src/main/java"; @@ -45,35 +51,14 @@ public class CommunicationMessageCodeGenerator { /** */ private static final String TAB = " "; - /** */ - private static final String COMM_STATE_VAR = "commState"; - /** */ private static final String BUF_VAR = "buf"; /** */ - private static final String STATE_VAR = COMM_STATE_VAR + "." + "idx"; - - /** */ - private static final String TYPE_WRITTEN_VAR = COMM_STATE_VAR + "." + "typeWritten"; - - /** */ - private static final String IT_VAR = COMM_STATE_VAR + "." + "it"; - - /** */ - private static final String CUR_VAR = COMM_STATE_VAR + "." + "cur"; + private static final String STATE_VAR = "state"; /** */ - private static final String KEY_DONE_VAR = COMM_STATE_VAR + "." + "keyDone"; - - /** */ - private static final String READ_SIZE_VAR = COMM_STATE_VAR + "." + "readSize"; - - /** */ - private static final String READ_ITEMS_VAR = COMM_STATE_VAR + "." + "readItems"; - - /** */ - private static final String DFLT_LOC_VAR = "_val"; + private static final String TYPE_WRITTEN_VAR = "typeWritten"; /** */ private final Collection write = new ArrayList<>(); @@ -297,14 +282,8 @@ public void generate(Class cls) throws Exception { for (Field field : cloningFields) { String name = field.getName(); - Class type = field.getType(); - - String res = name; - - if (BASE_CLS.isAssignableFrom(type)) - res = name + " != null ? (" + type.getSimpleName() + ")" + name + ".clone() : null"; - clone0.add(builder().a("_clone.").a(name).a(" = ").a(res).a(";").toString()); + clone0.add(builder().a("_clone.").a(name).a(" = ").a(name).a(";").toString()); } } @@ -359,12 +338,12 @@ private int startState(Class cls) { /** * @param code Code lines. * @param superMtd Super class method name. - * @param writeType Whether to write message type. + * @param write Whether write code is generated. */ - private void start(Collection code, @Nullable String superMtd, boolean writeType) { + private void start(Collection code, @Nullable String superMtd, boolean write) { assert code != null; - code.add(builder().a(COMM_STATE_VAR).a(".setBuffer(").a(BUF_VAR).a(");").toString()); + code.add(builder().a(write ? "writer" : "reader").a(".setBuffer(").a(BUF_VAR).a(");").toString()); code.add(EMPTY); if (superMtd != null) { @@ -373,12 +352,12 @@ private void start(Collection code, @Nullable String superMtd, boolean w code.add(EMPTY); } - if (writeType) { + if (write) { code.add(builder().a("if (!").a(TYPE_WRITTEN_VAR).a(") {").toString()); indent++; - returnFalseIfFailed(code, COMM_STATE_VAR + ".putByte", "null", "directType()"); + returnFalseIfFailed(code, "writer.writeByte", "null", "directType()"); code.add(EMPTY); code.add(builder().a(TYPE_WRITTEN_VAR).a(" = true;").toString()); @@ -537,7 +516,7 @@ else if (type == IgniteUuid.class) else if (type.isEnum()) returnFalseIfFailed(write, "writer.writeEnum", field, name); else if (BASE_CLS.isAssignableFrom(type)) - returnFalseIfFailed(write, "writer.writeMessage", field, name); + returnFalseIfFailed(write, "writer.writeMessage", field, name + " != null ? " + name + ".clone() : null"); else if (type.isArray()) { returnFalseIfFailed(write, "writer.writeObjectArray", field, name, type.getComponentType().getSimpleName() + ".class"); @@ -615,7 +594,7 @@ else if (type == UUID.class) else if (type == IgniteUuid.class) returnFalseIfReadFailed(retType, name, "reader.readGridUuid", field); else if (type.isEnum()) - returnFalseIfReadFailed(retType, name, "reader.readEnum", field); + returnFalseIfReadFailed(retType, name, "reader.readEnum", field, retType + ".class"); else if (BASE_CLS.isAssignableFrom(type)) returnFalseIfReadFailed(retType, name, "reader.readMessage", field); else if (type.isArray()) { @@ -776,6 +755,11 @@ private void processFile(File file, ClassLoader ldr, int prefixLen, if (path.endsWith(".class")) { String clsName = path.substring(prefixLen, path.length() - 6).replace(File.separatorChar, '.'); + for (String excluded : EXCLUDED_PACKAGES) { + if (clsName.startsWith(excluded)) + return; + } + Class cls = Class.forName(clsName, false, ldr); if (cls.getDeclaringClass() == null && cls.getEnclosingClass() == null && diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java index cbb8d4c826233..e674861ce58aa 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java @@ -524,6 +524,10 @@ public void writeIgniteUuid(IgniteUuid val) { writeByteArray(val != null ? U.igniteUuidToBytes(val) : null); } + public void writeEnum(Enum val) { + writeByte(val != null ? (byte)val.ordinal() : -1); + } + /** * @param msg Message. */ @@ -840,6 +844,13 @@ public IgniteUuid readIgniteUuid() { return arr != null ? U.bytesToIgniteUuid(arr, 0) : null; } + @SuppressWarnings("unchecked") + public > Enum readEnum(Class enumCls) { + byte ord = readByte(); + + return ord >= 0 ? (Enum)GridEnumCache.get(enumCls)[ord] : null; + } + /** * @return Message. */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java index 547c71a27bae7..3875cfe61ce94 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java @@ -226,6 +226,15 @@ public DirectMessageReader(GridTcpMessageFactory msgFactory) { return val; } + /** {@inheritDoc} */ + @Override public > Enum readEnum(String name, Class enumCls) { + Enum val = stream.readEnum(enumCls); + + lastRead = stream.lastFinished(); + + return val; + } + /** {@inheritDoc} */ @Nullable @Override public MessageAdapter readMessage(String name) { MessageAdapter msg = stream.readMessage(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java index d7c679d5a3426..e5f005dea0681 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java @@ -176,6 +176,13 @@ public class DirectMessageWriter implements MessageWriter { return stream.lastFinished(); } + /** {@inheritDoc} */ + @Override public boolean writeEnum(String name, Enum val) { + stream.writeEnum(val); + + return stream.lastFinished(); + } + /** {@inheritDoc} */ @Override public boolean writeMessage(String name, @Nullable MessageAdapter msg) { if (msg != null) diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageAdapter.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageAdapter.java index 89d26fc52ddd5..2234698b4a75e 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageAdapter.java @@ -41,6 +41,12 @@ public abstract class MessageAdapter implements Serializable, Cloneable { /** Reader. */ protected MessageReader reader; + /** */ + protected boolean typeWritten; + + /** */ + protected int state; + /** * @param writer Writer. */ diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java index aa1c09b9b4e4c..fa4ca660cbb55 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java @@ -60,6 +60,8 @@ public interface MessageReader { public IgniteUuid readIgniteUuid(String name); + public > Enum readEnum(String name, Class enumCls); + public MessageAdapter readMessage(String name); public T[] readObjectArray(String name, Class itemCls); diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java index 19bb268272640..fc348eeaca6e4 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java @@ -60,6 +60,8 @@ public interface MessageWriter { public boolean writeIgniteUuid(String name, IgniteUuid val); + public boolean writeEnum(String name, Enum val); + public boolean writeMessage(String name, MessageAdapter val); public boolean writeObjectArray(String name, T[] arr, Class itemCls); From 215268fe5c8461c65fc93868e21bba45e415072d Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Sat, 7 Feb 2015 22:17:36 -0800 Subject: [PATCH 46/95] IGNITE-61 - Direct marshalling --- .../CommunicationMessageCodeGenerator.java | 65 +++++++++---------- .../direct/DirectByteBufferStream.java | 13 ++-- .../internal/direct/DirectMessageReader.java | 12 ++-- .../communication/MessageReader.java | 6 +- 4 files changed, 46 insertions(+), 50 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java index b8c6aa91c7634..45a383c5d7baf 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java @@ -449,7 +449,7 @@ private void readField(Field field, int opt, @Nullable GridDirectCollection colA indent++; returnFalseIfReadFailed(field.getType(), field.getName(), colAnn != null ? colAnn.value() : null, - mapAnn != null ? mapAnn.keyType() : null, mapAnn != null ? mapAnn.valueType() : null, false); + mapAnn != null ? mapAnn.keyType() : null, mapAnn != null ? mapAnn.valueType() : null); read.add(EMPTY); read.add(builder().a(STATE_VAR).a("++;").toString()); @@ -543,75 +543,72 @@ else if (Map.class.isAssignableFrom(type)) { * @param colItemType Collection item type. * @param mapKeyType Map key type. * @param mapValType Map value type. - * @param raw Raw read flag. */ private void returnFalseIfReadFailed(Class type, @Nullable String name, @Nullable Class colItemType, - @Nullable Class mapKeyType, @Nullable Class mapValType, boolean raw) { + @Nullable Class mapKeyType, @Nullable Class mapValType) { assert type != null; - String field = raw ? "null" : '"' + name + '"'; - - String retType = type.getSimpleName(); + String field = '"' + name + '"'; if (type == byte.class) - returnFalseIfReadFailed("byte", name, "reader.readByte", field); + returnFalseIfReadFailed(name, "reader.readByte", field); else if (type == short.class) - returnFalseIfReadFailed("short", name, "reader.readShort", field); + returnFalseIfReadFailed(name, "reader.readShort", field); else if (type == int.class) - returnFalseIfReadFailed("int", name, "reader.readInt", field); + returnFalseIfReadFailed(name, "reader.readInt", field); else if (type == long.class) - returnFalseIfReadFailed("long", name, "reader.readLong", field); + returnFalseIfReadFailed(name, "reader.readLong", field); else if (type == float.class) - returnFalseIfReadFailed("float", name, "reader.readFloat", field); + returnFalseIfReadFailed(name, "reader.readFloat", field); else if (type == double.class) - returnFalseIfReadFailed("double", name, "reader.readDouble", field); + returnFalseIfReadFailed(name, "reader.readDouble", field); else if (type == char.class) - returnFalseIfReadFailed("char", name, "reader.readChar", field); + returnFalseIfReadFailed(name, "reader.readChar", field); else if (type == boolean.class) - returnFalseIfReadFailed("boolean", name, "reader.readBoolean", field); + returnFalseIfReadFailed(name, "reader.readBoolean", field); else if (type == byte[].class) - returnFalseIfReadFailed(retType, name, "reader.readByteArray", field); + returnFalseIfReadFailed(name, "reader.readByteArray", field); else if (type == short[].class) - returnFalseIfReadFailed(retType, name, "reader.readShortArray", field); + returnFalseIfReadFailed(name, "reader.readShortArray", field); else if (type == int[].class) - returnFalseIfReadFailed(retType, name, "reader.readIntArray", field); + returnFalseIfReadFailed(name, "reader.readIntArray", field); else if (type == long[].class) - returnFalseIfReadFailed(retType, name, "reader.readLongArray", field); + returnFalseIfReadFailed(name, "reader.readLongArray", field); else if (type == float[].class) - returnFalseIfReadFailed(retType, name, "reader.readFloatArray", field); + returnFalseIfReadFailed(name, "reader.readFloatArray", field); else if (type == double[].class) - returnFalseIfReadFailed(retType, name, "reader.readDoubleArray", field); + returnFalseIfReadFailed(name, "reader.readDoubleArray", field); else if (type == char[].class) - returnFalseIfReadFailed(retType, name, "reader.readCharArray", field); + returnFalseIfReadFailed(name, "reader.readCharArray", field); else if (type == boolean[].class) - returnFalseIfReadFailed(retType, name, "reader.readBooleanArray", field); + returnFalseIfReadFailed(name, "reader.readBooleanArray", field); else if (type == String.class) - returnFalseIfReadFailed(retType, name, "reader.readString", field); + returnFalseIfReadFailed(name, "reader.readString", field); else if (type == BitSet.class) - returnFalseIfReadFailed(retType, name, "reader.readBitSet", field); + returnFalseIfReadFailed(name, "reader.readBitSet", field); else if (type == UUID.class) - returnFalseIfReadFailed(retType, name, "reader.readUuid", field); + returnFalseIfReadFailed(name, "reader.readUuid", field); else if (type == IgniteUuid.class) - returnFalseIfReadFailed(retType, name, "reader.readGridUuid", field); + returnFalseIfReadFailed(name, "reader.readIgniteUuid", field); else if (type.isEnum()) - returnFalseIfReadFailed(retType, name, "reader.readEnum", field, retType + ".class"); + returnFalseIfReadFailed(name, "reader.readEnum", field, type.getSimpleName() + ".class"); else if (BASE_CLS.isAssignableFrom(type)) - returnFalseIfReadFailed(retType, name, "reader.readMessage", field); + returnFalseIfReadFailed(name, "reader.readMessage", field); else if (type.isArray()) { - returnFalseIfReadFailed(retType, name, "reader.readObjectArray", field, + returnFalseIfReadFailed(name, "reader.readObjectArray", field, type.getComponentType().getSimpleName() + ".class"); } else if (Collection.class.isAssignableFrom(type)) { assert colItemType != null; - returnFalseIfReadFailed(retType, name, "reader.readCollection", field, + returnFalseIfReadFailed(name, "reader.readCollection", field, colItemType.getSimpleName() + ".class"); } else if (Map.class.isAssignableFrom(type)) { assert mapKeyType != null; assert mapValType != null; - returnFalseIfReadFailed(retType, name, "reader.readMap", field, mapKeyType.getSimpleName() + ".class", + returnFalseIfReadFailed(name, "reader.readMap", field, mapKeyType.getSimpleName() + ".class", mapValType.getSimpleName() + ".class"); } else @@ -619,13 +616,11 @@ else if (Map.class.isAssignableFrom(type)) { } /** - * @param retType Return type. * @param var Variable name. * @param mtd Method name. * @param args Method arguments. */ - private void returnFalseIfReadFailed(String retType, String var, String mtd, @Nullable String... args) { - assert retType != null; + private void returnFalseIfReadFailed(String var, String mtd, @Nullable String... args) { assert mtd != null; String argsStr = ""; @@ -640,7 +635,7 @@ private void returnFalseIfReadFailed(String retType, String var, String mtd, @Nu read.add(builder().a(var).a(" = ").a(mtd).a("(").a(argsStr).a(");").toString()); read.add(EMPTY); - read.add(builder().a("if (!reader.lastRead())").toString()); + read.add(builder().a("if (!reader.isLastRead())").toString()); indent++; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java index e674861ce58aa..3234a64fc08b8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java @@ -845,16 +845,17 @@ public IgniteUuid readIgniteUuid() { } @SuppressWarnings("unchecked") - public > Enum readEnum(Class enumCls) { + public > T readEnum(Class enumCls) { byte ord = readByte(); - return ord >= 0 ? (Enum)GridEnumCache.get(enumCls)[ord] : null; + return ord >= 0 ? (T)GridEnumCache.get(enumCls)[ord] : null; } /** * @return Message. */ - public MessageAdapter readMessage() { + @SuppressWarnings("unchecked") + public T readMessage() { if (!msgTypeDone) { if (!buf.hasRemaining()) { lastFinished = false; @@ -877,7 +878,7 @@ public MessageAdapter readMessage() { msgTypeDone = false; msg = null; - return msg0; + return (T)msg0; } else return null; @@ -926,7 +927,7 @@ public T[] readObjectArray(Class itemCls) { } @SuppressWarnings("unchecked") - public Collection readCollection(Class itemCls) { + public , T> C readCollection(Class itemCls) { if (readSize == -1) { int size = readInt(); @@ -964,7 +965,7 @@ public Collection readCollection(Class itemCls) { col = null; - return col0; + return (C)col0; } @SuppressWarnings("unchecked") diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java index 3875cfe61ce94..f0efbae1e9a27 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java @@ -227,8 +227,8 @@ public DirectMessageReader(GridTcpMessageFactory msgFactory) { } /** {@inheritDoc} */ - @Override public > Enum readEnum(String name, Class enumCls) { - Enum val = stream.readEnum(enumCls); + @Override public > T readEnum(String name, Class enumCls) { + T val = stream.readEnum(enumCls); lastRead = stream.lastFinished(); @@ -236,8 +236,8 @@ public DirectMessageReader(GridTcpMessageFactory msgFactory) { } /** {@inheritDoc} */ - @Nullable @Override public MessageAdapter readMessage(String name) { - MessageAdapter msg = stream.readMessage(); + @Nullable @Override public T readMessage(String name) { + T msg = stream.readMessage(); lastRead = stream.lastFinished(); @@ -254,8 +254,8 @@ public DirectMessageReader(GridTcpMessageFactory msgFactory) { } /** {@inheritDoc} */ - @Override public Collection readCollection(String name, Class itemCls) { - Collection col = stream.readCollection(itemCls); + @Override public , T> C readCollection(String name, Class itemCls) { + C col = stream.readCollection(itemCls); lastRead = stream.lastFinished(); diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java index fa4ca660cbb55..eca6afbca06e8 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java @@ -60,13 +60,13 @@ public interface MessageReader { public IgniteUuid readIgniteUuid(String name); - public > Enum readEnum(String name, Class enumCls); + public > T readEnum(String name, Class enumCls); - public MessageAdapter readMessage(String name); + public T readMessage(String name); public T[] readObjectArray(String name, Class itemCls); - public Collection readCollection(String name, Class itemCls); + public , T> C readCollection(String name, Class itemCls); public Map readMap(String name, Class keyCls, Class valCls); From 159c1e84622cdc0c1ab9f4aa60a721fbff0a51df Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Sat, 7 Feb 2015 22:56:42 -0800 Subject: [PATCH 47/95] IGNITE-61 - Direct marshalling --- .../ignite/internal/GridJobCancelRequest.java | 44 +- .../internal/GridJobExecuteRequest.java | 344 +++------ .../internal/GridJobExecuteResponse.java | 84 +- .../internal/GridJobSiblingsRequest.java | 34 +- .../internal/GridJobSiblingsResponse.java | 24 +- .../internal/GridTaskCancelRequest.java | 24 +- .../internal/GridTaskSessionRequest.java | 44 +- .../direct/DirectByteBufferStream.java | 4 +- .../internal/direct/DirectMessageReader.java | 4 +- .../GridTcpCommunicationMessageState.java | 726 ------------------ .../checkpoint/GridCheckpointRequest.java | 44 +- .../managers/communication/GridIoMessage.java | 88 ++- .../communication/GridIoUserMessage.java | 157 ++-- .../deployment/GridDeploymentInfoBean.java | 137 +--- .../deployment/GridDeploymentRequest.java | 111 +-- .../deployment/GridDeploymentResponse.java | 44 +- .../eventstorage/GridEventStorageMessage.java | 177 ++--- .../cache/GridCacheEvictionRequest.java | 44 +- .../cache/GridCacheEvictionResponse.java | 91 +-- .../processors/cache/GridCacheMessage.java | 46 +- .../processors/cache/GridCacheValueBytes.java | 60 +- ...CacheOptimisticCheckPreparedTxRequest.java | 54 +- ...acheOptimisticCheckPreparedTxResponse.java | 44 +- ...chePessimisticCheckCommittedTxRequest.java | 74 +- ...hePessimisticCheckCommittedTxResponse.java | 44 +- .../GridCacheTtlUpdateRequest.java | 262 ++----- .../GridDistributedBaseMessage.java | 158 +--- .../GridDistributedLockRequest.java | 270 +++---- .../GridDistributedLockResponse.java | 91 +-- .../GridDistributedTxFinishRequest.java | 238 ++---- .../GridDistributedTxFinishResponse.java | 34 +- .../GridDistributedTxPrepareRequest.java | 252 ++---- .../GridDistributedTxPrepareResponse.java | 34 +- .../GridDistributedUnlockRequest.java | 71 +- .../dht/GridDhtAffinityAssignmentRequest.java | 24 +- .../GridDhtAffinityAssignmentResponse.java | 34 +- .../distributed/dht/GridDhtLockRequest.java | 151 ++-- .../distributed/dht/GridDhtLockResponse.java | 195 +---- .../dht/GridDhtTxFinishRequest.java | 240 ++---- .../dht/GridDhtTxFinishResponse.java | 24 +- .../dht/GridDhtTxPrepareRequest.java | 181 ++--- .../dht/GridDhtTxPrepareResponse.java | 205 +---- .../distributed/dht/GridDhtUnlockRequest.java | 71 +- .../GridDhtAtomicDeferredUpdateResponse.java | 71 +- .../atomic/GridDhtAtomicUpdateRequest.java | 592 +++----------- .../atomic/GridDhtAtomicUpdateResponse.java | 101 +-- .../atomic/GridNearAtomicUpdateRequest.java | 443 +++-------- .../atomic/GridNearAtomicUpdateResponse.java | 265 ++----- .../preloader/GridDhtForceKeysRequest.java | 101 +-- .../preloader/GridDhtForceKeysResponse.java | 101 +-- .../GridDhtPartitionDemandMessage.java | 121 +-- .../preloader/GridDhtPartitionExchangeId.java | 75 +- .../GridDhtPartitionSupplyMessage.java | 168 +--- .../GridDhtPartitionsAbstractMessage.java | 34 +- .../GridDhtPartitionsFullMessage.java | 44 +- .../GridDhtPartitionsSingleMessage.java | 24 +- .../GridDhtPartitionsSingleRequest.java | 10 +- .../distributed/near/GridNearGetRequest.java | 242 ++---- .../distributed/near/GridNearGetResponse.java | 131 ++-- .../distributed/near/GridNearLockRequest.java | 228 ++---- .../near/GridNearLockResponse.java | 205 +---- .../near/GridNearTxFinishRequest.java | 74 +- .../near/GridNearTxFinishResponse.java | 44 +- .../near/GridNearTxPrepareRequest.java | 141 ++-- .../near/GridNearTxPrepareResponse.java | 215 ++---- .../near/GridNearUnlockRequest.java | 10 +- .../cache/query/GridCacheQueryRequest.java | 206 +++-- .../cache/query/GridCacheQueryResponse.java | 168 +--- .../cache/version/GridCacheVersion.java | 90 ++- .../clock/GridClockDeltaSnapshotMessage.java | 105 +-- .../clock/GridClockDeltaVersion.java | 60 +- .../continuous/GridContinuousMessage.java | 56 +- .../dataload/GridDataLoadRequest.java | 217 ++---- .../dataload/GridDataLoadResponse.java | 44 +- .../processors/fs/GridGgfsAckMessage.java | 44 +- .../processors/fs/GridGgfsBlockKey.java | 54 +- .../processors/fs/GridGgfsBlocksMessage.java | 115 +-- .../fs/GridGgfsCommunicationMessage.java | 10 +- .../processors/fs/GridGgfsDeleteMessage.java | 34 +- .../fs/GridGgfsFileAffinityRange.java | 64 +- .../fs/GridGgfsFragmentizerRequest.java | 81 +- .../fs/GridGgfsFragmentizerResponse.java | 24 +- .../processors/fs/GridGgfsSyncMessage.java | 34 +- .../GridClientHandshakeRequestWrapper.java | 4 +- .../GridClientHandshakeResponseWrapper.java | 8 +- .../message/GridClientMessageWrapper.java | 28 +- .../message/GridClientPingPacketWrapper.java | 14 +- .../handlers/task/GridTaskResultRequest.java | 34 +- .../handlers/task/GridTaskResultResponse.java | 54 +- .../tcp/GridMemcachedMessageWrapper.java | 4 +- .../streamer/GridStreamerCancelRequest.java | 24 +- .../GridStreamerExecutionRequest.java | 157 ++-- .../streamer/GridStreamerResponse.java | 34 +- .../version/GridVersionConverter.java | 46 -- .../internal/util/GridByteArrayList.java | 60 +- .../ignite/internal/util/GridLongList.java | 60 +- .../communication/MessageAdapter.java | 47 -- .../communication/MessageReader.java | 2 +- .../jobstealing/JobStealingRequest.java | 24 +- .../GridCommunicationSendMessageSelfTest.java | 4 +- .../spi/communication/GridTestMessage.java | 58 +- 101 files changed, 3349 insertions(+), 7241 deletions(-) delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/direct/GridTcpCommunicationMessageState.java delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/processors/version/GridVersionConverter.java diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridJobCancelRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/GridJobCancelRequest.java index d55e205bdefff..5cb6a27b1f77d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridJobCancelRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridJobCancelRequest.java @@ -131,33 +131,33 @@ public boolean system() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 0: - if (!commState.putGridUuid("jobId", jobId)) + if (!writer.writeIgniteUuid("jobId", jobId)) return false; - commState.idx++; + state++; case 1: - if (!commState.putGridUuid("sesId", sesId)) + if (!writer.writeIgniteUuid("sesId", sesId)) return false; - commState.idx++; + state++; case 2: - if (!commState.putBoolean("sys", sys)) + if (!writer.writeBoolean("sys", sys)) return false; - commState.idx++; + state++; } @@ -167,32 +167,32 @@ public boolean system() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); - switch (commState.idx) { + switch (state) { case 0: - jobId = commState.getGridUuid("jobId"); + jobId = reader.readIgniteUuid("jobId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 1: - sesId = commState.getGridUuid("sesId"); + sesId = reader.readIgniteUuid("sesId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 2: - sys = commState.getBoolean("sys"); + sys = reader.readBoolean("sys"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java index cdc6dfaa3c918..46310005f56ea 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteRequest.java @@ -456,194 +456,141 @@ public UUID getSubjectId() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 0: - if (!commState.putGridUuid("clsLdrId", clsLdrId)) + if (!writer.writeIgniteUuid("clsLdrId", clsLdrId)) return false; - commState.idx++; + state++; case 1: - if (!commState.putString("cpSpi", cpSpi)) + if (!writer.writeString("cpSpi", cpSpi)) return false; - commState.idx++; + state++; case 2: - if (!commState.putEnum("depMode", depMode)) + if (!writer.writeEnum("depMode", depMode)) return false; - commState.idx++; + state++; case 3: - if (!commState.putBoolean("dynamicSiblings", dynamicSiblings)) + if (!writer.writeBoolean("dynamicSiblings", dynamicSiblings)) return false; - commState.idx++; + state++; case 4: - if (!commState.putBoolean("forceLocDep", forceLocDep)) + if (!writer.writeBoolean("forceLocDep", forceLocDep)) return false; - commState.idx++; + state++; case 5: - if (!commState.putBoolean("internal", internal)) + if (!writer.writeBoolean("internal", internal)) return false; - commState.idx++; + state++; case 6: - if (!commState.putByteArray("jobAttrsBytes", jobAttrsBytes)) + if (!writer.writeByteArray("jobAttrsBytes", jobAttrsBytes)) return false; - commState.idx++; + state++; case 7: - if (!commState.putByteArray("jobBytes", jobBytes)) + if (!writer.writeByteArray("jobBytes", jobBytes)) return false; - commState.idx++; + state++; case 8: - if (!commState.putGridUuid("jobId", jobId)) + if (!writer.writeIgniteUuid("jobId", jobId)) return false; - commState.idx++; + state++; case 9: - if (ldrParticipants != null) { - if (commState.it == null) { - if (!commState.putInt(null, ldrParticipants.size())) - return false; - - commState.it = ldrParticipants.entrySet().iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - Map.Entry e = (Map.Entry)commState.cur; - - if (!commState.keyDone) { - if (!commState.putUuid(null, e.getKey())) - return false; - - commState.keyDone = true; - } - - if (!commState.putGridUuid(null, e.getValue())) - return false; - - commState.keyDone = false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeMap("ldrParticipants", ldrParticipants, UUID.class, IgniteUuid.class)) + return false; - commState.idx++; + state++; case 10: - if (!commState.putByteArray("sesAttrsBytes", sesAttrsBytes)) + if (!writer.writeByteArray("sesAttrsBytes", sesAttrsBytes)) return false; - commState.idx++; + state++; case 11: - if (!commState.putBoolean("sesFullSup", sesFullSup)) + if (!writer.writeBoolean("sesFullSup", sesFullSup)) return false; - commState.idx++; + state++; case 12: - if (!commState.putGridUuid("sesId", sesId)) + if (!writer.writeIgniteUuid("sesId", sesId)) return false; - commState.idx++; + state++; case 13: - if (!commState.putByteArray("siblingsBytes", siblingsBytes)) + if (!writer.writeByteArray("siblingsBytes", siblingsBytes)) return false; - commState.idx++; + state++; case 14: - if (!commState.putLong("startTaskTime", startTaskTime)) + if (!writer.writeLong("startTaskTime", startTaskTime)) return false; - commState.idx++; + state++; case 15: - if (!commState.putUuid("subjId", subjId)) + if (!writer.writeUuid("subjId", subjId)) return false; - commState.idx++; + state++; case 16: - if (!commState.putString("taskClsName", taskClsName)) + if (!writer.writeString("taskClsName", taskClsName)) return false; - commState.idx++; + state++; case 17: - if (!commState.putString("taskName", taskName)) + if (!writer.writeString("taskName", taskName)) return false; - commState.idx++; + state++; case 18: - if (!commState.putLong("timeout", timeout)) + if (!writer.writeLong("timeout", timeout)) return false; - commState.idx++; + state++; case 19: - if (top != null) { - if (commState.it == null) { - if (!commState.putInt(null, top.size())) - return false; - - commState.it = top.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putUuid(null, (UUID)commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("top", top, UUID.class)) + return false; - commState.idx++; + state++; case 20: - if (!commState.putString("userVer", userVer)) + if (!writer.writeString("userVer", userVer)) return false; - commState.idx++; + state++; } @@ -653,235 +600,176 @@ public UUID getSubjectId() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); - switch (commState.idx) { + switch (state) { case 0: - clsLdrId = commState.getGridUuid("clsLdrId"); + clsLdrId = reader.readIgniteUuid("clsLdrId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 1: - cpSpi = commState.getString("cpSpi"); + cpSpi = reader.readString("cpSpi"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 2: - byte depMode0 = commState.getByte("depMode"); + depMode = reader.readEnum("depMode", DeploymentMode.class); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - depMode = DeploymentMode.fromOrdinal(depMode0); - - commState.idx++; + state++; case 3: - dynamicSiblings = commState.getBoolean("dynamicSiblings"); + dynamicSiblings = reader.readBoolean("dynamicSiblings"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 4: - forceLocDep = commState.getBoolean("forceLocDep"); + forceLocDep = reader.readBoolean("forceLocDep"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 5: - internal = commState.getBoolean("internal"); + internal = reader.readBoolean("internal"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 6: - jobAttrsBytes = commState.getByteArray("jobAttrsBytes"); + jobAttrsBytes = reader.readByteArray("jobAttrsBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 7: - jobBytes = commState.getByteArray("jobBytes"); + jobBytes = reader.readByteArray("jobBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 8: - jobId = commState.getGridUuid("jobId"); + jobId = reader.readIgniteUuid("jobId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 9: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } + ldrParticipants = reader.readMap("ldrParticipants", UUID.class, IgniteUuid.class); - if (commState.readSize >= 0) { - if (ldrParticipants == null) - ldrParticipants = new HashMap<>(commState.readSize, 1.0f); - - for (int i = commState.readItems; i < commState.readSize; i++) { - if (!commState.keyDone) { - UUID _val = commState.getUuid(null); - - if (!commState.lastRead()) - return false; - - commState.cur = _val; - commState.keyDone = true; - } - - IgniteUuid _val = commState.getGridUuid(null); - - if (!commState.lastRead()) - return false; - - ldrParticipants.put((UUID)commState.cur, _val); - - commState.keyDone = false; - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; - commState.cur = null; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 10: - sesAttrsBytes = commState.getByteArray("sesAttrsBytes"); + sesAttrsBytes = reader.readByteArray("sesAttrsBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 11: - sesFullSup = commState.getBoolean("sesFullSup"); + sesFullSup = reader.readBoolean("sesFullSup"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 12: - sesId = commState.getGridUuid("sesId"); + sesId = reader.readIgniteUuid("sesId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 13: - siblingsBytes = commState.getByteArray("siblingsBytes"); + siblingsBytes = reader.readByteArray("siblingsBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 14: - startTaskTime = commState.getLong("startTaskTime"); + startTaskTime = reader.readLong("startTaskTime"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 15: - subjId = commState.getUuid("subjId"); + subjId = reader.readUuid("subjId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 16: - taskClsName = commState.getString("taskClsName"); + taskClsName = reader.readString("taskClsName"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 17: - taskName = commState.getString("taskName"); + taskName = reader.readString("taskName"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 18: - timeout = commState.getLong("timeout"); + timeout = reader.readLong("timeout"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 19: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (top == null) - top = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - UUID _val = commState.getUuid(null); + top = reader.readCollection("top", UUID.class); - if (!commState.lastRead()) - return false; - - top.add((UUID)_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 20: - userVer = commState.getString("userVer"); + userVer = reader.readString("userVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteResponse.java index 5d936c8f64461..3c3352a72b469 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridJobExecuteResponse.java @@ -234,57 +234,57 @@ public void setFakeException(IgniteException fakeEx) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 0: - if (!commState.putByteArray("gridExBytes", gridExBytes)) + if (!writer.writeByteArray("gridExBytes", gridExBytes)) return false; - commState.idx++; + state++; case 1: - if (!commState.putBoolean("isCancelled", isCancelled)) + if (!writer.writeBoolean("isCancelled", isCancelled)) return false; - commState.idx++; + state++; case 2: - if (!commState.putByteArray("jobAttrsBytes", jobAttrsBytes)) + if (!writer.writeByteArray("jobAttrsBytes", jobAttrsBytes)) return false; - commState.idx++; + state++; case 3: - if (!commState.putGridUuid("jobId", jobId)) + if (!writer.writeIgniteUuid("jobId", jobId)) return false; - commState.idx++; + state++; case 4: - if (!commState.putUuid("nodeId", nodeId)) + if (!writer.writeUuid("nodeId", nodeId)) return false; - commState.idx++; + state++; case 5: - if (!commState.putByteArray("resBytes", resBytes)) + if (!writer.writeByteArray("resBytes", resBytes)) return false; - commState.idx++; + state++; case 6: - if (!commState.putGridUuid("sesId", sesId)) + if (!writer.writeIgniteUuid("sesId", sesId)) return false; - commState.idx++; + state++; } @@ -294,64 +294,64 @@ public void setFakeException(IgniteException fakeEx) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); - switch (commState.idx) { + switch (state) { case 0: - gridExBytes = commState.getByteArray("gridExBytes"); + gridExBytes = reader.readByteArray("gridExBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 1: - isCancelled = commState.getBoolean("isCancelled"); + isCancelled = reader.readBoolean("isCancelled"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 2: - jobAttrsBytes = commState.getByteArray("jobAttrsBytes"); + jobAttrsBytes = reader.readByteArray("jobAttrsBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 3: - jobId = commState.getGridUuid("jobId"); + jobId = reader.readIgniteUuid("jobId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 4: - nodeId = commState.getUuid("nodeId"); + nodeId = reader.readUuid("nodeId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 5: - resBytes = commState.getByteArray("resBytes"); + resBytes = reader.readByteArray("resBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 6: - sesId = commState.getGridUuid("sesId"); + sesId = reader.readIgniteUuid("sesId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsRequest.java index db27003c465bc..2fc71d9912c6c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsRequest.java @@ -105,27 +105,27 @@ public byte[] topicBytes() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 0: - if (!commState.putGridUuid("sesId", sesId)) + if (!writer.writeIgniteUuid("sesId", sesId)) return false; - commState.idx++; + state++; case 1: - if (!commState.putByteArray("topicBytes", topicBytes)) + if (!writer.writeByteArray("topicBytes", topicBytes)) return false; - commState.idx++; + state++; } @@ -135,24 +135,24 @@ public byte[] topicBytes() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); - switch (commState.idx) { + switch (state) { case 0: - sesId = commState.getGridUuid("sesId"); + sesId = reader.readIgniteUuid("sesId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 1: - topicBytes = commState.getByteArray("topicBytes"); + topicBytes = reader.readByteArray("topicBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java index 0dad8d914ab09..ffaaa1ef8cd10 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridJobSiblingsResponse.java @@ -97,21 +97,21 @@ public void unmarshalSiblings(Marshaller marsh) throws IgniteCheckedException { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 0: - if (!commState.putByteArray("siblingsBytes", siblingsBytes)) + if (!writer.writeByteArray("siblingsBytes", siblingsBytes)) return false; - commState.idx++; + state++; } @@ -121,16 +121,16 @@ public void unmarshalSiblings(Marshaller marsh) throws IgniteCheckedException { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); - switch (commState.idx) { + switch (state) { case 0: - siblingsBytes = commState.getByteArray("siblingsBytes"); + siblingsBytes = reader.readByteArray("siblingsBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridTaskCancelRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/GridTaskCancelRequest.java index 21153af7c1df4..75ff8eabec6a7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridTaskCancelRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridTaskCancelRequest.java @@ -80,21 +80,21 @@ public IgniteUuid sessionId() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 0: - if (!commState.putGridUuid("sesId", sesId)) + if (!writer.writeIgniteUuid("sesId", sesId)) return false; - commState.idx++; + state++; } @@ -104,16 +104,16 @@ public IgniteUuid sessionId() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); - switch (commState.idx) { + switch (state) { case 0: - sesId = commState.getGridUuid("sesId"); + sesId = reader.readIgniteUuid("sesId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridTaskSessionRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/GridTaskSessionRequest.java index f33e97ad966d6..1f75ee2bfe3af 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridTaskSessionRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridTaskSessionRequest.java @@ -120,33 +120,33 @@ public IgniteUuid getJobId() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 0: - if (!commState.putByteArray("attrsBytes", attrsBytes)) + if (!writer.writeByteArray("attrsBytes", attrsBytes)) return false; - commState.idx++; + state++; case 1: - if (!commState.putGridUuid("jobId", jobId)) + if (!writer.writeIgniteUuid("jobId", jobId)) return false; - commState.idx++; + state++; case 2: - if (!commState.putGridUuid("sesId", sesId)) + if (!writer.writeIgniteUuid("sesId", sesId)) return false; - commState.idx++; + state++; } @@ -156,32 +156,32 @@ public IgniteUuid getJobId() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); - switch (commState.idx) { + switch (state) { case 0: - attrsBytes = commState.getByteArray("attrsBytes"); + attrsBytes = reader.readByteArray("attrsBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 1: - jobId = commState.getGridUuid("jobId"); + jobId = reader.readIgniteUuid("jobId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 2: - sesId = commState.getGridUuid("sesId"); + sesId = reader.readIgniteUuid("sesId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java index 3234a64fc08b8..9d79f414e4e48 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectByteBufferStream.java @@ -969,7 +969,7 @@ public , T> C readCollection(Class itemCls) { } @SuppressWarnings("unchecked") - public Map readMap(Class keyCls, Class valCls) { + public , K, V> M readMap(Class keyCls, Class valCls) { if (readSize == -1) { int size = readInt(); @@ -1021,7 +1021,7 @@ public Map readMap(Class keyCls, Class valCls) { map = null; - return map0; + return (M)map0; } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java index f0efbae1e9a27..1bc3d50f19c42 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java @@ -263,8 +263,8 @@ public DirectMessageReader(GridTcpMessageFactory msgFactory) { } /** {@inheritDoc} */ - @Override public Map readMap(String name, Class keyCls, Class valCls) { - Map map = stream.readMap(keyCls, valCls); + @Override public , K, V> M readMap(String name, Class keyCls, Class valCls) { + M map = stream.readMap(keyCls, valCls); lastRead = stream.lastFinished(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/GridTcpCommunicationMessageState.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/GridTcpCommunicationMessageState.java deleted file mode 100644 index ad9542a6b5a1a..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/direct/GridTcpCommunicationMessageState.java +++ /dev/null @@ -1,726 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.direct; - -import org.apache.ignite.internal.processors.cache.*; -import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.*; -import org.apache.ignite.internal.processors.cache.version.*; -import org.apache.ignite.internal.processors.clock.*; -import org.apache.ignite.internal.util.*; -import org.apache.ignite.lang.*; -import org.apache.ignite.plugin.extensions.communication.*; -import org.jetbrains.annotations.*; -import sun.misc.*; - -import java.nio.*; -import java.util.*; - -import static org.apache.ignite.plugin.extensions.communication.MessageAdapter.*; - -/** - * Communication message state. - */ -@SuppressWarnings("PublicField") -public class GridTcpCommunicationMessageState { - /** */ - private static final Unsafe UNSAFE = GridUnsafe.unsafe(); - - /** */ - private static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class); - - /** */ - private final MessageWriter writer = new DirectMessageWriter(); - - /** */ - private MessageReader reader; - - /** */ - public int idx; - - /** */ - public boolean typeWritten; - - /** */ - public Iterator it; - - /** */ - public Object cur; - - /** */ - public boolean keyDone; - - /** */ - public int readSize = -1; - - /** */ - public int readItems; - - /** - * @param writer Writer. - */ - public final void setWriter(MessageWriter writer) { -// if (this.writer == null) -// this.writer = writer; - } - - /** - * @param reader Reader. - */ - public final void setReader(MessageReader reader) { - if (this.reader == null) - this.reader = reader; - } - - /** - * @param buf Buffer. - */ - public final void setBuffer(ByteBuffer buf) { - if (writer != null) - writer.setBuffer(buf); - - if (reader != null) - reader.setBuffer(buf); - } - - /** - * @param name Field name. - * @param b Byte value. - * @return Whether value was written. - */ - public final boolean putByte(String name, byte b) { - return writer.writeByte(name, b); - } - - /** - * @param name Field name. - * @return Byte value. - */ - public final byte getByte(String name) { - return reader.readByte(name); - } - - /** - * @param name Field name. - * @param s Short value. - * @return Whether value was written. - */ - public final boolean putShort(String name, short s) { - return writer.writeShort(name, s); - } - - /** - * @param name Field name. - * @return Short value. - */ - public final short getShort(String name) { - return reader.readShort(name); - } - - /** - * @param name Field name. - * @param i Integer value. - * @return Whether value was written. - */ - public final boolean putInt(String name, int i) { - return writer.writeInt(name, i); - } - - /** - * @param name Field name. - * @return Integer value. - */ - public final int getInt(String name) { - return reader.readInt(name); - } - - /** - * @param name Field name. - * @param l Long value. - * @return Whether value was written. - */ - public final boolean putLong(String name, long l) { - return writer.writeLong(name, l); - } - - /** - * @param name Field name. - * @return Long value. - */ - public final long getLong(String name) { - return reader.readLong(name); - } - - /** - * @param name Field name. - * @param f Float value. - * @return Whether value was written. - */ - public final boolean putFloat(String name, float f) { - return writer.writeFloat(name, f); - } - - /** - * @param name Field name. - * @return Float value. - */ - public final float getFloat(String name) { - return reader.readFloat(name); - } - - /** - * @param name Field name. - * @param d Double value. - * @return Whether value was written. - */ - public final boolean putDouble(String name, double d) { - return writer.writeDouble(name, d); - } - - /** - * @param name Field name. - * @return Double value. - */ - public final double getDouble(String name) { - return reader.readDouble(name); - } - - /** - * @param name Field name. - * @param c Char value. - * @return Whether value was written. - */ - public final boolean putChar(String name, char c) { - return writer.writeChar(name, c); - } - - /** - * @param name Field name. - * @return Char value. - */ - public final char getChar(String name) { - return reader.readChar(name); - } - - /** - * @param name Field name. - * @param b Boolean value. - * @return Whether value was written. - */ - public final boolean putBoolean(String name, boolean b) { - return writer.writeBoolean(name, b); - } - - /** - * @param name Field name. - * @return Boolean value. - */ - public final boolean getBoolean(String name) { - return reader.readBoolean(name); - } - - /** - * @param name Field name. - * @param arr Byte array. - * @return Whether array was fully written. - */ - public final boolean putByteArray(String name, @Nullable byte[] arr) { - return writer.writeByteArray(name, arr); - } - - /** - * @param name Field name. - * @return Byte array. - */ - public final byte[] getByteArray(String name) { - return reader.readByteArray(name); - } - - /** - * @param name Field name. - * @param arr Short array. - * @return Whether array was fully written. - */ - public final boolean putShortArray(String name, short[] arr) { - return writer.writeShortArray(name, arr); - } - - /** - * @param name Field name. - * @return Short array. - */ - public final short[] getShortArray(String name) { - return reader.readShortArray(name); - } - - /** - * @param name Field name. - * @param arr Integer array. - * @return Whether array was fully written. - */ - public final boolean putIntArray(String name, int[] arr) { - return writer.writeIntArray(name, arr); - } - - /** - * @param name Field name. - * @return Integer array. - */ - public final int[] getIntArray(String name) { - return reader.readIntArray(name); - } - - /** - * @param name Field name. - * @param arr Long array. - * @return Whether array was fully written. - */ - public final boolean putLongArray(String name, long[] arr) { - return writer.writeLongArray(name, arr); - } - - /** - * @param name Field name. - * @return Long array. - */ - public final long[] getLongArray(String name) { - return reader.readLongArray(name); - } - - /** - * @param name Field name. - * @param arr Float array. - * @return Whether array was fully written. - */ - public final boolean putFloatArray(String name, float[] arr) { - return writer.writeFloatArray(name, arr); - } - - /** - * @param name Field name. - * @return Float array. - */ - public final float[] getFloatArray(String name) { - return reader.readFloatArray(name); - } - - /** - * @param name Field name. - * @param arr Double array. - * @return Whether array was fully written. - */ - public final boolean putDoubleArray(String name, double[] arr) { - return writer.writeDoubleArray(name, arr); - } - - /** - * @param name Field name. - * @return Double array. - */ - public final double[] getDoubleArray(String name) { - return reader.readDoubleArray(name); - } - - /** - * @param name Field name. - * @param arr Char array. - * @return Whether array was fully written. - */ - public final boolean putCharArray(String name, char[] arr) { - return writer.writeCharArray(name, arr); - } - - /** - * @param name Field name. - * @return Char array. - */ - public final char[] getCharArray(String name) { - return reader.readCharArray(name); - } - - /** - * @param name Field name. - * @param arr Boolean array. - * @return Whether array was fully written. - */ - public final boolean putBooleanArray(String name, boolean[] arr) { - return writer.writeBooleanArray(name, arr); - } - - /** - * @param name Field name. - * @return Boolean array. - */ - public final boolean[] getBooleanArray(String name) { - return reader.readBooleanArray(name); - } - - - /** - * @param name Field name. - * @param uuid {@link UUID}. - * @return Whether value was fully written. - */ - public final boolean putUuid(String name, @Nullable UUID uuid) { - byte[] arr = null; - - if (uuid != null) { - arr = new byte[16]; - - UNSAFE.putLong(arr, BYTE_ARR_OFF, uuid.getMostSignificantBits()); - UNSAFE.putLong(arr, BYTE_ARR_OFF + 8, uuid.getLeastSignificantBits()); - } - - return putByteArray(name, arr); - } - - /** - * @param name Field name. - * @return {@link UUID}. - */ - public final UUID getUuid(String name) { - byte[] arr = getByteArray(name); - - if (arr == null) - return null; - else { - long most = UNSAFE.getLong(arr, BYTE_ARR_OFF); - long least = UNSAFE.getLong(arr, BYTE_ARR_OFF + 8); - - return new UUID(most, least); - } - } - - /** - * @param name Field name. - * @param uuid {@link IgniteUuid}. - * @return Whether value was fully written. - */ - public final boolean putGridUuid(String name, @Nullable IgniteUuid uuid) { - byte[] arr = null; - - if (uuid != null) { - arr = new byte[24]; - - UNSAFE.putLong(arr, BYTE_ARR_OFF, uuid.globalId().getMostSignificantBits()); - UNSAFE.putLong(arr, BYTE_ARR_OFF + 8, uuid.globalId().getLeastSignificantBits()); - UNSAFE.putLong(arr, BYTE_ARR_OFF + 16, uuid.localId()); - } - - return putByteArray(name, arr); - } - - /** - * @param name Field name. - * @return {@link IgniteUuid}. - */ - public final IgniteUuid getGridUuid(String name) { - byte[] arr = getByteArray(name); - - if (arr == null) - return null; - else { - long most = UNSAFE.getLong(arr, BYTE_ARR_OFF); - long least = UNSAFE.getLong(arr, BYTE_ARR_OFF + 8); - long loc = UNSAFE.getLong(arr, BYTE_ARR_OFF + 16); - - return new IgniteUuid(new UUID(most, least), loc); - } - } - - /** - * @param name Field name. - * @param ver {@link GridClockDeltaVersion}. - * @return Whether value was fully written. - */ - public final boolean putClockDeltaVersion(String name, @Nullable GridClockDeltaVersion ver) { - byte[] arr = null; - - if (ver != null) { - arr = new byte[16]; - - UNSAFE.putLong(arr, BYTE_ARR_OFF, ver.version()); - UNSAFE.putLong(arr, BYTE_ARR_OFF + 8, ver.topologyVersion()); - } - - return putByteArray(name, arr); - } - - /** - * @param name Field name. - * @return {@link GridClockDeltaVersion}. - */ - public final GridClockDeltaVersion getClockDeltaVersion(String name) { - byte[] arr = getByteArray(name); - - if (arr == null) - return null; - else { - long ver = UNSAFE.getLong(arr, BYTE_ARR_OFF); - long topVer = UNSAFE.getLong(arr, BYTE_ARR_OFF + 8); - - return new GridClockDeltaVersion(ver, topVer); - } - } - - /** - * @param name Field name. - * @param list {@link GridByteArrayList}. - * @return Whether value was fully written. - */ - public final boolean putByteArrayList(String name, @Nullable GridByteArrayList list) { - return putByteArray(name, list != null ? list.array() : null); - } - - /** - * @param name Field name. - * @return {@link GridByteArrayList}. - */ - public final GridByteArrayList getByteArrayList(String name) { - byte[] arr = getByteArray(name); - - return arr != null ? new GridByteArrayList(arr) : null; - } - - /** - * @param name Field name. - * @param list {@link GridLongList}. - * @return Whether value was fully written. - */ - public final boolean putLongList(String name, @Nullable GridLongList list) { - return putLongArray(name, list != null ? list.array() : null); - } - - /** - * @param name Field name. - * @return {@link GridLongList}. - */ - public final GridLongList getLongList(String name) { - long[] arr = getLongArray(name); - - return arr != null ? new GridLongList(arr) : null; - } - - /** - * @param name Field name. - * @param ver {@link org.apache.ignite.internal.processors.cache.version.GridCacheVersion}. - * @return Whether value was fully written. - */ - public final boolean putCacheVersion(String name, @Nullable GridCacheVersion ver) { - byte[] arr = null; - - if (ver != null) { - arr = new byte[24]; - - UNSAFE.putInt(arr, BYTE_ARR_OFF, ver.topologyVersion()); - UNSAFE.putInt(arr, BYTE_ARR_OFF + 4, ver.nodeOrderAndDrIdRaw()); - UNSAFE.putLong(arr, BYTE_ARR_OFF + 8, ver.globalTime()); - UNSAFE.putLong(arr, BYTE_ARR_OFF + 16, ver.order()); - } - - return putByteArray(name, arr); - } - - /** - * @param name Field name. - * @return {@link GridCacheVersion}. - */ - public final GridCacheVersion getCacheVersion(String name) { - byte[] arr = getByteArray(name); - - if (arr == null) - return null; - else { - int topVerDrId = UNSAFE.getInt(arr, BYTE_ARR_OFF); - int nodeOrder = UNSAFE.getInt(arr, BYTE_ARR_OFF + 4); - long globalTime = UNSAFE.getLong(arr, BYTE_ARR_OFF + 8); - long order = UNSAFE.getLong(arr, BYTE_ARR_OFF + 16); - - return new GridCacheVersion(topVerDrId, nodeOrder, globalTime, order); - } - } - - /** - * @param name Field name. - * @param id {@link GridDhtPartitionExchangeId}. - * @return Whether value was fully written. - */ - public final boolean putDhtPartitionExchangeId(String name, @Nullable GridDhtPartitionExchangeId id) { - byte[] arr = null; - - if (id != null) { - arr = new byte[28]; - - UNSAFE.putLong(arr, BYTE_ARR_OFF, id.nodeId().getMostSignificantBits()); - UNSAFE.putLong(arr, BYTE_ARR_OFF + 8, id.nodeId().getLeastSignificantBits()); - UNSAFE.putInt(arr, BYTE_ARR_OFF + 16, id.event()); - UNSAFE.putLong(arr, BYTE_ARR_OFF + 20, id.topologyVersion()); - } - - return putByteArray(name, arr); - } - - /** - * @param name Field name. - * @return {@link GridDhtPartitionExchangeId}. - */ - public final GridDhtPartitionExchangeId getDhtPartitionExchangeId(String name) { - byte[] arr = getByteArray(name); - - if (arr == null) - return null; - else { - long most = UNSAFE.getLong(arr, BYTE_ARR_OFF); - long least = UNSAFE.getLong(arr, BYTE_ARR_OFF + 8); - int evt = UNSAFE.getInt(arr, BYTE_ARR_OFF + 16); - long topVer = UNSAFE.getLong(arr, BYTE_ARR_OFF + 20); - - return new GridDhtPartitionExchangeId(new UUID(most, least), evt, topVer); - } - } - - /** - * @param name Field name. - * @param bytes {@link GridCacheValueBytes}. - * @return Whether value was fully written. - */ - public final boolean putValueBytes(String name, @Nullable GridCacheValueBytes bytes) { - byte[] arr = null; - - if (bytes != null) { - byte[] bytes0 = bytes.get(); - - if (bytes0 != null) { - int len = bytes0.length; - - arr = new byte[len + 2]; - - UNSAFE.putBoolean(arr, BYTE_ARR_OFF, true); - UNSAFE.copyMemory(bytes0, BYTE_ARR_OFF, arr, BYTE_ARR_OFF + 1, len); - UNSAFE.putBoolean(arr, BYTE_ARR_OFF + 1 + len, bytes.isPlain()); - } - else { - arr = new byte[1]; - - UNSAFE.putBoolean(arr, BYTE_ARR_OFF, false); - } - } - - return putByteArray(name, arr); - } - - /** - * @param name Field name. - * @return {@link GridCacheValueBytes}. - */ - public final GridCacheValueBytes getValueBytes(String name) { - byte[] arr = getByteArray(name); - - if (arr == null) - return null; - else { - boolean notNull = UNSAFE.getBoolean(arr, BYTE_ARR_OFF); - - if (notNull) { - int len = arr.length - 2; - - assert len >= 0 : len; - - byte[] bytesArr = new byte[len]; - - UNSAFE.copyMemory(arr, BYTE_ARR_OFF + 1, bytesArr, BYTE_ARR_OFF, len); - - boolean isPlain = UNSAFE.getBoolean(arr, BYTE_ARR_OFF + 1 + len); - - return new GridCacheValueBytes(bytesArr, isPlain); - } - else - return new GridCacheValueBytes(); - } - } - - /** - * @param name Field name. - * @param str {@link String}. - * @return Whether value was fully written. - */ - public final boolean putString(String name, @Nullable String str) { - return putByteArray(name, str != null ? str.getBytes() : null); - } - - /** - * @param name Field name. - * @return {@link String}. - */ - public final String getString(String name) { - byte[] arr = getByteArray(name); - - return arr != null ? new String(arr) : null; - } - - /** - * @param name Field name. - * @param bits {@link BitSet}. - * @return Whether value was fully written. - */ - public final boolean putBitSet(String name, @Nullable BitSet bits) { - return putLongArray(name, bits != null ? bits.toLongArray() : null); - } - - /** - * @param name Field name. - * @return {@link BitSet}. - */ - public final BitSet getBitSet(String name) { - long[] arr = getLongArray(name); - - return arr != null ? BitSet.valueOf(arr) : null; - } - - /** - * @param name Field name. - * @param e Enum. - * @return Whether value was fully written. - */ - public final boolean putEnum(String name, @Nullable Enum e) { - return putByte(name, e != null ? (byte)e.ordinal() : -1); - } - - /** - * @param name Field name. - * @param msg {@link MessageAdapter}. - * @return Whether value was fully written. - */ - public final boolean putMessage(String name, @Nullable MessageAdapter msg) { - if (msg != null) - msg.setWriter(writer); - - return writer.writeMessage(name, msg); - } - - /** - * @param name Field name. - * @return {@link MessageAdapter}. - */ - public final MessageAdapter getMessage(String name) { - return reader.readMessage(name); - } - - public final boolean lastRead() { - return reader.isLastRead(); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointRequest.java index fda129a4d8f6d..5085a9cdae501 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/checkpoint/GridCheckpointRequest.java @@ -105,33 +105,33 @@ public String getCheckpointSpi() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 0: - if (!commState.putString("cpSpi", cpSpi)) + if (!writer.writeString("cpSpi", cpSpi)) return false; - commState.idx++; + state++; case 1: - if (!commState.putString("key", key)) + if (!writer.writeString("key", key)) return false; - commState.idx++; + state++; case 2: - if (!commState.putGridUuid("sesId", sesId)) + if (!writer.writeIgniteUuid("sesId", sesId)) return false; - commState.idx++; + state++; } @@ -141,32 +141,32 @@ public String getCheckpointSpi() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); - switch (commState.idx) { + switch (state) { case 0: - cpSpi = commState.getString("cpSpi"); + cpSpi = reader.readString("cpSpi"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 1: - key = commState.getString("key"); + key = reader.readString("key"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 2: - sesId = commState.getGridUuid("sesId"); + sesId = reader.readIgniteUuid("sesId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java index 5dc52d86ebb23..27d64be594c7b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java @@ -200,63 +200,63 @@ boolean isOrdered() { _clone.ordered = ordered; _clone.timeout = timeout; _clone.skipOnTimeout = skipOnTimeout; - _clone.msg = msg != null ? (MessageAdapter)msg.clone() : null; + _clone.msg = msg; } /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 0: - if (!commState.putMessage("msg", msg)) + if (!writer.writeMessage("msg", msg != null ? msg.clone() : null)) return false; - commState.idx++; + state++; case 1: - if (!commState.putBoolean("ordered", ordered)) + if (!writer.writeBoolean("ordered", ordered)) return false; - commState.idx++; + state++; case 2: - if (!commState.putEnum("plc", plc)) + if (!writer.writeEnum("plc", plc)) return false; - commState.idx++; + state++; case 3: - if (!commState.putBoolean("skipOnTimeout", skipOnTimeout)) + if (!writer.writeBoolean("skipOnTimeout", skipOnTimeout)) return false; - commState.idx++; + state++; case 4: - if (!commState.putLong("timeout", timeout)) + if (!writer.writeLong("timeout", timeout)) return false; - commState.idx++; + state++; case 5: - if (!commState.putByteArray("topicBytes", topicBytes)) + if (!writer.writeByteArray("topicBytes", topicBytes)) return false; - commState.idx++; + state++; case 6: - if (!commState.putInt("topicOrd", topicOrd)) + if (!writer.writeInt("topicOrd", topicOrd)) return false; - commState.idx++; + state++; } @@ -266,66 +266,64 @@ boolean isOrdered() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); - switch (commState.idx) { + switch (state) { case 0: - msg = commState.getMessage("msg"); + msg = reader.readMessage("msg"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 1: - ordered = commState.getBoolean("ordered"); + ordered = reader.readBoolean("ordered"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 2: - byte plc0 = commState.getByte("plc"); + plc = reader.readEnum("plc", GridIoPolicy.class); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - plc = GridIoPolicy.fromOrdinal(plc0); - - commState.idx++; + state++; case 3: - skipOnTimeout = commState.getBoolean("skipOnTimeout"); + skipOnTimeout = reader.readBoolean("skipOnTimeout"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 4: - timeout = commState.getLong("timeout"); + timeout = reader.readLong("timeout"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 5: - topicBytes = commState.getByteArray("topicBytes"); + topicBytes = reader.readByteArray("topicBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 6: - topicOrd = commState.getInt("topicOrd"); + topicOrd = reader.readInt("topicOrd"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoUserMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoUserMessage.java index 44039a32d1169..0bc81d4e21bf6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoUserMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoUserMessage.java @@ -231,89 +231,57 @@ public void deployment(GridDeployment dep) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 0: - if (!commState.putByteArray("bodyBytes", bodyBytes)) + if (!writer.writeByteArray("bodyBytes", bodyBytes)) return false; - commState.idx++; + state++; case 1: - if (!commState.putGridUuid("clsLdrId", clsLdrId)) + if (!writer.writeIgniteUuid("clsLdrId", clsLdrId)) return false; - commState.idx++; + state++; case 2: - if (!commState.putString("depClsName", depClsName)) + if (!writer.writeString("depClsName", depClsName)) return false; - commState.idx++; + state++; case 3: - if (!commState.putEnum("depMode", depMode)) + if (!writer.writeEnum("depMode", depMode)) return false; - commState.idx++; + state++; case 4: - if (ldrParties != null) { - if (commState.it == null) { - if (!commState.putInt(null, ldrParties.size())) - return false; - - commState.it = ldrParties.entrySet().iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - Map.Entry e = (Map.Entry)commState.cur; - - if (!commState.keyDone) { - if (!commState.putUuid(null, e.getKey())) - return false; - - commState.keyDone = true; - } - - if (!commState.putGridUuid(null, e.getValue())) - return false; - - commState.keyDone = false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeMap("ldrParties", ldrParties, UUID.class, IgniteUuid.class)) + return false; - commState.idx++; + state++; case 5: - if (!commState.putByteArray("topicBytes", topicBytes)) + if (!writer.writeByteArray("topicBytes", topicBytes)) return false; - commState.idx++; + state++; case 6: - if (!commState.putString("userVer", userVer)) + if (!writer.writeString("userVer", userVer)) return false; - commState.idx++; + state++; } @@ -323,101 +291,64 @@ public void deployment(GridDeployment dep) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); - switch (commState.idx) { + switch (state) { case 0: - bodyBytes = commState.getByteArray("bodyBytes"); + bodyBytes = reader.readByteArray("bodyBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 1: - clsLdrId = commState.getGridUuid("clsLdrId"); + clsLdrId = reader.readIgniteUuid("clsLdrId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 2: - depClsName = commState.getString("depClsName"); + depClsName = reader.readString("depClsName"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 3: - byte depMode0 = commState.getByte("depMode"); + depMode = reader.readEnum("depMode", DeploymentMode.class); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - depMode = DeploymentMode.fromOrdinal(depMode0); - - commState.idx++; + state++; case 4: - if (commState.readSize == -1) { - int _val = commState.getInt(null); + ldrParties = reader.readMap("ldrParties", UUID.class, IgniteUuid.class); - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (ldrParties == null) - ldrParties = new HashMap<>(commState.readSize, 1.0f); - - for (int i = commState.readItems; i < commState.readSize; i++) { - if (!commState.keyDone) { - UUID _val = commState.getUuid(null); - - if (!commState.lastRead()) - return false; - - commState.cur = _val; - commState.keyDone = true; - } - - IgniteUuid _val = commState.getGridUuid(null); - - if (!commState.lastRead()) - return false; - - ldrParties.put((UUID)commState.cur, _val); - - commState.keyDone = false; - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; - commState.cur = null; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 5: - topicBytes = commState.getByteArray("topicBytes"); + topicBytes = reader.readByteArray("topicBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 6: - userVer = commState.getString("userVer"); + userVer = reader.readString("userVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentInfoBean.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentInfoBean.java index c0698d06f91a2..4907c56afc446 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentInfoBean.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentInfoBean.java @@ -161,77 +161,45 @@ public void localDeploymentOwner(boolean locDepOwner) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 0: - if (!commState.putGridUuid("clsLdrId", clsLdrId)) + if (!writer.writeIgniteUuid("clsLdrId", clsLdrId)) return false; - commState.idx++; + state++; case 1: - if (!commState.putEnum("depMode", depMode)) + if (!writer.writeEnum("depMode", depMode)) return false; - commState.idx++; + state++; case 2: - if (!commState.putBoolean("locDepOwner", locDepOwner)) + if (!writer.writeBoolean("locDepOwner", locDepOwner)) return false; - commState.idx++; + state++; case 3: - if (participants != null) { - if (commState.it == null) { - if (!commState.putInt(null, participants.size())) - return false; - - commState.it = participants.entrySet().iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - Map.Entry e = (Map.Entry)commState.cur; - - if (!commState.keyDone) { - if (!commState.putUuid(null, e.getKey())) - return false; - - commState.keyDone = true; - } - - if (!commState.putGridUuid(null, e.getValue())) - return false; - - commState.keyDone = false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeMap("participants", participants, UUID.class, IgniteUuid.class)) + return false; - commState.idx++; + state++; case 4: - if (!commState.putString("userVer", userVer)) + if (!writer.writeString("userVer", userVer)) return false; - commState.idx++; + state++; } @@ -241,85 +209,48 @@ public void localDeploymentOwner(boolean locDepOwner) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); - switch (commState.idx) { + switch (state) { case 0: - clsLdrId = commState.getGridUuid("clsLdrId"); + clsLdrId = reader.readIgniteUuid("clsLdrId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 1: - byte depMode0 = commState.getByte("depMode"); + depMode = reader.readEnum("depMode", DeploymentMode.class); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - depMode = DeploymentMode.fromOrdinal(depMode0); - - commState.idx++; + state++; case 2: - locDepOwner = commState.getBoolean("locDepOwner"); + locDepOwner = reader.readBoolean("locDepOwner"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 3: - if (commState.readSize == -1) { - int _val = commState.getInt(null); + participants = reader.readMap("participants", UUID.class, IgniteUuid.class); - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (participants == null) - participants = new HashMap<>(commState.readSize, 1.0f); - - for (int i = commState.readItems; i < commState.readSize; i++) { - if (!commState.keyDone) { - UUID _val = commState.getUuid(null); - - if (!commState.lastRead()) - return false; - - commState.cur = _val; - commState.keyDone = true; - } - - IgniteUuid _val = commState.getGridUuid(null); - - if (!commState.lastRead()) - return false; - - participants.put((UUID)commState.cur, _val); - - commState.keyDone = false; - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; - commState.cur = null; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 4: - userVer = commState.getString("userVer"); + userVer = reader.readString("userVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentRequest.java index 86019b9a6e132..50d9b24fd62ff 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentRequest.java @@ -180,66 +180,45 @@ public void nodeIds(Collection nodeIds) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 0: - if (!commState.putBoolean("isUndeploy", isUndeploy)) + if (!writer.writeBoolean("isUndeploy", isUndeploy)) return false; - commState.idx++; + state++; case 1: - if (!commState.putGridUuid("ldrId", ldrId)) + if (!writer.writeIgniteUuid("ldrId", ldrId)) return false; - commState.idx++; + state++; case 2: - if (nodeIds != null) { - if (commState.it == null) { - if (!commState.putInt(null, nodeIds.size())) - return false; - - commState.it = nodeIds.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putUuid(null, (UUID)commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("nodeIds", nodeIds, UUID.class)) + return false; - commState.idx++; + state++; case 3: - if (!commState.putByteArray("resTopicBytes", resTopicBytes)) + if (!writer.writeByteArray("resTopicBytes", resTopicBytes)) return false; - commState.idx++; + state++; case 4: - if (!commState.putString("rsrcName", rsrcName)) + if (!writer.writeString("rsrcName", rsrcName)) return false; - commState.idx++; + state++; } @@ -249,70 +228,48 @@ public void nodeIds(Collection nodeIds) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); - switch (commState.idx) { + switch (state) { case 0: - isUndeploy = commState.getBoolean("isUndeploy"); + isUndeploy = reader.readBoolean("isUndeploy"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 1: - ldrId = commState.getGridUuid("ldrId"); + ldrId = reader.readIgniteUuid("ldrId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 2: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } + nodeIds = reader.readCollection("nodeIds", UUID.class); - if (commState.readSize >= 0) { - if (nodeIds == null) - nodeIds = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - UUID _val = commState.getUuid(null); - - if (!commState.lastRead()) - return false; - - nodeIds.add((UUID)_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 3: - resTopicBytes = commState.getByteArray("resTopicBytes"); + resTopicBytes = reader.readByteArray("resTopicBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 4: - rsrcName = commState.getString("rsrcName"); + rsrcName = reader.readString("rsrcName"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentResponse.java index de50cc973e305..c46d7f332d8a9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentResponse.java @@ -127,33 +127,33 @@ void errorMessage(String errMsg) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 0: - if (!commState.putByteArrayList("byteSrc", byteSrc)) + if (!writer.writeMessage("byteSrc", byteSrc != null ? byteSrc.clone() : null)) return false; - commState.idx++; + state++; case 1: - if (!commState.putString("errMsg", errMsg)) + if (!writer.writeString("errMsg", errMsg)) return false; - commState.idx++; + state++; case 2: - if (!commState.putBoolean("success", success)) + if (!writer.writeBoolean("success", success)) return false; - commState.idx++; + state++; } @@ -163,32 +163,32 @@ void errorMessage(String errMsg) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); - switch (commState.idx) { + switch (state) { case 0: - byteSrc = commState.getByteArrayList("byteSrc"); + byteSrc = reader.readMessage("byteSrc"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 1: - errMsg = commState.getString("errMsg"); + errMsg = reader.readString("errMsg"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 2: - success = commState.getBoolean("success"); + success = reader.readBoolean("success"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java index 1658b88337bc7..352d3603edc39 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/eventstorage/GridEventStorageMessage.java @@ -291,101 +291,69 @@ void exceptionBytes(byte[] exBytes) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 0: - if (!commState.putGridUuid("clsLdrId", clsLdrId)) + if (!writer.writeIgniteUuid("clsLdrId", clsLdrId)) return false; - commState.idx++; + state++; case 1: - if (!commState.putEnum("depMode", depMode)) + if (!writer.writeEnum("depMode", depMode)) return false; - commState.idx++; + state++; case 2: - if (!commState.putByteArray("evtsBytes", evtsBytes)) + if (!writer.writeByteArray("evtsBytes", evtsBytes)) return false; - commState.idx++; + state++; case 3: - if (!commState.putByteArray("exBytes", exBytes)) + if (!writer.writeByteArray("exBytes", exBytes)) return false; - commState.idx++; + state++; case 4: - if (!commState.putByteArray("filter", filter)) + if (!writer.writeByteArray("filter", filter)) return false; - commState.idx++; + state++; case 5: - if (!commState.putString("filterClsName", filterClsName)) + if (!writer.writeString("filterClsName", filterClsName)) return false; - commState.idx++; + state++; case 6: - if (ldrParties != null) { - if (commState.it == null) { - if (!commState.putInt(null, ldrParties.size())) - return false; - - commState.it = ldrParties.entrySet().iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - Map.Entry e = (Map.Entry)commState.cur; - - if (!commState.keyDone) { - if (!commState.putUuid(null, e.getKey())) - return false; - - commState.keyDone = true; - } - - if (!commState.putGridUuid(null, e.getValue())) - return false; - - commState.keyDone = false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeMap("ldrParties", ldrParties, UUID.class, IgniteUuid.class)) + return false; - commState.idx++; + state++; case 7: - if (!commState.putByteArray("resTopicBytes", resTopicBytes)) + if (!writer.writeByteArray("resTopicBytes", resTopicBytes)) return false; - commState.idx++; + state++; case 8: - if (!commState.putString("userVer", userVer)) + if (!writer.writeString("userVer", userVer)) return false; - commState.idx++; + state++; } @@ -395,117 +363,80 @@ void exceptionBytes(byte[] exBytes) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); - switch (commState.idx) { + switch (state) { case 0: - clsLdrId = commState.getGridUuid("clsLdrId"); + clsLdrId = reader.readIgniteUuid("clsLdrId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 1: - byte depMode0 = commState.getByte("depMode"); + depMode = reader.readEnum("depMode", DeploymentMode.class); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - depMode = DeploymentMode.fromOrdinal(depMode0); - - commState.idx++; + state++; case 2: - evtsBytes = commState.getByteArray("evtsBytes"); + evtsBytes = reader.readByteArray("evtsBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 3: - exBytes = commState.getByteArray("exBytes"); + exBytes = reader.readByteArray("exBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 4: - filter = commState.getByteArray("filter"); + filter = reader.readByteArray("filter"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 5: - filterClsName = commState.getString("filterClsName"); + filterClsName = reader.readString("filterClsName"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 6: - if (commState.readSize == -1) { - int _val = commState.getInt(null); + ldrParties = reader.readMap("ldrParties", UUID.class, IgniteUuid.class); - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (ldrParties == null) - ldrParties = new HashMap<>(commState.readSize, 1.0f); - - for (int i = commState.readItems; i < commState.readSize; i++) { - if (!commState.keyDone) { - UUID _val = commState.getUuid(null); - - if (!commState.lastRead()) - return false; - - commState.cur = _val; - commState.keyDone = true; - } - - IgniteUuid _val = commState.getGridUuid(null); - - if (!commState.lastRead()) - return false; - - ldrParties.put((UUID)commState.cur, _val); - - commState.keyDone = false; - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; - commState.cur = null; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 7: - resTopicBytes = commState.getByteArray("resTopicBytes"); + resTopicBytes = reader.readByteArray("resTopicBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 8: - userVer = commState.getString("userVer"); + userVer = reader.readString("userVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionRequest.java index bb63b86e20a33..ce7d4d763a36b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionRequest.java @@ -164,36 +164,36 @@ void addKey(K key, GridCacheVersion ver, boolean near) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 3: - if (!commState.putByteArray("entriesBytes", entriesBytes)) + if (!writer.writeByteArray("entriesBytes", entriesBytes)) return false; - commState.idx++; + state++; case 4: - if (!commState.putLong("futId", futId)) + if (!writer.writeLong("futId", futId)) return false; - commState.idx++; + state++; case 5: - if (!commState.putLong("topVer", topVer)) + if (!writer.writeLong("topVer", topVer)) return false; - commState.idx++; + state++; } @@ -203,35 +203,35 @@ void addKey(K key, GridCacheVersion ver, boolean near) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 3: - entriesBytes = commState.getByteArray("entriesBytes"); + entriesBytes = reader.readByteArray("entriesBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 4: - futId = commState.getLong("futId"); + futId = reader.readLong("futId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 5: - topVer = commState.getLong("topVer"); + topVer = reader.readLong("topVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionResponse.java index 819902058e011..2687e95b07318 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionResponse.java @@ -153,57 +153,36 @@ boolean error() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 3: - if (!commState.putBoolean("err", err)) + if (!writer.writeBoolean("err", err)) return false; - commState.idx++; + state++; case 4: - if (!commState.putLong("futId", futId)) + if (!writer.writeLong("futId", futId)) return false; - commState.idx++; + state++; case 5: - if (rejectedKeyBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, rejectedKeyBytes.size())) - return false; - - commState.it = rejectedKeyBytes.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putByteArray(null, (byte[])commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("rejectedKeyBytes", rejectedKeyBytes, byte[].class)) + return false; - commState.idx++; + state++; } @@ -213,57 +192,35 @@ boolean error() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 3: - err = commState.getBoolean("err"); + err = reader.readBoolean("err"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 4: - futId = commState.getLong("futId"); + futId = reader.readLong("futId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 5: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } + rejectedKeyBytes = reader.readCollection("rejectedKeyBytes", byte[].class); - if (commState.readSize >= 0) { - if (rejectedKeyBytes == null) - rejectedKeyBytes = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(null); - - if (!commState.lastRead()) - return false; - - rejectedKeyBytes.add((byte[])_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java index 78028b0d5c2a3..dc8feee5dbb3c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java @@ -648,7 +648,7 @@ protected final void unmarshalTx(Iterable> txEntries, GridCacheMessage _clone = (GridCacheMessage)_msg; _clone.msgId = msgId; - _clone.depInfo = depInfo != null ? (GridDeploymentInfoBean)depInfo.clone() : null; + _clone.depInfo = depInfo; _clone.err = err; _clone.skipPrepare = skipPrepare; _clone.cacheId = cacheId; @@ -657,33 +657,33 @@ protected final void unmarshalTx(Iterable> txEntries, /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 0: - if (!commState.putInt("cacheId", cacheId)) + if (!writer.writeInt("cacheId", cacheId)) return false; - commState.idx++; + state++; case 1: - if (!commState.putMessage("depInfo", depInfo)) + if (!writer.writeMessage("depInfo", depInfo != null ? depInfo.clone() : null)) return false; - commState.idx++; + state++; case 2: - if (!commState.putLong("msgId", msgId)) + if (!writer.writeLong("msgId", msgId)) return false; - commState.idx++; + state++; } @@ -693,32 +693,32 @@ protected final void unmarshalTx(Iterable> txEntries, /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); - switch (commState.idx) { + switch (state) { case 0: - cacheId = commState.getInt("cacheId"); + cacheId = reader.readInt("cacheId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 1: - depInfo = (GridDeploymentInfoBean)commState.getMessage("depInfo"); + depInfo = reader.readMessage("depInfo"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 2: - msgId = commState.getLong("msgId"); + msgId = reader.readLong("msgId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheValueBytes.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheValueBytes.java index aba1c18d59fd0..289db2e08dd5f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheValueBytes.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheValueBytes.java @@ -118,12 +118,57 @@ public boolean isNull() { /** {@inheritDoc} */ @Override public boolean writeTo(ByteBuffer buf) { - return false; // TODO: implement. + writer.setBuffer(buf); + + if (!typeWritten) { + if (!writer.writeByte(null, directType())) + return false; + + typeWritten = true; + } + + switch (state) { + case 0: + if (!writer.writeByteArray("bytes", bytes)) + return false; + + state++; + + case 1: + if (!writer.writeBoolean("plain", plain)) + return false; + + state++; + + } + + return true; } /** {@inheritDoc} */ @Override public boolean readFrom(ByteBuffer buf) { - return false; // TODO: implement. + reader.setBuffer(buf); + + switch (state) { + case 0: + bytes = reader.readByteArray("bytes"); + + if (!reader.isLastRead()) + return false; + + state++; + + case 1: + plain = reader.readBoolean("plain"); + + if (!reader.isLastRead()) + return false; + + state++; + + } + + return true; } /** {@inheritDoc} */ @@ -133,12 +178,19 @@ public boolean isNull() { /** {@inheritDoc} */ @Override public MessageAdapter clone() { - return null; // TODO: implement. + GridCacheValueBytes _clone = new GridCacheValueBytes(); + + clone0(_clone); + + return _clone; } /** {@inheritDoc} */ @Override protected void clone0(MessageAdapter _msg) { - // TODO: implement. + GridCacheValueBytes _clone = (GridCacheValueBytes)_msg; + + _clone.bytes = bytes; + _clone.plain = plain; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxRequest.java index e021408985679..914f15098becc 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxRequest.java @@ -121,42 +121,42 @@ public int transactions() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 8: - if (!commState.putGridUuid("futId", futId)) + if (!writer.writeIgniteUuid("futId", futId)) return false; - commState.idx++; + state++; case 9: - if (!commState.putGridUuid("miniId", miniId)) + if (!writer.writeIgniteUuid("miniId", miniId)) return false; - commState.idx++; + state++; case 10: - if (!commState.putCacheVersion("nearXidVer", nearXidVer)) + if (!writer.writeMessage("nearXidVer", nearXidVer != null ? nearXidVer.clone() : null)) return false; - commState.idx++; + state++; case 11: - if (!commState.putInt("txNum", txNum)) + if (!writer.writeInt("txNum", txNum)) return false; - commState.idx++; + state++; } @@ -166,43 +166,43 @@ public int transactions() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 8: - futId = commState.getGridUuid("futId"); + futId = reader.readIgniteUuid("futId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 9: - miniId = commState.getGridUuid("miniId"); + miniId = reader.readIgniteUuid("miniId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 10: - nearXidVer = commState.getCacheVersion("nearXidVer"); + nearXidVer = reader.readMessage("nearXidVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 11: - txNum = commState.getInt("txNum"); + txNum = reader.readInt("txNum"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxResponse.java index bba1efb84ce48..7c9ae63e3273f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxResponse.java @@ -108,36 +108,36 @@ public boolean success() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 8: - if (!commState.putGridUuid("futId", futId)) + if (!writer.writeIgniteUuid("futId", futId)) return false; - commState.idx++; + state++; case 9: - if (!commState.putGridUuid("miniId", miniId)) + if (!writer.writeIgniteUuid("miniId", miniId)) return false; - commState.idx++; + state++; case 10: - if (!commState.putBoolean("success", success)) + if (!writer.writeBoolean("success", success)) return false; - commState.idx++; + state++; } @@ -147,35 +147,35 @@ public boolean success() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 8: - futId = commState.getGridUuid("futId"); + futId = reader.readIgniteUuid("futId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 9: - miniId = commState.getGridUuid("miniId"); + miniId = reader.readIgniteUuid("miniId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 10: - success = commState.getBoolean("success"); + success = reader.readBoolean("success"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxRequest.java index bd5f826c9b012..0aeabaf2075a2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxRequest.java @@ -154,54 +154,54 @@ public boolean nearOnlyCheck() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 8: - if (!commState.putGridUuid("futId", futId)) + if (!writer.writeIgniteUuid("futId", futId)) return false; - commState.idx++; + state++; case 9: - if (!commState.putGridUuid("miniId", miniId)) + if (!writer.writeIgniteUuid("miniId", miniId)) return false; - commState.idx++; + state++; case 10: - if (!commState.putCacheVersion("nearXidVer", nearXidVer)) + if (!writer.writeBoolean("nearOnlyCheck", nearOnlyCheck)) return false; - commState.idx++; + state++; case 11: - if (!commState.putUuid("originatingNodeId", originatingNodeId)) + if (!writer.writeMessage("nearXidVer", nearXidVer != null ? nearXidVer.clone() : null)) return false; - commState.idx++; + state++; case 12: - if (!commState.putLong("originatingThreadId", originatingThreadId)) + if (!writer.writeUuid("originatingNodeId", originatingNodeId)) return false; - commState.idx++; + state++; case 13: - if (!commState.putBoolean("nearOnlyCheck", nearOnlyCheck)) + if (!writer.writeLong("originatingThreadId", originatingThreadId)) return false; - commState.idx++; + state++; } @@ -211,59 +211,59 @@ public boolean nearOnlyCheck() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 8: - futId = commState.getGridUuid("futId"); + futId = reader.readIgniteUuid("futId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 9: - miniId = commState.getGridUuid("miniId"); + miniId = reader.readIgniteUuid("miniId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 10: - nearXidVer = commState.getCacheVersion("nearXidVer"); + nearOnlyCheck = reader.readBoolean("nearOnlyCheck"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 11: - originatingNodeId = commState.getUuid("originatingNodeId"); + nearXidVer = reader.readMessage("nearXidVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 12: - originatingThreadId = commState.getLong("originatingThreadId"); + originatingNodeId = reader.readUuid("originatingNodeId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 13: - nearOnlyCheck = commState.getBoolean("nearOnlyCheck"); + originatingThreadId = reader.readLong("originatingThreadId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxResponse.java index 68495f3003a51..36983beb66ff6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxResponse.java @@ -140,36 +140,36 @@ public GridCacheCommittedTxInfo committedTxInfo() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 8: - if (!commState.putByteArray("committedTxInfoBytes", committedTxInfoBytes)) + if (!writer.writeByteArray("committedTxInfoBytes", committedTxInfoBytes)) return false; - commState.idx++; + state++; case 9: - if (!commState.putGridUuid("futId", futId)) + if (!writer.writeIgniteUuid("futId", futId)) return false; - commState.idx++; + state++; case 10: - if (!commState.putGridUuid("miniId", miniId)) + if (!writer.writeIgniteUuid("miniId", miniId)) return false; - commState.idx++; + state++; } @@ -179,35 +179,35 @@ public GridCacheCommittedTxInfo committedTxInfo() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 8: - committedTxInfoBytes = commState.getByteArray("committedTxInfoBytes"); + committedTxInfoBytes = reader.readByteArray("committedTxInfoBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 9: - futId = commState.getGridUuid("futId"); + futId = reader.readIgniteUuid("futId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 10: - miniId = commState.getGridUuid("miniId"); + miniId = reader.readIgniteUuid("miniId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java index f8f9870dca9ab..96eb0a467a494 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java @@ -195,138 +195,54 @@ public List nearVersions() { /** {@inheritDoc} */ @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 3: - if (keysBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, keysBytes.size())) - return false; - - commState.it = keysBytes.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putByteArray(null, (byte[])commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("keysBytes", keysBytes, byte[].class)) + return false; - commState.idx++; + state++; case 4: - if (nearKeysBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, nearKeysBytes.size())) - return false; - - commState.it = nearKeysBytes.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putByteArray(null, (byte[])commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("nearKeysBytes", nearKeysBytes, byte[].class)) + return false; - commState.idx++; + state++; case 5: - if (nearVers != null) { - if (commState.it == null) { - if (!commState.putInt(null, nearVers.size())) - return false; - - commState.it = nearVers.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putCacheVersion(null, (GridCacheVersion)commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("nearVers", nearVers, GridCacheVersion.class)) + return false; - commState.idx++; + state++; case 6: - if (!commState.putLong("topVer", topVer)) + if (!writer.writeLong("topVer", topVer)) return false; - commState.idx++; + state++; case 7: - if (!commState.putLong("ttl", ttl)) + if (!writer.writeLong("ttl", ttl)) return false; - commState.idx++; + state++; case 8: - if (vers != null) { - if (commState.it == null) { - if (!commState.putInt(null, vers.size())) - return false; - - commState.it = vers.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putCacheVersion(null, (GridCacheVersion)commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("vers", vers, GridCacheVersion.class)) + return false; - commState.idx++; + state++; } @@ -335,147 +251,59 @@ public List nearVersions() { /** {@inheritDoc} */ @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 3: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (keysBytes == null) - keysBytes = new ArrayList<>(commState.readSize); + keysBytes = reader.readCollection("keysBytes", byte[].class); - for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(null); - - if (!commState.lastRead()) - return false; - - keysBytes.add((byte[])_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 4: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (nearKeysBytes == null) - nearKeysBytes = new ArrayList<>(commState.readSize); + nearKeysBytes = reader.readCollection("nearKeysBytes", byte[].class); - for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(null); - - if (!commState.lastRead()) - return false; - - nearKeysBytes.add((byte[])_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 5: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } + nearVers = reader.readCollection("nearVers", GridCacheVersion.class); - if (commState.readSize >= 0) { - if (nearVers == null) - nearVers = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheVersion _val = commState.getCacheVersion(null); - - if (!commState.lastRead()) - return false; - - nearVers.add((GridCacheVersion)_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 6: - topVer = commState.getLong("topVer"); + topVer = reader.readLong("topVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 7: - ttl = commState.getLong("ttl"); + ttl = reader.readLong("ttl"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 8: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } + vers = reader.readCollection("vers", GridCacheVersion.class); - if (commState.readSize >= 0) { - if (vers == null) - vers = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheVersion _val = commState.getCacheVersion(null); - - if (!commState.lastRead()) - return false; - - vers.add((GridCacheVersion)_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedBaseMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedBaseMessage.java index 55e5250c245a4..0c82e020609d3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedBaseMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedBaseMessage.java @@ -258,90 +258,48 @@ public int keysCount() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 3: - if (!commState.putByteArray("candsByIdxBytes", candsByIdxBytes)) + if (!writer.writeByteArray("candsByIdxBytes", candsByIdxBytes)) return false; - commState.idx++; + state++; case 4: - if (!commState.putByteArray("candsByKeyBytes", candsByKeyBytes)) + if (!writer.writeByteArray("candsByKeyBytes", candsByKeyBytes)) return false; - commState.idx++; + state++; case 5: - if (committedVers != null) { - if (commState.it == null) { - if (!commState.putInt(null, committedVers.size())) - return false; - - commState.it = committedVers.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putCacheVersion(null, (GridCacheVersion)commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("committedVers", committedVers, GridCacheVersion.class)) + return false; - commState.idx++; + state++; case 6: - if (rolledbackVers != null) { - if (commState.it == null) { - if (!commState.putInt(null, rolledbackVers.size())) - return false; - - commState.it = rolledbackVers.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putCacheVersion(null, (GridCacheVersion)commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("rolledbackVers", rolledbackVers, GridCacheVersion.class)) + return false; - commState.idx++; + state++; case 7: - if (!commState.putCacheVersion("ver", ver)) + if (!writer.writeMessage("ver", ver != null ? ver.clone() : null)) return false; - commState.idx++; + state++; } @@ -351,95 +309,51 @@ public int keysCount() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 3: - candsByIdxBytes = commState.getByteArray("candsByIdxBytes"); + candsByIdxBytes = reader.readByteArray("candsByIdxBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 4: - candsByKeyBytes = commState.getByteArray("candsByKeyBytes"); + candsByKeyBytes = reader.readByteArray("candsByKeyBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 5: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } + committedVers = reader.readCollection("committedVers", GridCacheVersion.class); - if (commState.readSize >= 0) { - if (committedVers == null) - committedVers = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheVersion _val = commState.getCacheVersion(null); - - if (!commState.lastRead()) - return false; - - committedVers.add((GridCacheVersion)_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 6: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } + rolledbackVers = reader.readCollection("rolledbackVers", GridCacheVersion.class); - if (commState.readSize >= 0) { - if (rolledbackVers == null) - rolledbackVers = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheVersion _val = commState.getCacheVersion(null); - - if (!commState.lastRead()) - return false; - - rolledbackVers.add((GridCacheVersion)_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 7: - ver = commState.getCacheVersion("ver"); + ver = reader.readMessage("ver"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java index 3c94d51d39eca..a3f54c2352902 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java @@ -467,156 +467,114 @@ public GridCacheVersion[] drVersions() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 8: - if (drVersByIdx != null) { - if (commState.it == null) { - if (!commState.putInt(null, drVersByIdx.length)) - return false; - - commState.it = arrayIterator(drVersByIdx); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putCacheVersion(null, (GridCacheVersion)commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeObjectArray("drVersByIdx", drVersByIdx, GridCacheVersion.class)) + return false; - commState.idx++; + state++; case 9: - if (!commState.putGridUuid("futId", futId)) + if (!writer.writeIgniteUuid("futId", futId)) return false; - commState.idx++; + state++; case 10: - if (!commState.putByteArray("grpLockKeyBytes", grpLockKeyBytes)) + if (!writer.writeByteArray("grpLockKeyBytes", grpLockKeyBytes)) return false; - commState.idx++; + state++; case 11: - if (!commState.putBoolean("isInTx", isInTx)) + if (!writer.writeBoolean("isInTx", isInTx)) return false; - commState.idx++; + state++; case 12: - if (!commState.putBoolean("isInvalidate", isInvalidate)) + if (!writer.writeBoolean("isInvalidate", isInvalidate)) return false; - commState.idx++; + state++; case 13: - if (!commState.putBoolean("isRead", isRead)) + if (!writer.writeBoolean("isRead", isRead)) return false; - commState.idx++; + state++; case 14: - if (!commState.putEnum("isolation", isolation)) + if (!writer.writeEnum("isolation", isolation)) return false; - commState.idx++; + state++; case 15: - if (keyBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, keyBytes.size())) - return false; - - commState.it = keyBytes.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putByteArray(null, (byte[])commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("keyBytes", keyBytes, byte[].class)) + return false; - commState.idx++; + state++; case 16: - if (!commState.putCacheVersion("nearXidVer", nearXidVer)) + if (!writer.writeMessage("nearXidVer", nearXidVer != null ? nearXidVer.clone() : null)) return false; - commState.idx++; + state++; case 17: - if (!commState.putUuid("nodeId", nodeId)) + if (!writer.writeUuid("nodeId", nodeId)) return false; - commState.idx++; + state++; case 18: - if (!commState.putBoolean("partLock", partLock)) + if (!writer.writeBoolean("partLock", partLock)) return false; - commState.idx++; + state++; case 19: - if (!commState.putBooleanArray("retVals", retVals)) + if (!writer.writeBooleanArray("retVals", retVals)) return false; - commState.idx++; + state++; case 20: - if (!commState.putLong("threadId", threadId)) + if (!writer.writeLong("threadId", threadId)) return false; - commState.idx++; + state++; case 21: - if (!commState.putLong("timeout", timeout)) + if (!writer.writeLong("timeout", timeout)) return false; - commState.idx++; + state++; case 22: - if (!commState.putInt("txSize", txSize)) + if (!writer.writeInt("txSize", txSize)) return false; - commState.idx++; + state++; case 23: - if (!commState.putByteArray("writeEntriesBytes", writeEntriesBytes)) + if (!writer.writeByteArray("writeEntriesBytes", writeEntriesBytes)) return false; - commState.idx++; + state++; } @@ -626,185 +584,139 @@ public GridCacheVersion[] drVersions() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 8: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (drVersByIdx == null) - drVersByIdx = new GridCacheVersion[commState.readSize]; + drVersByIdx = reader.readObjectArray("drVersByIdx", GridCacheVersion.class); - for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheVersion _val = commState.getCacheVersion(null); - - if (!commState.lastRead()) - return false; - - drVersByIdx[i] = (GridCacheVersion)_val; - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 9: - futId = commState.getGridUuid("futId"); + futId = reader.readIgniteUuid("futId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 10: - grpLockKeyBytes = commState.getByteArray("grpLockKeyBytes"); + grpLockKeyBytes = reader.readByteArray("grpLockKeyBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 11: - isInTx = commState.getBoolean("isInTx"); + isInTx = reader.readBoolean("isInTx"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 12: - isInvalidate = commState.getBoolean("isInvalidate"); + isInvalidate = reader.readBoolean("isInvalidate"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 13: - isRead = commState.getBoolean("isRead"); + isRead = reader.readBoolean("isRead"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 14: - byte isolation0 = commState.getByte("isolation"); + isolation = reader.readEnum("isolation", IgniteTxIsolation.class); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - isolation = IgniteTxIsolation.fromOrdinal(isolation0); - - commState.idx++; + state++; case 15: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } + keyBytes = reader.readCollection("keyBytes", byte[].class); - if (commState.readSize >= 0) { - if (keyBytes == null) - keyBytes = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(null); - - if (!commState.lastRead()) - return false; - - keyBytes.add((byte[])_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 16: - nearXidVer = commState.getCacheVersion("nearXidVer"); + nearXidVer = reader.readMessage("nearXidVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 17: - nodeId = commState.getUuid("nodeId"); + nodeId = reader.readUuid("nodeId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 18: - partLock = commState.getBoolean("partLock"); + partLock = reader.readBoolean("partLock"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 19: - retVals = commState.getBooleanArray("retVals"); + retVals = reader.readBooleanArray("retVals"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 20: - threadId = commState.getLong("threadId"); + threadId = reader.readLong("threadId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 21: - timeout = commState.getLong("timeout"); + timeout = reader.readLong("timeout"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 22: - txSize = commState.getInt("txSize"); + txSize = reader.readInt("txSize"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 23: - writeEntriesBytes = commState.getByteArray("writeEntriesBytes"); + writeEntriesBytes = reader.readByteArray("writeEntriesBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java index 32c73e6541298..ae7ac0e2ad856 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java @@ -303,57 +303,36 @@ protected int valuesSize() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 8: - if (!commState.putByteArray("errBytes", errBytes)) + if (!writer.writeByteArray("errBytes", errBytes)) return false; - commState.idx++; + state++; case 9: - if (!commState.putGridUuid("futId", futId)) + if (!writer.writeIgniteUuid("futId", futId)) return false; - commState.idx++; + state++; case 10: - if (valBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, valBytes.size())) - return false; - - commState.it = valBytes.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putValueBytes(null, (GridCacheValueBytes)commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("valBytes", valBytes, GridCacheValueBytes.class)) + return false; - commState.idx++; + state++; } @@ -363,57 +342,35 @@ protected int valuesSize() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 8: - errBytes = commState.getByteArray("errBytes"); + errBytes = reader.readByteArray("errBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 9: - futId = commState.getGridUuid("futId"); + futId = reader.readIgniteUuid("futId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 10: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } + valBytes = reader.readCollection("valBytes", GridCacheValueBytes.class); - if (commState.readSize >= 0) { - if (valBytes == null) - valBytes = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheValueBytes _val = commState.getValueBytes(null); - - if (!commState.lastRead()) - return false; - - valBytes.add((GridCacheValueBytes)_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java index 9a93a5ed125ba..ee4893d2013bb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java @@ -381,138 +381,96 @@ public boolean groupLock() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 8: - if (!commState.putCacheVersion("baseVer", baseVer)) + if (!writer.writeMessage("baseVer", baseVer != null ? baseVer.clone() : null)) return false; - commState.idx++; + state++; case 9: - if (!commState.putBoolean("commit", commit)) + if (!writer.writeBoolean("commit", commit)) return false; - commState.idx++; + state++; case 10: - if (!commState.putCacheVersion("commitVer", commitVer)) + if (!writer.writeMessage("commitVer", commitVer != null ? commitVer.clone() : null)) return false; - commState.idx++; + state++; case 11: - if (!commState.putGridUuid("futId", futId)) + if (!writer.writeIgniteUuid("futId", futId)) return false; - commState.idx++; + state++; case 12: - if (!commState.putByteArray("grpLockKeyBytes", grpLockKeyBytes)) + if (!writer.writeByteArray("grpLockKeyBytes", grpLockKeyBytes)) return false; - commState.idx++; + state++; case 13: - if (!commState.putBoolean("invalidate", invalidate)) + if (!writer.writeBoolean("invalidate", invalidate)) return false; - commState.idx++; + state++; case 14: - if (recoveryWritesBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, recoveryWritesBytes.size())) - return false; - - commState.it = recoveryWritesBytes.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putByteArray(null, (byte[])commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("recoveryWritesBytes", recoveryWritesBytes, byte[].class)) + return false; - commState.idx++; + state++; case 15: - if (!commState.putBoolean("syncCommit", syncCommit)) + if (!writer.writeBoolean("syncCommit", syncCommit)) return false; - commState.idx++; + state++; case 16: - if (!commState.putBoolean("syncRollback", syncRollback)) + if (!writer.writeBoolean("syncRollback", syncRollback)) return false; - commState.idx++; + state++; case 17: - if (!commState.putBoolean("sys", sys)) + if (!writer.writeBoolean("sys", sys)) return false; - commState.idx++; + state++; case 18: - if (!commState.putLong("threadId", threadId)) + if (!writer.writeLong("threadId", threadId)) return false; - commState.idx++; + state++; case 19: - if (!commState.putInt("txSize", txSize)) + if (!writer.writeInt("txSize", txSize)) return false; - commState.idx++; + state++; case 20: - if (writeEntriesBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, writeEntriesBytes.size())) - return false; - - commState.it = writeEntriesBytes.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putByteArray(null, (byte[])commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("writeEntriesBytes", writeEntriesBytes, byte[].class)) + return false; - commState.idx++; + state++; } @@ -522,159 +480,115 @@ public boolean groupLock() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 8: - baseVer = commState.getCacheVersion("baseVer"); + baseVer = reader.readMessage("baseVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 9: - commit = commState.getBoolean("commit"); + commit = reader.readBoolean("commit"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 10: - commitVer = commState.getCacheVersion("commitVer"); + commitVer = reader.readMessage("commitVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 11: - futId = commState.getGridUuid("futId"); + futId = reader.readIgniteUuid("futId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 12: - grpLockKeyBytes = commState.getByteArray("grpLockKeyBytes"); + grpLockKeyBytes = reader.readByteArray("grpLockKeyBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 13: - invalidate = commState.getBoolean("invalidate"); + invalidate = reader.readBoolean("invalidate"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 14: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } + recoveryWritesBytes = reader.readCollection("recoveryWritesBytes", byte[].class); - if (commState.readSize >= 0) { - if (recoveryWritesBytes == null) - recoveryWritesBytes = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(null); - - if (!commState.lastRead()) - return false; - - recoveryWritesBytes.add((byte[])_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 15: - syncCommit = commState.getBoolean("syncCommit"); + syncCommit = reader.readBoolean("syncCommit"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 16: - syncRollback = commState.getBoolean("syncRollback"); + syncRollback = reader.readBoolean("syncRollback"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 17: - sys = commState.getBoolean("sys"); + sys = reader.readBoolean("sys"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 18: - threadId = commState.getLong("threadId"); + threadId = reader.readLong("threadId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 19: - txSize = commState.getInt("txSize"); + txSize = reader.readInt("txSize"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 20: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } + writeEntriesBytes = reader.readCollection("writeEntriesBytes", byte[].class); - if (commState.readSize >= 0) { - if (writeEntriesBytes == null) - writeEntriesBytes = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(null); - - if (!commState.lastRead()) - return false; - - writeEntriesBytes.add((byte[])_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishResponse.java index b94daa63b9eb9..ab43a670c7497 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishResponse.java @@ -97,30 +97,30 @@ public IgniteUuid futureId() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 3: - if (!commState.putGridUuid("futId", futId)) + if (!writer.writeIgniteUuid("futId", futId)) return false; - commState.idx++; + state++; case 4: - if (!commState.putCacheVersion("txId", txId)) + if (!writer.writeMessage("txId", txId != null ? txId.clone() : null)) return false; - commState.idx++; + state++; } @@ -130,27 +130,27 @@ public IgniteUuid futureId() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 3: - futId = commState.getGridUuid("futId"); + futId = reader.readIgniteUuid("futId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 4: - txId = commState.getCacheVersion("txId"); + txId = reader.readMessage("txId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java index 2623188c46fc2..426c4fe606034 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java @@ -442,144 +442,102 @@ private void writeCollection(ObjectOutput out, Collection> c /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 8: - if (!commState.putCacheVersion("commitVer", commitVer)) + if (!writer.writeMessage("commitVer", commitVer != null ? commitVer.clone() : null)) return false; - commState.idx++; + state++; case 9: - if (!commState.putEnum("concurrency", concurrency)) + if (!writer.writeEnum("concurrency", concurrency)) return false; - commState.idx++; + state++; case 10: - if (!commState.putByteArray("dhtVersBytes", dhtVersBytes)) + if (!writer.writeByteArray("dhtVersBytes", dhtVersBytes)) return false; - commState.idx++; + state++; case 11: - if (!commState.putByteArray("grpLockKeyBytes", grpLockKeyBytes)) + if (!writer.writeByteArray("grpLockKeyBytes", grpLockKeyBytes)) return false; - commState.idx++; + state++; case 12: - if (!commState.putBoolean("invalidate", invalidate)) + if (!writer.writeBoolean("invalidate", invalidate)) return false; - commState.idx++; + state++; case 13: - if (!commState.putEnum("isolation", isolation)) + if (!writer.writeEnum("isolation", isolation)) return false; - commState.idx++; + state++; case 14: - if (!commState.putBoolean("partLock", partLock)) + if (!writer.writeBoolean("partLock", partLock)) return false; - commState.idx++; + state++; case 15: - if (readsBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, readsBytes.size())) - return false; - - commState.it = readsBytes.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putByteArray(null, (byte[])commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("readsBytes", readsBytes, byte[].class)) + return false; - commState.idx++; + state++; case 16: - if (!commState.putBoolean("sys", sys)) + if (!writer.writeBoolean("sys", sys)) return false; - commState.idx++; + state++; case 17: - if (!commState.putLong("threadId", threadId)) + if (!writer.writeLong("threadId", threadId)) return false; - commState.idx++; + state++; case 18: - if (!commState.putLong("timeout", timeout)) + if (!writer.writeLong("timeout", timeout)) return false; - commState.idx++; + state++; case 19: - if (!commState.putByteArray("txNodesBytes", txNodesBytes)) + if (!writer.writeByteArray("txNodesBytes", txNodesBytes)) return false; - commState.idx++; + state++; case 20: - if (!commState.putInt("txSize", txSize)) + if (!writer.writeInt("txSize", txSize)) return false; - commState.idx++; + state++; case 21: - if (writesBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, writesBytes.size())) - return false; - - commState.it = writesBytes.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putByteArray(null, (byte[])commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("writesBytes", writesBytes, byte[].class)) + return false; - commState.idx++; + state++; } @@ -589,171 +547,123 @@ private void writeCollection(ObjectOutput out, Collection> c /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 8: - commitVer = commState.getCacheVersion("commitVer"); + commitVer = reader.readMessage("commitVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 9: - byte concurrency0 = commState.getByte("concurrency"); + concurrency = reader.readEnum("concurrency", IgniteTxConcurrency.class); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - concurrency = IgniteTxConcurrency.fromOrdinal(concurrency0); - - commState.idx++; + state++; case 10: - dhtVersBytes = commState.getByteArray("dhtVersBytes"); + dhtVersBytes = reader.readByteArray("dhtVersBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 11: - grpLockKeyBytes = commState.getByteArray("grpLockKeyBytes"); + grpLockKeyBytes = reader.readByteArray("grpLockKeyBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 12: - invalidate = commState.getBoolean("invalidate"); + invalidate = reader.readBoolean("invalidate"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 13: - byte isolation0 = commState.getByte("isolation"); + isolation = reader.readEnum("isolation", IgniteTxIsolation.class); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - isolation = IgniteTxIsolation.fromOrdinal(isolation0); - - commState.idx++; + state++; case 14: - partLock = commState.getBoolean("partLock"); + partLock = reader.readBoolean("partLock"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 15: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (readsBytes == null) - readsBytes = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(null); - - if (!commState.lastRead()) - return false; - - readsBytes.add((byte[])_val); + readsBytes = reader.readCollection("readsBytes", byte[].class); - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 16: - sys = commState.getBoolean("sys"); + sys = reader.readBoolean("sys"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 17: - threadId = commState.getLong("threadId"); + threadId = reader.readLong("threadId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 18: - timeout = commState.getLong("timeout"); + timeout = reader.readLong("timeout"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 19: - txNodesBytes = commState.getByteArray("txNodesBytes"); + txNodesBytes = reader.readByteArray("txNodesBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 20: - txSize = commState.getInt("txSize"); + txSize = reader.readInt("txSize"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 21: - if (commState.readSize == -1) { - int _val = commState.getInt(null); + writesBytes = reader.readCollection("writesBytes", byte[].class); - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (writesBytes == null) - writesBytes = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(null); - - if (!commState.lastRead()) - return false; - - writesBytes.add((byte[])_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java index 057916c7fd154..cd475133afc94 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java @@ -174,30 +174,30 @@ public void candidates(Map>> cands) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 8: - if (!commState.putByteArray("candsBytes", candsBytes)) + if (!writer.writeByteArray("candsBytes", candsBytes)) return false; - commState.idx++; + state++; case 9: - if (!commState.putByteArray("errBytes", errBytes)) + if (!writer.writeByteArray("errBytes", errBytes)) return false; - commState.idx++; + state++; } @@ -207,27 +207,27 @@ public void candidates(Map>> cands) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 8: - candsBytes = commState.getByteArray("candsBytes"); + candsBytes = reader.readByteArray("candsBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 9: - errBytes = commState.getByteArray("errBytes"); + errBytes = reader.readByteArray("errBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedUnlockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedUnlockRequest.java index d865208ae3235..9c3f6abd61b4e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedUnlockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedUnlockRequest.java @@ -138,45 +138,24 @@ public void addKey(K key, byte[] bytes, GridCacheContext ctx) throws Ignit /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 8: - if (keyBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, keyBytes.size())) - return false; + if (!writer.writeCollection("keyBytes", keyBytes, byte[].class)) + return false; - commState.it = keyBytes.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putByteArray(null, (byte[])commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } - - commState.idx++; + state++; } @@ -186,41 +165,19 @@ public void addKey(K key, byte[] bytes, GridCacheContext ctx) throws Ignit /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 8: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (keyBytes == null) - keyBytes = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(null); - - if (!commState.lastRead()) - return false; - - keyBytes.add((byte[])_val); - - commState.readItems++; - } - } + keyBytes = reader.readCollection("keyBytes", byte[].class); - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java index 1ba375351b58d..3534fd30b37d2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java @@ -87,24 +87,24 @@ public GridDhtAffinityAssignmentRequest(int cacheId, long topVer) { /** {@inheritDoc} */ @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 3: - if (!commState.putLong("topVer", topVer)) + if (!writer.writeLong("topVer", topVer)) return false; - commState.idx++; + state++; } @@ -113,19 +113,19 @@ public GridDhtAffinityAssignmentRequest(int cacheId, long topVer) { /** {@inheritDoc} */ @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 3: - topVer = commState.getLong("topVer"); + topVer = reader.readLong("topVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java index 14d70e8d17a3b..4a44303cedf00 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java @@ -128,30 +128,30 @@ public List> affinityAssignment() { /** {@inheritDoc} */ @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 3: - if (!commState.putByteArray("affAssignmentBytes", affAssignmentBytes)) + if (!writer.writeByteArray("affAssignmentBytes", affAssignmentBytes)) return false; - commState.idx++; + state++; case 4: - if (!commState.putLong("topVer", topVer)) + if (!writer.writeLong("topVer", topVer)) return false; - commState.idx++; + state++; } @@ -160,27 +160,27 @@ public List> affinityAssignment() { /** {@inheritDoc} */ @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 3: - affAssignmentBytes = commState.getByteArray("affAssignmentBytes"); + affAssignmentBytes = reader.readByteArray("affAssignmentBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 4: - topVer = commState.getLong("topVer"); + topVer = reader.readLong("topVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java index 7a997209b589f..a9a93f764b87c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java @@ -372,93 +372,72 @@ public long accessTtl() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 24: - if (!commState.putLong("accessTtl", accessTtl)) + if (!writer.writeLong("accessTtl", accessTtl)) return false; - commState.idx++; + state++; case 25: - if (!commState.putBitSet("invalidateEntries", invalidateEntries)) + if (!writer.writeBitSet("invalidateEntries", invalidateEntries)) return false; - commState.idx++; + state++; case 26: - if (!commState.putGridUuid("miniId", miniId)) + if (!writer.writeIgniteUuid("miniId", miniId)) return false; - commState.idx++; + state++; case 27: - if (nearKeyBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, nearKeyBytes.size())) - return false; - - commState.it = nearKeyBytes.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putByteArray(null, (byte[])commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("nearKeyBytes", nearKeyBytes, byte[].class)) + return false; - commState.idx++; + state++; case 28: - if (!commState.putByteArray("ownedBytes", ownedBytes)) + if (!writer.writeByteArray("ownedBytes", ownedBytes)) return false; - commState.idx++; + state++; case 29: - if (!commState.putLong("topVer", topVer)) + if (!writer.writeBitSet("preloadKeys", preloadKeys)) return false; - commState.idx++; + state++; case 30: - if (!commState.putUuid("subjId", subjId)) + if (!writer.writeUuid("subjId", subjId)) return false; - commState.idx++; + state++; case 31: - if (!commState.putInt("taskNameHash", taskNameHash)) + if (!writer.writeInt("taskNameHash", taskNameHash)) return false; - commState.idx++; + state++; case 32: - if (!commState.putBitSet("preloadKeys", preloadKeys)) + if (!writer.writeLong("topVer", topVer)) return false; - commState.idx++; + state++; } @@ -468,105 +447,83 @@ public long accessTtl() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 24: - accessTtl = commState.getLong("accessTtl"); + accessTtl = reader.readLong("accessTtl"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 25: - invalidateEntries = commState.getBitSet("invalidateEntries"); + invalidateEntries = reader.readBitSet("invalidateEntries"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 26: - miniId = commState.getGridUuid("miniId"); + miniId = reader.readIgniteUuid("miniId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 27: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } + nearKeyBytes = reader.readCollection("nearKeyBytes", byte[].class); - if (commState.readSize >= 0) { - if (nearKeyBytes == null) - nearKeyBytes = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(null); - - if (!commState.lastRead()) - return false; - - nearKeyBytes.add((byte[])_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 28: - ownedBytes = commState.getByteArray("ownedBytes"); + ownedBytes = reader.readByteArray("ownedBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 29: - topVer = commState.getLong("topVer"); + preloadKeys = reader.readBitSet("preloadKeys"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 30: - subjId = commState.getUuid("subjId"); + subjId = reader.readUuid("subjId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 31: - taskNameHash = commState.getInt("taskNameHash"); + taskNameHash = reader.readInt("taskNameHash"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 32: - preloadKeys = commState.getBitSet("preloadKeys"); + topVer = reader.readLong("topVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java index f301a8fb93f14..2f28b8991d88d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java @@ -225,105 +225,42 @@ public Collection> preloadEntries() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 11: - if (invalidParts != null) { - if (commState.it == null) { - if (!commState.putInt(null, invalidParts.size())) - return false; - - commState.it = invalidParts.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putInt(null, (int)commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("invalidParts", invalidParts, int.class)) + return false; - commState.idx++; + state++; case 12: - if (!commState.putGridUuid("miniId", miniId)) + if (!writer.writeIgniteUuid("miniId", miniId)) return false; - commState.idx++; + state++; case 13: - if (nearEvictedBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, nearEvictedBytes.size())) - return false; - - commState.it = nearEvictedBytes.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putByteArray(null, (byte[])commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("nearEvictedBytes", nearEvictedBytes, byte[].class)) + return false; - commState.idx++; + state++; case 14: - if (preloadEntriesBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, preloadEntriesBytes.size())) - return false; - - commState.it = preloadEntriesBytes.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putByteArray(null, (byte[])commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("preloadEntriesBytes", preloadEntriesBytes, byte[].class)) + return false; - commState.idx++; + state++; } @@ -333,109 +270,43 @@ public Collection> preloadEntries() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 11: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (invalidParts == null) - invalidParts = new HashSet<>(commState.readSize); + invalidParts = reader.readCollection("invalidParts", int.class); - for (int i = commState.readItems; i < commState.readSize; i++) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - - invalidParts.add((Integer)_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 12: - miniId = commState.getGridUuid("miniId"); + miniId = reader.readIgniteUuid("miniId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 13: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (nearEvictedBytes == null) - nearEvictedBytes = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(null); - - if (!commState.lastRead()) - return false; - - nearEvictedBytes.add((byte[])_val); + nearEvictedBytes = reader.readCollection("nearEvictedBytes", byte[].class); - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 14: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (preloadEntriesBytes == null) - preloadEntriesBytes = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(null); + preloadEntriesBytes = reader.readCollection("preloadEntriesBytes", byte[].class); - if (!commState.lastRead()) - return false; - - preloadEntriesBytes.add((byte[])_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java index f814c5d597ac8..adc6df97f7e04 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishRequest.java @@ -382,138 +382,96 @@ public GridLongList nearTtls() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 21: - if (!commState.putEnum("isolation", isolation)) + if (!writer.writeEnum("isolation", isolation)) return false; - commState.idx++; + state++; case 22: - if (!commState.putGridUuid("miniId", miniId)) + if (!writer.writeIgniteUuid("miniId", miniId)) return false; - commState.idx++; + state++; case 23: - if (!commState.putUuid("nearNodeId", nearNodeId)) + if (!writer.writeUuid("nearNodeId", nearNodeId)) return false; - commState.idx++; + state++; case 24: - if (!commState.putLongList("nearTtls", nearTtls)) + if (!writer.writeMessage("nearTtls", nearTtls != null ? nearTtls.clone() : null)) return false; - commState.idx++; + state++; case 25: - if (nearWritesBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, nearWritesBytes.size())) - return false; - - commState.it = nearWritesBytes.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putByteArray(null, (byte[])commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("nearWritesBytes", nearWritesBytes, byte[].class)) + return false; - commState.idx++; + state++; case 26: - if (!commState.putBoolean("onePhaseCommit", onePhaseCommit)) + if (!writer.writeBoolean("onePhaseCommit", onePhaseCommit)) return false; - commState.idx++; + state++; case 27: - if (pendingVers != null) { - if (commState.it == null) { - if (!commState.putInt(null, pendingVers.size())) - return false; - - commState.it = pendingVers.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putCacheVersion(null, (GridCacheVersion)commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("pendingVers", pendingVers, GridCacheVersion.class)) + return false; - commState.idx++; + state++; case 28: - if (!commState.putBoolean("sysInvalidate", sysInvalidate)) + if (!writer.writeUuid("subjId", subjId)) return false; - commState.idx++; + state++; case 29: - if (!commState.putLong("topVer", topVer)) + if (!writer.writeBoolean("sysInvalidate", sysInvalidate)) return false; - commState.idx++; + state++; case 30: - if (!commState.putLongList("ttls", ttls)) + if (!writer.writeInt("taskNameHash", taskNameHash)) return false; - commState.idx++; + state++; case 31: - if (!commState.putCacheVersion("writeVer", writeVer)) + if (!writer.writeLong("topVer", topVer)) return false; - commState.idx++; + state++; case 32: - if (!commState.putUuid("subjId", subjId)) + if (!writer.writeMessage("ttls", ttls != null ? ttls.clone() : null)) return false; - commState.idx++; + state++; case 33: - if (!commState.putInt("taskNameHash", taskNameHash)) + if (!writer.writeMessage("writeVer", writeVer != null ? writeVer.clone() : null)) return false; - commState.idx++; + state++; } @@ -523,161 +481,115 @@ public GridLongList nearTtls() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 21: - byte isolation0 = commState.getByte("isolation"); + isolation = reader.readEnum("isolation", IgniteTxIsolation.class); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - isolation = IgniteTxIsolation.fromOrdinal(isolation0); - - commState.idx++; + state++; case 22: - miniId = commState.getGridUuid("miniId"); + miniId = reader.readIgniteUuid("miniId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 23: - nearNodeId = commState.getUuid("nearNodeId"); + nearNodeId = reader.readUuid("nearNodeId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 24: - nearTtls = commState.getLongList("nearTtls"); + nearTtls = reader.readMessage("nearTtls"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 25: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } + nearWritesBytes = reader.readCollection("nearWritesBytes", byte[].class); - if (commState.readSize >= 0) { - if (nearWritesBytes == null) - nearWritesBytes = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(null); - - if (!commState.lastRead()) - return false; - - nearWritesBytes.add((byte[])_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 26: - onePhaseCommit = commState.getBoolean("onePhaseCommit"); + onePhaseCommit = reader.readBoolean("onePhaseCommit"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 27: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } + pendingVers = reader.readCollection("pendingVers", GridCacheVersion.class); - if (commState.readSize >= 0) { - if (pendingVers == null) - pendingVers = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheVersion _val = commState.getCacheVersion(null); - - if (!commState.lastRead()) - return false; - - pendingVers.add((GridCacheVersion)_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 28: - sysInvalidate = commState.getBoolean("sysInvalidate"); + subjId = reader.readUuid("subjId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 29: - topVer = commState.getLong("topVer"); + sysInvalidate = reader.readBoolean("sysInvalidate"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 30: - ttls = commState.getLongList("ttls"); + taskNameHash = reader.readInt("taskNameHash"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 31: - writeVer = commState.getCacheVersion("writeVer"); + topVer = reader.readLong("topVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 32: - subjId = commState.getUuid("subjId"); + ttls = reader.readMessage("ttls"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 33: - taskNameHash = commState.getInt("taskNameHash"); + writeVer = reader.readMessage("writeVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java index 590f06a7153da..c8b2046a9cd69 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishResponse.java @@ -90,24 +90,24 @@ public IgniteUuid miniId() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 5: - if (!commState.putGridUuid("miniId", miniId)) + if (!writer.writeIgniteUuid("miniId", miniId)) return false; - commState.idx++; + state++; } @@ -117,19 +117,19 @@ public IgniteUuid miniId() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 5: - miniId = commState.getGridUuid("miniId"); + miniId = reader.readIgniteUuid("miniId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java index d7af7808c11a1..a57827c22c083 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java @@ -346,111 +346,90 @@ public Map, GridCacheVersion> owned() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 22: - if (!commState.putGridUuid("futId", futId)) + if (!writer.writeIgniteUuid("futId", futId)) return false; - commState.idx++; + state++; case 23: - if (!commState.putBitSet("invalidateNearEntries", invalidateNearEntries)) + if (!writer.writeBitSet("invalidateNearEntries", invalidateNearEntries)) return false; - commState.idx++; + state++; case 24: - if (!commState.putBoolean("last", last)) + if (!writer.writeBoolean("last", last)) return false; - commState.idx++; + state++; case 25: - if (!commState.putGridUuid("miniId", miniId)) + if (!writer.writeIgniteUuid("miniId", miniId)) return false; - commState.idx++; + state++; case 26: - if (!commState.putUuid("nearNodeId", nearNodeId)) + if (!writer.writeUuid("nearNodeId", nearNodeId)) return false; - commState.idx++; + state++; case 27: - if (nearWritesBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, nearWritesBytes.size())) - return false; - - commState.it = nearWritesBytes.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putByteArray(null, (byte[])commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("nearWritesBytes", nearWritesBytes, byte[].class)) + return false; - commState.idx++; + state++; case 28: - if (!commState.putCacheVersion("nearXidVer", nearXidVer)) + if (!writer.writeMessage("nearXidVer", nearXidVer != null ? nearXidVer.clone() : null)) return false; - commState.idx++; + state++; case 29: - if (!commState.putByteArray("ownedBytes", ownedBytes)) + if (!writer.writeByteArray("ownedBytes", ownedBytes)) return false; - commState.idx++; + state++; case 30: - if (!commState.putLong("topVer", topVer)) + if (!writer.writeBitSet("preloadKeys", preloadKeys)) return false; - commState.idx++; + state++; case 31: - if (!commState.putUuid("subjId", subjId)) + if (!writer.writeUuid("subjId", subjId)) return false; - commState.idx++; + state++; case 32: - if (!commState.putInt("taskNameHash", taskNameHash)) + if (!writer.writeInt("taskNameHash", taskNameHash)) return false; - commState.idx++; + state++; case 33: - if (!commState.putBitSet("preloadKeys", preloadKeys)) + if (!writer.writeLong("topVer", topVer)) return false; - commState.idx++; + state++; } @@ -460,129 +439,107 @@ public Map, GridCacheVersion> owned() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 22: - futId = commState.getGridUuid("futId"); + futId = reader.readIgniteUuid("futId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 23: - invalidateNearEntries = commState.getBitSet("invalidateNearEntries"); + invalidateNearEntries = reader.readBitSet("invalidateNearEntries"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 24: - last = commState.getBoolean("last"); + last = reader.readBoolean("last"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 25: - miniId = commState.getGridUuid("miniId"); + miniId = reader.readIgniteUuid("miniId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 26: - nearNodeId = commState.getUuid("nearNodeId"); + nearNodeId = reader.readUuid("nearNodeId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 27: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } + nearWritesBytes = reader.readCollection("nearWritesBytes", byte[].class); - if (commState.readSize >= 0) { - if (nearWritesBytes == null) - nearWritesBytes = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(null); - - if (!commState.lastRead()) - return false; - - nearWritesBytes.add((byte[])_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 28: - nearXidVer = commState.getCacheVersion("nearXidVer"); + nearXidVer = reader.readMessage("nearXidVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 29: - ownedBytes = commState.getByteArray("ownedBytes"); + ownedBytes = reader.readByteArray("ownedBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 30: - topVer = commState.getLong("topVer"); + preloadKeys = reader.readBitSet("preloadKeys"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 31: - subjId = commState.getUuid("subjId"); + subjId = reader.readUuid("subjId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 32: - taskNameHash = commState.getInt("taskNameHash"); + taskNameHash = reader.readInt("taskNameHash"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 33: - preloadKeys = commState.getBitSet("preloadKeys"); + topVer = reader.readLong("topVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java index fd6c0b44ed40f..319639949e2a3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareResponse.java @@ -232,111 +232,48 @@ public void addPreloadEntry(GridCacheEntryInfo info) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 10: - if (!commState.putGridUuid("futId", futId)) + if (!writer.writeIgniteUuid("futId", futId)) return false; - commState.idx++; + state++; case 11: - if (invalidParts != null) { - if (commState.it == null) { - if (!commState.putInt(null, invalidParts.size())) - return false; - - commState.it = invalidParts.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putInt(null, (int)commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("invalidParts", invalidParts, int.class)) + return false; - commState.idx++; + state++; case 12: - if (!commState.putGridUuid("miniId", miniId)) + if (!writer.writeIgniteUuid("miniId", miniId)) return false; - commState.idx++; + state++; case 13: - if (nearEvictedBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, nearEvictedBytes.size())) - return false; - - commState.it = nearEvictedBytes.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putByteArray(null, (byte[])commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("nearEvictedBytes", nearEvictedBytes, byte[].class)) + return false; - commState.idx++; + state++; case 14: - if (preloadEntriesBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, preloadEntriesBytes.size())) - return false; - - commState.it = preloadEntriesBytes.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putByteArray(null, (byte[])commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("preloadEntriesBytes", preloadEntriesBytes, byte[].class)) + return false; - commState.idx++; + state++; } @@ -346,117 +283,51 @@ public void addPreloadEntry(GridCacheEntryInfo info) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 10: - futId = commState.getGridUuid("futId"); + futId = reader.readIgniteUuid("futId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 11: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (invalidParts == null) - invalidParts = new ArrayList<>(commState.readSize); + invalidParts = reader.readCollection("invalidParts", int.class); - for (int i = commState.readItems; i < commState.readSize; i++) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - - invalidParts.add((Integer)_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 12: - miniId = commState.getGridUuid("miniId"); + miniId = reader.readIgniteUuid("miniId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 13: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (nearEvictedBytes == null) - nearEvictedBytes = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(null); - - if (!commState.lastRead()) - return false; - - nearEvictedBytes.add((byte[])_val); + nearEvictedBytes = reader.readCollection("nearEvictedBytes", byte[].class); - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 14: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (preloadEntriesBytes == null) - preloadEntriesBytes = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(null); + preloadEntriesBytes = reader.readCollection("preloadEntriesBytes", byte[].class); - if (!commState.lastRead()) - return false; - - preloadEntriesBytes.add((byte[])_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java index 19a9dce6b4452..7c381d6b37e83 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java @@ -126,45 +126,24 @@ public void addNearKey(K key, byte[] keyBytes, GridCacheSharedContext ctx) /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 9: - if (nearKeyBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, nearKeyBytes.size())) - return false; + if (!writer.writeCollection("nearKeyBytes", nearKeyBytes, byte[].class)) + return false; - commState.it = nearKeyBytes.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putByteArray(null, (byte[])commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } - - commState.idx++; + state++; } @@ -174,41 +153,19 @@ public void addNearKey(K key, byte[] keyBytes, GridCacheSharedContext ctx) /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 9: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (nearKeyBytes == null) - nearKeyBytes = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(null); - - if (!commState.lastRead()) - return false; - - nearKeyBytes.add((byte[])_val); - - commState.readItems++; - } - } + nearKeyBytes = reader.readCollection("nearKeyBytes", byte[].class); - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicDeferredUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicDeferredUpdateResponse.java index 07ba0bbcd3d6e..955bb4f55ba45 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicDeferredUpdateResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicDeferredUpdateResponse.java @@ -94,45 +94,24 @@ public Collection futureVersions() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 3: - if (futVers != null) { - if (commState.it == null) { - if (!commState.putInt(null, futVers.size())) - return false; + if (!writer.writeCollection("futVers", futVers, GridCacheVersion.class)) + return false; - commState.it = futVers.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putCacheVersion(null, (GridCacheVersion)commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } - - commState.idx++; + state++; } @@ -142,41 +121,19 @@ public Collection futureVersions() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 3: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (futVers == null) - futVers = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheVersion _val = commState.getCacheVersion(null); - - if (!commState.lastRead()) - return false; - - futVers.add((GridCacheVersion)_val); - - commState.readItems++; - } - } + futVers = reader.readCollection("futVers", GridCacheVersion.class); - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java index c69fc6e6036ca..6b59e829d7a4e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java @@ -728,306 +728,138 @@ public long nearExpireTime(int idx) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 3: - if (!commState.putLongList("drExpireTimes", drExpireTimes)) + if (!writer.writeMessage("drExpireTimes", drExpireTimes != null ? drExpireTimes.clone() : null)) return false; - commState.idx++; + state++; case 4: - if (drVers != null) { - if (commState.it == null) { - if (!commState.putInt(null, drVers.size())) - return false; - - commState.it = drVers.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putCacheVersion(null, (GridCacheVersion)commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("drVers", drVers, GridCacheVersion.class)) + return false; - commState.idx++; + state++; case 5: - if (!commState.putCacheVersion("futVer", futVer)) + if (!writer.writeCollection("entryProcessorsBytes", entryProcessorsBytes, byte[].class)) return false; - commState.idx++; + state++; case 6: - if (invokeArgsBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, invokeArgsBytes.length)) - return false; - - commState.it = arrayIterator(invokeArgsBytes); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putByteArray(null, (byte[])commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeBoolean("forceTransformBackups", forceTransformBackups)) + return false; - commState.idx++; + state++; case 7: - if (keyBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, keyBytes.size())) - return false; - - commState.it = keyBytes.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putByteArray(null, (byte[])commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeMessage("futVer", futVer != null ? futVer.clone() : null)) + return false; - commState.idx++; + state++; case 8: - if (!commState.putLongList("nearExpireTimes", nearExpireTimes)) + if (!writer.writeObjectArray("invokeArgsBytes", invokeArgsBytes, byte[].class)) return false; - commState.idx++; + state++; case 9: - if (!commState.putLongList("nearTtls", nearTtls)) + if (!writer.writeCollection("keyBytes", keyBytes, byte[].class)) return false; - commState.idx++; + state++; case 10: - if (!commState.putUuid("nodeId", nodeId)) + if (!writer.writeCollection("nearEntryProcessorsBytes", nearEntryProcessorsBytes, byte[].class)) return false; - commState.idx++; + state++; case 11: - if (!commState.putEnum("syncMode", syncMode)) + if (!writer.writeMessage("nearExpireTimes", nearExpireTimes != null ? nearExpireTimes.clone() : null)) return false; - commState.idx++; + state++; case 12: - if (!commState.putLong("topVer", topVer)) + if (!writer.writeCollection("nearKeyBytes", nearKeyBytes, byte[].class)) return false; - commState.idx++; + state++; case 13: - if (!commState.putLongList("ttls", ttls)) + if (!writer.writeMessage("nearTtls", nearTtls != null ? nearTtls.clone() : null)) return false; - commState.idx++; + state++; case 14: - if (valBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, valBytes.size())) - return false; - - commState.it = valBytes.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putValueBytes(null, (GridCacheValueBytes)commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("nearValBytes", nearValBytes, GridCacheValueBytes.class)) + return false; - commState.idx++; + state++; case 15: - if (!commState.putCacheVersion("writeVer", writeVer)) + if (!writer.writeUuid("nodeId", nodeId)) return false; - commState.idx++; + state++; case 16: - if (nearKeyBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, nearKeyBytes.size())) - return false; - - commState.it = nearKeyBytes.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putByteArray(null, (byte[])commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeUuid("subjId", subjId)) + return false; - commState.idx++; + state++; case 17: - if (nearValBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, nearValBytes.size())) - return false; - - commState.it = nearValBytes.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putValueBytes(null, (GridCacheValueBytes)commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeEnum("syncMode", syncMode)) + return false; - commState.idx++; + state++; case 18: - if (entryProcessorsBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, entryProcessorsBytes.size())) - return false; - - commState.it = entryProcessorsBytes.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putByteArray(null, (byte[])commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeInt("taskNameHash", taskNameHash)) + return false; - commState.idx++; + state++; case 19: - if (!commState.putBoolean("forceTransformBackups", forceTransformBackups)) + if (!writer.writeLong("topVer", topVer)) return false; - commState.idx++; + state++; case 20: - if (nearEntryProcessorsBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, nearEntryProcessorsBytes.size())) - return false; - - commState.it = nearEntryProcessorsBytes.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putByteArray(null, (byte[])commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeMessage("ttls", ttls != null ? ttls.clone() : null)) + return false; - commState.idx++; + state++; case 21: - if (!commState.putUuid("subjId", subjId)) + if (!writer.writeCollection("valBytes", valBytes, GridCacheValueBytes.class)) return false; - commState.idx++; + state++; case 22: - if (!commState.putInt("taskNameHash", taskNameHash)) + if (!writer.writeMessage("writeVer", writeVer != null ? writeVer.clone() : null)) return false; - commState.idx++; + state++; } @@ -1037,349 +869,171 @@ public long nearExpireTime(int idx) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 3: - drExpireTimes = commState.getLongList("drExpireTimes"); + drExpireTimes = reader.readMessage("drExpireTimes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 4: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (drVers == null) - drVers = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheVersion _val = commState.getCacheVersion(null); - - if (!commState.lastRead()) - return false; - - drVers.add((GridCacheVersion)_val); + drVers = reader.readCollection("drVers", GridCacheVersion.class); - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 5: - futVer = commState.getCacheVersion("futVer"); + entryProcessorsBytes = reader.readCollection("entryProcessorsBytes", byte[].class); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 6: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (invokeArgsBytes == null) - invokeArgsBytes = new byte[commState.readSize][]; - - for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(null); - - if (!commState.lastRead()) - return false; - - invokeArgsBytes[i] = (byte[])_val; + forceTransformBackups = reader.readBoolean("forceTransformBackups"); - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 7: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (keyBytes == null) - keyBytes = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(null); - - if (!commState.lastRead()) - return false; + futVer = reader.readMessage("futVer"); - keyBytes.add((byte[])_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 8: - nearExpireTimes = commState.getLongList("nearExpireTimes"); + invokeArgsBytes = reader.readObjectArray("invokeArgsBytes", byte[].class); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 9: - nearTtls = commState.getLongList("nearTtls"); + keyBytes = reader.readCollection("keyBytes", byte[].class); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 10: - nodeId = commState.getUuid("nodeId"); + nearEntryProcessorsBytes = reader.readCollection("nearEntryProcessorsBytes", byte[].class); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 11: - byte syncMode0 = commState.getByte("syncMode"); + nearExpireTimes = reader.readMessage("nearExpireTimes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - syncMode = CacheWriteSynchronizationMode.fromOrdinal(syncMode0); - - commState.idx++; + state++; case 12: - topVer = commState.getLong("topVer"); + nearKeyBytes = reader.readCollection("nearKeyBytes", byte[].class); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 13: - ttls = commState.getLongList("ttls"); + nearTtls = reader.readMessage("nearTtls"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 14: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (valBytes == null) - valBytes = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheValueBytes _val = commState.getValueBytes(null); + nearValBytes = reader.readCollection("nearValBytes", GridCacheValueBytes.class); - if (!commState.lastRead()) - return false; - - valBytes.add((GridCacheValueBytes)_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 15: - writeVer = commState.getCacheVersion("writeVer"); + nodeId = reader.readUuid("nodeId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 16: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (nearKeyBytes == null) - nearKeyBytes = new ArrayList<>(commState.readSize); + subjId = reader.readUuid("subjId"); - for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(null); - - if (!commState.lastRead()) - return false; - - nearKeyBytes.add((byte[])_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 17: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (nearValBytes == null) - nearValBytes = new ArrayList<>(commState.readSize); + syncMode = reader.readEnum("syncMode", CacheWriteSynchronizationMode.class); - for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheValueBytes _val = commState.getValueBytes(null); - - if (!commState.lastRead()) - return false; - - nearValBytes.add((GridCacheValueBytes)_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 18: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } + taskNameHash = reader.readInt("taskNameHash"); - if (commState.readSize >= 0) { - if (entryProcessorsBytes == null) - entryProcessorsBytes = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(null); - - if (!commState.lastRead()) - return false; - - entryProcessorsBytes.add((byte[])_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 19: - forceTransformBackups = commState.getBoolean("forceTransformBackups"); + topVer = reader.readLong("topVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 20: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } + ttls = reader.readMessage("ttls"); - if (commState.readSize >= 0) { - if (nearEntryProcessorsBytes == null) - nearEntryProcessorsBytes = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(null); - - if (!commState.lastRead()) - return false; - - nearEntryProcessorsBytes.add((byte[])_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 21: - subjId = commState.getUuid("subjId"); + valBytes = reader.readCollection("valBytes", GridCacheValueBytes.class); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 22: - taskNameHash = commState.getInt("taskNameHash"); + writeVer = reader.readMessage("writeVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java index afd013c8fea8f..256c4b6cc2c79 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateResponse.java @@ -205,63 +205,42 @@ public void addNearEvicted(K key, @Nullable byte[] bytes) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 3: - if (!commState.putByteArray("errBytes", errBytes)) + if (!writer.writeByteArray("errBytes", errBytes)) return false; - commState.idx++; + state++; case 4: - if (!commState.putByteArray("failedKeysBytes", failedKeysBytes)) + if (!writer.writeByteArray("failedKeysBytes", failedKeysBytes)) return false; - commState.idx++; + state++; case 5: - if (!commState.putCacheVersion("futVer", futVer)) + if (!writer.writeMessage("futVer", futVer != null ? futVer.clone() : null)) return false; - commState.idx++; + state++; case 6: - if (nearEvictedBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, nearEvictedBytes.size())) - return false; - - commState.it = nearEvictedBytes.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putByteArray(null, (byte[])commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("nearEvictedBytes", nearEvictedBytes, byte[].class)) + return false; - commState.idx++; + state++; } @@ -271,65 +250,43 @@ public void addNearEvicted(K key, @Nullable byte[] bytes) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 3: - errBytes = commState.getByteArray("errBytes"); + errBytes = reader.readByteArray("errBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 4: - failedKeysBytes = commState.getByteArray("failedKeysBytes"); + failedKeysBytes = reader.readByteArray("failedKeysBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 5: - futVer = commState.getCacheVersion("futVer"); + futVer = reader.readMessage("futVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 6: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } + nearEvictedBytes = reader.readCollection("nearEvictedBytes", byte[].class); - if (commState.readSize >= 0) { - if (nearEvictedBytes == null) - nearEvictedBytes = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(null); - - if (!commState.lastRead()) - return false; - - nearEvictedBytes.add((byte[])_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java index f700649dd4924..cf234512be39f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java @@ -587,237 +587,132 @@ public void forceTransformBackups(boolean forceTransformBackups) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 3: - if (!commState.putLongList("drExpireTimes", drExpireTimes)) + if (!writer.writeMessage("drExpireTimes", drExpireTimes != null ? drExpireTimes.clone() : null)) return false; - commState.idx++; + state++; case 4: - if (!commState.putLongList("drTtls", drTtls)) + if (!writer.writeMessage("drTtls", drTtls != null ? drTtls.clone() : null)) return false; - commState.idx++; + state++; case 5: - if (drVers != null) { - if (commState.it == null) { - if (!commState.putInt(null, drVers.size())) - return false; - - commState.it = drVers.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putCacheVersion(null, (GridCacheVersion)commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("drVers", drVers, GridCacheVersion.class)) + return false; - commState.idx++; + state++; case 6: - if (!commState.putByteArray("expiryPlcBytes", expiryPlcBytes)) + if (!writer.writeByteArray("expiryPlcBytes", expiryPlcBytes)) return false; - commState.idx++; + state++; case 7: - if (!commState.putBoolean("fastMap", fastMap)) + if (!writer.writeBoolean("fastMap", fastMap)) return false; - commState.idx++; + state++; case 8: - if (filterBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, filterBytes.length)) - return false; - - commState.it = arrayIterator(filterBytes); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putByteArray(null, (byte[])commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeObjectArray("filterBytes", filterBytes, byte[].class)) + return false; - commState.idx++; + state++; case 9: - if (!commState.putCacheVersion("futVer", futVer)) + if (!writer.writeBoolean("forceTransformBackups", forceTransformBackups)) return false; - commState.idx++; + state++; case 10: - if (!commState.putBoolean("hasPrimary", hasPrimary)) + if (!writer.writeMessage("futVer", futVer != null ? futVer.clone() : null)) return false; - commState.idx++; + state++; case 11: - if (invokeArgsBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, invokeArgsBytes.length)) - return false; - - commState.it = arrayIterator(invokeArgsBytes); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putByteArray(null, (byte[])commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeBoolean("hasPrimary", hasPrimary)) + return false; - commState.idx++; + state++; case 12: - if (keyBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, keyBytes.size())) - return false; - - commState.it = keyBytes.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putByteArray(null, (byte[])commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeObjectArray("invokeArgsBytes", invokeArgsBytes, byte[].class)) + return false; - commState.idx++; + state++; case 13: - if (!commState.putEnum("op", op)) + if (!writer.writeCollection("keyBytes", keyBytes, byte[].class)) return false; - commState.idx++; + state++; case 14: - if (!commState.putBoolean("retval", retval)) + if (!writer.writeEnum("op", op)) return false; - commState.idx++; + state++; case 15: - if (!commState.putEnum("syncMode", syncMode)) + if (!writer.writeBoolean("retval", retval)) return false; - commState.idx++; + state++; case 16: - if (!commState.putLong("topVer", topVer)) + if (!writer.writeUuid("subjId", subjId)) return false; - commState.idx++; + state++; case 17: - if (!commState.putCacheVersion("updateVer", updateVer)) + if (!writer.writeEnum("syncMode", syncMode)) return false; - commState.idx++; + state++; case 18: - if (valBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, valBytes.size())) - return false; - - commState.it = valBytes.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putValueBytes(null, (GridCacheValueBytes)commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeInt("taskNameHash", taskNameHash)) + return false; - commState.idx++; + state++; case 19: - if (!commState.putBoolean("forceTransformBackups", forceTransformBackups)) + if (!writer.writeLong("topVer", topVer)) return false; - commState.idx++; + state++; case 20: - if (!commState.putUuid("subjId", subjId)) + if (!writer.writeMessage("updateVer", updateVer != null ? updateVer.clone() : null)) return false; - commState.idx++; + state++; case 21: - if (!commState.putInt("taskNameHash", taskNameHash)) + if (!writer.writeCollection("valBytes", valBytes, GridCacheValueBytes.class)) return false; - commState.idx++; + state++; } @@ -827,277 +722,163 @@ public void forceTransformBackups(boolean forceTransformBackups) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 3: - drExpireTimes = commState.getLongList("drExpireTimes"); + drExpireTimes = reader.readMessage("drExpireTimes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 4: - drTtls = commState.getLongList("drTtls"); + drTtls = reader.readMessage("drTtls"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 5: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (drVers == null) - drVers = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheVersion _val = commState.getCacheVersion(null); - - if (!commState.lastRead()) - return false; + drVers = reader.readCollection("drVers", GridCacheVersion.class); - drVers.add((GridCacheVersion)_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 6: - expiryPlcBytes = commState.getByteArray("expiryPlcBytes"); + expiryPlcBytes = reader.readByteArray("expiryPlcBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 7: - fastMap = commState.getBoolean("fastMap"); + fastMap = reader.readBoolean("fastMap"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 8: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (filterBytes == null) - filterBytes = new byte[commState.readSize][]; - - for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(null); - - if (!commState.lastRead()) - return false; - - filterBytes[i] = (byte[])_val; - - commState.readItems++; - } - } + filterBytes = reader.readObjectArray("filterBytes", byte[].class); - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 9: - futVer = commState.getCacheVersion("futVer"); + forceTransformBackups = reader.readBoolean("forceTransformBackups"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 10: - hasPrimary = commState.getBoolean("hasPrimary"); + futVer = reader.readMessage("futVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 11: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (invokeArgsBytes == null) - invokeArgsBytes = new byte[commState.readSize][]; - - for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(null); + hasPrimary = reader.readBoolean("hasPrimary"); - if (!commState.lastRead()) - return false; - - invokeArgsBytes[i] = (byte[])_val; - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 12: - if (commState.readSize == -1) { - int _val = commState.getInt(null); + invokeArgsBytes = reader.readObjectArray("invokeArgsBytes", byte[].class); - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (keyBytes == null) - keyBytes = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(null); - - if (!commState.lastRead()) - return false; - - keyBytes.add((byte[])_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 13: - byte op0 = commState.getByte("op"); + keyBytes = reader.readCollection("keyBytes", byte[].class); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - op = GridCacheOperation.fromOrdinal(op0); - - commState.idx++; + state++; case 14: - retval = commState.getBoolean("retval"); + op = reader.readEnum("op", GridCacheOperation.class); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 15: - byte syncMode0 = commState.getByte("syncMode"); + retval = reader.readBoolean("retval"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - syncMode = CacheWriteSynchronizationMode.fromOrdinal(syncMode0); - - commState.idx++; + state++; case 16: - topVer = commState.getLong("topVer"); + subjId = reader.readUuid("subjId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 17: - updateVer = commState.getCacheVersion("updateVer"); + syncMode = reader.readEnum("syncMode", CacheWriteSynchronizationMode.class); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 18: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (valBytes == null) - valBytes = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheValueBytes _val = commState.getValueBytes(null); + taskNameHash = reader.readInt("taskNameHash"); - if (!commState.lastRead()) - return false; - - valBytes.add((GridCacheValueBytes)_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 19: - forceTransformBackups = commState.getBoolean("forceTransformBackups"); + topVer = reader.readLong("topVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 20: - subjId = commState.getUuid("subjId"); + updateVer = reader.readMessage("updateVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 21: - taskNameHash = commState.getInt("taskNameHash"); + valBytes = reader.readCollection("valBytes", GridCacheValueBytes.class); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java index d91e8001818df..23bca9b61b545 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java @@ -455,147 +455,84 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { /** {@inheritDoc} */ @SuppressWarnings("fallthrough") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 3: - if (!commState.putByteArray("errBytes", errBytes)) + if (!writer.writeByteArray("errBytes", errBytes)) return false; - commState.idx++; + state++; case 4: - if (!commState.putByteArray("failedKeysBytes", failedKeysBytes)) + if (!writer.writeByteArray("failedKeysBytes", failedKeysBytes)) return false; - commState.idx++; + state++; case 5: - if (!commState.putCacheVersion("futVer", futVer)) + if (!writer.writeMessage("futVer", futVer != null ? futVer.clone() : null)) return false; - commState.idx++; + state++; case 6: - if (!commState.putLongList("nearExpireTimes", nearExpireTimes)) + if (!writer.writeMessage("nearExpireTimes", nearExpireTimes != null ? nearExpireTimes.clone() : null)) return false; - commState.idx++; + state++; case 7: - if (!commState.putLongList("nearTtls", nearTtls)) + if (!writer.writeCollection("nearSkipIdxs", nearSkipIdxs, int.class)) return false; - commState.idx++; + state++; case 8: - if (!commState.putByteArray("remapKeysBytes", remapKeysBytes)) + if (!writer.writeMessage("nearTtls", nearTtls != null ? nearTtls.clone() : null)) return false; - commState.idx++; + state++; case 9: - if (!commState.putByteArray("retValBytes", retValBytes)) + if (!writer.writeCollection("nearValBytes", nearValBytes, GridCacheValueBytes.class)) return false; - commState.idx++; + state++; case 10: - if (nearSkipIdxs != null) { - if (commState.it == null) { - if (!commState.putInt(null, nearSkipIdxs.size())) - return false; - - commState.it = nearSkipIdxs.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putInt(null, (int)commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("nearValsIdxs", nearValsIdxs, int.class)) + return false; - commState.idx++; + state++; case 11: - if (nearValBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, nearValBytes.size())) - return false; - - commState.it = nearValBytes.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putValueBytes(null, (GridCacheValueBytes)commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeMessage("nearVer", nearVer != null ? nearVer.clone() : null)) + return false; - commState.idx++; + state++; case 12: - if (nearValsIdxs != null) { - if (commState.it == null) { - if (!commState.putInt(null, nearValsIdxs.size())) - return false; - - commState.it = nearValsIdxs.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putInt(null, (int)commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeByteArray("remapKeysBytes", remapKeysBytes)) + return false; - commState.idx++; + state++; case 13: - if (!commState.putCacheVersion("nearVer", nearVer)) + if (!writer.writeByteArray("retValBytes", retValBytes)) return false; - commState.idx++; + state++; } @@ -605,165 +542,99 @@ public synchronized void addFailedKeys(Collection keys, Throwable e) { /** {@inheritDoc} */ @SuppressWarnings("fallthrough") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 3: - errBytes = commState.getByteArray("errBytes"); + errBytes = reader.readByteArray("errBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 4: - failedKeysBytes = commState.getByteArray("failedKeysBytes"); + failedKeysBytes = reader.readByteArray("failedKeysBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 5: - futVer = commState.getCacheVersion("futVer"); + futVer = reader.readMessage("futVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 6: - nearExpireTimes = commState.getLongList("nearExpireTimes"); + nearExpireTimes = reader.readMessage("nearExpireTimes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 7: - nearTtls = commState.getLongList("nearTtls"); + nearSkipIdxs = reader.readCollection("nearSkipIdxs", int.class); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 8: - remapKeysBytes = commState.getByteArray("remapKeysBytes"); + nearTtls = reader.readMessage("nearTtls"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 9: - retValBytes = commState.getByteArray("retValBytes"); + nearValBytes = reader.readCollection("nearValBytes", GridCacheValueBytes.class); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 10: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (nearSkipIdxs == null) - nearSkipIdxs = new ArrayList<>(commState.readSize); + nearValsIdxs = reader.readCollection("nearValsIdxs", int.class); - for (int i = commState.readItems; i < commState.readSize; i++) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - - nearSkipIdxs.add((Integer)_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 11: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (nearValBytes == null) - nearValBytes = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheValueBytes _val = commState.getValueBytes(null); - - if (!commState.lastRead()) - return false; - - nearValBytes.add((GridCacheValueBytes)_val); + nearVer = reader.readMessage("nearVer"); - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 12: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (nearValsIdxs == null) - nearValsIdxs = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - int _val = commState.getInt(null); + remapKeysBytes = reader.readByteArray("remapKeysBytes"); - if (!commState.lastRead()) - return false; - - nearValsIdxs.add((Integer)_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 13: - nearVer = commState.getCacheVersion("nearVer"); + retValBytes = reader.readByteArray("retValBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java index 66a6ad156fb6c..60c4a9a2a8622 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysRequest.java @@ -187,63 +187,42 @@ private int keyCount() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 3: - if (!commState.putGridUuid("futId", futId)) + if (!writer.writeIgniteUuid("futId", futId)) return false; - commState.idx++; + state++; case 4: - if (keyBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, keyBytes.size())) - return false; - - commState.it = keyBytes.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putByteArray(null, (byte[])commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("keyBytes", keyBytes, byte[].class)) + return false; - commState.idx++; + state++; case 5: - if (!commState.putGridUuid("miniId", miniId)) + if (!writer.writeIgniteUuid("miniId", miniId)) return false; - commState.idx++; + state++; case 6: - if (!commState.putLong("topVer", topVer)) + if (!writer.writeLong("topVer", topVer)) return false; - commState.idx++; + state++; } @@ -253,65 +232,43 @@ private int keyCount() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 3: - futId = commState.getGridUuid("futId"); + futId = reader.readIgniteUuid("futId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 4: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } + keyBytes = reader.readCollection("keyBytes", byte[].class); - if (commState.readSize >= 0) { - if (keyBytes == null) - keyBytes = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(null); - - if (!commState.lastRead()) - return false; - - keyBytes.add((byte[])_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 5: - miniId = commState.getGridUuid("miniId"); + miniId = reader.readIgniteUuid("miniId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 6: - topVer = commState.getLong("topVer"); + topVer = reader.readLong("topVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java index 626cb1fe93c9e..ff8cdca66ba00 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysResponse.java @@ -191,63 +191,42 @@ public void addInfo(GridCacheEntryInfo info) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 3: - if (!commState.putGridUuid("futId", futId)) + if (!writer.writeIgniteUuid("futId", futId)) return false; - commState.idx++; + state++; case 4: - if (!commState.putByteArray("infosBytes", infosBytes)) + if (!writer.writeByteArray("infosBytes", infosBytes)) return false; - commState.idx++; + state++; case 5: - if (!commState.putGridUuid("miniId", miniId)) + if (!writer.writeIgniteUuid("miniId", miniId)) return false; - commState.idx++; + state++; case 6: - if (missedKeyBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, missedKeyBytes.size())) - return false; - - commState.it = missedKeyBytes.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putByteArray(null, (byte[])commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("missedKeyBytes", missedKeyBytes, byte[].class)) + return false; - commState.idx++; + state++; } @@ -257,65 +236,43 @@ public void addInfo(GridCacheEntryInfo info) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 3: - futId = commState.getGridUuid("futId"); + futId = reader.readIgniteUuid("futId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 4: - infosBytes = commState.getByteArray("infosBytes"); + infosBytes = reader.readByteArray("infosBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 5: - miniId = commState.getGridUuid("miniId"); + miniId = reader.readIgniteUuid("miniId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 6: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } + missedKeyBytes = reader.readCollection("missedKeyBytes", byte[].class); - if (commState.readSize >= 0) { - if (missedKeyBytes == null) - missedKeyBytes = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(null); - - if (!commState.lastRead()) - return false; - - missedKeyBytes.add((byte[])_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java index 59eb2bdfe8b67..409522c808034 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java @@ -217,75 +217,54 @@ void workerId(int workerId) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 3: - if (parts != null) { - if (commState.it == null) { - if (!commState.putInt(null, parts.size())) - return false; - - commState.it = parts.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putInt(null, (int)commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("parts", parts, int.class)) + return false; - commState.idx++; + state++; case 4: - if (!commState.putLong("timeout", timeout)) + if (!writer.writeLong("timeout", timeout)) return false; - commState.idx++; + state++; case 5: - if (!commState.putLong("topVer", topVer)) + if (!writer.writeLong("topVer", topVer)) return false; - commState.idx++; + state++; case 6: - if (!commState.putByteArray("topicBytes", topicBytes)) + if (!writer.writeByteArray("topicBytes", topicBytes)) return false; - commState.idx++; + state++; case 7: - if (!commState.putLong("updateSeq", updateSeq)) + if (!writer.writeLong("updateSeq", updateSeq)) return false; - commState.idx++; + state++; case 8: - if (!commState.putInt("workerId", workerId)) + if (!writer.writeInt("workerId", workerId)) return false; - commState.idx++; + state++; } @@ -295,81 +274,59 @@ void workerId(int workerId) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 3: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } + parts = reader.readCollection("parts", int.class); - if (commState.readSize >= 0) { - if (parts == null) - parts = new HashSet<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - - parts.add((Integer)_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 4: - timeout = commState.getLong("timeout"); + timeout = reader.readLong("timeout"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 5: - topVer = commState.getLong("topVer"); + topVer = reader.readLong("topVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 6: - topicBytes = commState.getByteArray("topicBytes"); + topicBytes = reader.readByteArray("topicBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 7: - updateSeq = commState.getLong("updateSeq"); + updateSeq = reader.readLong("updateSeq"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 8: - workerId = commState.getInt("workerId"); + workerId = reader.readInt("workerId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionExchangeId.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionExchangeId.java index dc9d26c1bce01..622f639afbbe3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionExchangeId.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionExchangeId.java @@ -147,12 +147,71 @@ public boolean isLeft() { /** {@inheritDoc} */ @Override public boolean writeTo(ByteBuffer buf) { - return false; // TODO: implement. + writer.setBuffer(buf); + + if (!typeWritten) { + if (!writer.writeByte(null, directType())) + return false; + + typeWritten = true; + } + + switch (state) { + case 0: + if (!writer.writeInt("evt", evt)) + return false; + + state++; + + case 1: + if (!writer.writeUuid("nodeId", nodeId)) + return false; + + state++; + + case 2: + if (!writer.writeLong("topVer", topVer)) + return false; + + state++; + + } + + return true; } /** {@inheritDoc} */ @Override public boolean readFrom(ByteBuffer buf) { - return false; // TODO: implement. + reader.setBuffer(buf); + + switch (state) { + case 0: + evt = reader.readInt("evt"); + + if (!reader.isLastRead()) + return false; + + state++; + + case 1: + nodeId = reader.readUuid("nodeId"); + + if (!reader.isLastRead()) + return false; + + state++; + + case 2: + topVer = reader.readLong("topVer"); + + if (!reader.isLastRead()) + return false; + + state++; + + } + + return true; } /** {@inheritDoc} */ @@ -162,12 +221,20 @@ public boolean isLeft() { /** {@inheritDoc} */ @Override public MessageAdapter clone() { - return null; // TODO: implement. + GridDhtPartitionExchangeId _clone = new GridDhtPartitionExchangeId(); + + clone0(_clone); + + return _clone; } /** {@inheritDoc} */ @Override protected void clone0(MessageAdapter _msg) { - // TODO: implement. + GridDhtPartitionExchangeId _clone = (GridDhtPartitionExchangeId)_msg; + + _clone.nodeId = nodeId; + _clone.evt = evt; + _clone.topVer = topVer; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java index 8b953a986e1b5..4835e771e40a6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java @@ -302,96 +302,54 @@ public int size() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 3: - if (!commState.putBoolean("ack", ack)) + if (!writer.writeBoolean("ack", ack)) return false; - commState.idx++; + state++; case 4: - if (!commState.putByteArray("infoBytes", infoBytes)) + if (!writer.writeByteArray("infoBytes", infoBytes)) return false; - commState.idx++; + state++; case 5: - if (last != null) { - if (commState.it == null) { - if (!commState.putInt(null, last.size())) - return false; - - commState.it = last.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putInt(null, (int)commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("last", last, int.class)) + return false; - commState.idx++; + state++; case 6: - if (missed != null) { - if (commState.it == null) { - if (!commState.putInt(null, missed.size())) - return false; - - commState.it = missed.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putInt(null, (int)commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("missed", missed, int.class)) + return false; - commState.idx++; + state++; case 7: - if (!commState.putLong("updateSeq", updateSeq)) + if (!writer.writeLong("updateSeq", updateSeq)) return false; - commState.idx++; + state++; case 8: - if (!commState.putInt("workerId", workerId)) + if (!writer.writeInt("workerId", workerId)) return false; - commState.idx++; + state++; } @@ -401,103 +359,59 @@ public int size() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 3: - ack = commState.getBoolean("ack"); + ack = reader.readBoolean("ack"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 4: - infoBytes = commState.getByteArray("infoBytes"); + infoBytes = reader.readByteArray("infoBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 5: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } + last = reader.readCollection("last", int.class); - if (commState.readSize >= 0) { - if (last == null) - last = new HashSet<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - - last.add((Integer)_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 6: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } + missed = reader.readCollection("missed", int.class); - if (commState.readSize >= 0) { - if (missed == null) - missed = new HashSet<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - - missed.add((Integer)_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 7: - updateSeq = commState.getLong("updateSeq"); + updateSeq = reader.readLong("updateSeq"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 8: - workerId = commState.getInt("workerId"); + workerId = reader.readInt("workerId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsAbstractMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsAbstractMessage.java index b8905f9c0b1d1..961da85732d81 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsAbstractMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsAbstractMessage.java @@ -87,30 +87,30 @@ public GridDhtPartitionExchangeId exchangeId() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 3: - if (!commState.putDhtPartitionExchangeId("exchId", exchId)) + if (!writer.writeMessage("exchId", exchId != null ? exchId.clone() : null)) return false; - commState.idx++; + state++; case 4: - if (!commState.putCacheVersion("lastVer", lastVer)) + if (!writer.writeMessage("lastVer", lastVer != null ? lastVer.clone() : null)) return false; - commState.idx++; + state++; } @@ -120,27 +120,27 @@ public GridDhtPartitionExchangeId exchangeId() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 3: - exchId = commState.getDhtPartitionExchangeId("exchId"); + exchId = reader.readMessage("exchId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 4: - lastVer = commState.getCacheVersion("lastVer"); + lastVer = reader.readMessage("lastVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java index fad32399887e7..d8dd3b1a0b2aa 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java @@ -168,36 +168,36 @@ public void affinityAssignment(List> affAssignment) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 5: - if (!commState.putByteArray("affAssignmentBytes", affAssignmentBytes)) + if (!writer.writeByteArray("affAssignmentBytes", affAssignmentBytes)) return false; - commState.idx++; + state++; case 6: - if (!commState.putByteArray("partsBytes", partsBytes)) + if (!writer.writeByteArray("partsBytes", partsBytes)) return false; - commState.idx++; + state++; case 7: - if (!commState.putLong("topVer", topVer)) + if (!writer.writeLong("topVer", topVer)) return false; - commState.idx++; + state++; } @@ -207,35 +207,35 @@ public void affinityAssignment(List> affAssignment) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 5: - affAssignmentBytes = commState.getByteArray("affAssignmentBytes"); + affAssignmentBytes = reader.readByteArray("affAssignmentBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 6: - partsBytes = commState.getByteArray("partsBytes"); + partsBytes = reader.readByteArray("partsBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 7: - topVer = commState.getLong("topVer"); + topVer = reader.readLong("topVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java index 94efd43eedd28..d9c9e4527a57c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java @@ -117,24 +117,24 @@ public Map partitions() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 5: - if (!commState.putByteArray("partsBytes", partsBytes)) + if (!writer.writeByteArray("partsBytes", partsBytes)) return false; - commState.idx++; + state++; } @@ -144,19 +144,19 @@ public Map partitions() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 5: - partsBytes = commState.getByteArray("partsBytes"); + partsBytes = reader.readByteArray("partsBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleRequest.java index d7a091bc628c4..944fcc0ae7f9c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleRequest.java @@ -63,16 +63,16 @@ public GridDhtPartitionsSingleRequest() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } return true; @@ -81,7 +81,7 @@ public GridDhtPartitionsSingleRequest() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java index f8c5cc270f683..44088aae6c6e3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java @@ -281,137 +281,84 @@ public long accessTtl() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 3: - if (!commState.putLong("accessTtl", accessTtl)) + if (!writer.writeLong("accessTtl", accessTtl)) return false; - commState.idx++; + state++; case 4: - if (filterBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, filterBytes.length)) - return false; - - commState.it = arrayIterator(filterBytes); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putByteArray(null, (byte[])commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeObjectArray("filterBytes", filterBytes, byte[].class)) + return false; - commState.idx++; + state++; case 5: - if (!commState.putGridUuid("futId", futId)) + if (!writer.writeIgniteUuid("futId", futId)) return false; - commState.idx++; + state++; case 6: - if (keyBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, keyBytes.size())) - return false; - - commState.it = keyBytes.entrySet().iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - Map.Entry e = (Map.Entry)commState.cur; - - if (!commState.keyDone) { - if (!commState.putByteArray(null, e.getKey())) - return false; - - commState.keyDone = true; - } - - if (!commState.putBoolean(null, e.getValue())) - return false; - - commState.keyDone = false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeMap("keyBytes", keyBytes, byte[].class, boolean.class)) + return false; - commState.idx++; + state++; case 7: - if (!commState.putGridUuid("miniId", miniId)) + if (!writer.writeIgniteUuid("miniId", miniId)) return false; - commState.idx++; + state++; case 8: - if (!commState.putBoolean("readThrough", readThrough)) + if (!writer.writeBoolean("readThrough", readThrough)) return false; - commState.idx++; + state++; case 9: - if (!commState.putBoolean("reload", reload)) + if (!writer.writeBoolean("reload", reload)) return false; - commState.idx++; + state++; case 10: - if (!commState.putLong("topVer", topVer)) + if (!writer.writeUuid("subjId", subjId)) return false; - commState.idx++; + state++; case 11: - if (!commState.putCacheVersion("ver", ver)) + if (!writer.writeInt("taskNameHash", taskNameHash)) return false; - commState.idx++; + state++; case 12: - if (!commState.putUuid("subjId", subjId)) + if (!writer.writeLong("topVer", topVer)) return false; - commState.idx++; + state++; case 13: - if (!commState.putInt("taskNameHash", taskNameHash)) + if (!writer.writeMessage("ver", ver != null ? ver.clone() : null)) return false; - commState.idx++; + state++; } @@ -421,156 +368,99 @@ public long accessTtl() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 3: - accessTtl = commState.getLong("accessTtl"); + accessTtl = reader.readLong("accessTtl"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 4: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } + filterBytes = reader.readObjectArray("filterBytes", byte[].class); - if (commState.readSize >= 0) { - if (filterBytes == null) - filterBytes = new byte[commState.readSize][]; - - for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(null); - - if (!commState.lastRead()) - return false; - - filterBytes[i] = (byte[])_val; - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 5: - futId = commState.getGridUuid("futId"); + futId = reader.readIgniteUuid("futId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 6: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (keyBytes == null) - keyBytes = new LinkedHashMap<>(commState.readSize, 1.0f); - - for (int i = commState.readItems; i < commState.readSize; i++) { - if (!commState.keyDone) { - byte[] _val = commState.getByteArray(null); + keyBytes = reader.readMap("keyBytes", byte[].class, boolean.class); - if (!commState.lastRead()) - return false; - - commState.cur = _val; - commState.keyDone = true; - } - - boolean _val = commState.getBoolean(null); - - if (!commState.lastRead()) - return false; - - keyBytes.put((byte[])commState.cur, _val); - - commState.keyDone = false; - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; - commState.cur = null; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 7: - miniId = commState.getGridUuid("miniId"); + miniId = reader.readIgniteUuid("miniId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 8: - readThrough = commState.getBoolean("readThrough"); + readThrough = reader.readBoolean("readThrough"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 9: - reload = commState.getBoolean("reload"); + reload = reader.readBoolean("reload"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 10: - topVer = commState.getLong("topVer"); + subjId = reader.readUuid("subjId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 11: - ver = commState.getCacheVersion("ver"); + taskNameHash = reader.readInt("taskNameHash"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 12: - subjId = commState.getUuid("subjId"); + topVer = reader.readLong("topVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 13: - taskNameHash = commState.getInt("taskNameHash"); + ver = reader.readMessage("ver"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java index cc2a48a82d593..63c9e464bf1cd 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java @@ -229,81 +229,60 @@ public void error(Throwable err) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 3: - if (!commState.putByteArray("entriesBytes", entriesBytes)) + if (!writer.writeByteArray("entriesBytes", entriesBytes)) return false; - commState.idx++; + state++; case 4: - if (!commState.putByteArray("errBytes", errBytes)) + if (!writer.writeByteArray("errBytes", errBytes)) return false; - commState.idx++; + state++; case 5: - if (!commState.putGridUuid("futId", futId)) + if (!writer.writeIgniteUuid("futId", futId)) return false; - commState.idx++; + state++; case 6: - if (invalidParts != null) { - if (commState.it == null) { - if (!commState.putInt(null, invalidParts.size())) - return false; - - commState.it = invalidParts.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putInt(null, (int)commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("invalidParts", invalidParts, int.class)) + return false; - commState.idx++; + state++; case 7: - if (!commState.putGridUuid("miniId", miniId)) + if (!writer.writeIgniteUuid("miniId", miniId)) return false; - commState.idx++; + state++; case 8: - if (!commState.putLong("topVer", topVer)) + if (!writer.writeLong("topVer", topVer)) return false; - commState.idx++; + state++; case 9: - if (!commState.putCacheVersion("ver", ver)) + if (!writer.writeMessage("ver", ver != null ? ver.clone() : null)) return false; - commState.idx++; + state++; } @@ -313,89 +292,67 @@ public void error(Throwable err) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 3: - entriesBytes = commState.getByteArray("entriesBytes"); + entriesBytes = reader.readByteArray("entriesBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 4: - errBytes = commState.getByteArray("errBytes"); + errBytes = reader.readByteArray("errBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 5: - futId = commState.getGridUuid("futId"); + futId = reader.readIgniteUuid("futId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 6: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } + invalidParts = reader.readCollection("invalidParts", int.class); - if (commState.readSize >= 0) { - if (invalidParts == null) - invalidParts = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - - invalidParts.add((Integer)_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 7: - miniId = commState.getGridUuid("miniId"); + miniId = reader.readIgniteUuid("miniId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 8: - topVer = commState.getLong("topVer"); + topVer = reader.readLong("topVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 9: - ver = commState.getCacheVersion("ver"); + ver = reader.readMessage("ver"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java index da008ac3522cb..599700760b149 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java @@ -364,132 +364,90 @@ public long accessTtl() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 24: - if (!commState.putLong("accessTtl", accessTtl)) + if (!writer.writeLong("accessTtl", accessTtl)) return false; - commState.idx++; + state++; case 25: - if (dhtVers != null) { - if (commState.it == null) { - if (!commState.putInt(null, dhtVers.length)) - return false; - - commState.it = arrayIterator(dhtVers); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putCacheVersion(null, (GridCacheVersion)commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeObjectArray("dhtVers", dhtVers, GridCacheVersion.class)) + return false; - commState.idx++; + state++; case 26: - if (filterBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, filterBytes.length)) - return false; - - commState.it = arrayIterator(filterBytes); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putByteArray(null, (byte[])commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeObjectArray("filterBytes", filterBytes, byte[].class)) + return false; - commState.idx++; + state++; case 27: - if (!commState.putBoolean("implicitSingleTx", implicitSingleTx)) + if (!writer.writeBoolean("hasTransforms", hasTransforms)) return false; - commState.idx++; + state++; case 28: - if (!commState.putBoolean("implicitTx", implicitTx)) + if (!writer.writeBoolean("implicitSingleTx", implicitSingleTx)) return false; - commState.idx++; + state++; case 29: - if (!commState.putGridUuid("miniId", miniId)) + if (!writer.writeBoolean("implicitTx", implicitTx)) return false; - commState.idx++; + state++; case 30: - if (!commState.putBoolean("onePhaseCommit", onePhaseCommit)) + if (!writer.writeIgniteUuid("miniId", miniId)) return false; - commState.idx++; + state++; case 31: - if (!commState.putBoolean("syncCommit", syncCommit)) + if (!writer.writeBoolean("onePhaseCommit", onePhaseCommit)) return false; - commState.idx++; + state++; case 32: - if (!commState.putLong("topVer", topVer)) + if (!writer.writeUuid("subjId", subjId)) return false; - commState.idx++; + state++; case 33: - if (!commState.putUuid("subjId", subjId)) + if (!writer.writeBoolean("syncCommit", syncCommit)) return false; - commState.idx++; + state++; case 34: - if (!commState.putInt("taskNameHash", taskNameHash)) + if (!writer.writeInt("taskNameHash", taskNameHash)) return false; - commState.idx++; + state++; case 35: - if (!commState.putBoolean("hasTransforms", hasTransforms)) + if (!writer.writeLong("topVer", topVer)) return false; - commState.idx++; + state++; } @@ -499,151 +457,107 @@ public long accessTtl() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 24: - accessTtl = commState.getLong("accessTtl"); + accessTtl = reader.readLong("accessTtl"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 25: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } + dhtVers = reader.readObjectArray("dhtVers", GridCacheVersion.class); - if (commState.readSize >= 0) { - if (dhtVers == null) - dhtVers = new GridCacheVersion[commState.readSize]; - - for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheVersion _val = commState.getCacheVersion(null); - - if (!commState.lastRead()) - return false; - - dhtVers[i] = (GridCacheVersion)_val; - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 26: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } + filterBytes = reader.readObjectArray("filterBytes", byte[].class); - if (commState.readSize >= 0) { - if (filterBytes == null) - filterBytes = new byte[commState.readSize][]; - - for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(null); - - if (!commState.lastRead()) - return false; - - filterBytes[i] = (byte[])_val; - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 27: - implicitSingleTx = commState.getBoolean("implicitSingleTx"); + hasTransforms = reader.readBoolean("hasTransforms"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 28: - implicitTx = commState.getBoolean("implicitTx"); + implicitSingleTx = reader.readBoolean("implicitSingleTx"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 29: - miniId = commState.getGridUuid("miniId"); + implicitTx = reader.readBoolean("implicitTx"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 30: - onePhaseCommit = commState.getBoolean("onePhaseCommit"); + miniId = reader.readIgniteUuid("miniId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 31: - syncCommit = commState.getBoolean("syncCommit"); + onePhaseCommit = reader.readBoolean("onePhaseCommit"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 32: - topVer = commState.getLong("topVer"); + subjId = reader.readUuid("subjId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 33: - subjId = commState.getUuid("subjId"); + syncCommit = reader.readBoolean("syncCommit"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 34: - taskNameHash = commState.getInt("taskNameHash"); + taskNameHash = reader.readInt("taskNameHash"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 35: - hasTransforms = commState.getBoolean("hasTransforms"); + topVer = reader.readLong("topVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockResponse.java index 9a62b025b3edc..2769f7abe3fd1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockResponse.java @@ -206,111 +206,48 @@ public void addValueBytes( /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 11: - if (dhtVers != null) { - if (commState.it == null) { - if (!commState.putInt(null, dhtVers.length)) - return false; - - commState.it = arrayIterator(dhtVers); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putCacheVersion(null, (GridCacheVersion)commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeObjectArray("dhtVers", dhtVers, GridCacheVersion.class)) + return false; - commState.idx++; + state++; case 12: - if (!commState.putBooleanArray("filterRes", filterRes)) + if (!writer.writeBooleanArray("filterRes", filterRes)) return false; - commState.idx++; + state++; case 13: - if (mappedVers != null) { - if (commState.it == null) { - if (!commState.putInt(null, mappedVers.length)) - return false; - - commState.it = arrayIterator(mappedVers); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putCacheVersion(null, (GridCacheVersion)commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeObjectArray("mappedVers", mappedVers, GridCacheVersion.class)) + return false; - commState.idx++; + state++; case 14: - if (!commState.putGridUuid("miniId", miniId)) + if (!writer.writeIgniteUuid("miniId", miniId)) return false; - commState.idx++; + state++; case 15: - if (pending != null) { - if (commState.it == null) { - if (!commState.putInt(null, pending.size())) - return false; - - commState.it = pending.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putCacheVersion(null, (GridCacheVersion)commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("pending", pending, GridCacheVersion.class)) + return false; - commState.idx++; + state++; } @@ -320,117 +257,51 @@ public void addValueBytes( /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 11: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (dhtVers == null) - dhtVers = new GridCacheVersion[commState.readSize]; + dhtVers = reader.readObjectArray("dhtVers", GridCacheVersion.class); - for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheVersion _val = commState.getCacheVersion(null); - - if (!commState.lastRead()) - return false; - - dhtVers[i] = (GridCacheVersion)_val; - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 12: - filterRes = commState.getBooleanArray("filterRes"); + filterRes = reader.readBooleanArray("filterRes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 13: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (mappedVers == null) - mappedVers = new GridCacheVersion[commState.readSize]; - - for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheVersion _val = commState.getCacheVersion(null); - - if (!commState.lastRead()) - return false; - - mappedVers[i] = (GridCacheVersion)_val; + mappedVers = reader.readObjectArray("mappedVers", GridCacheVersion.class); - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 14: - miniId = commState.getGridUuid("miniId"); + miniId = reader.readIgniteUuid("miniId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 15: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (pending == null) - pending = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheVersion _val = commState.getCacheVersion(null); + pending = reader.readCollection("pending", GridCacheVersion.class); - if (!commState.lastRead()) - return false; - - pending.add((GridCacheVersion)_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java index a462751ab25a5..cfa797a0296c8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java @@ -184,54 +184,54 @@ public int taskNameHash() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 21: - if (!commState.putBoolean("explicitLock", explicitLock)) + if (!writer.writeBoolean("explicitLock", explicitLock)) return false; - commState.idx++; + state++; case 22: - if (!commState.putGridUuid("miniId", miniId)) + if (!writer.writeIgniteUuid("miniId", miniId)) return false; - commState.idx++; + state++; case 23: - if (!commState.putBoolean("storeEnabled", storeEnabled)) + if (!writer.writeBoolean("storeEnabled", storeEnabled)) return false; - commState.idx++; + state++; case 24: - if (!commState.putLong("topVer", topVer)) + if (!writer.writeUuid("subjId", subjId)) return false; - commState.idx++; + state++; case 25: - if (!commState.putUuid("subjId", subjId)) + if (!writer.writeInt("taskNameHash", taskNameHash)) return false; - commState.idx++; + state++; case 26: - if (!commState.putInt("taskNameHash", taskNameHash)) + if (!writer.writeLong("topVer", topVer)) return false; - commState.idx++; + state++; } @@ -241,59 +241,59 @@ public int taskNameHash() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 21: - explicitLock = commState.getBoolean("explicitLock"); + explicitLock = reader.readBoolean("explicitLock"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 22: - miniId = commState.getGridUuid("miniId"); + miniId = reader.readIgniteUuid("miniId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 23: - storeEnabled = commState.getBoolean("storeEnabled"); + storeEnabled = reader.readBoolean("storeEnabled"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 24: - topVer = commState.getLong("topVer"); + subjId = reader.readUuid("subjId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 25: - subjId = commState.getUuid("subjId"); + taskNameHash = reader.readInt("taskNameHash"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 26: - taskNameHash = commState.getInt("taskNameHash"); + topVer = reader.readLong("topVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java index 5532b883ab6b9..5e190792163e4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java @@ -138,36 +138,36 @@ public long threadId() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 5: - if (!commState.putByteArray("errBytes", errBytes)) + if (!writer.writeByteArray("errBytes", errBytes)) return false; - commState.idx++; + state++; case 6: - if (!commState.putGridUuid("miniId", miniId)) + if (!writer.writeIgniteUuid("miniId", miniId)) return false; - commState.idx++; + state++; case 7: - if (!commState.putLong("nearThreadId", nearThreadId)) + if (!writer.writeLong("nearThreadId", nearThreadId)) return false; - commState.idx++; + state++; } @@ -177,35 +177,35 @@ public long threadId() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 5: - errBytes = commState.getByteArray("errBytes"); + errBytes = reader.readByteArray("errBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 6: - miniId = commState.getGridUuid("miniId"); + miniId = reader.readIgniteUuid("miniId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 7: - nearThreadId = commState.getLong("nearThreadId"); + nearThreadId = reader.readLong("nearThreadId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java index 1cd7ce06d9cf1..9d5f73d89a1c1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java @@ -244,87 +244,66 @@ private Collection> cloneEntries(Collection> cloneEntries(Collection= 0) { - if (lastBackups == null) - lastBackups = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - UUID _val = commState.getUuid(null); - - if (!commState.lastRead()) - return false; - - lastBackups.add((UUID)_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 25: - miniId = commState.getGridUuid("miniId"); + miniId = reader.readIgniteUuid("miniId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 26: - near = commState.getBoolean("near"); + near = reader.readBoolean("near"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 27: - topVer = commState.getLong("topVer"); + subjId = reader.readUuid("subjId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 28: - subjId = commState.getUuid("subjId"); + taskNameHash = reader.readInt("taskNameHash"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 29: - taskNameHash = commState.getInt("taskNameHash"); + topVer = reader.readLong("topVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java index f6e69753f2ab5..8eb63b147550b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java @@ -251,117 +251,54 @@ public Collection invalidPartitions() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 10: - if (!commState.putCacheVersion("dhtVer", dhtVer)) + if (!writer.writeMessage("dhtVer", dhtVer != null ? dhtVer.clone() : null)) return false; - commState.idx++; + state++; case 11: - if (!commState.putGridUuid("futId", futId)) + if (!writer.writeIgniteUuid("futId", futId)) return false; - commState.idx++; + state++; case 12: - if (invalidParts != null) { - if (commState.it == null) { - if (!commState.putInt(null, invalidParts.size())) - return false; - - commState.it = invalidParts.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putInt(null, (int)commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("invalidParts", invalidParts, int.class)) + return false; - commState.idx++; + state++; case 13: - if (!commState.putGridUuid("miniId", miniId)) + if (!writer.writeIgniteUuid("miniId", miniId)) return false; - commState.idx++; + state++; case 14: - if (ownedValsBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, ownedValsBytes.size())) - return false; - - commState.it = ownedValsBytes.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putByteArray(null, (byte[])commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("ownedValsBytes", ownedValsBytes, byte[].class)) + return false; - commState.idx++; + state++; case 15: - if (pending != null) { - if (commState.it == null) { - if (!commState.putInt(null, pending.size())) - return false; - - commState.it = pending.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putCacheVersion(null, (GridCacheVersion)commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("pending", pending, GridCacheVersion.class)) + return false; - commState.idx++; + state++; } @@ -371,125 +308,59 @@ public Collection invalidPartitions() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 10: - dhtVer = commState.getCacheVersion("dhtVer"); + dhtVer = reader.readMessage("dhtVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 11: - futId = commState.getGridUuid("futId"); + futId = reader.readIgniteUuid("futId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 12: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } + invalidParts = reader.readCollection("invalidParts", int.class); - if (commState.readSize >= 0) { - if (invalidParts == null) - invalidParts = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - - invalidParts.add((Integer)_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 13: - miniId = commState.getGridUuid("miniId"); + miniId = reader.readIgniteUuid("miniId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 14: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (ownedValsBytes == null) - ownedValsBytes = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(null); - - if (!commState.lastRead()) - return false; - - ownedValsBytes.add((byte[])_val); + ownedValsBytes = reader.readCollection("ownedValsBytes", byte[].class); - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 15: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (pending == null) - pending = new ArrayList<>(commState.readSize); + pending = reader.readCollection("pending", GridCacheVersion.class); - for (int i = commState.readItems; i < commState.readSize; i++) { - GridCacheVersion _val = commState.getCacheVersion(null); - - if (!commState.lastRead()) - return false; - - pending.add((GridCacheVersion)_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearUnlockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearUnlockRequest.java index 86f839bc3cd3e..267d798422d9c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearUnlockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearUnlockRequest.java @@ -65,16 +65,16 @@ public GridNearUnlockRequest(int cacheId, int keyCnt) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } return true; @@ -83,7 +83,7 @@ public GridNearUnlockRequest(int cacheId, int keyCnt) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java index 2893f4f6c24f6..e7079d107c170 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java @@ -485,132 +485,132 @@ public int taskHash() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 3: - if (!commState.putBoolean("all", all)) + if (!writer.writeBoolean("all", all)) return false; - commState.idx++; + state++; case 4: - if (!commState.putByteArray("argsBytes", argsBytes)) + if (!writer.writeByteArray("argsBytes", argsBytes)) return false; - commState.idx++; + state++; case 5: - if (!commState.putString("cacheName", cacheName)) + if (!writer.writeString("cacheName", cacheName)) return false; - commState.idx++; + state++; case 6: - if (!commState.putBoolean("cancel", cancel)) + if (!writer.writeBoolean("cancel", cancel)) return false; - commState.idx++; + state++; case 7: - if (!commState.putString("clause", clause)) + if (!writer.writeString("clause", clause)) return false; - commState.idx++; + state++; case 8: - if (!commState.putString("clsName", clsName)) + if (!writer.writeString("clsName", clsName)) return false; - commState.idx++; + state++; case 9: - if (!commState.putBoolean("fields", fields)) + if (!writer.writeBoolean("fields", fields)) return false; - commState.idx++; + state++; case 10: - if (!commState.putLong("id", id)) + if (!writer.writeLong("id", id)) return false; - commState.idx++; + state++; case 11: - if (!commState.putBoolean("incBackups", incBackups)) + if (!writer.writeBoolean("incBackups", incBackups)) return false; - commState.idx++; + state++; case 12: - if (!commState.putBoolean("incMeta", incMeta)) + if (!writer.writeBoolean("incMeta", incMeta)) return false; - commState.idx++; + state++; case 13: - if (!commState.putByteArray("keyValFilterBytes", keyValFilterBytes)) + if (!writer.writeBoolean("keepPortable", keepPortable)) return false; - commState.idx++; + state++; case 14: - if (!commState.putInt("pageSize", pageSize)) + if (!writer.writeByteArray("keyValFilterBytes", keyValFilterBytes)) return false; - commState.idx++; + state++; case 15: - if (!commState.putByteArray("prjFilterBytes", prjFilterBytes)) + if (!writer.writeInt("pageSize", pageSize)) return false; - commState.idx++; + state++; case 16: - if (!commState.putByteArray("rdcBytes", rdcBytes)) + if (!writer.writeByteArray("prjFilterBytes", prjFilterBytes)) return false; - commState.idx++; + state++; case 17: - if (!commState.putByteArray("transBytes", transBytes)) + if (!writer.writeByteArray("rdcBytes", rdcBytes)) return false; - commState.idx++; + state++; case 18: - if (!commState.putEnum("type", type)) + if (!writer.writeUuid("subjId", subjId)) return false; - commState.idx++; + state++; case 19: - if (!commState.putBoolean("keepPortable", keepPortable)) + if (!writer.writeInt("taskHash", taskHash)) return false; - commState.idx++; + state++; case 20: - if (!commState.putUuid("subjId", subjId)) + if (!writer.writeByteArray("transBytes", transBytes)) return false; - commState.idx++; + state++; case 21: - if (!commState.putInt("taskHash", taskHash)) + if (!writer.writeEnum("type", type)) return false; - commState.idx++; + state++; } @@ -620,165 +620,163 @@ public int taskHash() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 3: - all = commState.getBoolean("all"); + all = reader.readBoolean("all"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 4: - argsBytes = commState.getByteArray("argsBytes"); + argsBytes = reader.readByteArray("argsBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 5: - cacheName = commState.getString("cacheName"); + cacheName = reader.readString("cacheName"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 6: - cancel = commState.getBoolean("cancel"); + cancel = reader.readBoolean("cancel"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 7: - clause = commState.getString("clause"); + clause = reader.readString("clause"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 8: - clsName = commState.getString("clsName"); + clsName = reader.readString("clsName"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 9: - fields = commState.getBoolean("fields"); + fields = reader.readBoolean("fields"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 10: - id = commState.getLong("id"); + id = reader.readLong("id"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 11: - incBackups = commState.getBoolean("incBackups"); + incBackups = reader.readBoolean("incBackups"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 12: - incMeta = commState.getBoolean("incMeta"); + incMeta = reader.readBoolean("incMeta"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 13: - keyValFilterBytes = commState.getByteArray("keyValFilterBytes"); + keepPortable = reader.readBoolean("keepPortable"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 14: - pageSize = commState.getInt("pageSize"); + keyValFilterBytes = reader.readByteArray("keyValFilterBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 15: - prjFilterBytes = commState.getByteArray("prjFilterBytes"); + pageSize = reader.readInt("pageSize"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 16: - rdcBytes = commState.getByteArray("rdcBytes"); + prjFilterBytes = reader.readByteArray("prjFilterBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 17: - transBytes = commState.getByteArray("transBytes"); + rdcBytes = reader.readByteArray("rdcBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 18: - byte type0 = commState.getByte("type"); + subjId = reader.readUuid("subjId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - type = GridCacheQueryType.fromOrdinal(type0); - - commState.idx++; + state++; case 19: - keepPortable = commState.getBoolean("keepPortable"); + taskHash = reader.readInt("taskHash"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 20: - subjId = commState.getUuid("subjId"); + transBytes = reader.readByteArray("transBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 21: - taskHash = commState.getInt("taskHash"); + type = reader.readEnum("type", GridCacheQueryType.class); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java index fe18c8c3a9937..acba6f69e521a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java @@ -231,96 +231,54 @@ public boolean fields() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 3: - if (dataBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, dataBytes.size())) - return false; - - commState.it = dataBytes.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putByteArray(null, (byte[])commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("dataBytes", dataBytes, byte[].class)) + return false; - commState.idx++; + state++; case 4: - if (!commState.putByteArray("errBytes", errBytes)) + if (!writer.writeByteArray("errBytes", errBytes)) return false; - commState.idx++; + state++; case 5: - if (!commState.putBoolean("fields", fields)) + if (!writer.writeBoolean("fields", fields)) return false; - commState.idx++; + state++; case 6: - if (!commState.putBoolean("finished", finished)) + if (!writer.writeBoolean("finished", finished)) return false; - commState.idx++; + state++; case 7: - if (metaDataBytes != null) { - if (commState.it == null) { - if (!commState.putInt(null, metaDataBytes.size())) - return false; - - commState.it = metaDataBytes.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putByteArray(null, (byte[])commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("metaDataBytes", metaDataBytes, byte[].class)) + return false; - commState.idx++; + state++; case 8: - if (!commState.putLong("reqId", reqId)) + if (!writer.writeLong("reqId", reqId)) return false; - commState.idx++; + state++; } @@ -330,103 +288,59 @@ public boolean fields() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 3: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } + dataBytes = reader.readCollection("dataBytes", byte[].class); - if (commState.readSize >= 0) { - if (dataBytes == null) - dataBytes = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(null); - - if (!commState.lastRead()) - return false; - - dataBytes.add((byte[])_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 4: - errBytes = commState.getByteArray("errBytes"); + errBytes = reader.readByteArray("errBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 5: - fields = commState.getBoolean("fields"); + fields = reader.readBoolean("fields"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 6: - finished = commState.getBoolean("finished"); + finished = reader.readBoolean("finished"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 7: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (metaDataBytes == null) - metaDataBytes = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - byte[] _val = commState.getByteArray(null); - - if (!commState.lastRead()) - return false; + metaDataBytes = reader.readCollection("metaDataBytes", byte[].class); - metaDataBytes.add((byte[])_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 8: - reqId = commState.getLong("reqId"); + reqId = reader.readLong("reqId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersion.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersion.java index 15e84acb1236b..77fdf2dabb180 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersion.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersion.java @@ -254,12 +254,85 @@ public IgniteUuid asGridUuid() { /** {@inheritDoc} */ @Override public boolean writeTo(ByteBuffer buf) { - return false; // TODO: implement. + writer.setBuffer(buf); + + if (!typeWritten) { + if (!writer.writeByte(null, directType())) + return false; + + typeWritten = true; + } + + switch (state) { + case 0: + if (!writer.writeLong("globalTime", globalTime)) + return false; + + state++; + + case 1: + if (!writer.writeInt("nodeOrderDrId", nodeOrderDrId)) + return false; + + state++; + + case 2: + if (!writer.writeLong("order", order)) + return false; + + state++; + + case 3: + if (!writer.writeInt("topVer", topVer)) + return false; + + state++; + + } + + return true; } /** {@inheritDoc} */ @Override public boolean readFrom(ByteBuffer buf) { - return false; // TODO: implement. + reader.setBuffer(buf); + + switch (state) { + case 0: + globalTime = reader.readLong("globalTime"); + + if (!reader.isLastRead()) + return false; + + state++; + + case 1: + nodeOrderDrId = reader.readInt("nodeOrderDrId"); + + if (!reader.isLastRead()) + return false; + + state++; + + case 2: + order = reader.readLong("order"); + + if (!reader.isLastRead()) + return false; + + state++; + + case 3: + topVer = reader.readInt("topVer"); + + if (!reader.isLastRead()) + return false; + + state++; + + } + + return true; } /** {@inheritDoc} */ @@ -269,12 +342,21 @@ public IgniteUuid asGridUuid() { /** {@inheritDoc} */ @Override public MessageAdapter clone() { - return null; // TODO: implement. + GridCacheVersion _clone = new GridCacheVersion(); + + clone0(_clone); + + return _clone; } /** {@inheritDoc} */ @Override protected void clone0(MessageAdapter _msg) { - // TODO: implement. + GridCacheVersion _clone = (GridCacheVersion)_msg; + + _clone.topVer = topVer; + _clone.nodeOrderDrId = nodeOrderDrId; + _clone.globalTime = globalTime; + _clone.order = order; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaSnapshotMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaSnapshotMessage.java index dd576e3f5403c..61fe04480612e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaSnapshotMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaSnapshotMessage.java @@ -92,59 +92,27 @@ public Map deltas() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 0: - if (deltas != null) { - if (commState.it == null) { - if (!commState.putInt(null, deltas.size())) - return false; - - commState.it = deltas.entrySet().iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - Map.Entry e = (Map.Entry)commState.cur; - - if (!commState.keyDone) { - if (!commState.putUuid(null, e.getKey())) - return false; - - commState.keyDone = true; - } - - if (!commState.putLong(null, e.getValue())) - return false; - - commState.keyDone = false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeMap("deltas", deltas, UUID.class, long.class)) + return false; - commState.idx++; + state++; case 1: - if (!commState.putClockDeltaVersion("snapVer", snapVer)) + if (!writer.writeMessage("snapVer", snapVer != null ? snapVer.clone() : null)) return false; - commState.idx++; + state++; } @@ -154,59 +122,24 @@ public Map deltas() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); - switch (commState.idx) { + switch (state) { case 0: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } + deltas = reader.readMap("deltas", UUID.class, long.class); - if (commState.readSize >= 0) { - if (deltas == null) - deltas = new HashMap<>(commState.readSize, 1.0f); - - for (int i = commState.readItems; i < commState.readSize; i++) { - if (!commState.keyDone) { - UUID _val = commState.getUuid(null); - - if (!commState.lastRead()) - return false; - - commState.cur = _val; - commState.keyDone = true; - } - - long _val = commState.getLong(null); - - if (!commState.lastRead()) - return false; - - deltas.put((UUID)commState.cur, _val); - - commState.keyDone = false; - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; - commState.cur = null; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 1: - snapVer = commState.getClockDeltaVersion("snapVer"); + snapVer = reader.readMessage("snapVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaVersion.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaVersion.java index 852f9f0eea83b..06e8730fc2289 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaVersion.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaVersion.java @@ -114,12 +114,57 @@ public long topologyVersion() { /** {@inheritDoc} */ @Override public boolean writeTo(ByteBuffer buf) { - return false; // TODO: implement. + writer.setBuffer(buf); + + if (!typeWritten) { + if (!writer.writeByte(null, directType())) + return false; + + typeWritten = true; + } + + switch (state) { + case 0: + if (!writer.writeLong("topVer", topVer)) + return false; + + state++; + + case 1: + if (!writer.writeLong("ver", ver)) + return false; + + state++; + + } + + return true; } /** {@inheritDoc} */ @Override public boolean readFrom(ByteBuffer buf) { - return false; // TODO: implement. + reader.setBuffer(buf); + + switch (state) { + case 0: + topVer = reader.readLong("topVer"); + + if (!reader.isLastRead()) + return false; + + state++; + + case 1: + ver = reader.readLong("ver"); + + if (!reader.isLastRead()) + return false; + + state++; + + } + + return true; } /** {@inheritDoc} */ @@ -129,12 +174,19 @@ public long topologyVersion() { /** {@inheritDoc} */ @Override public MessageAdapter clone() { - return null; // TODO: implement. + GridClockDeltaVersion _clone = new GridClockDeltaVersion(); + + clone0(_clone); + + return _clone; } /** {@inheritDoc} */ @Override protected void clone0(MessageAdapter _msg) { - // TODO: implement. + GridClockDeltaVersion _clone = (GridClockDeltaVersion)_msg; + + _clone.ver = ver; + _clone.topVer = topVer; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousMessage.java index a6a62d750ca42..e005a9b30197b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousMessage.java @@ -154,39 +154,39 @@ public void dataBytes(byte[] dataBytes) { /** {@inheritDoc} */ @SuppressWarnings("fallthrough") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 0: - if (!commState.putByteArray("dataBytes", dataBytes)) + if (!writer.writeByteArray("dataBytes", dataBytes)) return false; - commState.idx++; + state++; case 1: - if (!commState.putGridUuid("futId", futId)) + if (!writer.writeIgniteUuid("futId", futId)) return false; - commState.idx++; + state++; case 2: - if (!commState.putUuid("routineId", routineId)) + if (!writer.writeUuid("routineId", routineId)) return false; - commState.idx++; + state++; case 3: - if (!commState.putEnum("type", type)) + if (!writer.writeEnum("type", type)) return false; - commState.idx++; + state++; } @@ -196,42 +196,40 @@ public void dataBytes(byte[] dataBytes) { /** {@inheritDoc} */ @SuppressWarnings("fallthrough") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); - switch (commState.idx) { + switch (state) { case 0: - dataBytes = commState.getByteArray("dataBytes"); + dataBytes = reader.readByteArray("dataBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 1: - futId = commState.getGridUuid("futId"); + futId = reader.readIgniteUuid("futId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 2: - routineId = commState.getUuid("routineId"); + routineId = reader.readUuid("routineId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 3: - byte type0 = commState.getByte("type"); + type = reader.readEnum("type", GridContinuousMessageType.class); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - type = GridContinuousMessageType.fromOrdinal(type0); - - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadRequest.java index 4690f82a8a162..15721f91a81ef 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadRequest.java @@ -224,125 +224,93 @@ public boolean forceLocalDeployment() { /** {@inheritDoc} */ @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 0: - if (!commState.putString("cacheName", cacheName)) + if (!writer.writeString("cacheName", cacheName)) return false; - commState.idx++; + state++; case 1: - if (!commState.putGridUuid("clsLdrId", clsLdrId)) + if (!writer.writeIgniteUuid("clsLdrId", clsLdrId)) return false; - commState.idx++; + state++; case 2: - if (!commState.putByteArray("colBytes", colBytes)) + if (!writer.writeByteArray("colBytes", colBytes)) return false; - commState.idx++; + state++; case 3: - if (!commState.putEnum("depMode", depMode)) + if (!writer.writeEnum("depMode", depMode)) return false; - commState.idx++; + state++; case 4: - if (!commState.putBoolean("forceLocDep", forceLocDep)) + if (!writer.writeBoolean("forceLocDep", forceLocDep)) return false; - commState.idx++; + state++; case 5: - if (!commState.putBoolean("ignoreDepOwnership", ignoreDepOwnership)) + if (!writer.writeBoolean("ignoreDepOwnership", ignoreDepOwnership)) return false; - commState.idx++; + state++; case 6: - if (ldrParticipants != null) { - if (commState.it == null) { - if (!commState.putInt(null, ldrParticipants.size())) - return false; - - commState.it = ldrParticipants.entrySet().iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - Map.Entry e = (Map.Entry)commState.cur; - - if (!commState.keyDone) { - if (!commState.putUuid(null, e.getKey())) - return false; - - commState.keyDone = true; - } - - if (!commState.putGridUuid(null, e.getValue())) - return false; - - commState.keyDone = false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeMap("ldrParticipants", ldrParticipants, UUID.class, IgniteUuid.class)) + return false; - commState.idx++; + state++; case 7: - if (!commState.putLong("reqId", reqId)) + if (!writer.writeLong("reqId", reqId)) return false; - commState.idx++; + state++; case 8: - if (!commState.putByteArray("resTopicBytes", resTopicBytes)) + if (!writer.writeByteArray("resTopicBytes", resTopicBytes)) return false; - commState.idx++; + state++; case 9: - if (!commState.putString("sampleClsName", sampleClsName)) + if (!writer.writeString("sampleClsName", sampleClsName)) return false; - commState.idx++; + state++; case 10: - if (!commState.putBoolean("skipStore", skipStore)) + if (!writer.writeBoolean("skipStore", skipStore)) return false; - commState.idx++; + state++; case 11: - if (!commState.putByteArray("updaterBytes", updaterBytes)) + if (!writer.writeByteArray("updaterBytes", updaterBytes)) return false; - commState.idx++; + state++; case 12: - if (!commState.putString("userVer", userVer)) + if (!writer.writeString("userVer", userVer)) return false; - commState.idx++; + state++; } @@ -351,149 +319,112 @@ public boolean forceLocalDeployment() { /** {@inheritDoc} */ @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); - switch (commState.idx) { + switch (state) { case 0: - cacheName = commState.getString("cacheName"); + cacheName = reader.readString("cacheName"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 1: - clsLdrId = commState.getGridUuid("clsLdrId"); + clsLdrId = reader.readIgniteUuid("clsLdrId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 2: - colBytes = commState.getByteArray("colBytes"); + colBytes = reader.readByteArray("colBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 3: - byte depMode0 = commState.getByte("depMode"); + depMode = reader.readEnum("depMode", DeploymentMode.class); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - depMode = DeploymentMode.fromOrdinal(depMode0); - - commState.idx++; + state++; case 4: - forceLocDep = commState.getBoolean("forceLocDep"); + forceLocDep = reader.readBoolean("forceLocDep"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 5: - ignoreDepOwnership = commState.getBoolean("ignoreDepOwnership"); + ignoreDepOwnership = reader.readBoolean("ignoreDepOwnership"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 6: - if (commState.readSize == -1) { - int _val = commState.getInt(null); + ldrParticipants = reader.readMap("ldrParticipants", UUID.class, IgniteUuid.class); - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (ldrParticipants == null) - ldrParticipants = new HashMap<>(commState.readSize, 1.0f); - - for (int i = commState.readItems; i < commState.readSize; i++) { - if (!commState.keyDone) { - UUID _val = commState.getUuid(null); - - if (!commState.lastRead()) - return false; - - commState.cur = _val; - commState.keyDone = true; - } - - IgniteUuid _val = commState.getGridUuid(null); - - if (!commState.lastRead()) - return false; - - ldrParticipants.put((UUID)commState.cur, _val); - - commState.keyDone = false; - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; - commState.cur = null; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 7: - reqId = commState.getLong("reqId"); + reqId = reader.readLong("reqId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 8: - resTopicBytes = commState.getByteArray("resTopicBytes"); + resTopicBytes = reader.readByteArray("resTopicBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 9: - sampleClsName = commState.getString("sampleClsName"); + sampleClsName = reader.readString("sampleClsName"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 10: - skipStore = commState.getBoolean("skipStore"); + skipStore = reader.readBoolean("skipStore"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 11: - updaterBytes = commState.getByteArray("updaterBytes"); + updaterBytes = reader.readByteArray("updaterBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 12: - userVer = commState.getString("userVer"); + userVer = reader.readString("userVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadResponse.java index 2b8c0ee9b838d..8676e7e3a83f5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadResponse.java @@ -104,33 +104,33 @@ public boolean forceLocalDeployment() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 0: - if (!commState.putByteArray("errBytes", errBytes)) + if (!writer.writeByteArray("errBytes", errBytes)) return false; - commState.idx++; + state++; case 1: - if (!commState.putBoolean("forceLocDep", forceLocDep)) + if (!writer.writeBoolean("forceLocDep", forceLocDep)) return false; - commState.idx++; + state++; case 2: - if (!commState.putLong("reqId", reqId)) + if (!writer.writeLong("reqId", reqId)) return false; - commState.idx++; + state++; } @@ -140,32 +140,32 @@ public boolean forceLocalDeployment() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); - switch (commState.idx) { + switch (state) { case 0: - errBytes = commState.getByteArray("errBytes"); + errBytes = reader.readByteArray("errBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 1: - forceLocDep = commState.getBoolean("forceLocDep"); + forceLocDep = reader.readBoolean("forceLocDep"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 2: - reqId = commState.getLong("reqId"); + reqId = reader.readLong("reqId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsAckMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsAckMessage.java index 496a114da24bb..6bbb8e41757ca 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsAckMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsAckMessage.java @@ -127,36 +127,36 @@ public IgniteCheckedException error() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 0: - if (!commState.putByteArray("errBytes", errBytes)) + if (!writer.writeByteArray("errBytes", errBytes)) return false; - commState.idx++; + state++; case 1: - if (!commState.putGridUuid("fileId", fileId)) + if (!writer.writeIgniteUuid("fileId", fileId)) return false; - commState.idx++; + state++; case 2: - if (!commState.putLong("id", id)) + if (!writer.writeLong("id", id)) return false; - commState.idx++; + state++; } @@ -166,35 +166,35 @@ public IgniteCheckedException error() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 0: - errBytes = commState.getByteArray("errBytes"); + errBytes = reader.readByteArray("errBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 1: - fileId = commState.getGridUuid("fileId"); + fileId = reader.readIgniteUuid("fileId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 2: - id = commState.getLong("id"); + id = reader.readLong("id"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlockKey.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlockKey.java index bbcbf4241b59e..6fc3776ad1748 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlockKey.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlockKey.java @@ -181,39 +181,39 @@ public long getBlockId() { /** {@inheritDoc} */ @SuppressWarnings("fallthrough") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 0: - if (!commState.putGridUuid("affKey", affKey)) + if (!writer.writeIgniteUuid("affKey", affKey)) return false; - commState.idx++; + state++; case 1: - if (!commState.putLong("blockId", blockId)) + if (!writer.writeLong("blockId", blockId)) return false; - commState.idx++; + state++; case 2: - if (!commState.putBoolean("evictExclude", evictExclude)) + if (!writer.writeBoolean("evictExclude", evictExclude)) return false; - commState.idx++; + state++; case 3: - if (!commState.putGridUuid("fileId", fileId)) + if (!writer.writeIgniteUuid("fileId", fileId)) return false; - commState.idx++; + state++; } @@ -223,40 +223,40 @@ public long getBlockId() { /** {@inheritDoc} */ @SuppressWarnings("fallthrough") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); - switch (commState.idx) { + switch (state) { case 0: - affKey = commState.getGridUuid("affKey"); + affKey = reader.readIgniteUuid("affKey"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 1: - blockId = commState.getLong("blockId"); + blockId = reader.readLong("blockId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 2: - evictExclude = commState.getBoolean("evictExclude"); + evictExclude = reader.readBoolean("evictExclude"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 3: - fileId = commState.getGridUuid("fileId"); + fileId = reader.readIgniteUuid("fileId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlocksMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlocksMessage.java index 632104227ddd5..774006675b101 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlocksMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlocksMessage.java @@ -107,68 +107,36 @@ public Map blocks() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 0: - if (blocks != null) { - if (commState.it == null) { - if (!commState.putInt(null, blocks.size())) - return false; - - commState.it = blocks.entrySet().iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - Map.Entry e = (Map.Entry)commState.cur; - - if (!commState.keyDone) { - if (!commState.putMessage(null, e.getKey())) - return false; - - commState.keyDone = true; - } - - if (!commState.putByteArray(null, e.getValue())) - return false; - - commState.keyDone = false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeMap("blocks", blocks, GridGgfsBlockKey.class, byte[].class)) + return false; - commState.idx++; + state++; case 1: - if (!commState.putGridUuid("fileId", fileId)) + if (!writer.writeIgniteUuid("fileId", fileId)) return false; - commState.idx++; + state++; case 2: - if (!commState.putLong("id", id)) + if (!writer.writeLong("id", id)) return false; - commState.idx++; + state++; } @@ -178,70 +146,35 @@ public Map blocks() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 0: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } + blocks = reader.readMap("blocks", GridGgfsBlockKey.class, byte[].class); - if (commState.readSize >= 0) { - if (blocks == null) - blocks = new HashMap<>(commState.readSize, 1.0f); - - for (int i = commState.readItems; i < commState.readSize; i++) { - if (!commState.keyDone) { - GridGgfsBlockKey _val = (GridGgfsBlockKey)commState.getMessage(null); - - if (!commState.lastRead()) - return false; - - commState.cur = _val; - commState.keyDone = true; - } - - byte[] _val = commState.getByteArray(null); - - if (!commState.lastRead()) - return false; - - blocks.put((GridGgfsBlockKey)commState.cur, _val); - - commState.keyDone = false; - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; - commState.cur = null; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 1: - fileId = commState.getGridUuid("fileId"); + fileId = reader.readIgniteUuid("fileId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 2: - id = commState.getLong("id"); + id = reader.readLong("id"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsCommunicationMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsCommunicationMessage.java index b08d64ae754df..860eb4c1f1ed3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsCommunicationMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsCommunicationMessage.java @@ -54,13 +54,13 @@ public void finishUnmarshal(Marshaller marsh, @Nullable ClassLoader ldr) throws /** {@inheritDoc} */ @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } return true; @@ -68,7 +68,7 @@ public void finishUnmarshal(Marshaller marsh, @Nullable ClassLoader ldr) throws /** {@inheritDoc} */ @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); return true; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsDeleteMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsDeleteMessage.java index 6be821a95ca0b..18ae5b53a405a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsDeleteMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsDeleteMessage.java @@ -130,30 +130,30 @@ public IgniteCheckedException error() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 0: - if (!commState.putByteArray("errBytes", errBytes)) + if (!writer.writeByteArray("errBytes", errBytes)) return false; - commState.idx++; + state++; case 1: - if (!commState.putGridUuid("id", id)) + if (!writer.writeIgniteUuid("id", id)) return false; - commState.idx++; + state++; } @@ -163,27 +163,27 @@ public IgniteCheckedException error() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 0: - errBytes = commState.getByteArray("errBytes"); + errBytes = reader.readByteArray("errBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 1: - id = commState.getGridUuid("id"); + id = reader.readIgniteUuid("id"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFileAffinityRange.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFileAffinityRange.java index 04c822e19ea4c..edd9d6a74843b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFileAffinityRange.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFileAffinityRange.java @@ -286,45 +286,45 @@ public boolean regionEqual(GridGgfsFileAffinityRange other) { /** {@inheritDoc} */ @SuppressWarnings("fallthrough") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 0: - if (!commState.putGridUuid("affKey", affKey)) + if (!writer.writeIgniteUuid("affKey", affKey)) return false; - commState.idx++; + state++; case 1: - if (!commState.putBoolean("done", done)) + if (!writer.writeBoolean("done", done)) return false; - commState.idx++; + state++; case 2: - if (!commState.putLong("endOff", endOff)) + if (!writer.writeLong("endOff", endOff)) return false; - commState.idx++; + state++; case 3: - if (!commState.putLong("startOff", startOff)) + if (!writer.writeLong("startOff", startOff)) return false; - commState.idx++; + state++; case 4: - if (!commState.putInt("status", status)) + if (!writer.writeInt("status", status)) return false; - commState.idx++; + state++; } @@ -334,48 +334,48 @@ public boolean regionEqual(GridGgfsFileAffinityRange other) { /** {@inheritDoc} */ @SuppressWarnings("fallthrough") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); - switch (commState.idx) { + switch (state) { case 0: - affKey = commState.getGridUuid("affKey"); + affKey = reader.readIgniteUuid("affKey"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 1: - done = commState.getBoolean("done"); + done = reader.readBoolean("done"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 2: - endOff = commState.getLong("endOff"); + endOff = reader.readLong("endOff"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 3: - startOff = commState.getLong("startOff"); + startOff = reader.readLong("startOff"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 4: - status = commState.getInt("status"); + status = reader.readInt("status"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerRequest.java index 3ecac2f3a70cc..978a2d66a8ec9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerRequest.java @@ -101,51 +101,30 @@ public Collection fragmentRanges() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 0: - if (!commState.putGridUuid("fileId", fileId)) + if (!writer.writeIgniteUuid("fileId", fileId)) return false; - commState.idx++; + state++; case 1: - if (fragmentRanges != null) { - if (commState.it == null) { - if (!commState.putInt(null, fragmentRanges.size())) - return false; - - commState.it = fragmentRanges.iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - if (!commState.putMessage(null, (GridGgfsFileAffinityRange)commState.cur)) - return false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeCollection("fragmentRanges", fragmentRanges, GridGgfsFileAffinityRange.class)) + return false; - commState.idx++; + state++; } @@ -155,49 +134,27 @@ public Collection fragmentRanges() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 0: - fileId = commState.getGridUuid("fileId"); + fileId = reader.readIgniteUuid("fileId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 1: - if (commState.readSize == -1) { - int _val = commState.getInt(null); - - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } + fragmentRanges = reader.readCollection("fragmentRanges", GridGgfsFileAffinityRange.class); - if (commState.readSize >= 0) { - if (fragmentRanges == null) - fragmentRanges = new ArrayList<>(commState.readSize); - - for (int i = commState.readItems; i < commState.readSize; i++) { - GridGgfsFileAffinityRange _val = (GridGgfsFileAffinityRange)commState.getMessage(null); - - if (!commState.lastRead()) - return false; - - fragmentRanges.add((GridGgfsFileAffinityRange)_val); - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerResponse.java index a842e9c98c9da..5a90b3c7c60d0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerResponse.java @@ -76,24 +76,24 @@ public IgniteUuid fileId() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 0: - if (!commState.putGridUuid("fileId", fileId)) + if (!writer.writeIgniteUuid("fileId", fileId)) return false; - commState.idx++; + state++; } @@ -103,19 +103,19 @@ public IgniteUuid fileId() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 0: - fileId = commState.getGridUuid("fileId"); + fileId = reader.readIgniteUuid("fileId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsSyncMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsSyncMessage.java index a632e02363681..c7c1e77053684 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsSyncMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsSyncMessage.java @@ -94,30 +94,30 @@ public boolean response() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); if (!super.writeTo(buf)) return false; - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 0: - if (!commState.putLong("order", order)) + if (!writer.writeLong("order", order)) return false; - commState.idx++; + state++; case 1: - if (!commState.putBoolean("res", res)) + if (!writer.writeBoolean("res", res)) return false; - commState.idx++; + state++; } @@ -127,27 +127,27 @@ public boolean response() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); if (!super.readFrom(buf)) return false; - switch (commState.idx) { + switch (state) { case 0: - order = commState.getLong("order"); + order = reader.readLong("order"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 1: - res = commState.getBoolean("res"); + res = reader.readBoolean("res"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java index 6223639f1e873..71dfcf94e255c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java @@ -65,13 +65,13 @@ public byte[] bytes() { @Override public boolean writeTo(ByteBuffer buf) { stream.setBuffer(buf); - if (!commState.typeWritten) { + if (!typeWritten) { if (!buf.hasRemaining()) return false; stream.writeByte(directType()); - commState.typeWritten = true; + typeWritten = true; } stream.writeByteArray(bytes, 0, bytes.length); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java index 57f2bd163a752..e598f66716086 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java @@ -48,13 +48,13 @@ public GridClientHandshakeResponseWrapper(byte code) { /** {@inheritDoc} */ @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } return true; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMessageWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMessageWrapper.java index 4d40c3ed8ae1f..746a40f5c8203 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMessageWrapper.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMessageWrapper.java @@ -136,23 +136,23 @@ public void message(ByteBuffer msg) { @Override public boolean writeTo(ByteBuffer buf) { stream.setBuffer(buf); - if (!commState.typeWritten) { + if (!typeWritten) { if (stream.remaining() < 1) return false; stream.writeByte(directType()); - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 0: if (stream.remaining() < 4) return false; stream.writeInt(msgSize); - commState.idx++; + state++; case 1: if (stream.remaining() < 8) @@ -160,7 +160,7 @@ public void message(ByteBuffer msg) { stream.writeLong(reqId); - commState.idx++; + state++; case 2: if (stream.remaining() < 16) @@ -168,7 +168,7 @@ public void message(ByteBuffer msg) { stream.writeByteArray(U.uuidToBytes(clientId), 0, 16); - commState.idx++; + state++; case 3: if (stream.remaining() < 16) @@ -176,12 +176,12 @@ public void message(ByteBuffer msg) { stream.writeByteArray(U.uuidToBytes(destId), 0, 16); - commState.idx++; + state++; case 4: stream.writeByteArray(msg.array(), msg.position(), msg.remaining()); - commState.idx++; + state++; } @@ -192,7 +192,7 @@ public void message(ByteBuffer msg) { @Override public boolean readFrom(ByteBuffer buf) { stream.setBuffer(buf); - switch (commState.idx) { + switch (state) { case 0: if (stream.remaining() < 4) return false; @@ -202,7 +202,7 @@ public void message(ByteBuffer msg) { if (msgSize == 0) // Ping message. return true; - commState.idx++; + state++; case 1: if (stream.remaining() < 8) @@ -210,7 +210,7 @@ public void message(ByteBuffer msg) { reqId = stream.readLong(); - commState.idx++; + state++; case 2: if (stream.remaining() < 16) @@ -218,7 +218,7 @@ public void message(ByteBuffer msg) { clientId = U.bytesToUuid(stream.readByteArray(16), 0); - commState.idx++; + state++; case 3: if (stream.remaining() < 16) @@ -226,7 +226,7 @@ public void message(ByteBuffer msg) { destId = U.bytesToUuid(stream.readByteArray(16), 0); - commState.idx++; + state++; case 4: byte[] msg0 = stream.readByteArray(msgSize); @@ -236,7 +236,7 @@ public void message(ByteBuffer msg) { msg = ByteBuffer.wrap(msg0); - commState.idx++; + state++; } return true; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacketWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacketWrapper.java index be953672259e8..ca8e80483b97a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacketWrapper.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacketWrapper.java @@ -34,21 +34,21 @@ public class GridClientPingPacketWrapper extends MessageAdapter { /** {@inheritDoc} */ @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 0: - if (!commState.putInt("size", size)) + if (!writer.writeInt("size", size)) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultRequest.java index 8df3008fd3ccd..637fa805e8638 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultRequest.java @@ -120,27 +120,27 @@ public void topic(String topic) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 0: - if (!commState.putGridUuid("taskId", taskId)) + if (!writer.writeIgniteUuid("taskId", taskId)) return false; - commState.idx++; + state++; case 1: - if (!commState.putByteArray("topicBytes", topicBytes)) + if (!writer.writeByteArray("topicBytes", topicBytes)) return false; - commState.idx++; + state++; } @@ -150,24 +150,24 @@ public void topic(String topic) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); - switch (commState.idx) { + switch (state) { case 0: - taskId = commState.getGridUuid("taskId"); + taskId = reader.readIgniteUuid("taskId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 1: - topicBytes = commState.getByteArray("topicBytes"); + topicBytes = reader.readByteArray("topicBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java index 6808f1adeb6be..384cfb3c7e082 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java @@ -140,39 +140,39 @@ public void error(String err) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 0: - if (!commState.putString("err", err)) + if (!writer.writeString("err", err)) return false; - commState.idx++; + state++; case 1: - if (!commState.putBoolean("finished", finished)) + if (!writer.writeBoolean("finished", finished)) return false; - commState.idx++; + state++; case 2: - if (!commState.putBoolean("found", found)) + if (!writer.writeBoolean("found", found)) return false; - commState.idx++; + state++; case 3: - if (!commState.putByteArray("resBytes", resBytes)) + if (!writer.writeByteArray("resBytes", resBytes)) return false; - commState.idx++; + state++; } @@ -182,40 +182,40 @@ public void error(String err) { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); - switch (commState.idx) { + switch (state) { case 0: - err = commState.getString("err"); + err = reader.readString("err"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 1: - finished = commState.getBoolean("finished"); + finished = reader.readBoolean("finished"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 2: - found = commState.getBoolean("found"); + found = reader.readBoolean("found"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 3: - resBytes = commState.getByteArray("resBytes"); + resBytes = reader.readByteArray("resBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java index ae0d6385528dc..d086efe812a47 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java @@ -69,13 +69,13 @@ public GridMemcachedMessageWrapper(GridMemcachedMessage msg, Marshaller jdkMarsh @Override public boolean writeTo(ByteBuffer buf) { stream.setBuffer(buf); - if (!commState.typeWritten) { + if (!typeWritten) { if (!buf.hasRemaining()) return false; stream.writeByte(directType()); - commState.typeWritten = true; + typeWritten = true; } stream.writeByteArray(bytes, 0, bytes.length); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerCancelRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerCancelRequest.java index aba17f31c6ef2..4f67c3abee23d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerCancelRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerCancelRequest.java @@ -74,21 +74,21 @@ public IgniteUuid cancelledFutureId() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 0: - if (!commState.putGridUuid("cancelledFutId", cancelledFutId)) + if (!writer.writeIgniteUuid("cancelledFutId", cancelledFutId)) return false; - commState.idx++; + state++; } @@ -98,16 +98,16 @@ public IgniteUuid cancelledFutureId() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); - switch (commState.idx) { + switch (state) { case 0: - cancelledFutId = commState.getGridUuid("cancelledFutId"); + cancelledFutId = reader.readIgniteUuid("cancelledFutId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerExecutionRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerExecutionRequest.java index e10ef047d0478..90e7163128fc8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerExecutionRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerExecutionRequest.java @@ -175,89 +175,57 @@ public byte[] batchBytes() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 0: - if (!commState.putByteArray("batchBytes", batchBytes)) + if (!writer.writeByteArray("batchBytes", batchBytes)) return false; - commState.idx++; + state++; case 1: - if (!commState.putGridUuid("clsLdrId", clsLdrId)) + if (!writer.writeIgniteUuid("clsLdrId", clsLdrId)) return false; - commState.idx++; + state++; case 2: - if (!commState.putEnum("depMode", depMode)) + if (!writer.writeEnum("depMode", depMode)) return false; - commState.idx++; + state++; case 3: - if (!commState.putBoolean("forceLocDep", forceLocDep)) + if (!writer.writeBoolean("forceLocDep", forceLocDep)) return false; - commState.idx++; + state++; case 4: - if (ldrParticipants != null) { - if (commState.it == null) { - if (!commState.putInt(null, ldrParticipants.size())) - return false; - - commState.it = ldrParticipants.entrySet().iterator(); - } - - while (commState.it.hasNext() || commState.cur != NULL) { - if (commState.cur == NULL) - commState.cur = commState.it.next(); - - Map.Entry e = (Map.Entry)commState.cur; - - if (!commState.keyDone) { - if (!commState.putUuid(null, e.getKey())) - return false; - - commState.keyDone = true; - } - - if (!commState.putGridUuid(null, e.getValue())) - return false; - - commState.keyDone = false; - - commState.cur = NULL; - } - - commState.it = null; - } else { - if (!commState.putInt(null, -1)) - return false; - } + if (!writer.writeMap("ldrParticipants", ldrParticipants, UUID.class, IgniteUuid.class)) + return false; - commState.idx++; + state++; case 5: - if (!commState.putString("sampleClsName", sampleClsName)) + if (!writer.writeString("sampleClsName", sampleClsName)) return false; - commState.idx++; + state++; case 6: - if (!commState.putString("userVer", userVer)) + if (!writer.writeString("userVer", userVer)) return false; - commState.idx++; + state++; } @@ -267,101 +235,64 @@ public byte[] batchBytes() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); - switch (commState.idx) { + switch (state) { case 0: - batchBytes = commState.getByteArray("batchBytes"); + batchBytes = reader.readByteArray("batchBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 1: - clsLdrId = commState.getGridUuid("clsLdrId"); + clsLdrId = reader.readIgniteUuid("clsLdrId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 2: - byte depMode0 = commState.getByte("depMode"); + depMode = reader.readEnum("depMode", DeploymentMode.class); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - depMode = DeploymentMode.fromOrdinal(depMode0); - - commState.idx++; + state++; case 3: - forceLocDep = commState.getBoolean("forceLocDep"); + forceLocDep = reader.readBoolean("forceLocDep"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 4: - if (commState.readSize == -1) { - int _val = commState.getInt(null); + ldrParticipants = reader.readMap("ldrParticipants", UUID.class, IgniteUuid.class); - if (!commState.lastRead()) - return false; - commState.readSize = _val; - } - - if (commState.readSize >= 0) { - if (ldrParticipants == null) - ldrParticipants = new HashMap<>(commState.readSize, 1.0f); - - for (int i = commState.readItems; i < commState.readSize; i++) { - if (!commState.keyDone) { - UUID _val = commState.getUuid(null); - - if (!commState.lastRead()) - return false; - - commState.cur = _val; - commState.keyDone = true; - } - - IgniteUuid _val = commState.getGridUuid(null); - - if (!commState.lastRead()) - return false; - - ldrParticipants.put((UUID)commState.cur, _val); - - commState.keyDone = false; - - commState.readItems++; - } - } - - commState.readSize = -1; - commState.readItems = 0; - commState.cur = null; + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 5: - sampleClsName = commState.getString("sampleClsName"); + sampleClsName = reader.readString("sampleClsName"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 6: - userVer = commState.getString("userVer"); + userVer = reader.readString("userVer"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerResponse.java index a9c05c55ba571..fc6da7fa8f74d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/streamer/GridStreamerResponse.java @@ -95,27 +95,27 @@ public byte[] errorBytes() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 0: - if (!commState.putByteArray("errBytes", errBytes)) + if (!writer.writeByteArray("errBytes", errBytes)) return false; - commState.idx++; + state++; case 1: - if (!commState.putGridUuid("futId", futId)) + if (!writer.writeIgniteUuid("futId", futId)) return false; - commState.idx++; + state++; } @@ -125,24 +125,24 @@ public byte[] errorBytes() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); - switch (commState.idx) { + switch (state) { case 0: - errBytes = commState.getByteArray("errBytes"); + errBytes = reader.readByteArray("errBytes"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 1: - futId = commState.getGridUuid("futId"); + futId = reader.readIgniteUuid("futId"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/version/GridVersionConverter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/version/GridVersionConverter.java deleted file mode 100644 index 9895f431eb5e6..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/version/GridVersionConverter.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.version; - -import org.apache.ignite.internal.direct.*; - -import java.nio.*; - -/** - * Version converter. - */ -public abstract class GridVersionConverter { - /** State. */ - protected final GridTcpCommunicationMessageState commState = new GridTcpCommunicationMessageState(); - - /** - * Writes delta between two versions. - * - * @param buf Buffer to write to. - * @return Whether delta was fully written. - */ - public abstract boolean writeTo(ByteBuffer buf); - - /** - * Reads delta between two versions. - * - * @param buf Buffer to read from. - * @return Whether delta was fully read. - */ - public abstract boolean readFrom(ByteBuffer buf); -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridByteArrayList.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridByteArrayList.java index 9cff49ca0a41e..8ec78d5bae501 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridByteArrayList.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridByteArrayList.java @@ -408,12 +408,57 @@ public InputStream inputStream() { /** {@inheritDoc} */ @Override public boolean writeTo(ByteBuffer buf) { - return false; // TODO: implement. + writer.setBuffer(buf); + + if (!typeWritten) { + if (!writer.writeByte(null, directType())) + return false; + + typeWritten = true; + } + + switch (state) { + case 0: + if (!writer.writeByteArray("data", data)) + return false; + + state++; + + case 1: + if (!writer.writeInt("size", size)) + return false; + + state++; + + } + + return true; } /** {@inheritDoc} */ @Override public boolean readFrom(ByteBuffer buf) { - return false; // TODO: implement. + reader.setBuffer(buf); + + switch (state) { + case 0: + data = reader.readByteArray("data"); + + if (!reader.isLastRead()) + return false; + + state++; + + case 1: + size = reader.readInt("size"); + + if (!reader.isLastRead()) + return false; + + state++; + + } + + return true; } /** {@inheritDoc} */ @@ -423,12 +468,19 @@ public InputStream inputStream() { /** {@inheritDoc} */ @Override public MessageAdapter clone() { - return null; // TODO: implement. + GridByteArrayList _clone = new GridByteArrayList(); + + clone0(_clone); + + return _clone; } /** {@inheritDoc} */ @Override protected void clone0(MessageAdapter _msg) { - // TODO: implement. + GridByteArrayList _clone = (GridByteArrayList)_msg; + + _clone.data = data; + _clone.size = size; } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridLongList.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridLongList.java index 25254676ed32c..5dce4e9db22f4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridLongList.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridLongList.java @@ -506,12 +506,57 @@ public void pop(int cnt) { /** {@inheritDoc} */ @Override public boolean writeTo(ByteBuffer buf) { - return false; // TODO: implement. + writer.setBuffer(buf); + + if (!typeWritten) { + if (!writer.writeByte(null, directType())) + return false; + + typeWritten = true; + } + + switch (state) { + case 0: + if (!writer.writeLongArray("arr", arr)) + return false; + + state++; + + case 1: + if (!writer.writeInt("idx", idx)) + return false; + + state++; + + } + + return true; } /** {@inheritDoc} */ @Override public boolean readFrom(ByteBuffer buf) { - return false; // TODO: implement. + reader.setBuffer(buf); + + switch (state) { + case 0: + arr = reader.readLongArray("arr"); + + if (!reader.isLastRead()) + return false; + + state++; + + case 1: + idx = reader.readInt("idx"); + + if (!reader.isLastRead()) + return false; + + state++; + + } + + return true; } /** {@inheritDoc} */ @@ -521,11 +566,18 @@ public void pop(int cnt) { /** {@inheritDoc} */ @Override public MessageAdapter clone() { - return null; // TODO: implement. + GridLongList _clone = new GridLongList(); + + clone0(_clone); + + return _clone; } /** {@inheritDoc} */ @Override protected void clone0(MessageAdapter _msg) { - // TODO: implement. + GridLongList _clone = (GridLongList)_msg; + + _clone.arr = arr; + _clone.idx = idx; } } diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageAdapter.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageAdapter.java index 2234698b4a75e..d393e1663c3ad 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageAdapter.java @@ -17,24 +17,13 @@ package org.apache.ignite.plugin.extensions.communication; -import org.apache.ignite.internal.direct.*; - import java.io.*; import java.nio.*; -import java.util.*; /** * Communication message adapter. */ public abstract class MessageAdapter implements Serializable, Cloneable { - /** */ - // TODO: remove - protected static final Object NULL = new Object(); - - /** */ - // TODO: remove - protected final GridTcpCommunicationMessageState commState = new GridTcpCommunicationMessageState(); - /** Writer. */ protected MessageWriter writer; @@ -63,17 +52,6 @@ public final void setReader(MessageReader reader) { this.reader = reader; } - /** - * @param buf Buffer. - */ - public final void setBuffer(ByteBuffer buf) { - if (writer != null) - writer.setBuffer(buf); - - if (reader != null) - reader.setBuffer(buf); - } - /** * @param buf Byte buffer. * @return Whether message was fully written. @@ -108,29 +86,4 @@ public final void setBuffer(ByteBuffer buf) { public boolean skipRecovery() { return false; } - - /** - * @param arr Array. - * @return Array iterator. - */ - protected final Iterator arrayIterator(final Object[] arr) { - return new Iterator() { - private int idx; - - @Override public boolean hasNext() { - return idx < arr.length; - } - - @Override public Object next() { - if (!hasNext()) - throw new NoSuchElementException(); - - return arr[idx++]; - } - - @Override public void remove() { - throw new UnsupportedOperationException(); - } - }; - } } diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java index eca6afbca06e8..db4d856eae322 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReader.java @@ -68,7 +68,7 @@ public interface MessageReader { public , T> C readCollection(String name, Class itemCls); - public Map readMap(String name, Class keyCls, Class valCls); + public , K, V> M readMap(String name, Class keyCls, Class valCls); public boolean isLastRead(); } diff --git a/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java b/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java index d468c281a8736..9a3a0f0d3c2cf 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingRequest.java @@ -74,21 +74,21 @@ int delta() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 0: - if (!commState.putInt("delta", delta)) + if (!writer.writeInt("delta", delta)) return false; - commState.idx++; + state++; } @@ -98,16 +98,16 @@ int delta() { /** {@inheritDoc} */ @SuppressWarnings("all") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); - switch (commState.idx) { + switch (state) { case 0: - delta = commState.getInt("delta"); + delta = reader.readInt("delta"); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridCommunicationSendMessageSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridCommunicationSendMessageSelfTest.java index ce1d7654cec5c..d99cdfdb89366 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridCommunicationSendMessageSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridCommunicationSendMessageSelfTest.java @@ -156,9 +156,9 @@ private static class TestMessage extends MessageAdapter { /** {@inheritDoc} */ @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); - return commState.putByte(null, directType()); + return writer.writeByte(null, directType()); } /** {@inheritDoc} */ diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/GridTestMessage.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/GridTestMessage.java index e1244a0b69a0c..9089e7c454acc 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/communication/GridTestMessage.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/GridTestMessage.java @@ -116,39 +116,39 @@ public byte[] payload() { /** {@inheritDoc} */ @SuppressWarnings("fallthrough") @Override public boolean writeTo(ByteBuffer buf) { - commState.setBuffer(buf); + writer.setBuffer(buf); - if (!commState.typeWritten) { - if (!commState.putByte(null, directType())) + if (!typeWritten) { + if (!writer.writeByte(null, directType())) return false; - commState.typeWritten = true; + typeWritten = true; } - switch (commState.idx) { + switch (state) { case 0: - if (!commState.putUuid(null, srcNodeId)) + if (!writer.writeUuid(null, srcNodeId)) return false; - commState.idx++; + state++; case 1: - if (!commState.putLong(null, msgId)) + if (!writer.writeLong(null, msgId)) return false; - commState.idx++; + state++; case 2: - if (!commState.putLong(null, resId)) + if (!writer.writeLong(null, resId)) return false; - commState.idx++; + state++; case 3: - if (!commState.putByteArray(null, payload)) + if (!writer.writeByteArray(null, payload)) return false; - commState.idx++; + state++; } return true; @@ -157,40 +157,40 @@ public byte[] payload() { /** {@inheritDoc} */ @SuppressWarnings("fallthrough") @Override public boolean readFrom(ByteBuffer buf) { - commState.setBuffer(buf); + reader.setBuffer(buf); - switch (commState.idx) { + switch (state) { case 0: - srcNodeId = commState.getUuid(null); + srcNodeId = reader.readUuid(null); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; case 1: - if (buf.remaining() < 8) - return false; + msgId = reader.readLong(null); - msgId = commState.getLong(null); + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 2: - if (buf.remaining() < 8) - return false; + resId = reader.readLong(null); - resId = commState.getLong(null); + if (!reader.isLastRead()) + return false; - commState.idx++; + state++; case 3: - payload = commState.getByteArray(null); + payload = reader.readByteArray(null); - if (!commState.lastRead()) + if (!reader.isLastRead()) return false; - commState.idx++; + state++; } return true; From 01b20a695ce7b5207888bf2dca998942d4224440 Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Sat, 7 Feb 2015 23:07:34 -0800 Subject: [PATCH 48/95] IGNITE-61 - Direct marshalling --- .../CommunicationMessageCodeGenerator.java | 21 +- .../ignite/internal/direct/DirectUtils.java | 346 ------------------ .../managers/communication/GridIoMessage.java | 4 +- 3 files changed, 20 insertions(+), 351 deletions(-) delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/direct/DirectUtils.java diff --git a/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java index 45a383c5d7baf..4a81a9284301b 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java @@ -10,6 +10,7 @@ package org.apache.ignite.codegen; import org.apache.ignite.internal.*; +import org.apache.ignite.internal.managers.communication.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; import org.apache.ignite.plugin.extensions.communication.*; @@ -75,6 +76,9 @@ public class CommunicationMessageCodeGenerator { /** */ private final Map, Integer> fieldCnt = new HashMap<>(); + /** */ + private Class curCls; + /** */ private List fields; @@ -233,6 +237,8 @@ else if (line.startsWith(TAB + "}")) { public void generate(Class cls) throws Exception { assert cls != null; + curCls = cls; + write.clear(); read.clear(); clone.clear(); @@ -282,8 +288,14 @@ public void generate(Class cls) throws Exception { for (Field field : cloningFields) { String name = field.getName(); + Class type = field.getType(); + + String res = name; - clone0.add(builder().a("_clone.").a(name).a(" = ").a(name).a(";").toString()); + if (curCls.equals(GridIoMessage.class) && BASE_CLS.isAssignableFrom(type)) + res = name + " != null ? (" + type.getSimpleName() + ")" + name + ".clone() : null"; + + clone0.add(builder().a("_clone.").a(name).a(" = ").a(res).a(";").toString()); } } @@ -515,8 +527,11 @@ else if (type == IgniteUuid.class) returnFalseIfFailed(write, "writer.writeIgniteUuid", field, name); else if (type.isEnum()) returnFalseIfFailed(write, "writer.writeEnum", field, name); - else if (BASE_CLS.isAssignableFrom(type)) - returnFalseIfFailed(write, "writer.writeMessage", field, name + " != null ? " + name + ".clone() : null"); + else if (BASE_CLS.isAssignableFrom(type)) { + String arg = curCls.equals(GridIoMessage.class) ? name : name + " != null ? " + name + ".clone() : null"; + + returnFalseIfFailed(write, "writer.writeMessage", field, arg); + } else if (type.isArray()) { returnFalseIfFailed(write, "writer.writeObjectArray", field, name, type.getComponentType().getSimpleName() + ".class"); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectUtils.java deleted file mode 100644 index d0d966fc87c58..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectUtils.java +++ /dev/null @@ -1,346 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.direct; - -import org.apache.ignite.internal.processors.cache.*; -import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.*; -import org.apache.ignite.internal.processors.cache.version.*; -import org.apache.ignite.internal.processors.clock.*; -import org.apache.ignite.internal.util.*; -import org.apache.ignite.lang.*; -import sun.misc.*; - -import java.util.*; - -/** - * Direct marshalling utility methods. - */ -public class DirectUtils { - /** */ - private static final Unsafe UNSAFE = GridUnsafe.unsafe(); - - /** */ - private static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class); - - /** - * Do not instantiate. - */ - private DirectUtils() { - // No-op. - } - - /** - * @param uuid {@link UUID}. - * @return Array. - */ - public static byte[] uuidToArray(UUID uuid) { - byte[] arr = null; - - if (uuid != null) { - arr = new byte[16]; - - UNSAFE.putLong(arr, BYTE_ARR_OFF, uuid.getMostSignificantBits()); - UNSAFE.putLong(arr, BYTE_ARR_OFF + 8, uuid.getLeastSignificantBits()); - } - - return arr; - } - - /** - * @param arr Array. - * @return {@link UUID}. - */ - public static UUID arrayToUuid(byte[] arr) { - if (arr == null) - return null; - else { - long most = UNSAFE.getLong(arr, BYTE_ARR_OFF); - long least = UNSAFE.getLong(arr, BYTE_ARR_OFF + 8); - - return new UUID(most, least); - } - } - - /** - * @param uuid {@link IgniteUuid}. - * @return Array. - */ - public static byte[] gridUuidToArray(IgniteUuid uuid) { - byte[] arr = null; - - if (uuid != null) { - arr = new byte[24]; - - UNSAFE.putLong(arr, BYTE_ARR_OFF, uuid.globalId().getMostSignificantBits()); - UNSAFE.putLong(arr, BYTE_ARR_OFF + 8, uuid.globalId().getLeastSignificantBits()); - UNSAFE.putLong(arr, BYTE_ARR_OFF + 16, uuid.localId()); - } - - return arr; - } - - /** - * @param arr Array. - * @return {@link IgniteUuid}. - */ - public static IgniteUuid arrayToIgniteUuid(byte[] arr) { - if (arr == null) - return null; - else { - long most = UNSAFE.getLong(arr, BYTE_ARR_OFF); - long least = UNSAFE.getLong(arr, BYTE_ARR_OFF + 8); - long loc = UNSAFE.getLong(arr, BYTE_ARR_OFF + 16); - - return new IgniteUuid(new UUID(most, least), loc); - } - } - - /** - * @param ver {@link GridClockDeltaVersion}. - * @return Array. - */ - public static byte[] clockDeltaVersionToArray(GridClockDeltaVersion ver) { - byte[] arr = null; - - if (ver != null) { - arr = new byte[16]; - - UNSAFE.putLong(arr, BYTE_ARR_OFF, ver.version()); - UNSAFE.putLong(arr, BYTE_ARR_OFF + 8, ver.topologyVersion()); - } - - return arr; - } - - /** - * @param arr Array. - * @return {@link GridClockDeltaVersion}. - */ - public static GridClockDeltaVersion arrayToClockDeltaVersion(byte[] arr) { - if (arr == null) - return null; - else { - long ver = UNSAFE.getLong(arr, BYTE_ARR_OFF); - long topVer = UNSAFE.getLong(arr, BYTE_ARR_OFF + 8); - - return new GridClockDeltaVersion(ver, topVer); - } - } - - /** - * @param list {@link GridByteArrayList}. - * @return Array. - */ - public static byte[] byteArrayListToArray(GridByteArrayList list) { - return list != null ? list.array() : null; - } - - /** - * @param arr Array. - * @return {@link GridByteArrayList}. - */ - public static GridByteArrayList arrayToByteArrayList(byte[] arr) { - return arr != null ? new GridByteArrayList(arr) : null; - } - - /** - * @param list {@link GridLongList}. - * @return Array. - */ - public static long[] longListToArray(GridLongList list) { - return list != null ? list.array() : null; - } - - /** - * @param arr Array. - * @return {@link GridLongList}. - */ - public static GridLongList arrayToLongList(long[] arr) { - return arr != null ? new GridLongList(arr) : null; - } - - /** - * @param ver {@link GridCacheVersion}. - * @return Array. - */ - public static byte[] cacheVersionToArray(GridCacheVersion ver) { - byte[] arr = null; - - if (ver != null) { - arr = new byte[24]; - - UNSAFE.putInt(arr, BYTE_ARR_OFF, ver.topologyVersion()); - UNSAFE.putInt(arr, BYTE_ARR_OFF + 4, ver.nodeOrderAndDrIdRaw()); - UNSAFE.putLong(arr, BYTE_ARR_OFF + 8, ver.globalTime()); - UNSAFE.putLong(arr, BYTE_ARR_OFF + 16, ver.order()); - } - - return arr; - } - - /** - * @param arr Array. - * @return {@link GridCacheVersion}. - */ - public static GridCacheVersion arrayToCacheVersion(byte[] arr) { - if (arr == null) - return null; - else { - int topVerDrId = UNSAFE.getInt(arr, BYTE_ARR_OFF); - int nodeOrder = UNSAFE.getInt(arr, BYTE_ARR_OFF + 4); - long globalTime = UNSAFE.getLong(arr, BYTE_ARR_OFF + 8); - long order = UNSAFE.getLong(arr, BYTE_ARR_OFF + 16); - - return new GridCacheVersion(topVerDrId, nodeOrder, globalTime, order); - } - } - - /** - * @param id {@link GridDhtPartitionExchangeId}. - * @return Array. - */ - public static byte[] dhtPartitionExchangeIdToArray(GridDhtPartitionExchangeId id) { - byte[] arr = null; - - if (id != null) { - arr = new byte[28]; - - UNSAFE.putLong(arr, BYTE_ARR_OFF, id.nodeId().getMostSignificantBits()); - UNSAFE.putLong(arr, BYTE_ARR_OFF + 8, id.nodeId().getLeastSignificantBits()); - UNSAFE.putInt(arr, BYTE_ARR_OFF + 16, id.event()); - UNSAFE.putLong(arr, BYTE_ARR_OFF + 20, id.topologyVersion()); - } - - return arr; - } - - /** - * @param arr Array. - * @return {@link GridDhtPartitionExchangeId}. - */ - public static GridDhtPartitionExchangeId arrayToDhtPartitionExchangeId(byte[] arr) { - if (arr == null) - return null; - else { - long most = UNSAFE.getLong(arr, BYTE_ARR_OFF); - long least = UNSAFE.getLong(arr, BYTE_ARR_OFF + 8); - int evt = UNSAFE.getInt(arr, BYTE_ARR_OFF + 16); - long topVer = UNSAFE.getLong(arr, BYTE_ARR_OFF + 20); - - return new GridDhtPartitionExchangeId(new UUID(most, least), evt, topVer); - } - } - - /** - * @param bytes {@link GridCacheValueBytes}. - * @return Array. - */ - public static byte[] valueBytesToArray(GridCacheValueBytes bytes) { - byte[] arr = null; - - if (bytes != null) { - byte[] bytes0 = bytes.get(); - - if (bytes0 != null) { - int len = bytes0.length; - - arr = new byte[len + 2]; - - UNSAFE.putBoolean(arr, BYTE_ARR_OFF, true); - UNSAFE.copyMemory(bytes0, BYTE_ARR_OFF, arr, BYTE_ARR_OFF + 1, len); - UNSAFE.putBoolean(arr, BYTE_ARR_OFF + 1 + len, bytes.isPlain()); - } - else { - arr = new byte[1]; - - UNSAFE.putBoolean(arr, BYTE_ARR_OFF, false); - } - } - - return arr; - } - - /** - * @param arr Array. - * @return {@link GridCacheValueBytes}. - */ - public static GridCacheValueBytes arrayToValueBytes(byte[] arr) { - if (arr == null) - return null; - else { - boolean notNull = UNSAFE.getBoolean(arr, BYTE_ARR_OFF); - - if (notNull) { - int len = arr.length - 2; - - assert len >= 0 : len; - - byte[] bytesArr = new byte[len]; - - UNSAFE.copyMemory(arr, BYTE_ARR_OFF + 1, bytesArr, BYTE_ARR_OFF, len); - - boolean isPlain = UNSAFE.getBoolean(arr, BYTE_ARR_OFF + 1 + len); - - return new GridCacheValueBytes(bytesArr, isPlain); - } - else - return new GridCacheValueBytes(); - } - } - - /** - * @param str {@link String}. - * @return Array. - */ - public static byte[] stringToArray(String str) { - return str != null ? str.getBytes() : null; - } - - /** - * @param arr Array. - * @return {@link String}. - */ - public static String arrayToString(byte[] arr) { - return arr != null ? new String(arr) : null; - } - - /** - * @param bits {@link BitSet}. - * @return Array. - */ - public static long[] bitSetToArray(BitSet bits) { - return bits != null ? bits.toLongArray() : null; - } - - /** - * @param arr Array. - * @return {@link BitSet}. - */ - public static BitSet arrayToBitSet(long[] arr) { - return arr != null ? BitSet.valueOf(arr) : null; - } - -// /** -// * @param name Field name. -// * @param e Enum. -// * @return Whether value was fully written. -// */ -// protected boolean putEnum(String name, @Nullable Enum e) { -// return writer.writeByte(name, e != null ? (byte)e.ordinal() : -1); -// } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java index 27d64be594c7b..c77f1745f7b97 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java @@ -200,7 +200,7 @@ boolean isOrdered() { _clone.ordered = ordered; _clone.timeout = timeout; _clone.skipOnTimeout = skipOnTimeout; - _clone.msg = msg; + _clone.msg = msg != null ? (MessageAdapter)msg.clone() : null; } /** {@inheritDoc} */ @@ -217,7 +217,7 @@ boolean isOrdered() { switch (state) { case 0: - if (!writer.writeMessage("msg", msg != null ? msg.clone() : null)) + if (!writer.writeMessage("msg", msg)) return false; state++; From 70c8f23d1a1da505ec35e57564c59c51f82901fc Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Sat, 7 Feb 2015 23:15:37 -0800 Subject: [PATCH 49/95] IGNITE-61 - Direct marshalling --- .../GridTcpCommunicationMessageFactory.java | 51 +++++++++++++++++-- .../processors/cache/GridCacheValueBytes.java | 3 +- .../preloader/GridDhtPartitionExchangeId.java | 3 +- .../cache/version/GridCacheVersion.java | 3 +- .../clock/GridClockDeltaVersion.java | 3 +- .../processors/fs/IgniteFsProcessor.java | 39 -------------- .../internal/util/GridByteArrayList.java | 3 +- .../ignite/internal/util/GridLongList.java | 3 +- 8 files changed, 59 insertions(+), 49 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/GridTcpCommunicationMessageFactory.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/GridTcpCommunicationMessageFactory.java index d3091e6ed804e..b1cbe7e6608bf 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/direct/GridTcpCommunicationMessageFactory.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/GridTcpCommunicationMessageFactory.java @@ -29,13 +29,16 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.*; import org.apache.ignite.internal.processors.cache.distributed.near.*; import org.apache.ignite.internal.processors.cache.query.*; +import org.apache.ignite.internal.processors.cache.version.*; import org.apache.ignite.internal.processors.clock.*; import org.apache.ignite.internal.processors.continuous.*; import org.apache.ignite.internal.processors.dataload.*; +import org.apache.ignite.internal.processors.fs.*; import org.apache.ignite.internal.processors.rest.client.message.*; import org.apache.ignite.internal.processors.rest.handlers.task.*; import org.apache.ignite.internal.processors.rest.protocols.tcp.*; import org.apache.ignite.internal.processors.streamer.*; +import org.apache.ignite.internal.util.*; import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.spi.collision.jobstealing.*; import org.apache.ignite.spi.communication.tcp.*; @@ -56,7 +59,7 @@ public class GridTcpCommunicationMessageFactory { private static final Map CUSTOM = new ConcurrentHashMap8<>(); /** */ - public static final int MAX_COMMON_TYPE = 82; + public static final int MAX_COMMON_TYPE = 88; static { registerCommon(new GridTcpCommunicationMessageProducer() { @@ -254,7 +257,29 @@ public class GridTcpCommunicationMessageFactory { case 63: return new GridDataLoadResponse(); - // 64-71: IgniteFS messages. + case 64: + return new GridGgfsAckMessage(); + + case 65: + return new GridGgfsBlockKey(); + + case 66: + return new GridGgfsBlocksMessage(); + + case 67: + return new GridGgfsDeleteMessage(); + + case 68: + return new GridGgfsFileAffinityRange(); + + case 69: + return new GridGgfsFragmentizerRequest(); + + case 70: + return new GridGgfsFragmentizerResponse(); + + case 71: + return new GridGgfsSyncMessage(); case 72: return new GridClientHandshakeRequestWrapper(); @@ -289,6 +314,24 @@ public class GridTcpCommunicationMessageFactory { case 82: return new JobStealingRequest(); + case 83: + return new GridClockDeltaVersion(); + + case 84: + return new GridByteArrayList(); + + case 85: + return new GridLongList(); + + case 86: + return new GridCacheVersion(); + + case 87: + return new GridDhtPartitionExchangeId(); + + case 88: + return new GridCacheValueBytes(); + default: assert false : "Invalid message type."; @@ -298,8 +341,8 @@ public class GridTcpCommunicationMessageFactory { }, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, /* 64-71: IgniteFS messages. */ 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82); + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88); } /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheValueBytes.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheValueBytes.java index 289db2e08dd5f..cf12c71883cde 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheValueBytes.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheValueBytes.java @@ -173,10 +173,11 @@ public boolean isNull() { /** {@inheritDoc} */ @Override public byte directType() { - return 0; // TODO: implement. + return 88; } /** {@inheritDoc} */ + @SuppressWarnings("CloneDoesntCallSuperClone") @Override public MessageAdapter clone() { GridCacheValueBytes _clone = new GridCacheValueBytes(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionExchangeId.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionExchangeId.java index 622f639afbbe3..c46b4c5bde00f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionExchangeId.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionExchangeId.java @@ -216,10 +216,11 @@ public boolean isLeft() { /** {@inheritDoc} */ @Override public byte directType() { - return 0; // TODO: implement. + return 87; } /** {@inheritDoc} */ + @SuppressWarnings("CloneDoesntCallSuperClone") @Override public MessageAdapter clone() { GridDhtPartitionExchangeId _clone = new GridDhtPartitionExchangeId(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersion.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersion.java index 77fdf2dabb180..1990bb129cda4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersion.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersion.java @@ -337,10 +337,11 @@ public IgniteUuid asGridUuid() { /** {@inheritDoc} */ @Override public byte directType() { - return 0; // TODO: implement. + return 86; } /** {@inheritDoc} */ + @SuppressWarnings("CloneDoesntCallSuperClone") @Override public MessageAdapter clone() { GridCacheVersion _clone = new GridCacheVersion(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaVersion.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaVersion.java index 06e8730fc2289..993213230ea3a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaVersion.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaVersion.java @@ -169,10 +169,11 @@ public long topologyVersion() { /** {@inheritDoc} */ @Override public byte directType() { - return 0; // TODO: implement. + return 83; } /** {@inheritDoc} */ + @SuppressWarnings("CloneDoesntCallSuperClone") @Override public MessageAdapter clone() { GridClockDeltaVersion _clone = new GridClockDeltaVersion(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/IgniteFsProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/IgniteFsProcessor.java index 9920d99240e94..aee707c4a560b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/IgniteFsProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/IgniteFsProcessor.java @@ -26,14 +26,12 @@ import org.apache.ignite.ignitefs.*; import org.apache.ignite.ignitefs.mapreduce.*; import org.apache.ignite.internal.*; -import org.apache.ignite.internal.direct.*; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.license.*; import org.apache.ignite.internal.util.ipc.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; -import org.apache.ignite.plugin.extensions.communication.*; import org.jdk8.backport.*; import org.jetbrains.annotations.*; @@ -81,43 +79,6 @@ public IgniteFsProcessor(GridKernalContext ctx) { assert cfgs != null && cfgs.length > 0; - // Register GGFS messages. - GridTcpCommunicationMessageFactory.registerCommon(new GridTcpCommunicationMessageProducer() { - @Override - public MessageAdapter create(byte type) { - switch (type) { - case 64: - return new GridGgfsAckMessage(); - - case 65: - return new GridGgfsBlockKey(); - - case 66: - return new GridGgfsBlocksMessage(); - - case 67: - return new GridGgfsDeleteMessage(); - - case 68: - return new GridGgfsFileAffinityRange(); - - case 69: - return new GridGgfsFragmentizerRequest(); - - case 70: - return new GridGgfsFragmentizerResponse(); - - case 71: - return new GridGgfsSyncMessage(); - - default: - assert false : "Invalid GGFS message type."; - - return null; - } - } - }, 64, 65, 66, 67, 68, 69, 70, 71); - // Register HDFS edition usage with license manager. GridLicenseUseRegistry.onUsage(HADOOP, getClass()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridByteArrayList.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridByteArrayList.java index 8ec78d5bae501..d9252a1452042 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridByteArrayList.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridByteArrayList.java @@ -463,10 +463,11 @@ public InputStream inputStream() { /** {@inheritDoc} */ @Override public byte directType() { - return 0; // TODO: implement. + return 84; } /** {@inheritDoc} */ + @SuppressWarnings("CloneDoesntCallSuperClone") @Override public MessageAdapter clone() { GridByteArrayList _clone = new GridByteArrayList(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridLongList.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridLongList.java index 5dce4e9db22f4..731dd5ed593f8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridLongList.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridLongList.java @@ -561,10 +561,11 @@ public void pop(int cnt) { /** {@inheritDoc} */ @Override public byte directType() { - return 0; // TODO: implement. + return 85; } /** {@inheritDoc} */ + @SuppressWarnings("CloneDoesntCallSuperClone") @Override public MessageAdapter clone() { GridLongList _clone = new GridLongList(); From 71c7a694cee50ac34519d9346e15925656901d0e Mon Sep 17 00:00:00 2001 From: Alexey Goncharuk Date: Sat, 7 Feb 2015 23:34:44 -0800 Subject: [PATCH 50/95] IGNITE-51 - Fixed compilation --- .../ignite/client/ClientPutPortableTask.java | 43 ---------- .../ClientTestPortableAffinityKeyTask.java | 85 ------------------- ...ridCacheOffHeapTieredAbstractSelfTest.java | 15 +--- ...OffHeapTieredEvictionAbstractSelfTest.java | 78 ++--------------- .../org/apache/ignite/IgniteSpringBean.java | 7 -- 5 files changed, 10 insertions(+), 218 deletions(-) delete mode 100644 modules/clients/src/test/java/org/apache/ignite/client/ClientPutPortableTask.java delete mode 100644 modules/clients/src/test/java/org/apache/ignite/client/ClientTestPortableAffinityKeyTask.java diff --git a/modules/clients/src/test/java/org/apache/ignite/client/ClientPutPortableTask.java b/modules/clients/src/test/java/org/apache/ignite/client/ClientPutPortableTask.java deleted file mode 100644 index a1452cd4dd595..0000000000000 --- a/modules/clients/src/test/java/org/apache/ignite/client/ClientPutPortableTask.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.client; - -import org.apache.ignite.*; -import org.apache.ignite.resources.*; - -/** - * Task creates portable object and puts it in cache. - */ -public class ClientPutPortableTask extends TaskSingleJobSplitAdapter { - /** */ - @IgniteInstanceResource - private Ignite ignite; - - /** {@inheritDoc} */ - @Override protected Object executeJob(int gridSize, Object arg) { - String cacheName = (String)arg; - - IgniteCache cache = ignite.jcache(cacheName); - - ClientTestPortable p = new ClientTestPortable(100, true); - - cache.put(1, p); - - return true; - } -} diff --git a/modules/clients/src/test/java/org/apache/ignite/client/ClientTestPortableAffinityKeyTask.java b/modules/clients/src/test/java/org/apache/ignite/client/ClientTestPortableAffinityKeyTask.java deleted file mode 100644 index 0c459f5a01ba8..0000000000000 --- a/modules/clients/src/test/java/org/apache/ignite/client/ClientTestPortableAffinityKeyTask.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.client; - -import org.apache.ignite.*; -import org.apache.ignite.cluster.*; -import org.apache.ignite.compute.*; -import org.gridgain.grid.portables.*; -import org.apache.ignite.resources.*; -import org.jetbrains.annotations.*; - -import java.util.*; - -/** - * Task used to test portable affinity key. - */ -public class ClientTestPortableAffinityKeyTask extends ComputeTaskAdapter { - /** */ - @IgniteInstanceResource - private Ignite ignite; - - /** {@inheritDoc} */ - @Nullable @Override public Map map(List clusterNodes, - @Nullable final Object arg) { - for (ClusterNode node : clusterNodes) { - if (node.isLocal()) - return Collections.singletonMap(new ComputeJobAdapter() { - @Override public Object execute() { - return executeJob(arg); - } - }, node); - } - - throw new IgniteException("Failed to find local node in task topology: " + clusterNodes); - } - - /** {@inheritDoc} */ - @Nullable @Override public Boolean reduce(List results) { - return results.get(0).getData(); - } - - /** - * @param arg Argument. - * @return Execution result. - * @throws IgniteException If failed. - */ - protected Boolean executeJob(Object arg) throws IgniteException { - Collection args = (Collection)arg; - - Iterator it = args.iterator(); - - assert args.size() == 3 : args.size(); - - PortableObject obj = (PortableObject)it.next(); - - String cacheName = (String)it.next(); - - String expAffKey = (String)it.next(); - - Object affKey = ignite.cache(cacheName).affinity().affinityKey(obj); - - if (!expAffKey.equals(affKey)) - throw new IgniteException("Unexpected affinity key: " + affKey); - - if (!ignite.cache(cacheName).affinity().mapKeyToNode(obj).isLocal()) - throw new IgniteException("Job is not run on primary node."); - - return true; - } -} diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapTieredAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapTieredAbstractSelfTest.java index 4d6162e2856cf..3e31419a63296 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapTieredAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapTieredAbstractSelfTest.java @@ -21,7 +21,6 @@ import org.apache.ignite.cache.*; import org.apache.ignite.configuration.*; import org.apache.ignite.lang.*; -import org.gridgain.grid.portables.*; import org.apache.ignite.transactions.*; import org.jetbrains.annotations.*; import org.junit.*; @@ -58,18 +57,8 @@ public abstract class GridCacheOffHeapTieredAbstractSelfTest extends GridCacheAb } /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - if (portableEnabled()) { - PortableConfiguration pCfg = new PortableConfiguration(); - - pCfg.setClassNames(Arrays.asList(TestValue.class.getName())); - - cfg.setPortableConfiguration(pCfg); - } - - return cfg; + protected boolean portableEnabled() { + return false; } /** {@inheritDoc} */ diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapTieredEvictionAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapTieredEvictionAbstractSelfTest.java index bc43dec730297..1f83ac1c158fd 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapTieredEvictionAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapTieredEvictionAbstractSelfTest.java @@ -22,7 +22,6 @@ import org.apache.ignite.configuration.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; -import org.gridgain.grid.portables.*; import org.apache.ignite.testframework.*; import javax.cache.processor.*; @@ -60,21 +59,6 @@ public abstract class GridCacheOffHeapTieredEvictionAbstractSelfTest extends Gri return 60 * 1000; } - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - if (portableEnabled()) { - PortableConfiguration pCfg = new PortableConfiguration(); - - pCfg.setClassNames(Arrays.asList(TestValue.class.getName())); - - cfg.setPortableConfiguration(pCfg); - } - - return cfg; - } - /** {@inheritDoc} */ @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception { CacheConfiguration ccfg = super.cacheConfiguration(gridName); @@ -207,10 +191,8 @@ public void testTransform() throws Exception { * @param acceptNull If {@code true} value can be null; * @return Predicate. */ - private TestPredicate testPredicate(String expVal, boolean acceptNull) { - return portableEnabled() ? - new PortableValuePredicate(expVal, acceptNull) : - new TestValuePredicate(expVal, acceptNull); + protected TestPredicate testPredicate(String expVal, boolean acceptNull) { + return new TestValuePredicate(expVal, acceptNull); } /** @@ -218,10 +200,8 @@ private TestPredicate testPredicate(String expVal, boolean acceptNull) { * @param acceptNull If {@code true} value can be null; * @return Predicate. */ - private TestProcessor testClosure(String expVal, boolean acceptNull) { - return portableEnabled() ? - new PortableValueClosure(expVal, acceptNull) : - new TestValueClosure(expVal, acceptNull); + protected TestProcessor testClosure(String expVal, boolean acceptNull) { + return new TestValueClosure(expVal, acceptNull); } /** @@ -288,28 +268,7 @@ protected TestPredicate(String expVal, boolean acceptNull) { /** * @param val Value. */ - abstract void checkValue(Object val); - } - - /** - * - */ - @SuppressWarnings("PackageVisibleInnerClass") - static class PortableValuePredicate extends TestPredicate { - /** - * @param expVal Expected value. - * @param acceptNull If {@code true} value can be null; - */ - PortableValuePredicate(String expVal, boolean acceptNull) { - super(expVal, acceptNull); - } - - /** {@inheritDoc} */ - @Override void checkValue(Object val) { - PortableObject obj = (PortableObject)val; - - assertEquals(expVal, obj.field("val")); - } + public abstract void checkValue(Object val); } /** @@ -326,7 +285,7 @@ static class TestValuePredicate extends TestPredicate { } /** {@inheritDoc} */ - @Override void checkValue(Object val) { + @Override public void checkValue(Object val) { TestValue obj = (TestValue)val; assertEquals(expVal, obj.val); @@ -375,28 +334,7 @@ protected TestProcessor(String expVal, boolean acceptNull) { /** * @param val Value. */ - abstract void checkValue(Object val); - } - - /** - * - */ - @SuppressWarnings("PackageVisibleInnerClass") - static class PortableValueClosure extends TestProcessor { - /** - * @param expVal Expected value. - * @param acceptNull If {@code true} value can be null; - */ - PortableValueClosure(String expVal, boolean acceptNull) { - super(expVal, acceptNull); - } - - /** {@inheritDoc} */ - @Override void checkValue(Object val) { - PortableObject obj = (PortableObject)val; - - assertEquals(expVal, obj.field("val")); - } + public abstract void checkValue(Object val); } /** @@ -413,7 +351,7 @@ static class TestValueClosure extends TestProcessor { } /** {@inheritDoc} */ - @Override void checkValue(Object val) { + @Override public void checkValue(Object val) { TestValue obj = (TestValue)val; assertEquals(expVal, obj.val); diff --git a/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java b/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java index 74c810a592e71..6a46da1266bcd 100644 --- a/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java +++ b/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java @@ -241,13 +241,6 @@ public void setConfiguration(IgniteConfiguration cfg) { return g.security(); } - /** {@inheritDoc} */ - @Override public IgnitePortables portables() { - assert g != null; - - return g.portables(); - } - /** {@inheritDoc} */ @Override public String name() { assert g != null; From 88f5b9d49db9e90d44bd9796aa91e14b53caf769 Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Sat, 7 Feb 2015 23:54:39 -0800 Subject: [PATCH 51/95] IGNITE-61 - Direct marshalling --- .../ignite/codegen/CommunicationMessageCodeGenerator.java | 4 ++-- .../direct/GridTcpCommunicationMessageFactory.java | 2 +- .../cache/distributed/dht/GridDhtLockFuture.java | 2 +- .../cache/distributed/dht/GridDhtLockResponse.java | 4 ++-- .../dht/preloader/GridDhtPartitionDemandMessage.java | 4 ++-- .../dht/preloader/GridDhtPartitionSupplyMessage.java | 8 ++++---- .../plugin/extensions/communication/MessageAdapter.java | 8 +++++--- 7 files changed, 17 insertions(+), 15 deletions(-) diff --git a/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java index 4a81a9284301b..429b15427a64c 100644 --- a/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java +++ b/modules/codegen/src/main/java/org/apache/ignite/codegen/CommunicationMessageCodeGenerator.java @@ -536,7 +536,7 @@ else if (type.isArray()) { returnFalseIfFailed(write, "writer.writeObjectArray", field, name, type.getComponentType().getSimpleName() + ".class"); } - else if (Collection.class.isAssignableFrom(type)) { + else if (Collection.class.isAssignableFrom(type) && !Set.class.isAssignableFrom(type)) { assert colItemType != null; returnFalseIfFailed(write, "writer.writeCollection", field, name, colItemType.getSimpleName() + ".class"); @@ -613,7 +613,7 @@ else if (type.isArray()) { returnFalseIfReadFailed(name, "reader.readObjectArray", field, type.getComponentType().getSimpleName() + ".class"); } - else if (Collection.class.isAssignableFrom(type)) { + else if (Collection.class.isAssignableFrom(type) && !Set.class.isAssignableFrom(type)) { assert colItemType != null; returnFalseIfReadFailed(name, "reader.readCollection", field, diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/GridTcpCommunicationMessageFactory.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/GridTcpCommunicationMessageFactory.java index b1cbe7e6608bf..600bd3156bf86 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/direct/GridTcpCommunicationMessageFactory.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/GridTcpCommunicationMessageFactory.java @@ -51,7 +51,7 @@ */ public class GridTcpCommunicationMessageFactory { /** Common message producers. */ - private static final GridTcpCommunicationMessageProducer[] COMMON = new GridTcpCommunicationMessageProducer[83]; + private static final GridTcpCommunicationMessageProducer[] COMMON = new GridTcpCommunicationMessageProducer[89]; /** * Custom messages registry. Used for test purposes. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java index 5cc6e7640c3e7..7521af7bc4024 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java @@ -1136,7 +1136,7 @@ void onResult(GridDhtLockResponse res) { evictReaders(cctx, res.nearEvicted(), node.id(), res.messageId(), nearMapping); } - Set invalidParts = res.invalidPartitions(); + Collection invalidParts = res.invalidPartitions(); // Removing mappings for invalid partitions. if (!F.isEmpty(invalidParts)) { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java index 2f28b8991d88d..48ef34d84c964 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java @@ -55,7 +55,7 @@ public class GridDhtLockResponse extends GridDistributedLockResponse /** Invalid partitions. */ @GridToStringInclude @GridDirectCollection(int.class) - private Set invalidParts = new GridLeanSet<>(); + private Collection invalidParts = new GridLeanSet<>(); @GridDirectTransient /** Preload entries. */ @@ -138,7 +138,7 @@ public void addInvalidPartition(int part) { /** * @return Invalid partitions. */ - public Set invalidPartitions() { + public Collection invalidPartitions() { return invalidParts; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java index 409522c808034..29760f67e95a4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java @@ -41,7 +41,7 @@ public class GridDhtPartitionDemandMessage extends GridCacheMessage /** Partition. */ @GridToStringInclude @GridDirectCollection(int.class) - private Set parts; + private Collection parts; /** Topic. */ @GridDirectTransient @@ -112,7 +112,7 @@ void addPartition(int p) { /** * @return Partition. */ - Set partitions() { + Collection partitions() { return parts; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java index 4835e771e40a6..ee1a930ea84f2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java @@ -46,12 +46,12 @@ public class GridDhtPartitionSupplyMessage extends GridCacheMessage /** Partitions that have been fully sent. */ @GridDirectCollection(int.class) - private Set last; + private Collection last; /** Partitions which were not found. */ @GridToStringInclude @GridDirectCollection(int.class) - private Set missed; + private Collection missed; /** Entries. */ @GridDirectTransient @@ -130,7 +130,7 @@ boolean ack() { /** * @return Flag to indicate last message for partition. */ - Set last() { + Collection last() { return last == null ? Collections.emptySet() : last; } @@ -166,7 +166,7 @@ void missed(int p) { /** * @return Missed partitions. */ - Set missed() { + Collection missed() { return missed == null ? Collections.emptySet() : missed; } diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageAdapter.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageAdapter.java index d393e1663c3ad..c2b4d96b319ca 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageAdapter.java @@ -17,6 +17,8 @@ package org.apache.ignite.plugin.extensions.communication; +import org.apache.ignite.internal.direct.*; + import java.io.*; import java.nio.*; @@ -25,7 +27,7 @@ */ public abstract class MessageAdapter implements Serializable, Cloneable { /** Writer. */ - protected MessageWriter writer; + protected final MessageWriter writer = new DirectMessageWriter(); /** Reader. */ protected MessageReader reader; @@ -40,8 +42,8 @@ public abstract class MessageAdapter implements Serializable, Cloneable { * @param writer Writer. */ public final void setWriter(MessageWriter writer) { - if (this.writer == null) - this.writer = writer; +// if (this.writer == null) +// this.writer = writer; } /** From 6d1cf0bf388b2614ac1e7b9cd1a0db0c47129252 Mon Sep 17 00:00:00 2001 From: sboikov Date: Sun, 8 Feb 2015 22:12:49 +0300 Subject: [PATCH 52/95] # ignite-57 --- .../internal/processors/cache/GridCacheAdapter.java | 2 +- .../distributed/GridDistributedCacheAdapter.java | 11 +++++++++++ .../cache/GridCacheAbstractFullApiSelfTest.java | 2 +- ...idCacheAtomicNearOnlyMultiNodeFullApiSelfTest.java | 1 + .../GridCacheNearOnlyMultiNodeFullApiSelfTest.java | 2 +- 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java index ae0d8a9921043..aff6113e86345 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java @@ -4120,7 +4120,7 @@ public Cache.Entry randomCacheEntry() throws IgniteCheckedException { @Override public IgniteInternalFuture sizeAsync(CachePeekMode[] peekModes) { assert peekModes != null; - Collection nodes = ctx.grid().forDataNodes(name()).nodes(); + Collection nodes = ctx.grid().forCacheNodes(name()).nodes(); if (nodes.isEmpty()) return new GridFinishedFuture<>(ctx.kernalContext(), 0); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheAdapter.java index c0ec962a74e2c..3f020b150879b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheAdapter.java @@ -36,6 +36,7 @@ import org.apache.ignite.transactions.*; import org.jetbrains.annotations.*; +import javax.cache.*; import java.io.*; import java.util.*; import java.util.concurrent.*; @@ -285,6 +286,16 @@ private GlobalRemoveAllCallable(String cacheName, long topVer) { } } } + + Iterator> it = dht.context().swap().offheapIterator(true, false, topVer); + + while (it.hasNext()) + dataLdr.removeData(it.next().getKey()); + + it = dht.context().swap().swapIterator(true, false, topVer); + + while (it.hasNext()) + dataLdr.removeData(it.next().getKey()); } } finally { diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java index 1b4319314c50e..95e555f9b18a6 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java @@ -2503,7 +2503,7 @@ public void testClear() throws Exception { cache.localEvict(Sets.union(ImmutableSet.of("key1", "key2"), keys)); - assert cache.localSize() == 0; + assert cache.localSize(CachePeekMode.ONHEAP) == 0; cache.clear(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest.java index 528e0c8dd8ecf..48422877740cb 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest.java @@ -68,6 +68,7 @@ public class GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest extends GridCacheNe return PARTITIONED_ONLY; } + /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { for (int i = 0; i < gridCount(); i++) grid(i).cache(null).removeAll(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java index 9fdab54be1d8d..1b9aebb5c5221 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java @@ -266,7 +266,7 @@ protected IgniteCache fullCache() { jcache().clear(); for (int i = 0; i < gridCount(); i++) - assertTrue(String.valueOf(jcache(i)), jcache(i).localSize() == 0); + assertEquals(ignite(i).name(), 0, jcache(i).localSize()); } /** {@inheritDoc} */ From 8dad83299fe52dcfaf5980a534e9bbaef7cdb3bf Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Sun, 8 Feb 2015 11:13:41 -0800 Subject: [PATCH 53/95] IGNITE-61 - Direct marshalling --- modules/codegen/pom.xml | 2 +- .../CommunicationMessageCodeGenerator.java | 24 ++++++++++++------- .../communication/MessageReader.java | 22 +++++++++++------ .../communication/MessageReaderFactory.java | 22 +++++++++++------ .../communication/MessageWriter.java | 22 +++++++++++------ .../communication/MessageWriterFactory.java | 22 +++++++++++------ pom.xml | 1 + 7 files changed, 78 insertions(+), 37 deletions(-) diff --git a/modules/codegen/pom.xml b/modules/codegen/pom.xml index 66a4eabc94477..5b9e1dba709c5 100644 --- a/modules/codegen/pom.xml +++ b/modules/codegen/pom.xml @@ -15,7 +15,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - --> +--> + + + + + + Contains extendable components for communication. + + From d64fefb9d3459ca7b0cdb7183514e46c2d995b1d Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Sun, 8 Feb 2015 20:43:31 -0800 Subject: [PATCH 66/95] # IGNITE-61 - Minor fixes --- .../org/apache/ignite/internal/util/nio/GridNioServer.java | 1 + .../communication/GridCommunicationSendMessageSelfTest.java | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java index b0c34ef829521..4a2e2e42e7960 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java @@ -139,6 +139,7 @@ public class GridNioServer { private GridNioSslFilter sslFilter; /** */ + @GridToStringExclude private IgniteSpiAdapter spi; /** */ diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridCommunicationSendMessageSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridCommunicationSendMessageSelfTest.java index 7f3914120949b..a26b6175ab787 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridCommunicationSendMessageSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridCommunicationSendMessageSelfTest.java @@ -19,7 +19,6 @@ import org.apache.ignite.configuration.*; import org.apache.ignite.internal.*; -import org.apache.ignite.internal.direct.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.spi.communication.tcp.*; @@ -147,7 +146,7 @@ private static class TestMessage extends MessageAdapter { /** {@inheritDoc} */ @SuppressWarnings("CloneDoesntCallSuperClone") @Override public MessageAdapter clone() { - throw new UnsupportedOperationException(); + return this; } /** {@inheritDoc} */ From b9cb15731239bb086895fcf1b7190317f90a483d Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Mon, 9 Feb 2015 00:28:35 -0800 Subject: [PATCH 67/95] # IGNITE-61 - Fixing client --- .../GridClientConnectionManagerAdapter.java | 84 +-- .../GridClientNioTcpConnection.java | 135 +---- .../communication/GridIoMessageFactory.java | 21 - .../GridClientHandshakeRequestWrapper.java | 117 ---- .../GridClientHandshakeResponseWrapper.java | 94 ---- .../message/GridClientMessageWrapper.java | 275 --------- .../message/GridClientPingPacketWrapper.java | 89 --- .../protocols/tcp/GridClientPacketType.java | 3 + .../protocols/tcp/GridMemcachedMessage.java | 3 + .../tcp/GridTcpRestDirectParser.java | 523 ------------------ .../protocols/tcp/GridTcpRestNioListener.java | 29 +- .../rest/protocols/tcp/GridTcpRestParser.java | 26 + .../protocols/tcp/GridTcpRestProtocol.java | 8 +- 13 files changed, 72 insertions(+), 1335 deletions(-) delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMessageWrapper.java delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacketWrapper.java delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestDirectParser.java diff --git a/modules/core/src/main/java/org/apache/ignite/client/impl/connection/GridClientConnectionManagerAdapter.java b/modules/core/src/main/java/org/apache/ignite/client/impl/connection/GridClientConnectionManagerAdapter.java index 476d9c5658de9..6cecef0a73fbe 100644 --- a/modules/core/src/main/java/org/apache/ignite/client/impl/connection/GridClientConnectionManagerAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/client/impl/connection/GridClientConnectionManagerAdapter.java @@ -18,18 +18,17 @@ package org.apache.ignite.client.impl.connection; import org.apache.ignite.*; -import org.apache.ignite.internal.direct.*; -import org.apache.ignite.logger.java.*; -import org.apache.ignite.plugin.extensions.communication.*; -import org.apache.ignite.plugin.security.*; import org.apache.ignite.client.*; import org.apache.ignite.client.impl.*; import org.apache.ignite.client.util.*; import org.apache.ignite.internal.processors.rest.client.message.*; +import org.apache.ignite.internal.processors.rest.protocols.tcp.*; import org.apache.ignite.internal.util.nio.*; import org.apache.ignite.internal.util.nio.ssl.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.logger.java.*; +import org.apache.ignite.plugin.security.*; import org.jetbrains.annotations.*; import javax.net.ssl.*; @@ -143,12 +142,12 @@ protected GridClientConnectionManagerAdapter(UUID clientId, GridNioFilter[] filters; - GridNioFilter codecFilter = new GridNioCodecFilter(new NioParser(), gridLog, true); + GridNioFilter codecFilter = new GridNioCodecFilter(new GridTcpRestParser(), gridLog, false); if (sslCtx != null) { GridNioSslFilter sslFilter = new GridNioSslFilter(sslCtx, gridLog); - sslFilter.directMode(true); + sslFilter.directMode(false); sslFilter.clientMode(true); filters = new GridNioFilter[]{codecFilter, sslFilter}; @@ -166,7 +165,7 @@ protected GridClientConnectionManagerAdapter(UUID clientId, .byteOrder(ByteOrder.nativeOrder()) .tcpNoDelay(cfg.isTcpNoDelay()) .directBuffer(true) - .directMode(true) + .directMode(false) .socketReceiveBufferSize(0) .socketSendBufferSize(0) .idleTimeout(Long.MAX_VALUE) @@ -594,22 +593,10 @@ private NioListener(Logger log) { assert conn != null; - if (msg instanceof GridClientMessageWrapper) { - GridClientMessageWrapper req = (GridClientMessageWrapper)msg; - - if (req.messageSize() != 0) { - assert req.message() != null; - - conn.handleResponse(req); - } - else - conn.handlePingResponse(); - } - else { - assert msg instanceof GridClientPingPacket : msg; - + if (msg instanceof GridClientPingPacket) conn.handlePingResponse(); - } + else + conn.handleResponse((GridClientMessage)msg); } } @@ -647,57 +634,4 @@ private void handleHandshakeResponse(GridClientFutureAdapter handshakeF ses.close(); } } - - /** - * - */ - private static class NioParser implements GridNioParser { - /** Message metadata key. */ - private static final int MSG_META_KEY = GridNioSessionMetaKey.nextUniqueKey(); - - /** {@inheritDoc} */ - @Nullable @Override public Object decode(GridNioSession ses, ByteBuffer buf) - throws IOException, IgniteCheckedException { - GridClientFutureAdapter handshakeFut = ses.meta(GridClientNioTcpConnection.SES_META_HANDSHAKE); - - if (handshakeFut != null) { - byte code = buf.get(); - - return new GridClientHandshakeResponse(code); - } - - MessageAdapter msg = ses.removeMeta(MSG_META_KEY); - - if (msg == null && buf.hasRemaining()) { - byte type = buf.get(); - - if (type == GridClientMessageWrapper.REQ_HEADER) { - msg = new GridClientMessageWrapper(); - - msg.setReader(new DirectMessageReader(null)); - } - else - throw new IOException("Invalid message type: " + type); - } - - boolean finished = false; - - if (buf.hasRemaining()) - finished = msg.readFrom(buf); - - if (finished) - return msg; - else { - ses.addMeta(MSG_META_KEY, msg); - - return null; - } - } - - /** {@inheritDoc} */ - @Override public ByteBuffer encode(GridNioSession ses, Object msg) throws IOException, IgniteCheckedException { - // No encoding needed for direct messages. - throw new UnsupportedEncodingException(); - } - } } diff --git a/modules/core/src/main/java/org/apache/ignite/client/impl/connection/GridClientNioTcpConnection.java b/modules/core/src/main/java/org/apache/ignite/client/impl/connection/GridClientNioTcpConnection.java index 51da3d7571015..3cead452be60f 100644 --- a/modules/core/src/main/java/org/apache/ignite/client/impl/connection/GridClientNioTcpConnection.java +++ b/modules/core/src/main/java/org/apache/ignite/client/impl/connection/GridClientNioTcpConnection.java @@ -33,7 +33,6 @@ import javax.net.ssl.*; import java.io.*; import java.net.*; -import java.nio.*; import java.nio.channels.*; import java.util.*; import java.util.concurrent.*; @@ -43,6 +42,7 @@ import static org.apache.ignite.client.GridClientCacheFlag.*; import static org.apache.ignite.client.impl.connection.GridClientConnectionCloseReason.*; import static org.apache.ignite.internal.processors.rest.client.message.GridClientCacheRequest.GridCacheOperation.*; +import static org.apache.ignite.internal.util.nio.GridNioSessionMetaKey.*; /** * This class performs request to grid over tcp protocol. Serialization is performed with marshaller @@ -194,9 +194,9 @@ else if (marsh instanceof GridClientOptimizedMarshaller) else if (marsh instanceof GridClientJdkMarshaller) req.marshallerId(GridClientJdkMarshaller.ID); - GridClientHandshakeRequestWrapper wrapper = new GridClientHandshakeRequestWrapper(req); + ses.addMeta(MARSHALLER.ordinal(), marsh); - ses.send(wrapper); + ses.send(req); handshakeFut.get(); @@ -392,7 +392,7 @@ private GridClientFutureAdapter makeRequest(GridClientMessage msg, final else if (now - lastPingSndTime > pingInterval && lastPingRcvTime != Long.MAX_VALUE) { lastPingRcvTime = Long.MAX_VALUE; - ses.send(new GridClientPingPacketWrapper()); + ses.send(GridClientPingPacket.PING_MESSAGE); lastPingSndTime = now; } @@ -415,22 +415,7 @@ else if (now - lastPingSndTime > pingInterval && lastPingRcvTime != Long.MAX_VAL assert old == null; - GridClientMessageWrapper wrapper; - - try { - wrapper = messageWrapper(msg); - } - catch (IOException e) { - log.log(Level.SEVERE, "Failed to marshal message: " + msg, e); - - removePending(reqId); - - fut.onDone(e); - - return fut; - } - - GridNioFuture sndFut = ses.send(wrapper); + GridNioFuture sndFut = ses.send(msg); lastMsgSndTime = U.currentTimeMillis(); @@ -473,59 +458,38 @@ void handlePingResponse() { * Handles incoming response message. If this connection is closed this method would signal empty event * if there is no more pending requests. * - * @param req Incoming response data. + * @param res Incoming response data. */ @SuppressWarnings({"unchecked", "TooBroadScope"}) - void handleResponse(GridClientMessageWrapper req) { + void handleResponse(GridClientMessage res) { lastMsgRcvTime = U.currentTimeMillis(); - TcpClientFuture fut = pendingReqs.get(req.requestId()); + TcpClientFuture fut = pendingReqs.get(res.requestId()); if (fut == null) { log.warning("Response for an unknown request is received, ignoring. " + - "[req=" + req + ", ses=" + ses + ']'); + "[res=" + res + ", ses=" + ses + ']'); return; } if (fut.forward()) { - GridRouterResponse msg = new GridRouterResponse( - req.messageArray(), - req.requestId(), - clientId, - req.destinationId()); - - removePending(msg.requestId()); - - fut.onDone(msg); + // TODO: IGNITE-61 +// GridRouterResponse msg = new GridRouterResponse( +// res.messageArray(), +// res.requestId(), +// clientId, +// res.destinationId()); +// +// removePending(msg.requestId()); +// +// fut.onDone(msg); } else { - GridClientMessage msg; - - if (keepPortablesMode != null) - keepPortablesMode.set(fut.keepPortables()); - - try { - msg = marsh.unmarshal(req.messageArray()); - } - catch (IOException e) { - fut.onDone(new GridClientException("Failed to unmarshal message.", e)); - - return; - } - - finally { - if (keepPortablesMode != null) - keepPortablesMode.set(true); - } - msg.requestId(req.requestId()); - msg.clientId(req.clientId()); - msg.destinationId(req.destinationId()); - - if (msg instanceof GridClientResponse) - handleClientResponse(fut, (GridClientResponse)msg); + if (res instanceof GridClientResponse) + handleClientResponse(fut, (GridClientResponse)res); else - log.warning("Unsupported response type received: " + msg); + log.warning("Unsupported response type received: " + res); } } @@ -559,22 +523,7 @@ private void handleClientResponse(TcpClientFuture fut, GridClientResponse resp) req.requestId(resp.requestId()); - GridClientMessageWrapper wrapper; - - try { - wrapper = messageWrapper(req); - } - catch (IOException e) { - log.log(Level.SEVERE, "Failed to marshal message: " + req, e); - - removePending(resp.requestId()); - - fut.onDone(e); - - return; - } - - ses.send(wrapper); + ses.send(req); return; } @@ -588,22 +537,7 @@ private void handleClientResponse(TcpClientFuture fut, GridClientResponse resp) src.sessionToken(sesTok); - GridClientMessageWrapper wrapper; - - try { - wrapper = messageWrapper(src); - } - catch (IOException e) { - log.log(Level.SEVERE, "Failed to marshal message: " + src, e); - - removePending(resp.requestId()); - - fut.onDone(e); - - return; - } - - ses.send(wrapper); + ses.send(src); return; } @@ -623,27 +557,6 @@ else if (resp.errorMessage() != null) fut.onDone(resp.result()); } - /** - * @param msg Client message. - * @return Message wrapper for direct marshalling. - * @throws IOException If failed to marshal message. - */ - private GridClientMessageWrapper messageWrapper(GridClientMessage msg) throws IOException { - GridClientMessageWrapper wrapper = new GridClientMessageWrapper(); - - wrapper.requestId(msg.requestId()); - wrapper.clientId(clientId); - wrapper.destinationId(msg.destinationId()); - - ByteBuffer data = (msg instanceof GridRouterRequest) ? ByteBuffer.wrap(((GridRouterRequest)msg).body()) : - marsh.marshal(msg, 0); - - wrapper.message(data); - wrapper.messageSize(data.remaining() + 40); - - return wrapper; - } - /** * Removes pending request and signals to {@link #closedLatch} if necessary. * diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java index 0634b1f194f2a..0f46e3d434d1d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java @@ -34,7 +34,6 @@ import org.apache.ignite.internal.processors.continuous.*; import org.apache.ignite.internal.processors.dataload.*; import org.apache.ignite.internal.processors.fs.*; -import org.apache.ignite.internal.processors.rest.client.message.*; import org.apache.ignite.internal.processors.rest.handlers.task.*; import org.apache.ignite.internal.processors.rest.protocols.tcp.*; import org.apache.ignite.internal.processors.streamer.*; @@ -445,26 +444,6 @@ public GridIoMessageFactory(MessageReaderFactory readerFactory, MessageFactory[] break; - case 72: - msg = new GridClientHandshakeRequestWrapper(); - - break; - - case 73: - msg = new GridClientHandshakeResponseWrapper(); - - break; - - case 74: - msg = new GridClientMessageWrapper(); - - break; - - case 75: - msg = new GridClientPingPacketWrapper(); - - break; - case 76: msg = new GridTaskResultRequest(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java deleted file mode 100644 index 71dfcf94e255c..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.rest.client.message; - -import org.apache.ignite.internal.direct.*; -import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.plugin.extensions.communication.*; - -import java.nio.*; - -/** - * Client handshake wrapper for direct marshalling. - */ -public class GridClientHandshakeRequestWrapper extends MessageAdapter { - /** */ - private static final long serialVersionUID = -5705048094821942662L; - - /** Signal char. */ - public static final byte HANDSHAKE_HEADER = (byte)0x91; - - /** Stream. */ - private final DirectByteBufferStream stream = new DirectByteBufferStream(null); - - /** Handshake bytes. */ - private byte[] bytes; - - /** - * - */ - public GridClientHandshakeRequestWrapper() { - // No-op. - } - - /** - * - * @param req Handshake request. - */ - public GridClientHandshakeRequestWrapper(GridClientHandshakeRequest req) { - bytes = req.rawBytes(); - } - - /** - * @return Handshake bytes. - */ - public byte[] bytes() { - return bytes; - } - - /** {@inheritDoc} */ - @Override public boolean writeTo(ByteBuffer buf) { - stream.setBuffer(buf); - - if (!typeWritten) { - if (!buf.hasRemaining()) - return false; - - stream.writeByte(directType()); - - typeWritten = true; - } - - stream.writeByteArray(bytes, 0, bytes.length); - - return stream.lastFinished(); - } - - /** {@inheritDoc} */ - @Override public boolean readFrom(ByteBuffer buf) { - stream.setBuffer(buf); - - bytes = stream.readByteArray(GridClientHandshakeRequest.PACKET_SIZE); - - return stream.lastFinished(); - } - - /** {@inheritDoc} */ - @Override public byte directType() { - return HANDSHAKE_HEADER; - } - - /** {@inheritDoc} */ - @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public MessageAdapter clone() { - GridClientHandshakeRequestWrapper _clone = new GridClientHandshakeRequestWrapper(); - - clone0(_clone); - - return _clone; - } - - /** {@inheritDoc} */ - @Override protected void clone0(MessageAdapter _msg) { - GridClientHandshakeRequestWrapper _clone = (GridClientHandshakeRequestWrapper)_msg; - - _clone.bytes = bytes; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(GridClientHandshakeRequestWrapper.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java deleted file mode 100644 index e598f66716086..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.rest.client.message; - -import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.plugin.extensions.communication.*; - -import java.nio.*; - -/** - * Client handshake wrapper for direct marshalling. - */ -public class GridClientHandshakeResponseWrapper extends MessageAdapter { - /** */ - private static final long serialVersionUID = -1529807975073967381L; - - /** */ - private byte code; - - /** - * - */ - public GridClientHandshakeResponseWrapper() { - // No-op. - } - - /** - * @param code Response code. - */ - public GridClientHandshakeResponseWrapper(byte code) { - this.code = code; - } - - /** {@inheritDoc} */ - @Override public boolean writeTo(ByteBuffer buf) { - writer.setBuffer(buf); - - if (!typeWritten) { - if (!writer.writeByte(null, directType())) - return false; - - typeWritten = true; - } - - return true; - } - - /** {@inheritDoc} */ - @Override public boolean readFrom(ByteBuffer buf) { - return true; - } - - /** {@inheritDoc} */ - @Override public byte directType() { - return code; - } - - /** {@inheritDoc} */ - @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public MessageAdapter clone() { - GridClientHandshakeResponseWrapper _clone = new GridClientHandshakeResponseWrapper(); - - clone0(_clone); - - return _clone; - } - - /** {@inheritDoc} */ - @Override protected void clone0(MessageAdapter _msg) { - GridClientHandshakeResponseWrapper _clone = (GridClientHandshakeResponseWrapper)_msg; - - _clone.code = code; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(GridClientHandshakeResponseWrapper.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMessageWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMessageWrapper.java deleted file mode 100644 index 746a40f5c8203..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMessageWrapper.java +++ /dev/null @@ -1,275 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.rest.client.message; - -import org.apache.ignite.internal.direct.*; -import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.plugin.extensions.communication.*; - -import java.nio.*; -import java.util.*; - -/** - * Client message wrapper for direct marshalling. - */ -public class GridClientMessageWrapper extends MessageAdapter { - /** */ - private static final long serialVersionUID = 5284375300887454697L; - - /** Client request header. */ - public static final byte REQ_HEADER = (byte)0x90; - - /** Stream. */ - private final DirectByteBufferStream stream = new DirectByteBufferStream(null); - - /** */ - private int msgSize; - - /** */ - private long reqId; - - /** */ - private UUID clientId; - - /** */ - private UUID destId; - - /** */ - private ByteBuffer msg; - - /** - * @return Request ID. - */ - public long requestId() { - return reqId; - } - - /** - * @param reqId Request ID. - */ - public void requestId(long reqId) { - this.reqId = reqId; - } - - /** - * @return Message size. - */ - public int messageSize() { - return msgSize; - } - - /** - * @param msgSize Message size. - */ - public void messageSize(int msgSize) { - this.msgSize = msgSize; - } - - /** - * @return Client ID. - */ - public UUID clientId() { - return clientId; - } - - /** - * @param clientId Client ID. - */ - public void clientId(UUID clientId) { - this.clientId = clientId; - } - - /** - * @return Destination ID. - */ - public UUID destinationId() { - return destId; - } - - /** - * @param destId Destination ID. - */ - public void destinationId(UUID destId) { - this.destId = destId; - } - - /** - * @return Message buffer. - */ - public ByteBuffer message() { - return msg; - } - - /** - * @return Message bytes. - */ - public byte[] messageArray() { - assert msg.hasArray(); - assert msg.position() == 0 && msg.remaining() == msg.capacity(); - - return msg.array(); - } - - /** - * @param msg Message bytes. - */ - public void message(ByteBuffer msg) { - this.msg = msg; - } - - /** {@inheritDoc} */ - @Override public boolean writeTo(ByteBuffer buf) { - stream.setBuffer(buf); - - if (!typeWritten) { - if (stream.remaining() < 1) - return false; - - stream.writeByte(directType()); - - typeWritten = true; - } - - switch (state) { - case 0: - if (stream.remaining() < 4) - return false; - - stream.writeInt(msgSize); - - state++; - - case 1: - if (stream.remaining() < 8) - return false; - - stream.writeLong(reqId); - - state++; - - case 2: - if (stream.remaining() < 16) - return false; - - stream.writeByteArray(U.uuidToBytes(clientId), 0, 16); - - state++; - - case 3: - if (stream.remaining() < 16) - return false; - - stream.writeByteArray(U.uuidToBytes(destId), 0, 16); - - state++; - - case 4: - stream.writeByteArray(msg.array(), msg.position(), msg.remaining()); - - state++; - - } - - return true; - } - - /** {@inheritDoc} */ - @Override public boolean readFrom(ByteBuffer buf) { - stream.setBuffer(buf); - - switch (state) { - case 0: - if (stream.remaining() < 4) - return false; - - msgSize = stream.readInt(); - - if (msgSize == 0) // Ping message. - return true; - - state++; - - case 1: - if (stream.remaining() < 8) - return false; - - reqId = stream.readLong(); - - state++; - - case 2: - if (stream.remaining() < 16) - return false; - - clientId = U.bytesToUuid(stream.readByteArray(16), 0); - - state++; - - case 3: - if (stream.remaining() < 16) - return false; - - destId = U.bytesToUuid(stream.readByteArray(16), 0); - - state++; - - case 4: - byte[] msg0 = stream.readByteArray(msgSize); - - if (!stream.lastFinished()) - return false; - - msg = ByteBuffer.wrap(msg0); - - state++; - } - - return true; - } - - /** {@inheritDoc} */ - @Override public byte directType() { - return REQ_HEADER; - } - - /** {@inheritDoc} */ - @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public MessageAdapter clone() { - GridClientMessageWrapper _clone = new GridClientMessageWrapper(); - - clone0(_clone); - - return _clone; - } - - /** {@inheritDoc} */ - @Override protected void clone0(MessageAdapter _msg) { - GridClientMessageWrapper _clone = (GridClientMessageWrapper)_msg; - - _clone.reqId = reqId; - _clone.msgSize = msgSize; - _clone.clientId = clientId; - _clone.destId = destId; - _clone.msg = msg; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(GridClientMessageWrapper.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacketWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacketWrapper.java deleted file mode 100644 index ca8e80483b97a..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacketWrapper.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.rest.client.message; - -import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.plugin.extensions.communication.*; - -import java.nio.*; - -/** - * Ping packet wrapper for direct marshalling. - */ -public class GridClientPingPacketWrapper extends MessageAdapter { - /** */ - private static final long serialVersionUID = -3956036611004055629L; - - /** Ping message size (always zero). */ - private int size; - - /** {@inheritDoc} */ - @Override public boolean writeTo(ByteBuffer buf) { - writer.setBuffer(buf); - - if (!typeWritten) { - if (!writer.writeByte(null, directType())) - return false; - - typeWritten = true; - } - - switch (state) { - case 0: - if (!writer.writeInt("size", size)) - return false; - - state++; - - } - - return true; - } - - /** {@inheritDoc} */ - @Override public boolean readFrom(ByteBuffer buf) { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Override public byte directType() { - return GridClientMessageWrapper.REQ_HEADER; - } - - /** {@inheritDoc} */ - @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public MessageAdapter clone() { - GridClientPingPacketWrapper _clone = new GridClientPingPacketWrapper(); - - clone0(_clone); - - return _clone; - } - - /** {@inheritDoc} */ - @Override protected void clone0(MessageAdapter _msg) { - GridClientPingPacketWrapper _clone = (GridClientPingPacketWrapper)_msg; - - _clone.size = size; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(GridClientPingPacketWrapper.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridClientPacketType.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridClientPacketType.java index 0bc8099cb9548..e47e825a20182 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridClientPacketType.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridClientPacketType.java @@ -27,6 +27,9 @@ public enum GridClientPacketType { /** Ignite handshake. */ IGNITE_HANDSHAKE, + /** Ignite handshake response. */ + IGNITE_HANDSHAKE_RES, + /** Ignite message. */ IGNITE } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessage.java index 707383f09ea2f..a42fb577ebc9b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessage.java @@ -51,6 +51,9 @@ public class GridMemcachedMessage implements GridClientMessage { /** Client handshake flag. */ public static final byte IGNITE_HANDSHAKE_FLAG = (byte)0x91; + /** Client handshake flag. */ + public static final byte IGNITE_HANDSHAKE_RES_FLAG = (byte)0x92; + /** Success status. */ public static final int SUCCESS = 0x0000; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestDirectParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestDirectParser.java deleted file mode 100644 index b743e66c275bc..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestDirectParser.java +++ /dev/null @@ -1,523 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.rest.protocols.tcp; - -import org.apache.ignite.*; -import org.apache.ignite.client.marshaller.*; -import org.apache.ignite.internal.direct.*; -import org.apache.ignite.internal.processors.rest.client.message.*; -import org.apache.ignite.internal.util.nio.*; -import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.plugin.extensions.communication.*; -import org.jetbrains.annotations.*; - -import java.io.*; -import java.nio.*; -import java.nio.charset.*; -import java.util.*; - -import static org.apache.ignite.internal.processors.rest.protocols.tcp.GridMemcachedMessage.*; -import static org.apache.ignite.internal.util.nio.GridNioSessionMetaKey.*; - -/** - * - */ -public class GridTcpRestDirectParser implements GridNioParser { - /** UTF-8 charset. */ - private static final Charset UTF_8 = Charset.forName("UTF-8"); - - /** Message metadata key. */ - private static final int MSG_META_KEY = GridNioSessionMetaKey.nextUniqueKey(); - - /** Message reader. */ - private final MessageReader rdr = new DirectMessageReader(null); - - /** Protocol handler. */ - private final GridTcpRestProtocol proto; - - /** - * @param proto Protocol handler. - */ - public GridTcpRestDirectParser(GridTcpRestProtocol proto) { - this.proto = proto; - } - - /** {@inheritDoc} */ - @Nullable @Override public Object decode(GridNioSession ses, ByteBuffer buf) - throws IOException, IgniteCheckedException { - ParserState state = ses.removeMeta(PARSER_STATE.ordinal()); - - if (state != null) { - assert state.packetType() == GridClientPacketType.MEMCACHE; - - Object memcacheMsg = parseMemcachePacket(ses, buf, state); - - if (memcacheMsg == null) - ses.addMeta(PARSER_STATE.ordinal(), state); - - return memcacheMsg; - } - - MessageAdapter msg = ses.removeMeta(MSG_META_KEY); - - if (msg == null && buf.hasRemaining()) { - byte type = buf.get(buf.position()); - - if (type == GridClientMessageWrapper.REQ_HEADER) { - buf.get(); - - msg = new GridClientMessageWrapper(); - - msg.setReader(rdr); - } - else if (type == GridClientHandshakeRequestWrapper.HANDSHAKE_HEADER) { - buf.get(); - - msg = new GridClientHandshakeRequestWrapper(); - - msg.setReader(rdr); - } - else if (type == MEMCACHE_REQ_FLAG) { - state = new ParserState(); - - state.packet(new GridMemcachedMessage()); - state.packetType(GridClientPacketType.MEMCACHE); - - Object memcacheMsg = parseMemcachePacket(ses, buf, state); - - if (memcacheMsg == null) - ses.addMeta(PARSER_STATE.ordinal(), state); - - return memcacheMsg; - } - else - throw new IOException("Invalid message type: " + type); - } - - boolean finished = false; - - if (buf.hasRemaining()) - finished = msg.readFrom(buf); - - if (finished) { - if (msg instanceof GridClientMessageWrapper) { - GridClientMessageWrapper clientMsg = (GridClientMessageWrapper)msg; - - if (clientMsg.messageSize() == 0) - return GridClientPingPacket.PING_MESSAGE; - - GridClientMarshaller marsh = proto.marshaller(ses); - - GridClientMessage ret = marsh.unmarshal(clientMsg.messageArray()); - - ret.requestId(clientMsg.requestId()); - ret.clientId(clientMsg.clientId()); - ret.destinationId(clientMsg.destinationId()); - - return ret; - } - else { - assert msg instanceof GridClientHandshakeRequestWrapper; - - GridClientHandshakeRequestWrapper req = (GridClientHandshakeRequestWrapper)msg; - - GridClientHandshakeRequest ret = new GridClientHandshakeRequest(); - - ret.putBytes(req.bytes(), 0, 4); - - return ret; - } - } - else { - ses.addMeta(MSG_META_KEY, msg); - - return null; - } - } - - /** {@inheritDoc} */ - @Override public ByteBuffer encode(GridNioSession ses, Object msg) throws IOException, IgniteCheckedException { - // No encoding needed for direct messages. - throw new UnsupportedEncodingException(); - } - - /** - * Parses memcache protocol message. - * - * @param ses Session. - * @param buf Buffer containing not parsed bytes. - * @param state Current parser state. - * @return Parsed packet.s - * @throws IOException If packet cannot be parsed. - * @throws IgniteCheckedException If deserialization error occurred. - */ - @Nullable private GridClientMessage parseMemcachePacket(GridNioSession ses, ByteBuffer buf, ParserState state) - throws IOException, IgniteCheckedException { - assert state.packetType() == GridClientPacketType.MEMCACHE; - assert state.packet() != null; - assert state.packet() instanceof GridMemcachedMessage; - - GridMemcachedMessage req = (GridMemcachedMessage)state.packet(); - ByteArrayOutputStream tmp = state.buffer(); - int i = state.index(); - - while (buf.remaining() > 0) { - byte b = buf.get(); - - if (i == 0) - req.requestFlag(b); - else if (i == 1) - req.operationCode(b); - else if (i == 2 || i == 3) { - tmp.write(b); - - if (i == 3) { - req.keyLength(U.bytesToShort(tmp.toByteArray(), 0)); - - tmp.reset(); - } - } - else if (i == 4) - req.extrasLength(b); - else if (i >= 8 && i <= 11) { - tmp.write(b); - - if (i == 11) { - req.totalLength(U.bytesToInt(tmp.toByteArray(), 0)); - - tmp.reset(); - } - } - else if (i >= 12 && i <= 15) { - tmp.write(b); - - if (i == 15) { - req.opaque(tmp.toByteArray()); - - tmp.reset(); - } - } - else if (i >= HDR_LEN && i < HDR_LEN + req.extrasLength()) { - tmp.write(b); - - if (i == HDR_LEN + req.extrasLength() - 1) { - req.extras(tmp.toByteArray()); - - tmp.reset(); - } - } - else if (i >= HDR_LEN + req.extrasLength() && - i < HDR_LEN + req.extrasLength() + req.keyLength()) { - tmp.write(b); - - if (i == HDR_LEN + req.extrasLength() + req.keyLength() - 1) { - req.key(tmp.toByteArray()); - - tmp.reset(); - } - } - else if (i >= HDR_LEN + req.extrasLength() + req.keyLength() && - i < HDR_LEN + req.totalLength()) { - tmp.write(b); - - if (i == HDR_LEN + req.totalLength() - 1) { - req.value(tmp.toByteArray()); - - tmp.reset(); - } - } - - if (i == HDR_LEN + req.totalLength() - 1) - // Assembled the packet. - return assemble(ses, req); - - i++; - } - - state.index(i); - - return null; - } - - /** - * Validates incoming packet and deserializes all fields that need to be deserialized. - * - * @param ses Session on which packet is being parsed. - * @param req Raw packet. - * @return Same packet with fields deserialized. - * @throws IOException If parsing failed. - * @throws IgniteCheckedException If deserialization failed. - */ - private GridClientMessage assemble(GridNioSession ses, GridMemcachedMessage req) throws IOException, IgniteCheckedException { - byte[] extras = req.extras(); - - // First, decode key and value, if any - if (req.key() != null || req.value() != null) { - short keyFlags = 0; - short valFlags = 0; - - if (req.hasFlags()) { - if (extras == null || extras.length < FLAGS_LENGTH) - throw new IOException("Failed to parse incoming packet (flags required for command) [ses=" + - ses + ", opCode=" + Integer.toHexString(req.operationCode() & 0xFF) + ']'); - - keyFlags = U.bytesToShort(extras, 0); - valFlags = U.bytesToShort(extras, 2); - } - - if (req.key() != null) { - assert req.key() instanceof byte[]; - - byte[] rawKey = (byte[])req.key(); - - // Only values can be hessian-encoded. - req.key(decodeObj(keyFlags, rawKey)); - } - - if (req.value() != null) { - assert req.value() instanceof byte[]; - - byte[] rawVal = (byte[])req.value(); - - req.value(decodeObj(valFlags, rawVal)); - } - } - - if (req.hasExpiration()) { - if (extras == null || extras.length < 8) - throw new IOException("Failed to parse incoming packet (expiration value required for command) [ses=" + - ses + ", opCode=" + Integer.toHexString(req.operationCode() & 0xFF) + ']'); - - req.expiration(U.bytesToInt(extras, 4) & 0xFFFFFFFFL); - } - - if (req.hasInitial()) { - if (extras == null || extras.length < 16) - throw new IOException("Failed to parse incoming packet (initial value required for command) [ses=" + - ses + ", opCode=" + Integer.toHexString(req.operationCode() & 0xFF) + ']'); - - req.initial(U.bytesToLong(extras, 8)); - } - - if (req.hasDelta()) { - if (extras == null || extras.length < 8) - throw new IOException("Failed to parse incoming packet (delta value required for command) [ses=" + - ses + ", opCode=" + Integer.toHexString(req.operationCode() & 0xFF) + ']'); - - req.delta(U.bytesToLong(extras, 0)); - } - - if (extras != null) { - // Clients that include cache name must always include flags. - int len = 4; - - if (req.hasExpiration()) - len += 4; - - if (req.hasDelta()) - len += 8; - - if (req.hasInitial()) - len += 8; - - if (extras.length - len > 0) { - byte[] cacheName = new byte[extras.length - len]; - - U.arrayCopy(extras, len, cacheName, 0, extras.length - len); - - req.cacheName(new String(cacheName, UTF_8)); - } - } - - return req; - } - - /** - * Decodes value from a given byte array to the object according to the flags given. - * - * @param flags Flags. - * @param bytes Byte array to decode. - * @return Decoded value. - * @throws IgniteCheckedException If deserialization failed. - */ - private Object decodeObj(short flags, byte[] bytes) throws IgniteCheckedException { - assert bytes != null; - - if ((flags & SERIALIZED_FLAG) != 0) - return proto.jdkMarshaller().unmarshal(bytes, null); - - int masked = flags & 0xff00; - - switch (masked) { - case BOOLEAN_FLAG: - return bytes[0] == '1'; - case INT_FLAG: - return U.bytesToInt(bytes, 0); - case LONG_FLAG: - return U.bytesToLong(bytes, 0); - case DATE_FLAG: - return new Date(U.bytesToLong(bytes, 0)); - case BYTE_FLAG: - return bytes[0]; - case FLOAT_FLAG: - return Float.intBitsToFloat(U.bytesToInt(bytes, 0)); - case DOUBLE_FLAG: - return Double.longBitsToDouble(U.bytesToLong(bytes, 0)); - case BYTE_ARR_FLAG: - return bytes; - default: - return new String(bytes, UTF_8); - } - } - - /** - * Holder for parser state and temporary buffer. - */ - protected static class ParserState { - /** Parser index. */ - private int idx; - - /** Temporary data buffer. */ - private ByteArrayOutputStream buf = new ByteArrayOutputStream(); - - /** Packet being assembled. */ - private GridClientMessage packet; - - /** Packet type. */ - private GridClientPacketType packetType; - - /** Header data. */ - private HeaderData hdr; - - /** - * @return Stored parser index. - */ - public int index() { - return idx; - } - - /** - * @param idx Index to store. - */ - public void index(int idx) { - this.idx = idx; - } - - /** - * @return Temporary data buffer. - */ - public ByteArrayOutputStream buffer() { - return buf; - } - - /** - * @return Pending packet. - */ - @Nullable public GridClientMessage packet() { - return packet; - } - - /** - * @param packet Pending packet. - */ - public void packet(GridClientMessage packet) { - assert this.packet == null; - - this.packet = packet; - } - - /** - * @return Pending packet type. - */ - public GridClientPacketType packetType() { - return packetType; - } - - /** - * @param packetType Pending packet type. - */ - public void packetType(GridClientPacketType packetType) { - this.packetType = packetType; - } - - /** - * @return Header. - */ - public HeaderData header() { - return hdr; - } - - /** - * @param hdr Header. - */ - public void header(HeaderData hdr) { - this.hdr = hdr; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(ParserState.class, this); - } - } - - /** - * Header. - */ - protected static class HeaderData { - /** Request Id. */ - private final long reqId; - - /** Request Id. */ - private final UUID clientId; - - /** Request Id. */ - private final UUID destId; - - /** - * @param reqId Request Id. - * @param clientId Client Id. - * @param destId Destination Id. - */ - private HeaderData(long reqId, UUID clientId, UUID destId) { - this.reqId = reqId; - this.clientId = clientId; - this.destId = destId; - } - - /** - * @return Request Id. - */ - public long reqId() { - return reqId; - } - - /** - * @return Client Id. - */ - public UUID clientId() { - return clientId; - } - - /** - * @return Destination Id. - */ - public UUID destinationId() { - return destId; - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestNioListener.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestNioListener.java index 12dc711268eb7..159f178961368 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestNioListener.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestNioListener.java @@ -29,14 +29,11 @@ import org.apache.ignite.internal.util.typedef.internal.*; import org.jetbrains.annotations.*; -import java.io.*; -import java.nio.*; import java.util.*; import java.util.concurrent.*; import static org.apache.ignite.internal.processors.rest.GridRestCommand.*; import static org.apache.ignite.internal.processors.rest.client.message.GridClientCacheRequest.GridCacheOperation.*; -import static org.apache.ignite.internal.processors.rest.client.message.GridClientHandshakeResponse.*; import static org.apache.ignite.internal.util.nio.GridNioSessionMetaKey.*; /** @@ -138,7 +135,7 @@ void marshallers(Map marshMap) { memcachedLsnr.onMessage(ses, (GridMemcachedMessage)msg); else { if (msg == GridClientPingPacket.PING_MESSAGE) - ses.send(new GridClientPingPacketWrapper()); + ses.send(new GridClientPingPacket()); else if (msg instanceof GridClientHandshakeRequest) { GridClientHandshakeRequest hs = (GridClientHandshakeRequest)msg; @@ -168,7 +165,7 @@ else if (msg instanceof GridClientHandshakeRequest) { else { ses.addMeta(MARSHALLER.ordinal(), marsh); - ses.send(new GridClientHandshakeResponseWrapper(CODE_OK)); + ses.send(GridClientHandshakeResponse.OK); } } } @@ -205,27 +202,7 @@ else if (msg instanceof GridClientHandshakeRequest) { res.errorMessage("Failed to process client request: " + e.getMessage()); } - GridClientMessageWrapper wrapper = new GridClientMessageWrapper(); - - wrapper.requestId(msg.requestId()); - wrapper.clientId(msg.clientId()); - - try { - ByteBuffer bytes = proto.marshaller(ses).marshal(res, 0); - - wrapper.message(bytes); - - wrapper.messageSize(bytes.remaining() + 40); - } - catch (IOException e) { - U.error(log, "Failed to marshal response: " + res, e); - - ses.close(); - - return; - } - - ses.send(wrapper); + ses.send(res); } }); else diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java index d94b598369907..978ae616f0033 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java @@ -81,6 +81,13 @@ public class GridTcpRestParser implements GridNioParser { break; + case IGNITE_HANDSHAKE_RES_FLAG: + buf.get(); + + state.packetType(GridClientPacketType.IGNITE_HANDSHAKE_RES); + + break; + default: throw new IOException("Failed to parse incoming packet (invalid packet start) [ses=" + ses + ", b=" + Integer.toHexString(hdr & 0xFF) + ']'); @@ -100,6 +107,12 @@ public class GridTcpRestParser implements GridNioParser { break; + case IGNITE_HANDSHAKE_RES: + if (buf.hasRemaining()) + res = new GridClientHandshakeResponse(buf.get()); + + break; + case IGNITE: res = parseCustomPacket(ses, buf, state); @@ -123,8 +136,21 @@ public class GridTcpRestParser implements GridNioParser { return encodeMemcache((GridMemcachedMessage)msg); else if (msg == GridClientPingPacket.PING_MESSAGE) return ByteBuffer.wrap(GridClientPingPacket.PING_PACKET); + else if (msg instanceof GridClientHandshakeRequest) { + byte[] bytes = ((GridClientHandshakeRequest)msg).rawBytes(); + + ByteBuffer buf = ByteBuffer.allocate(bytes.length + 1); + + buf.put(IGNITE_HANDSHAKE_FLAG); + buf.put(bytes); + + buf.flip(); + + return buf; + } else if (msg instanceof GridClientHandshakeResponse) return ByteBuffer.wrap(new byte[] { + IGNITE_HANDSHAKE_RES_FLAG, ((GridClientHandshakeResponse)msg).resultCode() }); else { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestProtocol.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestProtocol.java index c0c63a4150d1a..19971e1ba763b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestProtocol.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestProtocol.java @@ -106,7 +106,7 @@ boolean portableMode(GridNioSession ses) { lsnr = new GridTcpRestNioListener(log, this, hnd, ctx); - GridNioParser parser = new GridTcpRestDirectParser(this); + GridNioParser parser = new GridTcpRestParser(); try { host = resolveRestTcpHost(ctx.config()); @@ -207,14 +207,14 @@ private InetAddress resolveRestTcpHost(IgniteConfiguration cfg) throws IOExcepti private boolean startTcpServer(InetAddress hostAddr, int port, GridNioServerListener lsnr, GridNioParser parser, @Nullable SSLContext sslCtx, ClientConnectionConfiguration cfg) { try { - GridNioFilter codec = new GridNioCodecFilter(parser, log, true); + GridNioFilter codec = new GridNioCodecFilter(parser, log, false); GridNioFilter[] filters; if (sslCtx != null) { GridNioSslFilter sslFilter = new GridNioSslFilter(sslCtx, log); - sslFilter.directMode(true); + sslFilter.directMode(false); boolean auth = cfg.isRestTcpSslClientAuth(); @@ -244,7 +244,7 @@ private boolean startTcpServer(InetAddress hostAddr, int port, GridNioServerList .socketReceiveBufferSize(cfg.getRestTcpReceiveBufferSize()) .sendQueueLimit(cfg.getRestTcpSendQueueLimit()) .filters(filters) - .directMode(true) + .directMode(false) .build(); srv.idleTimeout(cfg.getRestIdleTimeout()); From 44ab171e1ed9d86161b4757e6ca7fba090bfaa29 Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Mon, 9 Feb 2015 00:35:19 -0800 Subject: [PATCH 68/95] # IGNITE-61 - Fixing client --- .../ignite/internal/processors/rest/TestBinaryClient.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/TestBinaryClient.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/TestBinaryClient.java index 21e5f8c172239..fd7cbd79788bf 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/TestBinaryClient.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/TestBinaryClient.java @@ -21,6 +21,7 @@ import org.apache.ignite.client.marshaller.*; import org.apache.ignite.client.marshaller.optimized.*; import org.apache.ignite.internal.processors.rest.client.message.*; +import org.apache.ignite.internal.processors.rest.protocols.tcp.*; import org.apache.ignite.internal.util.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; @@ -88,7 +89,7 @@ final class TestBinaryClient { req.marshallerId(GridClientOptimizedMarshaller.ID); // Write handshake. - sock.getOutputStream().write(GridClientHandshakeRequestWrapper.HANDSHAKE_HEADER); + sock.getOutputStream().write(GridMemcachedMessage.IGNITE_HANDSHAKE_FLAG); sock.getOutputStream().write(req.rawBytes()); byte[] buf = new byte[1]; From dd1c2d8a7f0f7e86caed9a3a39fe1d440e7ae852 Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Mon, 9 Feb 2015 01:18:18 -0800 Subject: [PATCH 69/95] # IGNITE-61 - Fixing client --- .../communication/GridIoMessageFactory.java | 6 - .../tcp/GridMemcachedMessageWrapper.java | 268 ------------------ .../tcp/GridTcpMemcachedNioListener.java | 13 +- 3 files changed, 1 insertion(+), 286 deletions(-) delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java index 0f46e3d434d1d..c1c2c54ec55be 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java @@ -35,7 +35,6 @@ import org.apache.ignite.internal.processors.dataload.*; import org.apache.ignite.internal.processors.fs.*; import org.apache.ignite.internal.processors.rest.handlers.task.*; -import org.apache.ignite.internal.processors.rest.protocols.tcp.*; import org.apache.ignite.internal.processors.streamer.*; import org.apache.ignite.internal.util.*; import org.apache.ignite.lang.*; @@ -454,11 +453,6 @@ public GridIoMessageFactory(MessageReaderFactory readerFactory, MessageFactory[] break; - case 78: - msg = new GridMemcachedMessageWrapper(); - - break; - case 79: msg = new GridStreamerCancelRequest(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java deleted file mode 100644 index d086efe812a47..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java +++ /dev/null @@ -1,268 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.rest.protocols.tcp; - -import org.apache.ignite.*; -import org.apache.ignite.internal.direct.*; -import org.apache.ignite.internal.util.*; -import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.marshaller.*; -import org.apache.ignite.plugin.extensions.communication.*; - -import java.io.*; -import java.nio.*; -import java.nio.charset.*; -import java.util.*; - -import static org.apache.ignite.internal.processors.rest.protocols.tcp.GridMemcachedMessage.*; - -/** - * Memcached message wrapper for direct marshalling. - */ -public class GridMemcachedMessageWrapper extends MessageAdapter { - /** */ - private static final long serialVersionUID = 3053626103006980626L; - - /** UTF-8 charset. */ - private static final Charset UTF_8 = Charset.forName("UTF-8"); - - /** Stream. */ - private final DirectByteBufferStream stream = new DirectByteBufferStream(null); - - /** - * Memcached message bytes. - */ - private byte[] bytes; - - /** - * - */ - public GridMemcachedMessageWrapper() { - // No-op. - } - - /** - * @param msg Message. - * @param jdkMarshaller JDK marshaller. - * @throws IgniteCheckedException If failed to marshal. - */ - public GridMemcachedMessageWrapper(GridMemcachedMessage msg, Marshaller jdkMarshaller) throws IgniteCheckedException { - bytes = encodeMemcache(msg, jdkMarshaller); - } - - /** {@inheritDoc} */ - @Override public boolean writeTo(ByteBuffer buf) { - stream.setBuffer(buf); - - if (!typeWritten) { - if (!buf.hasRemaining()) - return false; - - stream.writeByte(directType()); - - typeWritten = true; - } - - stream.writeByteArray(bytes, 0, bytes.length); - - return stream.lastFinished(); - } - - /** {@inheritDoc} */ - @Override public boolean readFrom(ByteBuffer buf) { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Override public byte directType() { - return MEMCACHE_RES_FLAG; - } - - /** {@inheritDoc} */ - @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) - @Override public MessageAdapter clone() { - GridMemcachedMessageWrapper _clone = new GridMemcachedMessageWrapper(); - - clone0(_clone); - - return _clone; - } - - /** {@inheritDoc} */ - @Override protected void clone0(MessageAdapter _msg) { - GridMemcachedMessageWrapper _clone = (GridMemcachedMessageWrapper)_msg; - - _clone.bytes = bytes; - } - - /** - * Encodes memcache message to a raw byte array. - * - * @param msg Message being serialized. - * @param jdkMarshaller JDK marshaller. - * @return Serialized message. - * @throws IgniteCheckedException If serialization failed. - */ - private byte[] encodeMemcache(GridMemcachedMessage msg, Marshaller jdkMarshaller) throws IgniteCheckedException { - GridByteArrayList res = new GridByteArrayList(HDR_LEN - 1); - - int keyLen = 0; - - int keyFlags = 0; - - if (msg.key() != null) { - ByteArrayOutputStream rawKey = new ByteArrayOutputStream(); - - keyFlags = encodeObj(msg.key(), rawKey, jdkMarshaller); - - msg.key(rawKey.toByteArray()); - - keyLen = rawKey.size(); - } - - int dataLen = 0; - - int valFlags = 0; - - if (msg.value() != null) { - ByteArrayOutputStream rawVal = new ByteArrayOutputStream(); - - valFlags = encodeObj(msg.value(), rawVal, jdkMarshaller); - - msg.value(rawVal.toByteArray()); - - dataLen = rawVal.size(); - } - - int flagsLen = 0; - - if (msg.addFlags()) - flagsLen = FLAGS_LENGTH; - - res.add(msg.operationCode()); - - // Cast is required due to packet layout. - res.add((short)keyLen); - - // Cast is required due to packet layout. - res.add((byte)flagsLen); - - // Data type is always 0x00. - res.add((byte)0x00); - - res.add((short)msg.status()); - - res.add(keyLen + flagsLen + dataLen); - - res.add(msg.opaque(), 0, msg.opaque().length); - - // CAS, unused. - res.add(0L); - - assert res.size() == HDR_LEN - 1; - - if (flagsLen > 0) { - res.add((short) keyFlags); - res.add((short) valFlags); - } - - assert msg.key() == null || msg.key() instanceof byte[]; - assert msg.value() == null || msg.value() instanceof byte[]; - - if (keyLen > 0) - res.add((byte[])msg.key(), 0, ((byte[])msg.key()).length); - - if (dataLen > 0) - res.add((byte[])msg.value(), 0, ((byte[])msg.value()).length); - - return res.entireArray(); - } - - /** - * Encodes given object to a byte array and returns flags that describe the type of serialized object. - * - * @param obj Object to serialize. - * @param out Output stream to which object should be written. - * @param jdkMarshaller JDK marshaller. - * @return Serialization flags. - * @throws IgniteCheckedException If JDK serialization failed. - */ - private int encodeObj(Object obj, ByteArrayOutputStream out, Marshaller jdkMarshaller) throws IgniteCheckedException { - int flags = 0; - - byte[] data = null; - - if (obj instanceof String) - data = ((String)obj).getBytes(UTF_8); - else if (obj instanceof Boolean) { - data = new byte[] {(byte)((Boolean)obj ? '1' : '0')}; - - flags |= BOOLEAN_FLAG; - } - else if (obj instanceof Integer) { - data = U.intToBytes((Integer) obj); - - flags |= INT_FLAG; - } - else if (obj instanceof Long) { - data = U.longToBytes((Long)obj); - - flags |= LONG_FLAG; - } - else if (obj instanceof Date) { - data = U.longToBytes(((Date)obj).getTime()); - - flags |= DATE_FLAG; - } - else if (obj instanceof Byte) { - data = new byte[] {(Byte)obj}; - - flags |= BYTE_FLAG; - } - else if (obj instanceof Float) { - data = U.intToBytes(Float.floatToIntBits((Float)obj)); - - flags |= FLOAT_FLAG; - } - else if (obj instanceof Double) { - data = U.longToBytes(Double.doubleToLongBits((Double)obj)); - - flags |= DOUBLE_FLAG; - } - else if (obj instanceof byte[]) { - data = (byte[])obj; - - flags |= BYTE_ARR_FLAG; - } - else { - jdkMarshaller.marshal(obj, out); - - flags |= SERIALIZED_FLAG; - } - - if (data != null) - out.write(data, 0, data.length); - - return flags; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(GridMemcachedMessageWrapper.class, this); - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpMemcachedNioListener.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpMemcachedNioListener.java index 070546ea04525..43e47cd241324 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpMemcachedNioListener.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpMemcachedNioListener.java @@ -244,18 +244,7 @@ public GridTcpMemcachedNioListener(IgniteLogger log, GridRestProtocolHandler hnd * @return NIO send future. */ private GridNioFuture sendResponse(GridNioSession ses, GridMemcachedMessage res) { - try { - GridMemcachedMessageWrapper wrapper = new GridMemcachedMessageWrapper(res, jdkMarshaller); - - return ses.send(wrapper); - } - catch (IgniteCheckedException e) { - U.error(log, "Failed to marshal response: " + res, e); - - ses.close(); - - return new GridNioFinishedFuture<>(e); - } + return ses.send(res); } /** From 40715c9eb9e1da727564b1a48f74e3aedae01677 Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Mon, 9 Feb 2015 08:47:18 -0800 Subject: [PATCH 70/95] Merge branch 'ignite-sprint-1' of github.com:ggprivate/ggprivate into ignite-61 Conflicts: modules/core/src/test/java/org/gridgain/grid/kernal/version/GridVersionConvertersSelfTest.java --- .../org/apache/ignite/internal/GridKernalContext.java | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java index 8f11e8d6e9bbc..152cfa67003af 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java @@ -501,17 +501,6 @@ public interface GridKernalContext extends Iterable { */ public T createComponent(Class cls); - /** - * @return Message factory. - */ - public GridTcpMessageFactory messageFactory(); - - /** - * @param producer Message producer. - * @return Message type code. - */ - public byte registerMessageProducer(GridTcpCommunicationMessageProducer producer); - /** * @return Thread pool implementation to be used in grid to process job execution * requests and user messages sent to the node. From 63025059a24045b4b4f315ad02748e385a29029f Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Mon, 9 Feb 2015 10:43:09 -0800 Subject: [PATCH 71/95] IGNITE-61 - Direct marshalling --- .../ignite/internal/processors/cache/GridCacheValueBytes.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheValueBytes.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheValueBytes.java index cf12c71883cde..03f20c6cd402e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheValueBytes.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheValueBytes.java @@ -27,6 +27,9 @@ * Wrapped value bytes of cache entry. */ public class GridCacheValueBytes extends MessageAdapter { + /** */ + private static final long serialVersionUID = 0L; + /** Null instance. */ private static final GridCacheValueBytes NULL = new GridCacheValueBytes(); From 2a6aa9fb4af19efdbea0884355a2f81491fb1659 Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Mon, 9 Feb 2015 11:00:55 -0800 Subject: [PATCH 72/95] IGNITE-61 - Direct marshalling --- .../misc/client/memcache/MemcacheRestExampleNodeStartup.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/src/main/java/org/apache/ignite/examples/misc/client/memcache/MemcacheRestExampleNodeStartup.java b/examples/src/main/java/org/apache/ignite/examples/misc/client/memcache/MemcacheRestExampleNodeStartup.java index fdd369b15a293..cf9aee219bc80 100644 --- a/examples/src/main/java/org/apache/ignite/examples/misc/client/memcache/MemcacheRestExampleNodeStartup.java +++ b/examples/src/main/java/org/apache/ignite/examples/misc/client/memcache/MemcacheRestExampleNodeStartup.java @@ -61,6 +61,8 @@ public static IgniteConfiguration configuration() throws IgniteException { cfg.setDeploymentMode(SHARED); cfg.setPeerClassLoadingEnabled(true); + cfg.setClientConnectionConfiguration(new ClientConnectionConfiguration()); + OptimizedMarshaller marsh = new OptimizedMarshaller(); marsh.setRequireSerializable(false); From 4e434848b9fd26ef78b0210f622ffd0ffd332f64 Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Mon, 9 Feb 2015 11:05:55 -0800 Subject: [PATCH 73/95] IGNITE-61 - Direct marshalling --- .../internal/processors/rest/TestBinaryClient.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/TestBinaryClient.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/TestBinaryClient.java index fd7cbd79788bf..d34f42138665b 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/TestBinaryClient.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/TestBinaryClient.java @@ -92,14 +92,15 @@ final class TestBinaryClient { sock.getOutputStream().write(GridMemcachedMessage.IGNITE_HANDSHAKE_FLAG); sock.getOutputStream().write(req.rawBytes()); - byte[] buf = new byte[1]; + byte[] buf = new byte[2]; // Wait for handshake response. int read = input.read(buf); - assert read == 1 : read; + assert read == 2 : read; - assert buf[0] == GridClientHandshakeResponse.OK.resultCode() : + assert buf[0] == GridMemcachedMessage.IGNITE_HANDSHAKE_RES_FLAG; + assert buf[1] == GridClientHandshakeResponse.OK.resultCode() : "Client handshake failed [code=" + buf[0] + ']'; } catch (IOException e) { @@ -275,8 +276,6 @@ private byte[] createPacket(GridClientMessage msg) throws IOException { ByteBuffer slice = res.slice(); - slice.order(ByteOrder.LITTLE_ENDIAN); - slice.put((byte)0x90); slice.putInt(res.remaining() - 5); slice.putLong(msg.requestId()); From d58e8085af062ac591ce4b57c3adcd39786efbb7 Mon Sep 17 00:00:00 2001 From: sboikov Date: Mon, 9 Feb 2015 23:03:56 +0300 Subject: [PATCH 74/95] # ignite-57 --- .../ignite/internal/ClusterGroupAdapter.java | 6 +++ .../ignite/internal/ClusterGroupEx.java | 9 ++++ .../processors/cache/GridCacheAdapter.java | 45 ++++++++----------- .../GridCacheAbstractFullApiSelfTest.java | 28 ++++++------ ...tomicNearOnlyMultiNodeFullApiSelfTest.java | 1 - ...CacheNearOnlyMultiNodeFullApiSelfTest.java | 18 +++++--- 6 files changed, 59 insertions(+), 48 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/ClusterGroupAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/ClusterGroupAdapter.java index d966434f35669..eb747125da775 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/ClusterGroupAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/ClusterGroupAdapter.java @@ -555,6 +555,12 @@ private ClusterGroup forOthers(Collection excludeIds) { return forPredicate(new StreamersFilter(streamerName, streamerNames)); } + /** {@inheritDoc} */ + @Override public ClusterGroup forCacheNodes(@Nullable String cacheName, + Set distributionModes) { + return forPredicate(new CachesFilter(cacheName, distributionModes)); + } + /** {@inheritDoc} */ @Override public final ClusterGroup forHost(ClusterNode node) { A.notNull(node, "node"); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/ClusterGroupEx.java b/modules/core/src/main/java/org/apache/ignite/internal/ClusterGroupEx.java index ac1fffabfb869..faaab85523f36 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/ClusterGroupEx.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/ClusterGroupEx.java @@ -17,7 +17,9 @@ package org.apache.ignite.internal; +import org.apache.ignite.cache.*; import org.apache.ignite.cluster.*; +import org.jetbrains.annotations.*; import java.util.*; @@ -32,4 +34,11 @@ public interface ClusterGroupEx extends ClusterGroup { * @return Internal projection. */ public ClusterGroupEx forSubjectId(UUID subjId); + + /** + * @param cacheName Cache name. + * @param distributionModes Cache distribution modes. + * @return Cluster group. + */ + public ClusterGroup forCacheNodes(@Nullable String cacheName, Set distributionModes); } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java index 6cd9e4952da9d..fdee08e3a9f01 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java @@ -82,6 +82,12 @@ public abstract class GridCacheAdapter implements GridCache, /** clearLocally() split threshold. */ public static final int CLEAR_ALL_SPLIT_THRESHOLD = 10000; + /** Distribution modes to include into global size calculation. */ + private static final Set SIZE_NODES = EnumSet.of( + CacheDistributionMode.NEAR_PARTITIONED, + CacheDistributionMode.PARTITIONED_ONLY, + CacheDistributionMode.NEAR_ONLY); + /** Deserialization stash. */ private static final ThreadLocal> stash = new ThreadLocal>() { @@ -4083,31 +4089,6 @@ IgniteInternalFuture globalLoadCacheAsync(@Nullable IgniteBiPredicate p return e == null || e.obsolete() ? null : e.wrap(true); } - /** - * @return Random entry. - * @throws IgniteCheckedException If failed. - */ - public Cache.Entry randomCacheEntry() throws IgniteCheckedException { - boolean keepPortable = ctx.keepPortable(); - - while (true) { - GridCacheMapEntry e = map.randomEntry(); - - if (e == null) - return null; - - try { - Cache.Entry entry = toCacheEntry(e, !keepPortable); - - if (entry != null) - return entry; - } - catch (GridCacheEntryRemovedException ignore) { - // No-op. - } - } - } - /** {@inheritDoc} */ @Override public int size(CachePeekMode[] peekModes) throws IgniteCheckedException { if (isLocal()) @@ -4120,7 +4101,16 @@ public Cache.Entry randomCacheEntry() throws IgniteCheckedException { @Override public IgniteInternalFuture sizeAsync(CachePeekMode[] peekModes) { assert peekModes != null; - Collection nodes = ctx.grid().forCacheNodes(name()).nodes(); + PeekModes modes = parsePeekModes(peekModes); + + ClusterGroup grp; + + if (modes.near) + grp = ctx.grid().forCacheNodes(name(), SIZE_NODES); + else + grp = ctx.grid().forDataNodes(name()); + + Collection nodes = grp.nodes(); if (nodes.isEmpty()) return new GridFinishedFuture<>(ctx.kernalContext(), 0); @@ -4129,7 +4119,8 @@ public Cache.Entry randomCacheEntry() throws IgniteCheckedException { ctx.closures().broadcastNoFailover(new SizeCallable(ctx.name(), peekModes), null, nodes); return fut.chain(new CX1>, Integer>() { - @Override public Integer applyx(IgniteInternalFuture> fut) throws IgniteCheckedException { + @Override public Integer applyx(IgniteInternalFuture> fut) + throws IgniteCheckedException { Collection res = fut.get(); int totalSize = 0; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java index e3fb1b5525282..420b19dfc8c8d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java @@ -2199,13 +2199,15 @@ public void testGlobalRemoveAllAsync() throws Exception { * @throws Exception In case of error. */ private void globalRemoveAll(boolean async) throws Exception { - jcache().put("key1", 1); - jcache().put("key2", 2); - jcache().put("key3", 3); + IgniteCache cache = jcache(); + + cache.put("key1", 1); + cache.put("key2", 2); + cache.put("key3", 3); checkSize(F.asSet("key1", "key2", "key3")); - IgniteCache asyncCache = jcache().withAsync(); + IgniteCache asyncCache = cache.withAsync(); if (async) { asyncCache.removeAll(F.asSet("key1", "key2")); @@ -2213,7 +2215,7 @@ private void globalRemoveAll(boolean async) throws Exception { asyncCache.future().get(); } else - jcache().removeAll(F.asSet("key1", "key2")); + cache.removeAll(F.asSet("key1", "key2")); checkSize(F.asSet("key3")); @@ -2222,9 +2224,9 @@ private void globalRemoveAll(boolean async) throws Exception { checkContainsKey(true, "key3"); // Put values again. - jcache().put("key1", 1); - jcache().put("key2", 2); - jcache().put("key3", 3); + cache.put("key1", 1); + cache.put("key2", 2); + cache.put("key3", 3); if (async) { IgniteCache asyncCache0 = jcache(gridCount() > 1 ? 1 : 0).withAsync(); @@ -2236,14 +2238,14 @@ private void globalRemoveAll(boolean async) throws Exception { else jcache(gridCount() > 1 ? 1 : 0).removeAll(); - assert cache().isEmpty(); + assertEquals(0, cache.localSize()); long entryCnt = hugeRemoveAllEntryCount(); for (int i = 0; i < entryCnt; i++) - cache().put(String.valueOf(i), i); + cache.put(String.valueOf(i), i); for (int i = 0; i < entryCnt; i++) - assertEquals(Integer.valueOf(i), cache().get(String.valueOf(i))); + assertEquals(Integer.valueOf(i), cache.get(String.valueOf(i))); if (async) { asyncCache.removeAll(); @@ -2251,10 +2253,10 @@ private void globalRemoveAll(boolean async) throws Exception { asyncCache.future().get(); } else - cache().removeAll(); + cache.removeAll(); for (int i = 0; i < entryCnt; i++) - assertNull(cache().get(String.valueOf(i))); + assertNull(cache.get(String.valueOf(i))); } /** diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest.java index deebb634afe7a..a431d831b6d1b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest.java @@ -112,7 +112,6 @@ public class GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest extends GridCacheNe for (String key : keys) assertEquals((Integer)i++, nearCache.localPeek(key, CachePeekMode.ONHEAP)); - } /** {@inheritDoc} */ diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java index ca2e3c573c615..945b05b049a8e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java @@ -98,7 +98,7 @@ public class GridCacheNearOnlyMultiNodeFullApiSelfTest extends GridCachePartitio GridCacheAttributes[] nodeAttrs = node.attribute(IgniteNodeAttributes.ATTR_CACHE); - info("Cache attribtues for node [nodeId=" + node.id() + ", attrs=" + + info("Cache attributes for node [nodeId=" + node.id() + ", attrs=" + Arrays.asList(nodeAttrs) + ']'); } @@ -238,23 +238,27 @@ protected IgniteCache fullCache() { // Save entries only on their primary nodes. If we didn't do so, clearLocally() will not remove all entries // because some of them were blocked due to having readers. for (int i = 0; i < gridCount(); i++) { - if (i != nearIdx) - for (String key : primaryKeysForCache(jcache(i), 3)) + if (i != nearIdx) { + for (String key : primaryKeysForCache(jcache(i), 3, 100_000)) jcache(i).put(key, 1); + } } if (async) { - IgniteCache asyncCache = jcache().withAsync(); + IgniteCache asyncCache = jcache(nearIdx).withAsync(); asyncCache.clear(); asyncCache.future().get(); } else - jcache().clear(); + jcache(nearIdx).clear(); - for (int i = 0; i < gridCount(); i++) - assertEquals(ignite(i).name(), 0, jcache(i).localSize()); + for (int i = 0; i < gridCount(); i++) { + assertEquals("Unexpected size [node=" + ignite(i).name() + ", nearIdx=" + nearIdx + ']', + 0, + jcache(i).localSize()); + } } /** {@inheritDoc} */ From d4ddf85c95b1dc121d943494ef3dad3a6b5b849d Mon Sep 17 00:00:00 2001 From: sboikov Date: Mon, 9 Feb 2015 23:11:28 +0300 Subject: [PATCH 75/95] # ignite-57 --- .../processors/cache/GridCacheAdapter.java | 122 +++---- .../cache/GridCacheSwapManager.java | 2 +- .../cache/IgniteCachePeekAbstractTest.java | 333 ------------------ 3 files changed, 46 insertions(+), 411 deletions(-) delete mode 100644 modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekAbstractTest.java diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java index fdee08e3a9f01..55c9445a0aeeb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java @@ -1296,22 +1296,22 @@ public Set> allEntries() { /** {@inheritDoc} */ @Override public Set> primaryEntrySet() { - return primaryEntrySet((IgnitePredicate>[]) null); + return primaryEntrySet((IgnitePredicate>[])null); } /** {@inheritDoc} */ @Override public Set keySet() { - return keySet((IgnitePredicate>[]) null); + return keySet((IgnitePredicate>[])null); } /** {@inheritDoc} */ @Override public Set primaryKeySet() { - return primaryKeySet((IgnitePredicate>[]) null); + return primaryKeySet((IgnitePredicate>[])null); } /** {@inheritDoc} */ @Override public Collection values() { - return values((IgnitePredicate>[]) null); + return values((IgnitePredicate>[])null); } /** {@inheritDoc} */ @@ -1611,8 +1611,7 @@ private boolean evictx(K key, GridCacheVersion ver, return getAllAsync(Collections.singletonList(key), /*force primary*/true, /*skip tx*/false, null, null, taskName, true).chain(new CX1>, V>() { - @Override - public V applyx(IgniteInternalFuture> e) throws IgniteCheckedException { + @Override public V applyx(IgniteInternalFuture> e) throws IgniteCheckedException { return e.get().get(key); } }); @@ -1634,7 +1633,7 @@ public V applyx(IgniteInternalFuture> e) throws IgniteCheckedException /** {@inheritDoc} */ @Nullable @Override public V reload(K key) throws IgniteCheckedException { - return reload(key, (IgnitePredicate>[]) null); + return reload(key, (IgnitePredicate>[])null); } /** {@inheritDoc} */ @@ -1663,7 +1662,7 @@ public V applyx(IgniteInternalFuture> e) throws IgniteCheckedException @Override public IgniteInternalFuture reloadAllAsync() { ctx.denyOnFlags(F.asList(LOCAL, READ)); - return reloadAllAsync(keySet(), (IgnitePredicate>[]) null); + return reloadAllAsync(keySet(), (IgnitePredicate>[])null); } /** @@ -1684,9 +1683,7 @@ public IgniteInternalFuture readThroughAllAsync(final Collection vis) { return ctx.closures().callLocalSafe(new GPC() { - @Nullable - @Override - public Object call() { + @Nullable @Override public Object call() { try { ctx.store().loadAllFromStore(tx, keys, vis); } @@ -1897,7 +1894,7 @@ public IgniteInternalFuture> reloadAllAsync(@Nullable Collection keys) { - evictAll(keys, (IgnitePredicate>[]) null); + evictAll(keys, (IgnitePredicate>[])null); } /** {@inheritDoc} */ @@ -1931,9 +1928,8 @@ public IgniteInternalFuture> reloadAllAsync(@Nullable Collection, V>() { - @Override - public V applyx(IgniteInternalFuture f) throws IgniteCheckedException { - return (V) ctx.config().getInterceptor().onGet(key, f.get()); + @Override public V applyx(IgniteInternalFuture f) throws IgniteCheckedException { + return (V)ctx.config().getInterceptor().onGet(key, f.get()); } }); @@ -2505,13 +2501,11 @@ public String toString() { ctx.denyOnLocalRead(); return asyncOp(new AsyncInOp(drMap.keySet()) { - @Override - public IgniteInternalFuture inOp(IgniteTxLocalAdapter tx) { + @Override public IgniteInternalFuture inOp(IgniteTxLocalAdapter tx) { return tx.putAllDrAsync(ctx, drMap); } - @Override - public String toString() { + @Override public String toString() { return "putAllDrAsync [drMap=" + drMap + ']'; } }); @@ -2533,7 +2527,7 @@ public String toString() { @Nullable @Override public EntryProcessorResult op(IgniteTxLocalAdapter tx) throws IgniteCheckedException { Map> invokeMap = - Collections.singletonMap(key, (EntryProcessor) entryProcessor); + Collections.singletonMap(key, (EntryProcessor)entryProcessor); IgniteInternalFuture>>> fut = tx.invokeAsync(ctx, invokeMap, args); @@ -2565,13 +2559,10 @@ public String toString() { ctx.denyOnLocalRead(); return syncOp(new SyncOp>>(keys.size() == 1) { - @Nullable - @Override - public Map> op(IgniteTxLocalAdapter tx) + @Nullable @Override public Map> op(IgniteTxLocalAdapter tx) throws IgniteCheckedException { Map> invokeMap = F.viewAsMap(keys, new C1>() { - @Override - public EntryProcessor apply(K k) { + @Override public EntryProcessor apply(K k) { return entryProcessor; } }); @@ -2602,7 +2593,7 @@ public EntryProcessor apply(K k) { IgniteInternalFuture fut = asyncOp(new AsyncInOp(key) { @Override public IgniteInternalFuture>>> inOp(IgniteTxLocalAdapter tx) { Map> invokeMap = - Collections.singletonMap(key, (EntryProcessor) entryProcessor); + Collections.singletonMap(key, (EntryProcessor)entryProcessor); return tx.invokeAsync(ctx, invokeMap, args); } @@ -2701,8 +2692,7 @@ public EntryProcessor apply(K k) { (IgniteInternalFuture>>>)fut; return fut0.chain(new CX1>>>, Map>>() { - @Override - public Map> applyx( + @Override public Map> applyx( IgniteInternalFuture>>> fut) throws IgniteCheckedException { GridCacheReturn>> ret = fut.get(); @@ -2764,14 +2754,12 @@ public Map> applyx( ctx.denyOnLocalRead(); return asyncOp(new AsyncOp(key) { - @Override - public IgniteInternalFuture op(IgniteTxLocalAdapter tx) { + @Override public IgniteInternalFuture op(IgniteTxLocalAdapter tx) { return tx.putAllAsync(ctx, F.t(key, val), false, entry, ttl, filter).chain( - (IgniteClosure>, Boolean>) RET2FLAG); + (IgniteClosure>, Boolean>)RET2FLAG); } - @Override - public String toString() { + @Override public String toString() { return "putxAsync [key=" + key + ", val=" + val + ", filter=" + Arrays.toString(filter) + ']'; } }); @@ -2815,14 +2803,12 @@ public String toString() { ctx.denyOnLocalRead(); IgniteInternalFuture fut = ctx.wrapClone(asyncOp(new AsyncOp(key) { - @Override - public IgniteInternalFuture op(IgniteTxLocalAdapter tx) { + @Override public IgniteInternalFuture op(IgniteTxLocalAdapter tx) { return tx.putAllAsync(ctx, F.t(key, val), true, null, -1, ctx.noPeekArray()) - .chain((IgniteClosure>, V>) RET2VAL); + .chain((IgniteClosure>, V>)RET2VAL); } - @Override - public String toString() { + @Override public String toString() { return "putIfAbsentAsync [key=" + key + ", val=" + val + ']'; } })); @@ -2849,13 +2835,11 @@ public String toString() { ctx.denyOnLocalRead(); Boolean stored = syncOp(new SyncOp(true) { - @Override - public Boolean op(IgniteTxLocalAdapter tx) throws IgniteCheckedException { + @Override public Boolean op(IgniteTxLocalAdapter tx) throws IgniteCheckedException { return tx.putAllAsync(ctx, F.t(key, val), false, null, -1, ctx.noPeekArray()).get().success(); } - @Override - public String toString() { + @Override public String toString() { return "putxIfAbsent [key=" + key + ", val=" + val + ']'; } }); @@ -2964,13 +2948,11 @@ public String toString() { ctx.denyOnLocalRead(); return syncOp(new SyncOp(true) { - @Override - public Boolean op(IgniteTxLocalAdapter tx) throws IgniteCheckedException { + @Override public Boolean op(IgniteTxLocalAdapter tx) throws IgniteCheckedException { return tx.putAllAsync(ctx, F.t(key, val), false, null, -1, ctx.hasPeekArray()).get().success(); } - @Override - public String toString() { + @Override public String toString() { return "replacex [key=" + key + ", val=" + val + ']'; } }); @@ -2988,14 +2970,12 @@ public String toString() { ctx.denyOnLocalRead(); return asyncOp(new AsyncOp(key) { - @Override - public IgniteInternalFuture op(IgniteTxLocalAdapter tx) { + @Override public IgniteInternalFuture op(IgniteTxLocalAdapter tx) { return tx.putAllAsync(ctx, F.t(key, val), false, null, -1, ctx.hasPeekArray()).chain( - (IgniteClosure>, Boolean>) RET2FLAG); + (IgniteClosure>, Boolean>)RET2FLAG); } - @Override - public String toString() { + @Override public String toString() { return "replacexAsync [key=" + key + ", val=" + val + ']'; } }); @@ -3119,13 +3099,11 @@ public String toString() { ctx.denyOnLocalRead(); return asyncOp(new AsyncInOp(m.keySet()) { - @Override - public IgniteInternalFuture inOp(IgniteTxLocalAdapter tx) { + @Override public IgniteInternalFuture inOp(IgniteTxLocalAdapter tx) { return tx.putAllAsync(ctx, m, false, null, -1, filter); } - @Override - public String toString() { + @Override public String toString() { return "putAllAsync [map=" + m + ", filter=" + Arrays.toString(filter) + ']'; } }); @@ -3152,18 +3130,16 @@ public String toString() { validateCacheKey(key); V prevVal = ctx.cloneOnFlag(syncOp(new SyncOp(true) { - @Override - public V op(IgniteTxLocalAdapter tx) throws IgniteCheckedException { + @Override public V op(IgniteTxLocalAdapter tx) throws IgniteCheckedException { V ret = tx.removeAllAsync(ctx, Collections.singletonList(key), entry, true, filter).get().value(); if (ctx.config().getInterceptor() != null) - return (V) ctx.config().getInterceptor().onBeforeRemove(key, ret).get2(); + return (V)ctx.config().getInterceptor().onBeforeRemove(key, ret).get2(); return ret; } - @Override - public String toString() { + @Override public String toString() { return "remove [key=" + key + ", filter=" + Arrays.toString(filter) + ']'; } })); @@ -3278,13 +3254,11 @@ public String toString() { ctx.denyOnLocalRead(); IgniteInternalFuture fut = asyncOp(new AsyncInOp(keys) { - @Override - public IgniteInternalFuture inOp(IgniteTxLocalAdapter tx) { + @Override public IgniteInternalFuture inOp(IgniteTxLocalAdapter tx) { return tx.removeAllAsync(ctx, keys, null, false, filter); } - @Override - public String toString() { + @Override public String toString() { return "removeAllAsync [keys=" + keys + ", filter=" + Arrays.toString(filter) + ']'; } }); @@ -3434,13 +3408,11 @@ public String toString() { ctx.dr().onReceiveCacheEntriesReceived(drMap.size()); return asyncOp(new AsyncInOp(drMap.keySet()) { - @Override - public IgniteInternalFuture inOp(IgniteTxLocalAdapter tx) { + @Override public IgniteInternalFuture inOp(IgniteTxLocalAdapter tx) { return tx.removeAllDrAsync(ctx, drMap); } - @Override - public String toString() { + @Override public String toString() { return "removeAllDrASync [drMap=" + drMap + ']'; } }); @@ -3456,8 +3428,7 @@ public String toString() { ctx.denyOnLocalRead(); return syncOp(new SyncOp>(true) { - @Override - public GridCacheReturn op(IgniteTxLocalAdapter tx) throws IgniteCheckedException { + @Override public GridCacheReturn op(IgniteTxLocalAdapter tx) throws IgniteCheckedException { // Register before hiding in the filter. if (ctx.deploymentEnabled()) ctx.deploy().registerClass(oldVal); @@ -3465,8 +3436,7 @@ public GridCacheReturn op(IgniteTxLocalAdapter tx) throws IgniteChecked return tx.putAllAsync(ctx, F.t(key, newVal), true, null, -1, ctx.equalsPeekArray(oldVal)).get(); } - @Override - public String toString() { + @Override public String toString() { return "replace [key=" + key + ", oldVal=" + oldVal + ", newVal=" + newVal + ']'; } }); @@ -3547,8 +3517,7 @@ public String toString() { validateCacheValue(val); boolean removed = syncOp(new SyncOp(true) { - @Override - public Boolean op(IgniteTxLocalAdapter tx) throws IgniteCheckedException { + @Override public Boolean op(IgniteTxLocalAdapter tx) throws IgniteCheckedException { // Register before hiding in the filter. if (ctx.deploymentEnabled()) ctx.deploy().registerClass(val); @@ -3556,14 +3525,13 @@ public Boolean op(IgniteTxLocalAdapter tx) throws IgniteCheckedException { K key0 = key; if (ctx.portableEnabled()) - key0 = (K) ctx.marshalToPortable(key); + key0 = (K)ctx.marshalToPortable(key); return tx.removeAllAsync(ctx, Collections.singletonList(key0), null, false, ctx.vararg(F.cacheContainsPeek(val))).get().success(); } - @Override - public String toString() { + @Override public String toString() { return "remove [key=" + key + ", val=" + val + ']'; } }); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java index 6fea05d1a5331..01f3a80872d41 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java @@ -1678,7 +1678,7 @@ int iteratorSetSize() { private static Iterator> cacheEntryIterator(Iterator> it) { return F.iterator(it, new C1, Cache.Entry>() { @Override public Cache.Entry apply(Map.Entry e) { - // Create Cache.Entry over Map.Entry to do not deserialize key/values if not needed. + // Create Cache.Entry over Map.Entry to do not deserialize keys/values if not needed. return new CacheEntryImpl0<>(e); } }, true); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekAbstractTest.java deleted file mode 100644 index 80fec09f25573..0000000000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekAbstractTest.java +++ /dev/null @@ -1,333 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.cache; - -import org.apache.ignite.*; -import org.apache.ignite.cache.*; -import org.apache.ignite.cache.affinity.*; -import org.apache.ignite.cache.eviction.fifo.*; -import org.apache.ignite.configuration.*; -import org.apache.ignite.internal.*; -import org.apache.ignite.spi.*; -import org.apache.ignite.spi.swapspace.file.*; - -import java.util.*; - -import static org.apache.ignite.cache.CacheDistributionMode.*; -import static org.apache.ignite.cache.CacheMode.*; -import static org.apache.ignite.cache.CachePeekMode.*; - -/** - * - */ -public abstract class IgniteCachePeekAbstractTest extends IgniteCacheAbstractTest { - /** */ - private static final int HEAP_ENTRIES = 10; - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - cfg.setSwapSpaceSpi(new FileSwapSpaceSpi()); - - return cfg; - } - - /** {@inheritDoc} */ - @Override protected CacheDistributionMode distributionMode() { - return PARTITIONED_ONLY; - } - - /** {@inheritDoc} */ - @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception { - CacheConfiguration ccfg = super.cacheConfiguration(gridName); - - ccfg.setMemoryMode(CacheMemoryMode.ONHEAP_TIERED); - - ccfg.setOffHeapMaxMemory(512); - - ccfg.setBackups(1); - - if (gridName.equals(getTestGridName(0))) - ccfg.setDistributionMode(NEAR_PARTITIONED); - - ccfg.setEvictionPolicy(new CacheFifoEvictionPolicy(HEAP_ENTRIES)); - - return ccfg; - } - - /** {@inheritDoc} */ - @Override protected boolean swapEnabled() { - return true; - } - - /** - * @throws Exception If failed. - */ - public void testLocalPeek() throws Exception { - if (cacheMode() == LOCAL) { - checkAffinityLocalCache(); - - checkStorage(0); - } - else { - checkAffinityPeek(0); - - checkAffinityPeek(1); - - checkStorage(0); - - checkStorage(1); - } - } - - /** - * @throws Exception If failed. - */ - private void checkAffinityLocalCache() throws Exception { - IgniteCache cache0 = jcache(0); - - final String val = "1"; - - for (int i = 0; i < HEAP_ENTRIES; i++) - cache0.put(i, val); - - try { - for (int i = 0; i < HEAP_ENTRIES; i++) { - assertEquals(val, cache0.localPeek(i)); - assertEquals(val, cache0.localPeek(i, ALL)); - assertEquals(val, cache0.localPeek(i, PRIMARY)); - assertEquals(val, cache0.localPeek(i, BACKUP)); - assertEquals(val, cache0.localPeek(i, NEAR)); - } - } - finally { - for (int i = 0; i < HEAP_ENTRIES; i++) - cache0.remove(i); - } - } - - /** - * @param nodeIdx Node index. - * @throws Exception If failed. - */ - private void checkAffinityPeek(int nodeIdx) throws Exception { - IgniteCache cache0 = jcache(nodeIdx); - - final String val = "1"; - - Integer key = null; - - try { - if (cacheMode() == REPLICATED) { - key = backupKey(cache0); - - cache0.put(key, val); - - assertEquals(val, cache0.localPeek(key, ALL)); - assertEquals(val, cache0.localPeek(key, BACKUP)); - assertNull(cache0.localPeek(key, NEAR)); - assertNull(cache0.localPeek(key, PRIMARY)); - } - else { - key = nearKey(cache0); - - cache0.put(key, val); - - boolean hasNearCache = nodeIdx == 0 ; - - if (hasNearCache) { - assertEquals(val, cache0.localPeek(key, NEAR)); - assertEquals(val, cache0.localPeek(key, ALL)); - } - else { - assertNull(cache0.localPeek(key, NEAR)); - assertNull(cache0.localPeek(key, ALL)); - } - - assertNull(cache0.localPeek(key, PRIMARY)); - assertNull(cache0.localPeek(key, BACKUP)); - } - - CacheAffinity aff = ignite(0).affinity(null); - - for (int i = 0; i < gridCount(); i++) { - if (i == nodeIdx) - continue; - - IgniteCache cache = jcache(i); - - assertNull(cache.localPeek(key, NEAR)); - - if (aff.isPrimary(ignite(i).cluster().localNode(), key)) { - assertEquals(val, cache.localPeek(key, PRIMARY)); - assertEquals(val, cache.localPeek(key, ALL)); - assertNull(cache.localPeek(key, BACKUP)); - assertNull(cache.localPeek(key, NEAR)); - } - else if (aff.isBackup(ignite(i).cluster().localNode(), key)) { - assertEquals(val, cache.localPeek(key, BACKUP)); - assertEquals(val, cache.localPeek(key, ALL)); - assertNull(cache.localPeek(key, PRIMARY)); - assertNull(cache.localPeek(key, NEAR)); - } - else { - assertNull(cache.localPeek(key, ALL)); - assertNull(cache.localPeek(key, PRIMARY)); - assertNull(cache.localPeek(key, BACKUP)); - assertNull(cache.localPeek(key, NEAR)); - } - } - } - finally { - if (key != null) - cache0.remove(key); - } - } - - /** - * @param nodeIdx Node index. - * @throws Exception If failed. - */ - private void checkStorage(int nodeIdx) throws Exception { - IgniteCache cache0 = jcache(nodeIdx); - - List keys = primaryKeys(cache0, 100, 10_000); - - try { - final String val = "test_value"; - - for (Integer key : keys) - cache0.put(key, val); - - FileSwapSpaceSpi swap = (FileSwapSpaceSpi)ignite(nodeIdx).configuration().getSwapSpaceSpi(); - - Set swapKeys = new HashSet<>(); - - final String spaceName = "gg-swap-cache-dflt"; - - IgniteSpiCloseableIterator it = swap.keyIterator(spaceName, null); - - assertNotNull(it); - - while (it.hasNext()) - assertTrue(swapKeys.add(it.next())); - - assertFalse(swapKeys.isEmpty()); - - assertTrue(swapKeys.size() + HEAP_ENTRIES < 100); - - Set offheapKeys = new HashSet<>(); - - GridCacheAdapter internalCache = - ((IgniteKernal)ignite(nodeIdx)).context().cache().internalCache(); - - Iterator> offheapIt; - - if (internalCache.context().isNear()) - offheapIt = internalCache.context().near().dht().context().swap().lazyOffHeapIterator(); - else - offheapIt = internalCache.context().swap().lazyOffHeapIterator(); - - while (offheapIt.hasNext()) { - Map.Entry e = offheapIt.next(); - - assertTrue(offheapKeys.add(e.getKey())); - - assertFalse(swapKeys.contains(e.getKey())); - } - - assertFalse(offheapKeys.isEmpty()); - - Set heapKeys = new HashSet<>(keys); - - heapKeys.removeAll(offheapKeys); - heapKeys.removeAll(swapKeys); - - assertFalse(heapKeys.isEmpty()); - - log.info("Keys [swap=" + swapKeys.size() + - ", offheap=" + offheapKeys.size() + - ", heap=" + heapKeys.size() + ']'); - - assertEquals(100, swapKeys.size() + offheapKeys.size() + heapKeys.size()); - - for (Integer key : swapKeys) { - assertEquals(val, cache0.localPeek(key, SWAP)); - assertEquals(val, cache0.localPeek(key, PRIMARY, SWAP)); - assertEquals(val, cache0.localPeek(key, ONHEAP, SWAP)); - assertEquals(val, cache0.localPeek(key, ONHEAP, OFFHEAP, SWAP)); - assertEquals(val, cache0.localPeek(key, PRIMARY, ONHEAP, SWAP)); - assertEquals(val, cache0.localPeek(key, PRIMARY, ONHEAP, OFFHEAP, SWAP)); - - if (cacheMode() == LOCAL) { - assertEquals(val, cache0.localPeek(key, SWAP, BACKUP)); - assertEquals(val, cache0.localPeek(key, SWAP, NEAR)); - } - else { - assertNull(cache0.localPeek(key, SWAP, BACKUP)); - assertNull(cache0.localPeek(key, SWAP, NEAR)); - } - - assertNull(cache0.localPeek(key, ONHEAP)); - assertNull(cache0.localPeek(key, OFFHEAP)); - } - - for (Integer key : offheapKeys) { - assertEquals(val, cache0.localPeek(key, OFFHEAP)); - assertEquals(val, cache0.localPeek(key, ONHEAP, OFFHEAP)); - assertEquals(val, cache0.localPeek(key, ONHEAP, SWAP, OFFHEAP)); - assertEquals(val, cache0.localPeek(key, PRIMARY, OFFHEAP)); - - if (cacheMode() == LOCAL) { - assertEquals(val, cache0.localPeek(key, OFFHEAP, BACKUP)); - assertEquals(val, cache0.localPeek(key, OFFHEAP, NEAR)); - } - else { - assertNull(cache0.localPeek(key, OFFHEAP, BACKUP)); - assertNull(cache0.localPeek(key, OFFHEAP, NEAR)); - } - - assertNull(cache0.localPeek(key, ONHEAP)); - assertNull(cache0.localPeek(key, SWAP)); - } - - for (Integer key : heapKeys) { - assertEquals(val, cache0.localPeek(key, ONHEAP)); - assertEquals(val, cache0.localPeek(key, SWAP, ONHEAP)); - assertEquals(val, cache0.localPeek(key, SWAP, OFFHEAP, ONHEAP)); - assertEquals(val, cache0.localPeek(key, PRIMARY, ONHEAP)); - - if (cacheMode() == LOCAL) { - assertEquals(val, cache0.localPeek(key, ONHEAP, BACKUP)); - assertEquals(val, cache0.localPeek(key, ONHEAP, NEAR)); - } - else { - assertNull(cache0.localPeek(key, ONHEAP, BACKUP)); - assertNull(cache0.localPeek(key, ONHEAP, NEAR)); - } - - assertNull(cache0.localPeek(key, SWAP)); - assertNull(cache0.localPeek(key, OFFHEAP)); - } - } - finally { - cache0.removeAll(new HashSet<>(keys)); - } - } -} From 3eba35205bec122298bc25dbe45c64f04fa1f29f Mon Sep 17 00:00:00 2001 From: sboikov Date: Mon, 9 Feb 2015 23:42:58 +0300 Subject: [PATCH 76/95] # sprint-1 --- .../hadoop/GridHadoopDefaultMapReducePlannerSelfTest.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/GridHadoopDefaultMapReducePlannerSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/GridHadoopDefaultMapReducePlannerSelfTest.java index de38897c6ffec..c76f0c4f32b92 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/GridHadoopDefaultMapReducePlannerSelfTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/GridHadoopDefaultMapReducePlannerSelfTest.java @@ -1221,5 +1221,10 @@ private static class MockIgnite extends IgniteSpringBean implements IgniteEx { @Override public IgniteFuture future() { return null; } + + /** {@inheritDoc} */ + @Override public ClusterGroup forCacheNodes(@Nullable String cacheName, Set distributionModes) { + return null; + } } } From 865c42867e60ab9b8abb703911bd9ff8ca351195 Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Mon, 9 Feb 2015 13:01:02 -0800 Subject: [PATCH 77/95] IGNITE-61 - Direct marshalling --- .../ignite/client/ClientTestRestServer.java | 6 +++ .../protocols/tcp/TcpRestParserSelfTest.java | 12 ++--- .../ignite/client/GridClientFactory.java | 2 +- .../ignite/client/impl/GridClientImpl.java | 17 ++++--- .../GridClientConnectionManagerAdapter.java | 15 ++++-- .../GridClientConnectionManagerOsImpl.java | 5 +- .../GridClientNioTcpConnection.java | 31 ++++++------ .../router/impl/GridRouterClientImpl.java | 4 +- .../router/impl/GridTcpRouterNioParser.java | 6 +++ .../client/message/GridRouterRequest.java | 1 + .../rest/protocols/tcp/GridTcpRestParser.java | 47 +++++++++++++++++-- .../protocols/tcp/GridTcpRestProtocol.java | 2 +- 12 files changed, 106 insertions(+), 42 deletions(-) diff --git a/modules/clients/src/test/java/org/apache/ignite/client/ClientTestRestServer.java b/modules/clients/src/test/java/org/apache/ignite/client/ClientTestRestServer.java index fbe3dda20a8a5..017888f11572f 100644 --- a/modules/clients/src/test/java/org/apache/ignite/client/ClientTestRestServer.java +++ b/modules/clients/src/test/java/org/apache/ignite/client/ClientTestRestServer.java @@ -267,6 +267,12 @@ private static class TestParser extends GridTcpRestParser { /** */ private final GridClientMarshaller marsh = new GridClientOptimizedMarshaller(); + /** + */ + public TestParser() { + super(false); + } + /** {@inheritDoc} */ @Override protected GridClientMarshaller marshaller(GridNioSession ses) { return marsh; diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/TcpRestParserSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/TcpRestParserSelfTest.java index 070441d788b39..2a7263f5c3cdd 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/TcpRestParserSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/TcpRestParserSelfTest.java @@ -56,7 +56,7 @@ public class TcpRestParserSelfTest extends GridCommonAbstractTest { public void testSimplePacketParsing() throws Exception { GridNioSession ses = new MockNioSession(); - GridTcpRestParser parser = new GridTcpRestParser(); + GridTcpRestParser parser = new GridTcpRestParser(false); byte hdr = MEMCACHE_REQ_FLAG; @@ -91,7 +91,7 @@ public void testSimplePacketParsing() throws Exception { public void testIncorrectPackets() throws Exception { final GridNioSession ses = new MockNioSession(); - final GridTcpRestParser parser = new GridTcpRestParser(); + final GridTcpRestParser parser = new GridTcpRestParser(false); final byte[] opaque = new byte[] {0x01, 0x02, 0x03, (byte)0xFF}; @@ -151,7 +151,7 @@ public void testCustomMessages() throws Exception { ses.addMeta(MARSHALLER.ordinal(), new GridClientOptimizedMarshaller()); - GridTcpRestParser parser = new GridTcpRestParser(); + GridTcpRestParser parser = new GridTcpRestParser(false); GridClientMessage msg = parser.decode(ses, raw); @@ -180,7 +180,7 @@ public void testMixedParsing() throws Exception { ses1.addMeta(MARSHALLER.ordinal(), new GridClientOptimizedMarshaller()); ses2.addMeta(MARSHALLER.ordinal(), new GridClientOptimizedMarshaller()); - GridTcpRestParser parser = new GridTcpRestParser(); + GridTcpRestParser parser = new GridTcpRestParser(false); GridClientCacheRequest req = new GridClientCacheRequest(CAS); @@ -266,7 +266,7 @@ public void testParseContinuousSplit() throws Exception { ses.addMeta(MARSHALLER.ordinal(), new GridClientOptimizedMarshaller()); - GridTcpRestParser parser = new GridTcpRestParser(); + GridTcpRestParser parser = new GridTcpRestParser(false); Collection lst = new ArrayList<>(5); @@ -308,7 +308,7 @@ public void testParseClientHandshake() throws Exception { ses.addMeta(MARSHALLER.ordinal(), new GridClientOptimizedMarshaller()); - GridTcpRestParser parser = new GridTcpRestParser(); + GridTcpRestParser parser = new GridTcpRestParser(false); Collection lst = new ArrayList<>(1); diff --git a/modules/core/src/main/java/org/apache/ignite/client/GridClientFactory.java b/modules/core/src/main/java/org/apache/ignite/client/GridClientFactory.java index 647155e018d8c..339a9f7a97a36 100644 --- a/modules/core/src/main/java/org/apache/ignite/client/GridClientFactory.java +++ b/modules/core/src/main/java/org/apache/ignite/client/GridClientFactory.java @@ -54,7 +54,7 @@ public static GridClient start(GridClientConfiguration cfg) throws GridClientExc try { UUID clientId = UUID.randomUUID(); - GridClientImpl client = new GridClientImpl(clientId, cfg); + GridClientImpl client = new GridClientImpl(clientId, cfg, false); GridClientImpl old = openClients.putIfAbsent(clientId, client); diff --git a/modules/core/src/main/java/org/apache/ignite/client/impl/GridClientImpl.java b/modules/core/src/main/java/org/apache/ignite/client/impl/GridClientImpl.java index 8f64a79188228..43b8d2004744c 100644 --- a/modules/core/src/main/java/org/apache/ignite/client/impl/GridClientImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/client/impl/GridClientImpl.java @@ -103,12 +103,13 @@ public class GridClientImpl implements GridClient { * * @param id Client identifier. * @param cfg0 Client configuration. + * @param routerClient Router client flag. * @throws GridClientException If client configuration is incorrect. * @throws GridServerUnreachableException If none of the servers specified in configuration can * be reached. */ @SuppressWarnings("CallToThreadStartDuringObjectConstruction") - public GridClientImpl(UUID id, GridClientConfiguration cfg0) throws GridClientException { + public GridClientImpl(UUID id, GridClientConfiguration cfg0, boolean routerClient) throws GridClientException { this.id = id; cfg = new GridClientConfiguration(cfg0); @@ -158,7 +159,7 @@ public GridClientImpl(UUID id, GridClientConfiguration cfg0) throws GridClientEx throw new GridClientException("Servers addresses and routers addresses cannot both be provided " + "for client (please fix configuration and restart): " + this); - connMgr = createConnectionManager(id, sslCtx, cfg, routers, top, null); + connMgr = createConnectionManager(id, sslCtx, cfg, routers, top, null, routerClient); try { // Init connection manager, it should cause topology update. @@ -385,8 +386,9 @@ private static Collection parseAddresses(Collection c * @return New connection manager based on current client settings. * @throws GridClientException If failed to start connection server. */ - public GridClientConnectionManager newConnectionManager(@Nullable Byte marshId) throws GridClientException { - return createConnectionManager(id, sslCtx, cfg, routers, top, marshId); + public GridClientConnectionManager newConnectionManager(@Nullable Byte marshId, boolean routerClient) + throws GridClientException { + return createConnectionManager(id, sslCtx, cfg, routers, top, marshId, routerClient); } /** @@ -399,7 +401,7 @@ public GridClientConnectionManager newConnectionManager(@Nullable Byte marshId) */ private GridClientConnectionManager createConnectionManager(UUID clientId, SSLContext sslCtx, GridClientConfiguration cfg, Collection routers, GridClientTopology top, - @Nullable Byte marshId) + @Nullable Byte marshId, boolean routerClient) throws GridClientException { GridClientConnectionManager mgr; @@ -409,10 +411,11 @@ private GridClientConnectionManager createConnectionManager(UUID clientId, SSLCo Constructor cons = cls.getConstructor(UUID.class, SSLContext.class, GridClientConfiguration.class, Collection.class, GridClientTopology.class, Byte.class); - mgr = (GridClientConnectionManager)cons.newInstance(clientId, sslCtx, cfg, routers, top, marshId); + mgr = (GridClientConnectionManager)cons.newInstance(clientId, sslCtx, cfg, routers, top, marshId, + routerClient); } catch (ClassNotFoundException ignored) { - mgr = new GridClientConnectionManagerOsImpl(clientId, sslCtx, cfg, routers, top, marshId); + mgr = new GridClientConnectionManagerOsImpl(clientId, sslCtx, cfg, routers, top, marshId, routerClient); } catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) { throw new GridClientException("Failed to create client connection manager.", e); diff --git a/modules/core/src/main/java/org/apache/ignite/client/impl/connection/GridClientConnectionManagerAdapter.java b/modules/core/src/main/java/org/apache/ignite/client/impl/connection/GridClientConnectionManagerAdapter.java index 6cecef0a73fbe..ff9bdf762d0df 100644 --- a/modules/core/src/main/java/org/apache/ignite/client/impl/connection/GridClientConnectionManagerAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/client/impl/connection/GridClientConnectionManagerAdapter.java @@ -110,7 +110,8 @@ protected GridClientConnectionManagerAdapter(UUID clientId, GridClientConfiguration cfg, Collection routers, GridClientTopology top, - @Nullable Byte marshId) + @Nullable Byte marshId, + boolean routerClient) throws GridClientException { assert clientId != null : "clientId != null"; assert cfg != null : "cfg != null"; @@ -142,7 +143,7 @@ protected GridClientConnectionManagerAdapter(UUID clientId, GridNioFilter[] filters; - GridNioFilter codecFilter = new GridNioCodecFilter(new GridTcpRestParser(), gridLog, false); + GridNioFilter codecFilter = new GridNioCodecFilter(new GridTcpRestParser(routerClient), gridLog, false); if (sslCtx != null) { GridNioSslFilter sslFilter = new GridNioSslFilter(sslCtx, gridLog); @@ -595,8 +596,14 @@ private NioListener(Logger log) { if (msg instanceof GridClientPingPacket) conn.handlePingResponse(); - else - conn.handleResponse((GridClientMessage)msg); + else { + try { + conn.handleResponse((GridClientMessage)msg); + } + catch (IOException e) { + log.log(Level.SEVERE, "Failed to parse response.", e); + } + } } } diff --git a/modules/core/src/main/java/org/apache/ignite/client/impl/connection/GridClientConnectionManagerOsImpl.java b/modules/core/src/main/java/org/apache/ignite/client/impl/connection/GridClientConnectionManagerOsImpl.java index f2d4506321585..a9bd80e5c61a2 100644 --- a/modules/core/src/main/java/org/apache/ignite/client/impl/connection/GridClientConnectionManagerOsImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/client/impl/connection/GridClientConnectionManagerOsImpl.java @@ -36,8 +36,9 @@ public class GridClientConnectionManagerOsImpl extends GridClientConnectionManag * @throws GridClientException In case of error. */ public GridClientConnectionManagerOsImpl(UUID clientId, SSLContext sslCtx, GridClientConfiguration cfg, - Collection routers, GridClientTopology top, Byte marshId) throws GridClientException { - super(clientId, sslCtx, cfg, routers, top, marshId); + Collection routers, GridClientTopology top, Byte marshId, boolean routerClient) + throws GridClientException { + super(clientId, sslCtx, cfg, routers, top, marshId, routerClient); } /** {@inheritDoc} */ diff --git a/modules/core/src/main/java/org/apache/ignite/client/impl/connection/GridClientNioTcpConnection.java b/modules/core/src/main/java/org/apache/ignite/client/impl/connection/GridClientNioTcpConnection.java index 3cead452be60f..03fa95d8ba76e 100644 --- a/modules/core/src/main/java/org/apache/ignite/client/impl/connection/GridClientNioTcpConnection.java +++ b/modules/core/src/main/java/org/apache/ignite/client/impl/connection/GridClientNioTcpConnection.java @@ -461,7 +461,7 @@ void handlePingResponse() { * @param res Incoming response data. */ @SuppressWarnings({"unchecked", "TooBroadScope"}) - void handleResponse(GridClientMessage res) { + void handleResponse(GridClientMessage res) throws IOException { lastMsgRcvTime = U.currentTimeMillis(); TcpClientFuture fut = pendingReqs.get(res.requestId()); @@ -474,22 +474,25 @@ void handleResponse(GridClientMessage res) { } if (fut.forward()) { - // TODO: IGNITE-61 -// GridRouterResponse msg = new GridRouterResponse( -// res.messageArray(), -// res.requestId(), -// clientId, -// res.destinationId()); -// -// removePending(msg.requestId()); -// -// fut.onDone(msg); + removePending(res.requestId()); + + fut.onDone(res); } else { - if (res instanceof GridClientResponse) - handleClientResponse(fut, (GridClientResponse)res); + GridClientMessage res0 = res; + + if (res instanceof GridRouterResponse) { + res0 = marsh.unmarshal(((GridRouterResponse)res).body()); + + res0.requestId(res.requestId()); + res0.clientId(res.clientId()); + res0.destinationId(res.destinationId()); + } + + if (res0 instanceof GridClientResponse) + handleClientResponse(fut, (GridClientResponse)res0); else - log.warning("Unsupported response type received: " + res); + log.warning("Unsupported response type received: " + res0); } } diff --git a/modules/core/src/main/java/org/apache/ignite/client/router/impl/GridRouterClientImpl.java b/modules/core/src/main/java/org/apache/ignite/client/router/impl/GridRouterClientImpl.java index 0d7f74d751f7f..1b3434612e79c 100644 --- a/modules/core/src/main/java/org/apache/ignite/client/router/impl/GridRouterClientImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/client/router/impl/GridRouterClientImpl.java @@ -60,7 +60,7 @@ class GridRouterClientImpl implements GridClient { this.cliCfg = cliCfg; - clientImpl = new GridClientImpl(id, cliCfg); + clientImpl = new GridClientImpl(id, cliCfg, true); if (cliCfg.getProtocol() != GridClientProtocol.TCP) throw new AssertionError("Unknown protocol: " + cliCfg.getProtocol()); @@ -136,7 +136,7 @@ private GridClientConnectionManager connectionManager(byte marshId) throws GridC if (mgr == null) { GridClientConnectionManager old = connMgrMap.putIfAbsent(marshId, mgr = - clientImpl.newConnectionManager(marshId)); + clientImpl.newConnectionManager(marshId, true)); if (old != null) mgr = old; diff --git a/modules/core/src/main/java/org/apache/ignite/client/router/impl/GridTcpRouterNioParser.java b/modules/core/src/main/java/org/apache/ignite/client/router/impl/GridTcpRouterNioParser.java index 231b0f52f48d0..129406dc332be 100644 --- a/modules/core/src/main/java/org/apache/ignite/client/router/impl/GridTcpRouterNioParser.java +++ b/modules/core/src/main/java/org/apache/ignite/client/router/impl/GridTcpRouterNioParser.java @@ -39,6 +39,12 @@ class GridTcpRouterNioParser extends GridTcpRestParser { /** Number of sent messages. */ private volatile long sndCnt; + /** + */ + public GridTcpRouterNioParser() { + super(false); + } + /** {@inheritDoc} */ @Override protected GridClientMessage parseClientMessage(GridNioSession ses, ParserState state) { rcvCnt++; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridRouterRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridRouterRequest.java index 34efcf6adf184..6dcbf923befe1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridRouterRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridRouterRequest.java @@ -37,6 +37,7 @@ public class GridRouterRequest extends GridClientAbstractMessage { */ public GridRouterRequest(byte[] body, Long reqId, UUID clientId, UUID destId) { this.body = body; + destinationId(destId); clientId(clientId); requestId(reqId); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java index 978ae616f0033..03322d1253624 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java @@ -45,6 +45,16 @@ public class GridTcpRestParser implements GridNioParser { /** JDK marshaller. */ private final Marshaller jdkMarshaller = new JdkMarshaller(); + /** Router client flag. */ + private final boolean routerClient; + + /** + * @param routerClient Router client flag. + */ + public GridTcpRestParser(boolean routerClient) { + this.routerClient = routerClient; + } + /** {@inheritDoc} */ @Nullable @Override public GridClientMessage decode(GridNioSession ses, ByteBuffer buf) throws IOException, IgniteCheckedException { @@ -153,6 +163,22 @@ else if (msg instanceof GridClientHandshakeResponse) IGNITE_HANDSHAKE_RES_FLAG, ((GridClientHandshakeResponse)msg).resultCode() }); + else if (msg instanceof GridRouterRequest) { + byte[] body = ((GridRouterRequest)msg).body(); + + ByteBuffer buf = ByteBuffer.allocate(45 + body.length); + + buf.put(IGNITE_REQ_FLAG); + buf.putInt(40 + body.length); + buf.putLong(msg.requestId()); + buf.put(U.uuidToBytes(msg.clientId())); + buf.put(U.uuidToBytes(msg.destinationId())); + buf.put(body); + + buf.flip(); + + return buf; + } else { GridClientMarshaller marsh = marshaller(ses); @@ -455,13 +481,24 @@ private void copyRemaining(ByteBuffer src, OutputStream dest) throws IOException * @throws IgniteCheckedException If no marshaller was defined for the session. */ protected GridClientMessage parseClientMessage(GridNioSession ses, ParserState state) throws IOException, IgniteCheckedException { - GridClientMarshaller marsh = marshaller(ses); + GridClientMessage msg; + + if (routerClient) { + msg = new GridRouterResponse( + state.buffer().toByteArray(), + state.header().reqId(), + state.header().clientId(), + state.header().destinationId()); + } + else { + GridClientMarshaller marsh = marshaller(ses); - GridClientMessage msg = marsh.unmarshal(state.buffer().toByteArray()); + msg = marsh.unmarshal(state.buffer().toByteArray()); - msg.requestId(state.header().reqId()); - msg.clientId(state.header().clientId()); - msg.destinationId(state.header().destinationId()); + msg.requestId(state.header().reqId()); + msg.clientId(state.header().clientId()); + msg.destinationId(state.header().destinationId()); + } return msg; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestProtocol.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestProtocol.java index 19971e1ba763b..7482a799c2eb3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestProtocol.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestProtocol.java @@ -106,7 +106,7 @@ boolean portableMode(GridNioSession ses) { lsnr = new GridTcpRestNioListener(log, this, hnd, ctx); - GridNioParser parser = new GridTcpRestParser(); + GridNioParser parser = new GridTcpRestParser(false); try { host = resolveRestTcpHost(ctx.config()); From 4ef1baea4c95a42ab6744516a18919ee29b4fee0 Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Mon, 9 Feb 2015 15:06:51 -0800 Subject: [PATCH 78/95] IGNITE-61 - Direct marshalling --- .../impl/connection/GridClientConnectionManagerAdapter.java | 2 +- .../processors/rest/client/message/GridClientPingPacket.java | 4 +++- .../processors/rest/client/message/GridRouterResponse.java | 2 +- .../processors/rest/protocols/tcp/GridTcpRestNioListener.java | 4 ++-- .../processors/rest/protocols/tcp/GridTcpRestParser.java | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/client/impl/connection/GridClientConnectionManagerAdapter.java b/modules/core/src/main/java/org/apache/ignite/client/impl/connection/GridClientConnectionManagerAdapter.java index ff9bdf762d0df..b689b9b6cfb0c 100644 --- a/modules/core/src/main/java/org/apache/ignite/client/impl/connection/GridClientConnectionManagerAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/client/impl/connection/GridClientConnectionManagerAdapter.java @@ -170,7 +170,7 @@ protected GridClientConnectionManagerAdapter(UUID clientId, .socketReceiveBufferSize(0) .socketSendBufferSize(0) .idleTimeout(Long.MAX_VALUE) - .gridName("gridClient") + .gridName(routerClient ? "routerClient" : "gridClient") .daemon(cfg.isDaemon()) .build(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacket.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacket.java index fef8a8d1a8e93..90235dff37e7d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacket.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacket.java @@ -17,6 +17,8 @@ package org.apache.ignite.internal.processors.rest.client.message; +import static org.apache.ignite.internal.processors.rest.protocols.tcp.GridMemcachedMessage.*; + /** * Fictive ping packet. */ @@ -28,7 +30,7 @@ public class GridClientPingPacket extends GridClientAbstractMessage { public static final GridClientMessage PING_MESSAGE = new GridClientPingPacket(); /** Ping packet. */ - public static final byte[] PING_PACKET = new byte[] {(byte)0x90, 0x00, 0x00, 0x00, 0x00}; + public static final byte[] PING_PACKET = new byte[] {IGNITE_REQ_FLAG, 0x00, 0x00, 0x00, 0x00}; /** {@inheritDoc} */ @Override public String toString() { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridRouterResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridRouterResponse.java index ce5104cafe309..2ff3e21a1900d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridRouterResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridRouterResponse.java @@ -74,7 +74,7 @@ public int status() { /** {@inheritDoc} */ @Override public String toString() { - return "GridRoutedResponse [" + + return "GridRouterResponse [" + "clientId=" + clientId() + ", reqId=" + requestId() + ", destId=" + destinationId() + diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestNioListener.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestNioListener.java index 159f178961368..ba4a2acee65b4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestNioListener.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestNioListener.java @@ -134,8 +134,8 @@ void marshallers(Map marshMap) { if (msg instanceof GridMemcachedMessage) memcachedLsnr.onMessage(ses, (GridMemcachedMessage)msg); else { - if (msg == GridClientPingPacket.PING_MESSAGE) - ses.send(new GridClientPingPacket()); + if (msg instanceof GridClientPingPacket) + ses.send(msg); else if (msg instanceof GridClientHandshakeRequest) { GridClientHandshakeRequest hs = (GridClientHandshakeRequest)msg; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java index 03322d1253624..3a83d4b0787cb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java @@ -144,7 +144,7 @@ public GridTcpRestParser(boolean routerClient) { if (msg instanceof GridMemcachedMessage) return encodeMemcache((GridMemcachedMessage)msg); - else if (msg == GridClientPingPacket.PING_MESSAGE) + else if (msg instanceof GridClientPingPacket) return ByteBuffer.wrap(GridClientPingPacket.PING_PACKET); else if (msg instanceof GridClientHandshakeRequest) { byte[] bytes = ((GridClientHandshakeRequest)msg).rawBytes(); From 13475f3db38f5aee7bbc81c220334ad71b2ed4b8 Mon Sep 17 00:00:00 2001 From: Alexey Goncharuk Date: Mon, 9 Feb 2015 15:11:54 -0800 Subject: [PATCH 79/95] IGNITE-209 - Fixed tests. --- .../GridCacheAbstractFullApiSelfTest.java | 41 ++-- ...micClientOnlyMultiNodeFullApiSelfTest.java | 10 + ...CacheNearOnlyMultiNodeFullApiSelfTest.java | 185 ++++++++++++++++++ 3 files changed, 222 insertions(+), 14 deletions(-) diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java index 7d26d87fca5c0..c468b139e6674 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java @@ -2957,8 +2957,7 @@ public void testPeekExpiredTx() throws Exception { /** * @throws Exception If failed. */ - // TODO: IGNITE-209: Enable when fixed. - public void _testTtlTx() throws Exception { + public void testTtlTx() throws Exception { if (txEnabled()) checkTtl(true, false); } @@ -2966,8 +2965,7 @@ public void _testTtlTx() throws Exception { /** * @throws Exception If failed. */ - // TODO: IGNITE-209: Enable when fixed. - public void _testTtlNoTx() throws Exception { + public void testTtlNoTx() throws Exception { checkTtl(false, false); } @@ -3009,7 +3007,7 @@ private void checkTtl(boolean inTx, boolean oldEntry) throws Exception { IgniteTx tx = transactions().txStart(); try { - grid(0).jcache(null).withExpiryPolicy(expiry).put(key, 1); + jcache().withExpiryPolicy(expiry).put(key, 1); } finally { tx.rollback(); @@ -3023,11 +3021,14 @@ private void checkTtl(boolean inTx, boolean oldEntry) throws Exception { IgniteTx tx = inTx ? transactions().txStart() : null; try { - grid(0).jcache(null).withExpiryPolicy(expiry).put(key, 1); + jcache().withExpiryPolicy(expiry).put(key, 1); + + if (tx != null) + tx.commit(); } finally { if (tx != null) - tx.commit(); + tx.close(); } long[] expireTimes = new long[gridCount()]; @@ -3050,11 +3051,14 @@ private void checkTtl(boolean inTx, boolean oldEntry) throws Exception { tx = inTx ? transactions().txStart() : null; try { - grid(0).jcache(null).withExpiryPolicy(expiry).put(key, 2); + jcache().withExpiryPolicy(expiry).put(key, 2); + + if (tx != null) + tx.commit(); } finally { if (tx != null) - tx.commit(); + tx.close(); } for (int i = 0; i < gridCount(); i++) { @@ -3075,11 +3079,14 @@ private void checkTtl(boolean inTx, boolean oldEntry) throws Exception { tx = inTx ? transactions().txStart() : null; try { - grid(0).jcache(null).withExpiryPolicy(expiry).put(key, 3); + jcache().withExpiryPolicy(expiry).put(key, 3); + + if (tx != null) + tx.commit(); } finally { if (tx != null) - tx.commit(); + tx.close(); } for (int i = 0; i < gridCount(); i++) { @@ -3102,11 +3109,14 @@ private void checkTtl(boolean inTx, boolean oldEntry) throws Exception { tx = inTx ? transactions().txStart() : null; try { - c.put(key, 4); + jcache().put(key, 4); + + if (tx != null) + tx.commit(); } finally { if (tx != null) - tx.commit(); + tx.close(); } log.info("Put 4 done"); @@ -3166,10 +3176,13 @@ private void checkTtl(boolean inTx, boolean oldEntry) throws Exception { try { entry.set(10); + + if (tx != null) + tx.commit(); } finally { if (tx != null) - tx.commit(); + tx.close(); } U.sleep(2000); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java index 17aa98c3b0800..8c182581393d2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java @@ -71,6 +71,16 @@ public class GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest extends GridCache return PARTITIONED_ONLY; } + /** {@inheritDoc} */ + @Override public void testReaderTtlNoTx() throws Exception { + // No-op. + } + + /** {@inheritDoc} */ + @Override public void testReaderTtlTx() throws Exception { + // No-op. + } + /** {@inheritDoc} */ @Override public void testSize() throws Exception { IgniteCache cache = jcache(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java index bc83d152beed1..99d27d674b20a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java @@ -24,15 +24,20 @@ import org.apache.ignite.events.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.*; +import org.apache.ignite.internal.util.lang.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.testframework.*; +import org.apache.ignite.transactions.*; +import javax.cache.expiry.*; import java.util.*; import java.util.concurrent.*; import java.util.concurrent.atomic.*; import java.util.concurrent.locks.*; +import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.*; import static org.apache.ignite.cache.CacheDistributionMode.*; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*; @@ -183,6 +188,186 @@ protected IgniteCache fullCache() { // TODO fix this test for client mode. } + /** + * @throws Exception If failed. + */ + public void testReaderTtlTx() throws Exception { + checkReaderTtl(true); + } + + /** + * @throws Exception If failed. + */ + public void testReaderTtlNoTx() throws Exception { + checkReaderTtl(false); + } + + /** + * + * @throws Exception + */ + private void checkReaderTtl(boolean inTx) throws Exception { + int ttl = 1000; + + final ExpiryPolicy expiry = new TouchedExpiryPolicy(new Duration(MILLISECONDS, ttl)); + + final GridCache c = cache(); + + final String key = primaryKeysForCache(jcache(), 1).get(0); + + c.put(key, 1); + + CacheEntry entry = c.entry(key); + + assert entry != null; + + assertEquals(0, entry.timeToLive()); + assertEquals(0, entry.expirationTime()); + + long startTime = System.currentTimeMillis(); + + int fullIdx = nearIdx == 0 ? 1 : 0; + + // Now commit transaction and check that ttl and expire time have been saved. + IgniteTx tx = inTx ? grid(fullIdx).transactions().txStart() : null; + + try { + jcache(fullIdx).withExpiryPolicy(expiry).put(key, 1); + + if (tx != null) + tx.commit(); + } + finally { + if (tx != null) + tx.close(); + } + + long[] expireTimes = new long[gridCount()]; + + for (int i = 0; i < gridCount(); i++) { + CacheEntry curEntry = cache(i).entry(key); + + if (curEntry.primary() || curEntry.backup() || i == nearIdx) { + assertEquals(ttl, curEntry.timeToLive()); + + assert curEntry.expirationTime() > startTime; + + expireTimes[i] = curEntry.expirationTime(); + } + } + + // One more update from the same cache entry to ensure that expire time is shifted forward. + U.sleep(100); + + tx = inTx ? grid(fullIdx).transactions().txStart() : null; + + try { + jcache(fullIdx).withExpiryPolicy(expiry).put(key, 2); + + if (tx != null) + tx.commit(); + } + finally { + if (tx != null) + tx.close(); + } + + for (int i = 0; i < gridCount(); i++) { + CacheEntry curEntry = cache(i).entry(key); + + if (curEntry.primary() || curEntry.backup() || i == nearIdx) { + assertEquals(ttl, curEntry.timeToLive()); + + assert curEntry.expirationTime() > expireTimes[i]; + + expireTimes[i] = curEntry.expirationTime(); + } + } + + // And one more update to ensure that ttl is not changed and expire time is not shifted forward. + U.sleep(100); + + tx = inTx ? grid(fullIdx).transactions().txStart() : null; + + try { + jcache(fullIdx).put(key, 4); + } + finally { + if (tx != null) + tx.commit(); + } + + for (int i = 0; i < gridCount(); i++) { + CacheEntry curEntry = cache(i).entry(key); + + if (curEntry.primary() || curEntry.backup() || i == nearIdx) { + assertEquals(ttl, curEntry.timeToLive()); + assertEquals(expireTimes[i], curEntry.expirationTime()); + } + } + + // Avoid reloading from store. + map.remove(key); + + assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicateX() { + @SuppressWarnings("unchecked") + @Override public boolean applyx() throws IgniteCheckedException { + try { + Integer val = c.get(key); + + if (val != null) { + info("Value is in cache [key=" + key + ", val=" + val + ']'); + + return false; + } + + // Get "cache" field from GridCacheProxyImpl. + GridCacheAdapter c0 = GridTestUtils.getFieldValue(c, "cache"); + + if (!c0.context().deferredDelete()) { + GridCacheEntryEx e0 = c0.peekEx(key); + + return e0 == null || (e0.rawGet() == null && e0.valueBytes() == null); + } + else + return true; + } + catch (GridCacheEntryRemovedException e) { + throw new RuntimeException(e); + } + } + }, Math.min(ttl * 10, getTestTimeout()))); + + // Ensure that old TTL and expire time are not longer "visible". + entry = c.entry(key); + + assert entry.get() == null; + + assertEquals(0, entry.timeToLive()); + assertEquals(0, entry.expirationTime()); + + // Ensure that next update will not pick old expire time. + + tx = inTx ? c.txStart() : null; + + try { + entry.set(10); + } + finally { + if (tx != null) + tx.commit(); + } + + U.sleep(2000); + + entry = c.entry(key); + + assertEquals((Integer)10, entry.get()); + + assertEquals(0, entry.timeToLive()); + assertEquals(0, entry.expirationTime()); + } + /** {@inheritDoc} */ @Override public void testClear() throws Exception { IgniteCache nearCache = jcache(); From 6f27726d8e0a5f48189ee8dafc0e26367df9c8aa Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Mon, 9 Feb 2015 15:21:18 -0800 Subject: [PATCH 80/95] IGNITE-61 - Direct marshalling --- .../ignite/client/integration/ClientAbstractSelfTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/clients/src/test/java/org/apache/ignite/client/integration/ClientAbstractSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/client/integration/ClientAbstractSelfTest.java index de5b0e948e0e5..eb538214bd349 100644 --- a/modules/clients/src/test/java/org/apache/ignite/client/integration/ClientAbstractSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/client/integration/ClientAbstractSelfTest.java @@ -434,7 +434,7 @@ public void testShutdown() throws Exception { info(">>> First task executed successfully, running batch."); - for (int i = 0; i < 100; i++) + for (int i = 0; i < 10; i++) futs.add(compute.executeAsync(taskName, taskArg)); // Stop client. From 6c11ac03393043ed5278392473dbbfb1825f3762 Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Mon, 9 Feb 2015 16:24:19 -0800 Subject: [PATCH 81/95] # IGNITE-61 - Fixed future for removeAllAsync --- .../cache/distributed/GridDistributedCacheAdapter.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheAdapter.java index 3f020b150879b..eea1df197d0c5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheAdapter.java @@ -22,7 +22,6 @@ import org.apache.ignite.cluster.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.cluster.*; -import org.apache.ignite.internal.compute.*; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.distributed.dht.*; import org.apache.ignite.internal.processors.cache.distributed.near.*; @@ -161,7 +160,7 @@ public void removeVersionedEntry(K key, GridCacheVersion ver) { /** {@inheritDoc} */ @Override public IgniteInternalFuture removeAllAsync() { - GridFutureAdapter opFut = new GridFutureAdapter<>(); + GridFutureAdapter opFut = new GridFutureAdapter<>(ctx.kernalContext()); long topVer = ctx.affinity().affinityTopologyVersion(); From 1023cd1425aff3b91d7c74bfa6d268ee7f8c4dce Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Mon, 9 Feb 2015 17:59:36 -0800 Subject: [PATCH 82/95] IGNITE-61 - Direct marshalling (fixes after review) --- .../internal/managers/GridManagerAdapter.java | 4 +- .../managers/communication/GridIoManager.java | 33 ++++++-------- .../communication/GridIoMessageFactory.java | 12 ++--- .../internal/util/ipc/IpcToNioAdapter.java | 10 ++--- .../internal/util/nio/GridDirectParser.java | 17 +++---- .../internal/util/nio/GridNioServer.java | 33 +++++--------- .../nio/GridShmemCommunicationClient.java | 10 ++--- .../util/nio/GridTcpCommunicationClient.java | 10 ++--- ...aderFactory.java => MessageFormatter.java} | 14 +++--- .../communication/MessageWriterFactory.java | 35 --------------- .../apache/ignite/spi/IgniteSpiAdapter.java | 2 +- .../apache/ignite/spi/IgniteSpiContext.java | 8 ++-- .../tcp/TcpCommunicationSpi.java | 45 ++++++++++++++++--- .../testframework/GridSpiTestContext.java | 14 +++--- ...iteProjectionStartStopRestartSelfTest.java | 4 +- 15 files changed, 119 insertions(+), 132 deletions(-) rename modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/{MessageReaderFactory.java => MessageFormatter.java} (83%) delete mode 100644 modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriterFactory.java diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/GridManagerAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/GridManagerAdapter.java index f3213868edd2b..771b352f4ecfb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/GridManagerAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/GridManagerAdapter.java @@ -527,8 +527,8 @@ protected final String stopInfo() { } } - @Override public MessageWriterFactory messageWriterFactory() { - return ctx.io().messageWriterFactory(); + @Override public MessageFormatter messageFormatter() { + return ctx.io().formatter(); } @Override public MessageFactory messageFactory() { diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java index 60bc12afa21bb..e53691df3b186 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java @@ -135,7 +135,7 @@ public class GridIoManager extends GridManagerAdapter 0) - writerFactory = writerExt[0]; + if (formatterExt != null && formatterExt.length > 0) { + if (formatterExt.length > 1) + throw new IgniteCheckedException("More than one MessageFormatter extension is defined. Check your " + + "plugins configuration and make sure that only one of them provides custom message format."); + + formatter = formatterExt[0]; + } else { - writerFactory = new MessageWriterFactory() { + formatter = new MessageFormatter() { @Override public MessageWriter writer() { return new DirectMessageWriter(); } - }; - } - MessageReaderFactory readerFactory; - - MessageReaderFactory[] readerExt = ctx.plugins().extensions(MessageReaderFactory.class); - - if (readerExt != null && readerExt.length > 0) - readerFactory = readerExt[0]; - else { - readerFactory = new MessageReaderFactory() { @Override public MessageReader reader() { return new DirectMessageReader(msgFactory); } }; } - msgFactory = new GridIoMessageFactory(readerFactory, ctx.plugins().extensions(MessageFactory.class)); + msgFactory = new GridIoMessageFactory(formatter, ctx.plugins().extensions(MessageFactory.class)); if (log.isDebugEnabled()) log.debug(startInfo()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java index c1c2c54ec55be..e8481f1688ca9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java @@ -53,19 +53,19 @@ public class GridIoMessageFactory implements MessageFactory { private static final Map> CUSTOM = new ConcurrentHashMap8<>(); /** Message reader factory. */ - private final MessageReaderFactory readerFactory; + private final MessageFormatter formatter; /** Extensions. */ private final MessageFactory[] ext; /** - * @param readerFactory Message reader factory. + * @param formatter Message formatter. * @param ext Extensions. */ - public GridIoMessageFactory(MessageReaderFactory readerFactory, MessageFactory[] ext) { - assert readerFactory != null; + public GridIoMessageFactory(MessageFormatter formatter, MessageFactory[] ext) { + assert formatter != null; - this.readerFactory = readerFactory; + this.formatter = formatter; this.ext = ext; } @@ -524,7 +524,7 @@ public GridIoMessageFactory(MessageReaderFactory readerFactory, MessageFactory[] if (msg == null) throw new IgniteException("Invalid message type: " + type); - msg.setReader(readerFactory.reader()); + msg.setReader(formatter.reader()); return msg; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/IpcToNioAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/IpcToNioAdapter.java index 67c2eae5462d5..388c38fa99f97 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/IpcToNioAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/ipc/IpcToNioAdapter.java @@ -54,23 +54,23 @@ public class IpcToNioAdapter { private final GridNioMetricsListener metricsLsnr; /** */ - private final MessageWriterFactory writerFactory; + private final MessageFormatter formatter; /** * @param metricsLsnr Metrics listener. * @param log Log. * @param endp Endpoint. * @param lsnr Listener. - * @param writerFactory Message writer factory. + * @param formatter Message formatter. * @param filters Filters. */ public IpcToNioAdapter(GridNioMetricsListener metricsLsnr, IgniteLogger log, IpcEndpoint endp, - GridNioServerListener lsnr, MessageWriterFactory writerFactory, GridNioFilter... filters) { + GridNioServerListener lsnr, MessageFormatter formatter, GridNioFilter... filters) { assert metricsLsnr != null; this.metricsLsnr = metricsLsnr; this.endp = endp; - this.writerFactory = writerFactory; + this.formatter = formatter; chain = new GridNioFilterChain<>(log, lsnr, new HeadFilter(), filters); ses = new GridNioSessionImpl(chain, null, null, true); @@ -152,7 +152,7 @@ private GridNioFuture send(MessageAdapter msg) { assert writeBuf.hasArray(); try { - msg.setWriter(writerFactory.writer()); + msg.setWriter(formatter.writer()); int cnt = U.writeMessageFully(msg, endp.outputStream(), writeBuf); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java index 021aa91fa3858..3b00bd90f7752 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java @@ -19,7 +19,6 @@ import org.apache.ignite.*; import org.apache.ignite.plugin.extensions.communication.*; -import org.apache.ignite.spi.*; import org.jetbrains.annotations.*; import java.io.*; @@ -33,23 +32,19 @@ public class GridDirectParser implements GridNioParser { private static final int MSG_META_KEY = GridNioSessionMetaKey.nextUniqueKey(); /** */ - private IgniteSpiAdapter spi; - - /** */ - private MessageFactory msgFactory; + private final MessageFactory msgFactory; /** - * @param spi Spi. + * @param msgFactory Message factory. */ - public GridDirectParser(IgniteSpiAdapter spi) { - this.spi = spi; + public GridDirectParser(MessageFactory msgFactory) { + assert msgFactory != null; + + this.msgFactory = msgFactory; } /** {@inheritDoc} */ @Nullable @Override public Object decode(GridNioSession ses, ByteBuffer buf) throws IOException, IgniteCheckedException { - if (msgFactory == null) - msgFactory = spi.getSpiContext().messageFactory(); - MessageAdapter msg = ses.removeMeta(MSG_META_KEY); if (msg == null && buf.hasRemaining()) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java index 4a2e2e42e7960..ffa345d311187 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java @@ -28,7 +28,6 @@ import org.apache.ignite.internal.util.worker.*; import org.apache.ignite.lang.*; import org.apache.ignite.plugin.extensions.communication.*; -import org.apache.ignite.spi.*; import org.apache.ignite.thread.*; import org.jdk8.backport.*; import org.jetbrains.annotations.*; @@ -140,10 +139,7 @@ public class GridNioServer { /** */ @GridToStringExclude - private IgniteSpiAdapter spi; - - /** */ - private MessageWriterFactory messageWriterFactory; + private MessageFormatter formatter; /** Static initializer ensures single-threaded execution of workaround. */ static { @@ -172,6 +168,7 @@ public class GridNioServer { * @param directMode Whether direct mode is used. * @param daemon Daemon flag to create threads. * @param metricsLsnr Metrics listener. + * @param formatter Message formatter. * @param filters Filters for this server. * @throws IgniteCheckedException If failed. */ @@ -191,7 +188,7 @@ private GridNioServer( boolean directMode, boolean daemon, GridNioMetricsListener metricsLsnr, - IgniteSpiAdapter spi, + MessageFormatter formatter, GridNioFilter... filters ) throws IgniteCheckedException { A.notNull(addr, "addr"); @@ -256,7 +253,7 @@ private GridNioServer( this.directMode = directMode; this.metricsLsnr = metricsLsnr; - this.spi = spi; + this.formatter = formatter; } /** @@ -1023,10 +1020,7 @@ private void processWrite0(SelectionKey key) throws IOException { assert msg != null; - if (messageWriterFactory == null) - messageWriterFactory = spi.getSpiContext().messageWriterFactory(); - - msg.setWriter(messageWriterFactory.writer()); + msg.setWriter(formatter.writer()); finished = msg.writeTo(buf); } @@ -1047,10 +1041,7 @@ private void processWrite0(SelectionKey key) throws IOException { assert msg != null; - if (messageWriterFactory == null) - messageWriterFactory = spi.getSpiContext().messageWriterFactory(); - - msg.setWriter(messageWriterFactory.writer()); + msg.setWriter(formatter.writer()); finished = msg.writeTo(buf); } @@ -2078,8 +2069,8 @@ public static class Builder { /** Daemon flag. */ private boolean daemon; - /** SPI. */ - private IgniteSpiAdapter spi; + /** Message formatter. */ + private MessageFormatter formatter; /** * Finishes building the instance. @@ -2104,7 +2095,7 @@ public GridNioServer build() throws IgniteCheckedException { directMode, daemon, metricsLsnr, - spi, + formatter, filters != null ? Arrays.copyOf(filters, filters.length) : EMPTY_FILTERS ); @@ -2299,11 +2290,11 @@ public Builder daemon(boolean daemon) { } /** - * @param spi SPI. + * @param formatter Message formatter. * @return This for chaining. */ - public Builder spi(IgniteSpiAdapter spi) { - this.spi = spi; + public Builder messageFormatter(MessageFormatter formatter) { + this.formatter = formatter; return this; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridShmemCommunicationClient.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridShmemCommunicationClient.java index c3c9a92084828..2add3256d9fac 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridShmemCommunicationClient.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridShmemCommunicationClient.java @@ -39,18 +39,18 @@ public class GridShmemCommunicationClient extends GridAbstractCommunicationClien private final ByteBuffer writeBuf; /** */ - private final MessageWriterFactory writerFactory; + private final MessageFormatter formatter; /** * @param metricsLsnr Metrics listener. * @param port Shared memory IPC server port. * @param connTimeout Connection timeout. * @param log Logger. - * @param writerFactory Message writer factory. + * @param formatter Message formatter. * @throws IgniteCheckedException If failed. */ public GridShmemCommunicationClient(GridNioMetricsListener metricsLsnr, int port, long connTimeout, - IgniteLogger log, MessageWriterFactory writerFactory) throws IgniteCheckedException { + IgniteLogger log, MessageFormatter formatter) throws IgniteCheckedException { super(metricsLsnr); assert metricsLsnr != null; @@ -63,7 +63,7 @@ public GridShmemCommunicationClient(GridNioMetricsListener metricsLsnr, int port writeBuf.order(ByteOrder.nativeOrder()); - this.writerFactory = writerFactory; + this.formatter = formatter; } /** {@inheritDoc} */ @@ -116,7 +116,7 @@ public GridShmemCommunicationClient(GridNioMetricsListener metricsLsnr, int port assert writeBuf.hasArray(); try { - msg.setWriter(writerFactory.writer()); + msg.setWriter(formatter.writer()); int cnt = U.writeMessageFully(msg, shmem.outputStream(), writeBuf); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridTcpCommunicationClient.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridTcpCommunicationClient.java index 561547d2bdd84..fd2aeb9a45a11 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridTcpCommunicationClient.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridTcpCommunicationClient.java @@ -49,7 +49,7 @@ public class GridTcpCommunicationClient extends GridAbstractCommunicationClient private final ByteBuffer writeBuf; /** */ - private final MessageWriterFactory writerFactory; + private final MessageFormatter formatter; /** * @param metricsLsnr Metrics listener. @@ -62,7 +62,7 @@ public class GridTcpCommunicationClient extends GridAbstractCommunicationClient * @param bufSize Buffer size (or {@code 0} to disable buffer). * @param minBufferedMsgCnt Minimum buffered message count. * @param bufSizeRatio Communication buffer size ratio. - * @param writerFactory Message writer factory. + * @param formatter Message formatter. * @throws IgniteCheckedException If failed. */ public GridTcpCommunicationClient( @@ -76,7 +76,7 @@ public GridTcpCommunicationClient( int bufSize, int minBufferedMsgCnt, double bufSizeRatio, - MessageWriterFactory writerFactory + MessageFormatter formatter ) throws IgniteCheckedException { super(metricsLsnr); @@ -93,7 +93,7 @@ public GridTcpCommunicationClient( this.minBufferedMsgCnt = minBufferedMsgCnt; this.bufSizeRatio = bufSizeRatio; - this.writerFactory = writerFactory; + this.formatter = formatter; writeBuf = ByteBuffer.allocate(8 << 10); @@ -197,7 +197,7 @@ public GridTcpCommunicationClient( assert writeBuf.hasArray(); try { - msg.setWriter(writerFactory.writer()); + msg.setWriter(formatter.writer()); int cnt = U.writeMessageFully(msg, out, writeBuf); diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReaderFactory.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageFormatter.java similarity index 83% rename from modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReaderFactory.java rename to modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageFormatter.java index 4729551781d0b..01c0c61956f80 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageReaderFactory.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageFormatter.java @@ -20,12 +20,16 @@ import org.apache.ignite.plugin.*; /** - * Factory for message readers. - *

      - * A plugin can provide his own message reader factory as - * an extension to define a custom binary format. + * TODO */ -public interface MessageReaderFactory extends Extension { +public interface MessageFormatter extends Extension { + /** + * Creates new message writer instance. + * + * @return Message writer. + */ + public MessageWriter writer(); + /** * Creates new message reader instance. * diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriterFactory.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriterFactory.java deleted file mode 100644 index 1ab04e3c6e530..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriterFactory.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.plugin.extensions.communication; - -import org.apache.ignite.plugin.*; - -/** - * Factory for message writers. - *

      - * A plugin can provide his own message writer factory as - * an extension to define a custom binary format. - */ -public interface MessageWriterFactory extends Extension { - /** - * Creates new message writer instance. - * - * @return Message writer. - */ - public MessageWriter writer(); -} diff --git a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java index 7a731e57e3194..c4518e6a9098f 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java @@ -713,7 +713,7 @@ public ClusterNode node(UUID nodeId) { return null; } - @Override public MessageWriterFactory messageWriterFactory() { + @Override public MessageFormatter messageFormatter() { return null; } diff --git a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiContext.java b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiContext.java index 7f7e25eb03788..5a0a23f8465eb 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiContext.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiContext.java @@ -377,13 +377,15 @@ public boolean removeFromOffheap(@Nullable String spaceName, int part, Object ke @Nullable ClassLoader ldr) throws IgniteException; /** - * Gets message writer factory. + * Gets message formatter. * - * @return Message writer factory. + * @return Message formatter. */ - public MessageWriterFactory messageWriterFactory(); + public MessageFormatter messageFormatter(); /** + * Gets message factory. + * * @return Message factory. */ public MessageFactory messageFactory(); diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java index e3db36bb5edf6..2ab05cbec58c6 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java @@ -1470,6 +1470,41 @@ private GridNioServer resetNioServer() throws IgniteCheckedExcep // If configured TCP port is busy, find first available in range. for (int port = locPort; port < locPort + locPortRange; port++) { try { + MessageFactory messageFactory = new MessageFactory() { + private MessageFactory impl; + + @Nullable @Override public MessageAdapter create(byte type) { + if (impl == null) + impl = getSpiContext().messageFactory(); + + assert impl != null; + + return impl.create(type); + } + }; + + MessageFormatter messageFormatter = new MessageFormatter() { + private MessageFormatter impl; + + @Override public MessageWriter writer() { + if (impl == null) + impl = getSpiContext().messageFormatter(); + + assert impl != null; + + return impl.writer(); + } + + @Override public MessageReader reader() { + if (impl == null) + impl = getSpiContext().messageFormatter(); + + assert impl != null; + + return impl.reader(); + } + }; + GridNioServer srvr = GridNioServer.builder() .address(locHost) @@ -1487,9 +1522,9 @@ private GridNioServer resetNioServer() throws IgniteCheckedExcep .directMode(true) .metricsListener(metricsLsnr) .writeTimeout(sockWriteTimeout) - .filters(new GridNioCodecFilter(new GridDirectParser(this), log, true), + .filters(new GridNioCodecFilter(new GridDirectParser(messageFactory), log, true), new GridConnectionBytesVerifyFilter(log)) - .spi(this) + .messageFormatter(messageFormatter) .build(); boundTcpPort = port; @@ -1852,7 +1887,7 @@ else if (log.isDebugEnabled()) try { client = new GridShmemCommunicationClient(metricsLsnr, port, connTimeout, log, - getSpiContext().messageWriterFactory()); + getSpiContext().messageFormatter()); } catch (IgniteCheckedException e) { // Reconnect for the second time, if connection is not established. @@ -2421,8 +2456,8 @@ private ShmemWorker(IpcEndpoint endpoint) { log, endpoint, srvLsnr, - getSpiContext().messageWriterFactory(), - new GridNioCodecFilter(new GridDirectParser(TcpCommunicationSpi.this), log, true), + getSpiContext().messageFormatter(), + new GridNioCodecFilter(new GridDirectParser(getSpiContext().messageFactory()), log, true), new GridConnectionBytesVerifyFilter(log) ); diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java b/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java index d91ed13bc1e5c..97cb4882ae35d 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java @@ -505,21 +505,21 @@ public void triggerEvent(Event evt) { return null; } - @Override public MessageWriterFactory messageWriterFactory() { - return new MessageWriterFactory() { + @Override public MessageFormatter messageFormatter() { + return new MessageFormatter() { @Override public MessageWriter writer() { return new DirectMessageWriter(); } + + @Override public MessageReader reader() { + throw new UnsupportedOperationException(); + } }; } /** {@inheritDoc} */ @Override public MessageFactory messageFactory() { - return new GridIoMessageFactory(new MessageReaderFactory() { - @Override public MessageReader reader() { - return new DirectMessageReader(null); - } - }, null); + return new GridIoMessageFactory(messageFormatter(), null); } /** diff --git a/modules/ssh/src/test/java/org/apache/ignite/internal/IgniteProjectionStartStopRestartSelfTest.java b/modules/ssh/src/test/java/org/apache/ignite/internal/IgniteProjectionStartStopRestartSelfTest.java index babdbbb0dc3ab..f5a73d8d43b58 100644 --- a/modules/ssh/src/test/java/org/apache/ignite/internal/IgniteProjectionStartStopRestartSelfTest.java +++ b/modules/ssh/src/test/java/org/apache/ignite/internal/IgniteProjectionStartStopRestartSelfTest.java @@ -49,10 +49,10 @@ @SuppressWarnings("ConstantConditions") public class IgniteProjectionStartStopRestartSelfTest extends GridCommonAbstractTest { /** */ - private static final String SSH_UNAME = System.getenv("test.ssh.username"); + private static final String SSH_UNAME = "vkulichenko"; /** */ - private static final String SSH_PWD = System.getenv("test.ssh.password"); + private static final String SSH_PWD = "8tQHsaM"; /** */ private static final String SSH_KEY = System.getenv("ssh.key"); From aba3df7e8c6e7d02a346d2ea0cb8b4e2a99704a8 Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Mon, 9 Feb 2015 18:09:40 -0800 Subject: [PATCH 83/95] # IGNITE-61 - Direct marshalling (fixes after review) --- .../internal/IgniteProjectionStartStopRestartSelfTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ssh/src/test/java/org/apache/ignite/internal/IgniteProjectionStartStopRestartSelfTest.java b/modules/ssh/src/test/java/org/apache/ignite/internal/IgniteProjectionStartStopRestartSelfTest.java index f5a73d8d43b58..babdbbb0dc3ab 100644 --- a/modules/ssh/src/test/java/org/apache/ignite/internal/IgniteProjectionStartStopRestartSelfTest.java +++ b/modules/ssh/src/test/java/org/apache/ignite/internal/IgniteProjectionStartStopRestartSelfTest.java @@ -49,10 +49,10 @@ @SuppressWarnings("ConstantConditions") public class IgniteProjectionStartStopRestartSelfTest extends GridCommonAbstractTest { /** */ - private static final String SSH_UNAME = "vkulichenko"; + private static final String SSH_UNAME = System.getenv("test.ssh.username"); /** */ - private static final String SSH_PWD = "8tQHsaM"; + private static final String SSH_PWD = System.getenv("test.ssh.password"); /** */ private static final String SSH_KEY = System.getenv("ssh.key"); From 3dab05e1aa5338a0256b5e29a26b2a9684da2a82 Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Mon, 9 Feb 2015 18:19:56 -0800 Subject: [PATCH 84/95] # IGNITE-61 - JavaDoc --- .../extensions/communication/MessageFormatter.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageFormatter.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageFormatter.java index 01c0c61956f80..796b31764536a 100644 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageFormatter.java +++ b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageFormatter.java @@ -20,7 +20,14 @@ import org.apache.ignite.plugin.*; /** - * TODO + * Provides a custom format for communication messages. + *

      + * A plugin can provide his own message factory as an extension + * to replace default format of communication messages. + *

      + * Note that only one custom formatter is allowed. If two + * plugins provide different formatters, exception will + * be thrown on node startup. */ public interface MessageFormatter extends Extension { /** From df777c3a27569280181e19ea1417b34486cbf788 Mon Sep 17 00:00:00 2001 From: Alexey Goncharuk Date: Mon, 9 Feb 2015 18:21:06 -0800 Subject: [PATCH 85/95] IGNITE-51 - Fixed tests. --- .../GridCachePartitionExchangeManager.java | 18 ++++++++-- .../GridCacheAffinityMapperSelfTest.java | 17 ++++++++++ .../dht/GridCacheAtomicFullApiSelfTest.java | 18 ++++++++++ .../GridCachePartitionedLockSelfTest.java | 34 ------------------- 4 files changed, 51 insertions(+), 36 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java index 8f9fb929a99d0..42fcb4bf1c4f5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java @@ -273,14 +273,28 @@ public class GridCachePartitionExchangeManager extends GridCacheSharedMana U.join(exchWorker, log); - exchFuts = null; - ResendTimeoutObject resendTimeoutObj = pendingResend.getAndSet(null); if (resendTimeoutObj != null) cctx.time().removeTimeoutObject(resendTimeoutObj); } + /** {@inheritDoc} */ + @SuppressWarnings("LockAcquiredButNotSafelyReleased") + @Override protected void stop0(boolean cancel) { + super.stop0(cancel); + + // Do not allow any activity in exchange manager after stop. + busyLock.writeLock().lock(); + + exchFuts = null; + } + + /** + * @param cacheId Cache ID. + * @param exchId Exchange ID. + * @return Topology. + */ public GridDhtPartitionTopology clientTopology(int cacheId, GridDhtPartitionExchangeId exchId) { GridClientPartitionTopology top = clientTops.get(cacheId); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityMapperSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityMapperSelfTest.java index 89baa85344a30..060491ae9d4f7 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityMapperSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityMapperSelfTest.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.cache.affinity.*; +import org.apache.ignite.testframework.*; import org.apache.ignite.testframework.junits.common.*; import java.util.*; @@ -26,6 +27,16 @@ * Test affinity mapper. */ public class GridCacheAffinityMapperSelfTest extends GridCommonAbstractTest { + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + startGrid(); + } + + /** {@inheritDoc} */ + @Override protected void afterTestsStopped() throws Exception { + stopAllGrids(); + } + /** * */ @@ -33,6 +44,8 @@ public void testMethodAffinityMapper() { CacheAffinityKeyMapper mapper = new GridCacheDefaultAffinityKeyMapper(); + GridTestUtils.setFieldValue(mapper, "ignite", grid()); + List> keys = new ArrayList<>(); for (int i = 1; i <= 10; i++) @@ -57,6 +70,8 @@ public void testFieldAffinityMapper() { CacheAffinityKeyMapper mapper = new GridCacheDefaultAffinityKeyMapper(); + GridTestUtils.setFieldValue(mapper, "ignite", grid()); + List> keys = new ArrayList<>(); for (int i = 1; i <= 10; i++) @@ -81,6 +96,8 @@ public void testFieldAffinityMapperWithWrongClass() { CacheAffinityKeyMapper mapper = new GridCacheDefaultAffinityKeyMapper(); + GridTestUtils.setFieldValue(mapper, "ignite", grid()); + FieldNoAffinityKey key = new FieldNoAffinityKey(); Object mapped = mapper.affinityKey(key); assertEquals(key, mapped); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAtomicFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAtomicFullApiSelfTest.java index 0b4f0487102ee..cbbaeeb240c26 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAtomicFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAtomicFullApiSelfTest.java @@ -23,6 +23,7 @@ import org.apache.ignite.internal.processors.cache.distributed.near.*; import org.apache.ignite.testframework.*; +import javax.cache.*; import java.util.*; import java.util.concurrent.*; @@ -70,6 +71,23 @@ protected CacheAtomicWriteOrderMode atomicWriteOrderMode() { return ccfg; } + /** + * @throws Exception If failed. + */ + public void testLock() throws Exception { + GridTestUtils.assertThrows(log, new Callable() { + @Override public Object call() throws Exception { + return jcache().lock("1").tryLock(Long.MAX_VALUE, TimeUnit.MILLISECONDS); + } + }, CacheException.class, "Locks are not supported"); + + GridTestUtils.assertThrows(log, new Callable() { + @Override public Object call() throws Exception { + return jcache().lockAll(Collections.singleton("1")).tryLock(Long.MAX_VALUE, TimeUnit.MILLISECONDS); + } + }, CacheException.class, "Locks are not supported"); + } + /** * @throws Exception In case of error. */ diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedLockSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedLockSelfTest.java index 5a79a5bdc9ada..04934ce660337 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedLockSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedLockSelfTest.java @@ -17,19 +17,12 @@ package org.apache.ignite.internal.processors.cache.distributed.near; -import org.apache.ignite.*; import org.apache.ignite.cache.*; import org.apache.ignite.configuration.*; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.distributed.*; -import org.apache.ignite.internal.util.typedef.*; -import org.apache.ignite.testframework.*; import org.apache.log4j.*; -import javax.cache.*; -import java.util.*; -import java.util.concurrent.*; - import static org.apache.ignite.cache.CacheMode.*; /** @@ -56,31 +49,4 @@ public class GridCachePartitionedLockSelfTest extends GridCacheLockAbstractTest @Override protected boolean isPartitioned() { return true; } - - /** - * @throws IgniteCheckedException If failed. - */ - public void testLockAtomicCache() throws Exception { - IgniteConfiguration cfg = new IgniteConfiguration(); - - cfg.setGridName(getTestGridName(0)); - cfg.setClientConnectionConfiguration(null); - cfg.setCacheConfiguration(new CacheConfiguration()); - - final Ignite g0 = G.start(cfg); - - final IgniteCache cache = g0.jcache(null); - - GridTestUtils.assertThrows(log, new Callable() { - @Override public Object call() throws Exception { - return cache.lock(1).tryLock(Long.MAX_VALUE, TimeUnit.MILLISECONDS); - } - }, CacheException.class, "Locks are not supported"); - - GridTestUtils.assertThrows(log, new Callable() { - @Override public Object call() throws Exception { - return cache.lockAll(Collections.singleton(1)).tryLock(Long.MAX_VALUE, TimeUnit.MILLISECONDS); - } - }, CacheException.class, "Locks are not supported"); - } } From 150e25bdf9017cc3b1562b92ed9917efaefa9934 Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Mon, 9 Feb 2015 18:23:33 -0800 Subject: [PATCH 86/95] IGNITE-61 - Direct marshalling (fixes after review) --- .../discovery/GridDiscoveryManager.java | 17 ------- .../discovery/DiscoveryCallback.java | 51 ------------------- 2 files changed, 68 deletions(-) delete mode 100644 modules/core/src/main/java/org/apache/ignite/plugin/extensions/discovery/DiscoveryCallback.java diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java index 834e6498fe320..39df697ce83f0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java @@ -34,7 +34,6 @@ import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.internal.util.worker.*; import org.apache.ignite.lang.*; -import org.apache.ignite.plugin.extensions.discovery.*; import org.apache.ignite.plugin.security.*; import org.apache.ignite.plugin.segmentation.*; import org.apache.ignite.spi.*; @@ -266,11 +265,6 @@ public void setNodeAttributes(Map attrs, IgniteProductVersion ve c.updateAlives(node); } - if (type == EVT_NODE_JOINED) { - for (DiscoveryCallback listener : ctx.plugins().extensions(DiscoveryCallback.class)) - listener.beforeNodeJoined(node); - } - // Put topology snapshot into discovery history. // There is no race possible between history maintenance and concurrent discovery // event notifications, since SPI notifies manager about all events from this listener. @@ -369,11 +363,6 @@ public void setNodeAttributes(Map attrs, IgniteProductVersion ve topVer.setIfGreater(locNode.order()); - for (DiscoveryCallback listener : ctx.plugins().extensions(DiscoveryCallback.class)) { - listener.onStart(discoCache().remoteNodes()); - listener.onStart(discoCache().daemonNodes()); - } - // Start discovery worker. new IgniteThread(discoWrk).start(); @@ -1416,9 +1405,6 @@ else if (log.isDebugEnabled()) if (hasRslvrs) segChkWrk.scheduleSegmentCheck(); - for (DiscoveryCallback listener : ctx.plugins().extensions(DiscoveryCallback.class)) - listener.onNodeLeft(node); - if (!isDaemon) { if (!isLocDaemon) { if (log.isInfoEnabled()) @@ -1440,9 +1426,6 @@ else if (log.isDebugEnabled()) if (hasRslvrs) segChkWrk.scheduleSegmentCheck(); - for (DiscoveryCallback listener : ctx.plugins().extensions(DiscoveryCallback.class)) - listener.onNodeLeft(node); - if (!isDaemon) { if (!isLocDaemon) { U.warn(log, "Node FAILED: " + node); diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/discovery/DiscoveryCallback.java b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/discovery/DiscoveryCallback.java deleted file mode 100644 index 3ff848a1d870d..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/discovery/DiscoveryCallback.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.plugin.extensions.discovery; - -import org.apache.ignite.cluster.*; -import org.apache.ignite.plugin.*; - -import java.util.*; - -/** - * Plugin extension that allows to listen messages from discovery. - * - * TODO 9447: redesign. - */ -public interface DiscoveryCallback extends Extension { - /** - * Handles node start. - * - * @param remoteNodes Remote grid nodes. - */ - public void onStart(Collection remoteNodes); - - /** - * Handles node joined event. - * - * @param node Joined node. - */ - public void beforeNodeJoined(ClusterNode node); - - /** - * Handles node left event. - * - * @param node Left node. - */ - public void onNodeLeft(ClusterNode node); -} From f3c503ed5a5bb04514458d6b422bcb880dd9bbc0 Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Mon, 9 Feb 2015 19:12:52 -0800 Subject: [PATCH 87/95] # IGNITE-61 - Test fix --- .../testframework/GridSpiTestContext.java | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java b/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java index 97cb4882ae35d..80b9b96f39a3b 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java @@ -61,6 +61,12 @@ public class GridSpiTestContext implements IgniteSpiContext { /** */ private final ConcurrentMap cache = new ConcurrentHashMap<>(); + /** */ + private MessageFormatter formatter; + + /** */ + private MessageFactory factory; + /** {@inheritDoc} */ @Override public Collection remoteNodes() { return rmtNodes; @@ -505,21 +511,29 @@ public void triggerEvent(Event evt) { return null; } + /** {@inheritDoc} */ @Override public MessageFormatter messageFormatter() { - return new MessageFormatter() { - @Override public MessageWriter writer() { - return new DirectMessageWriter(); - } + if (formatter == null) { + formatter = new MessageFormatter() { + @Override public MessageWriter writer() { + return new DirectMessageWriter(); + } - @Override public MessageReader reader() { - throw new UnsupportedOperationException(); - } - }; + @Override public MessageReader reader() { + return new DirectMessageReader(messageFactory()); + } + }; + } + + return formatter; } /** {@inheritDoc} */ @Override public MessageFactory messageFactory() { - return new GridIoMessageFactory(messageFormatter(), null); + if (factory == null) + factory = new GridIoMessageFactory(messageFormatter(), null); + + return factory; } /** From 34088fc9828e89f4047d1c98ee793a45bde570c2 Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Mon, 9 Feb 2015 19:30:55 -0800 Subject: [PATCH 88/95] # IGNITE-61 - Generated optimized-classnames.properties --- .../optimized/optimized-classnames.properties | 152 +++++++++--------- 1 file changed, 76 insertions(+), 76 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/optimized-classnames.properties b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/optimized-classnames.properties index bb8aecf210d37..b3ec7fcabee83 100644 --- a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/optimized-classnames.properties +++ b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/optimized-classnames.properties @@ -96,8 +96,8 @@ org.apache.ignite.cache.query.QueryAffinityPredicate org.apache.ignite.cache.query.QueryContinuousPredicate org.apache.ignite.cache.query.QuerySqlPredicate org.apache.ignite.cache.query.QueryTextPredicate -org.apache.ignite.cache.store.jdbc.JdbcCacheStore$EntryMapping$1 -org.apache.ignite.cache.store.jdbc.JdbcCacheStore$EntryMapping$2 +org.apache.ignite.cache.store.jdbc.CacheAbstractJdbcStore$EntryMapping$1 +org.apache.ignite.cache.store.jdbc.CacheAbstractJdbcStore$EntryMapping$2 org.apache.ignite.cache.store.jdbc.dialect.BasicJdbcDialect$1 org.apache.ignite.cache.store.jdbc.dialect.BasicJdbcDialect$2 org.apache.ignite.cache.store.jdbc.dialect.BasicJdbcDialect$3 @@ -152,42 +152,41 @@ org.apache.ignite.compute.gridify.aop.GridifyArgumentAdapter org.apache.ignite.compute.gridify.aop.GridifyDefaultRangeTask org.apache.ignite.compute.gridify.aop.GridifyDefaultTask org.apache.ignite.compute.gridify.aop.spring.GridifySpringPointcut$GridifySpringPointcutType -org.apache.ignite.configuration.IgniteDeploymentMode -org.apache.ignite.configuration.TransactionsConfiguration -org.apache.ignite.datastructures.DataStructureRemovedException -org.apache.ignite.events.IgniteAuthenticationEvent -org.apache.ignite.events.IgniteAuthorizationEvent -org.apache.ignite.events.IgniteCacheEvent -org.apache.ignite.events.IgniteCachePreloadingEvent -org.apache.ignite.events.IgniteCacheQueryExecutedEvent -org.apache.ignite.events.IgniteCacheQueryReadEvent -org.apache.ignite.events.IgniteCheckpointEvent -org.apache.ignite.events.IgniteDeploymentEvent -org.apache.ignite.events.IgniteDiscoveryEvent -org.apache.ignite.events.IgniteEventAdapter +org.apache.ignite.configuration.DeploymentMode +org.apache.ignite.configuration.TransactionConfiguration +org.apache.ignite.events.AuthenticationEvent +org.apache.ignite.events.AuthorizationEvent +org.apache.ignite.events.CacheEvent +org.apache.ignite.events.CachePreloadingEvent +org.apache.ignite.events.CacheQueryExecutedEvent +org.apache.ignite.events.CacheQueryReadEvent +org.apache.ignite.events.CheckpointEvent +org.apache.ignite.events.DeploymentEvent +org.apache.ignite.events.DiscoveryEvent +org.apache.ignite.events.EventAdapter org.apache.ignite.events.IgniteFsEvent -org.apache.ignite.events.IgniteJobEvent -org.apache.ignite.events.IgniteLicenseEvent -org.apache.ignite.events.IgniteSecureSessionEvent -org.apache.ignite.events.IgniteSwapSpaceEvent -org.apache.ignite.events.IgniteTaskEvent -org.apache.ignite.fs.IgniteFsConcurrentModificationException -org.apache.ignite.fs.IgniteFsCorruptedFileException -org.apache.ignite.fs.IgniteFsException -org.apache.ignite.fs.IgniteFsFileNotFoundException -org.apache.ignite.fs.IgniteFsGroupDataBlocksKeyMapper -org.apache.ignite.fs.IgniteFsInvalidHdfsVersionException -org.apache.ignite.fs.IgniteFsInvalidPathException -org.apache.ignite.fs.IgniteFsMode -org.apache.ignite.fs.IgniteFsOutOfSpaceException -org.apache.ignite.fs.IgniteFsParentNotDirectoryException -org.apache.ignite.fs.IgniteFsPath -org.apache.ignite.fs.IgniteFsPathAlreadyExistsException -org.apache.ignite.fs.IgniteFsPathSummary -org.apache.ignite.fs.mapreduce.records.IgniteFsByteDelimiterRecordResolver -org.apache.ignite.fs.mapreduce.records.IgniteFsFixedLengthRecordResolver -org.apache.ignite.fs.mapreduce.records.IgniteFsNewLineRecordResolver -org.apache.ignite.fs.mapreduce.records.IgniteFsStringDelimiterRecordResolver +org.apache.ignite.events.JobEvent +org.apache.ignite.events.LicenseEvent +org.apache.ignite.events.SecureSessionEvent +org.apache.ignite.events.SwapSpaceEvent +org.apache.ignite.events.TaskEvent +org.apache.ignite.ignitefs.IgniteFsConcurrentModificationException +org.apache.ignite.ignitefs.IgniteFsCorruptedFileException +org.apache.ignite.ignitefs.IgniteFsException +org.apache.ignite.ignitefs.IgniteFsFileNotFoundException +org.apache.ignite.ignitefs.IgniteFsGroupDataBlocksKeyMapper +org.apache.ignite.ignitefs.IgniteFsInvalidHdfsVersionException +org.apache.ignite.ignitefs.IgniteFsInvalidPathException +org.apache.ignite.ignitefs.IgniteFsMode +org.apache.ignite.ignitefs.IgniteFsOutOfSpaceException +org.apache.ignite.ignitefs.IgniteFsParentNotDirectoryException +org.apache.ignite.ignitefs.IgniteFsPath +org.apache.ignite.ignitefs.IgniteFsPathAlreadyExistsException +org.apache.ignite.ignitefs.IgniteFsPathSummary +org.apache.ignite.ignitefs.mapreduce.records.IgniteFsByteDelimiterRecordResolver +org.apache.ignite.ignitefs.mapreduce.records.IgniteFsFixedLengthRecordResolver +org.apache.ignite.ignitefs.mapreduce.records.IgniteFsNewLineRecordResolver +org.apache.ignite.ignitefs.mapreduce.records.IgniteFsStringDelimiterRecordResolver org.apache.ignite.internal.ClusterGroupAdapter org.apache.ignite.internal.ClusterGroupAdapter$AgeProjection org.apache.ignite.internal.ClusterGroupAdapter$AttributeFilter @@ -243,14 +242,15 @@ org.apache.ignite.internal.IgniteKernal$1 org.apache.ignite.internal.IgniteKernal$6 org.apache.ignite.internal.IgniteKernal$7 org.apache.ignite.internal.IgniteKernal$8 -org.apache.ignite.internal.IgniteManagedImpl org.apache.ignite.internal.IgniteMessagingImpl org.apache.ignite.internal.IgniteSchedulerImpl +org.apache.ignite.internal.IgniteServicesImpl org.apache.ignite.internal.IgnitionEx$IgniteNamedInstance$1 org.apache.ignite.internal.cluster.ClusterGroupEmptyCheckedException org.apache.ignite.internal.cluster.ClusterTopologyCheckedException org.apache.ignite.internal.compute.ComputeTaskCancelledCheckedException org.apache.ignite.internal.compute.ComputeTaskTimeoutCheckedException +org.apache.ignite.internal.direct.DirectByteBufferStream$Type org.apache.ignite.internal.executor.GridExecutorService org.apache.ignite.internal.executor.GridExecutorService$1 org.apache.ignite.internal.executor.GridExecutorService$TaskTerminateListener @@ -292,31 +292,34 @@ org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException org.apache.ignite.internal.processors.cache.CacheStorePartialUpdateException org.apache.ignite.internal.processors.cache.CacheWeakQueryIteratorsHolder$WeakQueryFutureIterator org.apache.ignite.internal.processors.cache.GridCacheAdapter$10 -org.apache.ignite.internal.processors.cache.GridCacheAdapter$11$1 +org.apache.ignite.internal.processors.cache.GridCacheAdapter$11 org.apache.ignite.internal.processors.cache.GridCacheAdapter$12 -org.apache.ignite.internal.processors.cache.GridCacheAdapter$13 +org.apache.ignite.internal.processors.cache.GridCacheAdapter$13$1 +org.apache.ignite.internal.processors.cache.GridCacheAdapter$14 +org.apache.ignite.internal.processors.cache.GridCacheAdapter$15 org.apache.ignite.internal.processors.cache.GridCacheAdapter$2 -org.apache.ignite.internal.processors.cache.GridCacheAdapter$22$1 -org.apache.ignite.internal.processors.cache.GridCacheAdapter$24 -org.apache.ignite.internal.processors.cache.GridCacheAdapter$25$1 +org.apache.ignite.internal.processors.cache.GridCacheAdapter$24$1 org.apache.ignite.internal.processors.cache.GridCacheAdapter$26 +org.apache.ignite.internal.processors.cache.GridCacheAdapter$27$1 org.apache.ignite.internal.processors.cache.GridCacheAdapter$28 org.apache.ignite.internal.processors.cache.GridCacheAdapter$3 -org.apache.ignite.internal.processors.cache.GridCacheAdapter$5 -org.apache.ignite.internal.processors.cache.GridCacheAdapter$61 -org.apache.ignite.internal.processors.cache.GridCacheAdapter$62 +org.apache.ignite.internal.processors.cache.GridCacheAdapter$30 +org.apache.ignite.internal.processors.cache.GridCacheAdapter$6 +org.apache.ignite.internal.processors.cache.GridCacheAdapter$63 org.apache.ignite.internal.processors.cache.GridCacheAdapter$64 org.apache.ignite.internal.processors.cache.GridCacheAdapter$65 -org.apache.ignite.internal.processors.cache.GridCacheAdapter$66 org.apache.ignite.internal.processors.cache.GridCacheAdapter$67 +org.apache.ignite.internal.processors.cache.GridCacheAdapter$68 +org.apache.ignite.internal.processors.cache.GridCacheAdapter$69 org.apache.ignite.internal.processors.cache.GridCacheAdapter$7 org.apache.ignite.internal.processors.cache.GridCacheAdapter$70 -org.apache.ignite.internal.processors.cache.GridCacheAdapter$8 +org.apache.ignite.internal.processors.cache.GridCacheAdapter$73 org.apache.ignite.internal.processors.cache.GridCacheAdapter$9 org.apache.ignite.internal.processors.cache.GridCacheAdapter$GlobalClearAllCallable org.apache.ignite.internal.processors.cache.GridCacheAdapter$GlobalSizeCallable org.apache.ignite.internal.processors.cache.GridCacheAdapter$LoadCacheClosure org.apache.ignite.internal.processors.cache.GridCacheAdapter$LoadKeysCallable +org.apache.ignite.internal.processors.cache.GridCacheAdapter$SizeCallable org.apache.ignite.internal.processors.cache.GridCacheAdapter$UpdateGetTimeStatClosure org.apache.ignite.internal.processors.cache.GridCacheAdapter$UpdatePutAndGetTimeStatClosure org.apache.ignite.internal.processors.cache.GridCacheAdapter$UpdatePutTimeStatClosure @@ -394,6 +397,7 @@ org.apache.ignite.internal.processors.cache.GridCacheStoreManager$1 org.apache.ignite.internal.processors.cache.GridCacheStoreManager$2 org.apache.ignite.internal.processors.cache.GridCacheStoreManager$3 org.apache.ignite.internal.processors.cache.GridCacheSwapManager$11 +org.apache.ignite.internal.processors.cache.GridCacheSwapManager$14 org.apache.ignite.internal.processors.cache.GridCacheSwapManager$2 org.apache.ignite.internal.processors.cache.GridCacheSwapManager$3 org.apache.ignite.internal.processors.cache.GridCacheSwapManager$4 @@ -426,6 +430,7 @@ org.apache.ignite.internal.processors.cache.GridCacheUtils$6 org.apache.ignite.internal.processors.cache.GridCacheUtils$7 org.apache.ignite.internal.processors.cache.GridCacheUtils$8 org.apache.ignite.internal.processors.cache.GridCacheUtils$9 +org.apache.ignite.internal.processors.cache.GridCacheValueBytes org.apache.ignite.internal.processors.cache.GridCacheValueCollection org.apache.ignite.internal.processors.cache.GridCacheValueCollection$1 org.apache.ignite.internal.processors.cache.GridCacheWriteBehindStore$StoreOperation @@ -447,6 +452,7 @@ org.apache.ignite.internal.processors.cache.distributed.GridCachePessimisticChec org.apache.ignite.internal.processors.cache.distributed.GridCachePessimisticCheckCommittedTxRequest org.apache.ignite.internal.processors.cache.distributed.GridCachePessimisticCheckCommittedTxResponse org.apache.ignite.internal.processors.cache.distributed.GridCacheTtlUpdateRequest +org.apache.ignite.internal.processors.cache.distributed.GridDistributedCacheAdapter$1 org.apache.ignite.internal.processors.cache.distributed.GridDistributedCacheAdapter$GlobalRemoveAllCallable org.apache.ignite.internal.processors.cache.distributed.GridDistributedLockCancelledException org.apache.ignite.internal.processors.cache.distributed.GridDistributedLockRequest @@ -638,10 +644,10 @@ org.apache.ignite.internal.processors.cache.dr.GridCacheDrExpirationInfo org.apache.ignite.internal.processors.cache.dr.GridCacheDrInfo org.apache.ignite.internal.processors.cache.local.GridLocalLockFuture org.apache.ignite.internal.processors.cache.local.GridLocalTxFuture -org.apache.ignite.internal.processors.cache.local.atomic.GridLocalAtomicCache$3 +org.apache.ignite.internal.processors.cache.local.atomic.GridLocalAtomicCache$10 org.apache.ignite.internal.processors.cache.local.atomic.GridLocalAtomicCache$4 org.apache.ignite.internal.processors.cache.local.atomic.GridLocalAtomicCache$5 -org.apache.ignite.internal.processors.cache.local.atomic.GridLocalAtomicCache$8 +org.apache.ignite.internal.processors.cache.local.atomic.GridLocalAtomicCache$6 org.apache.ignite.internal.processors.cache.local.atomic.GridLocalAtomicCache$9 org.apache.ignite.internal.processors.cache.query.GridCacheDistributedFieldsQueryFuture org.apache.ignite.internal.processors.cache.query.GridCacheDistributedQueryFuture @@ -885,7 +891,7 @@ org.apache.ignite.internal.processors.fs.IgniteFsFileImpl org.apache.ignite.internal.processors.fs.IgniteFsMetricsAdapter org.apache.ignite.internal.processors.fs.IgniteFsOutputStreamImpl$ReserveSpaceClosure org.apache.ignite.internal.processors.fs.IgniteFsProcessor$1 -org.apache.ignite.internal.processors.fs.IgniteFsProcessor$3 +org.apache.ignite.internal.processors.fs.IgniteFsProcessor$2 org.apache.ignite.internal.processors.fs.IgniteFsTaskArgsImpl org.apache.ignite.internal.processors.hadoop.GridHadoopDefaultJobInfo org.apache.ignite.internal.processors.hadoop.GridHadoopFileBlock @@ -977,15 +983,11 @@ org.apache.ignite.internal.processors.rest.client.message.GridClientCacheRequest org.apache.ignite.internal.processors.rest.client.message.GridClientCacheRequest$GridCacheOperation org.apache.ignite.internal.processors.rest.client.message.GridClientGetMetaDataRequest org.apache.ignite.internal.processors.rest.client.message.GridClientHandshakeRequest -org.apache.ignite.internal.processors.rest.client.message.GridClientHandshakeRequestWrapper org.apache.ignite.internal.processors.rest.client.message.GridClientHandshakeResponse -org.apache.ignite.internal.processors.rest.client.message.GridClientHandshakeResponseWrapper org.apache.ignite.internal.processors.rest.client.message.GridClientLogRequest -org.apache.ignite.internal.processors.rest.client.message.GridClientMessageWrapper org.apache.ignite.internal.processors.rest.client.message.GridClientNodeBean org.apache.ignite.internal.processors.rest.client.message.GridClientNodeMetricsBean org.apache.ignite.internal.processors.rest.client.message.GridClientPingPacket -org.apache.ignite.internal.processors.rest.client.message.GridClientPingPacketWrapper org.apache.ignite.internal.processors.rest.client.message.GridClientPutMetaDataRequest org.apache.ignite.internal.processors.rest.client.message.GridClientResponse org.apache.ignite.internal.processors.rest.client.message.GridClientTaskRequest @@ -1021,7 +1023,6 @@ org.apache.ignite.internal.processors.rest.handlers.top.GridTopologyCommandHandl org.apache.ignite.internal.processors.rest.protocols.http.jetty.GridJettyRestProtocol$1 org.apache.ignite.internal.processors.rest.protocols.tcp.GridClientPacketType org.apache.ignite.internal.processors.rest.protocols.tcp.GridMemcachedMessage -org.apache.ignite.internal.processors.rest.protocols.tcp.GridMemcachedMessageWrapper org.apache.ignite.internal.processors.rest.protocols.tcp.GridTcpMemcachedNioListener$1 org.apache.ignite.internal.processors.rest.protocols.tcp.GridTcpMemcachedNioListener$2 org.apache.ignite.internal.processors.rest.protocols.tcp.GridTcpRestNioListener$1 @@ -1040,8 +1041,8 @@ org.apache.ignite.internal.processors.service.GridServiceProcessor$AssignmentLis org.apache.ignite.internal.processors.service.GridServiceProcessor$DeploymentListener org.apache.ignite.internal.processors.service.GridServiceProxy org.apache.ignite.internal.processors.service.GridServiceProxy$ServiceProxyCallable -org.apache.ignite.internal.processors.service.ManagedServiceContextImpl -org.apache.ignite.internal.processors.service.ManagedServiceDescriptorImpl +org.apache.ignite.internal.processors.service.ServiceContextImpl +org.apache.ignite.internal.processors.service.ServiceDescriptorImpl org.apache.ignite.internal.processors.streamer.GridStreamerAttributes org.apache.ignite.internal.processors.streamer.GridStreamerCancelRequest org.apache.ignite.internal.processors.streamer.GridStreamerExecutionBatch @@ -1140,9 +1141,6 @@ org.apache.ignite.internal.util.IgniteUtils$6 org.apache.ignite.internal.util.IgniteUtils$7 org.apache.ignite.internal.util.IgniteUtils$8 org.apache.ignite.internal.util.IgniteUtils$9 -org.apache.ignite.internal.util.direct.GridTcpCommunicationMessageAdapter$1 -org.apache.ignite.internal.util.direct.GridTcpCommunicationMessageAdapter$DummyEnum -org.apache.ignite.internal.util.direct.GridTcpCommunicationMessageState$DummyEnum org.apache.ignite.internal.util.future.GridCompoundFuture$1 org.apache.ignite.internal.util.future.GridCompoundFuture$Listener org.apache.ignite.internal.util.future.GridCompoundIdentityFuture @@ -1180,8 +1178,6 @@ org.apache.ignite.internal.util.lang.GridFunc$1 org.apache.ignite.internal.util.lang.GridFunc$10 org.apache.ignite.internal.util.lang.GridFunc$100 org.apache.ignite.internal.util.lang.GridFunc$101 -org.apache.ignite.internal.util.lang.GridFunc$101$1 -org.apache.ignite.internal.util.lang.GridFunc$101$2 org.apache.ignite.internal.util.lang.GridFunc$102 org.apache.ignite.internal.util.lang.GridFunc$102$1 org.apache.ignite.internal.util.lang.GridFunc$102$2 @@ -1192,6 +1188,8 @@ org.apache.ignite.internal.util.lang.GridFunc$104 org.apache.ignite.internal.util.lang.GridFunc$104$1 org.apache.ignite.internal.util.lang.GridFunc$104$2 org.apache.ignite.internal.util.lang.GridFunc$105 +org.apache.ignite.internal.util.lang.GridFunc$105$1 +org.apache.ignite.internal.util.lang.GridFunc$105$2 org.apache.ignite.internal.util.lang.GridFunc$106 org.apache.ignite.internal.util.lang.GridFunc$107 org.apache.ignite.internal.util.lang.GridFunc$108 @@ -1208,22 +1206,22 @@ org.apache.ignite.internal.util.lang.GridFunc$117 org.apache.ignite.internal.util.lang.GridFunc$118 org.apache.ignite.internal.util.lang.GridFunc$119 org.apache.ignite.internal.util.lang.GridFunc$12 +org.apache.ignite.internal.util.lang.GridFunc$120 org.apache.ignite.internal.util.lang.GridFunc$121 -org.apache.ignite.internal.util.lang.GridFunc$122 +org.apache.ignite.internal.util.lang.GridFunc$123 org.apache.ignite.internal.util.lang.GridFunc$124 -org.apache.ignite.internal.util.lang.GridFunc$125 +org.apache.ignite.internal.util.lang.GridFunc$126 org.apache.ignite.internal.util.lang.GridFunc$127 -org.apache.ignite.internal.util.lang.GridFunc$128 org.apache.ignite.internal.util.lang.GridFunc$129 org.apache.ignite.internal.util.lang.GridFunc$13 +org.apache.ignite.internal.util.lang.GridFunc$130 org.apache.ignite.internal.util.lang.GridFunc$131 -org.apache.ignite.internal.util.lang.GridFunc$132 org.apache.ignite.internal.util.lang.GridFunc$133 org.apache.ignite.internal.util.lang.GridFunc$134 org.apache.ignite.internal.util.lang.GridFunc$135 org.apache.ignite.internal.util.lang.GridFunc$136 +org.apache.ignite.internal.util.lang.GridFunc$137 org.apache.ignite.internal.util.lang.GridFunc$138 -org.apache.ignite.internal.util.lang.GridFunc$139 org.apache.ignite.internal.util.lang.GridFunc$14 org.apache.ignite.internal.util.lang.GridFunc$140 org.apache.ignite.internal.util.lang.GridFunc$141 @@ -1251,6 +1249,8 @@ org.apache.ignite.internal.util.lang.GridFunc$160 org.apache.ignite.internal.util.lang.GridFunc$161 org.apache.ignite.internal.util.lang.GridFunc$162 org.apache.ignite.internal.util.lang.GridFunc$163 +org.apache.ignite.internal.util.lang.GridFunc$164 +org.apache.ignite.internal.util.lang.GridFunc$165 org.apache.ignite.internal.util.lang.GridFunc$17 org.apache.ignite.internal.util.lang.GridFunc$18 org.apache.ignite.internal.util.lang.GridFunc$19 @@ -1335,7 +1335,7 @@ org.apache.ignite.internal.util.lang.GridFunc$9 org.apache.ignite.internal.util.lang.GridFunc$90 org.apache.ignite.internal.util.lang.GridFunc$91 org.apache.ignite.internal.util.lang.GridFunc$92 -org.apache.ignite.internal.util.lang.GridFunc$95 +org.apache.ignite.internal.util.lang.GridFunc$93 org.apache.ignite.internal.util.lang.GridFunc$96 org.apache.ignite.internal.util.lang.GridFunc$97 org.apache.ignite.internal.util.lang.GridFunc$98 @@ -1531,14 +1531,13 @@ org.apache.ignite.lang.IgniteFutureTimeoutException org.apache.ignite.lang.IgniteProductVersion org.apache.ignite.lang.IgniteUuid org.apache.ignite.lifecycle.LifecycleEventType -org.apache.ignite.logger.log4j.IgniteLog4jLogger$1 -org.apache.ignite.logger.log4j.IgniteLog4jLogger$2 -org.apache.ignite.logger.log4j.IgniteLog4jLogger$3 -org.apache.ignite.logger.log4j.IgniteLog4jLogger$4 org.apache.ignite.logger.log4j.IgniteLog4jNodeIdFilePath -org.apache.ignite.managed.ManagedServiceConfiguration -org.apache.ignite.marshaller.jdk.IgniteJdkMarshallerDummySerializable -org.apache.ignite.marshaller.optimized.IgniteOptimizedFieldType +org.apache.ignite.logger.log4j.Log4JLogger$1 +org.apache.ignite.logger.log4j.Log4JLogger$2 +org.apache.ignite.logger.log4j.Log4JLogger$3 +org.apache.ignite.logger.log4j.Log4JLogger$4 +org.apache.ignite.marshaller.jdk.JdkMarshallerDummySerializable +org.apache.ignite.marshaller.optimized.OptimizedFieldType org.apache.ignite.plugin.PluginNotFoundException org.apache.ignite.plugin.PluginValidationException org.apache.ignite.plugin.security.GridSecurityCredentials @@ -1548,6 +1547,7 @@ org.apache.ignite.plugin.security.GridSecuritySubjectType org.apache.ignite.plugin.segmentation.GridSegmentationPolicy org.apache.ignite.portables.PortableException org.apache.ignite.portables.PortableInvalidClassException +org.apache.ignite.services.ServiceConfiguration org.apache.ignite.spi.IgnitePortProtocol org.apache.ignite.spi.IgniteSpiException org.apache.ignite.spi.IgniteSpiMultiException From 1c114052b9b11a1d8cf344ecd6b40603e1e41bed Mon Sep 17 00:00:00 2001 From: Valentin Kulichenko Date: Mon, 9 Feb 2015 19:57:32 -0800 Subject: [PATCH 89/95] IGNITE-61 - Direct marshalling improvements --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index b30a379a70dc6..498ce6391b88f 100644 --- a/pom.xml +++ b/pom.xml @@ -802,7 +802,7 @@ Ignite plugin API - org.apache.ignite.plugin:org.apache.ignite.plugin.extensions:org.apache.ignite.plugin.extensions.communication:org.apache.ignite.plugin.extensions.discovery:org.apache.ignite.visor.plugin + org.apache.ignite.plugin:org.apache.ignite.plugin.extensions:org.apache.ignite.plugin.extensions.communication:org.apache.ignite.visor.plugin Logging @@ -1012,7 +1012,7 @@ Ignite plugin API - org.apache.ignite.plugin:org.apache.ignite.plugin.extensions:org.apache.ignite.plugin.extensions.communication:org.apache.ignite.plugin.extensions.discovery:org.apache.ignite.visor.plugin + org.apache.ignite.plugin:org.apache.ignite.plugin.extensions:org.apache.ignite.plugin.extensions.communication:org.apache.ignite.visor.plugin Logging From e23789c714b22cb1046e9caf21736a6b943c4250 Mon Sep 17 00:00:00 2001 From: anovikov Date: Tue, 10 Feb 2015 11:31:28 +0700 Subject: [PATCH 90/95] # ignite-32 Fixed configuration in store benchmark. --- .../config/benchmark-store.properties | 33 +++++++++--- .../yardstick/config/ignite-store-config.xml | 50 ++++++------------- .../yardstick/IgniteBenchmarkArguments.java | 22 ++++++++ .../apache/ignite/yardstick/IgniteNode.java | 5 ++ 4 files changed, 67 insertions(+), 43 deletions(-) diff --git a/modules/yardstick/config/benchmark-store.properties b/modules/yardstick/config/benchmark-store.properties index c8e8cd72c695f..8a7c2652e5f74 100644 --- a/modules/yardstick/config/benchmark-store.properties +++ b/modules/yardstick/config/benchmark-store.properties @@ -42,7 +42,7 @@ JVM_OPTS=${JVM_OPTS}" \ # List of default probes. # Add DStatProbe or VmStatProbe if your OS supports it (e.g. if running on Linux). -BENCHMARK_DEFAULT_PROBES=ThroughputLatencyProbe,PercentileProbe,DStatProbe +BENCHMARK_DEFAULT_PROBES=ThroughputLatencyProbe,PercentileProbe # Packages where the specified benchmark is searched by reflection mechanism. BENCHMARK_PACKAGES=org.yardstickframework,org.apache.ignite.yardstick @@ -64,13 +64,30 @@ DRIVER_HOSTS=localhost # Number of nodes, used to wait for the specified number of nodes to start. nodesNum=$((`echo ${SERVER_HOSTS} | tr ',' '\n' | wc -l` + `echo ${DRIVER_HOSTS} | tr ',' '\n' | wc -l`)) +# Each benchmark warm_up set to 60 seconds (1 minute). +warm_up=60 + +# Each benchmark run set to 300 seconds (5 mins). +run=300 + # Run configuration which contains all benchmarks. -# Note that each benchmark is set to run for 300 seconds (5 mins) with warm-up set to 60 seconds (1 minute). CONFIGS="\ --cfg ${SCRIPT_DIR}/../config/ignite-store-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcStoreGetBenchmark -sn IgniteNode -ds atomic-get,\ --cfg ${SCRIPT_DIR}/../config/ignite-store-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcStoreGetTxBenchmark -sn IgniteNode -ds tx-get,\ --cfg ${SCRIPT_DIR}/../config/ignite-store-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcStorePutBenchmark -sn IgniteNode -ds atomic-put,\ --cfg ${SCRIPT_DIR}/../config/ignite-store-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcStorePutTxBenchmark -sn IgniteNode -ds tx-put,\ --cfg ${SCRIPT_DIR}/../config/ignite-store-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcStorePutGetBenchmark -sn IgniteNode -ds atomic-put-get,\ --cfg ${SCRIPT_DIR}/../config/ignite-store-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcStorePutGetTxBenchmark -sn IgniteNode -ds tx-put-get\ +-cfg ${SCRIPT_DIR}/../config/ignite-store-config.xml -nn ${nodesNum} -b 1 -w ${warm_up} -d ${run} -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcStoreGetBenchmark -sn IgniteNode -ds atomic-get,\ +-cfg ${SCRIPT_DIR}/../config/ignite-store-config.xml -nn ${nodesNum} -b 1 -w ${warm_up} -d ${run} -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcStoreGetBenchmark -sn IgniteNode -cs -ds atomic-store-get,\ +-cfg ${SCRIPT_DIR}/../config/ignite-store-config.xml -nn ${nodesNum} -b 1 -w ${warm_up} -d ${run} -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcStoreGetBenchmark -sn IgniteNode -cs -wb -ds atomic-writeBehind-get,\ +-cfg ${SCRIPT_DIR}/../config/ignite-store-config.xml -nn ${nodesNum} -b 1 -w ${warm_up} -d ${run} -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcStoreGetTxBenchmark -sn IgniteNode -ds tx-get,\ +-cfg ${SCRIPT_DIR}/../config/ignite-store-config.xml -nn ${nodesNum} -b 1 -w ${warm_up} -d ${run} -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcStoreGetTxBenchmark -sn IgniteNode -cs -ds tx-store-get,\ +-cfg ${SCRIPT_DIR}/../config/ignite-store-config.xml -nn ${nodesNum} -b 1 -w ${warm_up} -d ${run} -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcStoreGetTxBenchmark -sn IgniteNode -cs -wb -ds tx-writeBehind-get,\ +-cfg ${SCRIPT_DIR}/../config/ignite-store-config.xml -nn ${nodesNum} -b 1 -w ${warm_up} -d ${run} -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcStorePutBenchmark -sn IgniteNode -ds atomic-put,\ +-cfg ${SCRIPT_DIR}/../config/ignite-store-config.xml -nn ${nodesNum} -b 1 -w ${warm_up} -d ${run} -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcStorePutBenchmark -sn IgniteNode -cs -ds atomic-store-put,\ +-cfg ${SCRIPT_DIR}/../config/ignite-store-config.xml -nn ${nodesNum} -b 1 -w ${warm_up} -d ${run} -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcStorePutBenchmark -sn IgniteNode -cs -wb -ds atomic-writeBehind-put,\ +-cfg ${SCRIPT_DIR}/../config/ignite-store-config.xml -nn ${nodesNum} -b 1 -w ${warm_up} -d ${run} -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcStorePutTxBenchmark -sn IgniteNode -ds tx-put,\ +-cfg ${SCRIPT_DIR}/../config/ignite-store-config.xml -nn ${nodesNum} -b 1 -w ${warm_up} -d ${run} -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcStorePutTxBenchmark -sn IgniteNode -cs -ds tx-store-put,\ +-cfg ${SCRIPT_DIR}/../config/ignite-store-config.xml -nn ${nodesNum} -b 1 -w ${warm_up} -d ${run} -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcStorePutTxBenchmark -sn IgniteNode -cs -wb -ds tx-writeBehind-put,\ +-cfg ${SCRIPT_DIR}/../config/ignite-store-config.xml -nn ${nodesNum} -b 1 -w ${warm_up} -d ${run} -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcStorePutGetBenchmark -sn IgniteNode -ds atomic-put-get,\ +-cfg ${SCRIPT_DIR}/../config/ignite-store-config.xml -nn ${nodesNum} -b 1 -w ${warm_up} -d ${run} -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcStorePutGetBenchmark -sn IgniteNode -cs -ds atomic-store-put-get,\ +-cfg ${SCRIPT_DIR}/../config/ignite-store-config.xml -nn ${nodesNum} -b 1 -w ${warm_up} -d ${run} -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcStorePutGetBenchmark -sn IgniteNode -cs -wb -ds atomic-writeBehind-put-get,\ +-cfg ${SCRIPT_DIR}/../config/ignite-store-config.xml -nn ${nodesNum} -b 1 -w ${warm_up} -d ${run} -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcStorePutGetTxBenchmark -sn IgniteNode -ds tx-put-get,\ +-cfg ${SCRIPT_DIR}/../config/ignite-store-config.xml -nn ${nodesNum} -b 1 -w ${warm_up} -d ${run} -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcStorePutGetTxBenchmark -sn IgniteNode -cs -ds tx-store-put-get,\ +-cfg ${SCRIPT_DIR}/../config/ignite-store-config.xml -nn ${nodesNum} -b 1 -w ${warm_up} -d ${run} -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcStorePutGetTxBenchmark -sn IgniteNode -cs -wb -ds tx-writeBehind-put-get\ " diff --git a/modules/yardstick/config/ignite-store-config.xml b/modules/yardstick/config/ignite-store-config.xml index b1076217b2cdb..4cbee370e026b 100644 --- a/modules/yardstick/config/ignite-store-config.xml +++ b/modules/yardstick/config/ignite-store-config.xml @@ -24,6 +24,18 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> + + + + + + + + + + @@ -93,25 +105,9 @@ - - - - - - - - - - - + - - - - - - @@ -133,25 +129,9 @@ - - - - - - - - - - - + - - - - - - diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java index 12047209164e1..72d701374e0ba 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java @@ -86,6 +86,14 @@ public class IgniteBenchmarkArguments { @Parameter(names = {"-j", "--jobs"}, description = "Number of jobs for compute benchmarks") private int jobs = 10; + /** */ + @Parameter(names = {"-cs", "--cacheStore"}, description = "Enable or disable cache store readThrough, writeThrough") + private boolean storeEnabled; + + /** */ + @Parameter(names = {"-wb", "--writeBehind"}, description = "Enable or disable writeBehind for cache store") + private boolean writeBehind; + /** * @return Transaction concurrency. */ @@ -198,6 +206,20 @@ public int jobs() { return jobs; } + /** + * @return {@code True} if enabled readThrough, writeThrough for cache. + */ + public boolean isStoreEnabled() { + return storeEnabled; + } + + /** + * @return {@code True} if enabled writeBehind for cache store. + */ + public boolean isWriteBehind() { + return writeBehind; + } + /** * @return Description. */ diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteNode.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteNode.java index 94e6f52850823..7d6439846c400 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteNode.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteNode.java @@ -105,6 +105,11 @@ public IgniteNode(boolean clientMode, Ignite ignite) { cc.setEvictionPolicy(new CacheLruEvictionPolicy(50000)); } + cc.setReadThrough(args.isStoreEnabled()); + + cc.setWriteThrough(args.isStoreEnabled()); + + cc.setWriteBehindEnabled(args.isWriteBehind()); } TransactionConfiguration tc = c.getTransactionConfiguration(); From 81c443ac3e473d931d6506deee9ae508b8c1bbe0 Mon Sep 17 00:00:00 2001 From: Alexey Goncharuk Date: Mon, 9 Feb 2015 22:24:42 -0800 Subject: [PATCH 91/95] IGNITE-51 - Fixes after merge. --- .../java/org/apache/ignite/internal/util/IgniteUtils.java | 4 ---- .../marshaller/optimized/optimized-classnames.properties | 8 -------- 2 files changed, 12 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java index b887c52f72904..2d4e26bb5bf20 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java @@ -42,9 +42,6 @@ import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.internal.util.worker.*; -import org.apache.ignite.lang.*; -import org.apache.ignite.lifecycle.*; -import org.apache.ignite.spi.*; import org.apache.ignite.spi.discovery.*; import org.apache.ignite.transactions.*; import org.jdk8.backport.*; @@ -69,7 +66,6 @@ import java.security.*; import java.security.cert.*; import java.sql.*; -import java.sql.Timestamp; import java.text.*; import java.util.*; import java.util.Date; diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/optimized-classnames.properties b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/optimized-classnames.properties index b3ec7fcabee83..e6ece603d8883 100644 --- a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/optimized-classnames.properties +++ b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/optimized-classnames.properties @@ -981,14 +981,12 @@ org.apache.ignite.internal.processors.rest.client.message.GridClientCacheQueryRe org.apache.ignite.internal.processors.rest.client.message.GridClientCacheQueryRequest$GridQueryType org.apache.ignite.internal.processors.rest.client.message.GridClientCacheRequest org.apache.ignite.internal.processors.rest.client.message.GridClientCacheRequest$GridCacheOperation -org.apache.ignite.internal.processors.rest.client.message.GridClientGetMetaDataRequest org.apache.ignite.internal.processors.rest.client.message.GridClientHandshakeRequest org.apache.ignite.internal.processors.rest.client.message.GridClientHandshakeResponse org.apache.ignite.internal.processors.rest.client.message.GridClientLogRequest org.apache.ignite.internal.processors.rest.client.message.GridClientNodeBean org.apache.ignite.internal.processors.rest.client.message.GridClientNodeMetricsBean org.apache.ignite.internal.processors.rest.client.message.GridClientPingPacket -org.apache.ignite.internal.processors.rest.client.message.GridClientPutMetaDataRequest org.apache.ignite.internal.processors.rest.client.message.GridClientResponse org.apache.ignite.internal.processors.rest.client.message.GridClientTaskRequest org.apache.ignite.internal.processors.rest.client.message.GridClientTaskResultBean @@ -1501,10 +1499,6 @@ org.apache.ignite.internal.visor.node.VisorPeerToPeerConfiguration org.apache.ignite.internal.visor.node.VisorRestConfiguration org.apache.ignite.internal.visor.node.VisorSegmentationConfiguration org.apache.ignite.internal.visor.node.VisorSpisConfiguration -org.apache.ignite.internal.visor.portable.VisorPortableMetadata -org.apache.ignite.internal.visor.portable.VisorPortableMetadataCollectorTask -org.apache.ignite.internal.visor.portable.VisorPortableMetadataCollectorTask$VisorPortableCollectMetadataJob -org.apache.ignite.internal.visor.portable.VisorPortableMetadataField org.apache.ignite.internal.visor.query.VisorQueryCleanupTask org.apache.ignite.internal.visor.query.VisorQueryCleanupTask$VisorQueryCleanupJob org.apache.ignite.internal.visor.query.VisorQueryField @@ -1545,8 +1539,6 @@ org.apache.ignite.plugin.security.GridSecurityException org.apache.ignite.plugin.security.GridSecurityPermission org.apache.ignite.plugin.security.GridSecuritySubjectType org.apache.ignite.plugin.segmentation.GridSegmentationPolicy -org.apache.ignite.portables.PortableException -org.apache.ignite.portables.PortableInvalidClassException org.apache.ignite.services.ServiceConfiguration org.apache.ignite.spi.IgnitePortProtocol org.apache.ignite.spi.IgniteSpiException From 8ae4e9129aaa78f98d2a9f60d23151cdf8e51af0 Mon Sep 17 00:00:00 2001 From: vozerov-gridgain Date: Tue, 10 Feb 2015 09:57:17 +0300 Subject: [PATCH 92/95] # One more fix to "removeAll" in GridCacheProjectionImpl. --- .../internal/processors/cache/GridCacheProjectionImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java index 149a994863704..81df27e27ad3b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java @@ -1212,7 +1212,7 @@ private IgnitePredicate> visitor(final IgnitePredicate removeAllAsync() { - return cache.removeAllAsync(); + return removeAllAsync(new IgnitePredicate[0]); } /** {@inheritDoc} */ From 11cd874db703bd4a6cb5964e8a9dc17ddf7fda10 Mon Sep 17 00:00:00 2001 From: sboikov Date: Tue, 10 Feb 2015 11:37:44 +0300 Subject: [PATCH 93/95] # sprint-1 fixed test --- .../GridCacheAbstractFullApiSelfTest.java | 38 ++++++++++--------- ...micClientOnlyMultiNodeFullApiSelfTest.java | 6 +-- ...tomicNearOnlyMultiNodeFullApiSelfTest.java | 19 ++++------ 3 files changed, 30 insertions(+), 33 deletions(-) diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java index 78fa8c50e530b..f5799986f1871 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java @@ -2914,8 +2914,7 @@ public void testPeekMode() throws Exception { /** * @throws Exception In case of error. */ - // TODO: IGNITE-206: Enable when fixed. - public void _testEvictExpired() throws Exception { + public void testEvictExpired() throws Exception { IgniteCache cache = jcache(); String key = primaryKeysForCache(cache, 1).get(0); @@ -2943,16 +2942,14 @@ public void _testEvictExpired() throws Exception { assertTrue(cache.localSize() == 0); - // Force reload on primary node. - for (int i = 0; i < gridCount(); i++) { - if (cache(i).entry(key).primary()) - load(jcache(i), key, true); - } - - // Will do near get request. load(cache, key, true); - assertEquals((Integer)1, peek(cache, key)); + CacheAffinity aff = ignite(0).affinity(null); + + for (int i = 0; i < gridCount(); i++) { + if (aff.isPrimaryOrBackup(grid(i).cluster().localNode(), key)) + assertEquals((Integer)1, peek(jcache(i), key)); + } } /** @@ -3256,8 +3253,7 @@ private void checkTtl(boolean inTx, boolean oldEntry) throws Exception { /** * @throws Exception In case of error. */ - // TODO: IGNITE-206: Enable when fixed. - public void _testLocalEvict() throws Exception { + public void testLocalEvict() throws Exception { IgniteCache cache = jcache(); List keys = primaryKeysForCache(cache, 3); @@ -3280,14 +3276,20 @@ public void _testLocalEvict() throws Exception { assert cache.localPeek(key2, CachePeekMode.ONHEAP) == null; assert cache.localPeek(key3, CachePeekMode.ONHEAP) == 3; - if (cache.getConfiguration(CacheConfiguration.class).getDistributionMode() == CacheDistributionMode.NEAR_ONLY) - return; - loadAll(cache, ImmutableSet.of(key1, key2), true); - assert cache.localPeek(key1, CachePeekMode.ONHEAP) == 1; - assert cache.localPeek(key2, CachePeekMode.ONHEAP) == 2; - assert cache.localPeek(key3, CachePeekMode.ONHEAP) == 3; + CacheAffinity aff = ignite(0).affinity(null); + + for (int i = 0; i < gridCount(); i++) { + if (aff.isPrimaryOrBackup(grid(i).cluster().localNode(), key1)) + assertEquals((Integer)1, peek(jcache(i), key1)); + + if (aff.isPrimaryOrBackup(grid(i).cluster().localNode(), key2)) + assertEquals((Integer)2, peek(jcache(i), key2)); + + if (aff.isPrimaryOrBackup(grid(i).cluster().localNode(), key3)) + assertEquals((Integer)3, peek(jcache(i), key3)); + } } /** diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java index 8c182581393d2..843a1caf1941b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java @@ -144,8 +144,7 @@ public class GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest extends GridCache } /** {@inheritDoc} */ - // TODO: IGNITE-206: Enable when fixed. - @Override public void _testEvictExpired() throws Exception { + @Override public void testEvictExpired() throws Exception { IgniteCache cache = jcache(); String key = primaryKeysForCache(cache, 1).get(0); @@ -185,8 +184,7 @@ public class GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest extends GridCache } /** {@inheritDoc} */ - // TODO: IGNITE-206: Enable when fixed. - @Override public void _testLocalEvict() throws Exception { + @Override public void testLocalEvict() throws Exception { IgniteCache cache = jcache(); List keys = primaryKeysForCache(cache, 3); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest.java index a431d831b6d1b..59a347f473490 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest.java @@ -19,8 +19,8 @@ import org.apache.ignite.*; import org.apache.ignite.cache.*; +import org.apache.ignite.cache.affinity.*; import org.apache.ignite.configuration.*; -import org.apache.ignite.internal.util.typedef.*; import javax.cache.expiry.*; import java.util.*; @@ -115,8 +115,7 @@ public class GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest extends GridCacheNe } /** {@inheritDoc} */ - // TODO: IGNITE-206: Enable when fixed. - @Override public void _testEvictExpired() throws Exception { + @Override public void testEvictExpired() throws Exception { IgniteCache cache = jcache(); String key = primaryKeysForCache(cache, 1).get(0); @@ -143,15 +142,13 @@ public class GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest extends GridCacheNe assertTrue(cache.localSize() == 0); - // Force reload on primary node. - for (int i = 0; i < gridCount(); i++) { - if (ignite(i).affinity(null).isPrimary(ignite(i).cluster().localNode(), key)) - load(jcache(i), key, true); - } - - // Will do near get request. load(cache, key, true); - assertEquals((Integer)1, cache.localPeek(key, CachePeekMode.ONHEAP)); + CacheAffinity aff = ignite(0).affinity(null); + + for (int i = 0; i < gridCount(); i++) { + if (aff.isPrimaryOrBackup(grid(i).cluster().localNode(), key)) + assertEquals((Integer)1, peek(jcache(i), key)); + } } } From 4e60207b2a1636f536ce2c0c34976f5e6f9ed718 Mon Sep 17 00:00:00 2001 From: avinogradov Date: Tue, 10 Feb 2015 13:37:29 +0300 Subject: [PATCH 94/95] Ignite-192 Implemented --- assembly/release-base.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/assembly/release-base.xml b/assembly/release-base.xml index 2a82af8b2e9cd..3c94d6f490aa7 100644 --- a/assembly/release-base.xml +++ b/assembly/release-base.xml @@ -27,6 +27,11 @@ / + + NOTICE.txt + / + + config/ignite-log4j.xml /config From d70e59f0867306f48859763444c10315dabca0c0 Mon Sep 17 00:00:00 2001 From: vozerov-gridgain Date: Tue, 10 Feb 2015 15:15:26 +0300 Subject: [PATCH 95/95] # IGNITE-200: Removed cache versioned entry. --- .../processors/cache/GridCacheContext.java | 4 +- .../processors/cache/GridCacheMapEntry.java | 2 +- .../cache/GridCacheUpdateAtomicResult.java | 6 +- .../GridDistributedTxRemoteAdapter.java | 4 +- .../dht/atomic/GridDhtAtomicCache.java | 4 +- .../cache/transactions/IgniteTxAdapter.java | 6 +- .../transactions/IgniteTxLocalAdapter.java | 4 +- ...dCacheVersionAbstractConflictResolver.java | 6 +- .../GridCacheVersionConflictContext.java | 166 +++++++++++++++- .../GridCacheVersionConflictContextImpl.java | 187 ------------------ .../GridCacheVersionConflictResolver.java | 2 +- 11 files changed, 175 insertions(+), 216 deletions(-) delete mode 100644 modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionConflictContextImpl.java diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java index 21e572d70e98d..8fe80e351285e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java @@ -1581,11 +1581,11 @@ public boolean conflictNeedResolve(GridCacheVersion oldVer, GridCacheVersion new * @return Conflict resolution result. * @throws IgniteCheckedException In case of exception. */ - public GridCacheVersionConflictContextImpl conflictResolve(GridCacheVersionedEntryEx oldEntry, + public GridCacheVersionConflictContext conflictResolve(GridCacheVersionedEntryEx oldEntry, GridCacheVersionedEntryEx newEntry, boolean atomicVerComparator) throws IgniteCheckedException { assert conflictRslvr != null : "Should not reach this place."; - GridCacheVersionConflictContextImpl ctx = conflictRslvr.resolve(oldEntry, newEntry, atomicVerComparator); + GridCacheVersionConflictContext ctx = conflictRslvr.resolve(oldEntry, newEntry, atomicVerComparator); if (ctx.isManualResolve()) drMgr.onReceiveCacheConflictResolved(ctx.isUseNew(), ctx.isUseOld(), ctx.isMerge()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java index d57648bc1f49e..ca7b74080563c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java @@ -1657,7 +1657,7 @@ else if (log.isDebugEnabled()) GridCacheVersion enqueueVer = null; - GridCacheVersionConflictContextImpl drRes = null; + GridCacheVersionConflictContext drRes = null; EntryProcessorResult invokeRes = null; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUpdateAtomicResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUpdateAtomicResult.java index 16ab38d592caf..cabfaa5a3fd74 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUpdateAtomicResult.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUpdateAtomicResult.java @@ -51,7 +51,7 @@ public class GridCacheUpdateAtomicResult { /** DR resolution result. */ @GridToStringInclude - private final GridCacheVersionConflictContextImpl drRes; + private final GridCacheVersionConflictContext drRes; /** Whether update should be propagated to DHT node. */ private final boolean sndToDht; @@ -79,7 +79,7 @@ public GridCacheUpdateAtomicResult(boolean success, long newTtl, long drExpireTime, @Nullable GridCacheVersion rmvVer, - @Nullable GridCacheVersionConflictContextImpl drRes, + @Nullable GridCacheVersionConflictContext drRes, boolean sndToDht) { this.success = success; this.oldVal = oldVal; @@ -144,7 +144,7 @@ public long drExpireTime() { /** * @return DR conflict resolution context. */ - @Nullable public GridCacheVersionConflictContextImpl drResolveResult() { + @Nullable public GridCacheVersionConflictContext drResolveResult() { return drRes; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java index 3807cc9300f90..be65c0028750c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java @@ -514,13 +514,13 @@ private void commitIfLocked() throws IgniteCheckedException { cacheCtx.conflictNeedResolve(cached.version(), explicitVer); if (drNeedResolve) { - IgniteBiTuple> + IgniteBiTuple> drRes = conflictResolve(op, txEntry.key(), val, valBytes, txEntry.ttl(), txEntry.drExpireTime(), explicitVer, cached); assert drRes != null; - GridCacheVersionConflictContextImpl drCtx = drRes.get2(); + GridCacheVersionConflictContext drCtx = drRes.get2(); if (drCtx.isUseOld()) op = NOOP; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java index c757ad2a141b1..cf67c15dc79b0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java @@ -1709,7 +1709,7 @@ primary && writeThrough(), if (dhtFut != null) { if (updRes.sendToDht()) { // Send to backups even in case of remove-remove scenarios. - GridCacheVersionConflictContextImpl ctx = updRes.drResolveResult(); + GridCacheVersionConflictContext ctx = updRes.drResolveResult(); long ttl = updRes.newTtl(); long expireTime = updRes.drExpireTime(); @@ -1755,7 +1755,7 @@ else if (ctx.isMerge()) { if (hasNear) { if (primary && updRes.sendToDht()) { if (!ctx.affinity().belongs(node, entry.partition(), topVer)) { - GridCacheVersionConflictContextImpl ctx = updRes.drResolveResult(); + GridCacheVersionConflictContext ctx = updRes.drResolveResult(); long ttl = updRes.newTtl(); long expireTime = updRes.drExpireTime(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java index 01e06ba775b15..eb5e662d74776 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java @@ -1257,7 +1257,7 @@ public String resolveTaskName() { * @throws org.apache.ignite.IgniteCheckedException In case of eny exception. * @throws GridCacheEntryRemovedException If entry got removed. */ - protected IgniteBiTuple> conflictResolve( + protected IgniteBiTuple> conflictResolve( GridCacheOperation op, K key, V newVal, byte[] newValBytes, long newTtl, long newDrExpireTime, GridCacheVersion newVer, GridCacheEntryEx old) throws IgniteCheckedException, GridCacheEntryRemovedException { @@ -1271,9 +1271,9 @@ protected IgniteBiTuple= 0L ? newDrExpireTime : CU.toExpireTime(newTtl); GridCacheVersionedEntryEx newEntry = - new GridCachePlainVersionedEntry(key, newVal, newTtl, newExpireTime, newVer); + new GridCachePlainVersionedEntry<>(key, newVal, newTtl, newExpireTime, newVer); - GridCacheVersionConflictContextImpl ctx = old.context().conflictResolve(oldEntry, newEntry, false); + GridCacheVersionConflictContext ctx = old.context().conflictResolve(oldEntry, newEntry, false); if (ctx.isMerge()) { V resVal = ctx.mergeValue(); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java index 71eda9730863c..f985753bbae5d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java @@ -737,13 +737,13 @@ else if (cacheCtx.isNear() && txEntry.locallyMapped()) boolean drNeedResolve = cacheCtx.conflictNeedResolve(cached.version(), explicitVer); if (drNeedResolve) { - IgniteBiTuple> + IgniteBiTuple> drRes = conflictResolve(op, txEntry.key(), val, valBytes, txEntry.ttl(), txEntry.drExpireTime(), explicitVer, cached); assert drRes != null; - GridCacheVersionConflictContextImpl conflictCtx = drRes.get2(); + GridCacheVersionConflictContext conflictCtx = drRes.get2(); if (conflictCtx.isUseOld()) op = NOOP; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionAbstractConflictResolver.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionAbstractConflictResolver.java index a91bd4d3387e6..8bc6425cecf74 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionAbstractConflictResolver.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionAbstractConflictResolver.java @@ -32,9 +32,9 @@ public abstract class GridCacheVersionAbstractConflictResolver { * @return Conflict resolution context. * @throws IgniteCheckedException If failed. */ - public GridCacheVersionConflictContextImpl resolve(GridCacheVersionedEntryEx oldEntry, + public GridCacheVersionConflictContext resolve(GridCacheVersionedEntryEx oldEntry, GridCacheVersionedEntryEx newEntry, boolean atomicVerComparator) throws IgniteCheckedException { - GridCacheVersionConflictContextImpl ctx = new GridCacheVersionConflictContextImpl<>(oldEntry, newEntry); + GridCacheVersionConflictContext ctx = new GridCacheVersionConflictContext<>(oldEntry, newEntry); resolve0(ctx, oldEntry, newEntry, atomicVerComparator); @@ -50,7 +50,7 @@ public GridCacheVersionConflictContextImpl resolve(GridCacheVersion * @param atomicVerComparator Whether to use atomic version comparator. * @throws IgniteCheckedException If failed. */ - protected abstract void resolve0(GridCacheVersionConflictContextImpl ctx, + protected abstract void resolve0(GridCacheVersionConflictContext ctx, GridCacheVersionedEntryEx oldEntry, GridCacheVersionedEntryEx newEntry, boolean atomicVerComparator) throws IgniteCheckedException; } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionConflictContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionConflictContext.java index 72c323b985271..ab690e6bfb2bb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionConflictContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionConflictContext.java @@ -17,38 +17,87 @@ package org.apache.ignite.internal.processors.cache.version; -import org.apache.ignite.cache.*; +import org.apache.ignite.internal.util.tostring.*; +import org.apache.ignite.internal.util.typedef.internal.*; import org.jetbrains.annotations.*; /** - * Cache version conflict context. + * Conflict context implementation. */ -public interface GridCacheVersionConflictContext { +public class GridCacheVersionConflictContext { + /** Old entry. */ + @GridToStringInclude + private final GridCacheVersionedEntry oldEntry; + + /** New entry. */ + @GridToStringInclude + private final GridCacheVersionedEntry newEntry; + + /** Current state. */ + private State state; + + /** Current merge value. */ + @GridToStringExclude + private V mergeVal; + + /** TTL. */ + private long ttl; + + /** Explicit TTL flag. */ + private boolean explicitTtl; + + /** Manual resolve flag. */ + private boolean manualResolve; + + /** + * Constructor. + * + * @param oldEntry Old entry. + * @param newEntry New entry. + */ + public GridCacheVersionConflictContext(GridCacheVersionedEntry oldEntry, + GridCacheVersionedEntry newEntry) { + assert oldEntry != null && newEntry != null; + assert oldEntry.ttl() >= 0 && newEntry.ttl() >= 0; + + this.oldEntry = oldEntry; + this.newEntry = newEntry; + + // Set initial state. + useNew(); + } + /** * Gets old (existing) cache entry. * * @return Old (existing) cache entry. */ - public GridCacheVersionedEntry oldEntry(); + public GridCacheVersionedEntry oldEntry() { + return oldEntry; + } /** * Gets new cache entry. * * @return New cache entry. */ - public GridCacheVersionedEntry newEntry(); + public GridCacheVersionedEntry newEntry() { + return newEntry; + } /** * Force cache to ignore new entry and leave old (existing) entry unchanged. */ - public void useOld(); + public void useOld() { + state = State.USE_OLD; + } /** * Force cache to apply new entry overwriting old (existing) entry. *

      * Note that updates from remote data centers always have explicit TTL , while local data center - * updates will only have explicit TTL in case {@link CacheEntry#timeToLive(long)} was called - * before update. In the latter case new entry will pick TTL of the old (existing) entry, even + * updates will only have explicit TTL in case {@link org.apache.ignite.cache.CacheEntry#timeToLive(long)} was + * called before update. In the latter case new entry will pick TTL of the old (existing) entry, even * if it was set through update from remote data center. it means that depending on concurrent * update timings new update might pick unexpected TTL. For example, consider that three updates * of the same key are performed: local update with explicit TTL (1) followed by another local @@ -58,7 +107,12 @@ public interface GridCacheVersionConflictContext { * update (3). To have predictable TTL in such cases you should either always set it explicitly * through {@code GridCacheEntry.timeToLive(long)} or use {@link #merge(Object, long)}. */ - public void useNew(); + public void useNew() { + state = State.USE_NEW; + + if (!explicitTtl) + ttl = newEntry.ttl(); + } /** * Force cache to use neither old, nor new, but some other value passed as argument. In this case old @@ -69,5 +123,97 @@ public interface GridCacheVersionConflictContext { * @param mergeVal Merge value or {@code null} to force remove. * @param ttl Time to live in milliseconds. */ - public void merge(@Nullable V mergeVal, long ttl); + public void merge(@Nullable V mergeVal, long ttl) { + state = State.MERGE; + + this.mergeVal = mergeVal; + this.ttl = ttl; + + explicitTtl = true; + } + + /** + * @return {@code True} in case old value should be used. + */ + public boolean isUseOld() { + return state == State.USE_OLD; + } + + /** + * @return {@code True} in case new value should be used. + */ + public boolean isUseNew() { + return state == State.USE_NEW; + } + + /** + * @return {@code True} in case merge is to be performed. + */ + public boolean isMerge() { + return state == State.MERGE; + } + + /** + * Set manual resolve class. + */ + public void manualResolve() { + this.manualResolve = true; + } + + /** + * @return Manual resolve flag. + */ + public boolean isManualResolve() { + return manualResolve; + } + + /** + * @return Value to merge (if any). + */ + @Nullable public V mergeValue() { + return mergeVal; + } + + /** + * @return TTL. + */ + public long ttl() { + return ttl; + } + + /** + * @return Expire time. + */ + public long expireTime() { + return explicitTtl ? CU.toExpireTime(ttl) : isUseNew() ? newEntry.expireTime() : + isUseOld() ? oldEntry.expireTime() : 0L; + } + + /** + * @return Explicit TTL flag. + */ + public boolean explicitTtl() { + return explicitTtl; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return state == State.MERGE ? + S.toString(GridCacheVersionConflictContext.class, this, "mergeValue", mergeVal) : + S.toString(GridCacheVersionConflictContext.class, this); + } + + /** + * State. + */ + private enum State { + /** Use old. */ + USE_OLD, + + /** Use new. */ + USE_NEW, + + /** Merge. */ + MERGE + } } diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionConflictContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionConflictContextImpl.java deleted file mode 100644 index ed901ecb49c98..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionConflictContextImpl.java +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.cache.version; - -import org.apache.ignite.internal.util.tostring.*; -import org.apache.ignite.internal.util.typedef.internal.*; -import org.jetbrains.annotations.*; - -/** - * Conflict context implementation. - */ -public class GridCacheVersionConflictContextImpl implements GridCacheVersionConflictContext { - /** Old entry. */ - @GridToStringInclude - private final GridCacheVersionedEntry oldEntry; - - /** New entry. */ - @GridToStringInclude - private final GridCacheVersionedEntry newEntry; - - /** Current state. */ - private State state; - - /** Current merge value. */ - @GridToStringExclude - private V mergeVal; - - /** TTL. */ - private long ttl; - - /** Explicit TTL flag. */ - private boolean explicitTtl; - - /** Manual resolve flag. */ - private boolean manualResolve; - - /** - * Constructor. - * - * @param oldEntry Old entry. - * @param newEntry New entry. - */ - public GridCacheVersionConflictContextImpl(GridCacheVersionedEntry oldEntry, - GridCacheVersionedEntry newEntry) { - assert oldEntry != null && newEntry != null; - assert oldEntry.ttl() >= 0 && newEntry.ttl() >= 0; - - this.oldEntry = oldEntry; - this.newEntry = newEntry; - - // Set initial state. - useNew(); - } - - /** {@inheritDoc} */ - @Override public GridCacheVersionedEntry oldEntry() { - return oldEntry; - } - - /** {@inheritDoc} */ - @Override public GridCacheVersionedEntry newEntry() { - return newEntry; - } - - /** {@inheritDoc} */ - @Override public void useOld() { - state = State.USE_OLD; - } - - /** {@inheritDoc} */ - @Override public void useNew() { - state = State.USE_NEW; - - if (!explicitTtl) - ttl = newEntry.ttl(); - } - - /** {@inheritDoc} */ - @Override public void merge(@Nullable V mergeVal, long ttl) { - state = State.MERGE; - - this.mergeVal = mergeVal; - this.ttl = ttl; - - explicitTtl = true; - } - - /** - * @return {@code True} in case old value should be used. - */ - public boolean isUseOld() { - return state == State.USE_OLD; - } - - /** - * @return {@code True} in case new value should be used. - */ - public boolean isUseNew() { - return state == State.USE_NEW; - } - - /** - * @return {@code True} in case merge is to be performed. - */ - public boolean isMerge() { - return state == State.MERGE; - } - - /** - * Set manual resolve class. - */ - public void manualResolve() { - this.manualResolve = true; - } - - /** - * @return Manual resolve flag. - */ - public boolean isManualResolve() { - return manualResolve; - } - - /** - * @return Value to merge (if any). - */ - @Nullable public V mergeValue() { - return mergeVal; - } - - /** - * @return TTL. - */ - public long ttl() { - return ttl; - } - - /** - * @return Expire time. - */ - public long expireTime() { - return explicitTtl ? CU.toExpireTime(ttl) : isUseNew() ? newEntry.expireTime() : - isUseOld() ? oldEntry.expireTime() : 0L; - } - - /** - * @return Explicit TTL flag. - */ - public boolean explicitTtl() { - return explicitTtl; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return state == State.MERGE ? - S.toString(GridCacheVersionConflictContextImpl.class, this, "mergeValue", mergeVal) : - S.toString(GridCacheVersionConflictContextImpl.class, this); - } - - /** - * State. - */ - private enum State { - /** Use old. */ - USE_OLD, - - /** Use new. */ - USE_NEW, - - /** Merge. */ - MERGE - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionConflictResolver.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionConflictResolver.java index e327fb9e6d4a6..869993cf84538 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionConflictResolver.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionConflictResolver.java @@ -25,7 +25,7 @@ */ public class GridCacheVersionConflictResolver extends GridCacheVersionAbstractConflictResolver { /** {@inheritDoc} */ - @Override protected void resolve0(GridCacheVersionConflictContextImpl ctx, + @Override protected void resolve0(GridCacheVersionConflictContext ctx, GridCacheVersionedEntryEx oldEntry, GridCacheVersionedEntryEx newEntry, boolean atomicVerComparator) throws IgniteCheckedException { if (newEntry.dataCenterId() != oldEntry.dataCenterId())