IGNITE-96 Migrating tests.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/244e604a Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/244e604a Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/244e604a Branch: refs/heads/ignite-96-tests Commit: 244e604a66d764cd49db0975fc973ac995de98c0 Parents: aae71de Author: nikolay_tikhonov <ntikho...@gridgain.com> Authored: Tue Feb 10 13:50:06 2015 +0300 Committer: nikolay_tikhonov <ntikho...@gridgain.com> Committed: Tue Feb 10 13:50:20 2015 +0300 ---------------------------------------------------------------------- ...unctionExcludeNeighborsAbstractSelfTest.java | 12 +- ...eAtomicNearOnlyMultiNodeFullApiSelfTest.java | 2 +- .../near/GridCacheGetStoreErrorSelfTest.java | 5 +- .../near/GridCacheNearEvictionSelfTest.java | 20 +- .../near/GridCacheNearMetricsSelfTest.java | 195 ++++++++++--------- .../near/GridCacheNearMultiGetSelfTest.java | 17 +- .../near/GridCacheNearMultiNodeSelfTest.java | 10 +- .../near/GridCacheNearOnlyTopologySelfTest.java | 22 +-- .../GridCacheNearPartitionedClearSelfTest.java | 16 +- .../GridCacheNearReaderPreloadSelfTest.java | 26 +-- .../near/GridCacheNearReadersSelfTest.java | 10 +- .../near/GridCacheNearTxMultiNodeSelfTest.java | 23 +-- ...AffinityExcludeNeighborsPerformanceTest.java | 2 +- .../GridCachePartitionedAffinitySelfTest.java | 6 +- .../GridCachePartitionedFullApiSelfTest.java | 171 ---------------- ...achePartitionedMultiNodeCounterSelfTest.java | 36 ++-- ...achePartitionedMultiNodeFullApiSelfTest.java | 31 ++- ...idCacheReplicatedUnswapAdvancedSelfTest.java | 10 +- .../GridCacheSyncReplicatedPreloadSelfTest.java | 17 +- ...CacheReplicatedPreloadLifecycleSelfTest.java | 78 ++++---- .../GridCacheReplicatedPreloadSelfTest.java | 36 ++-- ...GridCacheReplicatedPreloadUndeploysTest.java | 4 +- .../junits/common/GridCommonAbstractTest.java | 13 ++ 23 files changed, 300 insertions(+), 462 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/244e604a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAffinityFunctionExcludeNeighborsAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAffinityFunctionExcludeNeighborsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAffinityFunctionExcludeNeighborsAbstractSelfTest.java index 7b089c4..7470174 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAffinityFunctionExcludeNeighborsAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAffinityFunctionExcludeNeighborsAbstractSelfTest.java @@ -91,14 +91,6 @@ public abstract class GridCacheAffinityFunctionExcludeNeighborsAbstractSelfTest protected abstract CacheAffinityFunction affinityFunction(); /** - * @param ignite Grid. - * @return Affinity. - */ - static CacheAffinity<Object> affinity(Ignite ignite) { - return ignite.cache(null).affinity(); - } - - /** * @param aff Affinity. * @param key Key. * @return Nodes. @@ -123,7 +115,7 @@ public abstract class GridCacheAffinityFunctionExcludeNeighborsAbstractSelfTest for (int i = 0; i < grids; i++) { final Ignite g = grid(i); - CacheAffinity<Object> aff = affinity(g); + CacheAffinity<Object> aff = g.affinity(null); List<TcpDiscoveryNode> top = new ArrayList<>(); @@ -170,7 +162,7 @@ public abstract class GridCacheAffinityFunctionExcludeNeighborsAbstractSelfTest try { Object key = 12345; - Collection<? extends ClusterNode> affNodes = nodes(affinity(g), key); + Collection<? extends ClusterNode> affNodes = nodes(g.affinity(null), key); info("Affinity picture for grid: " + U.toShortString(affNodes)); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/244e604a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest.java index ca69881..a6624c6 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest.java @@ -70,7 +70,7 @@ public class GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest extends GridCacheNe @Override protected void afterTest() throws Exception { for (int i = 0; i < gridCount(); i++) - grid(i).cache(null).removeAll(); + grid(i).jcache(null).removeAll(); super.afterTest(); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/244e604a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheGetStoreErrorSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheGetStoreErrorSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheGetStoreErrorSelfTest.java index 1152799..7decc27 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheGetStoreErrorSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheGetStoreErrorSelfTest.java @@ -29,6 +29,7 @@ import org.apache.ignite.testframework.junits.common.*; import javax.cache.*; import javax.cache.configuration.*; +import javax.cache.integration.*; import java.util.concurrent.*; import static org.apache.ignite.cache.CacheAtomicityMode.*; @@ -122,11 +123,11 @@ public class GridCacheGetStoreErrorSelfTest extends GridCommonAbstractTest { try { GridTestUtils.assertThrows(log, new Callable<Object>() { @Override public Object call() throws Exception { - grid(0).cache(null).get(nearKey()); + grid(0).jcache(null).get(nearKey()); return null; } - }, IgniteCheckedException.class, null); + }, CacheLoaderException.class, null); } finally { stopAllGrids(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/244e604a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearEvictionSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearEvictionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearEvictionSelfTest.java index 8bf8eb6..98c6652 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearEvictionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearEvictionSelfTest.java @@ -20,6 +20,7 @@ package org.apache.ignite.internal.processors.cache.distributed.near; import org.apache.ignite.*; import org.apache.ignite.cache.*; import org.apache.ignite.configuration.*; +import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.lang.*; import org.apache.ignite.marshaller.optimized.*; @@ -91,12 +92,12 @@ public class GridCacheNearEvictionSelfTest extends GridCommonAbstractTest { startGridsMultiThreaded(gridCnt); try { - GridCache<Integer, String> c = grid(0).cache(null); + IgniteCache<Integer, String> c = grid(0).jcache(null); int cnt = 100; for (int i = 0; i < cnt; i++) - assertTrue(c.putx(i, Integer.toString(i))); + c.put(i, Integer.toString(i)); assertEquals(cnt, c.size()); assertEquals(cnt, c.size()); @@ -121,18 +122,17 @@ public class GridCacheNearEvictionSelfTest extends GridCommonAbstractTest { private Ignite ignite; @Override public Object call() throws Exception { - GridCache<Integer, String> c = ignite.cache(null); + IgniteCache<Integer, String> c = ignite.jcache(null); for (int i = 0; i < cnt; i++) - c.putx(i, Integer.toString(i)); + c.put(i, Integer.toString(i)); return true; } }); for (int i = 0; i < gridCnt; i++) { - assertEquals(cnt, grid(i).cache(null).size()); - assertEquals(cnt, grid(i).cache(null).size()); + assertEquals(cnt, internalCache(i).size()); assertEquals(0, near(i).nearSize()); } } @@ -155,23 +155,23 @@ public class GridCacheNearEvictionSelfTest extends GridCommonAbstractTest { private Ignite ignite; @Override public Object call() throws Exception { - GridCache<Integer, String> c = ignite.cache(null); + IgniteCache<Integer, String> c = ignite.jcache(null); for (int i = 0; i < cnt; i++) - c.putx(i, Integer.toString(i)); + c.put(i, Integer.toString(i)); return true; } }); for (int i = 0; i < gridCnt; i++) { - final Ignite g = grid(i); + final GridCacheAdapter cache = internalCache(i); // Repeatedly check cache sizes because of concurrent cache updates. assertTrue(GridTestUtils.waitForCondition(new PA() { @Override public boolean apply() { // Every node contains either near, backup, or primary. - return cnt == g.cache(null).size(); + return cnt == cache.size(); } }, getTestTimeout())); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/244e604a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMetricsSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMetricsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMetricsSelfTest.java index 4886e8b..ba808bc 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMetricsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMetricsSelfTest.java @@ -66,11 +66,11 @@ public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest { for (int i = 0; i < gridCount(); i++) { Ignite g = grid(i); - g.cache(null).removeAll(); + g.jcache(null).removeAll(); - assert g.cache(null).isEmpty(); + assert internalCache(i).isEmpty(); - g.cache(null).mxBean().clear(); + g.jcache(null).mxBean().clear(); } } @@ -81,7 +81,7 @@ public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest { for (int i = 0; i < gridCount(); i++) { Ignite g = grid(i); - g.cache(null).configuration().setStatisticsEnabled(true); + g.jcache(null).configuration().setStatisticsEnabled(true); } } @@ -101,13 +101,13 @@ public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest { public void testPrimaryPut() throws Exception { Ignite g0 = grid(0); - GridCache<Integer, Integer> cache0 = g0.cache(null); + IgniteCache<Integer, Integer> cache0 = g0.jcache(null); int key; // Put and get a few keys. for (int i = 0; ; i++) { - if (cache0.affinity().isPrimary(g0.cluster().localNode(), i)) { + if (affinity(cache0).isPrimary(g0.cluster().localNode(), i)) { cache0.put(i, i); // +1 read cache0.get(i); // +1 read. @@ -116,7 +116,7 @@ public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest { info("Puts: " + cache0.metrics().getCachePuts()); info("Reads: " + cache0.metrics().getCacheGets()); - info("Affinity nodes: " + U.nodes2names(cache0.affinity().mapKeyToPrimaryAndBackups(i))); + info("Affinity nodes: " + U.nodes2names(affinity(cache0).mapKeyToPrimaryAndBackups(i))); break; } @@ -127,23 +127,25 @@ public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest { info("Checking grid: " + g.name()); - info("Puts: " + g.cache(null).metrics().getCachePuts()); - info("Reads: " + g.cache(null).metrics().getCacheGets()); + IgniteCache<Object, Object> jcache = g.jcache(null); - if (g.cache(null).affinity().isPrimaryOrBackup(g.cluster().localNode(), key)) - assertEquals(1, g.cache(null).metrics().getCachePuts()); + info("Puts: " + jcache.metrics().getCachePuts()); + info("Reads: " + jcache.metrics().getCacheGets()); + + if (affinity(jcache).isPrimaryOrBackup(g.cluster().localNode(), key)) + assertEquals(1, jcache.metrics().getCachePuts()); else - assertEquals(0, g.cache(null).metrics().getCachePuts()); + assertEquals(0, jcache.metrics().getCachePuts()); - if (g.cache(null).affinity().isPrimary(g.cluster().localNode(), key)) { - assertEquals(2, g.cache(null).metrics().getCacheGets()); - assertEquals(1, g.cache(null).metrics().getCacheHits()); - assertEquals(1, g.cache(null).metrics().getCacheHits()); + if (affinity(jcache).isPrimary(g.cluster().localNode(), key)) { + assertEquals(2, jcache.metrics().getCacheGets()); + assertEquals(1, jcache.metrics().getCacheHits()); + assertEquals(1, jcache.metrics().getCacheHits()); } else { - assertEquals(0, g.cache(null).metrics().getCacheGets()); - assertEquals(0, g.cache(null).metrics().getCacheHits()); - assertEquals(0, g.cache(null).metrics().getCacheMisses()); + assertEquals(0, jcache.metrics().getCacheGets()); + assertEquals(0, jcache.metrics().getCacheHits()); + assertEquals(0, jcache.metrics().getCacheMisses()); } } } @@ -154,13 +156,13 @@ public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest { public void testBackupPut() throws Exception { Ignite g0 = grid(0); - GridCache<Integer, Integer> cache0 = g0.cache(null); + IgniteCache<Integer, Integer> cache0 = g0.jcache(null); int key; // Put and get a few keys. for (int i = 0; ; i++) { - if (cache0.affinity().isBackup(g0.cluster().localNode(), i)) { + if (affinity(cache0).isBackup(g0.cluster().localNode(), i)) { cache0.put(i, i); // +1 read. cache0.get(i); // +1 read. @@ -169,7 +171,7 @@ public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest { info("Puts: " + cache0.metrics().getCachePuts()); info("Reads: " + cache0.metrics().getCacheGets()); - info("Affinity nodes: " + U.nodes2names(cache0.affinity().mapKeyToPrimaryAndBackups(i))); + info("Affinity nodes: " + U.nodes2names(affinity(cache0).mapKeyToPrimaryAndBackups(i))); break; } @@ -177,26 +179,27 @@ public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest { for (int j = 0; j < gridCount(); j++) { Ignite g = grid(j); + IgniteCache<Object, Object> jcache = g.jcache(null); - if (g.cache(null).affinity().isPrimaryOrBackup(g.cluster().localNode(), key)) - assertEquals(1, g.cache(null).metrics().getCachePuts()); + if (affinity(jcache).isPrimaryOrBackup(g.cluster().localNode(), key)) + assertEquals(1, jcache.metrics().getCachePuts()); else - assertEquals(0, g.cache(null).metrics().getCachePuts()); + assertEquals(0, jcache.metrics().getCachePuts()); - if (g.cache(null).affinity().isPrimary(g.cluster().localNode(), key)) { - assertEquals(1, g.cache(null).metrics().getCacheGets()); - assertEquals(0, g.cache(null).metrics().getCacheHits()); - assertEquals(1, g.cache(null).metrics().getCacheMisses()); + if (affinity(jcache).isPrimary(g.cluster().localNode(), key)) { + assertEquals(1, jcache.metrics().getCacheGets()); + assertEquals(0, jcache.metrics().getCacheHits()); + assertEquals(1, jcache.metrics().getCacheMisses()); } - else if (g.cache(null).affinity().isBackup(g.cluster().localNode(), key)){ - assertEquals(2, g.cache(null).metrics().getCacheGets()); - assertEquals(1, g.cache(null).metrics().getCacheHits()); - assertEquals(1, g.cache(null).metrics().getCacheMisses()); + else if (affinity(jcache).isBackup(g.cluster().localNode(), key)){ + assertEquals(2, jcache.metrics().getCacheGets()); + assertEquals(1, jcache.metrics().getCacheHits()); + assertEquals(1, jcache.metrics().getCacheMisses()); } else { - assertEquals(0, g.cache(null).metrics().getCacheGets()); - assertEquals(0, g.cache(null).metrics().getCacheHits()); - assertEquals(0, g.cache(null).metrics().getCacheMisses()); + assertEquals(0, jcache.metrics().getCacheGets()); + assertEquals(0, jcache.metrics().getCacheHits()); + assertEquals(0, jcache.metrics().getCacheMisses()); } } } @@ -207,13 +210,13 @@ public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest { public void testNearPut() throws Exception { Ignite g0 = grid(0); - GridCache<Integer, Integer> cache0 = g0.cache(null); + IgniteCache<Integer, Integer> cache0 = g0.jcache(null); int key; // Put and get a few keys. for (int i = 0; ; i++) { - if (!cache0.affinity().isPrimaryOrBackup(g0.cluster().localNode(), i)) { + if (!affinity(cache0).isPrimaryOrBackup(g0.cluster().localNode(), i)) { cache0.put(i, i); // +1 read. cache0.get(i); // +1 read. @@ -222,7 +225,7 @@ public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest { info("Writes: " + cache0.metrics().getCachePuts()); info("Reads: " + cache0.metrics().getCacheGets()); - info("Affinity nodes: " + U.nodes2names(cache0.affinity().mapKeyToPrimaryAndBackups(i))); + info("Affinity nodes: " + U.nodes2names(affinity(cache0).mapKeyToPrimaryAndBackups(i))); break; } @@ -231,22 +234,24 @@ public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest { for (int j = 0; j < gridCount(); j++) { Ignite g = grid(j); - assertEquals(1, g.cache(null).metrics().getCachePuts()); + IgniteCache<Object, Object> jcache = g.jcache(null); + + assertEquals(1, jcache.metrics().getCachePuts()); - if (g.cache(null).affinity().isPrimary(g.cluster().localNode(), key)) { - assertEquals(1, g.cache(null).metrics().getCacheGets()); - assertEquals(0, g.cache(null).metrics().getCacheHits()); - assertEquals(1, g.cache(null).metrics().getCacheMisses()); + if (affinity(jcache).isPrimary(g.cluster().localNode(), key)) { + assertEquals(1, jcache.metrics().getCacheGets()); + assertEquals(0, jcache.metrics().getCacheHits()); + assertEquals(1, jcache.metrics().getCacheMisses()); } - else if (g.cache(null).affinity().isBackup(g.cluster().localNode(), key)){ - assertEquals(0, g.cache(null).metrics().getCacheGets()); - assertEquals(0, g.cache(null).metrics().getCacheHits()); - assertEquals(0, g.cache(null).metrics().getCacheMisses()); + else if (affinity(jcache).isBackup(g.cluster().localNode(), key)){ + assertEquals(0, jcache.metrics().getCacheGets()); + assertEquals(0, jcache.metrics().getCacheHits()); + assertEquals(0, jcache.metrics().getCacheMisses()); } else { - assertEquals(2, g.cache(null).metrics().getCacheGets()); - assertEquals(1, g.cache(null).metrics().getCacheHits()); - assertEquals(1, g.cache(null).metrics().getCacheMisses()); + assertEquals(2, jcache.metrics().getCacheGets()); + assertEquals(1, jcache.metrics().getCacheHits()); + assertEquals(1, jcache.metrics().getCacheMisses()); } } } @@ -257,26 +262,26 @@ public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest { public void testPrimaryRead() throws Exception { Ignite g0 = grid(0); - GridCache<Integer, Integer> cache0 = g0.cache(null); + IgniteCache<Integer, Integer> cache0 = g0.jcache(null); int key; // Put and get a few keys. for (int i = 0; ; i++) { - if (cache0.affinity().isPrimary(g0.cluster().localNode(), i)) { + if (affinity(cache0).isPrimary(g0.cluster().localNode(), i)) { cache0.get(i); // +1 read. key = i; info("Writes: " + cache0.metrics().getCachePuts()); info("Reads: " + cache0.metrics().getCacheGets()); - info("Affinity nodes: " + U.nodes2names(cache0.affinity().mapKeyToPrimaryAndBackups(i))); + info("Affinity nodes: " + U.nodes2names(affinity(cache0).mapKeyToPrimaryAndBackups(i))); cache0.get(i); // +1 read. info("Writes: " + cache0.metrics().getCachePuts()); info("Reads: " + cache0.metrics().getCacheGets()); - info("Affinity nodes: " + U.nodes2names(cache0.affinity().mapKeyToPrimaryAndBackups(i))); + info("Affinity nodes: " + U.nodes2names(affinity(cache0).mapKeyToPrimaryAndBackups(i))); break; } @@ -287,20 +292,22 @@ public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest { info("Checking grid: " + g.name()); - info("Writes: " + g.cache(null).metrics().getCachePuts()); - info("Reads: " + g.cache(null).metrics().getCacheGets()); + IgniteCache<Object, Object> jcache = g.jcache(null); + + info("Writes: " + jcache.metrics().getCachePuts()); + info("Reads: " + jcache.metrics().getCacheGets()); - assertEquals(0, g.cache(null).metrics().getCachePuts()); + assertEquals(0, jcache.metrics().getCachePuts()); - if (g.cache(null).affinity().isPrimary(g.cluster().localNode(), key)) { - assertEquals(2, g.cache(null).metrics().getCacheGets()); - assertEquals(0, g.cache(null).metrics().getCacheHits()); - assertEquals(2, g.cache(null).metrics().getCacheMisses()); + if (affinity(jcache).isPrimary(g.cluster().localNode(), key)) { + assertEquals(2, jcache.metrics().getCacheGets()); + assertEquals(0, jcache.metrics().getCacheHits()); + assertEquals(2, jcache.metrics().getCacheMisses()); } else { - assertEquals(0, g.cache(null).metrics().getCacheGets()); - assertEquals(0, g.cache(null).metrics().getCacheHits()); - assertEquals(0, g.cache(null).metrics().getCacheMisses()); + assertEquals(0, jcache.metrics().getCacheGets()); + assertEquals(0, jcache.metrics().getCacheHits()); + assertEquals(0, jcache.metrics().getCacheMisses()); } } } @@ -311,26 +318,26 @@ public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest { public void testBackupRead() throws Exception { Ignite g0 = grid(0); - GridCache<Integer, Integer> cache0 = g0.cache(null); + IgniteCache<Integer, Integer> cache0 = g0.jcache(null); int key; // Put and get a few keys. for (int i = 0; ; i++) { - if (cache0.affinity().isBackup(g0.cluster().localNode(), i)) { + if (affinity(cache0).isBackup(g0.cluster().localNode(), i)) { cache0.get(i); // +1 read. key = i; info("Writes: " + cache0.metrics().getCachePuts()); info("Reads: " + cache0.metrics().getCacheGets()); - info("Affinity nodes: " + U.nodes2names(cache0.affinity().mapKeyToPrimaryAndBackups(i))); + info("Affinity nodes: " + U.nodes2names(affinity(cache0).mapKeyToPrimaryAndBackups(i))); cache0.get(i); // +1 read. info("Writes: " + cache0.metrics().getCachePuts()); info("Reads: " + cache0.metrics().getCacheGets()); - info("Affinity nodes: " + U.nodes2names(cache0.affinity().mapKeyToPrimaryAndBackups(i))); + info("Affinity nodes: " + U.nodes2names(affinity(cache0).mapKeyToPrimaryAndBackups(i))); break; } @@ -339,17 +346,19 @@ public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest { for (int j = 0; j < gridCount(); j++) { Ignite g = grid(j); - assertEquals(0, g.cache(null).metrics().getCachePuts()); + IgniteCache<Object, Object> jcache = g.jcache(null); - if (g.cache(null).affinity().isPrimaryOrBackup(g.cluster().localNode(), key)) { - assertEquals(2, g.cache(null).metrics().getCacheGets()); - assertEquals(0, g.cache(null).metrics().getCacheHits()); - assertEquals(2, g.cache(null).metrics().getCacheMisses()); + assertEquals(0, jcache.metrics().getCachePuts()); + + if (affinity(jcache).isPrimaryOrBackup(g.cluster().localNode(), key)) { + assertEquals(2, jcache.metrics().getCacheGets()); + assertEquals(0, jcache.metrics().getCacheHits()); + assertEquals(2, jcache.metrics().getCacheMisses()); } else { - assertEquals(0, g.cache(null).metrics().getCacheGets()); - assertEquals(0, g.cache(null).metrics().getCacheHits()); - assertEquals(0, g.cache(null).metrics().getCacheMisses()); + assertEquals(0, jcache.metrics().getCacheGets()); + assertEquals(0, jcache.metrics().getCacheHits()); + assertEquals(0, jcache.metrics().getCacheMisses()); } } } @@ -360,13 +369,13 @@ public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest { public void testNearRead() throws Exception { Ignite g0 = grid(0); - GridCache<Integer, Integer> cache0 = g0.cache(null); + IgniteCache<Integer, Integer> cache0 = g0.jcache(null); int key; // Put and get a few keys. for (int i = 0; ; i++) { - if (!cache0.affinity().isPrimaryOrBackup(g0.cluster().localNode(), i)) { + if (!affinity(cache0).isPrimaryOrBackup(g0.cluster().localNode(), i)) { cache0.get(i); // +1 read. cache0.get(i); // +1 read. @@ -376,7 +385,7 @@ public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest { info("Reads: " + cache0.metrics().getCacheGets()); info("Hits: " + cache0.metrics().getCacheHits()); info("Misses: " + cache0.metrics().getCacheMisses()); - info("Affinity nodes: " + U.nodes2names(cache0.affinity().mapKeyToPrimaryAndBackups(i))); + info("Affinity nodes: " + U.nodes2names(affinity(cache0).mapKeyToPrimaryAndBackups(i))); break; } @@ -385,22 +394,24 @@ public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest { for (int j = 0; j < gridCount(); j++) { Ignite g = grid(j); - assertEquals(0, g.cache(null).metrics().getCachePuts()); + IgniteCache<Object, Object> jcache = g.jcache(null); + + assertEquals(0, jcache.metrics().getCachePuts()); - if (g.cache(null).affinity().isPrimary(g.cluster().localNode(), key)) { - assertEquals(2, g.cache(null).metrics().getCacheGets()); - assertEquals(0, g.cache(null).metrics().getCacheHits()); - assertEquals(2, g.cache(null).metrics().getCacheMisses()); + if (affinity(jcache).isPrimary(g.cluster().localNode(), key)) { + assertEquals(2, jcache.metrics().getCacheGets()); + assertEquals(0, jcache.metrics().getCacheHits()); + assertEquals(2, jcache.metrics().getCacheMisses()); } - else if (g.cache(null).affinity().isBackup(g.cluster().localNode(), key)){ - assertEquals(0, g.cache(null).metrics().getCacheGets()); - assertEquals(0, g.cache(null).metrics().getCacheHits()); - assertEquals(0, g.cache(null).metrics().getCacheMisses()); + else if (affinity(jcache).isBackup(g.cluster().localNode(), key)){ + assertEquals(0, jcache.metrics().getCacheGets()); + assertEquals(0, jcache.metrics().getCacheHits()); + assertEquals(0, jcache.metrics().getCacheMisses()); } else { - assertEquals(2, g.cache(null).metrics().getCacheGets()); - assertEquals(0, g.cache(null).metrics().getCacheHits()); - assertEquals(2, g.cache(null).metrics().getCacheMisses()); + assertEquals(2, jcache.metrics().getCacheGets()); + assertEquals(0, jcache.metrics().getCacheHits()); + assertEquals(2, jcache.metrics().getCacheMisses()); } } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/244e604a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiGetSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiGetSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiGetSelfTest.java index 6da1db7..6eba373 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiGetSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiGetSelfTest.java @@ -21,8 +21,8 @@ import org.apache.ignite.*; import org.apache.ignite.cache.*; import org.apache.ignite.cache.affinity.*; import org.apache.ignite.configuration.*; +import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.*; -import org.apache.ignite.internal.transactions.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.spi.discovery.tcp.*; import org.apache.ignite.spi.discovery.tcp.ipfinder.*; @@ -103,11 +103,11 @@ public class GridCacheNearMultiGetSelfTest extends GridCommonAbstractTest { for (int i = 0; i < GRID_CNT; i++) { Ignite g = grid(i); - GridCache<Integer, String> c = g.cache(null); + IgniteCache<Integer, String> c = g.jcache(null); c.removeAll(); - assertEquals("Cache size mismatch for grid [grid=" + g.name() + ", entrySet=" + c.entrySet() + ']', + assertEquals("Cache size mismatch for grid [grid=" + g.name() + ", entrySet=" + entrySet(c) + ']', 0, c.size()); } } @@ -221,7 +221,8 @@ public class GridCacheNearMultiGetSelfTest extends GridCommonAbstractTest { */ private void checkDoubleGet(IgniteTxConcurrency concurrency, IgniteTxIsolation isolation, boolean put) throws Exception { - GridCache<Integer, String> cache = grid(0).cache(null); + IgniteEx ignite = grid(0); + IgniteCache<Integer, String> cache = ignite.jcache(null); Integer key = 1; @@ -230,13 +231,13 @@ public class GridCacheNearMultiGetSelfTest extends GridCommonAbstractTest { if (put) cache.put(key, val = Integer.toString(key)); - IgniteTx tx = cache.txStart(concurrency, isolation, 0, 0); + IgniteTx tx = ignite.transactions().txStart(concurrency, isolation, 0, 0); try { if (isTestDebug()) { info("Started transaction."); - CacheAffinity<Integer> aff = cache.affinity(); + CacheAffinity<Integer> aff = affinity(cache); int part = aff.partition(key); @@ -265,7 +266,7 @@ public class GridCacheNearMultiGetSelfTest extends GridCommonAbstractTest { if (isTestDebug()) info("Committed transaction: " + tx); } - catch (IgniteTxOptimisticCheckedException e) { + catch (IgniteTxOptimisticException e) { if (concurrency != OPTIMISTIC || isolation != SERIALIZABLE) { error("Received invalid optimistic failure.", e); @@ -300,7 +301,7 @@ public class GridCacheNearMultiGetSelfTest extends GridCommonAbstractTest { throw e; } finally { - IgniteTx t = cache.tx(); + IgniteTx t = ignite.transactions().tx(); assert t == null : "Thread should not have transaction upon completion ['t==tx'=" + (t == tx) + ", t=" + t + (t != tx ? "tx=" + tx : "tx=''") + ']'; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/244e604a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java index e783f3a..32cf658 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java @@ -166,7 +166,7 @@ public class GridCacheNearMultiNodeSelfTest extends GridCommonAbstractTest { store.reset(); for (int i = 0; i < GRID_CNT; i++) { - IgniteTx tx = grid(i).cache(null).tx(); + IgniteTx tx = grid(i).transactions().tx(); if (tx != null) { error("Ending zombie transaction: " + tx); @@ -199,7 +199,7 @@ public class GridCacheNearMultiNodeSelfTest extends GridCommonAbstractTest { * @return Affinity. */ private CacheAffinity<Object> affinity(int idx) { - return grid(idx).cache(null).affinity(); + return grid(idx).affinity(null); } /** @param cnt Count. */ @@ -319,11 +319,11 @@ public class GridCacheNearMultiNodeSelfTest extends GridCommonAbstractTest { backup = grid(0); } - assertEquals(String.valueOf(key), backup.cache(null).get(key)); + assertEquals(String.valueOf(key), backup.jcache(null).get(key)); - primary.cache(null).put(key, "a"); + primary.jcache(null).put(key, "a"); - assertEquals("a", backup.cache(null).get(key)); + assertEquals("a", backup.jcache(null).get(key)); } /** @throws Exception If failed. */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/244e604a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyTopologySelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyTopologySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyTopologySelfTest.java index 25ba562..c2d063f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyTopologySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyTopologySelfTest.java @@ -18,7 +18,6 @@ package org.apache.ignite.internal.processors.cache.distributed.near; import org.apache.ignite.*; -import org.apache.ignite.cache.*; import org.apache.ignite.cluster.*; import org.apache.ignite.configuration.*; import org.apache.ignite.internal.cluster.*; @@ -113,7 +112,7 @@ public class GridCacheNearOnlyTopologySelfTest extends GridCommonAbstractTest { } for (int i = 0; i < 100; i++) - assertFalse("For key: " + i, grid(0).cache(null).affinity().isPrimaryOrBackup(grid(0).localNode(), i)); + assertFalse("For key: " + i, grid(0).affinity(null).isPrimaryOrBackup(grid(0).localNode(), i)); } finally { stopAllGrids(); @@ -159,9 +158,10 @@ public class GridCacheNearOnlyTopologySelfTest extends GridCommonAbstractTest { } for (int i = 0; i < 10; i++) - grid(1).cache(null).put(i, i); + grid(1).jcache(null).put(i, i); - final GridCache<Object, Object> nearOnly = grid(0).cache(null); + final Ignite igniteNearOnly = grid(0); + final IgniteCache<Object, Object> nearOnly = igniteNearOnly.jcache(null); // Populate near cache. for (int i = 0; i < 10; i++) { @@ -177,18 +177,18 @@ public class GridCacheNearOnlyTopologySelfTest extends GridCommonAbstractTest { final int key = i; - GridTestUtils.assertThrows(log, new Callable<Object>() { + GridTestUtils.assertThrowsWithCause(new Callable<Object>() { @Override public Object call() throws Exception { return nearOnly.get(key); } - }, ClusterTopologyCheckedException.class, null); + }, ClusterTopologyCheckedException.class); } // Test optimistic transaction. GridTestUtils.assertThrows(log, new Callable<Object>() { @Override public Object call() throws Exception { - try (IgniteTx tx = nearOnly.txStart(OPTIMISTIC, REPEATABLE_READ)) { - nearOnly.putx("key", "val"); + try (IgniteTx tx = igniteNearOnly.transactions().txStart(OPTIMISTIC, REPEATABLE_READ)) { + nearOnly.put("key", "val"); tx.commit(); } @@ -198,9 +198,9 @@ public class GridCacheNearOnlyTopologySelfTest extends GridCommonAbstractTest { }, ClusterTopologyException.class, null); // Test pessimistic transaction. - GridTestUtils.assertThrows(log, new Callable<Object>() { + GridTestUtils.assertThrowsWithCause(new Callable<Object>() { @Override public Object call() throws Exception { - try (IgniteTx tx = nearOnly.txStart(PESSIMISTIC, REPEATABLE_READ)) { + try (IgniteTx tx = igniteNearOnly.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { nearOnly.put("key", "val"); tx.commit(); @@ -208,7 +208,7 @@ public class GridCacheNearOnlyTopologySelfTest extends GridCommonAbstractTest { return null; } - }, ClusterTopologyCheckedException.class, null); + }, ClusterTopologyCheckedException.class); } finally { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/244e604a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearPartitionedClearSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearPartitionedClearSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearPartitionedClearSelfTest.java index 6f9e994..48da12d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearPartitionedClearSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearPartitionedClearSelfTest.java @@ -104,22 +104,22 @@ public class GridCacheNearPartitionedClearSelfTest extends GridCommonAbstractTes * @throws Exception If failed. */ public void testClear() throws Exception { - GridCache cache = cacheForIndex(0); + IgniteCache cache = cacheForIndex(0); int key = primaryKey0(grid(0), cache); - cache.putx(key, 1); + cache.put(key, 1); cache.clear(); for (int i = 0; i < GRID_CNT; i++) { - GridCache cache0 = cacheForIndex(i); + IgniteCache cache0 = cacheForIndex(i); cache0.removeAll(); assert cache0.isEmpty(); } - cache.putx(key, 1); + cache.put(key, 1); cache.clear(); assertEquals(0, cache.size()); @@ -132,11 +132,11 @@ public class GridCacheNearPartitionedClearSelfTest extends GridCommonAbstractTes * @return Primary key. * @throws Exception If failed. */ - private int primaryKey0(Ignite ignite, GridCache cache) throws Exception { + private int primaryKey0(Ignite ignite, IgniteCache cache) throws Exception { ClusterNode locNode = ignite.cluster().localNode(); for (int i = 0; i < Integer.MAX_VALUE; i++) { - if (cache.affinity().isPrimary(locNode, i)) + if (affinity(cache).isPrimary(locNode, i)) return i; } @@ -149,7 +149,7 @@ public class GridCacheNearPartitionedClearSelfTest extends GridCommonAbstractTes * @param idx Index. * @return Cache. */ - private GridCache cacheForIndex(int idx) { - return grid(idx).cache(CACHE_NAME); + private IgniteCache cacheForIndex(int idx) { + return grid(idx).jcache(CACHE_NAME); } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/244e604a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReaderPreloadSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReaderPreloadSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReaderPreloadSelfTest.java index 61cd08d..7846424 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReaderPreloadSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReaderPreloadSelfTest.java @@ -52,13 +52,13 @@ public class GridCacheNearReaderPreloadSelfTest extends GridCommonAbstractTest { private static final String CACHE_NAME = "cache"; /** Cache on primary node. */ - private GridCache<Integer, Integer> cache1; + private IgniteCache<Integer, Integer> cache1; /** Cache on near node. */ - private GridCache<Integer, Integer> cache2; + private IgniteCache<Integer, Integer> cache2; /** Cache on backup node. */ - private GridCache<Integer, Integer> cache3; + private IgniteCache<Integer, Integer> cache3; /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { @@ -106,9 +106,9 @@ public class GridCacheNearReaderPreloadSelfTest extends GridCommonAbstractTest { info("Node 2: " + node2.cluster().localNode().id()); info("Node 3: " + node3.cluster().localNode().id()); - cache1 = node1.cache(CACHE_NAME); - cache2 = node2.cache(CACHE_NAME); - cache3 = node3.cache(CACHE_NAME); + cache1 = node1.jcache(CACHE_NAME); + cache2 = node2.jcache(CACHE_NAME); + cache3 = node3.jcache(CACHE_NAME); } /** @@ -153,14 +153,14 @@ public class GridCacheNearReaderPreloadSelfTest extends GridCommonAbstractTest { int key = 0; while (true) { - Collection<ClusterNode> affNodes = cache1.affinity().mapKeyToPrimaryAndBackups(key); + Collection<ClusterNode> affNodes = affinity(cache1).mapKeyToPrimaryAndBackups(key); assert !F.isEmpty(affNodes); ClusterNode primaryNode = F.first(affNodes); - if (F.eq(primaryNode, cache1.gridProjection().ignite().cluster().localNode()) && - affNodes.contains(cache3.gridProjection().ignite().cluster().localNode())) + if (F.eq(primaryNode, cache1.unwrap(Ignite.class).cluster().localNode()) && + affNodes.contains(cache3.unwrap(Ignite.class).cluster().localNode())) break; key++; @@ -190,10 +190,10 @@ public class GridCacheNearReaderPreloadSelfTest extends GridCommonAbstractTest { * @param expVal Expected value. * @throws Exception If failed. */ - private void checkCache(GridCache<Integer, Integer> cache, int key, int expVal) throws Exception { - Cache.Entry<Integer, Integer> entry = cache.entry(key); + private void checkCache(IgniteCache<Integer, Integer> cache, int key, int expVal) throws Exception { + Integer val = cache.get(key); - assert F.eq(expVal, entry.getValue()) : "Unexpected cache value [key=" + key + ", expected=" + expVal + - ", actual=" + entry.getValue() + ']'; + assert F.eq(expVal, val) : "Unexpected cache value [key=" + key + ", expected=" + expVal + + ", actual=" + val + ']'; } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/244e604a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReadersSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReadersSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReadersSelfTest.java index 97aed68..9c87268 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReadersSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReadersSelfTest.java @@ -297,8 +297,8 @@ public class GridCacheNearReadersSelfTest extends GridCommonAbstractTest { startGrids(); try { - GridCache<Object, Object> prj0 = grid(0).cache(null); - GridCache<Object, Object> prj1 = grid(1).cache(null); + IgniteCache<Object, Object> prj0 = grid(0).jcache(null); + IgniteCache<Object, Object> prj1 = grid(1).jcache(null); Map<Integer, Integer> putMap = new HashMap<>(); @@ -333,9 +333,9 @@ public class GridCacheNearReadersSelfTest extends GridCommonAbstractTest { startGrids(); try { - GridCache<Object, Object> prj0 = grid(0).cache(null); - GridCache<Object, Object> prj1 = grid(1).cache(null); - GridCache<Object, Object> prj2 = grid(2).cache(null); + IgniteCache<Object, Object> prj0 = grid(0).jcache(null); + IgniteCache<Object, Object> prj1 = grid(1).jcache(null); + IgniteCache<Object, Object> prj2 = grid(2).jcache(null); Map<Integer, Integer> putMap = new HashMap<>(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/244e604a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxMultiNodeSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxMultiNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxMultiNodeSelfTest.java index d37b1cb..01de425 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxMultiNodeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxMultiNodeSelfTest.java @@ -99,7 +99,7 @@ public class GridCacheNearTxMultiNodeSelfTest extends GridCommonAbstractTest { Integer mainKey = 0; ClusterNode priNode = ignite.cluster().mapKeyToNode(null, mainKey); - ClusterNode backupNode = F.first(F.view(ignite.cache(null).affinity().mapKeyToPrimaryAndBackups(mainKey), + ClusterNode backupNode = F.first(F.view(ignite.affinity(null).mapKeyToPrimaryAndBackups(mainKey), F.notIn(F.asList(priNode)))); ClusterNode otherNode = F.first(ignite.cluster().forPredicate(F.notIn(F.asList(priNode, backupNode))).nodes()); @@ -117,13 +117,13 @@ public class GridCacheNearTxMultiNodeSelfTest extends GridCommonAbstractTest { // Update main key from all nodes. for (Ignite g : ignites) - g.cache(null).put(mainKey, ++cntr); + g.jcache(null).put(mainKey, ++cntr); info("Updated mainKey from all nodes."); int keyCnt = 200; - Collection<Integer> keys = new LinkedList<>(); + Set<Integer> keys = new TreeSet<>(); // Populate cache from all nodes. for (int i = 1; i <= keyCnt; i++) { @@ -131,12 +131,12 @@ public class GridCacheNearTxMultiNodeSelfTest extends GridCommonAbstractTest { Ignite g = F.rand(ignites); - g.cache(null).put(new CacheAffinityKey<>(i, mainKey), Integer.toString(cntr++)); + g.jcache(null).put(new CacheAffinityKey<>(i, mainKey), Integer.toString(cntr++)); } - CacheProjection cache = priIgnite.cache(null).flagsOn(CacheFlag.CLONE); + IgniteCache cache = priIgnite.jcache(null); - IgniteTx tx = cache.txStart(PESSIMISTIC, REPEATABLE_READ); + IgniteTx tx = priIgnite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ); try { cache.get(mainKey); @@ -197,9 +197,10 @@ public class GridCacheNearTxMultiNodeSelfTest extends GridCommonAbstractTest { * @throws Exception If failed. */ private void testReadersUpdate(IgniteTxConcurrency concurrency, IgniteTxIsolation isolation) throws Exception { - GridCache<Integer, Integer> cache = grid(0).cache(null); + Ignite ignite = grid(0); + IgniteCache<Integer, Integer> cache = ignite.jcache(null); - try (IgniteTx tx = cache.txStart(concurrency, isolation)) { + try (IgniteTx tx = ignite.transactions().txStart(concurrency, isolation)) { for (int i = 0; i < 100; i++) cache.put(i, 1); @@ -208,13 +209,13 @@ public class GridCacheNearTxMultiNodeSelfTest extends GridCommonAbstractTest { // Create readers. for (int g = 0; g < GRID_CNT; g++) { - GridCache<Integer, Integer> c = grid(g).cache(null); + IgniteCache<Integer, Integer> c = grid(g).jcache(null); for (int i = 0; i < 100; i++) assertEquals((Integer)1, c.get(i)); } - try (IgniteTx tx = cache.txStart(concurrency, isolation)) { + try (IgniteTx tx = ignite.transactions().txStart(concurrency, isolation)) { for (int i = 0; i < 100; i++) cache.put(i, 2); @@ -222,7 +223,7 @@ public class GridCacheNearTxMultiNodeSelfTest extends GridCommonAbstractTest { } for (int g = 0; g < GRID_CNT; g++) { - GridCache<Integer, Integer> c = grid(g).cache(null); + IgniteCache<Integer, Integer> c = grid(g).jcache(null); for (int i = 0; i < 100; i++) assertEquals((Integer)2, c.get(i)); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/244e604a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedAffinityExcludeNeighborsPerformanceTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedAffinityExcludeNeighborsPerformanceTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedAffinityExcludeNeighborsPerformanceTest.java index 803a620..cdeaa54 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedAffinityExcludeNeighborsPerformanceTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedAffinityExcludeNeighborsPerformanceTest.java @@ -90,7 +90,7 @@ public class GridCachePartitionedAffinityExcludeNeighborsPerformanceTest extends * @return Affinity. */ static CacheAffinity<Object> affinity(Ignite ignite) { - return ignite.cache(null).affinity(); + return ignite.affinity(null); } /** http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/244e604a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedAffinitySelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedAffinitySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedAffinitySelfTest.java index 46eca5d..879e240 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedAffinitySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedAffinitySelfTest.java @@ -99,7 +99,7 @@ public class GridCachePartitionedAffinitySelfTest extends GridCommonAbstractTest * @return Affinity. */ static CacheAffinity<Object> affinity(Ignite ignite) { - return ignite.cache(null).affinity(); + return ignite.affinity(null); } /** @@ -393,7 +393,7 @@ public class GridCachePartitionedAffinitySelfTest extends GridCommonAbstractTest Ignite mg = grid(0); - GridCache<Integer, String> mc = mg.cache(null); + IgniteCache<Integer, String> mc = mg.jcache(null); int keyCnt = 10; @@ -410,7 +410,7 @@ public class GridCachePartitionedAffinitySelfTest extends GridCommonAbstractTest info("Before putting key [key=" + i + ", grid=" + mg.name() + ']'); - mc.putx(i, Integer.toString(i)); + mc.put(i, Integer.toString(i)); if (failFlag.get()) fail("testAffinityWithPut failed."); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/244e604a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedFullApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedFullApiSelfTest.java index 4625d43..52f363a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedFullApiSelfTest.java @@ -78,175 +78,4 @@ public class GridCachePartitionedFullApiSelfTest extends GridCacheAbstractFullAp for (int i = 0 ; i < aff.getPartitions(); i++) String.valueOf(cache.entrySet(i)); } - - /** - * @throws Exception If failed. - */ - public void testPartitionEntrySetIterator() throws Exception { - GridCacheAdapter<String, Integer> cache = ((IgniteKernal)grid(0)).internalCache(); - - Map<Integer, Collection<String>> partMap = new HashMap<>(); - - for (int i = 0; i < 1000; i++) { - String key = String.valueOf(i); - - int part = cache.affinity().partition(key); - - cache.put(key, i); - - Collection<String> keys = partMap.get(part); - - if (keys == null) { - keys = new LinkedList<>(); - - partMap.put(part, keys); - } - - keys.add(key); - } - - for (Map.Entry<Integer, Collection<String>> entry : partMap.entrySet()) { - int part = entry.getKey(); - Collection<String> vals = entry.getValue(); - - String key = F.first(vals); - - for (int i = 0; i < gridCount(); i++) { - Ignite g = grid(i); - - // This node has the partition. - GridCache<String, Integer> nodeCache = g.cache(null); - - if (offheapTiered(nodeCache)) - continue; - - Set<Cache.Entry<String, Integer>> partEntrySet = nodeCache.entrySet(part); - - if (nodeCache.affinity().isPrimaryOrBackup(g.cluster().localNode(), key)) { - Collection<String> cp = new LinkedList<>(vals); - - for (Cache.Entry<String, Integer> e : partEntrySet) { - String eKey = e.getKey(); - - assertTrue("Got unexpected key:" + eKey, cp.contains(eKey)); - - // Check contains. - assertTrue(partEntrySet.contains(nodeCache.entry(eKey))); - assertTrue(partEntrySet.contains(e)); - - cp.remove(eKey); - } - - assertTrue("Keys are not in partition entry set: " + cp, cp.isEmpty()); - } - else - assert partEntrySet == null || partEntrySet.isEmpty(); - } - } - - Collection<String> deleted = new LinkedList<>(); - - // Check remove. - for (Map.Entry<Integer, Collection<String>> entry : partMap.entrySet()) { - int part = entry.getKey(); - Collection<String> vals = entry.getValue(); - - String key = F.first(vals); - - for (int i = 0; i < gridCount(); i++) { - Ignite g = grid(i); - - // This node has the partition. - GridCache<String, Integer> nodeCache = g.cache(null); - - if (offheapTiered(nodeCache)) - continue; - - // First node with this partition will remove first key from partition. - if (nodeCache.affinity().isPrimaryOrBackup(g.cluster().localNode(), key)) { - Set<Cache.Entry<String, Integer>> partEntrySet = nodeCache.entrySet(part); - - Iterator<Cache.Entry<String, Integer>> it = partEntrySet.iterator(); - - assertTrue(it.hasNext()); - - Cache.Entry<String, Integer> next = it.next(); - - deleted.add(next.getKey()); - - it.remove(); - - break; // For. - } - } - } - - for (String delKey : deleted) { - for (int i = 0; i < gridCount(); i++) - assertNull(grid(i).cache(null).get(delKey)); - } - } - - /** - * @throws Exception If failed. - */ - public void testPartitionEntrySetRemove() throws Exception { - IgniteCache<String, Integer> cache = jcache(0); - - Map<Integer, Collection<String>> partMap = new HashMap<>(); - - for (int i = 0; i < 1000; i++) { - String key = String.valueOf(i); - - int part = grid(0).affinity(null).partition(key); - - cache.put(key, i); - - Collection<String> keys = partMap.get(part); - - if (keys == null) { - keys = new LinkedList<>(); - - partMap.put(part, keys); - } - - keys.add(key); - } - - Collection<String> deleted = new LinkedList<>(); - - for (Map.Entry<Integer, Collection<String>> entry : partMap.entrySet()) { - int part = entry.getKey(); - Collection<String> vals = entry.getValue(); - - String key = F.first(vals); - - for (int i = 0; i < gridCount(); i++) { - Ignite g = grid(i); - - // This node has the partition. - GridCache<String, Integer> nodeCache = g.cache(null); - - if (offheapTiered(nodeCache)) - continue; - - Set<Cache.Entry<String, Integer>> partEntrySet = nodeCache.entrySet(part); - - if (nodeCache.affinity().isPrimaryOrBackup(g.cluster().localNode(), key)) { - assertTrue(partEntrySet.contains(nodeCache.entry(key))); - - deleted.add(key); - - assertTrue(partEntrySet.remove(nodeCache.entry(key))); - - break; // For. - } - } - } - - for (String delKey : deleted) { - for (int i = 0; i < gridCount(); i++) - assertNull(grid(i).cache(null).get(delKey)); - } - } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/244e604a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeCounterSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeCounterSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeCounterSelfTest.java index 66e739d..d6ce670 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeCounterSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeCounterSelfTest.java @@ -241,7 +241,7 @@ public class GridCachePartitionedMultiNodeCounterSelfTest extends GridCommonAbst X.println("*** Retries: " + RETRIES); X.println("*** Log frequency: " + LOG_FREQ); - CacheAffinity<String> aff = affinity(grid(0).<String, Integer>cache(null)); + CacheAffinity<String> aff = affinity(grid(0).<String, Integer>jcache(null)); Collection<ClusterNode> affNodes = aff.mapKeyToPrimaryAndBackups(CNTR_KEY); @@ -261,7 +261,7 @@ public class GridCachePartitionedMultiNodeCounterSelfTest extends GridCommonAbst final UUID priId = pri.cluster().localNode().id(); // Initialize. - pri.cache(null).put(CNTR_KEY, 0); + pri.jcache(null).put(CNTR_KEY, 0); // nears.get(0).cache(null).put(CNTR_KEY, 0); assertNull(near(pri).peekEx(CNTR_KEY)); @@ -306,13 +306,13 @@ public class GridCachePartitionedMultiNodeCounterSelfTest extends GridCommonAbst if (DEBUG) info("***"); - GridCache<String, Integer> c = pri.cache(null); + IgniteCache<String, Integer> c = pri.jcache(null); Integer oldCntr = c.peek(CNTR_KEY); GridCacheEntryEx<String, Integer> dhtNear = near(pri).peekEx(CNTR_KEY); - try (IgniteTx tx = c.txStart(PESSIMISTIC, REPEATABLE_READ)) { + try (IgniteTx tx = pri.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { if (DEBUG) info("Started tx [grid=" + pri.name() + ", primary=true, xid=" + tx.xid() + ", oldCntr=" + oldCntr + ", node=" + priId + ", dhtEntry=" + dhtEntry + @@ -343,7 +343,7 @@ public class GridCachePartitionedMultiNodeCounterSelfTest extends GridCommonAbst assert globalCntr.compareAndSet(global, newCntr) : invalid("Invalid global counter", pri, true, newCntr, global); - int prev = c.put(CNTR_KEY, newCntr); + int prev = c.getAndPut(CNTR_KEY, newCntr); if (DEBUG) info("Put new value [grid=" + pri.name() + ", primary=true, prev=" + prev + @@ -403,11 +403,11 @@ public class GridCachePartitionedMultiNodeCounterSelfTest extends GridCommonAbst if (DEBUG) info("***"); - GridCache<String, Integer> c = near.cache(null); + IgniteCache<String, Integer> c = near.jcache(null); Integer oldCntr = c.peek(CNTR_KEY); - try (IgniteTx tx = c.txStart(PESSIMISTIC, REPEATABLE_READ)) { + try (IgniteTx tx = near.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { if (DEBUG) info("Started tx [grid=" + near.name() + ", primary=false, xid=" + tx.xid() + ", oldCntr=" + oldCntr + ", node=" + nearId + @@ -441,7 +441,7 @@ public class GridCachePartitionedMultiNodeCounterSelfTest extends GridCommonAbst assert globalCntr.compareAndSet(global, newCntr) : invalid("Invalid global counter", near, false, newCntr, global); - int prev = c.put(CNTR_KEY, newCntr); + int prev = c.getAndPut(CNTR_KEY, newCntr); if (DEBUG) info("Put new value [grid=" + near.name() + ", primary=false, prev=" + @@ -488,7 +488,7 @@ public class GridCachePartitionedMultiNodeCounterSelfTest extends GridCommonAbst dht(g).context().tm().printMemoryStats(); near(g).context().tm().printMemoryStats(); - GridCache<String, Integer> cache = grid(i).cache(null); + IgniteCache<String, Integer> cache = grid(i).jcache(null); int cntr = nearThreads > 0 && nears.contains(g) ? cache.get(CNTR_KEY) : cache.peek(CNTR_KEY); @@ -543,7 +543,7 @@ public class GridCachePartitionedMultiNodeCounterSelfTest extends GridCommonAbst * @throws Exception If failed. */ private void checkNearAndPrimaryMultiNode(int gridCnt) throws Exception { - CacheAffinity<String> aff = affinity(grid(0).<String, Integer>cache(null)); + CacheAffinity<String> aff = affinity(grid(0).<String, Integer>jcache(null)); Collection<ClusterNode> affNodes = aff.mapKeyToPrimaryAndBackups(CNTR_KEY); @@ -552,7 +552,7 @@ public class GridCachePartitionedMultiNodeCounterSelfTest extends GridCommonAbst Ignite pri = G.ignite(F.first(affNodes).id()); // Initialize. - pri.cache(null).put(CNTR_KEY, 0); + pri.jcache(null).put(CNTR_KEY, 0); assertNull(near(pri).peekEx(CNTR_KEY)); @@ -576,7 +576,7 @@ public class GridCachePartitionedMultiNodeCounterSelfTest extends GridCommonAbst for (int i = 0; i < gridCnt; i++) { Ignite g = grid(i); - GridCache<String, Integer> cache = grid(i).cache(null); + IgniteCache<String, Integer> cache = grid(i).jcache(null); int cntr = cache.peek(CNTR_KEY); @@ -640,11 +640,11 @@ public class GridCachePartitionedMultiNodeCounterSelfTest extends GridCommonAbst if (DEBUG) log.info("***"); - GridCache<String, Integer> c = near.cache(null); + IgniteCache<String, Integer> c = near.jcache(null); Integer oldCntr = c.peek(CNTR_KEY); - try (IgniteTx tx = c.txStart(PESSIMISTIC, REPEATABLE_READ)) { + try (IgniteTx tx = near.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { if (DEBUG) log.info("Started tx [grid=" + near.name() + ", primary=false, xid=" + tx.xid() + ", oldCntr=" + oldCntr + ", node=" + nearId + ", nearEntry=" + nearEntry + ']'); @@ -670,7 +670,7 @@ public class GridCachePartitionedMultiNodeCounterSelfTest extends GridCommonAbst assert globalCntrMultiNode.compareAndSet(global, newCntr) : invalid("Invalid global counter", near, false, newCntr, global); - int prev = c.put(CNTR_KEY, newCntr); + int prev = c.getAndPut(CNTR_KEY, newCntr); if (DEBUG) log.info("Put new value [grid=" + near.name() + ", primary=false, prev=" + prev + @@ -709,13 +709,13 @@ public class GridCachePartitionedMultiNodeCounterSelfTest extends GridCommonAbst if (DEBUG) log.info("***"); - GridCache<String, Integer> c = pri.cache(null); + IgniteCache<String, Integer> c = pri.jcache(null); Integer oldCntr = c.peek(CNTR_KEY); GridCacheEntryEx<String, Integer> dhtNear = near(pri).peekEx(CNTR_KEY); - try (IgniteTx tx = c.txStart(PESSIMISTIC, REPEATABLE_READ)) { + try (IgniteTx tx = pri.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { if (DEBUG) log.info("Started tx [grid=" + pri.name() + ", primary=true, xid=" + tx.xid() + ", oldCntr=" + oldCntr + ", node=" + pri.name() + ", dhtEntry=" + @@ -746,7 +746,7 @@ public class GridCachePartitionedMultiNodeCounterSelfTest extends GridCommonAbst assert globalCntrMultiNode.compareAndSet(global, newCntr) : invalid("Invalid global counter", pri, true, newCntr, global); - int prev = c.put(CNTR_KEY, newCntr); + int prev = c.getAndPut(CNTR_KEY, newCntr); if (DEBUG) { log.info("Put new value [grid=" + pri.name() + ", primary=true, prev=" + prev + http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/244e604a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java index 178e5c6..c58b6ea 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java @@ -61,13 +61,6 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti } /** - * TODO fix and uncomment - */ - @Override public void testPartitionEntrySetRemove() throws Exception { - assert false : "ignite-96"; - } - - /** * @throws Exception If failed. */ public void testPutAllRemoveAll() throws Exception { @@ -372,11 +365,11 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti info("All affinity nodes: " + affinityNodes()); - GridCache<Object, Object> cache = grid(0).cache(null); + IgniteCache<Object, Object> cache = grid(0).jcache(null); - info("Cache affinity nodes: " + cache.affinity().mapKeyToPrimaryAndBackups(key)); + info("Cache affinity nodes: " + affinity(cache).mapKeyToPrimaryAndBackups(key)); - CacheAffinity<Object> aff = cache.affinity(); + CacheAffinity<Object> aff = affinity(cache); Collection<ClusterNode> nodes = aff.mapKeyToPrimaryAndBackups(key); @@ -408,19 +401,19 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti assertNotNull(backup); assertNotNull(other); - assertTrue(cache.affinity().isPrimary(primary, key)); - assertFalse(cache.affinity().isBackup(primary, key)); - assertTrue(cache.affinity().isPrimaryOrBackup(primary, key)); + assertTrue(affinity(cache).isPrimary(primary, key)); + assertFalse(affinity(cache).isBackup(primary, key)); + assertTrue(affinity(cache).isPrimaryOrBackup(primary, key)); - assertFalse(cache.affinity().isPrimary(backup, key)); - assertTrue(cache.affinity().isBackup(backup, key)); - assertTrue(cache.affinity().isPrimaryOrBackup(backup, key)); + assertFalse(affinity(cache).isPrimary(backup, key)); + assertTrue(affinity(cache).isBackup(backup, key)); + assertTrue(affinity(cache).isPrimaryOrBackup(backup, key)); - assertFalse(cache.affinity().isPrimary(other, key)); + assertFalse(affinity(cache).isPrimary(other, key)); if (cacheMode() == PARTITIONED) { - assertFalse(cache.affinity().isBackup(other, key)); - assertFalse(cache.affinity().isPrimaryOrBackup(other, key)); + assertFalse(affinity(cache).isBackup(other, key)); + assertFalse(affinity(cache).isPrimaryOrBackup(other, key)); } } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/244e604a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedUnswapAdvancedSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedUnswapAdvancedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedUnswapAdvancedSelfTest.java index 24d5b00..6abab30 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedUnswapAdvancedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedUnswapAdvancedSelfTest.java @@ -78,8 +78,8 @@ public class GridCacheReplicatedUnswapAdvancedSelfTest extends GridCommonAbstrac assert g1.cluster().nodes().size() > 1 : "This test needs at least two grid nodes started."; - GridCache<Object, Object> cache1 = g1.cache(null); - GridCache<Object, Object> cache2 = g2.cache(null); + IgniteCache<Object, Object> cache1 = g1.jcache(null); + IgniteCache<Object, Object> cache2 = g2.jcache(null); try { ClassLoader ldr = new GridTestClassLoader( @@ -107,7 +107,7 @@ public class GridCacheReplicatedUnswapAdvancedSelfTest extends GridCommonAbstrac for (int i = 0; i < 1000; i++) { String k = "key-" + i; - if (cache1.affinity().isPrimary(g1.cluster().localNode(), k)) { + if (affinity(cache1).isPrimary(g1.cluster().localNode(), k)) { key = k; break; @@ -135,7 +135,9 @@ public class GridCacheReplicatedUnswapAdvancedSelfTest extends GridCommonAbstrac // To swap storage. cache2.evict(key); - v2 = cache2.promote(key); + cache2.promote(key); + + v2 = cache2.peek(key); log.info("Unswapped entry value: " + v2); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/244e604a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheSyncReplicatedPreloadSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheSyncReplicatedPreloadSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheSyncReplicatedPreloadSelfTest.java index 7a546e4..d5b2efd 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheSyncReplicatedPreloadSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheSyncReplicatedPreloadSelfTest.java @@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.cache.distributed.replicated; import org.apache.ignite.*; import org.apache.ignite.configuration.*; +import org.apache.ignite.internal.*; import org.apache.ignite.spi.discovery.tcp.*; import org.apache.ignite.spi.discovery.tcp.ipfinder.*; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*; @@ -98,17 +99,17 @@ public class GridCacheSyncReplicatedPreloadSelfTest extends GridCommonAbstractTe Ignite g1 = startGrid(1); for (int i = 0; i < keyCnt; i++) - g0.cache(null).putx(i, i); + g0.jcache(null).put(i, i); - assertEquals(keyCnt, g0.cache(null).size()); - assertEquals(keyCnt, g1.cache(null).size()); + assertEquals(keyCnt, ((IgniteKernal)g0).internalCache(null).size()); + assertEquals(keyCnt, ((IgniteKernal)g1).internalCache(null).size()); for (int n = 0; n < retries; n++) { info("Starting additional grid node..."); Ignite g2 = startGrid(2); - assertEquals(keyCnt, g2.cache(null).size()); + assertEquals(keyCnt, ((IgniteKernal)g2).internalCache(null).size()); info("Stopping additional grid node..."); @@ -122,17 +123,17 @@ public class GridCacheSyncReplicatedPreloadSelfTest extends GridCommonAbstractTe @SuppressWarnings({"TooBroadScope"}) public void testNodeRestartMultithreaded() throws Exception { final int keyCnt = 1000; - final int retries = 300; + final int retries = 50; int threadCnt = 5; Ignite g0 = startGrid(0); Ignite g1 = startGrid(1); for (int i = 0; i < keyCnt; i++) - g0.cache(null).putx(i, i); + g0.jcache(null).put(i, i); - assertEquals(keyCnt, g0.cache(null).size()); - assertEquals(keyCnt, g1.cache(null).size()); + assertEquals(keyCnt, ((IgniteKernal)g0).internalCache(null).size()); + assertEquals(keyCnt, ((IgniteKernal)g1).internalCache(null).size()); final AtomicInteger cnt = new AtomicInteger(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/244e604a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadLifecycleSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadLifecycleSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadLifecycleSelfTest.java index ab313d8..52eb6b2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadLifecycleSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadLifecycleSelfTest.java @@ -27,6 +27,7 @@ import org.apache.ignite.lang.*; import org.apache.ignite.lifecycle.*; import org.apache.ignite.resources.*; +import javax.cache.*; import java.util.*; import static org.apache.ignite.cache.CacheMode.*; @@ -83,56 +84,49 @@ public class GridCacheReplicatedPreloadLifecycleSelfTest extends GridCachePreloa private Ignite ignite; @Override public void onLifecycleEvent(LifecycleEventType evt) { - try { - switch (evt) { - case AFTER_GRID_START: { - GridCache<Object, MyValue> c1 = ignite.cache("one"); - GridCache<Object, MyValue> c2 = ignite.cache("two"); + switch (evt) { + case AFTER_GRID_START: { + IgniteCache<Object, MyValue> c1 = ignite.jcache("one"); + IgniteCache<Object, MyValue> c2 = ignite.jcache("two"); - if (!ignite.name().contains("Test0")) { - if (!quiet) { - info("Keys already in cache:"); + if (!ignite.name().contains("Test0")) { + if (!quiet) { + info("Keys already in cache:"); - for (Object k : c1.keySet()) - info("Cache1: " + k.toString()); + for (Cache.Entry<Object, MyValue> entry : c1) + info("Cache1: " + entry.getKey().toString()); - for (Object k : c2.keySet()) - info("Cache2: " + k.toString()); - } - - return; + for (Cache.Entry<Object, MyValue> entry : c2) + info("Cache2: " + entry.getKey().toString()); } - info("Populating cache data..."); + return; + } - int i = 0; + info("Populating cache data..."); - for (Object key : keys) { - c1.put(key, new MyValue(value(key))); + int i = 0; - if (i++ % 2 == 0) - c2.put(key, new MyValue(value(key))); - } + for (Object key : keys) { + c1.put(key, new MyValue(value(key))); - assert c1.size() == keys.length : "Invalid cache1 size [size=" + c1.size() + - ", entries=" + c1.entrySet() + ']'; - assert c2.size() == keys.length / 2 : "Invalid cache2 size [size=" + c2.size() + - ", entries=" + c2.entrySet() + ']'; - - break; + if (i++ % 2 == 0) + c2.put(key, new MyValue(value(key))); } - case BEFORE_GRID_START: - case BEFORE_GRID_STOP: - case AFTER_GRID_STOP: { - info("Lifecycle event: " + evt); + assert c1.size() == keys.length : "Invalid cache1 size [size=" + c1.size() + ']'; + assert c2.size() == keys.length / 2 : "Invalid cache2 size [size=" + c2.size() + ']'; - break; - } + break; + } + + case BEFORE_GRID_START: + case BEFORE_GRID_STOP: + case AFTER_GRID_STOP: { + info("Lifecycle event: " + evt); + + break; } - } - catch (IgniteCheckedException e) { - throw new IgniteException(e); } } }; @@ -153,16 +147,14 @@ public class GridCacheReplicatedPreloadLifecycleSelfTest extends GridCachePreloa info("Checking '" + (i + 1) + "' nodes..."); for (int j = 0; j < G.allGrids().size(); j++) { - GridCache<String, MyValue> c1 = grid(j).cache("one"); - GridCache<String, MyValue> c2 = grid(j).cache("two"); + IgniteCache<String, MyValue> c1 = grid(j).jcache("one"); + IgniteCache<String, MyValue> c2 = grid(j).jcache("two"); int size1 = c1.size(); int size2 = c2.size(); - assert size1 == keys.length : " Invalid cache1 size [i=" + i + ", j=" + j + ", size=" + size1 + - ", cache=" + c1.entrySet() + ']'; - assert size2 == keys.length / 2 : " Invalid cache2 size [i=" + i + ", j=" + j + ", size=" + size2 + - ", cache=" + c2.entrySet() + ']'; + assert size1 == keys.length : " Invalid cache1 size [i=" + i + ", j=" + j + ", size=" + size1 + ']'; + assert size2 == keys.length / 2 : " Invalid cache2 size [i=" + i + ", j=" + j + ", size=" + size2 + ']'; } } }