ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nizhi...@apache.org
Subject ignite git commit: IGNITE-7756: IgniteUuid added to predefined types - Fixes #3550.
Date Wed, 14 Mar 2018 19:38:35 GMT
Repository: ignite
Updated Branches:
  refs/heads/master e7ee88aa8 -> 70ca86a30


IGNITE-7756: IgniteUuid added to predefined types - Fixes #3550.


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

Branch: refs/heads/master
Commit: 70ca86a30a7589f9ff466b93a958362135347d02
Parents: e7ee88a
Author: Nikolay Izhikov <nizhikov@apache.org>
Authored: Wed Mar 14 22:33:47 2018 +0300
Committer: Nikolay Izhikov <nizhikov@apache.org>
Committed: Wed Mar 14 22:34:32 2018 +0300

----------------------------------------------------------------------
 .../IgniteUuidCompatibilityTest.java            | 189 +++++++++++++++++++
 .../IgniteCompatibilityBasicTestSuite.java      |   3 +
 .../ignite/internal/binary/BinaryContext.java   |   1 +
 .../client/IgniteDataStreamerTest.java          | 118 ++++++++++++
 .../IgniteCacheWithIndexingTestSuite.java       |   3 +
 5 files changed, 314 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/70ca86a3/modules/compatibility/src/test/java/org/apache/ignite/compatibility/persistence/IgniteUuidCompatibilityTest.java
----------------------------------------------------------------------
diff --git a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/persistence/IgniteUuidCompatibilityTest.java
b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/persistence/IgniteUuidCompatibilityTest.java
new file mode 100644
index 0000000..88c6900
--- /dev/null
+++ b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/persistence/IgniteUuidCompatibilityTest.java
@@ -0,0 +1,189 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.compatibility.persistence;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+import javax.cache.Cache;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CachePeekMode;
+import org.apache.ignite.cache.CacheWriteSynchronizationMode;
+import org.apache.ignite.configuration.BinaryConfiguration;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.PersistentStoreConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.binary.BinaryContext;
+import org.apache.ignite.internal.processors.cache.GridCacheAbstractFullApiSelfTest;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteInClosure;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+
+/**
+ * Checks that index and caches with IgniteUuid are compatible when IgniteUuid becomes predefined
type.
+ *
+ * @see BinaryContext#registerPredefinedType(Class, int)
+ */
+public class IgniteUuidCompatibilityTest extends IgnitePersistenceCompatibilityAbstractTest
{
+    /** */
+    protected static final String TEST_CACHE_NAME = IgniteUuidCompatibilityTest.class.getSimpleName();
+
+    /** */
+    protected volatile boolean compactFooter;
+
+    /** */
+    private static Set<String> VALUES = new HashSet<>(Arrays.asList("one", "two",
"three"));
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        super.beforeTest();
+
+        U.delete(U.resolveWorkDirectory(U.defaultWorkDirectory(), "binary_meta", false));
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws
Exception {
+        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+        cfg.setPeerClassLoadingEnabled(false);
+
+        cfg.setDataStorageConfiguration(
+            new DataStorageConfiguration()
+                .setDefaultDataRegionConfiguration(
+                    new DataRegionConfiguration()
+                        .setPersistenceEnabled(true)
+                ));
+
+        cfg.setBinaryConfiguration(
+            new BinaryConfiguration()
+                .setCompactFooter(compactFooter)
+        );
+
+        return cfg;
+    }
+
+    /**
+     * Tests opportunity to read data from previous Ignite DB version for cache contains
IgniteUuid instances.
+     *
+     * @throws Exception If failed.
+     */
+    public void testIgniteUuid_2_3() throws Exception {
+        doTestIgniteUuidCompatibility("2.3.0", false);
+    }
+
+    /**
+     * Tests opportunity to read data from previous Ignite DB version for cache contains
IgniteUuid instances.
+     *
+     * @throws Exception If failed.
+     */
+    public void testIgniteUuidWithCompactFooter_2_3() throws Exception {
+        doTestIgniteUuidCompatibility("2.3.0", true);
+    }
+
+    /**
+     * Tests opportunity to read data from previous Ignite DB version.
+     *
+     * @param igniteVer 3-digits version of ignite
+     * @throws Exception If failed.
+     */
+    private void doTestIgniteUuidCompatibility(String igniteVer, boolean compactFooter) throws
Exception {
+        boolean prev = this.compactFooter;
+
+        try {
+            this.compactFooter = compactFooter;
+
+            startGrid(1, igniteVer, new ConfigurationClosure(compactFooter), new PutData());
+
+            stopAllGrids();
+
+            IgniteEx ignite = startGrid(0);
+
+            assertEquals(1, ignite.context().discovery().topologyVersion());
+
+            ignite.active(true);
+
+            IgniteCache<IgniteUuid, String> cache = ignite.cache(TEST_CACHE_NAME);
+
+            assertEquals(cache.size(CachePeekMode.ALL), VALUES.size());
+
+            Set<String> values = new HashSet<>();
+
+            for (Cache.Entry<IgniteUuid, String> e : cache)
+                values.add(e.getValue());
+
+            assertEquals(values, VALUES);
+        }
+        finally {
+            stopAllGrids();
+
+            this.compactFooter = prev;
+        }
+    }
+
+    /** */
+    public static class ConfigurationClosure implements IgniteInClosure<IgniteConfiguration>
{
+        private boolean compactFooter;
+
+        public ConfigurationClosure(boolean compactFooter) {
+            this.compactFooter = compactFooter;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void apply(IgniteConfiguration cfg) {
+            cfg.setLocalHost("127.0.0.1");
+
+            TcpDiscoverySpi disco = new TcpDiscoverySpi();
+            disco.setIpFinder(GridCacheAbstractFullApiSelfTest.LOCAL_IP_FINDER);
+
+            cfg.setDiscoverySpi(disco);
+
+            cfg.setPeerClassLoadingEnabled(false);
+
+            cfg.setPersistentStoreConfiguration(new PersistentStoreConfiguration());
+
+            if (!compactFooter)
+                cfg.setBinaryConfiguration(new BinaryConfiguration().setCompactFooter(compactFooter));
+        }
+    }
+
+    /** */
+    public static class PutData implements IgniteInClosure<Ignite> {
+        /** {@inheritDoc} */
+        @Override public void apply(Ignite ignite) {
+            ignite.active(true);
+
+            CacheConfiguration<IgniteUuid, String> cacheCfg = new CacheConfiguration<>();
+
+            cacheCfg.setName(TEST_CACHE_NAME);
+            cacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
+            cacheCfg.setBackups(1);
+            cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
+
+            IgniteCache<IgniteUuid, String> cache = ignite.createCache(cacheCfg);
+
+            for (String v : VALUES)
+                cache.put(IgniteUuid.randomUuid(), v);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/70ca86a3/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testsuites/IgniteCompatibilityBasicTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testsuites/IgniteCompatibilityBasicTestSuite.java
b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testsuites/IgniteCompatibilityBasicTestSuite.java
index 20643d4..eaa38af 100644
--- a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testsuites/IgniteCompatibilityBasicTestSuite.java
+++ b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/testsuites/IgniteCompatibilityBasicTestSuite.java
@@ -20,6 +20,7 @@ package org.apache.ignite.compatibility.testsuites;
 import junit.framework.TestSuite;
 import org.apache.ignite.compatibility.persistence.DummyPersistenceCompatibilityTest;
 import org.apache.ignite.compatibility.persistence.FoldersReuseCompatibilityTest;
+import org.apache.ignite.compatibility.persistence.IgniteUuidCompatibilityTest;
 import org.apache.ignite.compatibility.persistence.MigratingToWalV2SerializerWithCompactionTest;
 
 /**
@@ -39,6 +40,8 @@ public class IgniteCompatibilityBasicTestSuite {
 
         suite.addTestSuite(MigratingToWalV2SerializerWithCompactionTest.class);
 
+        suite.addTestSuite(IgniteUuidCompatibilityTest.class);
+
         return suite;
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/70ca86a3/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
index 9606139..8f85947 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
@@ -333,6 +333,7 @@ public class BinaryContext {
         registerPredefinedType(GridMapEntry.class, 60);
         registerPredefinedType(IgniteBiTuple.class, 61);
         registerPredefinedType(T2.class, 62);
+        registerPredefinedType(IgniteUuid.class, 63);
 
         registerPredefinedType(PlatformJavaObjectFactoryProxy.class,
             GridBinaryMarshaller.PLATFORM_JAVA_OBJECT_FACTORY_PROXY);

http://git-wip-us.apache.org/repos/asf/ignite/blob/70ca86a3/modules/indexing/src/test/java/org/apache/ignite/internal/processors/client/IgniteDataStreamerTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/client/IgniteDataStreamerTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/client/IgniteDataStreamerTest.java
new file mode 100644
index 0000000..1bfb02e
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/client/IgniteDataStreamerTest.java
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.client;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.processors.datastreamer.DataStreamerImpl;
+import org.apache.ignite.lang.IgniteFuture;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static org.apache.ignite.cache.CachePeekMode.ALL;
+
+/**
+ */
+public class IgniteDataStreamerTest extends GridCommonAbstractTest {
+    public static final String CACHE_NAME = "UUID_CACHE";
+
+    public static final int DATA_SIZE = 3;
+
+    public static final long WAIT_TIMEOUT = 30_000L;
+
+    private boolean client = false;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws
Exception {
+        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+        if (client)
+            cfg.setClientMode(true);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        super.beforeTestsStarted();
+
+        startGrids(2);
+
+        client = true;
+
+        startGrid("client");
+    }
+
+    @Override protected void afterTest() throws Exception {
+        super.afterTest();
+
+        grid("client").destroyCache(CACHE_NAME);
+    }
+
+    /**
+     * @return Cache configuration
+     */
+    private <K, V> CacheConfiguration<K, V> cacheConfiguration(Class<K>
key, Class<V> value) {
+        CacheConfiguration<K, V> ccfg = new CacheConfiguration<>(CACHE_NAME);
+
+        ccfg.setIndexedTypes(key, value);
+
+        return ccfg;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testStreamerIgniteUuid() throws Exception {
+        Ignite client = grid("client");
+
+        IgniteCache<IgniteUuid, Integer> cache =
+            client.createCache(cacheConfiguration(IgniteUuid.class, Integer.class));
+
+        try(IgniteDataStreamer<IgniteUuid, Integer> streamer = client.dataStreamer(CACHE_NAME))
{
+            assertTrue("Expecting " + DataStreamerImpl.class.getName(), streamer instanceof
DataStreamerImpl);
+
+            ((DataStreamerImpl<IgniteUuid, Integer>)streamer).maxRemapCount(0);
+
+            List<IgniteFuture> futs = new ArrayList<>();
+
+            for(int i=0; i<DATA_SIZE; i++) {
+                IgniteFuture<?> fut = streamer.addData(IgniteUuid.randomUuid(), i);
+
+                futs.add(fut);
+            }
+
+            streamer.flush();
+
+            for (IgniteFuture fut : futs) {
+                //This should not throw any exception.
+                Object res = fut.get(WAIT_TIMEOUT);
+
+                //Printing future result to log to prevent jvm optimization
+                log.debug(res == null ? null : res.toString());
+            }
+
+            assertTrue(cache.size(ALL) == DATA_SIZE);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/70ca86a3/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheWithIndexingTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheWithIndexingTestSuite.java
b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheWithIndexingTestSuite.java
index 4047700..bc99981 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheWithIndexingTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheWithIndexingTestSuite.java
@@ -37,6 +37,7 @@ import org.apache.ignite.internal.processors.cache.ttl.CacheTtlAtomicLocalSelfTe
 import org.apache.ignite.internal.processors.cache.ttl.CacheTtlAtomicPartitionedSelfTest;
 import org.apache.ignite.internal.processors.cache.ttl.CacheTtlTransactionalLocalSelfTest;
 import org.apache.ignite.internal.processors.cache.ttl.CacheTtlTransactionalPartitionedSelfTest;
+import org.apache.ignite.internal.processors.client.IgniteDataStreamerTest;
 import org.apache.ignite.internal.processors.query.h2.database.InlineIndexHelperTest;
 
 /**
@@ -78,6 +79,8 @@ public class IgniteCacheWithIndexingTestSuite extends TestSuite {
 
         suite.addTestSuite(IgniteCacheGroupsSqlTest.class);
 
+        suite.addTestSuite(IgniteDataStreamerTest.class);
+
         return suite;
     }
 }


Mime
View raw message