You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2015/11/25 09:28:56 UTC
[1/3] ignite git commit: IGNITE-1983 Platforms: fixed a problem with
incorrect reader behavior for platform streams.
Repository: ignite
Updated Branches:
refs/heads/ignite-1956 ebf909d93 -> 462f8e618
IGNITE-1983 Platforms: fixed a problem with incorrect reader behavior for platform streams.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c40ab677
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c40ab677
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c40ab677
Branch: refs/heads/ignite-1956
Commit: c40ab677e69f0d756281c62549cb2f63de907ed6
Parents: dafad52
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Wed Nov 25 10:14:26 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Nov 25 10:14:26 2015 +0300
----------------------------------------------------------------------
.../internal/portable/BinaryReaderExImpl.java | 18 +++++++++++++++---
.../processors/platform/PlatformContextImpl.java | 2 +-
2 files changed, 16 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/c40ab677/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
index 4809c3c..872d7a3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
@@ -162,6 +162,20 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Bina
*/
public BinaryReaderExImpl(PortableContext ctx, PortableInputStream in, ClassLoader ldr,
@Nullable BinaryReaderHandles hnds) {
+ this(ctx, in, ldr, hnds, false);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param ctx Context.
+ * @param in Input stream.
+ * @param ldr Class loader.
+ * @param hnds Context.
+ * @param skipHdrCheck Whether to skip header check.
+ */
+ public BinaryReaderExImpl(PortableContext ctx, PortableInputStream in, ClassLoader ldr,
+ @Nullable BinaryReaderHandles hnds, boolean skipHdrCheck) {
// Initialize base members.
this.ctx = ctx;
this.in = in;
@@ -170,10 +184,8 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Bina
start = in.position();
- byte hdr = in.readByte();
-
// Perform full header parsing in case of portable object.
- if (hdr == GridPortableMarshaller.OBJ) {
+ if (!skipHdrCheck && (in.readByte() == GridPortableMarshaller.OBJ)) {
// Ensure protocol is fine.
PortableUtils.checkProtocolVersion(in.readByte());
http://git-wip-us.apache.org/repos/asf/ignite/blob/c40ab677/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
index 9a7f0df..7db752a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
@@ -177,7 +177,7 @@ public class PlatformContextImpl implements PlatformContext {
/** {@inheritDoc} */
@Override public BinaryRawReaderEx reader(PlatformInputStream in) {
// TODO: IGNITE-1272 - Is class loader needed here?
- return new BinaryReaderExImpl(marsh.context(), in, null);
+ return new BinaryReaderExImpl(marsh.context(), in, null, null, true);
}
/** {@inheritDoc} */
[2/3] ignite git commit: Merge branch 'ignite-1.5' into ignite-1956
Posted by vo...@apache.org.
Merge branch 'ignite-1.5' into ignite-1956
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b4d7a114
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b4d7a114
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b4d7a114
Branch: refs/heads/ignite-1956
Commit: b4d7a114900b75cac16bb6cfac37925f0b1d1efe
Parents: ebf909d c40ab67
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Nov 25 11:11:24 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Nov 25 11:11:24 2015 +0300
----------------------------------------------------------------------
.../internal/portable/BinaryReaderExImpl.java | 18 +++++++++++++++---
.../processors/platform/PlatformContextImpl.java | 2 +-
2 files changed, 16 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/b4d7a114/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
----------------------------------------------------------------------
[3/3] ignite git commit: IGNITE-1956: Added tests.
Posted by vo...@apache.org.
IGNITE-1956: Added tests.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/462f8e61
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/462f8e61
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/462f8e61
Branch: refs/heads/ignite-1956
Commit: 462f8e6181709da791a4aece64ddb49fb94daaf9
Parents: b4d7a11
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Nov 25 11:29:34 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Nov 25 11:29:34 2015 +0300
----------------------------------------------------------------------
.../internal/portable/BinaryEnumsSelfTest.java | 124 +++++++++++++++++--
1 file changed, 111 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/462f8e61/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 84d9423..203f723 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
@@ -28,6 +28,7 @@ import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import java.io.Serializable;
import java.util.Arrays;
/**
@@ -131,6 +132,24 @@ public class BinaryEnumsSelfTest extends GridCommonAbstractTest {
}
/**
+ * Test operations when enum is nested into an object (registered).
+ *
+ * @throws Exception If failed.
+ */
+ public void testNestedRegistered() throws Exception {
+ checkNested(true);
+ }
+
+ /**
+ * Test operations when enum is nested into an object (not registered).
+ *
+ * @throws Exception If failed.
+ */
+ public void testNestedNotRegistered() throws Exception {
+ checkNested(false);
+ }
+
+ /**
* Test builder operations on simple type which is registered in advance.
*
* @throws Exception If failed.
@@ -149,6 +168,24 @@ public class BinaryEnumsSelfTest extends GridCommonAbstractTest {
}
/**
+ * Test builder operations when enum is nested into an object (registered).
+ *
+ * @throws Exception If failed.
+ */
+ public void testNestedBuilderRegistered() throws Exception {
+ checkNestedBuilder(true);
+ }
+
+ /**
+ * Test builder operations when enum is nested into an object (not registered).
+ *
+ * @throws Exception If failed.
+ */
+ public void testNestedBuilderNotRegistered() throws Exception {
+ checkNestedBuilder(false);
+ }
+
+ /**
* Check simple serialization - deserialization.
*
* @param registered If type should be registered in advance.
@@ -159,7 +196,65 @@ public class BinaryEnumsSelfTest extends GridCommonAbstractTest {
cache1.put(1, EnumType.ONE);
- validateSimple();
+ validateSimple(1, EnumType.ONE);
+ }
+
+ /**
+ * Check nested serialization - deserialization.
+ *
+ * @param registered If type should be registered in advance.
+ * @throws Exception If failed.
+ */
+ private void checkNested(boolean registered) throws Exception {
+ startUp(registered);
+
+ cache1.put(1, new EnumHolder(EnumType.ONE));
+
+ validateNested(1, EnumType.ONE);
+ }
+
+ /**
+ * Check nested builder serialization - deserialization.
+ *
+ * @param registered If type should be registered in advance.
+ * @throws Exception If failed.
+ */
+ private void checkNestedBuilder(boolean registered) throws Exception {
+ startUp(registered);
+
+ BinaryObject obj = node1.binary().builder("EnumHolder").setField("val", EnumType.ONE).build();
+
+ cacheBinary1.put(1, obj);
+
+ validateNested(1, EnumType.ONE);
+
+ obj = (BinaryObject)cacheBinary1.get(1);
+ obj = node1.binary().builder(obj).setField("val", EnumType.TWO).build();
+
+ cacheBinary1.put(1, obj);
+
+ validateNested(1, EnumType.TWO);
+ }
+
+ /**
+ * Validate nested object.
+ *
+ * @param key Key.
+ * @param val Value.
+ * @throws Exception If failed.
+ */
+ private void validateNested(int key, EnumType val) throws Exception {
+ EnumHolder res1 = (EnumHolder)cache1.get(key);
+ EnumHolder res2 = (EnumHolder)cache2.get(key);
+
+ assertEquals(val, res1.val);
+ assertEquals(val, res2.val);
+
+ BinaryObject resBinary1 = (BinaryObject)cacheBinary1.get(key);
+ BinaryObject resBinary2 = (BinaryObject)cacheBinary2.get(key);
+
+ validate((BinaryObject)resBinary1.field("val"), val);
+ validate((BinaryObject)resBinary2.field("val"), val);
}
/**
@@ -175,7 +270,7 @@ public class BinaryEnumsSelfTest extends GridCommonAbstractTest {
cacheBinary1.put(1, binary);
- validateSimple();
+ validateSimple(1, EnumType.ONE);
}
/**
@@ -267,24 +362,26 @@ public class BinaryEnumsSelfTest extends GridCommonAbstractTest {
assertEquals(2, arr1.length);
assertEquals(2, arr2.length);
- validateValue((BinaryObject)arrBinary1[0], EnumType.ONE);
- validateValue((BinaryObject)arrBinary1[1], EnumType.TWO);
+ validate((BinaryObject) arrBinary1[0], EnumType.ONE);
+ validate((BinaryObject) arrBinary1[1], EnumType.TWO);
- validateValue((BinaryObject)arrBinary2[0], EnumType.ONE);
- validateValue((BinaryObject)arrBinary2[1], EnumType.TWO);
+ validate((BinaryObject) arrBinary2[0], EnumType.ONE);
+ validate((BinaryObject) arrBinary2[1], EnumType.TWO);
}
/**
* Internal check routine for simple scenario.
*
+ * @param key Key.
+ * @param val Value.
* @throws Exception If failed.
*/
- private void validateSimple() throws Exception {
- assertEquals(EnumType.ONE, cache1.get(1));
- assertEquals(EnumType.ONE, cache2.get(1));
+ private void validateSimple(int key, EnumType val) throws Exception {
+ assertEquals(val, cache1.get(key));
+ assertEquals(val, cache2.get(key));
- validateValue((BinaryObject)cacheBinary1.get(1), EnumType.ONE);
- validateValue((BinaryObject)cacheBinary2.get(1), EnumType.ONE);
+ validate((BinaryObject) cacheBinary1.get(key), val);
+ validate((BinaryObject) cacheBinary2.get(key), val);
}
/**
@@ -293,7 +390,7 @@ public class BinaryEnumsSelfTest extends GridCommonAbstractTest {
* @param obj Binary value.
* @param val Expected value.
*/
- private void validateValue(BinaryObject obj, EnumType val) {
+ private void validate(BinaryObject obj, EnumType val) {
assertTrue(obj.type().isEnum());
assertEquals(node1.binary().typeId(EnumType.class.getName()), obj.typeId());
@@ -305,13 +402,14 @@ public class BinaryEnumsSelfTest extends GridCommonAbstractTest {
/**
* Enumeration holder.
*/
- public static class EnumHolder {
+ public static class EnumHolder implements Serializable {
/** Value. */
public EnumType val;
/**
* Default constructor.
*/
+ @SuppressWarnings("UnusedDeclaration")
public EnumHolder() {
// No-op.
}