ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [2/4] ignite git commit: IGNITE-1956: Tests start passing.
Date Tue, 24 Nov 2015 14:48:58 GMT
IGNITE-1956: Tests start passing.


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

Branch: refs/heads/ignite-1956
Commit: 642218dccbd5aff7a2cb1a4489d80cb2cf3bc113
Parents: ed3bd2b
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Tue Nov 24 16:50:39 2015 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Tue Nov 24 16:50:39 2015 +0300

----------------------------------------------------------------------
 .../communication/GridIoMessageFactory.java     |  8 ++-
 .../internal/portable/BinaryEnumObjectImpl.java | 76 +++++++++++++++++---
 .../internal/portable/BinaryEnumsSelfTest.java  | 10 +--
 3 files changed, 81 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/642218dc/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java
b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java
index 02bd5ec..c9b8e27 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java
@@ -31,6 +31,7 @@ import org.apache.ignite.internal.managers.deployment.GridDeploymentInfoBean;
 import org.apache.ignite.internal.managers.deployment.GridDeploymentRequest;
 import org.apache.ignite.internal.managers.deployment.GridDeploymentResponse;
 import org.apache.ignite.internal.managers.eventstorage.GridEventStorageMessage;
+import org.apache.ignite.internal.portable.BinaryEnumObjectImpl;
 import org.apache.ignite.internal.portable.BinaryObjectImpl;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.cache.CacheEntryInfoCollection;
@@ -714,7 +715,12 @@ public class GridIoMessageFactory implements MessageFactory {
 
                 break;
 
-            // [-3..118] - this
+            case 119:
+                msg = new BinaryEnumObjectImpl();
+
+                break;
+
+            // [-3..119] - this
             // [120..123] - DR
             // [-4..-22] - SQL
             default:

http://git-wip-us.apache.org/repos/asf/ignite/blob/642218dc/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryEnumObjectImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryEnumObjectImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryEnumObjectImpl.java
index 66b080a..fe2dea7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryEnumObjectImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryEnumObjectImpl.java
@@ -21,6 +21,7 @@ import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.binary.BinaryObject;
 import org.apache.ignite.binary.BinaryObjectException;
 import org.apache.ignite.binary.BinaryType;
+import org.apache.ignite.internal.GridDirectTransient;
 import org.apache.ignite.internal.processors.cache.CacheObject;
 import org.apache.ignite.internal.processors.cache.CacheObjectContext;
 import org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessorImpl;
@@ -40,6 +41,7 @@ import java.nio.ByteBuffer;
  */
 public class BinaryEnumObjectImpl implements BinaryObject, Externalizable, CacheObject {
     /** Context. */
+    @GridDirectTransient
     private PortableContext ctx;
 
     /** Type ID. */
@@ -224,25 +226,83 @@ public class BinaryEnumObjectImpl implements BinaryObject, Externalizable,
Cache
 
     /** {@inheritDoc} */
     @Override public byte directType() {
-        // TODO
-        return 0;
+        return 119;
     }
 
     /** {@inheritDoc} */
     @Override public byte fieldsCount() {
-        // TODO
-        return 0;
+        return 3;
     }
 
     /** {@inheritDoc} */
     @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
-        // TODO
-        return false;
+        writer.setBuffer(buf);
+
+        if (!writer.isHeaderWritten()) {
+            if (!writer.writeHeader(directType(), fieldsCount()))
+                return false;
+
+            writer.onHeaderWritten();
+        }
+
+        switch (writer.state()) {
+            case 0:
+                if (!writer.writeString("clsName", clsName))
+                    return false;
+
+                writer.incrementState();
+
+            case 1:
+                if (!writer.writeInt("ord", ord))
+                    return false;
+
+                writer.incrementState();
+
+            case 2:
+                if (!writer.writeInt("typeId", typeId))
+                    return false;
+
+                writer.incrementState();
+
+        }
+
+        return true;
     }
 
     /** {@inheritDoc} */
     @Override public boolean readFrom(ByteBuffer buf, MessageReader reader) {
-        // TODO
-        return false;
+        reader.setBuffer(buf);
+
+        if (!reader.beforeMessageRead())
+            return false;
+
+        switch (reader.state()) {
+            case 0:
+                clsName = reader.readString("clsName");
+
+                if (!reader.isLastRead())
+                    return false;
+
+                reader.incrementState();
+
+            case 1:
+                ord = reader.readInt("ord");
+
+                if (!reader.isLastRead())
+                    return false;
+
+                reader.incrementState();
+
+            case 2:
+                typeId = reader.readInt("typeId");
+
+                if (!reader.isLastRead())
+                    return false;
+
+                reader.incrementState();
+
+        }
+
+        return reader.afterMessageRead(BinaryEnumObjectImpl.class);
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/642218dc/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryEnumsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryEnumsSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryEnumsSelfTest.java
index 3abf436..9b2cb84 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryEnumsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryEnumsSelfTest.java
@@ -120,10 +120,6 @@ public class BinaryEnumsSelfTest extends GridCommonAbstractTest {
     public void testSimpleRegistered() throws Exception{
         startUp(true);
 
-        cache1.put(0, new EnumHolder(EnumType.ONE));
-
-        Object res = cache1.get(0);
-
         cache1.put(1, EnumType.ONE);
 
         assertEquals(EnumType.ONE, cache1.get(1));
@@ -134,6 +130,12 @@ public class BinaryEnumsSelfTest extends GridCommonAbstractTest {
         assertTrue(obj.type().isEnum());
         assertEquals(node1.binary().typeId(EnumType.class.getName()), obj.typeId());
         assertEquals(EnumType.ONE.ordinal(), obj.enumOrdinal());
+
+        obj = cacheBinary2.get(1);
+
+        assertTrue(obj.type().isEnum());
+        assertEquals(node1.binary().typeId(EnumType.class.getName()), obj.typeId());
+        assertEquals(EnumType.ONE.ordinal(), obj.enumOrdinal());
     }
 
     /**


Mime
View raw message