ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject [02/52] [abbrv] incubator-ignite git commit: IGNITE-61 - Direct marshalling
Date Tue, 10 Feb 2015 06:25:02 GMT
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/159c1e84/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java
index fe18c8c..acba6f6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryResponse.java
@@ -231,96 +231,54 @@ public class GridCacheQueryResponse<K, V> extends GridCacheMessage<K, V> impleme
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean writeTo(ByteBuffer buf) {
-        commState.setBuffer(buf);
+        writer.setBuffer(buf);
 
         if (!super.writeTo(buf))
             return false;
 
-        if (!commState.typeWritten) {
-            if (!commState.putByte(null, directType()))
+        if (!typeWritten) {
+            if (!writer.writeByte(null, directType()))
                 return false;
 
-            commState.typeWritten = true;
+            typeWritten = true;
         }
 
-        switch (commState.idx) {
+        switch (state) {
             case 3:
-                if (dataBytes != null) {
-                    if (commState.it == null) {
-                        if (!commState.putInt(null, dataBytes.size()))
-                            return false;
-
-                        commState.it = dataBytes.iterator();
-                    }
-
-                    while (commState.it.hasNext() || commState.cur != NULL) {
-                        if (commState.cur == NULL)
-                            commState.cur = commState.it.next();
-
-                        if (!commState.putByteArray(null, (byte[])commState.cur))
-                            return false;
-
-                        commState.cur = NULL;
-                    }
-
-                    commState.it = null;
-                } else {
-                    if (!commState.putInt(null, -1))
-                        return false;
-                }
+                if (!writer.writeCollection("dataBytes", dataBytes, byte[].class))
+                    return false;
 
-                commState.idx++;
+                state++;
 
             case 4:
-                if (!commState.putByteArray("errBytes", errBytes))
+                if (!writer.writeByteArray("errBytes", errBytes))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 5:
-                if (!commState.putBoolean("fields", fields))
+                if (!writer.writeBoolean("fields", fields))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 6:
-                if (!commState.putBoolean("finished", finished))
+                if (!writer.writeBoolean("finished", finished))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 7:
-                if (metaDataBytes != null) {
-                    if (commState.it == null) {
-                        if (!commState.putInt(null, metaDataBytes.size()))
-                            return false;
-
-                        commState.it = metaDataBytes.iterator();
-                    }
-
-                    while (commState.it.hasNext() || commState.cur != NULL) {
-                        if (commState.cur == NULL)
-                            commState.cur = commState.it.next();
-
-                        if (!commState.putByteArray(null, (byte[])commState.cur))
-                            return false;
-
-                        commState.cur = NULL;
-                    }
-
-                    commState.it = null;
-                } else {
-                    if (!commState.putInt(null, -1))
-                        return false;
-                }
+                if (!writer.writeCollection("metaDataBytes", metaDataBytes, byte[].class))
+                    return false;
 
-                commState.idx++;
+                state++;
 
             case 8:
-                if (!commState.putLong("reqId", reqId))
+                if (!writer.writeLong("reqId", reqId))
                     return false;
 
-                commState.idx++;
+                state++;
 
         }
 
@@ -330,103 +288,59 @@ public class GridCacheQueryResponse<K, V> extends GridCacheMessage<K, V> impleme
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean readFrom(ByteBuffer buf) {
-        commState.setBuffer(buf);
+        reader.setBuffer(buf);
 
         if (!super.readFrom(buf))
             return false;
 
-        switch (commState.idx) {
+        switch (state) {
             case 3:
-                if (commState.readSize == -1) {
-                    int _val = commState.getInt(null);
-
-                    if (!commState.lastRead())
-                        return false;
-                    commState.readSize = _val;
-                }
+                dataBytes = reader.readCollection("dataBytes", byte[].class);
 
-                if (commState.readSize >= 0) {
-                    if (dataBytes == null)
-                        dataBytes = new ArrayList<>(commState.readSize);
-
-                    for (int i = commState.readItems; i < commState.readSize; i++) {
-                        byte[] _val = commState.getByteArray(null);
-
-                        if (!commState.lastRead())
-                            return false;
-
-                        dataBytes.add((byte[])_val);
-
-                        commState.readItems++;
-                    }
-                }
-
-                commState.readSize = -1;
-                commState.readItems = 0;
+                if (!reader.isLastRead())
+                    return false;
 
-                commState.idx++;
+                state++;
 
             case 4:
-                errBytes = commState.getByteArray("errBytes");
+                errBytes = reader.readByteArray("errBytes");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 5:
-                fields = commState.getBoolean("fields");
+                fields = reader.readBoolean("fields");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 6:
-                finished = commState.getBoolean("finished");
+                finished = reader.readBoolean("finished");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 7:
-                if (commState.readSize == -1) {
-                    int _val = commState.getInt(null);
-
-                    if (!commState.lastRead())
-                        return false;
-                    commState.readSize = _val;
-                }
-
-                if (commState.readSize >= 0) {
-                    if (metaDataBytes == null)
-                        metaDataBytes = new ArrayList<>(commState.readSize);
-
-                    for (int i = commState.readItems; i < commState.readSize; i++) {
-                        byte[] _val = commState.getByteArray(null);
-
-                        if (!commState.lastRead())
-                            return false;
+                metaDataBytes = reader.readCollection("metaDataBytes", byte[].class);
 
-                        metaDataBytes.add((byte[])_val);
-
-                        commState.readItems++;
-                    }
-                }
-
-                commState.readSize = -1;
-                commState.readItems = 0;
+                if (!reader.isLastRead())
+                    return false;
 
-                commState.idx++;
+                state++;
 
             case 8:
-                reqId = commState.getLong("reqId");
+                reqId = reader.readLong("reqId");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/159c1e84/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersion.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersion.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersion.java
index 15e84ac..77fdf2d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersion.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersion.java
@@ -254,12 +254,85 @@ public class GridCacheVersion extends MessageAdapter implements Comparable<GridC
 
     /** {@inheritDoc} */
     @Override public boolean writeTo(ByteBuffer buf) {
-        return false; // TODO: implement.
+        writer.setBuffer(buf);
+
+        if (!typeWritten) {
+            if (!writer.writeByte(null, directType()))
+                return false;
+
+            typeWritten = true;
+        }
+
+        switch (state) {
+            case 0:
+                if (!writer.writeLong("globalTime", globalTime))
+                    return false;
+
+                state++;
+
+            case 1:
+                if (!writer.writeInt("nodeOrderDrId", nodeOrderDrId))
+                    return false;
+
+                state++;
+
+            case 2:
+                if (!writer.writeLong("order", order))
+                    return false;
+
+                state++;
+
+            case 3:
+                if (!writer.writeInt("topVer", topVer))
+                    return false;
+
+                state++;
+
+        }
+
+        return true;
     }
 
     /** {@inheritDoc} */
     @Override public boolean readFrom(ByteBuffer buf) {
-        return false; // TODO: implement.
+        reader.setBuffer(buf);
+
+        switch (state) {
+            case 0:
+                globalTime = reader.readLong("globalTime");
+
+                if (!reader.isLastRead())
+                    return false;
+
+                state++;
+
+            case 1:
+                nodeOrderDrId = reader.readInt("nodeOrderDrId");
+
+                if (!reader.isLastRead())
+                    return false;
+
+                state++;
+
+            case 2:
+                order = reader.readLong("order");
+
+                if (!reader.isLastRead())
+                    return false;
+
+                state++;
+
+            case 3:
+                topVer = reader.readInt("topVer");
+
+                if (!reader.isLastRead())
+                    return false;
+
+                state++;
+
+        }
+
+        return true;
     }
 
     /** {@inheritDoc} */
@@ -269,12 +342,21 @@ public class GridCacheVersion extends MessageAdapter implements Comparable<GridC
 
     /** {@inheritDoc} */
     @Override public MessageAdapter clone() {
-        return null; // TODO: implement.
+        GridCacheVersion _clone = new GridCacheVersion();
+
+        clone0(_clone);
+
+        return _clone;
     }
 
     /** {@inheritDoc} */
     @Override protected void clone0(MessageAdapter _msg) {
-        // TODO: implement.
+        GridCacheVersion _clone = (GridCacheVersion)_msg;
+
+        _clone.topVer = topVer;
+        _clone.nodeOrderDrId = nodeOrderDrId;
+        _clone.globalTime = globalTime;
+        _clone.order = order;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/159c1e84/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaSnapshotMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaSnapshotMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaSnapshotMessage.java
index dd576e3..61fe044 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaSnapshotMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaSnapshotMessage.java
@@ -92,59 +92,27 @@ public class GridClockDeltaSnapshotMessage extends MessageAdapter {
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean writeTo(ByteBuffer buf) {
-        commState.setBuffer(buf);
+        writer.setBuffer(buf);
 
-        if (!commState.typeWritten) {
-            if (!commState.putByte(null, directType()))
+        if (!typeWritten) {
+            if (!writer.writeByte(null, directType()))
                 return false;
 
-            commState.typeWritten = true;
+            typeWritten = true;
         }
 
-        switch (commState.idx) {
+        switch (state) {
             case 0:
-                if (deltas != null) {
-                    if (commState.it == null) {
-                        if (!commState.putInt(null, deltas.size()))
-                            return false;
-
-                        commState.it = deltas.entrySet().iterator();
-                    }
-
-                    while (commState.it.hasNext() || commState.cur != NULL) {
-                        if (commState.cur == NULL)
-                            commState.cur = commState.it.next();
-
-                        Map.Entry<UUID, Long> e = (Map.Entry<UUID, Long>)commState.cur;
-
-                        if (!commState.keyDone) {
-                            if (!commState.putUuid(null, e.getKey()))
-                                return false;
-
-                            commState.keyDone = true;
-                        }
-
-                        if (!commState.putLong(null, e.getValue()))
-                            return false;
-
-                        commState.keyDone = false;
-
-                        commState.cur = NULL;
-                    }
-
-                    commState.it = null;
-                } else {
-                    if (!commState.putInt(null, -1))
-                        return false;
-                }
+                if (!writer.writeMap("deltas", deltas, UUID.class, long.class))
+                    return false;
 
-                commState.idx++;
+                state++;
 
             case 1:
-                if (!commState.putClockDeltaVersion("snapVer", snapVer))
+                if (!writer.writeMessage("snapVer", snapVer != null ? snapVer.clone() : null))
                     return false;
 
-                commState.idx++;
+                state++;
 
         }
 
@@ -154,59 +122,24 @@ public class GridClockDeltaSnapshotMessage extends MessageAdapter {
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean readFrom(ByteBuffer buf) {
-        commState.setBuffer(buf);
+        reader.setBuffer(buf);
 
-        switch (commState.idx) {
+        switch (state) {
             case 0:
-                if (commState.readSize == -1) {
-                    int _val = commState.getInt(null);
-
-                    if (!commState.lastRead())
-                        return false;
-                    commState.readSize = _val;
-                }
+                deltas = reader.readMap("deltas", UUID.class, long.class);
 
-                if (commState.readSize >= 0) {
-                    if (deltas == null)
-                        deltas = new HashMap<>(commState.readSize, 1.0f);
-
-                    for (int i = commState.readItems; i < commState.readSize; i++) {
-                        if (!commState.keyDone) {
-                            UUID _val = commState.getUuid(null);
-
-                            if (!commState.lastRead())
-                                return false;
-
-                            commState.cur = _val;
-                            commState.keyDone = true;
-                        }
-
-                        long _val = commState.getLong(null);
-
-                        if (!commState.lastRead())
-                            return false;
-
-                        deltas.put((UUID)commState.cur, _val);
-
-                        commState.keyDone = false;
-
-                        commState.readItems++;
-                    }
-                }
-
-                commState.readSize = -1;
-                commState.readItems = 0;
-                commState.cur = null;
+                if (!reader.isLastRead())
+                    return false;
 
-                commState.idx++;
+                state++;
 
             case 1:
-                snapVer = commState.getClockDeltaVersion("snapVer");
+                snapVer = reader.readMessage("snapVer");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/159c1e84/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaVersion.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaVersion.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaVersion.java
index 852f9f0..06e8730 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaVersion.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockDeltaVersion.java
@@ -114,12 +114,57 @@ public class GridClockDeltaVersion extends MessageAdapter implements Comparable<
 
     /** {@inheritDoc} */
     @Override public boolean writeTo(ByteBuffer buf) {
-        return false; // TODO: implement.
+        writer.setBuffer(buf);
+
+        if (!typeWritten) {
+            if (!writer.writeByte(null, directType()))
+                return false;
+
+            typeWritten = true;
+        }
+
+        switch (state) {
+            case 0:
+                if (!writer.writeLong("topVer", topVer))
+                    return false;
+
+                state++;
+
+            case 1:
+                if (!writer.writeLong("ver", ver))
+                    return false;
+
+                state++;
+
+        }
+
+        return true;
     }
 
     /** {@inheritDoc} */
     @Override public boolean readFrom(ByteBuffer buf) {
-        return false; // TODO: implement.
+        reader.setBuffer(buf);
+
+        switch (state) {
+            case 0:
+                topVer = reader.readLong("topVer");
+
+                if (!reader.isLastRead())
+                    return false;
+
+                state++;
+
+            case 1:
+                ver = reader.readLong("ver");
+
+                if (!reader.isLastRead())
+                    return false;
+
+                state++;
+
+        }
+
+        return true;
     }
 
     /** {@inheritDoc} */
@@ -129,12 +174,19 @@ public class GridClockDeltaVersion extends MessageAdapter implements Comparable<
 
     /** {@inheritDoc} */
     @Override public MessageAdapter clone() {
-        return null; // TODO: implement.
+        GridClockDeltaVersion _clone = new GridClockDeltaVersion();
+
+        clone0(_clone);
+
+        return _clone;
     }
 
     /** {@inheritDoc} */
     @Override protected void clone0(MessageAdapter _msg) {
-        // TODO: implement.
+        GridClockDeltaVersion _clone = (GridClockDeltaVersion)_msg;
+
+        _clone.ver = ver;
+        _clone.topVer = topVer;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/159c1e84/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousMessage.java
index a6a62d7..e005a9b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousMessage.java
@@ -154,39 +154,39 @@ public class GridContinuousMessage extends MessageAdapter {
     /** {@inheritDoc} */
     @SuppressWarnings("fallthrough")
     @Override public boolean writeTo(ByteBuffer buf) {
-        commState.setBuffer(buf);
+        writer.setBuffer(buf);
 
-        if (!commState.typeWritten) {
-            if (!commState.putByte(null, directType()))
+        if (!typeWritten) {
+            if (!writer.writeByte(null, directType()))
                 return false;
 
-            commState.typeWritten = true;
+            typeWritten = true;
         }
 
-        switch (commState.idx) {
+        switch (state) {
             case 0:
-                if (!commState.putByteArray("dataBytes", dataBytes))
+                if (!writer.writeByteArray("dataBytes", dataBytes))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 1:
-                if (!commState.putGridUuid("futId", futId))
+                if (!writer.writeIgniteUuid("futId", futId))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 2:
-                if (!commState.putUuid("routineId", routineId))
+                if (!writer.writeUuid("routineId", routineId))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 3:
-                if (!commState.putEnum("type", type))
+                if (!writer.writeEnum("type", type))
                     return false;
 
-                commState.idx++;
+                state++;
 
         }
 
@@ -196,42 +196,40 @@ public class GridContinuousMessage extends MessageAdapter {
     /** {@inheritDoc} */
     @SuppressWarnings("fallthrough")
     @Override public boolean readFrom(ByteBuffer buf) {
-        commState.setBuffer(buf);
+        reader.setBuffer(buf);
 
-        switch (commState.idx) {
+        switch (state) {
             case 0:
-                dataBytes = commState.getByteArray("dataBytes");
+                dataBytes = reader.readByteArray("dataBytes");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 1:
-                futId = commState.getGridUuid("futId");
+                futId = reader.readIgniteUuid("futId");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 2:
-                routineId = commState.getUuid("routineId");
+                routineId = reader.readUuid("routineId");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 3:
-                byte type0 = commState.getByte("type");
+                type = reader.readEnum("type", GridContinuousMessageType.class);
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                type = GridContinuousMessageType.fromOrdinal(type0);
-
-                commState.idx++;
+                state++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/159c1e84/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadRequest.java
index 4690f82..15721f9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadRequest.java
@@ -224,125 +224,93 @@ public class GridDataLoadRequest extends MessageAdapter {
 
     /** {@inheritDoc} */
     @Override public boolean writeTo(ByteBuffer buf) {
-        commState.setBuffer(buf);
+        writer.setBuffer(buf);
 
-        if (!commState.typeWritten) {
-            if (!commState.putByte(null, directType()))
+        if (!typeWritten) {
+            if (!writer.writeByte(null, directType()))
                 return false;
 
-            commState.typeWritten = true;
+            typeWritten = true;
         }
 
-        switch (commState.idx) {
+        switch (state) {
             case 0:
-                if (!commState.putString("cacheName", cacheName))
+                if (!writer.writeString("cacheName", cacheName))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 1:
-                if (!commState.putGridUuid("clsLdrId", clsLdrId))
+                if (!writer.writeIgniteUuid("clsLdrId", clsLdrId))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 2:
-                if (!commState.putByteArray("colBytes", colBytes))
+                if (!writer.writeByteArray("colBytes", colBytes))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 3:
-                if (!commState.putEnum("depMode", depMode))
+                if (!writer.writeEnum("depMode", depMode))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 4:
-                if (!commState.putBoolean("forceLocDep", forceLocDep))
+                if (!writer.writeBoolean("forceLocDep", forceLocDep))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 5:
-                if (!commState.putBoolean("ignoreDepOwnership", ignoreDepOwnership))
+                if (!writer.writeBoolean("ignoreDepOwnership", ignoreDepOwnership))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 6:
-                if (ldrParticipants != null) {
-                    if (commState.it == null) {
-                        if (!commState.putInt(null, ldrParticipants.size()))
-                            return false;
-
-                        commState.it = ldrParticipants.entrySet().iterator();
-                    }
-
-                    while (commState.it.hasNext() || commState.cur != NULL) {
-                        if (commState.cur == NULL)
-                            commState.cur = commState.it.next();
-
-                        Map.Entry<UUID, IgniteUuid> e = (Map.Entry<UUID, IgniteUuid>)commState.cur;
-
-                        if (!commState.keyDone) {
-                            if (!commState.putUuid(null, e.getKey()))
-                                return false;
-
-                            commState.keyDone = true;
-                        }
-
-                        if (!commState.putGridUuid(null, e.getValue()))
-                            return false;
-
-                        commState.keyDone = false;
-
-                        commState.cur = NULL;
-                    }
-
-                    commState.it = null;
-                } else {
-                    if (!commState.putInt(null, -1))
-                        return false;
-                }
+                if (!writer.writeMap("ldrParticipants", ldrParticipants, UUID.class, IgniteUuid.class))
+                    return false;
 
-                commState.idx++;
+                state++;
 
             case 7:
-                if (!commState.putLong("reqId", reqId))
+                if (!writer.writeLong("reqId", reqId))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 8:
-                if (!commState.putByteArray("resTopicBytes", resTopicBytes))
+                if (!writer.writeByteArray("resTopicBytes", resTopicBytes))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 9:
-                if (!commState.putString("sampleClsName", sampleClsName))
+                if (!writer.writeString("sampleClsName", sampleClsName))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 10:
-                if (!commState.putBoolean("skipStore", skipStore))
+                if (!writer.writeBoolean("skipStore", skipStore))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 11:
-                if (!commState.putByteArray("updaterBytes", updaterBytes))
+                if (!writer.writeByteArray("updaterBytes", updaterBytes))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 12:
-                if (!commState.putString("userVer", userVer))
+                if (!writer.writeString("userVer", userVer))
                     return false;
 
-                commState.idx++;
+                state++;
 
         }
 
@@ -351,149 +319,112 @@ public class GridDataLoadRequest extends MessageAdapter {
 
     /** {@inheritDoc} */
     @Override public boolean readFrom(ByteBuffer buf) {
-        commState.setBuffer(buf);
+        reader.setBuffer(buf);
 
-        switch (commState.idx) {
+        switch (state) {
             case 0:
-                cacheName = commState.getString("cacheName");
+                cacheName = reader.readString("cacheName");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 1:
-                clsLdrId = commState.getGridUuid("clsLdrId");
+                clsLdrId = reader.readIgniteUuid("clsLdrId");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 2:
-                colBytes = commState.getByteArray("colBytes");
+                colBytes = reader.readByteArray("colBytes");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 3:
-                byte depMode0 = commState.getByte("depMode");
+                depMode = reader.readEnum("depMode", DeploymentMode.class);
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                depMode = DeploymentMode.fromOrdinal(depMode0);
-
-                commState.idx++;
+                state++;
 
             case 4:
-                forceLocDep = commState.getBoolean("forceLocDep");
+                forceLocDep = reader.readBoolean("forceLocDep");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 5:
-                ignoreDepOwnership = commState.getBoolean("ignoreDepOwnership");
+                ignoreDepOwnership = reader.readBoolean("ignoreDepOwnership");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 6:
-                if (commState.readSize == -1) {
-                    int _val = commState.getInt(null);
+                ldrParticipants = reader.readMap("ldrParticipants", UUID.class, IgniteUuid.class);
 
-                    if (!commState.lastRead())
-                        return false;
-                    commState.readSize = _val;
-                }
-
-                if (commState.readSize >= 0) {
-                    if (ldrParticipants == null)
-                        ldrParticipants = new HashMap<>(commState.readSize, 1.0f);
-
-                    for (int i = commState.readItems; i < commState.readSize; i++) {
-                        if (!commState.keyDone) {
-                            UUID _val = commState.getUuid(null);
-
-                            if (!commState.lastRead())
-                                return false;
-
-                            commState.cur = _val;
-                            commState.keyDone = true;
-                        }
-
-                        IgniteUuid _val = commState.getGridUuid(null);
-
-                        if (!commState.lastRead())
-                            return false;
-
-                        ldrParticipants.put((UUID)commState.cur, _val);
-
-                        commState.keyDone = false;
-
-                        commState.readItems++;
-                    }
-                }
-
-                commState.readSize = -1;
-                commState.readItems = 0;
-                commState.cur = null;
+                if (!reader.isLastRead())
+                    return false;
 
-                commState.idx++;
+                state++;
 
             case 7:
-                reqId = commState.getLong("reqId");
+                reqId = reader.readLong("reqId");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 8:
-                resTopicBytes = commState.getByteArray("resTopicBytes");
+                resTopicBytes = reader.readByteArray("resTopicBytes");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 9:
-                sampleClsName = commState.getString("sampleClsName");
+                sampleClsName = reader.readString("sampleClsName");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 10:
-                skipStore = commState.getBoolean("skipStore");
+                skipStore = reader.readBoolean("skipStore");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 11:
-                updaterBytes = commState.getByteArray("updaterBytes");
+                updaterBytes = reader.readByteArray("updaterBytes");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 12:
-                userVer = commState.getString("userVer");
+                userVer = reader.readString("userVer");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/159c1e84/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadResponse.java
index 2b8c0ee..8676e7e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/GridDataLoadResponse.java
@@ -104,33 +104,33 @@ public class GridDataLoadResponse extends MessageAdapter {
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean writeTo(ByteBuffer buf) {
-        commState.setBuffer(buf);
+        writer.setBuffer(buf);
 
-        if (!commState.typeWritten) {
-            if (!commState.putByte(null, directType()))
+        if (!typeWritten) {
+            if (!writer.writeByte(null, directType()))
                 return false;
 
-            commState.typeWritten = true;
+            typeWritten = true;
         }
 
-        switch (commState.idx) {
+        switch (state) {
             case 0:
-                if (!commState.putByteArray("errBytes", errBytes))
+                if (!writer.writeByteArray("errBytes", errBytes))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 1:
-                if (!commState.putBoolean("forceLocDep", forceLocDep))
+                if (!writer.writeBoolean("forceLocDep", forceLocDep))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 2:
-                if (!commState.putLong("reqId", reqId))
+                if (!writer.writeLong("reqId", reqId))
                     return false;
 
-                commState.idx++;
+                state++;
 
         }
 
@@ -140,32 +140,32 @@ public class GridDataLoadResponse extends MessageAdapter {
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean readFrom(ByteBuffer buf) {
-        commState.setBuffer(buf);
+        reader.setBuffer(buf);
 
-        switch (commState.idx) {
+        switch (state) {
             case 0:
-                errBytes = commState.getByteArray("errBytes");
+                errBytes = reader.readByteArray("errBytes");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 1:
-                forceLocDep = commState.getBoolean("forceLocDep");
+                forceLocDep = reader.readBoolean("forceLocDep");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 2:
-                reqId = commState.getLong("reqId");
+                reqId = reader.readLong("reqId");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/159c1e84/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsAckMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsAckMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsAckMessage.java
index 496a114..6bbb8e4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsAckMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsAckMessage.java
@@ -127,36 +127,36 @@ public class GridGgfsAckMessage extends GridGgfsCommunicationMessage {
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean writeTo(ByteBuffer buf) {
-        commState.setBuffer(buf);
+        writer.setBuffer(buf);
 
         if (!super.writeTo(buf))
             return false;
 
-        if (!commState.typeWritten) {
-            if (!commState.putByte(null, directType()))
+        if (!typeWritten) {
+            if (!writer.writeByte(null, directType()))
                 return false;
 
-            commState.typeWritten = true;
+            typeWritten = true;
         }
 
-        switch (commState.idx) {
+        switch (state) {
             case 0:
-                if (!commState.putByteArray("errBytes", errBytes))
+                if (!writer.writeByteArray("errBytes", errBytes))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 1:
-                if (!commState.putGridUuid("fileId", fileId))
+                if (!writer.writeIgniteUuid("fileId", fileId))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 2:
-                if (!commState.putLong("id", id))
+                if (!writer.writeLong("id", id))
                     return false;
 
-                commState.idx++;
+                state++;
 
         }
 
@@ -166,35 +166,35 @@ public class GridGgfsAckMessage extends GridGgfsCommunicationMessage {
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean readFrom(ByteBuffer buf) {
-        commState.setBuffer(buf);
+        reader.setBuffer(buf);
 
         if (!super.readFrom(buf))
             return false;
 
-        switch (commState.idx) {
+        switch (state) {
             case 0:
-                errBytes = commState.getByteArray("errBytes");
+                errBytes = reader.readByteArray("errBytes");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 1:
-                fileId = commState.getGridUuid("fileId");
+                fileId = reader.readIgniteUuid("fileId");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 2:
-                id = commState.getLong("id");
+                id = reader.readLong("id");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/159c1e84/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlockKey.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlockKey.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlockKey.java
index bbcbf42..6fc3776 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlockKey.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlockKey.java
@@ -181,39 +181,39 @@ public final class GridGgfsBlockKey extends MessageAdapter
     /** {@inheritDoc} */
     @SuppressWarnings("fallthrough")
     @Override public boolean writeTo(ByteBuffer buf) {
-        commState.setBuffer(buf);
+        writer.setBuffer(buf);
 
-        if (!commState.typeWritten) {
-            if (!commState.putByte(null, directType()))
+        if (!typeWritten) {
+            if (!writer.writeByte(null, directType()))
                 return false;
 
-            commState.typeWritten = true;
+            typeWritten = true;
         }
 
-        switch (commState.idx) {
+        switch (state) {
             case 0:
-                if (!commState.putGridUuid("affKey", affKey))
+                if (!writer.writeIgniteUuid("affKey", affKey))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 1:
-                if (!commState.putLong("blockId", blockId))
+                if (!writer.writeLong("blockId", blockId))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 2:
-                if (!commState.putBoolean("evictExclude", evictExclude))
+                if (!writer.writeBoolean("evictExclude", evictExclude))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 3:
-                if (!commState.putGridUuid("fileId", fileId))
+                if (!writer.writeIgniteUuid("fileId", fileId))
                     return false;
 
-                commState.idx++;
+                state++;
 
         }
 
@@ -223,40 +223,40 @@ public final class GridGgfsBlockKey extends MessageAdapter
     /** {@inheritDoc} */
     @SuppressWarnings("fallthrough")
     @Override public boolean readFrom(ByteBuffer buf) {
-        commState.setBuffer(buf);
+        reader.setBuffer(buf);
 
-        switch (commState.idx) {
+        switch (state) {
             case 0:
-                affKey = commState.getGridUuid("affKey");
+                affKey = reader.readIgniteUuid("affKey");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 1:
-                blockId = commState.getLong("blockId");
+                blockId = reader.readLong("blockId");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 2:
-                evictExclude = commState.getBoolean("evictExclude");
+                evictExclude = reader.readBoolean("evictExclude");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 3:
-                fileId = commState.getGridUuid("fileId");
+                fileId = reader.readIgniteUuid("fileId");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/159c1e84/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlocksMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlocksMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlocksMessage.java
index 6321042..7740066 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlocksMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsBlocksMessage.java
@@ -107,68 +107,36 @@ public class GridGgfsBlocksMessage extends GridGgfsCommunicationMessage {
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean writeTo(ByteBuffer buf) {
-        commState.setBuffer(buf);
+        writer.setBuffer(buf);
 
         if (!super.writeTo(buf))
             return false;
 
-        if (!commState.typeWritten) {
-            if (!commState.putByte(null, directType()))
+        if (!typeWritten) {
+            if (!writer.writeByte(null, directType()))
                 return false;
 
-            commState.typeWritten = true;
+            typeWritten = true;
         }
 
-        switch (commState.idx) {
+        switch (state) {
             case 0:
-                if (blocks != null) {
-                    if (commState.it == null) {
-                        if (!commState.putInt(null, blocks.size()))
-                            return false;
-
-                        commState.it = blocks.entrySet().iterator();
-                    }
-
-                    while (commState.it.hasNext() || commState.cur != NULL) {
-                        if (commState.cur == NULL)
-                            commState.cur = commState.it.next();
-
-                        Map.Entry<GridGgfsBlockKey, byte[]> e = (Map.Entry<GridGgfsBlockKey, byte[]>)commState.cur;
-
-                        if (!commState.keyDone) {
-                            if (!commState.putMessage(null, e.getKey()))
-                                return false;
-
-                            commState.keyDone = true;
-                        }
-
-                        if (!commState.putByteArray(null, e.getValue()))
-                            return false;
-
-                        commState.keyDone = false;
-
-                        commState.cur = NULL;
-                    }
-
-                    commState.it = null;
-                } else {
-                    if (!commState.putInt(null, -1))
-                        return false;
-                }
+                if (!writer.writeMap("blocks", blocks, GridGgfsBlockKey.class, byte[].class))
+                    return false;
 
-                commState.idx++;
+                state++;
 
             case 1:
-                if (!commState.putGridUuid("fileId", fileId))
+                if (!writer.writeIgniteUuid("fileId", fileId))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 2:
-                if (!commState.putLong("id", id))
+                if (!writer.writeLong("id", id))
                     return false;
 
-                commState.idx++;
+                state++;
 
         }
 
@@ -178,70 +146,35 @@ public class GridGgfsBlocksMessage extends GridGgfsCommunicationMessage {
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean readFrom(ByteBuffer buf) {
-        commState.setBuffer(buf);
+        reader.setBuffer(buf);
 
         if (!super.readFrom(buf))
             return false;
 
-        switch (commState.idx) {
+        switch (state) {
             case 0:
-                if (commState.readSize == -1) {
-                    int _val = commState.getInt(null);
-
-                    if (!commState.lastRead())
-                        return false;
-                    commState.readSize = _val;
-                }
+                blocks = reader.readMap("blocks", GridGgfsBlockKey.class, byte[].class);
 
-                if (commState.readSize >= 0) {
-                    if (blocks == null)
-                        blocks = new HashMap<>(commState.readSize, 1.0f);
-
-                    for (int i = commState.readItems; i < commState.readSize; i++) {
-                        if (!commState.keyDone) {
-                            GridGgfsBlockKey _val = (GridGgfsBlockKey)commState.getMessage(null);
-
-                            if (!commState.lastRead())
-                                return false;
-
-                            commState.cur = _val;
-                            commState.keyDone = true;
-                        }
-
-                        byte[] _val = commState.getByteArray(null);
-
-                        if (!commState.lastRead())
-                            return false;
-
-                        blocks.put((GridGgfsBlockKey)commState.cur, _val);
-
-                        commState.keyDone = false;
-
-                        commState.readItems++;
-                    }
-                }
-
-                commState.readSize = -1;
-                commState.readItems = 0;
-                commState.cur = null;
+                if (!reader.isLastRead())
+                    return false;
 
-                commState.idx++;
+                state++;
 
             case 1:
-                fileId = commState.getGridUuid("fileId");
+                fileId = reader.readIgniteUuid("fileId");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 2:
-                id = commState.getLong("id");
+                id = reader.readLong("id");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/159c1e84/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsCommunicationMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsCommunicationMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsCommunicationMessage.java
index b08d64a..860eb4c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsCommunicationMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsCommunicationMessage.java
@@ -54,13 +54,13 @@ public abstract class GridGgfsCommunicationMessage extends MessageAdapter {
 
     /** {@inheritDoc} */
     @Override public boolean writeTo(ByteBuffer buf) {
-        commState.setBuffer(buf);
+        writer.setBuffer(buf);
 
-        if (!commState.typeWritten) {
-            if (!commState.putByte(null, directType()))
+        if (!typeWritten) {
+            if (!writer.writeByte(null, directType()))
                 return false;
 
-            commState.typeWritten = true;
+            typeWritten = true;
         }
 
         return true;
@@ -68,7 +68,7 @@ public abstract class GridGgfsCommunicationMessage extends MessageAdapter {
 
     /** {@inheritDoc} */
     @Override public boolean readFrom(ByteBuffer buf) {
-        commState.setBuffer(buf);
+        reader.setBuffer(buf);
 
         return true;
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/159c1e84/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsDeleteMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsDeleteMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsDeleteMessage.java
index 6be821a..18ae5b5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsDeleteMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsDeleteMessage.java
@@ -130,30 +130,30 @@ public class GridGgfsDeleteMessage extends GridGgfsCommunicationMessage {
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean writeTo(ByteBuffer buf) {
-        commState.setBuffer(buf);
+        writer.setBuffer(buf);
 
         if (!super.writeTo(buf))
             return false;
 
-        if (!commState.typeWritten) {
-            if (!commState.putByte(null, directType()))
+        if (!typeWritten) {
+            if (!writer.writeByte(null, directType()))
                 return false;
 
-            commState.typeWritten = true;
+            typeWritten = true;
         }
 
-        switch (commState.idx) {
+        switch (state) {
             case 0:
-                if (!commState.putByteArray("errBytes", errBytes))
+                if (!writer.writeByteArray("errBytes", errBytes))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 1:
-                if (!commState.putGridUuid("id", id))
+                if (!writer.writeIgniteUuid("id", id))
                     return false;
 
-                commState.idx++;
+                state++;
 
         }
 
@@ -163,27 +163,27 @@ public class GridGgfsDeleteMessage extends GridGgfsCommunicationMessage {
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean readFrom(ByteBuffer buf) {
-        commState.setBuffer(buf);
+        reader.setBuffer(buf);
 
         if (!super.readFrom(buf))
             return false;
 
-        switch (commState.idx) {
+        switch (state) {
             case 0:
-                errBytes = commState.getByteArray("errBytes");
+                errBytes = reader.readByteArray("errBytes");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 1:
-                id = commState.getGridUuid("id");
+                id = reader.readIgniteUuid("id");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/159c1e84/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFileAffinityRange.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFileAffinityRange.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFileAffinityRange.java
index 04c822e..edd9d6a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFileAffinityRange.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFileAffinityRange.java
@@ -286,45 +286,45 @@ public class GridGgfsFileAffinityRange extends MessageAdapter implements Externa
     /** {@inheritDoc} */
     @SuppressWarnings("fallthrough")
     @Override public boolean writeTo(ByteBuffer buf) {
-        commState.setBuffer(buf);
+        writer.setBuffer(buf);
 
-        if (!commState.typeWritten) {
-            if (!commState.putByte(null, directType()))
+        if (!typeWritten) {
+            if (!writer.writeByte(null, directType()))
                 return false;
 
-            commState.typeWritten = true;
+            typeWritten = true;
         }
 
-        switch (commState.idx) {
+        switch (state) {
             case 0:
-                if (!commState.putGridUuid("affKey", affKey))
+                if (!writer.writeIgniteUuid("affKey", affKey))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 1:
-                if (!commState.putBoolean("done", done))
+                if (!writer.writeBoolean("done", done))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 2:
-                if (!commState.putLong("endOff", endOff))
+                if (!writer.writeLong("endOff", endOff))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 3:
-                if (!commState.putLong("startOff", startOff))
+                if (!writer.writeLong("startOff", startOff))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 4:
-                if (!commState.putInt("status", status))
+                if (!writer.writeInt("status", status))
                     return false;
 
-                commState.idx++;
+                state++;
 
         }
 
@@ -334,48 +334,48 @@ public class GridGgfsFileAffinityRange extends MessageAdapter implements Externa
     /** {@inheritDoc} */
     @SuppressWarnings("fallthrough")
     @Override public boolean readFrom(ByteBuffer buf) {
-        commState.setBuffer(buf);
+        reader.setBuffer(buf);
 
-        switch (commState.idx) {
+        switch (state) {
             case 0:
-                affKey = commState.getGridUuid("affKey");
+                affKey = reader.readIgniteUuid("affKey");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 1:
-                done = commState.getBoolean("done");
+                done = reader.readBoolean("done");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 2:
-                endOff = commState.getLong("endOff");
+                endOff = reader.readLong("endOff");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 3:
-                startOff = commState.getLong("startOff");
+                startOff = reader.readLong("startOff");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 4:
-                status = commState.getInt("status");
+                status = reader.readInt("status");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/159c1e84/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerRequest.java
index 3ecac2f..978a2d6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerRequest.java
@@ -101,51 +101,30 @@ public class GridGgfsFragmentizerRequest extends GridGgfsCommunicationMessage {
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean writeTo(ByteBuffer buf) {
-        commState.setBuffer(buf);
+        writer.setBuffer(buf);
 
         if (!super.writeTo(buf))
             return false;
 
-        if (!commState.typeWritten) {
-            if (!commState.putByte(null, directType()))
+        if (!typeWritten) {
+            if (!writer.writeByte(null, directType()))
                 return false;
 
-            commState.typeWritten = true;
+            typeWritten = true;
         }
 
-        switch (commState.idx) {
+        switch (state) {
             case 0:
-                if (!commState.putGridUuid("fileId", fileId))
+                if (!writer.writeIgniteUuid("fileId", fileId))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 1:
-                if (fragmentRanges != null) {
-                    if (commState.it == null) {
-                        if (!commState.putInt(null, fragmentRanges.size()))
-                            return false;
-
-                        commState.it = fragmentRanges.iterator();
-                    }
-
-                    while (commState.it.hasNext() || commState.cur != NULL) {
-                        if (commState.cur == NULL)
-                            commState.cur = commState.it.next();
-
-                        if (!commState.putMessage(null, (GridGgfsFileAffinityRange)commState.cur))
-                            return false;
-
-                        commState.cur = NULL;
-                    }
-
-                    commState.it = null;
-                } else {
-                    if (!commState.putInt(null, -1))
-                        return false;
-                }
+                if (!writer.writeCollection("fragmentRanges", fragmentRanges, GridGgfsFileAffinityRange.class))
+                    return false;
 
-                commState.idx++;
+                state++;
 
         }
 
@@ -155,49 +134,27 @@ public class GridGgfsFragmentizerRequest extends GridGgfsCommunicationMessage {
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean readFrom(ByteBuffer buf) {
-        commState.setBuffer(buf);
+        reader.setBuffer(buf);
 
         if (!super.readFrom(buf))
             return false;
 
-        switch (commState.idx) {
+        switch (state) {
             case 0:
-                fileId = commState.getGridUuid("fileId");
+                fileId = reader.readIgniteUuid("fileId");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 1:
-                if (commState.readSize == -1) {
-                    int _val = commState.getInt(null);
-
-                    if (!commState.lastRead())
-                        return false;
-                    commState.readSize = _val;
-                }
+                fragmentRanges = reader.readCollection("fragmentRanges", GridGgfsFileAffinityRange.class);
 
-                if (commState.readSize >= 0) {
-                    if (fragmentRanges == null)
-                        fragmentRanges = new ArrayList<>(commState.readSize);
-
-                    for (int i = commState.readItems; i < commState.readSize; i++) {
-                        GridGgfsFileAffinityRange _val = (GridGgfsFileAffinityRange)commState.getMessage(null);
-
-                        if (!commState.lastRead())
-                            return false;
-
-                        fragmentRanges.add((GridGgfsFileAffinityRange)_val);
-
-                        commState.readItems++;
-                    }
-                }
-
-                commState.readSize = -1;
-                commState.readItems = 0;
+                if (!reader.isLastRead())
+                    return false;
 
-                commState.idx++;
+                state++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/159c1e84/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerResponse.java
index a842e9c..5a90b3c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsFragmentizerResponse.java
@@ -76,24 +76,24 @@ public class GridGgfsFragmentizerResponse extends GridGgfsCommunicationMessage {
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean writeTo(ByteBuffer buf) {
-        commState.setBuffer(buf);
+        writer.setBuffer(buf);
 
         if (!super.writeTo(buf))
             return false;
 
-        if (!commState.typeWritten) {
-            if (!commState.putByte(null, directType()))
+        if (!typeWritten) {
+            if (!writer.writeByte(null, directType()))
                 return false;
 
-            commState.typeWritten = true;
+            typeWritten = true;
         }
 
-        switch (commState.idx) {
+        switch (state) {
             case 0:
-                if (!commState.putGridUuid("fileId", fileId))
+                if (!writer.writeIgniteUuid("fileId", fileId))
                     return false;
 
-                commState.idx++;
+                state++;
 
         }
 
@@ -103,19 +103,19 @@ public class GridGgfsFragmentizerResponse extends GridGgfsCommunicationMessage {
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean readFrom(ByteBuffer buf) {
-        commState.setBuffer(buf);
+        reader.setBuffer(buf);
 
         if (!super.readFrom(buf))
             return false;
 
-        switch (commState.idx) {
+        switch (state) {
             case 0:
-                fileId = commState.getGridUuid("fileId");
+                fileId = reader.readIgniteUuid("fileId");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/159c1e84/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsSyncMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsSyncMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsSyncMessage.java
index a632e02..c7c1e77 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsSyncMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/fs/GridGgfsSyncMessage.java
@@ -94,30 +94,30 @@ public class GridGgfsSyncMessage extends GridGgfsCommunicationMessage {
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean writeTo(ByteBuffer buf) {
-        commState.setBuffer(buf);
+        writer.setBuffer(buf);
 
         if (!super.writeTo(buf))
             return false;
 
-        if (!commState.typeWritten) {
-            if (!commState.putByte(null, directType()))
+        if (!typeWritten) {
+            if (!writer.writeByte(null, directType()))
                 return false;
 
-            commState.typeWritten = true;
+            typeWritten = true;
         }
 
-        switch (commState.idx) {
+        switch (state) {
             case 0:
-                if (!commState.putLong("order", order))
+                if (!writer.writeLong("order", order))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 1:
-                if (!commState.putBoolean("res", res))
+                if (!writer.writeBoolean("res", res))
                     return false;
 
-                commState.idx++;
+                state++;
 
         }
 
@@ -127,27 +127,27 @@ public class GridGgfsSyncMessage extends GridGgfsCommunicationMessage {
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean readFrom(ByteBuffer buf) {
-        commState.setBuffer(buf);
+        reader.setBuffer(buf);
 
         if (!super.readFrom(buf))
             return false;
 
-        switch (commState.idx) {
+        switch (state) {
             case 0:
-                order = commState.getLong("order");
+                order = reader.readLong("order");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 1:
-                res = commState.getBoolean("res");
+                res = reader.readBoolean("res");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/159c1e84/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java
index 6223639..71dfcf9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeRequestWrapper.java
@@ -65,13 +65,13 @@ public class GridClientHandshakeRequestWrapper extends MessageAdapter {
     @Override public boolean writeTo(ByteBuffer buf) {
         stream.setBuffer(buf);
 
-        if (!commState.typeWritten) {
+        if (!typeWritten) {
             if (!buf.hasRemaining())
                 return false;
 
             stream.writeByte(directType());
 
-            commState.typeWritten = true;
+            typeWritten = true;
         }
 
         stream.writeByteArray(bytes, 0, bytes.length);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/159c1e84/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java
index 57f2bd1..e598f66 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientHandshakeResponseWrapper.java
@@ -48,13 +48,13 @@ public class GridClientHandshakeResponseWrapper extends MessageAdapter {
 
     /** {@inheritDoc} */
     @Override public boolean writeTo(ByteBuffer buf) {
-        commState.setBuffer(buf);
+        writer.setBuffer(buf);
 
-        if (!commState.typeWritten) {
-            if (!commState.putByte(null, directType()))
+        if (!typeWritten) {
+            if (!writer.writeByte(null, directType()))
                 return false;
 
-            commState.typeWritten = true;
+            typeWritten = true;
         }
 
         return true;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/159c1e84/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMessageWrapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMessageWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMessageWrapper.java
index 4d40c3e..746a40f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMessageWrapper.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientMessageWrapper.java
@@ -136,23 +136,23 @@ public class GridClientMessageWrapper extends MessageAdapter {
     @Override public boolean writeTo(ByteBuffer buf) {
         stream.setBuffer(buf);
 
-        if (!commState.typeWritten) {
+        if (!typeWritten) {
             if (stream.remaining() < 1)
                 return false;
 
             stream.writeByte(directType());
 
-            commState.typeWritten = true;
+            typeWritten = true;
         }
 
-        switch (commState.idx) {
+        switch (state) {
             case 0:
                 if (stream.remaining() < 4)
                     return false;
 
                 stream.writeInt(msgSize);
 
-                commState.idx++;
+                state++;
 
             case 1:
                 if (stream.remaining() < 8)
@@ -160,7 +160,7 @@ public class GridClientMessageWrapper extends MessageAdapter {
 
                 stream.writeLong(reqId);
 
-                commState.idx++;
+                state++;
 
             case 2:
                 if (stream.remaining() < 16)
@@ -168,7 +168,7 @@ public class GridClientMessageWrapper extends MessageAdapter {
 
                 stream.writeByteArray(U.uuidToBytes(clientId), 0, 16);
 
-                commState.idx++;
+                state++;
 
             case 3:
                 if (stream.remaining() < 16)
@@ -176,12 +176,12 @@ public class GridClientMessageWrapper extends MessageAdapter {
 
                 stream.writeByteArray(U.uuidToBytes(destId), 0, 16);
 
-                commState.idx++;
+                state++;
 
             case 4:
                 stream.writeByteArray(msg.array(), msg.position(), msg.remaining());
 
-                commState.idx++;
+                state++;
 
         }
 
@@ -192,7 +192,7 @@ public class GridClientMessageWrapper extends MessageAdapter {
     @Override public boolean readFrom(ByteBuffer buf) {
         stream.setBuffer(buf);
 
-        switch (commState.idx) {
+        switch (state) {
             case 0:
                 if (stream.remaining() < 4)
                     return false;
@@ -202,7 +202,7 @@ public class GridClientMessageWrapper extends MessageAdapter {
                 if (msgSize == 0) // Ping message.
                     return true;
 
-                commState.idx++;
+                state++;
 
             case 1:
                 if (stream.remaining() < 8)
@@ -210,7 +210,7 @@ public class GridClientMessageWrapper extends MessageAdapter {
 
                 reqId = stream.readLong();
 
-                commState.idx++;
+                state++;
 
             case 2:
                 if (stream.remaining() < 16)
@@ -218,7 +218,7 @@ public class GridClientMessageWrapper extends MessageAdapter {
 
                 clientId = U.bytesToUuid(stream.readByteArray(16), 0);
 
-                commState.idx++;
+                state++;
 
             case 3:
                 if (stream.remaining() < 16)
@@ -226,7 +226,7 @@ public class GridClientMessageWrapper extends MessageAdapter {
 
                 destId = U.bytesToUuid(stream.readByteArray(16), 0);
 
-                commState.idx++;
+                state++;
 
             case 4:
                 byte[] msg0 = stream.readByteArray(msgSize);
@@ -236,7 +236,7 @@ public class GridClientMessageWrapper extends MessageAdapter {
 
                 msg = ByteBuffer.wrap(msg0);
 
-                commState.idx++;
+                state++;
         }
 
         return true;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/159c1e84/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacketWrapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacketWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacketWrapper.java
index be95367..ca8e804 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacketWrapper.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/client/message/GridClientPingPacketWrapper.java
@@ -34,21 +34,21 @@ public class GridClientPingPacketWrapper extends MessageAdapter {
 
     /** {@inheritDoc} */
     @Override public boolean writeTo(ByteBuffer buf) {
-        commState.setBuffer(buf);
+        writer.setBuffer(buf);
 
-        if (!commState.typeWritten) {
-            if (!commState.putByte(null, directType()))
+        if (!typeWritten) {
+            if (!writer.writeByte(null, directType()))
                 return false;
 
-            commState.typeWritten = true;
+            typeWritten = true;
         }
 
-        switch (commState.idx) {
+        switch (state) {
             case 0:
-                if (!commState.putInt("size", size))
+                if (!writer.writeInt("size", size))
                     return false;
 
-                commState.idx++;
+                state++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/159c1e84/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultRequest.java
index 8df3008..637fa80 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultRequest.java
@@ -120,27 +120,27 @@ public class GridTaskResultRequest extends MessageAdapter {
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean writeTo(ByteBuffer buf) {
-        commState.setBuffer(buf);
+        writer.setBuffer(buf);
 
-        if (!commState.typeWritten) {
-            if (!commState.putByte(null, directType()))
+        if (!typeWritten) {
+            if (!writer.writeByte(null, directType()))
                 return false;
 
-            commState.typeWritten = true;
+            typeWritten = true;
         }
 
-        switch (commState.idx) {
+        switch (state) {
             case 0:
-                if (!commState.putGridUuid("taskId", taskId))
+                if (!writer.writeIgniteUuid("taskId", taskId))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 1:
-                if (!commState.putByteArray("topicBytes", topicBytes))
+                if (!writer.writeByteArray("topicBytes", topicBytes))
                     return false;
 
-                commState.idx++;
+                state++;
 
         }
 
@@ -150,24 +150,24 @@ public class GridTaskResultRequest extends MessageAdapter {
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean readFrom(ByteBuffer buf) {
-        commState.setBuffer(buf);
+        reader.setBuffer(buf);
 
-        switch (commState.idx) {
+        switch (state) {
             case 0:
-                taskId = commState.getGridUuid("taskId");
+                taskId = reader.readIgniteUuid("taskId");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 1:
-                topicBytes = commState.getByteArray("topicBytes");
+                topicBytes = reader.readByteArray("topicBytes");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/159c1e84/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java
index 6808f1a..384cfb3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskResultResponse.java
@@ -140,39 +140,39 @@ public class GridTaskResultResponse extends MessageAdapter {
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean writeTo(ByteBuffer buf) {
-        commState.setBuffer(buf);
+        writer.setBuffer(buf);
 
-        if (!commState.typeWritten) {
-            if (!commState.putByte(null, directType()))
+        if (!typeWritten) {
+            if (!writer.writeByte(null, directType()))
                 return false;
 
-            commState.typeWritten = true;
+            typeWritten = true;
         }
 
-        switch (commState.idx) {
+        switch (state) {
             case 0:
-                if (!commState.putString("err", err))
+                if (!writer.writeString("err", err))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 1:
-                if (!commState.putBoolean("finished", finished))
+                if (!writer.writeBoolean("finished", finished))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 2:
-                if (!commState.putBoolean("found", found))
+                if (!writer.writeBoolean("found", found))
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 3:
-                if (!commState.putByteArray("resBytes", resBytes))
+                if (!writer.writeByteArray("resBytes", resBytes))
                     return false;
 
-                commState.idx++;
+                state++;
 
         }
 
@@ -182,40 +182,40 @@ public class GridTaskResultResponse extends MessageAdapter {
     /** {@inheritDoc} */
     @SuppressWarnings("all")
     @Override public boolean readFrom(ByteBuffer buf) {
-        commState.setBuffer(buf);
+        reader.setBuffer(buf);
 
-        switch (commState.idx) {
+        switch (state) {
             case 0:
-                err = commState.getString("err");
+                err = reader.readString("err");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 1:
-                finished = commState.getBoolean("finished");
+                finished = reader.readBoolean("finished");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 2:
-                found = commState.getBoolean("found");
+                found = reader.readBoolean("found");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
             case 3:
-                resBytes = commState.getByteArray("resBytes");
+                resBytes = reader.readByteArray("resBytes");
 
-                if (!commState.lastRead())
+                if (!reader.isLastRead())
                     return false;
 
-                commState.idx++;
+                state++;
 
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/159c1e84/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java
index ae0d638..d086efe 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridMemcachedMessageWrapper.java
@@ -69,13 +69,13 @@ public class GridMemcachedMessageWrapper extends MessageAdapter {
     @Override public boolean writeTo(ByteBuffer buf) {
         stream.setBuffer(buf);
 
-        if (!commState.typeWritten) {
+        if (!typeWritten) {
             if (!buf.hasRemaining())
                 return false;
 
             stream.writeByte(directType());
 
-            commState.typeWritten = true;
+            typeWritten = true;
         }
 
         stream.writeByteArray(bytes, 0, bytes.length);


Mime
View raw message