Repository: incubator-ignite Updated Branches: refs/heads/ignite-929 19b0c2bed -> 50b219849
Ignite-929 Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/50b21984 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/50b21984 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/50b21984 Branch: refs/heads/ignite-929 Commit: 50b2198494a4327a67df70ddeb738a869846046c Parents: 19b0c2b Author: avinogradov <avinogra...@gridgain.com> Authored: Thu May 28 13:51:55 2015 +0300 Committer: avinogradov <avinogra...@gridgain.com> Committed: Thu May 28 13:51:55 2015 +0300 ---------------------------------------------------------------------- .../GridCacheTxLoadFromStoreOnLockSelfTest.java | 33 ++--- .../cache/CacheOffheapMapEntrySelfTest.java | 20 +-- .../cache/CacheStopAndDestroySelfTest.java | 1 + .../cache/IgniteDynamicCacheStartSelfTest.java | 138 ++++++++++--------- 4 files changed, 101 insertions(+), 91 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/50b21984/modules/core/src/test/java/org/apache/ignite/internal/processors/GridCacheTxLoadFromStoreOnLockSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/GridCacheTxLoadFromStoreOnLockSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/GridCacheTxLoadFromStoreOnLockSelfTest.java index 7b01f0f..eae07f9 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/GridCacheTxLoadFromStoreOnLockSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/GridCacheTxLoadFromStoreOnLockSelfTest.java @@ -92,31 +92,32 @@ public class GridCacheTxLoadFromStoreOnLockSelfTest extends GridCommonAbstractTe cacheCfg.setBackups(backups); cacheCfg.setLoadPreviousValue(true); - try (IgniteCache<Integer, Integer> cache = ignite(0).createCache(cacheCfg)) { - for (int i = 0; i < 10; i++) - assertEquals((Integer)i, cache.get(i)); + IgniteCache<Integer, Integer> cache = ignite(0).createCache(cacheCfg); - cache.removeAll(); + for (int i = 0; i < 10; i++) + assertEquals((Integer)i, cache.get(i)); - assertEquals(0, cache.size()); + cache.removeAll(); - for (TransactionConcurrency conc : TransactionConcurrency.values()) { - for (TransactionIsolation iso : TransactionIsolation.values()) { - info("Checking transaction [conc=" + conc + ", iso=" + iso + ']'); + assertEquals(0, cache.size()); - try (Transaction tx = ignite(0).transactions().txStart(conc, iso)) { - for (int i = 0; i < 10; i++) - assertEquals("Invalid value for transaction [conc=" + conc + ", iso=" + iso + ']', - (Integer)i, cache.get(i)); + for (TransactionConcurrency conc : TransactionConcurrency.values()) { + for (TransactionIsolation iso : TransactionIsolation.values()) { + info("Checking transaction [conc=" + conc + ", iso=" + iso + ']'); - tx.commit(); - } + try (Transaction tx = ignite(0).transactions().txStart(conc, iso)) { + for (int i = 0; i < 10; i++) + assertEquals("Invalid value for transaction [conc=" + conc + ", iso=" + iso + ']', + (Integer)i, cache.get(i)); - cache.removeAll(); - assertEquals(0, cache.size()); + tx.commit(); } + + cache.removeAll(); + assertEquals(0, cache.size()); } } + cache.destroy(); } /** http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/50b21984/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheOffheapMapEntrySelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheOffheapMapEntrySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheOffheapMapEntrySelfTest.java index 8c7d33d..7630582 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheOffheapMapEntrySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheOffheapMapEntrySelfTest.java @@ -149,20 +149,22 @@ public class CacheOffheapMapEntrySelfTest extends GridCacheAbstractSelfTest { cacheMode, "Cache"); - try (IgniteCache jcache = grid(0).getOrCreateCache(cfg)) { - GridCacheAdapter<Integer, String> cache = ((IgniteKernal)grid(0)).internalCache(jcache.getName()); + IgniteCache jcache = grid(0).getOrCreateCache(cfg); - Integer key = primaryKey(grid(0).cache(null)); + GridCacheAdapter<Integer, String> cache = ((IgniteKernal)grid(0)).internalCache(jcache.getName()); - cache.put(key, "val"); + Integer key = primaryKey(grid(0).cache(null)); - GridCacheEntryEx entry = cache.entryEx(key); + cache.put(key, "val"); - entry.unswap(true); + GridCacheEntryEx entry = cache.entryEx(key); - assertNotNull(entry); + entry.unswap(true); - assertEquals(entry.getClass(), entryCls); - } + assertNotNull(entry); + + assertEquals(entry.getClass(), entryCls); + + jcache.destroy(); } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/50b21984/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStopAndDestroySelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStopAndDestroySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStopAndDestroySelfTest.java index 4acd9f5..e86bd99 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStopAndDestroySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStopAndDestroySelfTest.java @@ -365,6 +365,7 @@ public class CacheStopAndDestroySelfTest extends GridCommonAbstractTest { assert grid(2).cache(CACHE_NAME_CLOSE_LOC).get(KEY_VAL).equals(KEY_VAL + "recreated2"); } + /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { super.afterTest(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/50b21984/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartSelfTest.java index a9c28ed..39cbd80 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartSelfTest.java @@ -476,7 +476,7 @@ public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest { GridTestUtils.assertThrows(log, new Callable<Object>() { @Override public Object call() throws Exception { - IgniteKernal ignite = (IgniteKernal) grid(nodeCount()); + IgniteKernal ignite = (IgniteKernal)grid(nodeCount()); return ignite.getCache(DYNAMIC_CACHE_NAME); } @@ -631,10 +631,12 @@ public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest { ignite(i).events().localListen(lsnrs[i], EventType.EVTS_CACHE_LIFECYCLE); } - try (IgniteCache<Object, Object> ignored = ignite(0).createCache(cfg)) { - for (CountDownLatch start : starts) - start.await(); - } + IgniteCache<Object, Object> cache = ignite(0).createCache(cfg); + + for (CountDownLatch start : starts) + start.await(); + + cache.destroy(); for (CountDownLatch stop : stops) stop.await(); @@ -658,28 +660,28 @@ public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest { ccfg.setCacheMode(CacheMode.PARTITIONED); ccfg.setNodeFilter(NODE_FILTER); - try (IgniteCache cache = ig.createCache(ccfg, new NearCacheConfiguration())) { - assertNotNull(cache); + IgniteCache cache = ig.createCache(ccfg, new NearCacheConfiguration()); + assertNotNull(cache); - GridCacheAdapter<Object, Object> cacheAdapter = - ((IgniteKernal)ig).internalCache(DYNAMIC_CACHE_NAME); + GridCacheAdapter<Object, Object> cacheAdapter = + ((IgniteKernal)ig).internalCache(DYNAMIC_CACHE_NAME); - assertNotNull(cacheAdapter); - assertFalse(cacheAdapter.context().affinityNode()); - assertTrue(cacheAdapter.context().isNear()); + assertNotNull(cacheAdapter); + assertFalse(cacheAdapter.context().affinityNode()); + assertTrue(cacheAdapter.context().isNear()); - try { - IgniteEx grid = startGrid(nodeCount() + 1); + try { + IgniteEx grid = startGrid(nodeCount() + 1); - // Check that new node sees near node. - GridDiscoveryManager disco = grid.context().discovery(); + // Check that new node sees near node. + GridDiscoveryManager disco = grid.context().discovery(); - assertTrue(disco.cacheNearNode(disco.node(ig.cluster().localNode().id()), - DYNAMIC_CACHE_NAME)); - } - finally { - stopGrid(nodeCount() + 1); - } + assertTrue(disco.cacheNearNode(disco.node(ig.cluster().localNode().id()), + DYNAMIC_CACHE_NAME)); + } + finally { + cache.destroy(); + stopGrid(nodeCount() + 1); } } finally { @@ -929,46 +931,47 @@ public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest { cfg.setNodeFilter(F.not(NODE_FILTER)); - try (IgniteCache<Object, Object> ignored = ignite(0).createCache(cfg)) { + IgniteCache<Object, Object> cache = ignite(0).createCache(cfg); - final CountDownLatch[] latches = new CountDownLatch[nodeCount()]; + final CountDownLatch[] latches = new CountDownLatch[nodeCount()]; - IgnitePredicate[] lsnrs = new IgnitePredicate[nodeCount()]; + IgnitePredicate[] lsnrs = new IgnitePredicate[nodeCount()]; - for (int i = 0; i < nodeCount(); i++) { - final int idx = i; + for (int i = 0; i < nodeCount(); i++) { + final int idx = i; - latches[i] = new CountDownLatch(1); - lsnrs[i] = new IgnitePredicate<CacheEvent>() { - @Override - public boolean apply(CacheEvent e) { - switch (e.type()) { - case EventType.EVT_CACHE_NODES_LEFT: - latches[idx].countDown(); + latches[i] = new CountDownLatch(1); + lsnrs[i] = new IgnitePredicate<CacheEvent>() { + @Override + public boolean apply(CacheEvent e) { + switch (e.type()) { + case EventType.EVT_CACHE_NODES_LEFT: + latches[idx].countDown(); - break; + break; - default: - assert false; - } + default: + assert false; + } - assertEquals(DYNAMIC_CACHE_NAME, e.cacheName()); + assertEquals(DYNAMIC_CACHE_NAME, e.cacheName()); - return true; - } - }; + return true; + } + }; - ignite(i).events().localListen(lsnrs[i], EventType.EVTS_CACHE_LIFECYCLE); - } + ignite(i).events().localListen(lsnrs[i], EventType.EVTS_CACHE_LIFECYCLE); + } - stopGrid(nodeCount()); + stopGrid(nodeCount()); - for (CountDownLatch latch : latches) - latch.await(); + for (CountDownLatch latch : latches) + latch.await(); - for (int i = 0; i < nodeCount(); i++) - ignite(i).events().stopLocalListen(lsnrs[i]); - } + for (int i = 0; i < nodeCount(); i++) + ignite(i).events().stopLocalListen(lsnrs[i]); + + cache.destroy(); } /** @@ -982,14 +985,15 @@ public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest { try { CacheConfiguration cfg = new CacheConfiguration(DYNAMIC_CACHE_NAME); - try (IgniteCache cache = ignite(0).createCache(cfg)) { - for (int i = 0; i < 100; i++) { - assertFalse(ignite(0).affinity(DYNAMIC_CACHE_NAME).mapKeyToPrimaryAndBackups(i) - .contains(dNode.cluster().localNode())); + IgniteCache cache = ignite(0).createCache(cfg); + for (int i = 0; i < 100; i++) { + assertFalse(ignite(0).affinity(DYNAMIC_CACHE_NAME).mapKeyToPrimaryAndBackups(i) + .contains(dNode.cluster().localNode())); - cache.put(i, i); - } + cache.put(i, i); } + + cache.destroy(); } finally { stopGrid(nodeCount()); @@ -1002,22 +1006,24 @@ public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest { * @throws Exception If failed. */ public void testAwaitPartitionMapExchange() throws Exception { - try (IgniteCache ignored = grid(0).getOrCreateCache(new CacheConfiguration(DYNAMIC_CACHE_NAME))) { - awaitPartitionMapExchange(); + IgniteCache cache = grid(0).getOrCreateCache(new CacheConfiguration(DYNAMIC_CACHE_NAME)); - startGrid(nodeCount()); + awaitPartitionMapExchange(); - awaitPartitionMapExchange(); + startGrid(nodeCount()); - startGrid(nodeCount() + 1); + awaitPartitionMapExchange(); - awaitPartitionMapExchange(); + startGrid(nodeCount() + 1); - stopGrid(nodeCount() + 1); + awaitPartitionMapExchange(); - awaitPartitionMapExchange(); + stopGrid(nodeCount() + 1); - stopGrid(nodeCount()); - } + awaitPartitionMapExchange(); + + stopGrid(nodeCount()); + + cache.destroy(); } }