ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject ignite git commit: IGNITE-1651: WIP.
Date Wed, 21 Oct 2015 12:13:50 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-1651 [created] 82113575f


IGNITE-1651: WIP.


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

Branch: refs/heads/ignite-1651
Commit: 82113575fe21631d3542d243260c5b6c6451e06b
Parents: 3a29b97
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Wed Oct 21 15:14:24 2015 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Wed Oct 21 15:14:24 2015 +0300

----------------------------------------------------------------------
 .../internal/portable/GridPortableMarshaller.java | 18 ++++++++++++------
 .../portable/PortableClassDescriptor.java         |  1 +
 .../internal/portable/PortableReaderExImpl.java   |  4 ++++
 .../ignite/internal/portable/PortableUtils.java   | 13 +++++++++++++
 .../portable/builder/PortableBuilderImpl.java     |  7 +++++++
 .../portable/builder/PortableBuilderReader.java   |  8 ++++++++
 6 files changed, 45 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/82113575/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java
b/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java
index 4bc8545..6aaccf7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java
@@ -186,23 +186,29 @@ public class GridPortableMarshaller {
     /** */
     public static final int UNREGISTERED_TYPE_ID = 0;
 
+    /** Protocol version. */
+    public static final byte PROTO_VER = 1;
+
+    /** Protocol version position. */
+    public static final int PROTO_VER_POS = 1;
+
     /** */
-    public static final int TYPE_ID_POS = 2;
+    public static final int TYPE_ID_POS = 3;
 
     /** */
-    public static final int HASH_CODE_POS = 6;
+    public static final int HASH_CODE_POS = 7;
 
     /** */
-    public static final int TOTAL_LEN_POS = 10;
+    public static final int TOTAL_LEN_POS = 11;
 
     /** */
-    public static final byte RAW_DATA_OFF_POS = 14;
+    public static final byte RAW_DATA_OFF_POS = 15;
 
     /** */
-    public static final int CLS_NAME_POS = 18;
+    public static final int CLS_NAME_POS = 19;
 
     /** */
-    public static final byte DFLT_HDR_LEN = 18;
+    public static final byte DFLT_HDR_LEN = 19;
 
     /** */
     private final PortableContext ctx;

http://git-wip-us.apache.org/repos/asf/ignite/blob/82113575/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
index e1b7324..16fe91b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
@@ -653,6 +653,7 @@ public class PortableClassDescriptor {
         int pos = writer.position();
 
         writer.doWriteByte(GridPortableMarshaller.OBJ);
+        writer.doWriteByte(GridPortableMarshaller.PROTO_VER);
         writer.doWriteBoolean(userType);
         writer.doWriteInt(registered ? typeId : GridPortableMarshaller.UNREGISTERED_TYPE_ID);
         writer.doWriteInt(obj instanceof CacheObjectImpl ? 0 : obj.hashCode());

http://git-wip-us.apache.org/repos/asf/ignite/blob/82113575/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java
index a101db5..3004dde 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java
@@ -1737,6 +1737,8 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
                 return unmarshal(false);
 
             case OBJ:
+                PortableUtils.checkProtocolVersion(doReadByte(raw));
+
                 PortableObjectEx po;
 
                 if (detach) {
@@ -2143,6 +2145,8 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
 
                 assert typeId != UNREGISTERED_TYPE_ID;
 
+                PortableUtils.checkProtocolVersion(doReadByte(true));
+
                 boolean userType = doReadBoolean(true);
 
                 // Skip typeId and hash code.

http://git-wip-us.apache.org/repos/asf/ignite/blob/82113575/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
index ccc1a5b..d9e5f47 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
@@ -33,6 +33,8 @@ import java.util.TreeSet;
 import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentSkipListSet;
+
+import org.apache.ignite.internal.portable.api.PortableException;
 import org.apache.ignite.internal.portable.builder.PortableLazyValue;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.internal.portable.api.PortableObject;
@@ -64,6 +66,7 @@ import static org.apache.ignite.internal.portable.GridPortableMarshaller.MAP;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.NULL;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.OBJ;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.OBJ_ARR;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.PROTO_VER;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.SHORT;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.SHORT_ARR;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.STRING;
@@ -466,4 +469,14 @@ public class PortableUtils {
 
         return U.newHashSet(set.size());
     }
+
+    /**
+     * Check protocol version.
+     *
+     * @param protoVer Protocol version.
+     */
+    public static void checkProtocolVersion(byte protoVer) {
+        if (PROTO_VER != protoVer)
+            throw new PortableException("Unsupported protocol version: " + protoVer);
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/82113575/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderImpl.java
index 96d10a2..32bccf8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderImpl.java
@@ -36,6 +36,8 @@ import org.apache.ignite.internal.portable.*;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.CLS_NAME_POS;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.DFLT_HDR_LEN;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.HASH_CODE_POS;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.PROTO_VER;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.PROTO_VER_POS;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.RAW_DATA_OFF_POS;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.TOTAL_LEN_POS;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.TYPE_ID_POS;
@@ -133,6 +135,10 @@ public class PortableBuilderImpl implements PortableBuilder {
         this.reader = reader;
         this.start = start;
 
+        byte ver = reader.readByteAbsolute(start + PROTO_VER_POS);
+
+        PortableUtils.checkProtocolVersion(ver);
+
         int typeId = reader.readIntAbsolute(start + TYPE_ID_POS);
         ctx = reader.portableContext();
         hashCode = reader.readIntAbsolute(start + HASH_CODE_POS);
@@ -190,6 +196,7 @@ public class PortableBuilderImpl implements PortableBuilder {
      */
     void serializeTo(PortableWriterExImpl writer, PortableBuilderSerializer serializer) {
         writer.doWriteByte(GridPortableMarshaller.OBJ);
+        writer.doWriteByte(PROTO_VER);
         writer.doWriteBoolean(true);
         writer.doWriteInt(registeredType ? typeId : UNREGISTERED_TYPE_ID);
         writer.doWriteInt(hashCode);

http://git-wip-us.apache.org/repos/asf/ignite/blob/82113575/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java
b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java
index e93f860..2f9e97f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java
@@ -124,6 +124,14 @@ class PortableBuilderReader {
 
     /**
      * @param pos Position in the source array.
+     * @return Read byte value.
+     */
+    public byte readByteAbsolute(int pos) {
+        return PRIM.readByte(arr, pos);
+    }
+
+    /**
+     * @param pos Position in the source array.
      * @return Read int value.
      */
     public int readIntAbsolute(int pos) {


Mime
View raw message