You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by dm...@apache.org on 2016/02/08 11:45:32 UTC

ignite git commit: Improved CacheStore + external class loader tests

Repository: ignite
Updated Branches:
  refs/heads/ignite-1.5.7 ccd2f8a9e -> 13b3cce60


Improved CacheStore + external class loader tests


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

Branch: refs/heads/ignite-1.5.7
Commit: 13b3cce6002da1b0e826ae657b10f5e9e802dc1f
Parents: ccd2f8a
Author: Denis Magda <dm...@gridgain.com>
Authored: Mon Feb 8 13:41:38 2016 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Mon Feb 8 13:45:02 2016 +0300

----------------------------------------------------------------------
 .../GridCacheReplicatedPreloadSelfTest.java     | 120 +++++++++++++------
 1 file changed, 82 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/13b3cce6/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
index 523f641..887fea4 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
@@ -77,6 +77,9 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest {
     private volatile boolean isClient = false;
 
     /** */
+    private volatile boolean useExtClassLoader = false;
+
+    /** */
     private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
 
     /** {@inheritDoc} */
@@ -108,7 +111,8 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest {
 
         cfg.setEventStorageSpi(spi);
 
-        if (getTestGridName(1).equals(gridName) || cfg.getMarshaller() instanceof BinaryMarshaller)
+        if (getTestGridName(1).equals(gridName) || useExtClassLoader ||
+            cfg.getMarshaller() instanceof BinaryMarshaller)
             cfg.setClassLoader(getExternalClassLoader());
 
         if (isClient)
@@ -187,7 +191,7 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest {
 
             for (int i = 0; i < 3; i++) {
                 evts = g2.events().localQuery(F.<Event>alwaysTrue(),
-                        EVT_CACHE_REBALANCE_STARTED, EVT_CACHE_REBALANCE_STOPPED);
+                    EVT_CACHE_REBALANCE_STARTED, EVT_CACHE_REBALANCE_STOPPED);
 
                 if (evts.size() != 2) {
                     info("Wrong events collection size (will retry in 1000 ms): " + evts.size());
@@ -284,7 +288,7 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest {
             assert v3 != null;
             assert v3.toString().equals(v1.toString());
             assert !v3.getClass().getClassLoader().equals(getClass().getClassLoader());
-            assert v3.getClass().getClassLoader().getClass().getName().contains("GridDeploymentClassLoader")||
+            assert v3.getClass().getClassLoader().getClass().getName().contains("GridDeploymentClassLoader") ||
                 grid(3).configuration().getMarshaller() instanceof BinaryMarshaller;
         }
         finally {
@@ -297,70 +301,110 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest {
      */
     public void testStore() throws Exception {
         try {
+            needStore = true;
+            useExtClassLoader = true;
+
             Ignite g1 = startGrid(1);
 
-            if (g1.configuration().getMarshaller() instanceof BinaryMarshaller) {
-                stopAllGrids();
+            Ignite g2 = startGrid(2);  // Checks deserialization at node join.
 
-                needStore = true;
+            isClient = true;
 
-                g1 = startGrid(1);
+            Ignite g3 = startGrid(3);
+
+            IgniteCache<Integer, Object> cache1 = g1.cache(null);
+            IgniteCache<Integer, Object> cache2 = g2.cache(null);
+            IgniteCache<Integer, Object> cache3 = g3.cache(null);
+
+            cache1.put(1, 1);
+
+            assertEquals(1, cache2.get(1));
+            assertEquals(1, cache3.get(1));
+        }
+        finally {
+            needStore = false;
+            isClient = false;
+            useExtClassLoader = false;
+        }
+    }
+
+    /**
+     * @throws Exception If test failed.
+     */
+    public void testStoreDynamicStart() throws Exception {
+        try {
+            needStore = false;
+            useExtClassLoader = true;
 
-                ClassLoader ldr = grid(1).configuration().getClassLoader();
+            Ignite g1 = startGrid(1);
+            Ignite g2 = startGrid(2);
 
-                CacheConfiguration cfg = defaultCacheConfiguration();
+            isClient = true;
 
-                Ignite g2 = startGrid(2);  // Checks deserialization at node join.
+            Ignite g3 = startGrid(3);
 
-                isClient = true;
+            Object sf = getExternalClassLoader().loadClass(
+                "org.apache.ignite.tests.p2p.CacheDeploymentTestStoreFactory").newInstance();
 
-                Ignite g3 = startGrid(3);
+            CacheConfiguration cfg = defaultCacheConfiguration();
 
-                isClient = false;
+            cfg.setCacheStoreFactory((Factory)sf);
+            cfg.setName("customStore");
 
-                IgniteCache<Integer, Object> cache1 = g1.cache(null);
-                IgniteCache<Integer, Object> cache2 = g2.cache(null);
-                IgniteCache<Integer, Object> cache3 = g3.cache(null);
+            IgniteCache<Integer, Object> cache1 = g1.createCache(cfg);
 
-                cache1.put(1, 1);
+            IgniteCache<Integer, Object> cache2 = g2.getOrCreateCache(cfg); // Checks deserialization at cache creation.
+            IgniteCache<Integer, Object> cache3 = g3.getOrCreateCache(cfg); // Checks deserialization at cache creation.
 
-                assertEquals(1, cache2.get(1));
-                assertEquals(1, cache3.get(1));
+            cache1.put(1, 1);
 
-                needStore = false;
+            assertEquals(1, cache2.get(1));
+            assertEquals(1, cache3.get(1));
+        }
+        finally {
+            needStore = false;
+            isClient = false;
+            useExtClassLoader = false;
+        }
+    }
 
-                stopAllGrids();
+    /**
+     * @throws Exception If test failed.
+     */
+    public void testStoreDynamicStart2() throws Exception {
+        try {
+            needStore = false;
+            useExtClassLoader = true;
 
-                g1 = startGrid(1);
-                g2 = startGrid(2);
+            Ignite g1 = startGrid(1);
+            Ignite g2 = startGrid(2);
 
-                isClient = true;
+            isClient = true;
 
-                g3 = startGrid(3);
+            Ignite g3 = startGrid(3);
 
-                isClient = false;
+            Object sf = getExternalClassLoader().loadClass(
+                "org.apache.ignite.tests.p2p.CacheDeploymentTestStoreFactory").newInstance();
 
-                Object sf = ldr.loadClass("org.apache.ignite.tests.p2p.CacheDeploymentTestStoreFactory").newInstance();
+            CacheConfiguration cfg = defaultCacheConfiguration();
 
-                cfg.setCacheStoreFactory((Factory)sf);
-                cfg.setName("customStore");
+            cfg.setCacheStoreFactory((Factory)sf);
+            cfg.setName("customStore");
 
-                cache1 = g1.createCache(cfg);
+            IgniteCache<Integer, Object> cache1 = g1.getOrCreateCache(cfg);
 
-                cache2 = g2.getOrCreateCache(cfg); // Checks deserialization at cache creation.
-                cache3 = g3.getOrCreateCache(cfg); // Checks deserialization at cache creation.
+            IgniteCache<Integer, Object> cache2 = g2.getOrCreateCache("customStore"); // Checks deserialization at cache creation.
+            IgniteCache<Integer, Object> cache3 = g3.getOrCreateCache("customStore"); // Checks deserialization at cache creation.
 
-                cache1.put(1, 1);
+            cache1.put(1, 1);
 
-                assertEquals(1, cache2.get(1));
-                assertEquals(1, cache3.get(1));
-            }
+            assertEquals(1, cache2.get(1));
+            assertEquals(1, cache3.get(1));
         }
         finally {
             needStore = false;
             isClient = false;
-
-            stopAllGrids();
+            useExtClassLoader = false;
         }
     }