Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 890061819D for ; Mon, 8 Feb 2016 10:45:32 +0000 (UTC) Received: (qmail 78306 invoked by uid 500); 8 Feb 2016 10:45:32 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 78272 invoked by uid 500); 8 Feb 2016 10:45:32 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 78263 invoked by uid 99); 8 Feb 2016 10:45:32 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Feb 2016 10:45:32 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 47FF8E00A0; Mon, 8 Feb 2016 10:45:32 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dmagda@apache.org To: commits@ignite.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: ignite git commit: Improved CacheStore + external class loader tests Date: Mon, 8 Feb 2016 10:45:32 +0000 (UTC) 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 Authored: Mon Feb 8 13:41:38 2016 +0300 Committer: Denis Magda 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.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 cache1 = g1.cache(null); + IgniteCache cache2 = g2.cache(null); + IgniteCache 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 cache1 = g1.cache(null); - IgniteCache cache2 = g2.cache(null); - IgniteCache cache3 = g3.cache(null); + IgniteCache cache1 = g1.createCache(cfg); - cache1.put(1, 1); + IgniteCache cache2 = g2.getOrCreateCache(cfg); // Checks deserialization at cache creation. + IgniteCache 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 cache1 = g1.getOrCreateCache(cfg); - cache2 = g2.getOrCreateCache(cfg); // Checks deserialization at cache creation. - cache3 = g3.getOrCreateCache(cfg); // Checks deserialization at cache creation. + IgniteCache cache2 = g2.getOrCreateCache("customStore"); // Checks deserialization at cache creation. + IgniteCache 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; } }