ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vkuliche...@apache.org
Subject [05/50] [abbrv] incubator-ignite git commit: IGNITE-61 - Direct marshalling
Date Tue, 10 Feb 2015 04:09:36 GMT
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/159c1e84/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java
----------------------------------------------------------------------
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 f8c5cc2..44088aa 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 class GridNearGetRequest<K, V> extends GridCacheMessage<K, V> implements
     /** {@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<byte[], Boolean> e = (Map.Entry<byte[], Boolean>)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 class GridNearGetRequest<K, V> extends GridCacheMessage<K, V> implements
     /** {@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++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/159c1e84/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java
----------------------------------------------------------------------
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 cc2a48a..63c9e46 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 class GridNearGetResponse<K, V> extends GridCacheMessage<K, V> implements
     /** {@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 class GridNearGetResponse<K, V> extends GridCacheMessage<K, V> implements
     /** {@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++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/159c1e84/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java
----------------------------------------------------------------------
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 da008ac..5997007 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 class GridNearLockRequest<K, V> extends GridDistributedLockRequest<K, V>
     /** {@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 class GridNearLockRequest<K, V> extends GridDistributedLockRequest<K, V>
     /** {@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++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/159c1e84/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockResponse.java
----------------------------------------------------------------------
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 9a62b02..2769f7a 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 class GridNearLockResponse<K, V> extends GridDistributedLockResponse<K, V
     /** {@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 class GridNearLockResponse<K, V> extends GridDistributedLockResponse<K, V
     /** {@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++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/159c1e84/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java
----------------------------------------------------------------------
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 a462751..cfa797a 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 class GridNearTxFinishRequest<K, V> extends GridDistributedTxFinishReques
     /** {@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 class GridNearTxFinishRequest<K, V> extends GridDistributedTxFinishReques
     /** {@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++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/159c1e84/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java
----------------------------------------------------------------------
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 5532b88..5e19079 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 class GridNearTxFinishResponse<K, V> extends GridDistributedTxFinishRespo
     /** {@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 class GridNearTxFinishResponse<K, V> extends GridDistributedTxFinishRespo
     /** {@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++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/159c1e84/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java
----------------------------------------------------------------------
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 1cd7ce0..9d5f73d 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 @@ public class GridNearTxPrepareRequest<K, V> extends GridDistributedTxPrepareRequ
     /** {@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.putBoolean("last", last))
+                if (!writer.writeBoolean("last", last))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 24:
-                if (lastBackups != null) {
-                    if (commState.it == null) {
-                        if (!commState.putInt(null, lastBackups.size()))
-                            return false;
-
-                        commState.it = lastBackups.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("lastBackups", lastBackups, UUID.class))
+                    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.putBoolean("near", near))
+                if (!writer.writeBoolean("near", near))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 27:
-                if (!commState.putLong("topVer", topVer))
+                if (!writer.writeUuid("subjId", subjId))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 28:
-                if (!commState.putUuid("subjId", subjId))
+                if (!writer.writeInt("taskNameHash", taskNameHash))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 29:
-                if (!commState.putInt("taskNameHash", taskNameHash))
+                if (!writer.writeLong("topVer", topVer))
                     return false;
 
-                commState.idx++;
+                state++;
 
         }
 
@@ -334,97 +313,75 @@ public class GridNearTxPrepareRequest<K, V> extends GridDistributedTxPrepareRequ
     /** {@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:
-                last = commState.getBoolean("last");
+                last = reader.readBoolean("last");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 24:
-                if (commState.readSize == -1) {
-                    int _val = commState.getInt(null);
-
-                    if (!commState.lastRead())
-                        return false;
-                    commState.readSize = _val;
-                }
+                lastBackups = reader.readCollection("lastBackups", UUID.class);
 
-                if (commState.readSize >= 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++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/159c1e84/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareResponse.java
----------------------------------------------------------------------
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 f6e6975..8eb63b1 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 class GridNearTxPrepareResponse<K, V> extends GridDistributedTxPrepareRes
     /** {@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 class GridNearTxPrepareResponse<K, V> extends GridDistributedTxPrepareRes
     /** {@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++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/159c1e84/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearUnlockRequest.java
----------------------------------------------------------------------
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 86f839b..267d798 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 class GridNearUnlockRequest<K, V> extends GridDistributedUnlockRequest<K,
     /** {@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 class GridNearUnlockRequest<K, V> extends GridDistributedUnlockRequest<K,
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean readFrom(ByteBuffer buf) {
-        commState.setBuffer(buf);
+        reader.setBuffer(buf);
 
         if (!super.readFrom(buf))
             return false;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/159c1e84/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java
----------------------------------------------------------------------
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 2893f4f..e7079d1 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 class GridCacheQueryRequest<K, V> extends GridCacheMessage<K, V> implemen
     /** {@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 class GridCacheQueryRequest<K, V> extends GridCacheMessage<K, V> implemen
     /** {@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++;
 
         }
 


Mime
View raw message