From 1d7267a77108e01f5a24a0af9a994dc7a0aee779 Mon Sep 17 00:00:00 2001 From: nikolay_tikhonov Date: Mon, 9 Feb 2015 18:21:17 +0300 Subject: [PATCH] IGNITE-96 Migrating tests on new API. --- .../cache/GridCacheAbstractLoadTest.java | 12 +++--- ...dCacheAffinityTransactionsOffHeapTest.java | 40 ++++++++++++------- .../loadtests/cache/GridCacheBenchmark.java | 6 +-- .../GridCacheDataStructuresLoadTest.java | 6 +-- .../GridCacheGroupLockComparisonTest.java | 9 +++-- .../loadtests/cache/GridCacheLoadTest.java | 26 ++++++------ .../cache/GridCachePutRemoveLoadTest.java | 8 ++-- .../cache/GridCacheSingleNodeLoadTest.java | 6 +-- .../cache/GridCacheSwapLoadTest.java | 10 ++--- .../capacity/GridCapacityLoadTest.java | 2 +- .../colocation/GridTestCacheStore.java | 7 +--- .../loadtests/colocation/GridTestMain.java | 8 ++-- .../ignite/loadtests/dsi/GridDsiClient.java | 4 +- .../ignite/loadtests/dsi/GridDsiPerfJob.java | 6 +-- .../mapper/GridContinuousMapperTask1.java | 2 +- .../mapper/GridContinuousMapperTask2.java | 2 +- .../swap/GridSwapEvictAllBenchmark.java | 10 +++-- .../GridMarshallerAbstractTest.java | 16 ++++---- ...CacheCheckpointSpiSecondCacheSelfTest.java | 12 +++--- .../GridCacheStoreValueBytesTest.java | 16 +++++--- .../junits/common/GridCommonAbstractTest.java | 11 ++++- 21 files changed, 123 insertions(+), 96 deletions(-) diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheAbstractLoadTest.java b/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheAbstractLoadTest.java index 94d989f2a95ca..9b97b7986745b 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheAbstractLoadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheAbstractLoadTest.java @@ -123,15 +123,15 @@ protected GridCacheAbstractLoadTest() { * @param writeClos Write closure. * @param readClos ReadClosure. */ - protected void loadTest(final CIX1> writeClos, - final CIX1> readClos) { + protected void loadTest(final CIX1> writeClos, + final CIX1> readClos) { info("Read threads: " + readThreads()); info("Write threads: " + writeThreads()); info("Test duration (ms): " + testDuration); - Ignite ignite = G.ignite(); + final Ignite ignite = G.ignite(); - final GridCache cache = ignite.cache(null); + final IgniteCache cache = ignite.jcache(null); assert cache != null; @@ -142,7 +142,7 @@ protected void loadTest(final CIX1> writeClos, while (!done.get()) { if (tx) { - try (IgniteTx tx = cache.txStart()) { + try (IgniteTx tx = ignite.transactions().txStart()) { writeClos.apply(cache); tx.commit(); @@ -164,7 +164,7 @@ protected void loadTest(final CIX1> writeClos, while(!done.get()) { if (tx) { - try (IgniteTx tx = cache.txStart()) { + try (IgniteTx tx = ignite.transactions().txStart()) { readClos.apply(cache); tx.commit(); diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheAffinityTransactionsOffHeapTest.java b/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheAffinityTransactionsOffHeapTest.java index fc8ba61b54c15..c3e177a22d509 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheAffinityTransactionsOffHeapTest.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheAffinityTransactionsOffHeapTest.java @@ -59,21 +59,22 @@ public static void main(String[] args) throws Exception { startNodes(); for (int i = 0; i < KEY_CNT; i++) { - GridCache c = cache(i); + IgniteCache c = cache(i); - c.putx((long)i, 0); - c.putx(new UserKey(i, 0), 0); - c.putx(new UserKey(i, 1), 0); - c.putx(new UserKey(i, 2), 0); + c.put((long) i, 0); + c.put(new UserKey(i, 0), 0); + c.put(new UserKey(i, 1), 0); + c.put(new UserKey(i, 2), 0); } assert cache(5).get(5L) != null; long key = 5; - GridCache c = cache(key); + IgniteCache c = cache(key); + Ignite ignite = ignite(key); - try (IgniteTx tx = c.txStartAffinity(key, PESSIMISTIC, REPEATABLE_READ, 0, 0)) { + try (IgniteTx tx = ignite.transactions().txStartAffinity(c.getName(), key, PESSIMISTIC, REPEATABLE_READ, 0, 0)) { Integer val = c.get(key); Integer userVal1 = c.get(new UserKey(key, 0)); Integer userVal2 = c.get(new UserKey(key, 1)); @@ -90,10 +91,10 @@ public static void main(String[] args) throws Exception { int newVal = val + 1; - c.putx(key, newVal); - c.putx(new UserKey(key, 0), newVal); - c.putx(new UserKey(key, 1), newVal); - c.putx(new UserKey(key, 2), newVal); + c.put(key, newVal); + c.put(new UserKey(key, 0), newVal); + c.put(new UserKey(key, 1), newVal); + c.put(new UserKey(key, 2), newVal); tx.commit(); } @@ -153,10 +154,21 @@ public static void main(String[] args) throws Exception { * @param key Key. * @return Cache. */ - private static GridCache cache(long key) { - UUID id = Ignition.ignite("grid-0").cache(null).affinity().mapKeyToNode(key).id(); + private static IgniteCache cache(long key) { + UUID id = Ignition.ignite("grid-0").affinity(null).mapKeyToNode(key).id(); - return Ignition.ignite(id).cache(null); + return Ignition.ignite(id).jcache(null); + } + + + /** + * @param key Key. + * @return Cache. + */ + private static Ignite ignite(long key) { + UUID id = Ignition.ignite("grid-0").affinity(null).mapKeyToNode(key).id(); + + return Ignition.ignite(id); } /** diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheBenchmark.java b/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheBenchmark.java index 9c0772bbc3712..1f05f2aa673da 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheBenchmark.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheBenchmark.java @@ -72,7 +72,7 @@ public static void main(String[] args) throws Exception { X.println("threadCnt=" + THREADS); X.println("testWrite=" + testWrite); - final GridCache cache = g.cache(CACHE); + final IgniteCache cache = g.jcache(CACHE); assert cache != null; @@ -86,7 +86,7 @@ public static void main(String[] args) throws Exception { @Nullable @Override public Object call() throws Exception { long keyVal = cntr.incrementAndGet(); - cache.putx(keyVal % 100000, keyVal); + cache.put(keyVal % 100000, keyVal); long ops = opCnt.incrementAndGet(); @@ -136,7 +136,7 @@ public static void main(String[] args) throws Exception { if (keyVal >= PUT_CNT) break; - cache.putx(keyVal % 100000, keyVal); + cache.put(keyVal % 100000, keyVal); long ops = opCnt.incrementAndGet(); diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheDataStructuresLoadTest.java b/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheDataStructuresLoadTest.java index 941bcfc8b278d..063b1507daa8e 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheDataStructuresLoadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheDataStructuresLoadTest.java @@ -379,7 +379,7 @@ protected void loadTestIgnite(final CIX1 writeClos, final CIX1 r final Ignite ignite = G.ignite(); - final GridCache cache = ignite.cache(null); + final IgniteCache cache = ignite.jcache(null); assert cache != null; @@ -390,7 +390,7 @@ protected void loadTestIgnite(final CIX1 writeClos, final CIX1 r while (!done.get()) { if (tx) { - try (IgniteTx tx = cache.txStart()) { + try (IgniteTx tx = ignite.transactions().txStart()) { writeClos.apply(ignite); tx.commit(); @@ -412,7 +412,7 @@ protected void loadTestIgnite(final CIX1 writeClos, final CIX1 r while(!done.get()) { if (tx) { - try (IgniteTx tx = cache.txStart()) { + try (IgniteTx tx = ignite.transactions().txStart()) { readClos.apply(ignite); tx.commit(); diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheGroupLockComparisonTest.java b/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheGroupLockComparisonTest.java index f76b5540e541c..a4f917f263cb7 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheGroupLockComparisonTest.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheGroupLockComparisonTest.java @@ -83,7 +83,7 @@ private static void ignitePutAll(Ignite ignite, final long max, int threads) thr X.println(">>> Testing putAll"); X.println(">>>"); - final GridCache, Long> cache = ignite.cache(CACHE); + final IgniteCache, Long> cache = ignite.jcache(CACHE); assert cache != null; @@ -133,12 +133,12 @@ private static void ignitePutAll(Ignite ignite, final long max, int threads) thr * @param threads Threads. * @throws Exception If failed. */ - private static void igniteGroupLock(Ignite ignite, final long max, int threads) throws Exception { + private static void igniteGroupLock(final Ignite ignite, final long max, int threads) throws Exception { X.println(">>>"); X.println(">>> Testing group lock"); X.println(">>>"); - final GridCache, Long> cache = ignite.cache(CACHE); + final IgniteCache, Long> cache = ignite.jcache(CACHE); assert cache != null; @@ -172,7 +172,8 @@ private static void igniteGroupLock(Ignite ignite, final long max, int threads) // Threads should not lock the same key. - try (IgniteTx tx = cache.txStartAffinity(affKey, PESSIMISTIC, REPEATABLE_READ, 0, BATCH_SIZE)) { + try (IgniteTx tx = ignite.transactions().txStartAffinity(cache.getName(), affKey, PESSIMISTIC, + REPEATABLE_READ, 0, BATCH_SIZE)) { for (long i = 0; i < BATCH_SIZE; i++) { cache.put(new CacheAffinityKey<>((key % rangeCnt) + base, affKey), i); diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheLoadTest.java b/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheLoadTest.java index cbffddd117fb5..9d072026fe6eb 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheLoadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheLoadTest.java @@ -45,14 +45,14 @@ private GridCacheLoadTest() { } /** Write closure. */ - private final CIX1> writeClos = - new CIX1>() { - @Override public void applyx(CacheProjection cache) + private final CIX1> writeClos = + new CIX1>() { + @Override public void applyx(IgniteCache cache) throws IgniteCheckedException { for (int i = 0; i < operationsPerTx; i++) { int kv = RAND.nextInt(KEY_RANGE); - assert cache.putx(kv, kv); + cache.put(kv, kv); long cnt = writes.incrementAndGet(); @@ -63,9 +63,9 @@ private GridCacheLoadTest() { }; /** Read closure. */ - private final CIX1> readClos = - new CIX1>() { - @Override public void applyx(CacheProjection cache) + private final CIX1> readClos = + new CIX1>() { + @Override public void applyx(IgniteCache cache) throws IgniteCheckedException { for (int i = 0; i < operationsPerTx; i++) { int k = RAND.nextInt(KEY_RANGE); @@ -102,7 +102,7 @@ private byte[] newArray() { private void memoryTest() { Ignite ignite = G.ignite(); - final GridCache cache = ignite.cache(null); + final IgniteCache cache = ignite.jcache(null); assert cache != null; @@ -114,16 +114,18 @@ private void memoryTest() { while (true) { int idx; - cache.putx(idx = cnt.getAndIncrement(), newArray()); + cache.put(idx = cnt.getAndIncrement(), newArray()); if (idx % 1000 == 0) - info("Stored '" + idx + "' objects in cache [cache-size=" + cache.keySet().size() + ']'); + info("Stored '" + idx + "' objects in cache [cache-size=" + cache.size(CachePeekMode.ALL) + + ']'); } } }, threads, "memory-test-worker"); } catch (OutOfMemoryError ignore) { - info("Populated '" + cnt.get() + "' 1K objects into cache [cache-size=" + cache.keySet().size() + ']'); + info("Populated '" + cnt.get() + "' 1K objects into cache [cache-size=" + cache.size(CachePeekMode.ALL) + + ']'); } catch (Exception e) { e.printStackTrace(); @@ -150,7 +152,7 @@ public static void main(String[] args) throws Exception { if (LOAD) test.loadTest(test.writeClos, test.readClos); - G.ignite().cache(null).clear(); + G.ignite().jcache(null).clear(); System.gc(); diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCachePutRemoveLoadTest.java b/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCachePutRemoveLoadTest.java index 2d271f0ede85c..e220044ea64e8 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCachePutRemoveLoadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCachePutRemoveLoadTest.java @@ -45,7 +45,7 @@ public class GridCachePutRemoveLoadTest { private final Arguments args; /** */ - private GridCache cache; + private IgniteCache cache; /** * @param args Arguments. @@ -134,7 +134,7 @@ protected void startNodes() throws Exception { assert g != null; - cache = g.cache("cache"); + cache = g.jcache("cache"); assert cache != null; } @@ -188,7 +188,7 @@ private void runTest() throws Exception { for (long i = 0; i < Long.MAX_VALUE; i++) { Long key = queue.take(); - cache.removex(key); + cache.remove(key); rmvNum.set(key); } @@ -203,7 +203,7 @@ private void runTest() throws Exception { } for (long i = 0; i < Long.MAX_VALUE; i++) { - cache.putx(i, i); + cache.put(i, i); putNum.set(i); diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheSingleNodeLoadTest.java b/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheSingleNodeLoadTest.java index 9df16ddbc0fa4..43368bba81257 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheSingleNodeLoadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheSingleNodeLoadTest.java @@ -17,7 +17,7 @@ package org.apache.ignite.loadtests.cache; -import org.apache.ignite.cache.*; +import org.apache.ignite.*; import org.apache.ignite.cache.eviction.lru.*; import org.apache.ignite.configuration.*; import org.apache.ignite.internal.util.typedef.*; @@ -77,14 +77,14 @@ private static void runTest(final int putCnt, int userThreads) throws Exception GridTestUtils.runMultiThreaded(new Callable() { @Nullable @Override public Object call() throws Exception { - GridCache cache = G.ignite().cache(null); + IgniteCache cache = G.ignite().jcache(null); assert cache != null; long startTime = System.currentTimeMillis(); for (int i = 0; i < putCnt; i++) { - cache.putx(keyGen.incrementAndGet(), new Student()); + cache.put(keyGen.incrementAndGet(), new Student()); int cnt = txCntr.incrementAndGet(); diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheSwapLoadTest.java b/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheSwapLoadTest.java index 16f5cbb5d9009..d90a3fb1208f1 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheSwapLoadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/cache/GridCacheSwapLoadTest.java @@ -203,7 +203,7 @@ private static IgniteInternalFuture doPut(final Ignite g) { return GridTestUtils.runMultiThreadedAsync(new CAX() { @Override public void applyx() throws IgniteCheckedException { - GridCache cache = g.cache(null); + IgniteCache cache = g.jcache(null); assert cache != null; @@ -216,7 +216,7 @@ private static IgniteInternalFuture doPut(final Ignite g) { if (i > keyCnt) break; - cache.putx(i, i); + cache.put(i, i); } X.println(">>> Thread '" + Thread.currentThread().getName() + "' stopped."); @@ -235,7 +235,7 @@ private static Collection> doGetRemove(final Ignite g @Nullable @Override public Object call() throws Exception { getRemoveStartedLatch.await(); - GridCache cache = g.cache(null); + IgniteCache cache = g.jcache(null); assert cache != null; @@ -269,14 +269,14 @@ private static Collection> doGetRemove(final Ignite g @Nullable @Override public Object call() throws Exception { getRemoveStartedLatch.await(); - GridCache cache = g.cache(null); + IgniteCache cache = g.jcache(null); assert cache != null; while (true) { Integer i = swappedKeys.take(); - Integer val = cache.remove(i); + Integer val = cache.getAndRemove(i); assert val != null && val.equals(i); diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/capacity/GridCapacityLoadTest.java b/modules/core/src/test/java/org/apache/ignite/loadtests/capacity/GridCapacityLoadTest.java index da78a2d852bf2..316af3a65463d 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/capacity/GridCapacityLoadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/capacity/GridCapacityLoadTest.java @@ -46,7 +46,7 @@ public static void main(String[] args) throws Exception { IgniteConfiguration cfg = (IgniteConfiguration)ctx.getBean("grid.cfg"); try (Ignite g = G.start(cfg)) { - GridCache c = g.cache(null); + IgniteCache c = g.jcache(null); long init = mem.getHeapMemoryUsage().getUsed(); diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/colocation/GridTestCacheStore.java b/modules/core/src/test/java/org/apache/ignite/loadtests/colocation/GridTestCacheStore.java index 6f6ba52159437..3394bf917fb04 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/colocation/GridTestCacheStore.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/colocation/GridTestCacheStore.java @@ -58,13 +58,10 @@ public class GridTestCacheStore extends CacheStoreAdapter { try { ExecutorCompletionService completeSvc = new ExecutorCompletionService<>(execSvc); - GridCache cache = ignite.cache("partitioned"); + final IgniteCache cache = ignite.jcache("partitioned"); assert cache != null; - // Get projection just to check affinity for Integer. - final CacheProjection prj = cache.projection(Integer.class, Long.class); - final LongAdder adder = new LongAdder(); for (int i = 0; i < numThreads; i++) { @@ -83,7 +80,7 @@ public class GridTestCacheStore extends CacheStoreAdapter { end += mod; for (long i = start; i < end; i++) { - if (prj.cache().affinity().mapKeyToNode(GridTestKey.affinityKey(i)).isLocal()) { // Only add if key is local. + if (ignite.affinity(cache.getName()).mapKeyToNode(GridTestKey.affinityKey(i)).isLocal()) { // Only add if key is local. clo.apply(new GridTestKey(i), i); adder.increment(); diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/colocation/GridTestMain.java b/modules/core/src/test/java/org/apache/ignite/loadtests/colocation/GridTestMain.java index e845d23f9da2c..9b32d0f995d29 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/colocation/GridTestMain.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/colocation/GridTestMain.java @@ -43,7 +43,7 @@ public static void main(String[] args) throws Exception { // Initialize Spring factory. try (Ignite g = G.start((IgniteConfiguration)ctx.getBean("grid.cfg"))) { - final GridCache cache = g.cache("partitioned"); + final IgniteCache cache = g.jcache("partitioned"); assert cache != null; @@ -71,7 +71,7 @@ private static void colocateJobs() throws Exception { Ignite g = G.ignite(); - final GridCache cache = g.cache("partitioned"); + final IgniteCache cache = g.jcache("partitioned"); final BlockingQueue q = new ArrayBlockingQueue<>(400); @@ -133,7 +133,7 @@ private static void localPoolRun() { long start = System.currentTimeMillis(); - final GridCache cache = G.ignite().cache("partitioned"); + final IgniteCache cache = G.ignite().jcache("partitioned"); // Collocate computations and data. for (long i = 0; i < GridTestConstants.ENTRY_COUNT; i++) { @@ -164,7 +164,7 @@ private static void localPoolRun() { * @param cache Cache to load. * @throws IgniteCheckedException If failed. */ - private static void loadFromStore(GridCache cache) throws IgniteCheckedException { + private static void loadFromStore(IgniteCache cache) throws IgniteCheckedException { cache.loadCache(null, 0, GridTestConstants.LOAD_THREADS, GridTestConstants.ENTRY_COUNT); } diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/dsi/GridDsiClient.java b/modules/core/src/test/java/org/apache/ignite/loadtests/dsi/GridDsiClient.java index 08a65721f65ac..5518a6d5293c5 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/dsi/GridDsiClient.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/dsi/GridDsiClient.java @@ -234,7 +234,7 @@ public static void main(String[] args) throws Exception { // No 2 client should use the same simulator. HashMap> terminals = (HashMap>) - g.cache("CLIENT_PARTITIONED_CACHE").get("terminals"); + g.jcache("CLIENT_PARTITIONED_CACHE").get("terminals"); if (terminals == null) { X.println(">>> Terminals map has not been initialized."); @@ -279,7 +279,7 @@ public static void main(String[] args) throws Exception { terminals.put(srvrId, list); } - g.cache("CLIENT_PARTITIONED_CACHE").putx("terminals", terminals); + g.jcache("CLIENT_PARTITIONED_CACHE").put("terminals", terminals); } else { X.println(">>> Terminals map has been initialized."); diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/dsi/GridDsiPerfJob.java b/modules/core/src/test/java/org/apache/ignite/loadtests/dsi/GridDsiPerfJob.java index 4f62c4f4822cc..301b445574b96 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/dsi/GridDsiPerfJob.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/dsi/GridDsiPerfJob.java @@ -225,7 +225,7 @@ private void printTimers() { * */ private void doWork() { - GridCache cache = ignite.cache(cacheName); + IgniteCache cache = ignite.jcache(cacheName); assert cache != null; @@ -259,7 +259,7 @@ private void doWork() { ses = new GridDsiSession(terminalId); try { - try (IgniteTx tx = cache.txStart()) { + try (IgniteTx tx = ignite.transactions().txStart()) { GridDsiRequest req = new GridDsiRequest(getId()); req.setMessageId(getId()); @@ -338,6 +338,6 @@ private void put(final Object o, Object cacheKey) throws IgniteCheckedException */ @SuppressWarnings("ConstantConditions") private Object get(Object key) throws IgniteCheckedException { - return ignite.cache(cacheName).get(key); + return ignite.jcache(cacheName).get(key); } } diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/mapper/GridContinuousMapperTask1.java b/modules/core/src/test/java/org/apache/ignite/loadtests/mapper/GridContinuousMapperTask1.java index 1b13fbefde6fb..be5fb80a83b4b 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/mapper/GridContinuousMapperTask1.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/mapper/GridContinuousMapperTask1.java @@ -88,7 +88,7 @@ private void sendJob(ClusterNode n) { X.println(">>> Received job for ID: " + jobId); - return g.cache("replicated").peek(jobId); + return g.jcache("replicated").peek(jobId); } }, n); } diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/mapper/GridContinuousMapperTask2.java b/modules/core/src/test/java/org/apache/ignite/loadtests/mapper/GridContinuousMapperTask2.java index ce4a59fc8d719..ba4174329753b 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/mapper/GridContinuousMapperTask2.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/mapper/GridContinuousMapperTask2.java @@ -50,7 +50,7 @@ public class GridContinuousMapperTask2 extends ComputeTaskAdapter>> Received job for ID: " + jobId); - return g.cache("replicated").peek(jobId); + return g.jcache("replicated").peek(jobId); } }; diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/swap/GridSwapEvictAllBenchmark.java b/modules/core/src/test/java/org/apache/ignite/loadtests/swap/GridSwapEvictAllBenchmark.java index 059759200c166..fd1c56c083a16 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/swap/GridSwapEvictAllBenchmark.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/swap/GridSwapEvictAllBenchmark.java @@ -83,7 +83,7 @@ public static void main(String ... args) throws Exception { }); try { - GridCache cache = g.cache(null); + IgniteCache cache = g.jcache(null); assert cache != null; @@ -152,7 +152,7 @@ private static void runBenchmark(final int keysCnt, int batchSize, @Nullable Str long start = System.currentTimeMillis(); - GridCache cache = G.ignite().cache(null); + IgniteCache cache = G.ignite().jcache(null); assert cache != null; @@ -162,7 +162,8 @@ private static void runBenchmark(final int keysCnt, int batchSize, @Nullable Str keys.add(i); if (keys.size() == batchSize) { - cache.evictAll(keys); + for (Long key : keys) + cache.evict(key); evictedKeysCnt.addAndGet(batchSize); @@ -216,7 +217,8 @@ private static void runBenchmark(final int keysCnt, int batchSize, @Nullable Str keys.add(i); if (keys.size() == batchSize) { - cache.promoteAll(keys); + for (Long key : keys) + cache.promote(key); unswappedKeys.addAndGet(batchSize); diff --git a/modules/core/src/test/java/org/apache/ignite/marshaller/GridMarshallerAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/marshaller/GridMarshallerAbstractTest.java index f1a950ea983b4..db4c76b71ed0d 100644 --- a/modules/core/src/test/java/org/apache/ignite/marshaller/GridMarshallerAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/marshaller/GridMarshallerAbstractTest.java @@ -153,9 +153,9 @@ public Map> run(StreamerContext ctx, Collection evts) { * @throws Exception If failed. */ public void testDefaultCache() throws Exception { - GridCache cache = grid().cache(null); + IgniteCache cache = grid().jcache(null); - cache.putx("key", "val"); + cache.put("key", "val"); GridMarshallerTestBean inBean = newTestBean(cache); @@ -183,9 +183,9 @@ public void testDefaultCache() throws Exception { * @throws Exception If failed. */ public void testNamedCache() throws Exception { - GridCache cache = grid().cache(CACHE_NAME); + IgniteCache cache = grid().jcache(CACHE_NAME); - cache.putx("key", "val"); + cache.put("key", "val"); GridMarshallerTestBean inBean = newTestBean(cache); @@ -702,7 +702,7 @@ public void testEvents() throws Exception { } }, EVTS_CACHE); - grid().cache(null).put(1, 1); + grid().jcache(null).put(1, 1); GridMarshallerTestBean inBean = newTestBean(evts); @@ -805,11 +805,11 @@ public void testServices() throws Exception { * @throws Exception If failed. */ public void testAffinity() throws Exception { - GridCache cache = grid().cache(CACHE_NAME); + IgniteCache cache = grid().jcache(CACHE_NAME); - CacheAffinity affinity = cache.affinity(); + CacheAffinity affinity = affinity(cache); - cache.putx("tst", "test"); + cache.put("tst", "test"); GridMarshallerTestBean inBean = newTestBean(affinity); diff --git a/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/cache/CacheCheckpointSpiSecondCacheSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/cache/CacheCheckpointSpiSecondCacheSelfTest.java index 9432d1d7da69a..96bf6dda2b6c9 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/cache/CacheCheckpointSpiSecondCacheSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/checkpoint/cache/CacheCheckpointSpiSecondCacheSelfTest.java @@ -17,7 +17,7 @@ package org.apache.ignite.spi.checkpoint.cache; -import org.apache.ignite.cache.*; +import org.apache.ignite.*; import org.apache.ignite.configuration.*; import org.apache.ignite.spi.discovery.tcp.*; import org.apache.ignite.spi.discovery.tcp.ipfinder.*; @@ -82,18 +82,18 @@ public CacheCheckpointSpiSecondCacheSelfTest() { * @throws Exception If failed. */ public void testSecondCachePutRemove() throws Exception { - GridCache data = grid().cache(DATA_CACHE); - GridCache cp = grid().cache(CP_CACHE); + IgniteCache data = grid().jcache(DATA_CACHE); + IgniteCache cp = grid().jcache(CP_CACHE); - assertTrue(data.putx(1, 1)); - assertTrue(cp.putx(1, "1")); + data.put(1, 1); + cp.put(1, "1"); Integer v = data.get(1); assertNotNull(v); assertEquals(Integer.valueOf(1), data.get(1)); - assertTrue(data.removex(1)); + data.remove(1); assertNull(data.get(1)); diff --git a/modules/core/src/test/java/org/apache/ignite/storevalbytes/GridCacheStoreValueBytesTest.java b/modules/core/src/test/java/org/apache/ignite/storevalbytes/GridCacheStoreValueBytesTest.java index 87c894b8beb2d..05fd5f8dce32d 100644 --- a/modules/core/src/test/java/org/apache/ignite/storevalbytes/GridCacheStoreValueBytesTest.java +++ b/modules/core/src/test/java/org/apache/ignite/storevalbytes/GridCacheStoreValueBytesTest.java @@ -165,7 +165,7 @@ public static void main(String[] args) throws Exception { int sizeRange = maxSize - minSize; - GridCache cache = ignite.cache(null); + IgniteCache cache = ignite.jcache(null); if (sizeRange == 0) { for (Integer key : KEYS) @@ -202,8 +202,8 @@ static Collection> startThreads(ExecutorService exec, final Ignite ign final Semaphore sem = new Semaphore(concurrentGetNum); - final IgniteInClosure lsnr = new CI1() { - @Override public void apply(IgniteInternalFuture t) { + final IgniteInClosure lsnr = new CI1() { + @Override public void apply(Object t) { sem.release(); } }; @@ -217,12 +217,12 @@ static Collection> startThreads(ExecutorService exec, final Ignite ign for (int i = 0; i < threadsNum; i++) { futs.add(exec.submit(new Callable() { @Override public Void call() throws Exception { - GridCache cache = ignite.cache(null); + IgniteCache cache = ignite.jcache(null); Random random = new Random(); while (!finish.get()) { - Collection keys = new ArrayList<>(getKeyNum); + Set keys = new TreeSet<>(); for (int i = 0; i < KEYS_NUM; i++) { Integer key = KEYS[randomGet ? random.nextInt(KEYS_NUM) : i]; @@ -232,7 +232,11 @@ static Collection> startThreads(ExecutorService exec, final Ignite ign if (keys.size() == getKeyNum) { sem.acquire(); - IgniteInternalFuture> f = cache.getAllAsync(keys); + IgniteCache asyncCache = cache.withAsync(); + + asyncCache.getAll(keys); + + IgniteFuture f = asyncCache.future(); f.listenAsync(lsnr); 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 e5f27adb651d7..7efe9496eee01 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 @@ -102,6 +102,15 @@ protected GridCache cache() { protected GridCacheAdapter internalCache(int idx) { return ((IgniteKernal)grid(idx)).internalCache(null); } + + /** + * @param idx Grid index. + * @return Cache. + */ + protected GridCacheAdapter internalCache(int idx, String cacheName) { + return ((IgniteKernal)grid(idx)).internalCache(null); + } + /** * @return Cache. */ @@ -512,7 +521,7 @@ protected List nearKeys(IgniteCache cache, int cnt, int startFrom * @return Cache. */ protected IgniteCache primaryCache(Object key, @Nullable String cacheName) { - ClusterNode node = grid(0).cache(cacheName).affinity().mapKeyToNode(key); + ClusterNode node = internalCache(0, cacheName).affinity().mapKeyToNode(key); assertNotNull(node);