ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vkuliche...@apache.org
Subject [04/50] [abbrv] incubator-ignite git commit: ignite-nio - Removing message clone
Date Sun, 15 Feb 2015 08:41:46 GMT
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/947723c9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxRequest.java
----------------------------------------------------------------------
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 611eeda..7712ac3 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
@@ -112,11 +112,7 @@ public class GridCacheOptimisticCheckPreparedTxRequest<K, V> extends GridDistrib
     /** {@inheritDoc} */
     @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"})
     @Override public MessageAdapter clone() {
-        GridCacheOptimisticCheckPreparedTxRequest _clone = new GridCacheOptimisticCheckPreparedTxRequest();
-
-        clone0(_clone);
-
-        return _clone;
+        throw new UnsupportedOperationException();
     }
 
     /** {@inheritDoc} */
@@ -135,48 +131,51 @@ public class GridCacheOptimisticCheckPreparedTxRequest<K, V> extends GridDistrib
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean writeTo(ByteBuffer buf) {
+        MessageWriteState state = MessageWriteState.get();
+        MessageWriter writer = state.writer();
+
         writer.setBuffer(buf);
 
         if (!super.writeTo(buf))
             return false;
 
-        if (!typeWritten) {
+        if (!state.isTypeWritten()) {
             if (!writer.writeByte(null, directType()))
                 return false;
 
-            typeWritten = true;
+            state.setTypeWritten();
         }
 
-        switch (state) {
+        switch (state.index()) {
             case 8:
                 if (!writer.writeIgniteUuid("futId", futId))
                     return false;
 
-                state++;
+                state.increment();
 
             case 9:
                 if (!writer.writeIgniteUuid("miniId", miniId))
                     return false;
 
-                state++;
+                state.increment();
 
             case 10:
                 if (!writer.writeMessage("nearXidVer", nearXidVer))
                     return false;
 
-                state++;
+                state.increment();
 
             case 11:
                 if (!writer.writeBoolean("sys", sys))
                     return false;
 
-                state++;
+                state.increment();
 
             case 12:
                 if (!writer.writeInt("txNum", txNum))
                     return false;
 
-                state++;
+                state.increment();
 
         }
 
@@ -191,14 +190,14 @@ public class GridCacheOptimisticCheckPreparedTxRequest<K, V> extends GridDistrib
         if (!super.readFrom(buf))
             return false;
 
-        switch (state) {
+        switch (readState) {
             case 8:
                 futId = reader.readIgniteUuid("futId");
 
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 9:
                 miniId = reader.readIgniteUuid("miniId");
@@ -206,7 +205,7 @@ public class GridCacheOptimisticCheckPreparedTxRequest<K, V> extends GridDistrib
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 10:
                 nearXidVer = reader.readMessage("nearXidVer");
@@ -214,7 +213,7 @@ public class GridCacheOptimisticCheckPreparedTxRequest<K, V> extends GridDistrib
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 11:
                 sys = reader.readBoolean("sys");
@@ -222,7 +221,7 @@ public class GridCacheOptimisticCheckPreparedTxRequest<K, V> extends GridDistrib
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 12:
                 txNum = reader.readInt("txNum");
@@ -230,7 +229,7 @@ public class GridCacheOptimisticCheckPreparedTxRequest<K, V> extends GridDistrib
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/947723c9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxResponse.java
----------------------------------------------------------------------
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 7c9ae63..0aa4ac1 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
@@ -87,11 +87,7 @@ public class GridCacheOptimisticCheckPreparedTxResponse<K, V> extends GridDistri
     /** {@inheritDoc} */
     @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"})
     @Override public MessageAdapter clone() {
-        GridCacheOptimisticCheckPreparedTxResponse _clone = new GridCacheOptimisticCheckPreparedTxResponse();
-
-        clone0(_clone);
-
-        return _clone;
+        throw new UnsupportedOperationException();
     }
 
     /** {@inheritDoc} */
@@ -108,36 +104,39 @@ public class GridCacheOptimisticCheckPreparedTxResponse<K, V> extends GridDistri
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean writeTo(ByteBuffer buf) {
+        MessageWriteState state = MessageWriteState.get();
+        MessageWriter writer = state.writer();
+
         writer.setBuffer(buf);
 
         if (!super.writeTo(buf))
             return false;
 
-        if (!typeWritten) {
+        if (!state.isTypeWritten()) {
             if (!writer.writeByte(null, directType()))
                 return false;
 
-            typeWritten = true;
+            state.setTypeWritten();
         }
 
-        switch (state) {
+        switch (state.index()) {
             case 8:
                 if (!writer.writeIgniteUuid("futId", futId))
                     return false;
 
-                state++;
+                state.increment();
 
             case 9:
                 if (!writer.writeIgniteUuid("miniId", miniId))
                     return false;
 
-                state++;
+                state.increment();
 
             case 10:
                 if (!writer.writeBoolean("success", success))
                     return false;
 
-                state++;
+                state.increment();
 
         }
 
@@ -152,14 +151,14 @@ public class GridCacheOptimisticCheckPreparedTxResponse<K, V> extends GridDistri
         if (!super.readFrom(buf))
             return false;
 
-        switch (state) {
+        switch (readState) {
             case 8:
                 futId = reader.readIgniteUuid("futId");
 
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 9:
                 miniId = reader.readIgniteUuid("miniId");
@@ -167,7 +166,7 @@ public class GridCacheOptimisticCheckPreparedTxResponse<K, V> extends GridDistri
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 10:
                 success = reader.readBoolean("success");
@@ -175,7 +174,7 @@ public class GridCacheOptimisticCheckPreparedTxResponse<K, V> extends GridDistri
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/947723c9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxRequest.java
----------------------------------------------------------------------
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 21bbf17..86324a8 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
@@ -142,11 +142,7 @@ public class GridCachePessimisticCheckCommittedTxRequest<K, V> extends GridDistr
     /** {@inheritDoc} */
     @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"})
     @Override public MessageAdapter clone() {
-        GridCachePessimisticCheckCommittedTxRequest _clone = new GridCachePessimisticCheckCommittedTxRequest();
-
-        clone0(_clone);
-
-        return _clone;
+        throw new UnsupportedOperationException();
     }
 
     /** {@inheritDoc} */
@@ -167,60 +163,63 @@ public class GridCachePessimisticCheckCommittedTxRequest<K, V> extends GridDistr
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean writeTo(ByteBuffer buf) {
+        MessageWriteState state = MessageWriteState.get();
+        MessageWriter writer = state.writer();
+
         writer.setBuffer(buf);
 
         if (!super.writeTo(buf))
             return false;
 
-        if (!typeWritten) {
+        if (!state.isTypeWritten()) {
             if (!writer.writeByte(null, directType()))
                 return false;
 
-            typeWritten = true;
+            state.setTypeWritten();
         }
 
-        switch (state) {
+        switch (state.index()) {
             case 8:
                 if (!writer.writeIgniteUuid("futId", futId))
                     return false;
 
-                state++;
+                state.increment();
 
             case 9:
                 if (!writer.writeIgniteUuid("miniId", miniId))
                     return false;
 
-                state++;
+                state.increment();
 
             case 10:
                 if (!writer.writeBoolean("nearOnlyCheck", nearOnlyCheck))
                     return false;
 
-                state++;
+                state.increment();
 
             case 11:
                 if (!writer.writeMessage("nearXidVer", nearXidVer))
                     return false;
 
-                state++;
+                state.increment();
 
             case 12:
                 if (!writer.writeUuid("originatingNodeId", originatingNodeId))
                     return false;
 
-                state++;
+                state.increment();
 
             case 13:
                 if (!writer.writeLong("originatingThreadId", originatingThreadId))
                     return false;
 
-                state++;
+                state.increment();
 
             case 14:
                 if (!writer.writeBoolean("sys", sys))
                     return false;
 
-                state++;
+                state.increment();
 
         }
 
@@ -235,14 +234,14 @@ public class GridCachePessimisticCheckCommittedTxRequest<K, V> extends GridDistr
         if (!super.readFrom(buf))
             return false;
 
-        switch (state) {
+        switch (readState) {
             case 8:
                 futId = reader.readIgniteUuid("futId");
 
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 9:
                 miniId = reader.readIgniteUuid("miniId");
@@ -250,7 +249,7 @@ public class GridCachePessimisticCheckCommittedTxRequest<K, V> extends GridDistr
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 10:
                 nearOnlyCheck = reader.readBoolean("nearOnlyCheck");
@@ -258,7 +257,7 @@ public class GridCachePessimisticCheckCommittedTxRequest<K, V> extends GridDistr
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 11:
                 nearXidVer = reader.readMessage("nearXidVer");
@@ -266,7 +265,7 @@ public class GridCachePessimisticCheckCommittedTxRequest<K, V> extends GridDistr
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 12:
                 originatingNodeId = reader.readUuid("originatingNodeId");
@@ -274,7 +273,7 @@ public class GridCachePessimisticCheckCommittedTxRequest<K, V> extends GridDistr
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 13:
                 originatingThreadId = reader.readLong("originatingThreadId");
@@ -282,7 +281,7 @@ public class GridCachePessimisticCheckCommittedTxRequest<K, V> extends GridDistr
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 14:
                 sys = reader.readBoolean("sys");
@@ -290,7 +289,7 @@ public class GridCachePessimisticCheckCommittedTxRequest<K, V> extends GridDistr
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/947723c9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePessimisticCheckCommittedTxResponse.java
----------------------------------------------------------------------
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 922555e..cdb73b9 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
@@ -130,11 +130,7 @@ public class GridCachePessimisticCheckCommittedTxResponse<K, V> extends GridDist
     /** {@inheritDoc} */
     @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"})
     @Override public MessageAdapter clone() {
-        GridCachePessimisticCheckCommittedTxResponse _clone = new GridCachePessimisticCheckCommittedTxResponse();
-
-        clone0(_clone);
-
-        return _clone;
+        throw new UnsupportedOperationException();
     }
 
     /** {@inheritDoc} */
@@ -153,42 +149,45 @@ public class GridCachePessimisticCheckCommittedTxResponse<K, V> extends GridDist
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean writeTo(ByteBuffer buf) {
+        MessageWriteState state = MessageWriteState.get();
+        MessageWriter writer = state.writer();
+
         writer.setBuffer(buf);
 
         if (!super.writeTo(buf))
             return false;
 
-        if (!typeWritten) {
+        if (!state.isTypeWritten()) {
             if (!writer.writeByte(null, directType()))
                 return false;
 
-            typeWritten = true;
+            state.setTypeWritten();
         }
 
-        switch (state) {
+        switch (state.index()) {
             case 8:
                 if (!writer.writeByteArray("committedTxInfoBytes", committedTxInfoBytes))
                     return false;
 
-                state++;
+                state.increment();
 
             case 9:
                 if (!writer.writeIgniteUuid("futId", futId))
                     return false;
 
-                state++;
+                state.increment();
 
             case 10:
                 if (!writer.writeIgniteUuid("miniId", miniId))
                     return false;
 
-                state++;
+                state.increment();
 
             case 11:
                 if (!writer.writeBoolean("sys", sys))
                     return false;
 
-                state++;
+                state.increment();
 
         }
 
@@ -203,14 +202,14 @@ public class GridCachePessimisticCheckCommittedTxResponse<K, V> extends GridDist
         if (!super.readFrom(buf))
             return false;
 
-        switch (state) {
+        switch (readState) {
             case 8:
                 committedTxInfoBytes = reader.readByteArray("committedTxInfoBytes");
 
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 9:
                 futId = reader.readIgniteUuid("futId");
@@ -218,7 +217,7 @@ public class GridCachePessimisticCheckCommittedTxResponse<K, V> extends GridDist
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 10:
                 miniId = reader.readIgniteUuid("miniId");
@@ -226,7 +225,7 @@ public class GridCachePessimisticCheckCommittedTxResponse<K, V> extends GridDist
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 11:
                 sys = reader.readBoolean("sys");
@@ -234,7 +233,7 @@ public class GridCachePessimisticCheckCommittedTxResponse<K, V> extends GridDist
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/947723c9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTtlUpdateRequest.java
----------------------------------------------------------------------
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 a36ceab..cea818c 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
@@ -189,63 +189,62 @@ public class GridCacheTtlUpdateRequest<K, V> extends GridCacheMessage<K, V> {
     /** {@inheritDoc} */
     @SuppressWarnings("CloneDoesntCallSuperClone")
     @Override public MessageAdapter clone() {
-        GridCacheTtlUpdateRequest _clone = new GridCacheTtlUpdateRequest();
-
-        clone0(_clone);
-
-        return _clone;
+        throw new UnsupportedOperationException();
     }
 
     /** {@inheritDoc} */
     @Override public boolean writeTo(ByteBuffer buf) {
+        MessageWriteState state = MessageWriteState.get();
+        MessageWriter writer = state.writer();
+
         writer.setBuffer(buf);
 
         if (!super.writeTo(buf))
             return false;
 
-        if (!typeWritten) {
+        if (!state.isTypeWritten()) {
             if (!writer.writeByte(null, directType()))
                 return false;
 
-            typeWritten = true;
+            state.setTypeWritten();
         }
 
-        switch (state) {
+        switch (state.index()) {
             case 3:
                 if (!writer.writeCollection("keysBytes", keysBytes, byte[].class))
                     return false;
 
-                state++;
+                state.increment();
 
             case 4:
                 if (!writer.writeCollection("nearKeysBytes", nearKeysBytes, byte[].class))
                     return false;
 
-                state++;
+                state.increment();
 
             case 5:
                 if (!writer.writeCollection("nearVers", nearVers, GridCacheVersion.class))
                     return false;
 
-                state++;
+                state.increment();
 
             case 6:
                 if (!writer.writeLong("topVer", topVer))
                     return false;
 
-                state++;
+                state.increment();
 
             case 7:
                 if (!writer.writeLong("ttl", ttl))
                     return false;
 
-                state++;
+                state.increment();
 
             case 8:
                 if (!writer.writeCollection("vers", vers, GridCacheVersion.class))
                     return false;
 
-                state++;
+                state.increment();
 
         }
 
@@ -259,14 +258,14 @@ public class GridCacheTtlUpdateRequest<K, V> extends GridCacheMessage<K, V> {
         if (!super.readFrom(buf))
             return false;
 
-        switch (state) {
+        switch (readState) {
             case 3:
                 keysBytes = reader.readCollection("keysBytes", byte[].class);
 
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 4:
                 nearKeysBytes = reader.readCollection("nearKeysBytes", byte[].class);
@@ -274,7 +273,7 @@ public class GridCacheTtlUpdateRequest<K, V> extends GridCacheMessage<K, V> {
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 5:
                 nearVers = reader.readCollection("nearVers", GridCacheVersion.class);
@@ -282,7 +281,7 @@ public class GridCacheTtlUpdateRequest<K, V> extends GridCacheMessage<K, V> {
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 6:
                 topVer = reader.readLong("topVer");
@@ -290,7 +289,7 @@ public class GridCacheTtlUpdateRequest<K, V> extends GridCacheMessage<K, V> {
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 7:
                 ttl = reader.readLong("ttl");
@@ -298,7 +297,7 @@ public class GridCacheTtlUpdateRequest<K, V> extends GridCacheMessage<K, V> {
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 8:
                 vers = reader.readCollection("vers", GridCacheVersion.class);
@@ -306,7 +305,7 @@ public class GridCacheTtlUpdateRequest<K, V> extends GridCacheMessage<K, V> {
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/947723c9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedBaseMessage.java
----------------------------------------------------------------------
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 4c7b959..725df25 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,48 +258,51 @@ public abstract class GridDistributedBaseMessage<K, V> extends GridCacheMessage<
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean writeTo(ByteBuffer buf) {
+        MessageWriteState state = MessageWriteState.get();
+        MessageWriter writer = state.writer();
+
         writer.setBuffer(buf);
 
         if (!super.writeTo(buf))
             return false;
 
-        if (!typeWritten) {
+        if (!state.isTypeWritten()) {
             if (!writer.writeByte(null, directType()))
                 return false;
 
-            typeWritten = true;
+            state.setTypeWritten();
         }
 
-        switch (state) {
+        switch (state.index()) {
             case 3:
                 if (!writer.writeByteArray("candsByIdxBytes", candsByIdxBytes))
                     return false;
 
-                state++;
+                state.increment();
 
             case 4:
                 if (!writer.writeByteArray("candsByKeyBytes", candsByKeyBytes))
                     return false;
 
-                state++;
+                state.increment();
 
             case 5:
                 if (!writer.writeCollection("committedVers", committedVers, GridCacheVersion.class))
                     return false;
 
-                state++;
+                state.increment();
 
             case 6:
                 if (!writer.writeCollection("rolledbackVers", rolledbackVers, GridCacheVersion.class))
                     return false;
 
-                state++;
+                state.increment();
 
             case 7:
                 if (!writer.writeMessage("ver", ver))
                     return false;
 
-                state++;
+                state.increment();
 
         }
 
@@ -314,14 +317,14 @@ public abstract class GridDistributedBaseMessage<K, V> extends GridCacheMessage<
         if (!super.readFrom(buf))
             return false;
 
-        switch (state) {
+        switch (readState) {
             case 3:
                 candsByIdxBytes = reader.readByteArray("candsByIdxBytes");
 
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 4:
                 candsByKeyBytes = reader.readByteArray("candsByKeyBytes");
@@ -329,7 +332,7 @@ public abstract class GridDistributedBaseMessage<K, V> extends GridCacheMessage<
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 5:
                 committedVers = reader.readCollection("committedVers", GridCacheVersion.class);
@@ -337,7 +340,7 @@ public abstract class GridDistributedBaseMessage<K, V> extends GridCacheMessage<
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 6:
                 rolledbackVers = reader.readCollection("rolledbackVers", GridCacheVersion.class);
@@ -345,7 +348,7 @@ public abstract class GridDistributedBaseMessage<K, V> extends GridCacheMessage<
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 7:
                 ver = reader.readMessage("ver");
@@ -353,7 +356,7 @@ public abstract class GridDistributedBaseMessage<K, V> extends GridCacheMessage<
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/947723c9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java
----------------------------------------------------------------------
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 1f77a01..88b34c8 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
@@ -429,11 +429,7 @@ public class GridDistributedLockRequest<K, V> extends GridDistributedBaseMessage
     @SuppressWarnings({"CloneCallsConstructors", "OverriddenMethodCallDuringObjectConstruction",
         "CloneDoesntCallSuperClone"})
     @Override public MessageAdapter clone() {
-        GridDistributedLockRequest _clone = new GridDistributedLockRequest();
-
-        clone0(_clone);
-
-        return _clone;
+        throw new UnsupportedOperationException();
     }
 
     /** {@inheritDoc} */
@@ -467,114 +463,117 @@ public class GridDistributedLockRequest<K, V> extends GridDistributedBaseMessage
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean writeTo(ByteBuffer buf) {
+        MessageWriteState state = MessageWriteState.get();
+        MessageWriter writer = state.writer();
+
         writer.setBuffer(buf);
 
         if (!super.writeTo(buf))
             return false;
 
-        if (!typeWritten) {
+        if (!state.isTypeWritten()) {
             if (!writer.writeByte(null, directType()))
                 return false;
 
-            typeWritten = true;
+            state.setTypeWritten();
         }
 
-        switch (state) {
+        switch (state.index()) {
             case 8:
                 if (!writer.writeObjectArray("drVersByIdx", drVersByIdx, GridCacheVersion.class))
                     return false;
 
-                state++;
+                state.increment();
 
             case 9:
                 if (!writer.writeIgniteUuid("futId", futId))
                     return false;
 
-                state++;
+                state.increment();
 
             case 10:
                 if (!writer.writeByteArray("grpLockKeyBytes", grpLockKeyBytes))
                     return false;
 
-                state++;
+                state.increment();
 
             case 11:
                 if (!writer.writeBoolean("isInTx", isInTx))
                     return false;
 
-                state++;
+                state.increment();
 
             case 12:
                 if (!writer.writeBoolean("isInvalidate", isInvalidate))
                     return false;
 
-                state++;
+                state.increment();
 
             case 13:
                 if (!writer.writeBoolean("isRead", isRead))
                     return false;
 
-                state++;
+                state.increment();
 
             case 14:
                 if (!writer.writeEnum("isolation", isolation))
                     return false;
 
-                state++;
+                state.increment();
 
             case 15:
                 if (!writer.writeCollection("keyBytes", keyBytes, byte[].class))
                     return false;
 
-                state++;
+                state.increment();
 
             case 16:
                 if (!writer.writeMessage("nearXidVer", nearXidVer))
                     return false;
 
-                state++;
+                state.increment();
 
             case 17:
                 if (!writer.writeUuid("nodeId", nodeId))
                     return false;
 
-                state++;
+                state.increment();
 
             case 18:
                 if (!writer.writeBoolean("partLock", partLock))
                     return false;
 
-                state++;
+                state.increment();
 
             case 19:
                 if (!writer.writeBooleanArray("retVals", retVals))
                     return false;
 
-                state++;
+                state.increment();
 
             case 20:
                 if (!writer.writeLong("threadId", threadId))
                     return false;
 
-                state++;
+                state.increment();
 
             case 21:
                 if (!writer.writeLong("timeout", timeout))
                     return false;
 
-                state++;
+                state.increment();
 
             case 22:
                 if (!writer.writeInt("txSize", txSize))
                     return false;
 
-                state++;
+                state.increment();
 
             case 23:
                 if (!writer.writeByteArray("writeEntriesBytes", writeEntriesBytes))
                     return false;
 
-                state++;
+                state.increment();
 
         }
 
@@ -589,14 +588,14 @@ public class GridDistributedLockRequest<K, V> extends GridDistributedBaseMessage
         if (!super.readFrom(buf))
             return false;
 
-        switch (state) {
+        switch (readState) {
             case 8:
                 drVersByIdx = reader.readObjectArray("drVersByIdx", GridCacheVersion.class);
 
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 9:
                 futId = reader.readIgniteUuid("futId");
@@ -604,7 +603,7 @@ public class GridDistributedLockRequest<K, V> extends GridDistributedBaseMessage
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 10:
                 grpLockKeyBytes = reader.readByteArray("grpLockKeyBytes");
@@ -612,7 +611,7 @@ public class GridDistributedLockRequest<K, V> extends GridDistributedBaseMessage
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 11:
                 isInTx = reader.readBoolean("isInTx");
@@ -620,7 +619,7 @@ public class GridDistributedLockRequest<K, V> extends GridDistributedBaseMessage
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 12:
                 isInvalidate = reader.readBoolean("isInvalidate");
@@ -628,7 +627,7 @@ public class GridDistributedLockRequest<K, V> extends GridDistributedBaseMessage
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 13:
                 isRead = reader.readBoolean("isRead");
@@ -636,7 +635,7 @@ public class GridDistributedLockRequest<K, V> extends GridDistributedBaseMessage
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 14:
                 isolation = reader.readEnum("isolation", IgniteTxIsolation.class);
@@ -644,7 +643,7 @@ public class GridDistributedLockRequest<K, V> extends GridDistributedBaseMessage
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 15:
                 keyBytes = reader.readCollection("keyBytes", byte[].class);
@@ -652,7 +651,7 @@ public class GridDistributedLockRequest<K, V> extends GridDistributedBaseMessage
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 16:
                 nearXidVer = reader.readMessage("nearXidVer");
@@ -660,7 +659,7 @@ public class GridDistributedLockRequest<K, V> extends GridDistributedBaseMessage
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 17:
                 nodeId = reader.readUuid("nodeId");
@@ -668,7 +667,7 @@ public class GridDistributedLockRequest<K, V> extends GridDistributedBaseMessage
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 18:
                 partLock = reader.readBoolean("partLock");
@@ -676,7 +675,7 @@ public class GridDistributedLockRequest<K, V> extends GridDistributedBaseMessage
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 19:
                 retVals = reader.readBooleanArray("retVals");
@@ -684,7 +683,7 @@ public class GridDistributedLockRequest<K, V> extends GridDistributedBaseMessage
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 20:
                 threadId = reader.readLong("threadId");
@@ -692,7 +691,7 @@ public class GridDistributedLockRequest<K, V> extends GridDistributedBaseMessage
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 21:
                 timeout = reader.readLong("timeout");
@@ -700,7 +699,7 @@ public class GridDistributedLockRequest<K, V> extends GridDistributedBaseMessage
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 22:
                 txSize = reader.readInt("txSize");
@@ -708,7 +707,7 @@ public class GridDistributedLockRequest<K, V> extends GridDistributedBaseMessage
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 23:
                 writeEntriesBytes = reader.readByteArray("writeEntriesBytes");
@@ -716,7 +715,7 @@ public class GridDistributedLockRequest<K, V> extends GridDistributedBaseMessage
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/947723c9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java
----------------------------------------------------------------------
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 ae7ac0e..762a73a 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
@@ -280,11 +280,7 @@ public class GridDistributedLockResponse<K, V> extends GridDistributedBaseMessag
     @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors",
         "OverriddenMethodCallDuringObjectConstruction"})
     @Override public MessageAdapter clone() {
-        GridDistributedLockResponse _clone = new GridDistributedLockResponse();
-
-        clone0(_clone);
-
-        return _clone;
+        throw new UnsupportedOperationException();
     }
 
     /** {@inheritDoc} */
@@ -303,36 +299,39 @@ public class GridDistributedLockResponse<K, V> extends GridDistributedBaseMessag
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean writeTo(ByteBuffer buf) {
+        MessageWriteState state = MessageWriteState.get();
+        MessageWriter writer = state.writer();
+
         writer.setBuffer(buf);
 
         if (!super.writeTo(buf))
             return false;
 
-        if (!typeWritten) {
+        if (!state.isTypeWritten()) {
             if (!writer.writeByte(null, directType()))
                 return false;
 
-            typeWritten = true;
+            state.setTypeWritten();
         }
 
-        switch (state) {
+        switch (state.index()) {
             case 8:
                 if (!writer.writeByteArray("errBytes", errBytes))
                     return false;
 
-                state++;
+                state.increment();
 
             case 9:
                 if (!writer.writeIgniteUuid("futId", futId))
                     return false;
 
-                state++;
+                state.increment();
 
             case 10:
                 if (!writer.writeCollection("valBytes", valBytes, GridCacheValueBytes.class))
                     return false;
 
-                state++;
+                state.increment();
 
         }
 
@@ -347,14 +346,14 @@ public class GridDistributedLockResponse<K, V> extends GridDistributedBaseMessag
         if (!super.readFrom(buf))
             return false;
 
-        switch (state) {
+        switch (readState) {
             case 8:
                 errBytes = reader.readByteArray("errBytes");
 
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 9:
                 futId = reader.readIgniteUuid("futId");
@@ -362,7 +361,7 @@ public class GridDistributedLockResponse<K, V> extends GridDistributedBaseMessag
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 10:
                 valBytes = reader.readCollection("valBytes", GridCacheValueBytes.class);
@@ -370,7 +369,7 @@ public class GridDistributedLockResponse<K, V> extends GridDistributedBaseMessag
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/947723c9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishRequest.java
----------------------------------------------------------------------
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 d8cc296..77aa1af 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
@@ -347,11 +347,7 @@ public class GridDistributedTxFinishRequest<K, V> extends GridDistributedBaseMes
     @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors",
         "OverriddenMethodCallDuringObjectConstruction"})
     @Override public MessageAdapter clone() {
-        GridDistributedTxFinishRequest _clone = new GridDistributedTxFinishRequest();
-
-        clone0(_clone);
-
-        return _clone;
+        throw new UnsupportedOperationException();
     }
 
     /** {@inheritDoc} */
@@ -381,96 +377,99 @@ public class GridDistributedTxFinishRequest<K, V> extends GridDistributedBaseMes
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean writeTo(ByteBuffer buf) {
+        MessageWriteState state = MessageWriteState.get();
+        MessageWriter writer = state.writer();
+
         writer.setBuffer(buf);
 
         if (!super.writeTo(buf))
             return false;
 
-        if (!typeWritten) {
+        if (!state.isTypeWritten()) {
             if (!writer.writeByte(null, directType()))
                 return false;
 
-            typeWritten = true;
+            state.setTypeWritten();
         }
 
-        switch (state) {
+        switch (state.index()) {
             case 8:
                 if (!writer.writeMessage("baseVer", baseVer))
                     return false;
 
-                state++;
+                state.increment();
 
             case 9:
                 if (!writer.writeBoolean("commit", commit))
                     return false;
 
-                state++;
+                state.increment();
 
             case 10:
                 if (!writer.writeMessage("commitVer", commitVer))
                     return false;
 
-                state++;
+                state.increment();
 
             case 11:
                 if (!writer.writeIgniteUuid("futId", futId))
                     return false;
 
-                state++;
+                state.increment();
 
             case 12:
                 if (!writer.writeByteArray("grpLockKeyBytes", grpLockKeyBytes))
                     return false;
 
-                state++;
+                state.increment();
 
             case 13:
                 if (!writer.writeBoolean("invalidate", invalidate))
                     return false;
 
-                state++;
+                state.increment();
 
             case 14:
                 if (!writer.writeCollection("recoveryWritesBytes", recoveryWritesBytes, byte[].class))
                     return false;
 
-                state++;
+                state.increment();
 
             case 15:
                 if (!writer.writeBoolean("syncCommit", syncCommit))
                     return false;
 
-                state++;
+                state.increment();
 
             case 16:
                 if (!writer.writeBoolean("syncRollback", syncRollback))
                     return false;
 
-                state++;
+                state.increment();
 
             case 17:
                 if (!writer.writeBoolean("sys", sys))
                     return false;
 
-                state++;
+                state.increment();
 
             case 18:
                 if (!writer.writeLong("threadId", threadId))
                     return false;
 
-                state++;
+                state.increment();
 
             case 19:
                 if (!writer.writeInt("txSize", txSize))
                     return false;
 
-                state++;
+                state.increment();
 
             case 20:
                 if (!writer.writeCollection("writeEntriesBytes", writeEntriesBytes, byte[].class))
                     return false;
 
-                state++;
+                state.increment();
 
         }
 
@@ -485,14 +484,14 @@ public class GridDistributedTxFinishRequest<K, V> extends GridDistributedBaseMes
         if (!super.readFrom(buf))
             return false;
 
-        switch (state) {
+        switch (readState) {
             case 8:
                 baseVer = reader.readMessage("baseVer");
 
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 9:
                 commit = reader.readBoolean("commit");
@@ -500,7 +499,7 @@ public class GridDistributedTxFinishRequest<K, V> extends GridDistributedBaseMes
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 10:
                 commitVer = reader.readMessage("commitVer");
@@ -508,7 +507,7 @@ public class GridDistributedTxFinishRequest<K, V> extends GridDistributedBaseMes
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 11:
                 futId = reader.readIgniteUuid("futId");
@@ -516,7 +515,7 @@ public class GridDistributedTxFinishRequest<K, V> extends GridDistributedBaseMes
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 12:
                 grpLockKeyBytes = reader.readByteArray("grpLockKeyBytes");
@@ -524,7 +523,7 @@ public class GridDistributedTxFinishRequest<K, V> extends GridDistributedBaseMes
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 13:
                 invalidate = reader.readBoolean("invalidate");
@@ -532,7 +531,7 @@ public class GridDistributedTxFinishRequest<K, V> extends GridDistributedBaseMes
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 14:
                 recoveryWritesBytes = reader.readCollection("recoveryWritesBytes", byte[].class);
@@ -540,7 +539,7 @@ public class GridDistributedTxFinishRequest<K, V> extends GridDistributedBaseMes
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 15:
                 syncCommit = reader.readBoolean("syncCommit");
@@ -548,7 +547,7 @@ public class GridDistributedTxFinishRequest<K, V> extends GridDistributedBaseMes
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 16:
                 syncRollback = reader.readBoolean("syncRollback");
@@ -556,7 +555,7 @@ public class GridDistributedTxFinishRequest<K, V> extends GridDistributedBaseMes
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 17:
                 sys = reader.readBoolean("sys");
@@ -564,7 +563,7 @@ public class GridDistributedTxFinishRequest<K, V> extends GridDistributedBaseMes
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 18:
                 threadId = reader.readLong("threadId");
@@ -572,7 +571,7 @@ public class GridDistributedTxFinishRequest<K, V> extends GridDistributedBaseMes
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 19:
                 txSize = reader.readInt("txSize");
@@ -580,7 +579,7 @@ public class GridDistributedTxFinishRequest<K, V> extends GridDistributedBaseMes
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 20:
                 writeEntriesBytes = reader.readCollection("writeEntriesBytes", byte[].class);
@@ -588,7 +587,7 @@ public class GridDistributedTxFinishRequest<K, V> extends GridDistributedBaseMes
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/947723c9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishResponse.java
----------------------------------------------------------------------
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 e31c24f..3e2313e 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
@@ -77,11 +77,7 @@ public class GridDistributedTxFinishResponse<K, V> extends GridCacheMessage<K, V
     @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors",
         "OverriddenMethodCallDuringObjectConstruction"})
     @Override public MessageAdapter clone() {
-        GridDistributedTxFinishResponse _clone = new GridDistributedTxFinishResponse();
-
-        clone0(_clone);
-
-        return _clone;
+        throw new UnsupportedOperationException();
     }
 
     /** {@inheritDoc} */
@@ -97,30 +93,33 @@ public class GridDistributedTxFinishResponse<K, V> extends GridCacheMessage<K, V
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean writeTo(ByteBuffer buf) {
+        MessageWriteState state = MessageWriteState.get();
+        MessageWriter writer = state.writer();
+
         writer.setBuffer(buf);
 
         if (!super.writeTo(buf))
             return false;
 
-        if (!typeWritten) {
+        if (!state.isTypeWritten()) {
             if (!writer.writeByte(null, directType()))
                 return false;
 
-            typeWritten = true;
+            state.setTypeWritten();
         }
 
-        switch (state) {
+        switch (state.index()) {
             case 3:
                 if (!writer.writeIgniteUuid("futId", futId))
                     return false;
 
-                state++;
+                state.increment();
 
             case 4:
                 if (!writer.writeMessage("txId", txId))
                     return false;
 
-                state++;
+                state.increment();
 
         }
 
@@ -135,14 +134,14 @@ public class GridDistributedTxFinishResponse<K, V> extends GridCacheMessage<K, V
         if (!super.readFrom(buf))
             return false;
 
-        switch (state) {
+        switch (readState) {
             case 3:
                 futId = reader.readIgniteUuid("futId");
 
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 4:
                 txId = reader.readMessage("txId");
@@ -150,7 +149,7 @@ public class GridDistributedTxFinishResponse<K, V> extends GridCacheMessage<K, V
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/947723c9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
----------------------------------------------------------------------
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 54d7757..6af8916 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
@@ -405,11 +405,7 @@ public class GridDistributedTxPrepareRequest<K, V> extends GridDistributedBaseMe
     @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors",
         "OverriddenMethodCallDuringObjectConstruction"})
     @Override public MessageAdapter clone() {
-        GridDistributedTxPrepareRequest _clone = new GridDistributedTxPrepareRequest();
-
-        clone0(_clone);
-
-        return _clone;
+        throw new UnsupportedOperationException();
     }
 
     /** {@inheritDoc} */
@@ -442,102 +438,105 @@ public class GridDistributedTxPrepareRequest<K, V> extends GridDistributedBaseMe
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean writeTo(ByteBuffer buf) {
+        MessageWriteState state = MessageWriteState.get();
+        MessageWriter writer = state.writer();
+
         writer.setBuffer(buf);
 
         if (!super.writeTo(buf))
             return false;
 
-        if (!typeWritten) {
+        if (!state.isTypeWritten()) {
             if (!writer.writeByte(null, directType()))
                 return false;
 
-            typeWritten = true;
+            state.setTypeWritten();
         }
 
-        switch (state) {
+        switch (state.index()) {
             case 8:
                 if (!writer.writeMessage("commitVer", commitVer))
                     return false;
 
-                state++;
+                state.increment();
 
             case 9:
                 if (!writer.writeEnum("concurrency", concurrency))
                     return false;
 
-                state++;
+                state.increment();
 
             case 10:
                 if (!writer.writeByteArray("dhtVersBytes", dhtVersBytes))
                     return false;
 
-                state++;
+                state.increment();
 
             case 11:
                 if (!writer.writeByteArray("grpLockKeyBytes", grpLockKeyBytes))
                     return false;
 
-                state++;
+                state.increment();
 
             case 12:
                 if (!writer.writeBoolean("invalidate", invalidate))
                     return false;
 
-                state++;
+                state.increment();
 
             case 13:
                 if (!writer.writeEnum("isolation", isolation))
                     return false;
 
-                state++;
+                state.increment();
 
             case 14:
                 if (!writer.writeBoolean("partLock", partLock))
                     return false;
 
-                state++;
+                state.increment();
 
             case 15:
                 if (!writer.writeCollection("readsBytes", readsBytes, byte[].class))
                     return false;
 
-                state++;
+                state.increment();
 
             case 16:
                 if (!writer.writeBoolean("sys", sys))
                     return false;
 
-                state++;
+                state.increment();
 
             case 17:
                 if (!writer.writeLong("threadId", threadId))
                     return false;
 
-                state++;
+                state.increment();
 
             case 18:
                 if (!writer.writeLong("timeout", timeout))
                     return false;
 
-                state++;
+                state.increment();
 
             case 19:
                 if (!writer.writeByteArray("txNodesBytes", txNodesBytes))
                     return false;
 
-                state++;
+                state.increment();
 
             case 20:
                 if (!writer.writeInt("txSize", txSize))
                     return false;
 
-                state++;
+                state.increment();
 
             case 21:
                 if (!writer.writeCollection("writesBytes", writesBytes, byte[].class))
                     return false;
 
-                state++;
+                state.increment();
 
         }
 
@@ -552,14 +551,14 @@ public class GridDistributedTxPrepareRequest<K, V> extends GridDistributedBaseMe
         if (!super.readFrom(buf))
             return false;
 
-        switch (state) {
+        switch (readState) {
             case 8:
                 commitVer = reader.readMessage("commitVer");
 
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 9:
                 concurrency = reader.readEnum("concurrency", IgniteTxConcurrency.class);
@@ -567,7 +566,7 @@ public class GridDistributedTxPrepareRequest<K, V> extends GridDistributedBaseMe
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 10:
                 dhtVersBytes = reader.readByteArray("dhtVersBytes");
@@ -575,7 +574,7 @@ public class GridDistributedTxPrepareRequest<K, V> extends GridDistributedBaseMe
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 11:
                 grpLockKeyBytes = reader.readByteArray("grpLockKeyBytes");
@@ -583,7 +582,7 @@ public class GridDistributedTxPrepareRequest<K, V> extends GridDistributedBaseMe
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 12:
                 invalidate = reader.readBoolean("invalidate");
@@ -591,7 +590,7 @@ public class GridDistributedTxPrepareRequest<K, V> extends GridDistributedBaseMe
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 13:
                 isolation = reader.readEnum("isolation", IgniteTxIsolation.class);
@@ -599,7 +598,7 @@ public class GridDistributedTxPrepareRequest<K, V> extends GridDistributedBaseMe
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 14:
                 partLock = reader.readBoolean("partLock");
@@ -607,7 +606,7 @@ public class GridDistributedTxPrepareRequest<K, V> extends GridDistributedBaseMe
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 15:
                 readsBytes = reader.readCollection("readsBytes", byte[].class);
@@ -615,7 +614,7 @@ public class GridDistributedTxPrepareRequest<K, V> extends GridDistributedBaseMe
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 16:
                 sys = reader.readBoolean("sys");
@@ -623,7 +622,7 @@ public class GridDistributedTxPrepareRequest<K, V> extends GridDistributedBaseMe
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 17:
                 threadId = reader.readLong("threadId");
@@ -631,7 +630,7 @@ public class GridDistributedTxPrepareRequest<K, V> extends GridDistributedBaseMe
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 18:
                 timeout = reader.readLong("timeout");
@@ -639,7 +638,7 @@ public class GridDistributedTxPrepareRequest<K, V> extends GridDistributedBaseMe
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 19:
                 txNodesBytes = reader.readByteArray("txNodesBytes");
@@ -647,7 +646,7 @@ public class GridDistributedTxPrepareRequest<K, V> extends GridDistributedBaseMe
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 20:
                 txSize = reader.readInt("txSize");
@@ -655,7 +654,7 @@ public class GridDistributedTxPrepareRequest<K, V> extends GridDistributedBaseMe
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 21:
                 writesBytes = reader.readCollection("writesBytes", byte[].class);
@@ -663,7 +662,7 @@ public class GridDistributedTxPrepareRequest<K, V> extends GridDistributedBaseMe
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/947723c9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareResponse.java
----------------------------------------------------------------------
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 cd47513..5355f97 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
@@ -152,11 +152,7 @@ public class GridDistributedTxPrepareResponse<K, V> extends GridDistributedBaseM
     @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors",
         "OverriddenMethodCallDuringObjectConstruction"})
     @Override public MessageAdapter clone() {
-        GridDistributedTxPrepareResponse _clone = new GridDistributedTxPrepareResponse();
-
-        clone0(_clone);
-
-        return _clone;
+        throw new UnsupportedOperationException();
     }
 
     /** {@inheritDoc} */
@@ -174,30 +170,33 @@ public class GridDistributedTxPrepareResponse<K, V> extends GridDistributedBaseM
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean writeTo(ByteBuffer buf) {
+        MessageWriteState state = MessageWriteState.get();
+        MessageWriter writer = state.writer();
+
         writer.setBuffer(buf);
 
         if (!super.writeTo(buf))
             return false;
 
-        if (!typeWritten) {
+        if (!state.isTypeWritten()) {
             if (!writer.writeByte(null, directType()))
                 return false;
 
-            typeWritten = true;
+            state.setTypeWritten();
         }
 
-        switch (state) {
+        switch (state.index()) {
             case 8:
                 if (!writer.writeByteArray("candsBytes", candsBytes))
                     return false;
 
-                state++;
+                state.increment();
 
             case 9:
                 if (!writer.writeByteArray("errBytes", errBytes))
                     return false;
 
-                state++;
+                state.increment();
 
         }
 
@@ -212,14 +211,14 @@ public class GridDistributedTxPrepareResponse<K, V> extends GridDistributedBaseM
         if (!super.readFrom(buf))
             return false;
 
-        switch (state) {
+        switch (readState) {
             case 8:
                 candsBytes = reader.readByteArray("candsBytes");
 
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 9:
                 errBytes = reader.readByteArray("errBytes");
@@ -227,7 +226,7 @@ public class GridDistributedTxPrepareResponse<K, V> extends GridDistributedBaseM
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/947723c9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedUnlockRequest.java
----------------------------------------------------------------------
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 9c3f6ab..f5fe1eb 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
@@ -118,11 +118,7 @@ public class GridDistributedUnlockRequest<K, V> extends GridDistributedBaseMessa
     @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors",
         "OverriddenMethodCallDuringObjectConstruction"})
     @Override public MessageAdapter clone() {
-        GridDistributedUnlockRequest _clone = new GridDistributedUnlockRequest();
-
-        clone0(_clone);
-
-        return _clone;
+        throw new UnsupportedOperationException();
     }
 
     /** {@inheritDoc} */
@@ -138,24 +134,27 @@ public class GridDistributedUnlockRequest<K, V> extends GridDistributedBaseMessa
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean writeTo(ByteBuffer buf) {
+        MessageWriteState state = MessageWriteState.get();
+        MessageWriter writer = state.writer();
+
         writer.setBuffer(buf);
 
         if (!super.writeTo(buf))
             return false;
 
-        if (!typeWritten) {
+        if (!state.isTypeWritten()) {
             if (!writer.writeByte(null, directType()))
                 return false;
 
-            typeWritten = true;
+            state.setTypeWritten();
         }
 
-        switch (state) {
+        switch (state.index()) {
             case 8:
                 if (!writer.writeCollection("keyBytes", keyBytes, byte[].class))
                     return false;
 
-                state++;
+                state.increment();
 
         }
 
@@ -170,14 +169,14 @@ public class GridDistributedUnlockRequest<K, V> extends GridDistributedBaseMessa
         if (!super.readFrom(buf))
             return false;
 
-        switch (state) {
+        switch (readState) {
             case 8:
                 keyBytes = reader.readCollection("keyBytes", byte[].class);
 
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/947723c9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java
----------------------------------------------------------------------
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 3534fd3..8832adc 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
@@ -69,11 +69,7 @@ public class GridDhtAffinityAssignmentRequest<K, V> extends GridCacheMessage<K,
     /** {@inheritDoc} */
     @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"})
     @Override public MessageAdapter clone() {
-        GridDhtAffinityAssignmentRequest _clone = new GridDhtAffinityAssignmentRequest();
-
-        clone0(_clone);
-
-        return _clone;
+        throw new UnsupportedOperationException();
     }
 
     /** {@inheritDoc} */
@@ -87,24 +83,27 @@ public class GridDhtAffinityAssignmentRequest<K, V> extends GridCacheMessage<K,
 
     /** {@inheritDoc} */
     @Override public boolean writeTo(ByteBuffer buf) {
+        MessageWriteState state = MessageWriteState.get();
+        MessageWriter writer = state.writer();
+
         writer.setBuffer(buf);
 
         if (!super.writeTo(buf))
             return false;
 
-        if (!typeWritten) {
+        if (!state.isTypeWritten()) {
             if (!writer.writeByte(null, directType()))
                 return false;
 
-            typeWritten = true;
+            state.setTypeWritten();
         }
 
-        switch (state) {
+        switch (state.index()) {
             case 3:
                 if (!writer.writeLong("topVer", topVer))
                     return false;
 
-                state++;
+                state.increment();
 
         }
 
@@ -118,14 +117,14 @@ public class GridDhtAffinityAssignmentRequest<K, V> extends GridCacheMessage<K,
         if (!super.readFrom(buf))
             return false;
 
-        switch (state) {
+        switch (readState) {
             case 3:
                 topVer = reader.readLong("topVer");
 
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/947723c9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentResponse.java
----------------------------------------------------------------------
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 4a44303..b26e54b 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
@@ -91,11 +91,7 @@ public class GridDhtAffinityAssignmentResponse<K, V> extends GridCacheMessage<K,
     /** {@inheritDoc} */
     @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"})
     @Override public MessageAdapter clone() {
-        GridDhtAffinityAssignmentResponse _clone = new GridDhtAffinityAssignmentResponse();
-
-        clone0(_clone);
-
-        return _clone;
+        throw new UnsupportedOperationException();
     }
 
     /** {@inheritDoc} */
@@ -128,30 +124,33 @@ public class GridDhtAffinityAssignmentResponse<K, V> extends GridCacheMessage<K,
 
     /** {@inheritDoc} */
     @Override public boolean writeTo(ByteBuffer buf) {
+        MessageWriteState state = MessageWriteState.get();
+        MessageWriter writer = state.writer();
+
         writer.setBuffer(buf);
 
         if (!super.writeTo(buf))
             return false;
 
-        if (!typeWritten) {
+        if (!state.isTypeWritten()) {
             if (!writer.writeByte(null, directType()))
                 return false;
 
-            typeWritten = true;
+            state.setTypeWritten();
         }
 
-        switch (state) {
+        switch (state.index()) {
             case 3:
                 if (!writer.writeByteArray("affAssignmentBytes", affAssignmentBytes))
                     return false;
 
-                state++;
+                state.increment();
 
             case 4:
                 if (!writer.writeLong("topVer", topVer))
                     return false;
 
-                state++;
+                state.increment();
 
         }
 
@@ -165,14 +164,14 @@ public class GridDhtAffinityAssignmentResponse<K, V> extends GridCacheMessage<K,
         if (!super.readFrom(buf))
             return false;
 
-        switch (state) {
+        switch (readState) {
             case 3:
                 affAssignmentBytes = reader.readByteArray("affAssignmentBytes");
 
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 4:
                 topVer = reader.readLong("topVer");
@@ -180,7 +179,7 @@ public class GridDhtAffinityAssignmentResponse<K, V> extends GridCacheMessage<K,
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/947723c9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java
----------------------------------------------------------------------
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 a9a93f7..4746103 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
@@ -343,11 +343,7 @@ public class GridDhtLockRequest<K, V> extends GridDistributedLockRequest<K, V> {
     /** {@inheritDoc} */
     @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"})
     @Override public MessageAdapter clone() {
-        GridDhtLockRequest _clone = new GridDhtLockRequest();
-
-        clone0(_clone);
-
-        return _clone;
+        throw new UnsupportedOperationException();
     }
 
     /** {@inheritDoc} */
@@ -372,72 +368,75 @@ public class GridDhtLockRequest<K, V> extends GridDistributedLockRequest<K, V> {
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean writeTo(ByteBuffer buf) {
+        MessageWriteState state = MessageWriteState.get();
+        MessageWriter writer = state.writer();
+
         writer.setBuffer(buf);
 
         if (!super.writeTo(buf))
             return false;
 
-        if (!typeWritten) {
+        if (!state.isTypeWritten()) {
             if (!writer.writeByte(null, directType()))
                 return false;
 
-            typeWritten = true;
+            state.setTypeWritten();
         }
 
-        switch (state) {
+        switch (state.index()) {
             case 24:
                 if (!writer.writeLong("accessTtl", accessTtl))
                     return false;
 
-                state++;
+                state.increment();
 
             case 25:
                 if (!writer.writeBitSet("invalidateEntries", invalidateEntries))
                     return false;
 
-                state++;
+                state.increment();
 
             case 26:
                 if (!writer.writeIgniteUuid("miniId", miniId))
                     return false;
 
-                state++;
+                state.increment();
 
             case 27:
                 if (!writer.writeCollection("nearKeyBytes", nearKeyBytes, byte[].class))
                     return false;
 
-                state++;
+                state.increment();
 
             case 28:
                 if (!writer.writeByteArray("ownedBytes", ownedBytes))
                     return false;
 
-                state++;
+                state.increment();
 
             case 29:
                 if (!writer.writeBitSet("preloadKeys", preloadKeys))
                     return false;
 
-                state++;
+                state.increment();
 
             case 30:
                 if (!writer.writeUuid("subjId", subjId))
                     return false;
 
-                state++;
+                state.increment();
 
             case 31:
                 if (!writer.writeInt("taskNameHash", taskNameHash))
                     return false;
 
-                state++;
+                state.increment();
 
             case 32:
                 if (!writer.writeLong("topVer", topVer))
                     return false;
 
-                state++;
+                state.increment();
 
         }
 
@@ -452,14 +451,14 @@ public class GridDhtLockRequest<K, V> extends GridDistributedLockRequest<K, V> {
         if (!super.readFrom(buf))
             return false;
 
-        switch (state) {
+        switch (readState) {
             case 24:
                 accessTtl = reader.readLong("accessTtl");
 
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 25:
                 invalidateEntries = reader.readBitSet("invalidateEntries");
@@ -467,7 +466,7 @@ public class GridDhtLockRequest<K, V> extends GridDistributedLockRequest<K, V> {
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 26:
                 miniId = reader.readIgniteUuid("miniId");
@@ -475,7 +474,7 @@ public class GridDhtLockRequest<K, V> extends GridDistributedLockRequest<K, V> {
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 27:
                 nearKeyBytes = reader.readCollection("nearKeyBytes", byte[].class);
@@ -483,7 +482,7 @@ public class GridDhtLockRequest<K, V> extends GridDistributedLockRequest<K, V> {
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 28:
                 ownedBytes = reader.readByteArray("ownedBytes");
@@ -491,7 +490,7 @@ public class GridDhtLockRequest<K, V> extends GridDistributedLockRequest<K, V> {
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 29:
                 preloadKeys = reader.readBitSet("preloadKeys");
@@ -499,7 +498,7 @@ public class GridDhtLockRequest<K, V> extends GridDistributedLockRequest<K, V> {
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 30:
                 subjId = reader.readUuid("subjId");
@@ -507,7 +506,7 @@ public class GridDhtLockRequest<K, V> extends GridDistributedLockRequest<K, V> {
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 31:
                 taskNameHash = reader.readInt("taskNameHash");
@@ -515,7 +514,7 @@ public class GridDhtLockRequest<K, V> extends GridDistributedLockRequest<K, V> {
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 32:
                 topVer = reader.readLong("topVer");
@@ -523,7 +522,7 @@ public class GridDhtLockRequest<K, V> extends GridDistributedLockRequest<K, V> {
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/947723c9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockResponse.java
----------------------------------------------------------------------
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 48ef34d..0bc988c 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
@@ -201,11 +201,7 @@ public class GridDhtLockResponse<K, V> extends GridDistributedLockResponse<K, V>
     /** {@inheritDoc} */
     @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"})
     @Override public MessageAdapter clone() {
-        GridDhtLockResponse _clone = new GridDhtLockResponse();
-
-        clone0(_clone);
-
-        return _clone;
+        throw new UnsupportedOperationException();
     }
 
     /** {@inheritDoc} */
@@ -225,42 +221,45 @@ public class GridDhtLockResponse<K, V> extends GridDistributedLockResponse<K, V>
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean writeTo(ByteBuffer buf) {
+        MessageWriteState state = MessageWriteState.get();
+        MessageWriter writer = state.writer();
+
         writer.setBuffer(buf);
 
         if (!super.writeTo(buf))
             return false;
 
-        if (!typeWritten) {
+        if (!state.isTypeWritten()) {
             if (!writer.writeByte(null, directType()))
                 return false;
 
-            typeWritten = true;
+            state.setTypeWritten();
         }
 
-        switch (state) {
+        switch (state.index()) {
             case 11:
                 if (!writer.writeCollection("invalidParts", invalidParts, int.class))
                     return false;
 
-                state++;
+                state.increment();
 
             case 12:
                 if (!writer.writeIgniteUuid("miniId", miniId))
                     return false;
 
-                state++;
+                state.increment();
 
             case 13:
                 if (!writer.writeCollection("nearEvictedBytes", nearEvictedBytes, byte[].class))
                     return false;
 
-                state++;
+                state.increment();
 
             case 14:
                 if (!writer.writeCollection("preloadEntriesBytes", preloadEntriesBytes, byte[].class))
                     return false;
 
-                state++;
+                state.increment();
 
         }
 
@@ -275,14 +274,14 @@ public class GridDhtLockResponse<K, V> extends GridDistributedLockResponse<K, V>
         if (!super.readFrom(buf))
             return false;
 
-        switch (state) {
+        switch (readState) {
             case 11:
                 invalidParts = reader.readCollection("invalidParts", int.class);
 
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 12:
                 miniId = reader.readIgniteUuid("miniId");
@@ -290,7 +289,7 @@ public class GridDhtLockResponse<K, V> extends GridDistributedLockResponse<K, V>
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 13:
                 nearEvictedBytes = reader.readCollection("nearEvictedBytes", byte[].class);
@@ -298,7 +297,7 @@ public class GridDhtLockResponse<K, V> extends GridDistributedLockResponse<K, V>
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
             case 14:
                 preloadEntriesBytes = reader.readCollection("preloadEntriesBytes", byte[].class);
@@ -306,7 +305,7 @@ public class GridDhtLockResponse<K, V> extends GridDistributedLockResponse<K, V>
                 if (!reader.isLastRead())
                     return false;
 
-                state++;
+                readState++;
 
         }
 


Mime
View raw message