# IGNITE-56 Get rid CacheProjection.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/75ce20d4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/75ce20d4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/75ce20d4 Branch: refs/heads/ignite-51 Commit: 75ce20d498aed705b8d081597bd23db93730bcea Parents: 0100a50 Author: sevdokimov <sergey.evdoki...@jetbrains.com> Authored: Sun Feb 8 15:08:05 2015 +0300 Committer: sevdokimov <sergey.evdoki...@jetbrains.com> Committed: Sun Feb 8 15:08:05 2015 +0300 ---------------------------------------------------------------------- .../cache/GridCacheAbstractFullApiSelfTest.java | 45 ++---- .../cache/GridCacheAbstractMetricsSelfTest.java | 25 +--- .../cache/GridCacheAbstractSelfTest.java | 12 -- .../GridCacheOffHeapTieredAbstractSelfTest.java | 28 ++-- .../IgniteCacheEntryListenerAbstractTest.java | 2 +- .../GridCacheAbstractJobExecutionTest.java | 4 +- .../GridCacheMultiNodeLockAbstractTest.java | 72 ---------- ...chePartitionedReloadAllAbstractSelfTest.java | 56 +++----- .../dht/GridCacheDhtEntrySelfTest.java | 14 +- .../dht/GridCacheDhtPreloadSelfTest.java | 9 -- .../GridCacheDhtPreloadStartStopSelfTest.java | 8 -- .../distributed/dht/GridCacheDhtTestUtils.java | 9 -- .../near/GridCacheNearMultiNodeSelfTest.java | 18 +-- ...idCacheNearOnlyMultiNodeFullApiSelfTest.java | 12 -- .../GridCacheNearReaderPreloadSelfTest.java | 2 +- .../GridCacheReplicatedPreloadSelfTest.java | 16 +-- .../IgniteCacheExpiryPolicyAbstractTest.java | 14 +- ...iteCacheNoLoadPreviousValueAbstractTest.java | 6 +- .../IgniteCacheNoReadThroughAbstractTest.java | 6 +- .../IgniteCacheNoWriteThroughAbstractTest.java | 6 +- .../GridCacheSwapScanQueryAbstractSelfTest.java | 55 -------- ...dCacheContinuousQueryReplicatedSelfTest.java | 4 +- .../cacheget/GridBenchmarkCacheGetLoadTest.java | 13 +- .../ignite/testframework/GridTestUtils.java | 8 +- .../junits/common/GridCommonAbstractTest.java | 139 ++++--------------- 25 files changed, 111 insertions(+), 472 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/75ce20d4/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 a42348c..f41f2ef 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 @@ -21,6 +21,7 @@ import com.google.common.collect.*; import junit.framework.*; import org.apache.ignite.*; 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.events.*; @@ -2984,7 +2985,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract final GridCache<String, Integer> c = cache(); - final String key = primaryKeysForCache(c, 1).get(0); + final String key = primaryKeysForCache(jcache(), 1).get(0); if (oldEntry) c.put(key, 1); @@ -3210,7 +3211,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract public void testUnswap() throws Exception { GridCache<String, Integer> cache = cache(); - List<String> keys = primaryKeysForCache(cache, 3); + List<String> keys = primaryKeysForCache(jcache(), 3); String k1 = keys.get(0); String k2 = keys.get(1); @@ -3646,28 +3647,17 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract * @param cache Cache. * @param cnt Keys count. * @return Collection of keys for which given cache is primary. - * @throws IgniteCheckedException If failed. */ - protected List<String> primaryKeysForCache(CacheProjection<String, Integer> cache, int cnt) - throws IgniteCheckedException { - return primaryKeysForCache(cache, cnt, 1); - } - - /** - * @param cache Cache. - * @param cnt Keys count. - * @param startFrom Start value for keys search. - * @return Collection of keys for which given cache is primary. - * @throws IgniteCheckedException If failed. - */ - protected List<String> primaryKeysForCache(CacheProjection<String, Integer> cache, int cnt, int startFrom) - throws IgniteCheckedException { + protected List<String> primaryKeysForCache(IgniteCache<String, Integer> cache, int cnt, int startFrom) { List<String> found = new ArrayList<>(cnt); + Ignite ignite = cache.unwrap(Ignite.class); + CacheAffinity<Object> affinity = ignite.affinity(cache.getName()); + for (int i = startFrom; i < startFrom + 100_000; i++) { String key = "key" + i; - if (cache.entry(key).primary()) { + if (affinity.isPrimary(ignite.cluster().localNode(), key)) { found.add(key); if (found.size() == cnt) @@ -3675,20 +3665,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract } } - throw new IgniteCheckedException("Unable to find " + cnt + " keys as primary for cache."); - } - - /** - * @param cache Cache. - * @param cnt Keys count. - * @return Collection of keys for which given cache is primary. - * @throws IgniteCheckedException If failed. - */ - protected List<String> primaryKeysForCache(IgniteCache<String, Integer> cache, int cnt, int startFrom) - throws IgniteCheckedException { - CacheProjection<String, Integer> prj = GridTestUtils.getFieldValue(cache, "delegate"); - - return primaryKeysForCache(prj, cnt, startFrom); + throw new IgniteException("Unable to find " + cnt + " keys as primary for cache."); } /** @@ -3699,9 +3676,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract */ protected List<String> primaryKeysForCache(IgniteCache<String, Integer> cache, int cnt) throws IgniteCheckedException { - CacheProjection<String, Integer> prj = GridTestUtils.getFieldValue(cache, "delegate"); - - return primaryKeysForCache(prj, cnt); + return primaryKeysForCache(cache, cnt, 1); } /** http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/75ce20d4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractMetricsSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractMetricsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractMetricsSelfTest.java index 831063f..9e2cd94 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractMetricsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractMetricsSelfTest.java @@ -684,7 +684,7 @@ public abstract class GridCacheAbstractMetricsSelfTest extends GridCacheAbstract final GridCache<Integer, Integer> c = grid(0).cache(null); - final Integer key = primaryKeysForCache(c, 1, 0).get(0); + final Integer key = primaryKeys(jcache(0), 1, 0).get(0); c.put(key, 1); @@ -876,27 +876,4 @@ public abstract class GridCacheAbstractMetricsSelfTest extends GridCacheAbstract if (c.configuration().getCacheMode() != CacheMode.PARTITIONED && inTx) assertEquals(1, grid(0).cache(null).metrics().getCacheEvictions()); } - - /** - * @param cache Cache. - * @param cnt Keys count. - * @param startFrom Start value for keys search. - * @return Collection of keys for which given cache is primary. - * @throws IgniteCheckedException If failed. - */ - protected List<Integer> primaryKeysForCache(CacheProjection<Integer, Integer> cache, int cnt, int startFrom) - throws IgniteCheckedException { - List<Integer> found = new ArrayList<>(cnt); - - for (int i = startFrom; i < startFrom + 100_000; i++) { - if (cache.entry(i).primary()) { - found.add(i); - - if (found.size() == cnt) - return found; - } - } - - throw new IgniteCheckedException("Unable to find " + cnt + " keys as primary for cache."); - } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/75ce20d4/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 bc74e62..7b91617 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 @@ -425,18 +425,6 @@ public abstract class GridCacheAbstractSelfTest extends GridCommonAbstractTest { /** * Executes regular peek or peek from swap. * - * @param prj Cache projection. - * @param key Key. - * @return Value. - * @throws Exception If failed. - */ - @Nullable protected <K, V> V peek(CacheProjection<K, V> prj, K key) throws Exception { - return offheapTiered(prj.cache()) ? prj.peek(key, F.asList(GridCachePeekMode.SWAP)) : prj.peek(key); - } - - /** - * Executes regular peek or peek from swap. - * * @param cache Cache projection. * @param key Key. * @return Value. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/75ce20d4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapTieredAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapTieredAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapTieredAbstractSelfTest.java index bf607b4..71f1add 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapTieredAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapTieredAbstractSelfTest.java @@ -88,7 +88,7 @@ public abstract class GridCacheOffHeapTieredAbstractSelfTest extends GridCacheAb * @throws Exception If failed. */ public void testTransform() throws Exception { - GridCache<Integer, Integer> cache = grid(0).cache(null); + IgniteCache<Integer, Integer> cache = grid(0).jcache(null); checkTransform(primaryKey(cache)); @@ -169,7 +169,7 @@ public abstract class GridCacheOffHeapTieredAbstractSelfTest extends GridCacheAb * @throws Exception If failed. */ public void testPutGetRemove() throws Exception { - GridCache<Integer, Integer> c = grid(0).cache(null); + IgniteCache<Integer, Integer> c = grid(0).jcache(null); checkPutGetRemove(primaryKey(c)); @@ -182,7 +182,7 @@ public abstract class GridCacheOffHeapTieredAbstractSelfTest extends GridCacheAb * @throws Exception If failed. */ public void testPutGetRemoveByteArray() throws Exception { - GridCache<Integer, Integer> c = grid(0).cache(null); + IgniteCache<Integer, Integer> c = grid(0).jcache(null); checkPutGetRemoveByteArray(primaryKey(c)); @@ -297,26 +297,18 @@ public abstract class GridCacheOffHeapTieredAbstractSelfTest extends GridCacheAb * @throws Exception If failed. */ public void testPromote() throws Exception { - GridCache<Integer, TestValue> c = grid(0).cache(null); + IgniteCache<Integer, TestValue> c = grid(0).jcache(null); TestValue val = new TestValue(new byte[100 * 1024]); List<Integer> keys = primaryKeys(c, 200); for (Integer key : keys) - c.putx(key, val); - - for (int i = 0; i < 50; i++) { - TestValue val0 = c.promote(keys.get(i)); - - Assert.assertArrayEquals(val.val, val0.val); - } - - List<Integer> keys0 = keys.subList(50, 100); + c.put(key, val); - c.promoteAll(keys0); + c.localPromote(new HashSet<>(keys)); - for (Integer key : keys0) { + for (Integer key : keys) { TestValue val0 = c.get(key); Assert.assertArrayEquals(val.val, val0.val); @@ -428,7 +420,7 @@ public abstract class GridCacheOffHeapTieredAbstractSelfTest extends GridCacheAb * @throws Exception If failed. */ public void testPutGetRemoveObject() throws Exception { - GridCache<Integer, Integer> c = grid(0).cache(null); + IgniteCache<Integer, Integer> c = grid(0).jcache(null); checkPutGetRemoveObject(primaryKey(c)); @@ -509,7 +501,7 @@ public abstract class GridCacheOffHeapTieredAbstractSelfTest extends GridCacheAb if (atomicityMode() == ATOMIC) return; - GridCache<Integer, TestValue> c = grid(0).cache(null); + IgniteCache<Integer, TestValue> c = grid(0).jcache(null); checkLockUnlock(primaryKey(c)); @@ -568,7 +560,7 @@ public abstract class GridCacheOffHeapTieredAbstractSelfTest extends GridCacheAb * @throws Exception If failed. */ public void testUnswap() throws Exception { - GridCache<Integer, Integer> c = grid(0).cache(null); + IgniteCache<Integer, Integer> c = grid(0).jcache(null); checkUnswap(primaryKey(c)); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/75ce20d4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java index 58850fa..ee0e3ea 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java @@ -240,7 +240,7 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb Map<Integer, Integer> vals = new HashMap<>(); - for (Integer key : nearKeys(grid.cache(null), 100, 1_000_000)) + for (Integer key : nearKeys(grid.jcache(null), 100, 1_000_000)) vals.put(key, 1); final AtomicBoolean done = new AtomicBoolean(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/75ce20d4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractJobExecutionTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractJobExecutionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractJobExecutionTest.java index 1eeb431..ae7d871 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractJobExecutionTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractJobExecutionTest.java @@ -162,12 +162,12 @@ public abstract class GridCacheAbstractJobExecutionTest extends GridCommonAbstra fut.get(); // Wait for completion. for (int i = 0; i < GRID_CNT; i++) { - CacheProjection<String, int[]> c = grid(i).cache(null).projection(String.class, int[].class); + IgniteCache<String, int[]> c = grid(i).jcache(null); // Do within transaction to make sure that lock is acquired // which means that all previous transactions have committed. - try (IgniteTx tx = c.txStart(concur, isolation)) { + try (IgniteTx tx = grid(i).transactions().txStart(concur, isolation)) { int[] arr = c.get("TestKey"); assertNotNull(arr); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/75ce20d4/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 59b4281..37d7e0c 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 @@ -138,15 +138,6 @@ public abstract class GridCacheMultiNodeLockAbstractTest extends GridCommonAbstr * @param cache Cache. * @param key Key. */ - private void checkLocked(CacheProjection<Integer,String> cache, Integer key) { - assert cache.isLocked(key); - assert cache.isLockedByThread(key); - } - - /** - * @param cache Cache. - * @param key Key. - */ private void checkLocked(IgniteCache<Integer,String> cache, Integer key) { assert cache.isLocalLocked(key, false); assert cache.isLocalLocked(key, true); @@ -156,15 +147,6 @@ public abstract class GridCacheMultiNodeLockAbstractTest extends GridCommonAbstr * @param cache Cache. * @param key Key. */ - private void checkRemoteLocked(CacheProjection<Integer,String> cache, Integer key) { - assert cache.isLocked(key); - assert !cache.isLockedByThread(key); - } - - /** - * @param cache Cache. - * @param key Key. - */ private void checkRemoteLocked(IgniteCache<Integer,String> cache, Integer key) { assert cache.isLocalLocked(key, false); assert !cache.isLocalLocked(key, true); @@ -175,30 +157,6 @@ public abstract class GridCacheMultiNodeLockAbstractTest extends GridCommonAbstr * @param key Key. */ @SuppressWarnings({"BusyWait"}) - private void checkUnlocked(CacheProjection<Integer,String> cache, Integer key) { - assert !cache.isLockedByThread(key); - - if (partitioned()) { - for(int i = 0; i < 200; i++) - if (cache.isLocked(key)) { - try { - Thread.sleep(10); - } - catch (InterruptedException e) { - e.printStackTrace(); - } - } - else - return; - } - - assertFalse("Key locked [key=" + key + ", entries=" + entries(key) + "]", cache.isLocked(key)); - } - /** - * @param cache Cache. - * @param key Key. - */ - @SuppressWarnings({"BusyWait"}) private void checkUnlocked(IgniteCache<Integer,String> cache, Integer key) { assert !cache.isLocalLocked(key, true); @@ -223,16 +181,6 @@ public abstract class GridCacheMultiNodeLockAbstractTest extends GridCommonAbstr * @param cache Cache. * @param keys Keys. */ - private void checkLocked(CacheProjection<Integer,String> cache, Iterable<Integer> keys) { - for (Integer key : keys) { - checkLocked(cache, key); - } - } - - /** - * @param cache Cache. - * @param keys Keys. - */ private void checkLocked(IgniteCache<Integer,String> cache, Iterable<Integer> keys) { for (Integer key : keys) checkLocked(cache, key); @@ -242,16 +190,6 @@ public abstract class GridCacheMultiNodeLockAbstractTest extends GridCommonAbstr * @param cache Cache. * @param keys Keys. */ - private void checkRemoteLocked(CacheProjection<Integer,String> cache, Iterable<Integer> keys) { - for (Integer key : keys) { - checkRemoteLocked(cache, key); - } - } - - /** - * @param cache Cache. - * @param keys Keys. - */ private void checkRemoteLocked(IgniteCache<Integer,String> cache, Iterable<Integer> keys) { for (Integer key : keys) checkRemoteLocked(cache, key); @@ -262,16 +200,6 @@ public abstract class GridCacheMultiNodeLockAbstractTest extends GridCommonAbstr * @param cache Cache. * @param keys Keys. */ - private void checkUnlocked(CacheProjection<Integer,String> cache, Iterable<Integer> keys) { - for (Integer key : keys) - checkUnlocked(cache, key); - } - - /** - * - * @param cache Cache. - * @param keys Keys. - */ private void checkUnlocked(IgniteCache<Integer,String> cache, Iterable<Integer> keys) { for (Integer key : keys) checkUnlocked(cache, key); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/75ce20d4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePartitionedReloadAllAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePartitionedReloadAllAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePartitionedReloadAllAbstractSelfTest.java index eb1900e..1797eee 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePartitionedReloadAllAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePartitionedReloadAllAbstractSelfTest.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.cache.affinity.*; import org.apache.ignite.cache.store.*; import org.apache.ignite.configuration.*; import org.apache.ignite.internal.util.typedef.*; @@ -55,7 +56,7 @@ public abstract class GridCachePartitionedReloadAllAbstractSelfTest extends Grid private final Map<Integer, String> map = new ConcurrentHashMap8<>(); /** Collection of caches, one per grid node. */ - private List<GridCache<Integer, String>> caches; + private List<IgniteCache<Integer, String>> caches; /** {@inheritDoc} */ @SuppressWarnings("unchecked") @@ -129,7 +130,7 @@ public abstract class GridCachePartitionedReloadAllAbstractSelfTest extends Grid caches = new ArrayList<>(GRID_CNT); for (int i = 0; i < GRID_CNT; i++) - caches.add(startGrid(i).<Integer, String>cache(null)); + caches.add(startGrid(i).<Integer, String>jcache(null)); awaitPartitionMapExchange(); } @@ -155,14 +156,14 @@ public abstract class GridCachePartitionedReloadAllAbstractSelfTest extends Grid @Override public void loadCache(IgniteBiInClosure<Integer, String> c, Object... args) { - X.println("Loading all on: " + caches.indexOf(g.<Integer, String>cache(null))); + X.println("Loading all on: " + caches.indexOf(g.<Integer, String>jcache(null))); for (Map.Entry<Integer, String> e : map.entrySet()) c.apply(e.getKey(), e.getValue()); } @Override public String load(Integer key) { - X.println("Loading on: " + caches.indexOf(g.<Integer, String>cache(null)) + " key=" + key); + X.println("Loading on: " + caches.indexOf(g.<Integer, String>jcache(null)) + " key=" + key); return map.get(key); } @@ -185,8 +186,8 @@ public abstract class GridCachePartitionedReloadAllAbstractSelfTest extends Grid */ public void testReloadAll() throws Exception { // Fill caches with values. - for (GridCache<Integer, String> cache : caches) { - Iterable<Integer> keys = primaryKeysForCache(cache, 100); + for (IgniteCache<Integer, String> cache : caches) { + Iterable<Integer> keys = primaryKeys(cache, 100); info("Values [cache=" + caches.indexOf(cache) + ", size=" + F.size(keys.iterator()) + ", keys=" + keys + "]"); @@ -194,54 +195,33 @@ public abstract class GridCachePartitionedReloadAllAbstractSelfTest extends Grid map.put(key, "val" + key); } - Collection<GridCache<Integer, String>> emptyCaches = new ArrayList<>(caches); + Collection<IgniteCache<Integer, String>> emptyCaches = new ArrayList<>(caches); - for (GridCache<Integer, String> cache : caches) { + for (IgniteCache<Integer, String> cache : caches) { info("Reloading cache: " + caches.indexOf(cache)); // Check data is reloaded only on the nodes on which reloadAll() has been called. if (!nearEnabled()) { - for (GridCache<Integer, String> eCache : emptyCaches) + for (IgniteCache<Integer, String> eCache : emptyCaches) assertEquals("Non-null values found in cache [cache=" + caches.indexOf(eCache) + - ", size=" + eCache.size() + ", size=" + eCache.size() + - ", entrySetSize=" + eCache.entrySet().size() + "]", + ", size=" + eCache.size() + ", size=" + eCache.size() + "]", 0, eCache.size()); } - cache.reloadAll(map.keySet()); + loadAll(cache, map.keySet(), true); for (Integer key : map.keySet()) { - CacheEntry entry = cache.entry(key); + CacheAffinity<Integer> affinity = affinity(cache); - if (entry.primary() || entry.backup() || nearEnabled()) - assertEquals(map.get(key), cache.peek(key)); + if (affinity.isPrimary(localNode(cache), key) + || affinity.isBackup(localNode(cache), key) + || nearEnabled()) + assertEquals(map.get(key), cache.localPeek(key, CachePeekMode.ONHEAP)); else - assertNull(cache.peek(key)); + assertNull(cache.localPeek(key, CachePeekMode.ONHEAP)); } emptyCaches.remove(cache); } } - - /** - * Create list of keys for which the given cache is primary. - * - * @param cache Cache. - * @param cnt Keys count. - * @return Collection of keys for which given cache is primary. - */ - private Iterable<Integer> primaryKeysForCache(CacheProjection<Integer,String> cache, int cnt) { - Collection<Integer> found = new ArrayList<>(cnt); - - for (int i = 0; i < 10000; i++) { - if (cache.entry(i).primary()) { - found.add(i); - - if (found.size() == cnt) - return found; - } - } - - throw new IllegalStateException("Unable to find " + cnt + " keys as primary for cache."); - } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/75ce20d4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEntrySelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEntrySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEntrySelfTest.java index 807f068..e36363f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEntrySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEntrySelfTest.java @@ -121,7 +121,7 @@ public class GridCacheDhtEntrySelfTest extends GridCommonAbstractTest { * @param g Grid. * @return Near cache. */ - private CacheProjection<Integer, String> near(Ignite g) { + private GridCache<Integer, String> near(Ignite g) { return g.cache(null); } @@ -151,8 +151,8 @@ public class GridCacheDhtEntrySelfTest extends GridCommonAbstractTest { ClusterNode primary = t.get1(); ClusterNode other = t.get2(); - CacheProjection<Integer, String> near0 = near(grid(primary.id())); - CacheProjection<Integer, String> near1 = near(grid(other.id())); + GridCache<Integer, String> near0 = near(grid(primary.id())); + GridCache<Integer, String> near1 = near(grid(other.id())); assert near0 != near1; @@ -196,8 +196,8 @@ public class GridCacheDhtEntrySelfTest extends GridCommonAbstractTest { ClusterNode primary = t.get1(); ClusterNode other = t.get2(); - CacheProjection<Integer, String> near0 = near(grid(primary.id())); - CacheProjection<Integer, String> near1 = near(grid(other.id())); + GridCache<Integer, String> near0 = near(grid(primary.id())); + GridCache<Integer, String> near1 = near(grid(other.id())); assert near0 != near1; @@ -242,8 +242,8 @@ public class GridCacheDhtEntrySelfTest extends GridCommonAbstractTest { ClusterNode primary = t.get1(); ClusterNode other = t.get2(); - CacheProjection<Integer, String> near0 = near(grid(primary.id())); - CacheProjection<Integer, String> near1 = near(grid(other.id())); + GridCache<Integer, String> near0 = near(grid(primary.id())); + GridCache<Integer, String> near1 = near(grid(other.id())); assert near0 != near1; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/75ce20d4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadSelfTest.java index d75d971..ae94b12 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadSelfTest.java @@ -141,15 +141,6 @@ public class GridCacheDhtPreloadSelfTest extends GridCommonAbstractTest { } /** - * @param cache Cache. - * @return Affinity. - */ - @SuppressWarnings({"unchecked"}) - private CacheAffinity<Integer> affinity(IgniteCache<Integer, ?> cache) { - return cache.unwrap(Ignite.class).affinity(cache.getName()); - } - - /** * @param c Cache. * @return {@code True} if synchronous preloading. */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/75ce20d4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadStartStopSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadStartStopSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadStartStopSelfTest.java index cc788ed..9ff1bf2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadStartStopSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadStartStopSelfTest.java @@ -131,14 +131,6 @@ public class GridCacheDhtPreloadStartStopSelfTest extends GridCommonAbstractTest } /** - * @param cache Cache. - * @return Affinity. - */ - private CacheAffinity<Integer> affinity(IgniteCache<Integer, ?> cache) { - return cache.unwrap(Ignite.class).affinity(null); - } - - /** * @param c Cache. * @return {@code True} if synchronoous preloading. */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/75ce20d4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtTestUtils.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtTestUtils.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtTestUtils.java index cdd3ac3..0cf6684 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtTestUtils.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtTestUtils.java @@ -24,7 +24,6 @@ import org.apache.ignite.cache.affinity.consistenthash.*; import org.apache.ignite.cluster.*; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.*; -import org.apache.ignite.internal.processors.cache.distributed.near.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; @@ -45,14 +44,6 @@ public class GridCacheDhtTestUtils { } /** - * @param cache Cache. - * @return Dht cache. - */ - static <K, V> GridDhtCacheAdapter<K, V> dht(CacheProjection<K, V> cache) { - return ((GridNearCacheAdapter<K, V>)cache.<K, V>cache()).dht(); - } - - /** * @param dht Cache. * @param keyCnt Number of test keys to put into cache. * @throws IgniteCheckedException If failed to prepare. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/75ce20d4/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 4b18561..cb8992f 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 @@ -142,10 +142,10 @@ public class GridCacheNearMultiNodeSelfTest extends GridCommonAbstractTest { @SuppressWarnings({"SizeReplaceableByIsEmpty"}) @Override protected void beforeTest() throws Exception { for (int i = 0; i < GRID_CNT; i++) { - assert cache(grid(i)).size() == 0 : "Near cache size is not zero for grid: " + i; + assert jcache(i).localSize() == 0 : "Near cache size is not zero for grid: " + i; assert dht(grid(i)).size() == 0 : "DHT cache size is not zero for grid: " + i; - assert cache(grid(i)).isEmpty() : "Near cache is not empty for grid: " + i; + assert jcache(i).localSize() == 0 : "Near cache is not empty for grid: " + i; assert dht(grid(i)).isEmpty() : "DHT cache is not empty for grid: " + i; } } @@ -154,12 +154,12 @@ public class GridCacheNearMultiNodeSelfTest extends GridCommonAbstractTest { @SuppressWarnings({"SizeReplaceableByIsEmpty"}) @Override protected void afterTest() throws Exception { for (int i = 0; i < GRID_CNT; i++) { - cache(grid(i)).removeAll(); + jcache(i).removeAll(); - assertEquals("Near cache size is not zero for grid: " + i, 0, cache(grid(i)).size()); + assertEquals("Near cache size is not zero for grid: " + i, 0, jcache(i).localSize()); assertEquals("DHT cache size is not zero for grid: " + i, 0, dht(grid(i)).size()); - assert cache(grid(i)).isEmpty() : "Near cache is not empty for grid: " + i; + assert jcache(i).localSize() == 0 : "Near cache is not empty for grid: " + i; assert dht(grid(i)).isEmpty() : "DHT cache is not empty for grid: " + i; } @@ -178,14 +178,6 @@ public class GridCacheNearMultiNodeSelfTest extends GridCommonAbstractTest { /** * @param g Grid. - * @return Near cache. - */ - private CacheProjection<Integer, String> cache(Ignite g) { - return g.cache(null); - } - - /** - * @param g Grid. * @return Dht cache. */ @SuppressWarnings({"unchecked", "TypeMayBeWeakened"}) http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/75ce20d4/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 60cf072..41a35a6 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 @@ -130,18 +130,6 @@ public class GridCacheNearOnlyMultiNodeFullApiSelfTest extends GridCachePartitio return jcache(nearIdx); } - /** - * Returns primary keys for node of the given cache, - * handling possible near-only argument by selecting a single real cache instead. - * - * {@inheritDoc} - */ - @Override protected List<String> primaryKeysForCache(CacheProjection<String, Integer> cache, int cnt) - throws IgniteCheckedException { - return cache.equals(cache()) ? - super.primaryKeysForCache(fullCache(), cnt) : super.primaryKeysForCache(cache, cnt); - } - /** {@inheritDoc} */ @Override protected List<String> primaryKeysForCache(IgniteCache<String, Integer> cache, int cnt) throws IgniteCheckedException { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/75ce20d4/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 352faea..080218a 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 @@ -190,7 +190,7 @@ public class GridCacheNearReaderPreloadSelfTest extends GridCommonAbstractTest { * @param expVal Expected value. * @throws Exception If failed. */ - private void checkCache(CacheProjection<Integer, Integer> cache, int key, int expVal) throws Exception { + private void checkCache(GridCache<Integer, Integer> cache, int key, int expVal) throws Exception { CacheEntry<Integer, Integer> entry = cache.entry(key); assert F.eq(expVal, entry.getValue()) : "Unexpected cache value [key=" + key + ", expected=" + expVal + http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/75ce20d4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java index ed4ab8c..9ea9ea5 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java @@ -298,13 +298,13 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest { for (int i = 0; i < keyCnt; i++) cache1.put(i, "val" + i); - GridCache<Integer, String> cache2 = startGrid(2).cache(null); + IgniteCache<Integer, String> cache2 = startGrid(2).jcache(null); - int size = cache2.size(); + int size = cache2.localSize(); info("Size of cache2: " + size); - assert waitCacheSize(cache2, keyCnt, getTestTimeout()) : "Actual cache size: " + cache2.size(); + assert waitCacheSize(cache2, keyCnt, getTestTimeout()) : "Actual cache size: " + cache2.localSize(); } finally { stopAllGrids(); @@ -319,7 +319,7 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest { * @throws InterruptedException If thread was interrupted. */ @SuppressWarnings({"BusyWait"}) - private boolean waitCacheSize(CacheProjection<Integer, String> cache, int expSize, long timeout) + private boolean waitCacheSize(IgniteCache<Integer, String> cache, int expSize, long timeout) throws InterruptedException { assert cache != null; assert expSize > 0; @@ -327,14 +327,14 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest { long end = System.currentTimeMillis() + timeout; - while (cache.size() < expSize) { + while (cache.localSize() < expSize) { Thread.sleep(50); if (end - System.currentTimeMillis() <= 0) break; } - return cache.size() >= expSize; + return cache.localSize() >= expSize; } /** @@ -451,7 +451,7 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest { info("Cache size is OK for grid index: " + gridIdx); } - GridCache<Integer, String> lastCache = startGrid(gridCnt).cache(null); + IgniteCache<Integer, String> lastCache = startGrid(gridCnt).jcache(null); // Let preloading start. Thread.sleep(1000); @@ -463,7 +463,7 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest { stopGrid(idx); - assert waitCacheSize(lastCache, cnt, 20 * 1000) : "Actual cache size: " + lastCache.size(); + assert waitCacheSize(lastCache, cnt, 20 * 1000) : "Actual cache size: " + lastCache.localSize(); } finally { stopAllGrids(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/75ce20d4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyAbstractTest.java index 74187f8..580f356 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyAbstractTest.java @@ -610,11 +610,11 @@ public abstract class IgniteCacheExpiryPolicyAbstractTest extends IgniteCacheAbs private void nearReaderUpdate() throws Exception { log.info("Test near reader update."); - Integer key = nearKeys(cache(0), 1, 500_000).get(0); + Integer key = nearKeys(jcache(0), 1, 500_000).get(0); IgniteCache<Integer, Integer> cache0 = jcache(0); - assertEquals(NEAR_PARTITIONED, cache(0).configuration().getDistributionMode()); + assertEquals(NEAR_PARTITIONED, jcache(0).getConfiguration(CacheConfiguration.class).getDistributionMode()); cache0.put(key, 1); @@ -722,7 +722,7 @@ public abstract class IgniteCacheExpiryPolicyAbstractTest extends IgniteCacheAbs testAccess(); - Integer key = primaryKeys(cache(0), 1, 500_000).get(0); + Integer key = primaryKeys(jcache(0), 1, 500_000).get(0); IgniteCache<Integer, Integer> cache0 = jcache(0); @@ -742,7 +742,7 @@ public abstract class IgniteCacheExpiryPolicyAbstractTest extends IgniteCacheAbs // Test reader update on get. - key = nearKeys(cache(0), 1, 600_000).get(0); + key = nearKeys(jcache(0), 1, 600_000).get(0); cache0.put(key, 1); @@ -761,16 +761,16 @@ public abstract class IgniteCacheExpiryPolicyAbstractTest extends IgniteCacheAbs * @throws Exception If failed. */ private Collection<Integer> keys() throws Exception { - GridCache<Integer, Object> cache = cache(0); + IgniteCache<Integer, Object> cache = jcache(0); - ArrayList<Integer> keys = new ArrayList<>(); + List<Integer> keys = new ArrayList<>(); keys.add(primaryKeys(cache, 1, lastKey).get(0)); if (gridCount() > 1) { keys.add(backupKeys(cache, 1, lastKey).get(0)); - if (cache.configuration().getCacheMode() != REPLICATED) + if (cache.getConfiguration(CacheConfiguration.class).getCacheMode() != REPLICATED) keys.add(nearKeys(cache, 1, lastKey).get(0)); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/75ce20d4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoLoadPreviousValueAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoLoadPreviousValueAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoLoadPreviousValueAbstractTest.java index 6d333c7..d0c1640 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoLoadPreviousValueAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoLoadPreviousValueAbstractTest.java @@ -191,16 +191,16 @@ public abstract class IgniteCacheNoLoadPreviousValueAbstractTest extends IgniteC * @throws Exception If failed. */ protected Collection<Integer> keys() throws Exception { - GridCache<Integer, Object> cache = cache(0); + IgniteCache<Integer, Object> cache = jcache(0); - ArrayList<Integer> keys = new ArrayList<>(); + Collection<Integer> keys = new ArrayList<>(); keys.add(primaryKeys(cache, 1, lastKey).get(0)); if (gridCount() > 1) { keys.add(backupKeys(cache, 1, lastKey).get(0)); - if (cache.configuration().getCacheMode() != REPLICATED) + if (cache.getConfiguration(CacheConfiguration.class).getCacheMode() != REPLICATED) keys.add(nearKeys(cache, 1, lastKey).get(0)); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/75ce20d4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoReadThroughAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoReadThroughAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoReadThroughAbstractTest.java index 4c01ba1..1700824 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoReadThroughAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoReadThroughAbstractTest.java @@ -301,16 +301,16 @@ public abstract class IgniteCacheNoReadThroughAbstractTest extends IgniteCacheAb * @throws Exception If failed. */ protected Collection<Integer> keys() throws Exception { - GridCache<Integer, Object> cache = cache(0); + IgniteCache<Integer, Object> cache = jcache(0); - ArrayList<Integer> keys = new ArrayList<>(); + Collection<Integer> keys = new ArrayList<>(); keys.add(primaryKeys(cache, 1, lastKey).get(0)); if (gridCount() > 1) { keys.add(backupKeys(cache, 1, lastKey).get(0)); - if (cache.configuration().getCacheMode() != REPLICATED) + if (cache.getConfiguration(CacheConfiguration.class).getCacheMode() != REPLICATED) keys.add(nearKeys(cache, 1, lastKey).get(0)); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/75ce20d4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoWriteThroughAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoWriteThroughAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoWriteThroughAbstractTest.java index 1c09b69..6080cd0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoWriteThroughAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoWriteThroughAbstractTest.java @@ -324,16 +324,16 @@ public abstract class IgniteCacheNoWriteThroughAbstractTest extends IgniteCacheA * @throws Exception If failed. */ protected Collection<Integer> keys() throws Exception { - GridCache<Integer, Object> cache = cache(0); + IgniteCache<Integer, Object> cache = jcache(0); - ArrayList<Integer> keys = new ArrayList<>(); + Collection<Integer> keys = new ArrayList<>(); keys.add(primaryKeys(cache, 1, lastKey).get(0)); if (gridCount() > 1) { keys.add(backupKeys(cache, 1, lastKey).get(0)); - if (cache.configuration().getCacheMode() != REPLICATED) + if (cache.getConfiguration(CacheConfiguration.class).getCacheMode() != REPLICATED) keys.add(nearKeys(cache, 1, lastKey).get(0)); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/75ce20d4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/GridCacheSwapScanQueryAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/GridCacheSwapScanQueryAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/GridCacheSwapScanQueryAbstractSelfTest.java index df305c1..1f26666 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/GridCacheSwapScanQueryAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/GridCacheSwapScanQueryAbstractSelfTest.java @@ -175,8 +175,6 @@ public abstract class GridCacheSwapScanQueryAbstractSelfTest extends GridCommonA assertEquals(ENTRY_CNT, res.size()); - checkProjectionFilter(cache, ENTRY_CNT / 2 - 5); - testMultithreaded(cache, ENTRY_CNT / 2); } finally { @@ -190,59 +188,6 @@ public abstract class GridCacheSwapScanQueryAbstractSelfTest extends GridCommonA * @param expCnt Expected entries in query result. * @throws Exception If failed. */ - @SuppressWarnings({"unchecked", "IfMayBeConditional"}) - private void checkProjectionFilter(GridCache cache, int expCnt) throws Exception { - CacheProjection prj; - - if (portableEnabled()) { - prj = cache.projection(new IgnitePredicate<CacheEntry<PortableObject, PortableObject>>() { - @Override public boolean apply(CacheEntry<PortableObject, PortableObject> e) { - Key key = e.getKey().deserialize(); - Person val = e.peek().deserialize(); - - assertNotNull(e.version()); - - assertEquals(key.id, (Integer)val.salary); - - return key.id % 100 != 0; - } - }); - } - else { - prj = cache.projection(new IgnitePredicate<CacheEntry<Key, Person>>() { - @Override public boolean apply(CacheEntry<Key, Person> e) { - Key key = e.getKey(); - Person val = e.peek(); - - assertNotNull(e.version()); - - assertEquals(key.id, (Integer)val.salary); - - return key.id % 100 != 0; - } - }); - } - - CacheQuery<Map.Entry<Key, Person>> qry = prj.queries().createScanQuery( - new IgniteBiPredicate<Key, Person>() { - @Override public boolean apply(Key key, Person p) { - assertEquals(key.id, (Integer)p.salary); - - return key.id % 2 == 0; - } - } - ); - - Collection<Map.Entry<Key, Person>> res = qry.execute().get(); - - assertEquals(expCnt, res.size()); - } - - /** - * @param cache Cache. - * @param expCnt Expected entries in query result. - * @throws Exception If failed. - */ private void testMultithreaded(final GridCache cache, final int expCnt) throws Exception { log.info("Starting multithreaded queries."); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/75ce20d4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedSelfTest.java index dddda8c..f9c7ee2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedSelfTest.java @@ -93,8 +93,8 @@ public class GridCacheContinuousQueryReplicatedSelfTest extends GridCacheContinu GridCache<Integer, Integer> cache1 = grid(0).cache(null); GridCache<Integer, Integer> cache2 = grid(1).cache(null); - final int key1 = primaryKey(cache1); - final int key2 = primaryKey(cache2); + final int key1 = primaryKey(jcache(0)); + final int key2 = primaryKey(jcache(1)); final CountDownLatch latch1 = new CountDownLatch(2); final CountDownLatch latch2 = new CountDownLatch(2); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/75ce20d4/modules/core/src/test/java/org/apache/ignite/loadtests/dsi/cacheget/GridBenchmarkCacheGetLoadTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/dsi/cacheget/GridBenchmarkCacheGetLoadTest.java b/modules/core/src/test/java/org/apache/ignite/loadtests/dsi/cacheget/GridBenchmarkCacheGetLoadTest.java index ce2a0ea..e292672 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/dsi/cacheget/GridBenchmarkCacheGetLoadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/dsi/cacheget/GridBenchmarkCacheGetLoadTest.java @@ -51,25 +51,16 @@ public class GridBenchmarkCacheGetLoadTest { public static void main(String[] args) throws Exception { Ignition.start("modules/core/src/test/config/load/dsi-49-server-production.xml"); - GridCache<Long, Long> cache = Ignition.ignite("dsi").cache("PARTITIONED_CACHE"); + IgniteCache<Long, Long> cache = Ignition.ignite("dsi").jcache("PARTITIONED_CACHE"); stats(); - boolean usePrj = true; - - CacheProjection<Long, Long> cachePrj = cache.projection(Long.class, Long.class); - for (int i = 0; i < 5000000; i++) { long t0 = System.currentTimeMillis(); cnt.incrementAndGet(); - if (usePrj) - // This is slow - cachePrj.get(id.incrementAndGet()); - else - // This is fast - cache.get(id.incrementAndGet()); + cache.get(id.incrementAndGet()); latency.addAndGet(System.currentTimeMillis() - t0); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/75ce20d4/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java index 7419bde..d54a9ca 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java @@ -842,7 +842,7 @@ public final class GridTestUtils { * @param cache Cache. * @return Cache context. */ - public static <K, V> GridCacheContext<K, V> cacheContext(CacheProjection<K, V> cache) { + public static <K, V> GridCacheContext<K, V> cacheContext(GridCache<K, V> cache) { return ((IgniteKernal)cache.gridProjection().ignite()).<K, V>internalCache().context(); } @@ -850,7 +850,7 @@ public final class GridTestUtils { * @param cache Cache. * @return Near cache. */ - public static <K, V> GridNearCacheAdapter<K, V> near(CacheProjection<K, V> cache) { + public static <K, V> GridNearCacheAdapter<K, V> near(GridCache<K, V> cache) { return cacheContext(cache).near(); } @@ -858,7 +858,7 @@ public final class GridTestUtils { * @param cache Cache. * @return DHT cache. */ - public static <K, V> GridDhtCacheAdapter<K, V> dht(CacheProjection<K, V> cache) { + public static <K, V> GridDhtCacheAdapter<K, V> dht(GridCache<K, V> cache) { return near(cache).dht(); } @@ -866,7 +866,7 @@ public final class GridTestUtils { * @param cache Cache. * @return Affinity. */ - static <K, V> CacheConsistentHashAffinityFunction affinity(CacheProjection<K, V> cache) { + static <K, V> CacheConsistentHashAffinityFunction affinity(GridCache<K, V> cache) { return (CacheConsistentHashAffinityFunction)cache.cache().configuration().getAffinity(); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/75ce20d4/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java index e01da76..b20167b 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java @@ -32,7 +32,6 @@ import org.apache.ignite.internal.processors.cache.local.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; -import org.apache.ignite.testframework.*; import org.apache.ignite.testframework.junits.*; import org.jetbrains.annotations.*; @@ -380,23 +379,18 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest { /** * @param cache Cache. - * @return Key for which given cache is primary. - * @throws IgniteCheckedException If failed. + * @return Affinity. */ - protected Integer primaryKey(CacheProjection<?, ?> cache) - throws IgniteCheckedException { - return primaryKeys(cache, 1, 1).get(0); + public static <K> CacheAffinity<K> affinity(IgniteCache<K, ?> cache) { + return cache.unwrap(Ignite.class).affinity(cache.getName()); } /** * @param cache Cache. - * @param cnt Keys count. - * @return Collection of keys for which given cache is primary. - * @throws IgniteCheckedException If failed. + * @return Local node. */ - protected List<Integer> primaryKeys(CacheProjection<?, ?> cache, int cnt) - throws IgniteCheckedException { - return primaryKeys(cache, cnt, 1); + public static ClusterNode localNode(IgniteCache<?, ?> cache) { + return cache.unwrap(Ignite.class).cluster().node(); } /** @@ -404,22 +398,20 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest { * @param cnt Keys count. * @param startFrom Start value for keys search. * @return Collection of keys for which given cache is primary. - * @throws IgniteCheckedException If failed. */ - protected List<Integer> primaryKeys(CacheProjection<?, ?> cache, int cnt, int startFrom) - throws IgniteCheckedException { + protected List<Integer> primaryKeys(IgniteCache<?, ?> cache, int cnt, int startFrom) { assert cnt > 0 : cnt; List<Integer> found = new ArrayList<>(cnt); - ClusterNode locNode = cache.gridProjection().ignite().cluster().localNode(); + ClusterNode locNode = localNode(cache); - CacheAffinity<Integer> aff = cache.<Integer, Object>cache().affinity(); + CacheAffinity<Integer> aff = (CacheAffinity<Integer>)affinity(cache); for (int i = startFrom; i < startFrom + 100_000; i++) { Integer key = i; - if (aff.isPrimary(locNode, key)) { + if (!aff.isPrimaryOrBackup(locNode, key)) { found.add(key); if (found.size() == cnt) @@ -427,28 +419,16 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest { } } - throw new IgniteCheckedException("Unable to find " + cnt + " keys as primary for cache."); - } - - /** - * @param cache Cache. - * @return Key for which given cache is backup. - * @throws IgniteCheckedException If failed. - */ - protected Integer backupKey(CacheProjection<?, ?> cache) - throws IgniteCheckedException { - return backupKeys(cache, 1, 1).get(0); + throw new IgniteException("Unable to find " + cnt + " keys as backup for cache."); } /** * @param cache Cache. * @param cnt Keys count. - * @return Collection of keys for which given cache is backup. - * @throws IgniteCheckedException If failed. + * @return Collection of keys for which given cache is primary. */ - protected List<Integer> backupKeys(CacheProjection<?, ?> cache, int cnt) - throws IgniteCheckedException { - return backupKeys(cache, cnt, 1); + protected List<Integer> primaryKeys(IgniteCache<?, ?> cache, int cnt) { + return primaryKeys(cache, cnt, 1); } /** @@ -456,17 +436,15 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest { * @param cnt Keys count. * @param startFrom Start value for keys search. * @return Collection of keys for which given cache is backup. - * @throws IgniteCheckedException If failed. */ - protected List<Integer> backupKeys(CacheProjection<?, ?> cache, int cnt, int startFrom) - throws IgniteCheckedException { + protected List<Integer> backupKeys(IgniteCache<?, ?> cache, int cnt, int startFrom) { assert cnt > 0 : cnt; List<Integer> found = new ArrayList<>(cnt); - ClusterNode locNode = cache.gridProjection().ignite().cluster().localNode(); + ClusterNode locNode = localNode(cache); - CacheAffinity<Integer> aff = cache.<Integer, Object>cache().affinity(); + CacheAffinity<Integer> aff = affinity((IgniteCache<Integer, ?>)cache); for (int i = startFrom; i < startFrom + 100_000; i++) { Integer key = i; @@ -479,28 +457,7 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest { } } - throw new IgniteCheckedException("Unable to find " + cnt + " keys as backup for cache."); - } - - /** - * @param cache Cache. - * @return Keys for which given cache is neither primary nor backup. - * @throws IgniteCheckedException If failed. - */ - protected Integer nearKey(CacheProjection<?, ?> cache) - throws IgniteCheckedException { - return nearKeys(cache, 1, 1).get(0); - } - - /** - * @param cache Cache. - * @param cnt Keys count. - * @return Collection of keys for which given cache is neither primary nor backup. - * @throws IgniteCheckedException If failed. - */ - protected List<Integer> nearKeys(CacheProjection<?, ?> cache, int cnt) - throws IgniteCheckedException { - return nearKeys(cache, cnt, 1); + throw new IgniteException("Unable to find " + cnt + " keys as backup for cache."); } /** @@ -510,15 +467,15 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest { * @return Collection of keys for which given cache is neither primary nor backup. * @throws IgniteCheckedException If failed. */ - protected List<Integer> nearKeys(CacheProjection<?, ?> cache, int cnt, int startFrom) + protected List<Integer> nearKeys(IgniteCache<?, ?> cache, int cnt, int startFrom) throws IgniteCheckedException { assert cnt > 0 : cnt; List<Integer> found = new ArrayList<>(cnt); - ClusterNode locNode = cache.gridProjection().ignite().cluster().localNode(); + ClusterNode locNode = localNode(cache); - CacheAffinity<Integer> aff = cache.<Integer, Object>cache().affinity(); + CacheAffinity<Integer> aff = affinity((IgniteCache<Integer, ?>)cache); for (int i = startFrom; i < startFrom + 100_000; i++) { Integer key = i; @@ -535,48 +492,6 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest { } /** - * @param cache Cache. - * @param cnt Keys count. - * @param startFrom Start value for keys search. - * @return Collection of keys for which given cache is primary. - * @throws IgniteCheckedException If failed. - */ - protected List<Integer> primaryKeys(IgniteCache<?, ?> cache, int cnt, int startFrom) - throws IgniteCheckedException { - CacheProjection<?, ?> prj = GridTestUtils.getFieldValue(cache, "delegate"); - - return primaryKeys(prj, cnt, startFrom); - } - - /** - * @param cache Cache. - * @param cnt Keys count. - * @param startFrom Start value for keys search. - * @return Collection of keys for which given cache is backup. - * @throws IgniteCheckedException If failed. - */ - protected List<Integer> backupKeys(IgniteCache<?, ?> cache, int cnt, int startFrom) - throws IgniteCheckedException { - CacheProjection<?, ?> prj = GridTestUtils.getFieldValue(cache, "delegate"); - - return backupKeys(prj, cnt, startFrom); - } - - /** - * @param cache Cache. - * @param cnt Keys count. - * @param startFrom Start value for keys search. - * @return Collection of keys for which given cache is neither primary nor backup. - * @throws IgniteCheckedException If failed. - */ - protected List<Integer> nearKeys(IgniteCache<?, ?> cache, int cnt, int startFrom) - throws IgniteCheckedException { - CacheProjection<?, ?> prj = GridTestUtils.getFieldValue(cache, "delegate"); - - return nearKeys(prj, cnt, startFrom); - } - - /** * @param key Key. * @param cacheName Cache name. * @return Cache. @@ -596,9 +511,7 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest { */ protected Integer primaryKey(IgniteCache<?, ?> cache) throws IgniteCheckedException { - CacheProjection<?, ?> prj = GridTestUtils.getFieldValue(cache, "delegate"); - - return primaryKey(prj); + return primaryKeys(cache, 1, 1).get(0); } /** @@ -608,9 +521,7 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest { */ protected Integer backupKey(IgniteCache<?, ?> cache) throws IgniteCheckedException { - CacheProjection<?, ?> prj = GridTestUtils.getFieldValue(cache, "delegate"); - - return backupKey(prj); + return backupKeys(cache, 1, 1).get(0); } /** @@ -620,9 +531,7 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest { */ protected Integer nearKey(IgniteCache<?, ?> cache) throws IgniteCheckedException { - CacheProjection<?, ?> prj = GridTestUtils.getFieldValue(cache, "delegate"); - - return nearKey(prj); + return nearKeys(cache, 1, 1).get(0); } /**