You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2017/03/27 10:20:20 UTC
[06/10] ignite git commit: IGNITE-4475: New async API: now all async
methods are defined explicitly,
IgniteAsyncSupport is deprecated. This closes #1648.
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/ComputeJobCancelWithServiceSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/ComputeJobCancelWithServiceSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/ComputeJobCancelWithServiceSelfTest.java
index bf23bdf..9c3611c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/ComputeJobCancelWithServiceSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/ComputeJobCancelWithServiceSelfTest.java
@@ -21,7 +21,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCompute;
import org.apache.ignite.IgniteException;
import org.apache.ignite.Ignition;
import org.apache.ignite.compute.ComputeJob;
@@ -71,11 +70,7 @@ public class ComputeJobCancelWithServiceSelfTest extends GridCommonAbstractTest
Ignite client = startGrid("client");
- IgniteCompute compute = client.compute().withAsync();
-
- compute.execute(new MyTask(), null);
-
- ComputeTaskFuture<Integer> fut = compute.future();
+ ComputeTaskFuture<Integer> fut = client.compute().executeAsync(new MyTask(), null);
Thread.sleep(3000);
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/GridCancelOnGridStopSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridCancelOnGridStopSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridCancelOnGridStopSelfTest.java
index 75affc4..61ed2b3 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridCancelOnGridStopSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridCancelOnGridStopSelfTest.java
@@ -59,7 +59,7 @@ public class GridCancelOnGridStopSelfTest extends GridCommonAbstractTest {
try (Ignite g = startGrid(1)) {
cnt = new CountDownLatch(1);
- g.compute().withAsync().execute(CancelledTask.class, null);
+ g.compute().executeAsync(CancelledTask.class, null);
cnt.await();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/GridCancelledJobsMetricsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridCancelledJobsMetricsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridCancelledJobsMetricsSelfTest.java
index 79b6505..39677c5 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridCancelledJobsMetricsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridCancelledJobsMetricsSelfTest.java
@@ -23,7 +23,6 @@ import java.util.Collection;
import java.util.List;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteCompute;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.compute.ComputeJob;
@@ -54,7 +53,6 @@ import org.apache.ignite.testframework.junits.common.GridCommonTest;
*/
@GridCommonTest(group = "Kernal Self")
public class GridCancelledJobsMetricsSelfTest extends GridCommonAbstractTest {
-
/** */
private static GridCancelCollisionSpi colSpi = new GridCancelCollisionSpi();
@@ -87,13 +85,8 @@ public class GridCancelledJobsMetricsSelfTest extends GridCommonAbstractTest {
Collection<ComputeTaskFuture<?>> futs = new ArrayList<>();
- IgniteCompute comp = ignite.compute().withAsync();
-
- for (int i = 1; i <= 10; i++) {
- comp.execute(CancelledTask.class, null);
-
- futs.add(comp.future());
- }
+ for (int i = 1; i <= 10; i++)
+ futs.add(ignite.compute().executeAsync(CancelledTask.class, null));
// Wait to be sure that metrics were updated.
GridTestUtils.waitForCondition(new GridAbsPredicate() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/GridContinuousTaskSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridContinuousTaskSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridContinuousTaskSelfTest.java
index d224fc5..6589dce 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridContinuousTaskSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridContinuousTaskSelfTest.java
@@ -28,7 +28,6 @@ import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.Callable;
import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCompute;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cluster.ClusterNode;
@@ -75,15 +74,9 @@ public class GridContinuousTaskSelfTest extends GridCommonAbstractTest {
try {
Ignite ignite = startGrid(0);
- IgniteCompute comp = ignite.compute().withAsync();
+ ComputeTaskFuture<Integer> fut1 = ignite.compute().executeAsync(TestJobsChainTask.class, true);
- comp.execute(TestJobsChainTask.class, true);
-
- ComputeTaskFuture<Integer> fut1 = comp.future();
-
- comp.execute(TestJobsChainTask.class, false);
-
- ComputeTaskFuture<Integer> fut2 = comp.future();
+ ComputeTaskFuture<Integer> fut2 = ignite.compute().executeAsync(TestJobsChainTask.class, false);
assert fut1.get() == 55;
assert fut2.get() == 55;
@@ -105,15 +98,9 @@ public class GridContinuousTaskSelfTest extends GridCommonAbstractTest {
/** {@inheritDoc} */
@Override public void run() {
try {
- IgniteCompute comp = ignite.compute().withAsync();
-
- comp.execute(TestJobsChainTask.class, true);
-
- ComputeTaskFuture<Integer> fut1 = comp.future();
-
- comp.execute(TestJobsChainTask.class, false);
+ ComputeTaskFuture<Integer> fut1 = ignite.compute().executeAsync(TestJobsChainTask.class, true);
- ComputeTaskFuture<Integer> fut2 = comp.future();
+ ComputeTaskFuture<Integer> fut2 = ignite.compute().executeAsync(TestJobsChainTask.class, false);
assert fut1.get() == 55;
assert fut2.get() == 55;
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/GridEventStorageCheckAllEventsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridEventStorageCheckAllEventsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridEventStorageCheckAllEventsSelfTest.java
index c78003a..30a16b0 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridEventStorageCheckAllEventsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridEventStorageCheckAllEventsSelfTest.java
@@ -23,7 +23,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCompute;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.compute.ComputeJob;
@@ -361,14 +360,9 @@ public class GridEventStorageCheckAllEventsSelfTest extends GridCommonAbstractTe
* @throws Exception If failed.
*/
private ComputeTaskFuture<?> generateEvents(@Nullable Long timeout, ComputeJob job) throws Exception {
- IgniteCompute comp = ignite.compute().withAsync();
-
- if (timeout == null)
- comp.execute(GridAllEventsTestTask.class.getName(), job);
- else
- comp.withTimeout(timeout).execute(GridAllEventsTestTask.class.getName(), job);
-
- return comp.future();
+ return timeout == null
+ ? ignite.compute().executeAsync(GridAllEventsTestTask.class.getName(), job)
+ : ignite.compute().withTimeout(timeout).executeAsync(GridAllEventsTestTask.class.getName(), job);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/GridFailoverCustomTopologySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridFailoverCustomTopologySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridFailoverCustomTopologySelfTest.java
index 6f70373..ea0c6eb 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridFailoverCustomTopologySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridFailoverCustomTopologySelfTest.java
@@ -24,7 +24,6 @@ import java.util.Map;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCompute;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cluster.ClusterNode;
@@ -96,11 +95,7 @@ public class GridFailoverCustomTopologySelfTest extends GridCommonAbstractTest {
ComputeTaskFuture<String> fut;
synchronized(mux){
- IgniteCompute comp = ignite1.compute().withAsync();
-
- comp.execute(JobTask.class, null);
-
- fut = comp.future();
+ fut = ignite1.compute().executeAsync(JobTask.class, null);
mux.wait();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/GridJobMasterLeaveAwareSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridJobMasterLeaveAwareSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridJobMasterLeaveAwareSelfTest.java
index 608eab4..0a55de1 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridJobMasterLeaveAwareSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridJobMasterLeaveAwareSelfTest.java
@@ -23,7 +23,6 @@ import java.util.Collection;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCompute;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cache.affinity.Affinity;
@@ -152,7 +151,7 @@ public class GridJobMasterLeaveAwareSelfTest extends GridCommonAbstractTest {
Ignite g = startGrid(0);
- g.compute().withAsync().execute(new TestTask(1), null);
+ g.compute().executeAsync(new TestTask(1), null);
jobLatch.await();
@@ -189,8 +188,8 @@ public class GridJobMasterLeaveAwareSelfTest extends GridCommonAbstractTest {
int lastGridIdx = GRID_CNT - 1;
- compute(grid(lastGridIdx).cluster().forPredicate(excludeLastPredicate())).withAsync().
- execute(new TestTask(GRID_CNT - 1), null);
+ compute(grid(lastGridIdx).cluster().forPredicate(excludeLastPredicate()))
+ .executeAsync(new TestTask(GRID_CNT - 1), null);
jobLatch.await();
@@ -214,8 +213,8 @@ public class GridJobMasterLeaveAwareSelfTest extends GridCommonAbstractTest {
int lastGridIdx = GRID_CNT - 1;
- compute(grid(lastGridIdx).cluster().forPredicate(excludeLastPredicate())).withAsync().
- execute(new TestTask(GRID_CNT - 1), null);
+ compute(grid(lastGridIdx).cluster().forPredicate(excludeLastPredicate()))
+ .executeAsync(new TestTask(GRID_CNT - 1), null);
jobLatch.await();
@@ -243,8 +242,8 @@ public class GridJobMasterLeaveAwareSelfTest extends GridCommonAbstractTest {
int lastGridIdx = GRID_CNT - 1;
- compute(grid(lastGridIdx).cluster().forPredicate(excludeLastPredicate())).withAsync().
- execute(new TestTask(GRID_CNT - 1), null);
+ compute(grid(lastGridIdx).cluster().forPredicate(excludeLastPredicate()))
+ .executeAsync(new TestTask(GRID_CNT - 1), null);
jobLatch.await();
@@ -273,11 +272,7 @@ public class GridJobMasterLeaveAwareSelfTest extends GridCommonAbstractTest {
public void testApply1() throws Exception {
testMasterLeaveAwareCallback(1, new CX1<ClusterGroup, IgniteFuture<?>>() {
@Override public IgniteFuture<?> applyx(ClusterGroup grid) {
- IgniteCompute comp = compute(grid).withAsync();
-
- comp.apply(new TestClosure(), "arg");
-
- return comp.future();
+ return compute(grid).applyAsync(new TestClosure(), "arg");
}
});
}
@@ -288,11 +283,7 @@ public class GridJobMasterLeaveAwareSelfTest extends GridCommonAbstractTest {
public void testApply2() throws Exception {
testMasterLeaveAwareCallback(2, new CX1<ClusterGroup, IgniteFuture<?>>() {
@Override public IgniteFuture<?> applyx(ClusterGroup grid) {
- IgniteCompute comp = compute(grid).withAsync();
-
- comp.apply(new TestClosure(), Arrays.asList("arg1", "arg2"));
-
- return comp.future();
+ return compute(grid).applyAsync(new TestClosure(), Arrays.asList("arg1", "arg2"));
}
});
}
@@ -303,9 +294,7 @@ public class GridJobMasterLeaveAwareSelfTest extends GridCommonAbstractTest {
public void testApply3() throws Exception {
testMasterLeaveAwareCallback(2, new CX1<ClusterGroup, IgniteFuture<?>>() {
@Override public IgniteFuture<?> applyx(ClusterGroup grid) {
- IgniteCompute comp = compute(grid).withAsync();
-
- comp.apply(new TestClosure(),
+ return compute(grid).applyAsync(new TestClosure(),
Arrays.asList("arg1", "arg2"),
new IgniteReducer<Void, Object>() {
@Override public boolean collect(@Nullable Void aVoid) {
@@ -316,8 +305,6 @@ public class GridJobMasterLeaveAwareSelfTest extends GridCommonAbstractTest {
return null;
}
});
-
- return comp.future();
}
});
}
@@ -328,11 +315,7 @@ public class GridJobMasterLeaveAwareSelfTest extends GridCommonAbstractTest {
public void testRun1() throws Exception {
testMasterLeaveAwareCallback(1, new CX1<ClusterGroup, IgniteFuture<?>>() {
@Override public IgniteFuture<?> applyx(ClusterGroup prj) {
- IgniteCompute comp = compute(prj).withAsync();
-
- comp.run(new TestRunnable());
-
- return comp.future();
+ return compute(prj).runAsync(new TestRunnable());
}
});
}
@@ -343,11 +326,7 @@ public class GridJobMasterLeaveAwareSelfTest extends GridCommonAbstractTest {
public void testRun2() throws Exception {
testMasterLeaveAwareCallback(2, new CX1<ClusterGroup, IgniteFuture<?>>() {
@Override public IgniteFuture<?> applyx(ClusterGroup prj) {
- IgniteCompute comp = compute(prj).withAsync();
-
- comp.run(Arrays.asList(new TestRunnable(), new TestRunnable()));
-
- return comp.future();
+ return compute(prj).runAsync(Arrays.asList(new TestRunnable(), new TestRunnable()));
}
});
}
@@ -358,11 +337,7 @@ public class GridJobMasterLeaveAwareSelfTest extends GridCommonAbstractTest {
public void testCall1() throws Exception {
testMasterLeaveAwareCallback(1, new CX1<ClusterGroup, IgniteFuture<?>>() {
@Override public IgniteFuture<?> applyx(ClusterGroup prj) {
- IgniteCompute comp = compute(prj).withAsync();
-
- comp.call(new TestCallable());
-
- return comp.future();
+ return compute(prj).callAsync(new TestCallable());
}
});
}
@@ -373,11 +348,7 @@ public class GridJobMasterLeaveAwareSelfTest extends GridCommonAbstractTest {
public void testCall2() throws Exception {
testMasterLeaveAwareCallback(2, new CX1<ClusterGroup, IgniteFuture<?>>() {
@Override public IgniteFuture<?> applyx(ClusterGroup prj) {
- IgniteCompute comp = compute(prj).withAsync();
-
- comp.call(Arrays.asList(new TestCallable(), new TestCallable()));
-
- return comp.future();
+ return compute(prj).callAsync(Arrays.asList(new TestCallable(), new TestCallable()));
}
});
}
@@ -388,9 +359,7 @@ public class GridJobMasterLeaveAwareSelfTest extends GridCommonAbstractTest {
public void testCall3() throws Exception {
testMasterLeaveAwareCallback(2, new CX1<ClusterGroup, IgniteFuture<?>>() {
@Override public IgniteFuture<?> applyx(ClusterGroup prj) {
- IgniteCompute comp = compute(prj).withAsync();
-
- comp.call(
+ return compute(prj).callAsync(
Arrays.asList(new TestCallable(), new TestCallable()),
new IgniteReducer<Void, Object>() {
@Override public boolean collect(@Nullable Void aVoid) {
@@ -401,8 +370,6 @@ public class GridJobMasterLeaveAwareSelfTest extends GridCommonAbstractTest {
return null;
}
});
-
- return comp.future();
}
});
}
@@ -413,11 +380,7 @@ public class GridJobMasterLeaveAwareSelfTest extends GridCommonAbstractTest {
public void testBroadcast1() throws Exception {
testMasterLeaveAwareCallback(1, new CX1<ClusterGroup, IgniteFuture<?>>() {
@Override public IgniteFuture<?> applyx(ClusterGroup prj) {
- IgniteCompute comp = compute(prj).withAsync();
-
- comp.broadcast(new TestRunnable());
-
- return comp.future();
+ return compute(prj).broadcastAsync(new TestRunnable());
}
});
}
@@ -428,11 +391,7 @@ public class GridJobMasterLeaveAwareSelfTest extends GridCommonAbstractTest {
public void testBroadcast2() throws Exception {
testMasterLeaveAwareCallback(1, new CX1<ClusterGroup, IgniteFuture<?>>() {
@Override public IgniteFuture<?> applyx(ClusterGroup prj) {
- IgniteCompute comp = compute(prj).withAsync();
-
- comp.broadcast(new TestCallable());
-
- return comp.future();
+ return compute(prj).broadcastAsync(new TestCallable());
}
});
}
@@ -443,11 +402,7 @@ public class GridJobMasterLeaveAwareSelfTest extends GridCommonAbstractTest {
public void testBroadcast3() throws Exception {
testMasterLeaveAwareCallback(1, new CX1<ClusterGroup, IgniteFuture<?>>() {
@Override public IgniteFuture<?> applyx(ClusterGroup prj) {
- IgniteCompute comp = compute(prj).withAsync();
-
- comp.broadcast(new TestClosure(), "arg");
-
- return comp.future();
+ return compute(prj).broadcastAsync(new TestClosure(), "arg");
}
});
}
@@ -458,15 +413,11 @@ public class GridJobMasterLeaveAwareSelfTest extends GridCommonAbstractTest {
public void testAffinityRun() throws Exception {
testMasterLeaveAwareCallback(1, new CX1<ClusterGroup, IgniteFuture<?>>() {
@Override public IgniteFuture<?> applyx(ClusterGroup prj) {
- IgniteCompute comp = compute(prj).withAsync();
-
Affinity<Object> aff = prj.ignite().affinity(null);
ClusterNode node = F.first(prj.nodes());
- comp.affinityRun((String)null, keyForNode(aff, node), new TestRunnable());
-
- return comp.future();
+ return compute(prj).affinityRunAsync((String)null, keyForNode(aff, node), new TestRunnable());
}
});
}
@@ -477,15 +428,11 @@ public class GridJobMasterLeaveAwareSelfTest extends GridCommonAbstractTest {
public void testAffinityCall() throws Exception {
testMasterLeaveAwareCallback(1, new CX1<ClusterGroup, IgniteFuture<?>>() {
@Override public IgniteFuture<?> applyx(ClusterGroup prj) {
- IgniteCompute comp = compute(prj).withAsync();
-
Affinity<Object> aff = prj.ignite().affinity(null);
ClusterNode node = F.first(prj.nodes());
- comp.affinityCall((String)null, keyForNode(aff, node), new TestCallable());
-
- return comp.future();
+ return compute(prj).affinityCallAsync((String)null, keyForNode(aff, node), new TestCallable());
}
});
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/GridMultipleJobsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridMultipleJobsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridMultipleJobsSelfTest.java
index 0970ba4..5776a15 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridMultipleJobsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridMultipleJobsSelfTest.java
@@ -21,9 +21,7 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteCompute;
import org.apache.ignite.cache.affinity.AffinityKeyMapped;
-import org.apache.ignite.compute.ComputeTaskFuture;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.util.typedef.CAX;
@@ -162,11 +160,7 @@ public class GridMultipleJobsSelfTest extends GridCommonAbstractTest {
throw new IgniteCheckedException("Could not instantiate a job.", e);
}
- IgniteCompute comp = ignite1.compute().withAsync();
-
- comp.call(job);
-
- ComputeTaskFuture<Boolean> fut = comp.future();
+ IgniteFuture<Boolean> fut = ignite1.compute().callAsync(job);
if (cnt % LOG_MOD == 0)
X.println("Submitted jobs: " + cnt);
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/GridReduceSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridReduceSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridReduceSelfTest.java
index 4b89241..827e2a2 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridReduceSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridReduceSelfTest.java
@@ -20,11 +20,10 @@ package org.apache.ignite.internal;
import java.util.ArrayList;
import java.util.List;
import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCompute;
import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.compute.ComputeTaskFuture;
import org.apache.ignite.internal.util.typedef.R1;
import org.apache.ignite.lang.IgniteCallable;
+import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.resources.LoggerResource;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
@@ -90,9 +89,7 @@ public class GridReduceSelfTest extends GridCommonAbstractTest {
List<ReducerTestClosure> closures = closures(ignite.cluster().nodes().size());
- IgniteCompute comp = compute(ignite.cluster().forLocal()).withAsync();
-
- comp.call(closures, new R1<Long, Long>() {
+ IgniteFuture<Long> fut = compute(ignite.cluster().forLocal()).callAsync(closures, new R1<Long, Long>() {
private long sum;
@Override public boolean collect(Long e) {
@@ -109,8 +106,6 @@ public class GridReduceSelfTest extends GridCommonAbstractTest {
}
});
- ComputeTaskFuture<Long> fut = comp.future();
-
assertEquals((Long)1L, fut.get());
assertTrue(closures.get(0).isFinished);
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/GridTaskCancelSingleNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridTaskCancelSingleNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridTaskCancelSingleNodeSelfTest.java
index 0557e04..950f89d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridTaskCancelSingleNodeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridTaskCancelSingleNodeSelfTest.java
@@ -22,7 +22,6 @@ import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCompute;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.compute.ComputeJob;
import org.apache.ignite.compute.ComputeJobAdapter;
@@ -118,11 +117,7 @@ public class GridTaskCancelSingleNodeSelfTest extends GridCommonAbstractTest {
}
}, EVT_JOB_STARTED, EVT_JOB_FINISHED, EVT_JOB_CANCELLED, EVT_JOB_REJECTED);
- IgniteCompute comp = grid().compute().withAsync();
-
- comp.execute(TestTask.class, null);
-
- ComputeTaskFuture<?> fut = comp.future();
+ ComputeTaskFuture<?> fut = grid().compute().executeAsync(TestTask.class, null);
if (timeoutBeforeCancel > 0L)
Thread.sleep(timeoutBeforeCancel);
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/GridTaskExecutionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridTaskExecutionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridTaskExecutionSelfTest.java
index 996acd6..a98c578 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridTaskExecutionSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridTaskExecutionSelfTest.java
@@ -68,11 +68,7 @@ public class GridTaskExecutionSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testSynchronousExecute() throws Exception {
- IgniteCompute comp = ignite.compute().withAsync();
-
- assertNull(comp.execute(GridTestTask.class, "testArg"));
-
- ComputeTaskFuture<?> fut = comp.future();
+ ComputeTaskFuture<?> fut = ignite.compute().executeAsync(GridTestTask.class, "testArg");
assert fut != null;
@@ -89,10 +85,10 @@ public class GridTaskExecutionSelfTest extends GridCommonAbstractTest {
ArrayList<IgniteFuture<Object>> futs = new ArrayList<>(2016);
- IgniteCompute compute = grid(1).compute(grid(1).cluster().forNodeId(grid(3).localNode().id())).withAsync();
+ IgniteCompute compute = grid(1).compute(grid(1).cluster().forNodeId(grid(3).localNode().id()));
for (int i = 0; i < 1000; i++) {
- compute.call(new IgniteCallable<Object>() {
+ futs.add(compute.callAsync(new IgniteCallable<Object>() {
@JobContextResource
ComputeJobContext ctx;
@@ -107,9 +103,7 @@ public class GridTaskExecutionSelfTest extends GridCommonAbstractTest {
return null;
}
- });
-
- futs.add(compute.future());
+ }));
}
info("Finished first loop.");
@@ -118,10 +112,10 @@ public class GridTaskExecutionSelfTest extends GridCommonAbstractTest {
idx.set(locId);
- IgniteCompute compute1 = grid(2).compute(grid(2).cluster().forNodeId(grid(3).localNode().id())).withAsync();
+ IgniteCompute compute1 = grid(2).compute(grid(2).cluster().forNodeId(grid(3).localNode().id()));
for (int i = 0; i < 100; i++) {
- compute1.call(new IgniteCallable<Object>() {
+ futs.add(compute1.callAsync(new IgniteCallable<Object>() {
@JobContextResource
ComputeJobContext ctx;
@@ -136,9 +130,7 @@ public class GridTaskExecutionSelfTest extends GridCommonAbstractTest {
return null;
}
- });
-
- futs.add(compute1.future());
+ }));
}
for (IgniteFuture<Object> fut : futs)
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/GridTaskFailoverAffinityRunTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridTaskFailoverAffinityRunTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridTaskFailoverAffinityRunTest.java
index 5760c19..da6875c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridTaskFailoverAffinityRunTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridTaskFailoverAffinityRunTest.java
@@ -22,7 +22,6 @@ import java.util.Collection;
import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.ignite.IgniteCompute;
import org.apache.ignite.IgniteException;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
@@ -110,8 +109,6 @@ public class GridTaskFailoverAffinityRunTest extends GridCommonAbstractTest {
assertEquals((Boolean)clientMode, grid(0).configuration().isClientMode());
- IgniteCompute comp = grid(0).compute().withAsync();
-
final AtomicBoolean stop = new AtomicBoolean();
final AtomicInteger gridIdx = new AtomicInteger(1);
@@ -137,9 +134,7 @@ public class GridTaskFailoverAffinityRunTest extends GridCommonAbstractTest {
Collection<IgniteFuture<?>> futs = new ArrayList<>(1000);
for (int i = 0; i < 1000; i++) {
- comp.affinityCall((String)null, i, new TestJob());
-
- IgniteFuture<?> fut0 = comp.future();
+ IgniteFuture<?> fut0 = grid(0).compute().affinityCallAsync((String)null, i, new TestJob());
assertNotNull(fut0);
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/GridTaskInstanceExecutionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridTaskInstanceExecutionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridTaskInstanceExecutionSelfTest.java
index 32fc350..2f153bb 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridTaskInstanceExecutionSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridTaskInstanceExecutionSelfTest.java
@@ -21,7 +21,6 @@ import java.util.Collection;
import java.util.List;
import org.apache.ignite.GridTestTask;
import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCompute;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.compute.ComputeJob;
import org.apache.ignite.compute.ComputeJobResult;
@@ -59,11 +58,7 @@ public class GridTaskInstanceExecutionSelfTest extends GridCommonAbstractTest {
assert task.getState() != null;
assert task.getState() == testState;
- IgniteCompute comp = ignite.compute().withAsync();
-
- assertNull(comp.execute(task, "testArg"));
-
- ComputeTaskFuture<?> fut = comp.future();
+ ComputeTaskFuture<?> fut = ignite.compute().executeAsync(task, "testArg");
assert fut != null;
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/GridTaskJobRejectSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridTaskJobRejectSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridTaskJobRejectSelfTest.java
index ed3ad63..68abc95 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridTaskJobRejectSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridTaskJobRejectSelfTest.java
@@ -21,7 +21,6 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.ignite.IgniteCompute;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.compute.ComputeJob;
import org.apache.ignite.compute.ComputeJobAdapter;
@@ -126,9 +125,7 @@ public class GridTaskJobRejectSelfTest extends GridCommonAbstractTest {
final ClusterNode node = grid(1).localNode();
- IgniteCompute comp = grid(1).compute().withAsync();
-
- comp.execute(new ComputeTaskAdapter<Void, Void>() {
+ ComputeTaskFuture<?> fut = grid(1).compute().executeAsync(new ComputeTaskAdapter<Void, Void>() {
@Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid,
@Nullable Void arg) {
return F.asMap(new SleepJob(), node, new SleepJob(), node);
@@ -140,8 +137,6 @@ public class GridTaskJobRejectSelfTest extends GridCommonAbstractTest {
}
}, null);
- ComputeTaskFuture<?> fut = comp.future();
-
assert startedLatch.await(2, SECONDS);
fut.cancel();
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectApiExceptionTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectApiExceptionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectApiExceptionTest.java
index 31f72e7..37ca6bd 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectApiExceptionTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectApiExceptionTest.java
@@ -362,14 +362,10 @@ public class IgniteClientReconnectApiExceptionTest extends IgniteClientReconnect
new T2<Callable, C1<Object, Boolean>>(
new Callable() {
@Override public Object call() throws Exception {
- IgniteCache<Object, Object> async = dfltCache.withAsync();
-
boolean failed = false;
try {
- async.put(10002, 10002);
-
- async.future().get();
+ dfltCache.putAsync(10002, 10002).get();
}
catch (CacheException e) {
failed = true;
@@ -379,9 +375,7 @@ public class IgniteClientReconnectApiExceptionTest extends IgniteClientReconnect
assertTrue(failed);
- async.put(10002, 10002);
-
- return async.future().get();
+ return dfltCache.putAsync(10002, 10002).get();
}
},
new C1<Object, Boolean>() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/IgniteComputeEmptyClusterGroupTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteComputeEmptyClusterGroupTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteComputeEmptyClusterGroupTest.java
index 49a97bd..489979f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/IgniteComputeEmptyClusterGroupTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteComputeEmptyClusterGroupTest.java
@@ -22,11 +22,11 @@ import java.util.concurrent.Callable;
import org.apache.ignite.IgniteCompute;
import org.apache.ignite.cluster.ClusterGroup;
import org.apache.ignite.cluster.ClusterGroupEmptyException;
-import org.apache.ignite.compute.ComputeTaskFuture;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.lang.IgniteCallable;
import org.apache.ignite.lang.IgniteClosure;
+import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.lang.IgniteRunnable;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
@@ -80,23 +80,15 @@ public class IgniteComputeEmptyClusterGroupTest extends GridCommonAbstractTest {
assertEquals(0, empty.nodes().size());
- IgniteCompute comp = ignite(0).compute(empty).withAsync();
+ IgniteCompute comp = ignite(0).compute(empty);
- comp.affinityRun((String)null, 1, new FailRunnable());
+ checkFutureFails(comp.affinityRunAsync((String)null, 1, new FailRunnable()));
- checkFutureFails(comp);
+ checkFutureFails(comp.applyAsync(new FailClosure(), new Object()));
- comp.apply(new FailClosure(), new Object());
+ checkFutureFails(comp.affinityCallAsync((String)null, 1, new FailCallable()));
- checkFutureFails(comp);
-
- comp.affinityCall((String)null, 1, new FailCallable());
-
- checkFutureFails(comp);
-
- comp.broadcast(new FailCallable());
-
- checkFutureFails(comp);
+ checkFutureFails(comp.broadcastAsync(new FailCallable()));
}
/**
@@ -145,11 +137,9 @@ public class IgniteComputeEmptyClusterGroupTest extends GridCommonAbstractTest {
}
/**
- * @param comp Compute.
+ * @param fut Future.
*/
- private void checkFutureFails(IgniteCompute comp) {
- final ComputeTaskFuture fut = comp.future();
-
+ private void checkFutureFails(final IgniteFuture fut) {
assertNotNull(fut);
GridTestUtils.assertThrows(log, new Callable<Void>() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConcurrentReadThroughTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConcurrentReadThroughTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConcurrentReadThroughTest.java
index 87baa49..0551ec6 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConcurrentReadThroughTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConcurrentReadThroughTest.java
@@ -86,8 +86,6 @@ public class CacheConcurrentReadThroughTest extends GridCommonAbstractTest {
assertTrue(client.configuration().isClientMode());
- IgniteCompute compute = client.compute().withAsync();
-
for (int iter = 0; iter < 10; iter++) {
CacheConfiguration ccfg = new CacheConfiguration();
@@ -107,7 +105,7 @@ public class CacheConcurrentReadThroughTest extends GridCommonAbstractTest {
Collection<IgniteFuture<?>> futs = new ArrayList<>();
for (int i = 0; i < SYS_THREADS * 3; i++) {
- compute.run(new IgniteRunnable() {
+ futs.add(client.compute().runAsync(new IgniteRunnable() {
@IgniteInstanceResource
private transient Ignite ignite;
@@ -119,9 +117,7 @@ public class CacheConcurrentReadThroughTest extends GridCommonAbstractTest {
if (v == null)
throw new IgniteException("Failed to get value");
}
- });
-
- futs.add(compute.future());
+ }));
}
for (IgniteFuture<?> fut : futs)
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheFutureExceptionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheFutureExceptionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheFutureExceptionSelfTest.java
index 78145d2..1b93623 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheFutureExceptionSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheFutureExceptionSelfTest.java
@@ -114,15 +114,11 @@ public class CacheFutureExceptionSelfTest extends GridCommonAbstractTest {
IgniteCache<Object, Object> clientCache = nearCache ? client.createNearCache(cacheName,
new NearCacheConfiguration<>()) : client.cache(cacheName);
- IgniteCache<Object, Object> asyncCache = clientCache.withAsync();
-
fail = true;
- asyncCache.get("key");
-
final CountDownLatch futLatch = new CountDownLatch(1);
- asyncCache.future().listen(new IgniteInClosure<IgniteFuture<Object>>() {
+ clientCache.getAsync("key").listen(new IgniteInClosure<IgniteFuture<Object>>() {
@Override public void apply(IgniteFuture<Object> fut) {
assertTrue(fut.isDone());
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CachePutEventListenerErrorSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CachePutEventListenerErrorSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CachePutEventListenerErrorSelfTest.java
index 25b7404..bd43956 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CachePutEventListenerErrorSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CachePutEventListenerErrorSelfTest.java
@@ -30,6 +30,7 @@ import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.events.Event;
import org.apache.ignite.events.EventType;
import org.apache.ignite.lang.IgniteBiPredicate;
+import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
@@ -165,12 +166,12 @@ public class CachePutEventListenerErrorSelfTest extends GridCommonAbstractTest {
cfg.setAtomicityMode(atomicityMode);
cfg.setMemoryMode(memMode);
- IgniteCache<Integer, Integer> cache = ignite.createCache(cfg).withAsync();
+ IgniteCache<Integer, Integer> cache = ignite.createCache(cfg);
- cache.put(0, 0);
+ IgniteFuture f = cache.putAsync(0, 0);
try {
- cache.future().get(2000);
+ f.get(2000);
assert false : "Exception was not thrown";
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java
index 09a0d9a..850561f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java
@@ -203,14 +203,12 @@ public abstract class GridCacheAbstractFailoverSelfTest extends GridCacheAbstrac
try {
final Ignite g = startGrid(name);
- IgniteCache<String, Object> cache = g.<String, Object>cache(null).withAsync();
+ IgniteCache<String, Object> cache = g.cache(null);
for (int k = half; k < ENTRY_CNT; k++) {
String key = "key" + k;
- cache.get(key);
-
- assertNotNull("Failed to get key: 'key" + k + "'", cache.future().get(30_000));
+ assertNotNull("Failed to get key: 'key" + k + "'", cache.getAsync(key).get(30_000));
}
}
finally {
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiMultithreadedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiMultithreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiMultithreadedSelfTest.java
index 9908b87..140efb0 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiMultithreadedSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiMultithreadedSelfTest.java
@@ -189,7 +189,7 @@ public abstract class GridCacheAbstractFullApiMultithreadedSelfTest extends Grid
/**
* @throws Exception In case of error.
*/
- public void testGetAsync() throws Exception {
+ public void testGetAsyncOld() throws Exception {
runTest(new CIX1<IgniteCache<String, Integer>>() {
@Override public void applyx(IgniteCache<String, Integer> cache) {
int rnd = random();
@@ -210,6 +210,21 @@ public abstract class GridCacheAbstractFullApiMultithreadedSelfTest extends Grid
/**
* @throws Exception In case of error.
*/
+ public void testGetAsync() throws Exception {
+ runTest(new CIX1<IgniteCache<String, Integer>>() {
+ @Override public void applyx(IgniteCache<String, Integer> cache) {
+ int rnd = random();
+
+ assert cache.getAsync("key" + rnd).get() == rnd;
+
+ assert cache.getAsync("wrongKey").get() == null;
+ }
+ });
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
public void testGetAll() throws Exception {
runTest(new CIX1<IgniteCache<String, Integer>>() {
@Override public void applyx(IgniteCache<String, Integer> cache) {
@@ -228,7 +243,7 @@ public abstract class GridCacheAbstractFullApiMultithreadedSelfTest extends Grid
/**
* @throws Exception In case of error.
*/
- public void testGetAllAsync() throws Exception {
+ public void testGetAllAsyncOld() throws Exception {
runTest(new CIX1<IgniteCache<String, Integer>>() {
@Override public void applyx(IgniteCache<String, Integer> cache) {
int rnd1 = random();
@@ -250,6 +265,24 @@ public abstract class GridCacheAbstractFullApiMultithreadedSelfTest extends Grid
/**
* @throws Exception In case of error.
*/
+ public void testGetAllAsync() throws Exception {
+ runTest(new CIX1<IgniteCache<String, Integer>>() {
+ @Override public void applyx(IgniteCache<String, Integer> cache) {
+ int rnd1 = random();
+ int rnd2 = random();
+
+ Map<String, Integer> map = cache.getAllAsync(ImmutableSet.of("key" + rnd1, "key" + rnd2)).get();
+
+ assert map.size() == (rnd1 != rnd2 ? 2 : 1);
+ assert map.get("key" + rnd1) == rnd1;
+ assert map.get("key" + rnd2) == rnd2;
+ }
+ });
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
public void testRemove() throws Exception {
runTest(new CIX1<IgniteCache<String, Integer>>() {
@Override public void applyx(IgniteCache<String, Integer> cache) {
@@ -281,7 +314,7 @@ public abstract class GridCacheAbstractFullApiMultithreadedSelfTest extends Grid
/**
* @throws Exception In case of error.
*/
- public void testRemoveAsync() throws Exception {
+ public void testRemoveAsyncOld() throws Exception {
runTest(new CIX1<IgniteCache<String, Integer>>() {
@Override public void applyx(IgniteCache<String, Integer> cache) {
int rnd1 = random();
@@ -319,6 +352,38 @@ public abstract class GridCacheAbstractFullApiMultithreadedSelfTest extends Grid
/**
* @throws Exception In case of error.
*/
+ public void testRemoveAsync() throws Exception {
+ runTest(new CIX1<IgniteCache<String, Integer>>() {
+ @Override public void applyx(IgniteCache<String, Integer> cache) {
+ int rnd1 = random();
+ int rnd2 = random();
+
+ assert cache.getAndRemoveAsync("wrongKey").get() == null;
+
+ assert !cache.removeAsync("key" + rnd1, -1).get();
+
+ Integer v1 = cache.localPeek("key" + rnd1, CachePeekMode.ONHEAP);
+ Integer v2 = cache.localPeek("key" + rnd2, CachePeekMode.ONHEAP);
+
+ assert v1 == null || v1 == rnd1;
+ assert v2 == null || v2 == rnd2;
+
+ v1 = removeAsync(cache, "key" + rnd1);
+
+ assert cache.localPeek("key" + rnd1, CachePeekMode.ONHEAP) == null && (v1 == null || v1 == rnd1);
+
+ assert cache.getAndRemove("key" + rnd1) == null;
+
+ removeAsync(cache, "key" + rnd2, rnd2);
+
+ assert cache.localPeek("key" + rnd2, CachePeekMode.ONHEAP) == null;
+ }
+ });
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
public void testRemoveAll() throws Exception {
runTest(new CIX1<IgniteCache<String, Integer>>() {
@Override public void applyx(IgniteCache<String, Integer> cache) {
@@ -339,7 +404,7 @@ public abstract class GridCacheAbstractFullApiMultithreadedSelfTest extends Grid
/**
* @throws Exception In case of error.
*/
- public void testRemoveAllAsync() throws Exception {
+ public void testRemoveAllAsyncOld() throws Exception {
runTest(new CIX1<IgniteCache<String, Integer>>() {
@Override public void applyx(IgniteCache<String, Integer> cache) {
int rnd = random();
@@ -361,16 +426,32 @@ public abstract class GridCacheAbstractFullApiMultithreadedSelfTest extends Grid
}
/**
+ * @throws Exception In case of error.
+ */
+ public void testRemoveAllAsync() throws Exception {
+ runTest(new CIX1<IgniteCache<String, Integer>>() {
+ @Override public void applyx(IgniteCache<String, Integer> cache) {
+ int rnd = random();
+
+ Set<Integer> ids = new HashSet<>(set);
+
+ cache.removeAllAsync(rangeKeys(0, rnd)).get();
+
+ for (int i = 0; i < rnd; i++) {
+ if (ids.contains(i))
+ assertNull(cache.localPeek("key" + i));
+ }
+ }
+ });
+ }
+
+ /**
* @param cache Cache.
* @param key Key.
* @return Removed value.
*/
private <K, V> V removeAsync(IgniteCache<K, V> cache, K key) {
- IgniteCache<K, V> cacheAsync = cache.withAsync();
-
- cacheAsync.getAndRemove(key);
-
- return cacheAsync.<V>future().get();
+ return cache.getAndRemoveAsync(key).get();
}
/**
@@ -380,10 +461,6 @@ public abstract class GridCacheAbstractFullApiMultithreadedSelfTest extends Grid
* @return Remove result.
*/
private <K, V> boolean removeAsync(IgniteCache<K, V> cache, K key, V val) {
- IgniteCache<K, V> cacheAsync = cache.withAsync();
-
- cacheAsync.remove(key, val);
-
- return cacheAsync.<Boolean>future().get();
+ return cache.removeAsync(key, val).get();
}
}
\ No newline at end of file