ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [04/14] ignite git commit: ignite-1273: fixes in metadata impl
Date Tue, 01 Sep 2015 13:40:51 GMT
ignite-1273: fixes in metadata impl


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

Branch: refs/heads/ignite-1273
Commit: df0aa2f5450c68e366de90236077d49183fb19b3
Parents: 8ffe7af
Author: Denis Magda <dmagda@gridgain.com>
Authored: Mon Aug 31 14:31:25 2015 +0300
Committer: Denis Magda <dmagda@gridgain.com>
Committed: Mon Aug 31 14:31:25 2015 +0300

----------------------------------------------------------------------
 .../ignite/internal/portable/PortableContext.java  |  5 ++++-
 .../GridPortableMetaDataDisabledSelfTest.java      | 16 ++++++++++++++++
 .../portable/GridPortableMetaDataSelfTest.java     | 17 +++++++++++++++++
 ...cheClientNodePortableMetadataMultinodeTest.java | 11 +++++++++++
 4 files changed, 48 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/df0aa2f5/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
index e5f48f1..483f1dc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
@@ -521,6 +521,9 @@ public class PortableContext implements Externalizable {
         userTypes.put(typeId, desc);
         descByCls.put(cls, desc);
 
+        if (isMetaDataEnabled(typeId))
+            metaHnd.addMeta(typeId, new PortableMetaDataImpl(typeName, desc.fieldsMeta(),
null));
+
         return desc;
     }
 
@@ -769,7 +772,7 @@ public class PortableContext implements Externalizable {
     public boolean isMetaDataEnabled(int typeId) {
         Boolean enabled = metaEnabled.get(typeId);
 
-        return enabled != null ? enabled : true;
+        return enabled != null ? enabled : metaDataEnabled;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/df0aa2f5/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataDisabledSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataDisabledSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataDisabledSelfTest.java
index 47db42b..28ccee6 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataDisabledSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataDisabledSelfTest.java
@@ -65,9 +65,17 @@ public class GridPortableMetaDataDisabledSelfTest extends GridCommonAbstractTest
 
             portables().toPortable(new TestObject1());
             portables().toPortable(new TestObject2());
+            portables().toPortable(new TestObject3());
 
             assertEquals(0, portables().metadata(TestObject1.class).fields().size());
             assertEquals(0, portables().metadata(TestObject2.class).fields().size());
+
+            PortableBuilder bldr = portables().builder("FakeType");
+
+            bldr.setField("field1", 0).setField("field2", "value").build();
+
+            assertNull(portables().metadata("FakeType"));
+            assertNull(portables().metadata(TestObject3.class));
         }
         finally {
             stopGrid();
@@ -215,4 +223,12 @@ public class GridPortableMetaDataDisabledSelfTest extends GridCommonAbstractTest
             // No-op.
         }
     }
+
+    /**
+     */
+    @SuppressWarnings("UnusedDeclaration")
+    private static class TestObject3 {
+        /** */
+        private int field;
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/df0aa2f5/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java
index e5ca91e..4c91ec5 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java
@@ -138,6 +138,15 @@ public class GridPortableMetaDataSelfTest extends GridCommonAbstractTest
{
     /**
      * @throws Exception If failed.
      */
+    public void testNoConfiguration() throws Exception {
+        portables().toPortable(new TestObject3());
+
+        assertNotNull(portables().metadata(TestObject3.class));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
     public void testReflection() throws Exception {
         PortableMetadata meta = portables().metadata(TestObject1.class);
 
@@ -340,4 +349,12 @@ public class GridPortableMetaDataSelfTest extends GridCommonAbstractTest
{
             // No-op.
         }
     }
+
+    /**
+     */
+    @SuppressWarnings("UnusedDeclaration")
+    private static class TestObject3 {
+        /** */
+        private int intVal;
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/df0aa2f5/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodePortableMetadataMultinodeTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodePortableMetadataMultinodeTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodePortableMetadataMultinodeTest.java
index bb57ab0..46bb0b5 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodePortableMetadataMultinodeTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodePortableMetadataMultinodeTest.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.processors.cache.portable;
 import org.apache.ignite.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.util.lang.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.marshaller.portable.*;
 import org.apache.ignite.portable.*;
@@ -226,6 +227,16 @@ public class GridCacheClientNodePortableMetadataMultinodeTest extends
GridCommon
 
             portables = ignite(i).portables();
 
+            final IgnitePortables p0 = portables;
+
+            GridTestUtils.waitForCondition(new GridAbsPredicate() {
+                @Override public boolean apply() {
+                    Collection<PortableMetadata> metaCol = p0.metadata();
+
+                    return metaCol.size() == 1000;
+                }
+            }, getTestTimeout());
+
             Collection<PortableMetadata> metaCol = portables.metadata();
 
             assertEquals(1000, metaCol.size());


Mime
View raw message