# IGNITE-56 Use IgniteCache instead of GridCache in the 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/cd72342a Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/cd72342a Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/cd72342a Branch: refs/heads/ignite-sql-tests Commit: cd72342a93fe493e125044ad5a5741619568eef7 Parents: 6bbaa99 Author: sevdokimov <sergey.evdoki...@jetbrains.com> Authored: Sun Feb 8 13:11:40 2015 +0300 Committer: sevdokimov <sergey.evdoki...@jetbrains.com> Committed: Sun Feb 8 13:11:40 2015 +0300 ---------------------------------------------------------------------- .../cache/GridCacheAbstractFullApiSelfTest.java | 141 +++---------------- .../cache/GridCacheAbstractSelfTest.java | 27 +--- .../GridCacheAtomicMessageCountSelfTest.java | 9 +- .../cache/GridCacheEntryMemorySizeSelfTest.java | 6 +- .../GridCacheGroupLockAbstractSelfTest.java | 14 +- ...dCachePartitionedQueueEntryMoveSelfTest.java | 8 +- .../GridCacheEntrySetAbstractSelfTest.java | 2 +- .../distributed/GridCacheEventAbstractTest.java | 7 +- ...heExpiredEntriesPreloadAbstractSelfTest.java | 2 +- .../distributed/GridCacheLockAbstractTest.java | 4 +- .../GridCacheMultiNodeLockAbstractTest.java | 4 +- .../GridCacheNodeFailureAbstractTest.java | 50 +++---- .../IgniteTxPreloadAbstractTest.java | 4 +- .../IgniteTxTimeoutAbstractTest.java | 6 +- ...heAbstractTransformWriteThroughSelfTest.java | 9 +- .../dht/GridCacheAtomicNearCacheSelfTest.java | 2 +- .../dht/GridCacheColocatedDebugTest.java | 27 ++-- ...cheGroupLockPartitionedAbstractSelfTest.java | 4 +- ...idCacheNearOnlyMultiNodeFullApiSelfTest.java | 5 - 19 files changed, 102 insertions(+), 229 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd72342a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java index 50ba5ef..a42348c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java @@ -194,11 +194,11 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract // Will actually delete entry from map. CU.invalidate(cache(i), "key0"); - assertNull("Failed check for grid: " + i, cache(i).peek("key0")); + assertNull("Failed check for grid: " + i, jcache(i).localPeek("key0", CachePeekMode.ONHEAP)); Collection<String> keysCol = mapped.get(grid(i).localNode()); - assert !cache(i).isEmpty() || F.isEmpty(keysCol); + assert jcache(i).localSize() != 0 || F.isEmpty(keysCol); } for (int i = 0; i < gridCount(); i++) { @@ -210,8 +210,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract if (ctx.affinity().localNode(key, ctx.discovery().topologyVersion())) sum++; - assertEquals("Incorrect key size on cache #" + i, sum, cache(i).keySet().size()); - assertEquals("Incorrect key size on cache #" + i, sum, cache(i).size()); + assertEquals("Incorrect key size on cache #" + i, sum, jcache(i).localSize()); } for (int i = 0; i < gridCount(); i++) { @@ -626,7 +625,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract assertNull(cache.get("key3")); for (int i = 0; i < gridCount(); i++) - assertNull("Failed for cache: " + i, cache(i).peek("key3")); + assertNull("Failed for cache: " + i, jcache(i).localPeek("key3", CachePeekMode.ONHEAP)); cache.remove("key1"); cache.put("key2", 1); @@ -641,7 +640,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract assertNull(cache.get("key3")); for (int i = 0; i < gridCount(); i++) - assertNull(cache(i).peek("key3")); + assertNull(jcache(i).localPeek("key3", CachePeekMode.ONHEAP)); } /** @@ -711,9 +710,9 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract Map<String, EntryProcessorResult<String>> res = cache.invokeAll(F.asSet("key1", "key2", "key3"), RMV_PROCESSOR); for (int i = 0; i < gridCount(); i++) { - assertNull(cache(i).peek("key1")); - assertNull(cache(i).peek("key2")); - assertNull(cache(i).peek("key3")); + assertNull(jcache(i).localPeek("key1", CachePeekMode.ONHEAP)); + assertNull(jcache(i).localPeek("key2", CachePeekMode.ONHEAP)); + assertNull(jcache(i).localPeek("key3", CachePeekMode.ONHEAP)); } assertEquals("null", res.get("key1").get()); @@ -861,8 +860,8 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract assertEquals(exp, cache.get("key")); for (int i = 0; i < gridCount(); i++) { - if (cache(i).affinity().isPrimaryOrBackup(grid(i).localNode(), "key")) - assertEquals(exp, peek(cache(i), "key")); + if (ignite(i).affinity(null).isPrimaryOrBackup(grid(i).localNode(), "key")) + assertEquals(exp, peek(jcache(i), "key")); } } @@ -1059,7 +1058,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract assertNull(cache.get("key3")); for (int i = 0; i < gridCount(); i++) - assertNull(cache(i).peek("key3")); + assertNull(jcache(i).localPeek("key3", CachePeekMode.ONHEAP)); } /** @@ -1098,7 +1097,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract assertNull(cache.get("k1")); for (int i = 0; i < gridCount(); i++) - assertNull(cache(i).peek("k1")); + assertNull(jcache(i).localPeek("k1", CachePeekMode.ONHEAP)); final EntryProcessor<String, Integer, Integer> errProcessor = new EntryProcessor<String, Integer, Integer>() { @Override public Integer process(MutableEntry<String, Integer> e, Object... args) { @@ -2103,9 +2102,9 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract String key = String.valueOf(i); if (grid(0).affinity(null).mapKeyToPrimaryAndBackups(key).contains(grid(g).localNode())) - assertEquals((Integer)i, cache(g).peek(key)); + assertEquals((Integer)i, jcache(g).localPeek(key, CachePeekMode.ONHEAP)); else - assertNull(cache(g).peek(key)); + assertNull(jcache(g).localPeek(key, CachePeekMode.ONHEAP)); } } } @@ -2203,7 +2202,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract cache.put("key2", 2); cache.put("key3", 3); - cache(gridCount() > 1 ? 1 : 0).removeAll(); + jcache(gridCount() > 1 ? 1 : 0).removeAll(); assert cache.localSize() == 0; long entryCount = hugeRemoveAllEntryCount(); @@ -2454,10 +2453,10 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract assertNull(peek(cache, key)); for (i = 0; i < gridCount(); i++) - cache(i).clear(); + jcache(i).clear(); for (i = 0; i < gridCount(); i++) - assert cache(i).isEmpty(); + assert jcache(i).localSize() == 0; for (Map.Entry<String, Integer> entry : vals.entrySet()) cache.put(entry.getKey(), entry.getValue()); @@ -2885,7 +2884,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract // Force reload on primary node. for (int i = 0; i < gridCount(); i++) { if (cache(i).entry(key).primary()) - cache(i).reload(key); + load(jcache(i), key, true); } // Will do near get request. @@ -3514,102 +3513,6 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract } /** - * @throws Exception If failed. - */ - public void testPrimaryData() throws Exception { - if (offheapTiered(cache(0))) - return; - - final List<String> keys = new ArrayList<>(3); - - for (int i = 0; i < 3; i++) { - while (true) { - String key = UUID.randomUUID().toString(); - - if (grid(0).mapKeyToNode(null, key).equals(grid(0).localNode())) { - assertTrue(cache(0).putx(key, i)); - - keys.add(key); - - break; - } - } - } - - if (cacheMode() == PARTITIONED && gridCount() > 1) { - for (int i = 0; i < 10; i++) { - while (true) { - String key = UUID.randomUUID().toString(); - - if (!grid(0).mapKeyToNode(null, key).equals(grid(0).localNode())) { - assertTrue(cache(1).putx(key, i)); - - break; - } - } - } - } - - List<String> subList = keys.subList(1, keys.size()); - - // --------------- - // Key set checks. - // --------------- - - info("Key set: " + cache(0).keySet()); - info("Entry set: " + cache(0).entrySet()); - info("Primary entry set: " + cache(0).primaryEntrySet()); - - Set<String> primKeys = cache(0).primaryKeySet(); - - assertEquals(3, primKeys.size()); - assertTrue(primKeys.containsAll(keys)); - - primKeys = cache(0).projection(new P1<CacheEntry<String, Integer>>() { - @Override public boolean apply(CacheEntry<String, Integer> e) { - return !e.getKey().equals(keys.get(0)); - } - }).primaryKeySet(); - - assertEquals(2, primKeys.size()); - assertTrue(primKeys.containsAll(subList)); - - // -------------- - // Values checks. - // -------------- - - Collection<Integer> primVals = cache(0).primaryValues(); - - assertEquals(3, primVals.size()); - assertTrue(primVals.containsAll(F.asList(0, 1, 2))); - - primVals = cache(0).projection(new P1<CacheEntry<String, Integer>>() { - @Override public boolean apply(CacheEntry<String, Integer> e) { - return !e.getKey().equals(keys.get(0)); - } - }).primaryValues(); - - assertEquals(2, primVals.size()); - assertTrue(primVals.containsAll(F.asList(1, 2))); - - // ----------------- - // Entry set checks. - // ----------------- - - Set<CacheEntry<String, Integer>> primEntries = cache(0).primaryEntrySet(); - - assertEquals(3, primEntries.size()); - - primEntries = cache(0).projection(new P1<CacheEntry<String, Integer>>() { - @Override public boolean apply(CacheEntry<String, Integer> e) { - return !e.getKey().equals(keys.get(0)); - } - }).primaryEntrySet(); - - assertEquals(2, primEntries.size()); - } - - /** * @throws Exception In case of error. */ public void testToMap() throws Exception { @@ -3624,7 +3527,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract Map<String, Integer> map = new HashMap<>(); for (int i = 0; i < gridCount(); i++) { - for (CacheEntry<String, Integer> entry : cache(i)) + for (Cache.Entry<String, Integer> entry : jcache(i)) map.put(entry.getKey(), entry.getValue()); } @@ -3662,7 +3565,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract } } - assertEquals("Incorrect size on cache #" + i, size, cache(i).size()); + assertEquals("Incorrect size on cache #" + i, size, jcache(i).localSize()); } } } @@ -3684,7 +3587,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract if (ctx.affinity().localNode(key, ctx.discovery().topologyVersion())) size++; - assertEquals("Incorrect key size on cache #" + i, size, cache(i).size()); + assertEquals("Incorrect key size on cache #" + i, size, jcache(i).localSize()); } } } @@ -3701,7 +3604,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract boolean contains = false; for (int i = 0; i < gridCount(); i++) - if (containsKey(cache(i), key)) { + if (containsKey(jcache(i), key)) { contains = true; break; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd72342a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java index 2fe8b85..bc74e62 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java @@ -37,11 +37,8 @@ import org.apache.ignite.transactions.*; import org.jdk8.backport.*; import org.jetbrains.annotations.*; -import javax.cache.*; import javax.cache.configuration.*; -import javax.cache.integration.*; import java.util.*; -import java.util.concurrent.*; import java.util.concurrent.atomic.*; import static org.apache.ignite.cache.CacheAtomicityMode.*; @@ -388,7 +385,7 @@ public abstract class GridCacheAbstractSelfTest extends GridCommonAbstractTest { * @return Default cache. */ @SuppressWarnings({"unchecked"}) - protected IgniteCache<String, Integer> jcache(int idx) { + @Override protected IgniteCache<String, Integer> jcache(int idx) { return ignite(idx).jcache(null); } @@ -456,8 +453,8 @@ public abstract class GridCacheAbstractSelfTest extends GridCommonAbstractTest { * @throws Exception If failed. */ @SuppressWarnings("unchecked") - protected boolean containsKey(GridCache cache, Object key) throws Exception { - return offheapTiered(cache) ? containsOffheapKey(cache, key) : cache.containsKey(key); + protected boolean containsKey(IgniteCache cache, Object key) throws Exception { + return offheapTiered(cache) ? cache.localPeek(key, CachePeekMode.OFFHEAP) != null : cache.containsKey(key); } /** @@ -473,24 +470,6 @@ public abstract class GridCacheAbstractSelfTest extends GridCommonAbstractTest { /** * @param cache Cache. - * @param key Key. - * @return {@code True} if offheap contains given key. - * @throws Exception If failed. - */ - @SuppressWarnings("unchecked") - protected boolean containsOffheapKey(GridCache cache, Object key) throws Exception { - for (Iterator<Map.Entry> it = cache.offHeapIterator(); it.hasNext();) { - Map.Entry e = it.next(); - - if (key.equals(e.getKey())) - return true; - } - - return false; - } - - /** - * @param cache Cache. * @param val Value. * @return {@code True} if offheap contains given value. * @throws Exception If failed. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd72342a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAtomicMessageCountSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAtomicMessageCountSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAtomicMessageCountSelfTest.java index 0b23669..e6a911b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAtomicMessageCountSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAtomicMessageCountSelfTest.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.cache.*; +import org.apache.ignite.cache.affinity.*; import org.apache.ignite.cluster.*; import org.apache.ignite.configuration.*; import org.apache.ignite.internal.managers.communication.*; @@ -143,20 +144,22 @@ public class GridCacheAtomicMessageCountSelfTest extends GridCommonAbstractTest for (int i = 0; i < putCnt; i++) { ClusterNode locNode = grid(0).localNode(); + CacheAffinity<Object> affinity = ignite(0).affinity(null); + if (writeOrderMode == CLOCK) { - if (cache(0).affinity().isPrimary(locNode, i) || cache(0).affinity().isBackup(locNode, i)) + if (affinity.isPrimary(locNode, i) || affinity.isBackup(locNode, i)) expNearCnt++; else expNearCnt += 2; } else { - if (cache(0).affinity().isPrimary(locNode, i)) + if (affinity.isPrimary(locNode, i)) expDhtCnt++; else expNearCnt ++; } - cache(0).put(i, i); + jcache(0).put(i, i); } assertEquals(expNearCnt, commSpi.messageCount(GridNearAtomicUpdateRequest.class)); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd72342a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryMemorySizeSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryMemorySizeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryMemorySizeSelfTest.java index dae5b51..b15c2d9 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryMemorySizeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryMemorySizeSelfTest.java @@ -186,7 +186,7 @@ public class GridCacheEntryMemorySizeSelfTest extends GridCommonAbstractTest { if (grid(0).mapKeyToNode(null, key).equals(grid(0).localNode())) { if (i > 0) - assertTrue(cache(0).putx(key, new Value(new byte[i * 1024]))); + jcache(0).put(key, new Value(new byte[i * 1024])); keys[i] = key; @@ -196,8 +196,8 @@ public class GridCacheEntryMemorySizeSelfTest extends GridCommonAbstractTest { } // Create near entries. - assertNotNull(cache(1).get(keys[1])); - assertNotNull(cache(1).get(keys[2])); + assertNotNull(jcache(1).get(keys[1])); + assertNotNull(jcache(1).get(keys[2])); assertEquals(KEY_SIZE + NULL_REF_SIZE + ENTRY_OVERHEAD + DHT_ENTRY_OVERHEAD + extrasSize(cache(0).entry(keys[0])), cache(0).entry(keys[0]).memorySize()); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd72342a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheGroupLockAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheGroupLockAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheGroupLockAbstractSelfTest.java index d4c7fc1..7838d9a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheGroupLockAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheGroupLockAbstractSelfTest.java @@ -845,10 +845,10 @@ public abstract class GridCacheGroupLockAbstractSelfTest extends GridCommonAbstr } for (int i = 0; i < gridCount(); i++) { - assertNull("For cache [i=" + i + ", val=" + cache(i).peek(key1) + ']', cache(i).peek(key1)); - assertNull("For cache [i=" + i + ", val=" + cache(i).peek(key2) + ']', cache(i).peek(key2)); + IgniteCache<Object, Object> cacheI = jcache(i); - assertTrue("For cache [idx=" + i + ", keySet=" + cache(i).keySet() + ']', cache(i).size() <= 1); + assertNull("For cache [i=" + i + ", val=" + cacheI.localPeek(key1, CachePeekMode.ONHEAP) + ']', cacheI.localPeek(key1, CachePeekMode.ONHEAP)); + assertNull("For cache [i=" + i + ", val=" + cacheI.localPeek(key2, CachePeekMode.ONHEAP) + ']', cacheI.localPeek(key2, CachePeekMode.ONHEAP)); } // Check that there are no further locks after transaction commit. @@ -959,11 +959,11 @@ public abstract class GridCacheGroupLockAbstractSelfTest extends GridCommonAbstr private void checkGetRepeatableRead(IgniteTxConcurrency concurrency) throws Exception { UUID key = primaryKeyForCache(grid(0)); - cache(0).put(key, "val"); + jcache(0).put(key, "val"); - try (IgniteTx ignored = cache(0).txStartPartition(cache(0).affinity().partition(key), concurrency, - REPEATABLE_READ, 0, 1)) { - assertEquals("val", cache(0).get(key)); + try (IgniteTx ignored = ignite(0).transactions().txStartPartition(null, ignite(0).affinity(null).partition(key), + concurrency, REPEATABLE_READ, 0, 1)) { + assertEquals("val", jcache(0).get(key)); } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd72342a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueEntryMoveSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueEntryMoveSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueEntryMoveSelfTest.java index dfc9410..8118d06 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueEntryMoveSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueEntryMoveSelfTest.java @@ -195,8 +195,8 @@ public class GridCachePartitionedQueueEntryMoveSelfTest extends IgniteCollection * @throws Exception If failed. */ private void startAdditionalNodes(int cnt, String queueName) throws Exception { - CacheAffinityFunction aff = cache(0).configuration().getAffinity(); - CacheAffinityKeyMapper mapper = cache(0).configuration().getAffinityMapper(); + CacheAffinityFunction aff = jcache(0).getConfiguration(CacheConfiguration.class).getAffinity(); + CacheAffinityKeyMapper mapper = jcache(0).getConfiguration(CacheConfiguration.class).getAffinityMapper(); assertNotNull(aff); assertNotNull(mapper); @@ -205,7 +205,7 @@ public class GridCachePartitionedQueueEntryMoveSelfTest extends IgniteCollection Collection<ClusterNode> nodes = grid(0).nodes(); - Collection<ClusterNode> aff0 = cache(0).affinity().mapKeyToPrimaryAndBackups(queueName); + Collection<ClusterNode> aff0 = ignite(0).affinity(null).mapKeyToPrimaryAndBackups(queueName); Collection<ClusterNode> aff1 = nodes(aff, part, nodes); assertEquals(new ArrayList<>(aff0), new ArrayList<>(aff1)); @@ -237,7 +237,7 @@ public class GridCachePartitionedQueueEntryMoveSelfTest extends IgniteCollection startGrid(i++); } - aff2 = cache(0).affinity().mapKeyToPrimaryAndBackups(queueName); + aff2 = ignite(0).affinity(null).mapKeyToPrimaryAndBackups(queueName); assertFalse("Unexpected affinity [aff1=" + aff1 + ", aff2=" + aff2 + ']', F.containsAny(aff1, aff2)); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd72342a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEntrySetAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEntrySetAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEntrySetAbstractSelfTest.java index 64243d8..e713c19 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEntrySetAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEntrySetAbstractSelfTest.java @@ -81,7 +81,7 @@ public abstract class GridCacheEntrySetAbstractSelfTest extends GridCacheAbstrac }, GRID_CNT, "test"); for (int j = 0; j < gridCount(); j++) - cache(j).removeAll(); + jcache(j).removeAll(); } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd72342a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEventAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEventAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEventAbstractTest.java index 7871246..a16ca16 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEventAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEventAbstractTest.java @@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.cache.distributed; import org.apache.ignite.*; import org.apache.ignite.cache.*; +import org.apache.ignite.configuration.*; import org.apache.ignite.events.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.*; @@ -138,11 +139,11 @@ public abstract class GridCacheEventAbstractTest extends GridCacheAbstractSelfTe */ private void clearCaches() throws IgniteCheckedException { for (int i = 0; i < gridCnt; i++) { - GridCache<String, Integer> cache = cache(i); + IgniteCache<String, Integer> cache = jcache(i); cache.removeAll(); - assert cache.isEmpty(); + assert cache.localSize() == 0; } } @@ -321,7 +322,7 @@ public abstract class GridCacheEventAbstractTest extends GridCacheAbstractSelfTe */ public void testGetPutRemoveAsync() throws Exception { // TODO: GG-7578. - if (cache(0).configuration().getCacheMode() == CacheMode.REPLICATED) + if (jcache(0).getConfiguration(CacheConfiguration.class).getCacheMode() == CacheMode.REPLICATED) return; runTest(new TestCacheRunnable() { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd72342a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheExpiredEntriesPreloadAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheExpiredEntriesPreloadAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheExpiredEntriesPreloadAbstractSelfTest.java index 71fcc14..d2b868c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheExpiredEntriesPreloadAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheExpiredEntriesPreloadAbstractSelfTest.java @@ -76,7 +76,7 @@ public abstract class GridCacheExpiredEntriesPreloadAbstractSelfTest extends Gri * @throws Exception If failed. */ public void testExpiredEntriesPreloading() throws Exception { - GridCache<String, Integer> cache0 = cache(0); + IgniteCache<String, Integer> cache0 = jcache(0); final int KEYS_NUM = 3; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd72342a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheLockAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheLockAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheLockAbstractTest.java index e774ca9..6103f49 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheLockAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheLockAbstractTest.java @@ -168,7 +168,7 @@ public abstract class GridCacheLockAbstractTest extends GridCommonAbstractTest { if (isPartitioned()) return near(idx).isLockedNearOnly(k); - return cache(idx).isLocked(k); + return jcache(idx).isLocalLocked(k, false); } /** @@ -181,7 +181,7 @@ public abstract class GridCacheLockAbstractTest extends GridCommonAbstractTest { return near(idx).isAllLockedNearOnly(keys); for (Integer key : keys) { - if (!cache(idx).isLocked(key)) + if (!jcache(idx).isLocalLocked(key, true)) return false; } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd72342a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultiNodeLockAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultiNodeLockAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultiNodeLockAbstractTest.java index 4ae26b7..59b4281 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultiNodeLockAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultiNodeLockAbstractTest.java @@ -107,11 +107,11 @@ public abstract class GridCacheMultiNodeLockAbstractTest extends GridCommonAbstr lsnrs.clear(); for (int i = 1; i <= 3; i++) { - cache(i).clear(); + jcache(i).clear(); assertTrue( "Cache isn't empty [i=" + i + ", entries=" + ((IgniteKernal)grid(i)).internalCache().entries() + "]", - cache(i).isEmpty()); + jcache(i).localSize() == 0); } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd72342a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheNodeFailureAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheNodeFailureAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheNodeFailureAbstractTest.java index 25ab04d..c31c684 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheNodeFailureAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheNodeFailureAbstractTest.java @@ -32,6 +32,7 @@ import org.apache.ignite.testframework.junits.common.*; import org.apache.ignite.transactions.*; import java.util.*; +import java.util.concurrent.locks.*; import static org.apache.ignite.IgniteState.*; import static org.apache.ignite.IgniteSystemProperties.*; @@ -132,7 +133,7 @@ public abstract class GridCacheNodeFailureAbstractTest extends GridCommonAbstrac */ public void testPessimisticReadCommitted() throws Throwable { // TODO: GG-7437. - if (cache(0).configuration().getCacheMode() == CacheMode.REPLICATED) + if (jcache(0).getConfiguration(CacheConfiguration.class).getCacheMode() == CacheMode.REPLICATED) return; checkTransaction(PESSIMISTIC, READ_COMMITTED); @@ -164,12 +165,10 @@ public abstract class GridCacheNodeFailureAbstractTest extends GridCommonAbstrac Ignite g = grid(idx); - GridCache<Integer, String> cache = cache(idx); - - IgniteTx tx = cache.txStart(concurrency, isolation); + IgniteTx tx = g.transactions().txStart(concurrency, isolation); try { - cache.put(KEY, VALUE); + g.jcache(null).put(KEY, VALUE); int checkIdx = (idx + 1) % G.allGrids().size(); @@ -189,12 +188,13 @@ public abstract class GridCacheNodeFailureAbstractTest extends GridCommonAbstrac U.sleep(getInteger(IGNITE_TX_SALVAGE_TIMEOUT, 3000)); - GridCache<Integer, String> checkCache = cache(checkIdx); + IgniteCache<Integer, String> checkCache = jcache(checkIdx); boolean locked = false; + Lock lock = checkCache.lock(KEY); for (int i = 0; !locked && i < 3; i++) { - locked = checkCache.lock(KEY, -1); + locked = lock.tryLock(); if (!locked) U.sleep(500); @@ -202,12 +202,9 @@ public abstract class GridCacheNodeFailureAbstractTest extends GridCommonAbstrac break; } - try { - assert locked : "Failed to lock key on cache [idx=" + checkIdx + ", key=" + KEY + ']'; - } - finally { - checkCache.unlockAll(F.asList(KEY)); - } + assert locked : "Failed to lock key on cache [idx=" + checkIdx + ", key=" + KEY + ']'; + + lock.unlock(); } catch (IgniteTxOptimisticCheckedException e) { U.warn(log, "Optimistic transaction failure (will rollback) [msg=" + e.getMessage() + ", tx=" + tx + ']'); @@ -238,27 +235,25 @@ public abstract class GridCacheNodeFailureAbstractTest extends GridCommonAbstrac info("Nodes for key [id=" + grid(idx).cache(null).affinity().mapKeyToPrimaryAndBackups(KEY) + ", key=" + KEY + ']'); - GridCache<Integer, String> cache = cache(idx); + IgniteCache<Integer, String> cache = jcache(idx); // TODO: GG-7437. - if (cache.configuration().getCacheMode() == CacheMode.REPLICATED) + if (cache.getConfiguration(CacheConfiguration.class).getCacheMode() == CacheMode.REPLICATED) return; cache.put(KEY, VALUE); - assert cache.lock(KEY, -1); + Lock lock = cache.lock(KEY); + + assert lock.tryLock(); int checkIdx = 1; info("Check grid index: " + checkIdx); - GridCache<Integer, String> checkCache = cache(checkIdx); - - assert !checkCache.lock(KEY, -1); + IgniteCache<Integer, String> checkCache = jcache(checkIdx); - CacheEntry e = checkCache.entry(KEY); - - assert e.isLocked() : "Entry is not locked for grid [idx=" + checkIdx + ", entry=" + e + ']'; + assert !checkCache.lock(KEY).tryLock(); IgniteFuture<?> f = waitForLocalEvent(grid(checkIdx).events(), new P1<Event>() { @Override public boolean apply(Event e) { @@ -273,9 +268,10 @@ public abstract class GridCacheNodeFailureAbstractTest extends GridCommonAbstrac f.get(); boolean locked = false; + Lock checkLock = checkCache.lock(KEY); for (int i = 0; !locked && i < 3; i++) { - locked = checkCache.lock(KEY, -1); + locked = checkLock.tryLock(); if (!locked) { info("Still not locked..."); @@ -286,12 +282,10 @@ public abstract class GridCacheNodeFailureAbstractTest extends GridCommonAbstrac break; } - assert locked : "Failed to lock entry: " + e; - - checkCache.unlockAll(F.asList(KEY)); + assert locked : "Failed to lock"; - e = checkCache.entry(KEY); + checkLock.unlock(); - assert !e.isLocked() : "Entry is locked for grid [idx=" + checkIdx + ", entry=" + e + ']'; + assert !checkCache.isLocalLocked(KEY, false); } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd72342a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPreloadAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPreloadAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPreloadAbstractTest.java index 04866a9..462b3ce 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPreloadAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPreloadAbstractTest.java @@ -125,7 +125,7 @@ public abstract class IgniteTxPreloadAbstractTest extends GridCacheAbstractSelfT for (int i = 0; i < GRID_CNT; i++) { for (String key : keys) - assertEquals("Unexpected value for cache " + i, (Integer)1, cache(i).get(key)); + assertEquals("Unexpected value for cache " + i, (Integer)1, jcache(i).get(key)); } } @@ -202,7 +202,7 @@ public abstract class IgniteTxPreloadAbstractTest extends GridCacheAbstractSelfT } for (int i = 0; i < GRID_CNT; i++) - assertEquals("Unexpected value for cache " + i, (Integer)expVal, cache(i).get(TX_KEY)); + assertEquals("Unexpected value for cache " + i, (Integer)expVal, jcache(i).get(TX_KEY)); } /** {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd72342a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxTimeoutAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxTimeoutAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxTimeoutAbstractTest.java index 65f3e98..0733c60 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxTimeoutAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxTimeoutAbstractTest.java @@ -121,9 +121,9 @@ public class IgniteTxTimeoutAbstractTest extends GridCommonAbstractTest { int idx = RAND.nextInt(GRID_COUNT); - GridCache<Integer, String> cache = cache(idx); + IgniteCache<Integer, String> cache = jcache(idx); - IgniteTx tx = cache.txStart(concurrency, isolation, TIMEOUT, 0); + IgniteTx tx = ignite(idx).transactions().txStart(concurrency, isolation, TIMEOUT, 0); try { info("Storing value in cache [key=1, val=1]"); @@ -146,7 +146,7 @@ public class IgniteTxTimeoutAbstractTest extends GridCommonAbstractTest { assert false : "Timeout never happened for transaction: " + tx; } - catch (IgniteTxTimeoutCheckedException e) { + catch (IgniteTxTimeoutException e) { info("Received expected timeout exception [msg=" + e.getMessage() + ", tx=" + tx + ']'); } finally { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd72342a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAbstractTransformWriteThroughSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAbstractTransformWriteThroughSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAbstractTransformWriteThroughSelfTest.java index e0dfad4..634df50 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAbstractTransformWriteThroughSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAbstractTransformWriteThroughSelfTest.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal.processors.cache.distributed.dht; import org.apache.ignite.*; +import org.apache.ignite.cache.affinity.*; import org.apache.ignite.configuration.*; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.marshaller.optimized.*; @@ -314,16 +315,18 @@ public abstract class GridCacheAbstractTransformWriteThroughSelfTest extends Gri while (keys.size() < 30) { String key = String.valueOf(numKey); + CacheAffinity<Object> affinity = ignite(0).affinity(null); + if (nodeType == NEAR_NODE) { - if (!cache(0).affinity().isPrimaryOrBackup(grid(0).localNode(), key)) + if (!affinity.isPrimaryOrBackup(grid(0).localNode(), key)) keys.add(key); } else if (nodeType == PRIMARY_NODE) { - if (cache(0).affinity().isPrimary(grid(0).localNode(), key)) + if (affinity.isPrimary(grid(0).localNode(), key)) keys.add(key); } else if (nodeType == BACKUP_NODE) { - if (cache(0).affinity().isBackup(grid(0).localNode(), key)) + if (affinity.isBackup(grid(0).localNode(), key)) keys.add(key); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd72342a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAtomicNearCacheSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAtomicNearCacheSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAtomicNearCacheSelfTest.java index 447abee..ae1845c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAtomicNearCacheSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAtomicNearCacheSelfTest.java @@ -265,7 +265,7 @@ public class GridCacheAtomicNearCacheSelfTest extends GridCommonAbstractTest { IgniteCache<Integer, Integer> cache0 = ignite0.jcache(null); - CacheAffinity<Object> aff = cache(0).affinity(); + CacheAffinity<Object> aff = ignite0.affinity(null); UUID id0 = ignite0.cluster().localNode().id(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd72342a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedDebugTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedDebugTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedDebugTest.java index 07af0fc..9609cef 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedDebugTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedDebugTest.java @@ -287,29 +287,24 @@ public class GridCacheColocatedDebugTest extends GridCommonAbstractTest { long threadId = Thread.currentThread().getId(); - try { - long itNum; + long itNum; - while ((itNum = iterCnt.getAndIncrement()) < maxIterCnt) { - Collections.shuffle(threadKeys); + while ((itNum = iterCnt.getAndIncrement()) < maxIterCnt) { + Collections.shuffle(threadKeys); - List<Integer> iterKeys = threadKeys.subList(0, keysCnt); + List<Integer> iterKeys = threadKeys.subList(0, keysCnt); - Collections.sort(iterKeys); + Collections.sort(iterKeys); - Map<Integer, String> vals = U.newLinkedHashMap(keysCnt); + Map<Integer, String> vals = U.newLinkedHashMap(keysCnt); - for (Integer key : iterKeys) - vals.put(key, String.valueOf(key) + threadId); + for (Integer key : iterKeys) + vals.put(key, String.valueOf(key) + threadId); - cache(0).putAll(vals); + jcache(0).putAll(vals); - if (itNum > 0 && itNum % 5000 == 0) - info(">>> " + itNum + " iterations completed."); - } - } - catch (IgniteCheckedException e) { - fail("Unexpected exception caught: " + e); + if (itNum > 0 && itNum % 5000 == 0) + info(">>> " + itNum + " iterations completed."); } } }, THREAD_CNT); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd72342a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheGroupLockPartitionedAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheGroupLockPartitionedAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheGroupLockPartitionedAbstractSelfTest.java index 2deebe6..494d5f6 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheGroupLockPartitionedAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheGroupLockPartitionedAbstractSelfTest.java @@ -83,9 +83,9 @@ public abstract class GridCacheGroupLockPartitionedAbstractSelfTest extends Grid cache.put(new CacheAffinityKey<>(i, affinityKey), i); for (int i = 0; i < 3; i++) { - try (IgniteTx tx = cache.txStartAffinity(affinityKey, concurrency, isolation, 0, 10)) { + try (IgniteTx tx = ignite(0).transactions().txStartAffinity(null, affinityKey, concurrency, isolation, 0, 10)) { Set<CacheEntry<CacheAffinityKey<Integer>, Integer>> set = - cache.entrySet(cache(0).affinity().partition(affinityKey)); + cache.entrySet(ignite(0).affinity(null).partition(affinityKey)); for (CacheEntry<CacheAffinityKey<Integer>, Integer> entry : set) { Integer old = entry.get(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd72342a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java index c5db9dc..60cf072 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java @@ -319,9 +319,4 @@ public class GridCacheNearOnlyMultiNodeFullApiSelfTest extends GridCachePartitio assert !cache.isLocalLocked(key, false); } } - - /** {@inheritDoc} */ - @Override public void testPrimaryData() throws Exception { - // Not needed for near-only cache. - } }