ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ag...@apache.org
Subject [17/50] [abbrv] ignite git commit: IGNITE-3477 - Fixed direct marshallable code
Date Fri, 14 Apr 2017 15:13:34 GMT
IGNITE-3477 - Fixed direct marshallable code


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b6b3d375
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b6b3d375
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b6b3d375

Branch: refs/heads/ignite-4587
Commit: b6b3d3754849aa54626befe2375cbc88cbebfab9
Parents: faaf92d
Author: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Authored: Thu Apr 13 19:16:23 2017 +0300
Committer: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Committed: Thu Apr 13 20:56:59 2017 +0300

----------------------------------------------------------------------
 .../cache/binary/MetadataRequestMessage.java    |  2 ++
 .../cache/binary/MetadataResponseMessage.java   | 36 +++++++++++++++-----
 2 files changed, 30 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b6b3d375/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/MetadataRequestMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/MetadataRequestMessage.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/MetadataRequestMessage.java
index 87bf805..b34acd8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/MetadataRequestMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/MetadataRequestMessage.java
@@ -70,6 +70,7 @@ public class MetadataRequestMessage implements Message {
                     return false;
 
                 writer.incrementState();
+
         }
 
         return true;
@@ -90,6 +91,7 @@ public class MetadataRequestMessage implements Message {
                     return false;
 
                 reader.incrementState();
+
         }
 
         return reader.afterMessageRead(MetadataRequestMessage.class);

http://git-wip-us.apache.org/repos/asf/ignite/blob/b6b3d375/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/MetadataResponseMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/MetadataResponseMessage.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/MetadataResponseMessage.java
index bb3d3a3..6ff4fd8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/MetadataResponseMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/MetadataResponseMessage.java
@@ -63,22 +63,23 @@ public class MetadataResponseMessage implements Message {
 
         switch (writer.state()) {
             case 0:
-                if (!writer.writeInt("typeId", typeId))
+                if (!writer.writeByteArray("binaryMetadataBytes", binaryMetadataBytes))
                     return false;
 
                 writer.incrementState();
 
             case 1:
-                if (!writer.writeInt("status", status.ordinal()))
+                if (!writer.writeByte("status", status != null ? (byte)status.ordinal() :
-1))
                     return false;
 
                 writer.incrementState();
 
             case 2:
-                if (!writer.writeByteArray("binMetaBytes", binaryMetadataBytes))
+                if (!writer.writeInt("typeId", typeId))
                     return false;
 
                 writer.incrementState();
+
         }
 
         return true;
@@ -93,7 +94,7 @@ public class MetadataResponseMessage implements Message {
 
         switch (reader.state()) {
             case 0:
-                typeId = reader.readInt("typeId");
+                binaryMetadataBytes = reader.readByteArray("binaryMetadataBytes");
 
                 if (!reader.isLastRead())
                     return false;
@@ -101,18 +102,25 @@ public class MetadataResponseMessage implements Message {
                 reader.incrementState();
 
             case 1:
-                status = ClientResponseStatus.values()[reader.readInt("status")];
+                byte statusOrd;
+
+                statusOrd = reader.readByte("status");
 
                 if (!reader.isLastRead())
                     return false;
 
+                status = ClientResponseStatus.fromOrdinal(statusOrd);
+
                 reader.incrementState();
 
             case 2:
-                binaryMetadataBytes = reader.readByteArray("binMetaBytes");
+                typeId = reader.readInt("typeId");
 
                 if (!reader.isLastRead())
                     return false;
+
+                reader.incrementState();
+
         }
 
         return reader.afterMessageRead(MetadataResponseMessage.class);
@@ -131,7 +139,6 @@ public class MetadataResponseMessage implements Message {
     /** {@inheritDoc} */
     @Override public void onAckReceived() {
         // No-op.
-
     }
 
     /**
@@ -185,7 +192,20 @@ public class MetadataResponseMessage implements Message {
         METADATA_NOT_FOUND,
 
         /** */
-        ERROR
+        ERROR;
+
+        /** Enumerated values. */
+        private static final ClientResponseStatus[] VALS = values();
+
+        /**
+         * Efficiently gets enumerated value from its ordinal.
+         *
+         * @param ord Ordinal value.
+         * @return Enumerated value.
+         */
+        public static ClientResponseStatus fromOrdinal(byte ord) {
+            return ord >= 0 && ord < VALS.length ? VALS[ord] : null;
+        }
     }
 
     /** {@inheritDoc} */


Mime
View raw message