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:15 UTC
[01/10] ignite git commit: IGNITE-4475: New async API: now all async
methods are defined explicitly,
IgniteAsyncSupport is deprecated. This closes #1648.
Repository: ignite
Updated Branches:
refs/heads/master 906b69268 -> 282b334f7
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/messaging/IgniteMessagingSendAsyncTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/messaging/IgniteMessagingSendAsyncTest.java b/modules/core/src/test/java/org/apache/ignite/messaging/IgniteMessagingSendAsyncTest.java
index 75e7d22..03e7210 100644
--- a/modules/core/src/test/java/org/apache/ignite/messaging/IgniteMessagingSendAsyncTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/messaging/IgniteMessagingSendAsyncTest.java
@@ -83,7 +83,7 @@ public class IgniteMessagingSendAsyncTest extends GridCommonAbstractTest impleme
Assert.assertEquals(Thread.currentThread(), thread);
Assert.assertEquals(msgStr, msg);
}
- });
+ }, false);
}
/**
@@ -94,12 +94,12 @@ public class IgniteMessagingSendAsyncTest extends GridCommonAbstractTest impleme
public void testSendAsyncMode() throws Exception {
Ignite ignite1 = startGrid(1);
- send(ignite1.message().withAsync(), msgStr, new IgniteBiInClosure<String, Thread> () {
+ send(ignite1.message(), msgStr, new IgniteBiInClosure<String, Thread> () {
@Override public void apply(String msg, Thread thread) {
Assert.assertTrue(!Thread.currentThread().equals(thread));
Assert.assertEquals(msgStr, msg);
}
- });
+ }, true);
}
/**
@@ -116,7 +116,7 @@ public class IgniteMessagingSendAsyncTest extends GridCommonAbstractTest impleme
Assert.assertEquals(Thread.currentThread(), thread);
Assert.assertEquals(msgStr, msg);
}
- });
+ }, false);
}
/**
@@ -128,12 +128,12 @@ public class IgniteMessagingSendAsyncTest extends GridCommonAbstractTest impleme
Ignite ignite1 = startGrid(1);
Ignite ignite2 = startGrid(2);
- sendWith2Nodes(ignite2, ignite1.message().withAsync(), msgStr, new IgniteBiInClosure<String, Thread> () {
+ sendWith2Nodes(ignite2, ignite1.message(), msgStr, new IgniteBiInClosure<String, Thread> () {
@Override public void apply(String msg, Thread thread) {
Assert.assertTrue(!Thread.currentThread().equals(thread));
Assert.assertEquals(msgStr, msg);
}
- });
+ }, true);
}
/**
@@ -155,24 +155,6 @@ public class IgniteMessagingSendAsyncTest extends GridCommonAbstractTest impleme
}
/**
- * Checks that sendOrdered work in thread pool, 1 node in topology.
- *
- * @throws Exception If failed.
- */
- public void testSendOrderedAsyncMode() throws Exception {
- Ignite ignite1 = startGrid(1);
-
- final List<String> msgs = orderedMessages();
-
- sendOrdered(ignite1.message().withAsync(), msgs, new IgniteBiInClosure< List<String>, List<Thread>> () {
- @Override public void apply(List<String> received, List<Thread> threads) {
- assertFalse(threads.contains(Thread.currentThread()));
- assertTrue(msgs.equals(received));
- }
- });
- }
-
- /**
* Checks that sendOrdered work in thread pool, 2 nodes in topology.
*
* @throws Exception If failed.
@@ -192,25 +174,6 @@ public class IgniteMessagingSendAsyncTest extends GridCommonAbstractTest impleme
}
/**
- * Checks that sendOrdered work in thread pool, 2 nodes in topology.
- *
- * @throws Exception If failed.
- */
- public void testSendOrderedAsyncMode2Node() throws Exception {
- Ignite ignite1 = startGrid(1);
- Ignite ignite2 = startGrid(2);
-
- final List<String> msgs = orderedMessages();
-
- sendOrderedWith2Node(ignite2, ignite1.message().withAsync(), msgs, new IgniteBiInClosure<List<String>, List<Thread>>() {
- @Override public void apply(List<String> received, List<Thread> threads) {
- assertFalse(threads.contains(Thread.currentThread()));
- assertTrue(msgs.equals(received));
- }
- });
- }
-
- /**
* @throws Exception If failed.
*/
public void testSendOrderedDefaultModeMultiThreads() throws Exception {
@@ -222,15 +185,6 @@ public class IgniteMessagingSendAsyncTest extends GridCommonAbstractTest impleme
/**
* @throws Exception If failed.
*/
- public void testSendOrderedAsyncModeMultiThreads() throws Exception {
- Ignite ignite = startGrid(1);
-
- sendOrderedMultiThreads(ignite.message().withAsync());
- }
-
- /**
- * @throws Exception If failed.
- */
public void testSendOrderedDefaultModeMultiThreadsWith2Node() throws Exception {
Ignite ignite1 = startGrid(1);
Ignite ignite2 = startGrid(2);
@@ -239,16 +193,6 @@ public class IgniteMessagingSendAsyncTest extends GridCommonAbstractTest impleme
}
/**
- * @throws Exception If failed.
- */
- public void testSendOrderedAsyncModeMultiThreadsWith2Node() throws Exception {
- Ignite ignite1 = startGrid(1);
- Ignite ignite2 = startGrid(2);
-
- sendOrderedMultiThreadsWith2Node(ignite2, ignite1.message().withAsync());
- }
-
- /**
* @param ignite2 Second node.
* @param ignMsg IgniteMessage.
* @throws Exception If failed.
@@ -380,13 +324,15 @@ public class IgniteMessagingSendAsyncTest extends GridCommonAbstractTest impleme
* @param igniteMsg Ignite message.
* @param msgStr Message string.
* @param cls Callback for compare result.
+ * @param async Use sendAsync flag.
* @throws Exception If failed.
*/
private void sendWith2Nodes(
final Ignite ignite2,
final IgniteMessaging igniteMsg,
final String msgStr,
- final IgniteBiInClosure<String, Thread> cls
+ final IgniteBiInClosure<String, Thread> cls,
+ final boolean async
) throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
@@ -400,7 +346,7 @@ public class IgniteMessagingSendAsyncTest extends GridCommonAbstractTest impleme
}
});
- send(igniteMsg, msgStr, cls);
+ send(igniteMsg, msgStr, cls, async);
latch.await();
}
@@ -409,12 +355,14 @@ public class IgniteMessagingSendAsyncTest extends GridCommonAbstractTest impleme
* @param igniteMsg Ignite messaging.
* @param msgStr Message string.
* @param cls Callback for compare result.
+ * @param async Use sendAsync flag.
* @throws Exception If failed.
*/
private void send(
final IgniteMessaging igniteMsg,
final String msgStr,
- final IgniteBiInClosure<String, Thread> cls
+ final IgniteBiInClosure<String, Thread> cls,
+ final boolean async
) throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
@@ -433,7 +381,10 @@ public class IgniteMessagingSendAsyncTest extends GridCommonAbstractTest impleme
}
});
- igniteMsg.send(TOPIC, msgStr);
+ if (async)
+ igniteMsg.withAsync().send(TOPIC, msgStr);
+ else
+ igniteMsg.send(TOPIC, msgStr);
latch.await();
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/session/GridSessionFutureWaitJobAttributeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/session/GridSessionFutureWaitJobAttributeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/session/GridSessionFutureWaitJobAttributeSelfTest.java
index 36c3027..bc601db 100644
--- a/modules/core/src/test/java/org/apache/ignite/session/GridSessionFutureWaitJobAttributeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/session/GridSessionFutureWaitJobAttributeSelfTest.java
@@ -25,7 +25,6 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
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;
@@ -122,11 +121,7 @@ public class GridSessionFutureWaitJobAttributeSelfTest extends GridCommonAbstrac
private void checkTask(int num) throws InterruptedException {
Ignite ignite = G.ignite(getTestIgniteInstanceName());
- IgniteCompute comp = ignite.compute().withAsync();
-
- comp.execute(GridTaskSessionTestTask.class.getName(), num);
-
- ComputeTaskFuture<?> fut = comp.future();
+ ComputeTaskFuture<?> fut = ignite.compute().executeAsync(GridTaskSessionTestTask.class.getName(), num);
assert fut != null;
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/session/GridSessionSetJobAttributeOrderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/session/GridSessionSetJobAttributeOrderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/session/GridSessionSetJobAttributeOrderSelfTest.java
index 7711733..0c28e7e 100644
--- a/modules/core/src/test/java/org/apache/ignite/session/GridSessionSetJobAttributeOrderSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/session/GridSessionSetJobAttributeOrderSelfTest.java
@@ -23,7 +23,6 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
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;
@@ -63,12 +62,9 @@ public class GridSessionSetJobAttributeOrderSelfTest extends GridCommonAbstractT
ignite1.compute().localDeployTask(SessionTestTask.class, SessionTestTask.class.getClassLoader());
- IgniteCompute comp = ignite1.compute().withAsync();
-
for (int i = 0; i < TESTS_COUNT; i++) {
- comp.withTimeout(100000).execute(SessionTestTask.class.getName(), ignite2.cluster().localNode().id());
-
- ComputeTaskFuture<?> fut = comp.future();
+ ComputeTaskFuture<?> fut = ignite1.compute().withTimeout(100000).executeAsync(
+ SessionTestTask.class.getName(), ignite2.cluster().localNode().id());
fut.getTaskSession().setAttribute(TEST_ATTR_KEY, SETS_ATTR_COUNT);
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/session/GridSessionSetJobAttributeWaitListenerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/session/GridSessionSetJobAttributeWaitListenerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/session/GridSessionSetJobAttributeWaitListenerSelfTest.java
index 6cf642b..5c7e6ec 100644
--- a/modules/core/src/test/java/org/apache/ignite/session/GridSessionSetJobAttributeWaitListenerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/session/GridSessionSetJobAttributeWaitListenerSelfTest.java
@@ -26,7 +26,6 @@ import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
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;
@@ -92,11 +91,7 @@ public class GridSessionSetJobAttributeWaitListenerSelfTest extends GridCommonAb
for (int i = 0; i < 5; i++) {
refreshInitialData();
- IgniteCompute comp = ignite.compute().withAsync();
-
- comp.execute(GridTaskSessionTestTask.class.getName(), null);
-
- ComputeTaskFuture<?> fut = comp.future();
+ ComputeTaskFuture<?> fut = ignite.compute().executeAsync(GridTaskSessionTestTask.class.getName(), null);
assert fut != null;
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/session/GridSessionSetTaskAttributeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/session/GridSessionSetTaskAttributeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/session/GridSessionSetTaskAttributeSelfTest.java
index 4092e74..ec8d5a3 100644
--- a/modules/core/src/test/java/org/apache/ignite/session/GridSessionSetTaskAttributeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/session/GridSessionSetTaskAttributeSelfTest.java
@@ -23,7 +23,6 @@ import java.util.Collection;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
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;
@@ -107,11 +106,7 @@ public class GridSessionSetTaskAttributeSelfTest extends GridCommonAbstractTest
private void checkTask(int num) {
Ignite ignite = G.ignite(getTestIgniteInstanceName());
- IgniteCompute comp = ignite.compute().withAsync();
-
- comp.execute(GridTaskSessionTestTask.class.getName(), num);
-
- ComputeTaskFuture<?> fut = comp.future();
+ ComputeTaskFuture<?> fut = ignite.compute().executeAsync(GridTaskSessionTestTask.class.getName(), num);
Object res = fut.get();
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/session/GridSessionTaskWaitJobAttributeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/session/GridSessionTaskWaitJobAttributeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/session/GridSessionTaskWaitJobAttributeSelfTest.java
index 41f6457..7150a27 100644
--- a/modules/core/src/test/java/org/apache/ignite/session/GridSessionTaskWaitJobAttributeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/session/GridSessionTaskWaitJobAttributeSelfTest.java
@@ -23,7 +23,6 @@ import java.util.Collection;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
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;
@@ -107,11 +106,7 @@ public class GridSessionTaskWaitJobAttributeSelfTest extends GridCommonAbstractT
private void checkTask(int num) {
Ignite ignite = G.ignite(getTestIgniteInstanceName());
- IgniteCompute comp = ignite.compute().withAsync();
-
- comp.execute(GridTaskSessionTestTask.class.getName(), num);
-
- ComputeTaskFuture<?> fut = comp.future();
+ ComputeTaskFuture<?> fut = ignite.compute().executeAsync(GridTaskSessionTestTask.class.getName(), num);
Object res = fut.get();
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/session/GridSessionWaitAttributeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/session/GridSessionWaitAttributeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/session/GridSessionWaitAttributeSelfTest.java
index f3f39ef..06f47b4 100644
--- a/modules/core/src/test/java/org/apache/ignite/session/GridSessionWaitAttributeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/session/GridSessionWaitAttributeSelfTest.java
@@ -24,8 +24,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
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.ComputeJobAdapter;
@@ -215,11 +213,7 @@ public class GridSessionWaitAttributeSelfTest extends GridCommonAbstractTest {
ignite1.compute().localDeployTask(TestSessionTask.class, TestSessionTask.class.getClassLoader());
- IgniteCompute comp = ignite1.compute().withAsync();
-
- comp.execute(TestSessionTask.class.getName(), type);
-
- ComputeTaskFuture<?> fut = comp.future();
+ ComputeTaskFuture<?> fut = ignite1.compute().executeAsync(TestSessionTask.class.getName(), type);
fut.getTaskSession().mapFuture().get();
@@ -254,7 +248,6 @@ public class GridSessionWaitAttributeSelfTest extends GridCommonAbstractTest {
* @param ses Session.
* @param prefix Prefix.
* @param type Type.
- * @throws IgniteCheckedException If failed.
*/
private static void checkSessionAttributes(ComputeTaskSession ses, String prefix, WaitAttributeType type) {
assert ses != null;
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/testframework/junits/cache/GridAbstractCacheStoreSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/cache/GridAbstractCacheStoreSelfTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/cache/GridAbstractCacheStoreSelfTest.java
index bb2e046..8aba684 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/cache/GridAbstractCacheStoreSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/cache/GridAbstractCacheStoreSelfTest.java
@@ -28,6 +28,7 @@ import java.util.concurrent.Callable;
import java.util.concurrent.LinkedBlockingQueue;
import javax.cache.Cache;
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
import org.apache.ignite.cache.store.CacheStore;
import org.apache.ignite.internal.processors.cache.CacheEntryImpl;
import org.apache.ignite.internal.util.lang.GridMetadataAwareAdapter;
@@ -547,6 +548,11 @@ public abstract class GridAbstractCacheStoreSelfTest<T extends CacheStore<Object
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Void> commitAsync() throws IgniteException {
+ return null;
+ }
+
+ /** {@inheritDoc} */
@Override public void close() {
// No-op.
}
@@ -570,5 +576,10 @@ public abstract class GridAbstractCacheStoreSelfTest<T extends CacheStore<Object
@Override public void rollback() {
// No-op.
}
+
+ /** {@inheritDoc} */
+ @Override public IgniteFuture<Void> rollbackAsync() throws IgniteException {
+ return null;
+ }
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/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 7b41b6c..ec31e59 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
@@ -929,11 +929,7 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
*/
protected <R> ComputeTaskFuture<R> executeAsync(IgniteCompute comp, ComputeTask task, @Nullable Object arg)
throws IgniteCheckedException {
- comp = comp.withAsync();
-
- assertNull(comp.execute(task, arg));
-
- ComputeTaskFuture<R> fut = comp.future();
+ ComputeTaskFuture<R> fut = comp.executeAsync(task, arg);
assertNotNull(fut);
@@ -949,11 +945,7 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
*/
protected <R> ComputeTaskFuture<R> executeAsync(IgniteCompute comp, String taskName, @Nullable Object arg)
throws IgniteCheckedException {
- comp = comp.withAsync();
-
- assertNull(comp.execute(taskName, arg));
-
- ComputeTaskFuture<R> fut = comp.future();
+ ComputeTaskFuture<R> fut = comp.executeAsync(taskName, arg);
assertNotNull(fut);
@@ -970,11 +962,7 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
@SuppressWarnings("unchecked")
protected <R> ComputeTaskFuture<R> executeAsync(IgniteCompute comp, Class taskCls, @Nullable Object arg)
throws IgniteCheckedException {
- comp = comp.withAsync();
-
- assertNull(comp.execute(taskCls, arg));
-
- ComputeTaskFuture<R> fut = comp.future();
+ ComputeTaskFuture<R> fut = comp.executeAsync(taskCls, arg);
assertNotNull(fut);
@@ -990,13 +978,7 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
*/
protected <T extends Event> IgniteFuture<T> waitForLocalEvent(IgniteEvents evts,
@Nullable IgnitePredicate<T> filter, @Nullable int... types) throws IgniteCheckedException {
- evts = evts.withAsync();
-
- assertTrue(evts.isAsync());
-
- assertNull(evts.waitForLocal(filter, types));
-
- IgniteFuture<T> fut = evts.future();
+ IgniteFuture<T> fut = evts.waitForLocalAsync(filter, types);
assertNotNull(fut);
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
index 46053b3..01207b6 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
@@ -143,17 +143,34 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Void> loadCacheAsync(@Nullable IgniteBiPredicate<K, V> p,
+ @Nullable Object... args) throws CacheException {
+ throw new UnsupportedOperationException("Method should be supported.");
+ }
+
+ /** {@inheritDoc} */
@Override public void localLoadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args)
throws CacheException {
compute.call(new LocalLoadCacheTask<>(cacheName, isAsync, p, args));
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Void> localLoadCacheAsync(@Nullable IgniteBiPredicate<K, V> p,
+ @Nullable Object... args) throws CacheException {
+ throw new UnsupportedOperationException("Method should be supported.");
+ }
+
+ /** {@inheritDoc} */
@Override public V getAndPutIfAbsent(K key, V val) throws CacheException {
return compute.call(new GetAndPutIfAbsentTask<>(cacheName, isAsync, key, val));
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<V> getAndPutIfAbsentAsync(K key, V val) throws CacheException {
+ return compute.callAsync(new GetAndPutIfAbsentTask<>(cacheName, isAsync, key, val));
+ }
+
+ /** {@inheritDoc} */
@Override public Lock lock(K key) {
throw new UnsupportedOperationException("Method should be supported.");
}
@@ -224,15 +241,28 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Integer> sizeAsync(CachePeekMode... peekModes) throws CacheException {
+ return compute.callAsync(new SizeTask(cacheName, isAsync, peekModes, false));
+ }
+
+ /** {@inheritDoc} */
@Override public long sizeLong(CachePeekMode... peekModes) throws CacheException {
return compute.call(new SizeLongTask(cacheName, isAsync, peekModes, false));
}
+ @Override public IgniteFuture<Long> sizeLongAsync(CachePeekMode... peekModes) throws CacheException {
+ return compute.callAsync(new SizeLongTask(cacheName, isAsync, peekModes, false));
+ }
+
/** {@inheritDoc} */
@Override public long sizeLong(int partition, CachePeekMode... peekModes) throws CacheException {
return compute.call(new PartitionSizeLongTask(cacheName, isAsync, peekModes, partition, false));
}
+ @Override public IgniteFuture<Long> sizeLongAsync(int partition, CachePeekMode... peekModes) throws CacheException {
+ return compute.callAsync(new PartitionSizeLongTask(cacheName, isAsync, peekModes, partition, false));
+ }
+
/** {@inheritDoc} */
@Override public int localSize(CachePeekMode... peekModes) {
return compute.call(new SizeTask(cacheName, isAsync, peekModes, true));
@@ -257,36 +287,72 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
}
/** {@inheritDoc} */
+ @Override public <T> IgniteFuture<Map<K, EntryProcessorResult<T>>> invokeAllAsync(
+ Map<? extends K, ? extends EntryProcessor<K, V, T>> map, Object... args) {
+ throw new UnsupportedOperationException("Method should be supported.");
+ }
+
+ /** {@inheritDoc} */
@Override public V get(K key) {
return compute.call(new GetTask<K, V>(cacheName, isAsync, key));
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<V> getAsync(K key) {
+ return compute.callAsync(new GetTask<K, V>(cacheName, isAsync, key));
+ }
+
+ /** {@inheritDoc} */
@Override public CacheEntry<K, V> getEntry(K key) {
return compute.call(new GetEntryTask<K, V>(cacheName, isAsync, key));
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<CacheEntry<K, V>> getEntryAsync(K key) {
+ return compute.callAsync(new GetEntryTask<K, V>(cacheName, isAsync, key));
+ }
+
+ /** {@inheritDoc} */
@Override public Map<K, V> getAll(Set<? extends K> keys) {
return compute.call(new GetAllTask<K, V>(cacheName, isAsync, keys));
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Map<K, V>> getAllAsync(Set<? extends K> keys) {
+ return compute.callAsync(new GetAllTask<K, V>(cacheName, isAsync, keys));
+ }
+
+ /** {@inheritDoc} */
@Override public Collection<CacheEntry<K, V>> getEntries(Set<? extends K> keys) {
return compute.call(new GetEntriesTask<K, V>(cacheName, isAsync, keys));
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Collection<CacheEntry<K, V>>> getEntriesAsync(Set<? extends K> keys) {
+ return compute.callAsync(new GetEntriesTask<K, V>(cacheName, isAsync, keys));
+ }
+
+ /** {@inheritDoc} */
@Override public Map<K, V> getAllOutTx(Set<? extends K> keys) {
return compute.call(new GetAllOutTxTask<K, V>(cacheName, isAsync, keys));
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Map<K, V>> getAllOutTxAsync(Set<? extends K> keys) {
+ return compute.callAsync(new GetAllOutTxTask<K, V>(cacheName, isAsync, keys));
+ }
+
+ /** {@inheritDoc} */
@Override public boolean containsKey(K key) {
return compute.call(new ContainsKeyTask<>(cacheName, isAsync, key));
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Boolean> containsKeyAsync(K key) {
+ return compute.callAsync(new ContainsKeyTask<>(cacheName, isAsync, key));
+ }
+
+ /** {@inheritDoc} */
@Override public void loadAll(Set<? extends K> keys, boolean replaceExistVals, CompletionListener completionLsnr) {
throw new UnsupportedOperationException("Oparetion can't be supported automatically.");
}
@@ -297,81 +363,161 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Boolean> containsKeysAsync(Set<? extends K> keys) {
+ return compute.callAsync(new ContainsKeysTask<>(cacheName, isAsync, keys));
+ }
+
+ /** {@inheritDoc} */
@Override public void put(K key, V val) {
compute.call(new PutTask<>(cacheName, isAsync, expiryPlc, key, val));
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Void> putAsync(K key, V val) {
+ return compute.callAsync(new PutTask<>(cacheName, isAsync, expiryPlc, key, val));
+ }
+
+ /** {@inheritDoc} */
@Override public V getAndPut(K key, V val) {
return compute.call(new GetAndPutTask<>(cacheName, isAsync, key, val));
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<V> getAndPutAsync(K key, V val) {
+ return compute.callAsync(new GetAndPutTask<>(cacheName, isAsync, key, val));
+ }
+
+ /** {@inheritDoc} */
@Override public void putAll(Map<? extends K, ? extends V> map) {
compute.call(new PutAllTask<>(cacheName, isAsync, map));
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Void> putAllAsync(Map<? extends K, ? extends V> map) {
+ return compute.callAsync(new PutAllTask<>(cacheName, isAsync, map));
+ }
+
+ /** {@inheritDoc} */
@Override public boolean putIfAbsent(K key, V val) {
return compute.call(new PutIfAbsentTask<>(cacheName, isAsync, key, val));
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Boolean> putIfAbsentAsync(K key, V val) {
+ return compute.callAsync(new PutIfAbsentTask<>(cacheName, isAsync, key, val));
+ }
+
+ /** {@inheritDoc} */
@Override public boolean remove(K key) {
return compute.call(new RemoveTask<>(cacheName, isAsync, key));
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Boolean> removeAsync(K key) {
+ return compute.callAsync(new RemoveTask<>(cacheName, isAsync, key));
+ }
+
+ /** {@inheritDoc} */
@Override public boolean remove(K key, V oldVal) {
return compute.call(new RemoveIfExistsTask<>(cacheName, isAsync, key, oldVal));
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Boolean> removeAsync(K key, V oldVal) {
+ return compute.callAsync(new RemoveIfExistsTask<>(cacheName, isAsync, key, oldVal));
+ }
+
+ /** {@inheritDoc} */
@Override public V getAndRemove(K key) {
return compute.call(new GetAndRemoveTask<K, V>(cacheName, isAsync, key));
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<V> getAndRemoveAsync(K key) {
+ return compute.callAsync(new GetAndRemoveTask<K, V>(cacheName, isAsync, key));
+ }
+
+ /** {@inheritDoc} */
@Override public boolean replace(K key, V oldVal, V newVal) {
return compute.call(new ReplaceIfExistsTask<>(cacheName, isAsync, key, oldVal, newVal));
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Boolean> replaceAsync(K key, V oldVal, V newVal) {
+ return compute.callAsync(new ReplaceIfExistsTask<>(cacheName, isAsync, key, oldVal, newVal));
+ }
+
+ /** {@inheritDoc} */
@Override public boolean replace(K key, V val) {
return compute.call(new ReplaceTask<>(cacheName, isAsync, key, val));
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Boolean> replaceAsync(K key, V val) {
+ return compute.callAsync(new ReplaceTask<>(cacheName, isAsync, key, val));
+ }
+
+ /** {@inheritDoc} */
@Override public V getAndReplace(K key, V val) {
return compute.call(new GetAndReplaceTask<>(cacheName, isAsync, key, val));
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<V> getAndReplaceAsync(K key, V val) {
+ return compute.callAsync(new GetAndReplaceTask<>(cacheName, isAsync, key, val));
+ }
+
+ /** {@inheritDoc} */
@Override public void removeAll(Set<? extends K> keys) {
compute.call(new RemoveAllKeysTask<>(cacheName, isAsync, keys));
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Void> removeAllAsync(Set<? extends K> keys) {
+ return compute.callAsync(new RemoveAllKeysTask<>(cacheName, isAsync, keys));
+ }
+
+ /** {@inheritDoc} */
@Override public void removeAll() {
compute.call(new RemoveAllTask<K, V>(cacheName, isAsync));
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Void> removeAllAsync() {
+ return compute.callAsync(new RemoveAllTask<K, V>(cacheName, isAsync));
+ }
+
+ /** {@inheritDoc} */
@Override public void clear() {
compute.call(new ClearTask(cacheName, isAsync));
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Void> clearAsync() {
+ return compute.callAsync(new ClearTask(cacheName, isAsync));
+ }
+
+ /** {@inheritDoc} */
@Override public void clear(K key) {
compute.call(new ClearKeyTask<>(cacheName, isAsync, false, key));
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Void> clearAsync(K key) {
+ return compute.callAsync(new ClearKeyTask<>(cacheName, isAsync, false, key));
+ }
+
+ /** {@inheritDoc} */
@Override public void clearAll(Set<? extends K> keys) {
compute.call(new ClearAllKeys<>(cacheName, isAsync, false, keys));
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Void> clearAllAsync(Set<? extends K> keys) {
+ return compute.callAsync(new ClearAllKeys<>(cacheName, isAsync, false, keys));
+ }
+
+ /** {@inheritDoc} */
@Override public void localClear(K key) {
compute.call(new ClearKeyTask<>(cacheName, isAsync, true, key));
}
@@ -387,11 +533,23 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
}
/** {@inheritDoc} */
+ @Override public <T> IgniteFuture<T> invokeAsync(
+ K key, EntryProcessor<K, V, T> processor, Object... args) {
+ return compute.callAsync(new InvokeTask<>(cacheName, isAsync, key, processor, args));
+ }
+
+ /** {@inheritDoc} */
@Override public <T> T invoke(K key, CacheEntryProcessor<K, V, T> processor, Object... args) {
return compute.call(new InvokeTask<>(cacheName, isAsync, key, processor, args));
}
/** {@inheritDoc} */
+ @Override public <T> IgniteFuture<T> invokeAsync(K key, CacheEntryProcessor<K, V, T> processor,
+ Object... args) {
+ return compute.callAsync(new InvokeTask<>(cacheName, isAsync, key, processor, args));
+ }
+
+ /** {@inheritDoc} */
@Override public <T> Map<K, EntryProcessorResult<T>> invokeAll(
Set<? extends K> keys,
EntryProcessor<K, V, T> processor,
@@ -401,6 +559,12 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
}
/** {@inheritDoc} */
+ @Override public <T> IgniteFuture<Map<K, EntryProcessorResult<T>>> invokeAllAsync(Set<? extends K> keys,
+ EntryProcessor<K, V, T> processor, Object... args) {
+ return compute.callAsync(new InvokeAllTask<>(cacheName, isAsync, keys, processor, args));
+ }
+
+ /** {@inheritDoc} */
@Override public String getName() {
return compute.call(new GetNameTask(cacheName, isAsync));
}
@@ -462,6 +626,12 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
}
/** {@inheritDoc} */
+ @Override public <T> IgniteFuture<Map<K, EntryProcessorResult<T>>> invokeAllAsync(Set<? extends K> keys,
+ CacheEntryProcessor<K, V, T> entryProcessor, Object... args) {
+ throw new UnsupportedOperationException("Method should be supported.");
+ }
+
+ /** {@inheritDoc} */
@Override public IgniteFuture<?> rebalance() {
throw new UnsupportedOperationException("Method should be supported.");
}
@@ -1335,6 +1505,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
/**
* @param cacheName Cache name.
* @param async Async.
+ * @param loc Local flag.
* @param key Key.
*/
public ClearKeyTask(String cacheName, boolean async, boolean loc, K key) {
@@ -1367,6 +1538,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
/**
* @param cacheName Cache name.
* @param async Async.
+ * @param loc Local flag.
* @param keys Keys.
*/
public ClearAllKeys(String cacheName, boolean async, boolean loc, Set<? extends K> keys) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteClusterProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteClusterProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteClusterProcessProxy.java
index 76a88d9..a0d10c4 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteClusterProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteClusterProcessProxy.java
@@ -121,12 +121,25 @@ public class IgniteClusterProcessProxy implements IgniteClusterEx {
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Collection<ClusterStartNodeResult>> startNodesAsync(File file, boolean restart,
+ int timeout, int maxConn) throws IgniteException {
+ throw new UnsupportedOperationException("Operation is not supported yet.");
+ }
+
+ /** {@inheritDoc} */
@Override public Collection<ClusterStartNodeResult> startNodes(Collection<Map<String, Object>> hosts,
@Nullable Map<String, Object> dflts, boolean restart, int timeout, int maxConn) throws IgniteException {
throw new UnsupportedOperationException("Operation is not supported yet.");
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Collection<ClusterStartNodeResult>> startNodesAsync(
+ Collection<Map<String, Object>> hosts, @Nullable Map<String, Object> dflts,
+ boolean restart, int timeout, int maxConn) throws IgniteException {
+ throw new UnsupportedOperationException("Operation is not supported yet.");
+ }
+
+ /** {@inheritDoc} */
@Override public void stopNodes() throws IgniteException {
throw new UnsupportedOperationException("Operation is not supported yet.");
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteEventsProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteEventsProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteEventsProcessProxy.java
index d5af81e..a925300 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteEventsProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteEventsProcessProxy.java
@@ -59,12 +59,25 @@ public class IgniteEventsProcessProxy implements IgniteEvents {
}
/** {@inheritDoc} */
+ @Override public <T extends Event> IgniteFuture<List<T>> remoteQueryAsync(IgnitePredicate<T> p, long timeout,
+ @Nullable int... types) throws IgniteException {
+ throw new UnsupportedOperationException("Operation isn't supported yet.");
+ }
+
+ /** {@inheritDoc} */
@Override public <T extends Event> UUID remoteListen(@Nullable IgniteBiPredicate<UUID, T> locLsnr,
@Nullable IgnitePredicate<T> rmtFilter, @Nullable int... types) throws IgniteException {
throw new UnsupportedOperationException("Operation isn't supported yet.");
}
/** {@inheritDoc} */
+ @Override public <T extends Event> IgniteFuture<UUID> remoteListenAsync(
+ @Nullable IgniteBiPredicate<UUID, T> locLsnr, @Nullable IgnitePredicate<T> rmtFilter,
+ @Nullable int... types) throws IgniteException {
+ throw new UnsupportedOperationException("Operation isn't supported yet.");
+ }
+
+ /** {@inheritDoc} */
@Override public <T extends Event> UUID remoteListen(int bufSize, long interval, boolean autoUnsubscribe,
@Nullable IgniteBiPredicate<UUID, T> locLsnr, @Nullable IgnitePredicate<T> rmtFilter,
@Nullable int... types) throws IgniteException {
@@ -72,17 +85,35 @@ public class IgniteEventsProcessProxy implements IgniteEvents {
}
/** {@inheritDoc} */
+ @Override public <T extends Event> IgniteFuture<UUID> remoteListenAsync(int bufSize, long interval,
+ boolean autoUnsubscribe, @Nullable IgniteBiPredicate<UUID, T> locLsnr, @Nullable IgnitePredicate<T> rmtFilter,
+ @Nullable int... types) throws IgniteException {
+ throw new UnsupportedOperationException("Operation isn't supported yet.");
+ }
+
+ /** {@inheritDoc} */
@Override public void stopRemoteListen(UUID opId) throws IgniteException {
throw new UnsupportedOperationException("Operation isn't supported yet.");
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Void> stopRemoteListenAsync(UUID opId) throws IgniteException {
+ throw new UnsupportedOperationException("Operation isn't supported yet.");
+ }
+
+ /** {@inheritDoc} */
@Override public <T extends Event> T waitForLocal(@Nullable IgnitePredicate<T> filter,
@Nullable int... types) throws IgniteException {
throw new UnsupportedOperationException("Operation isn't supported yet.");
}
/** {@inheritDoc} */
+ @Override public <T extends Event> IgniteFuture<T> waitForLocalAsync(@Nullable IgnitePredicate<T> filter,
+ @Nullable int... types) throws IgniteException {
+ throw new UnsupportedOperationException("Operation isn't supported yet.");
+ }
+
+ /** {@inheritDoc} */
@Override public <T extends Event> Collection<T> localQuery(IgnitePredicate<T> p, @Nullable int... types) {
throw new UnsupportedOperationException("Operation isn't supported yet.");
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLockPartitionOnAffinityRunTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLockPartitionOnAffinityRunTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLockPartitionOnAffinityRunTest.java
index fbc94ed..a1603d8 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLockPartitionOnAffinityRunTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLockPartitionOnAffinityRunTest.java
@@ -589,7 +589,7 @@ public class IgniteCacheLockPartitionOnAffinityRunTest extends IgniteCacheLockPa
final int orgId = primaryKey(grid(0).cache(Organization.class.getSimpleName()));
try {
- grid(1).compute().withAsync().affinityRun(
+ grid(1).compute().affinityRunAsync(
Arrays.asList(Organization.class.getSimpleName(), Person.class.getSimpleName()),
new Integer(orgId),
new IgniteRunnable() {
@@ -630,7 +630,7 @@ public class IgniteCacheLockPartitionOnAffinityRunTest extends IgniteCacheLockPa
try {
- grid(1).compute().withAsync().affinityCall(
+ grid(1).compute().affinityCallAsync(
Arrays.asList(Organization.class.getSimpleName(), Person.class.getSimpleName()),
new Integer(orgId),
new IgniteCallable<Object>() {
@@ -678,7 +678,7 @@ public class IgniteCacheLockPartitionOnAffinityRunTest extends IgniteCacheLockPa
final int orgId = primaryKey(grid(0).cache(Organization.class.getSimpleName()));
try {
- grid(1).compute().withAsync().affinityRun(
+ grid(1).compute().affinityRunAsync(
Arrays.asList(Organization.class.getSimpleName(), Person.class.getSimpleName()),
new Integer(orgId),
new RunnableWithMasterLeave() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryLoadSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryLoadSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryLoadSelfTest.java
index dc4a41f..0338429 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryLoadSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryLoadSelfTest.java
@@ -138,11 +138,7 @@ public class IgniteCacheQueryLoadSelfTest extends GridCommonAbstractTest {
public void testLoadCacheAsync() throws Exception {
IgniteCache<Integer, ValueObject> cache = grid().cache(null);
- IgniteCache<Integer, ValueObject> asyncCache = cache.withAsync();
-
- asyncCache.loadCache(null, 0);
-
- asyncCache.future().get();
+ cache.loadCacheAsync(null, 0).get();
assert cache.size() == PUT_CNT;
@@ -183,16 +179,12 @@ public class IgniteCacheQueryLoadSelfTest extends GridCommonAbstractTest {
public void testLoadCacheAsyncFiltered() throws Exception {
IgniteCache<Integer, ValueObject> cache = grid().cache(null);
- IgniteCache<Integer, ValueObject> asyncCache = cache.withAsync();
-
- asyncCache.loadCache(new P2<Integer, ValueObject>() {
+ cache.loadCacheAsync(new P2<Integer, ValueObject>() {
@Override
public boolean apply(Integer key, ValueObject val) {
return key >= 5;
}
- }, 0);
-
- asyncCache.future().get();
+ }, 0).get();
assert cache.localSize() == PUT_CNT - 5;
@@ -212,11 +204,7 @@ public class IgniteCacheQueryLoadSelfTest extends GridCommonAbstractTest {
IgniteCache<Integer, ValueObject> cache = jcache();
- IgniteCache<Integer, ValueObject> asyncCache = cache.withAsync();
-
- asyncCache.get(1);
-
- assert ((ValueObject)asyncCache.future().get()).value() == 1;
+ assert cache.getAsync(1).get().value() == 1;
assert cache.size() == 1;
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/platforms/cpp/jni/include/ignite/jni/exports.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/jni/include/ignite/jni/exports.h b/modules/platforms/cpp/jni/include/ignite/jni/exports.h
index 06be75d..6fe91c7 100644
--- a/modules/platforms/cpp/jni/include/ignite/jni/exports.h
+++ b/modules/platforms/cpp/jni/include/ignite/jni/exports.h
@@ -67,8 +67,6 @@ extern "C" {
void IGNITE_CALL IgniteTargetOutStream(gcj::JniContext* ctx, void* obj, int opType, long long memPtr);
void* IGNITE_CALL IgniteTargetOutObject(gcj::JniContext* ctx, void* obj, int opType);
void IGNITE_CALL IgniteTargetInStreamAsync(gcj::JniContext* ctx, void* obj, int opType, long long memPtr);
- void IGNITE_CALL IgniteTargetListenFuture(gcj::JniContext* ctx, void* obj, long long futId, int typ);
- void IGNITE_CALL IgniteTargetListenFutureForOperation(gcj::JniContext* ctx, void* obj, long long futId, int typ, int opId);
void* IGNITE_CALL IgniteAcquire(gcj::JniContext* ctx, void* obj);
void IGNITE_CALL IgniteRelease(void* obj);
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/platforms/cpp/jni/include/ignite/jni/java.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/jni/include/ignite/jni/java.h b/modules/platforms/cpp/jni/include/ignite/jni/java.h
index 7c5d684..85955b3 100644
--- a/modules/platforms/cpp/jni/include/ignite/jni/java.h
+++ b/modules/platforms/cpp/jni/include/ignite/jni/java.h
@@ -211,8 +211,6 @@ namespace ignite
jmethodID m_PlatformTarget_inStreamAsync;
jmethodID m_PlatformTarget_inStreamOutStream;
jmethodID m_PlatformTarget_inObjectStreamOutObjectStream;
- jmethodID m_PlatformTarget_listenFuture;
- jmethodID m_PlatformTarget_listenFutureForOperation;
jclass c_PlatformUtils;
jmethodID m_PlatformUtils_reallocate;
@@ -389,8 +387,6 @@ namespace ignite
void TargetOutStream(jobject obj, int opType, long long memPtr, JniErrorInfo* errInfo = NULL);
jobject TargetOutObject(jobject obj, int opType, JniErrorInfo* errInfo = NULL);
void TargetInStreamAsync(jobject obj, int type, long long memPtr, JniErrorInfo* errInfo = NULL);
- void TargetListenFuture(jobject obj, long long futId, int typ);
- void TargetListenFutureForOperation(jobject obj, long long futId, int typ, int opId);
jobject CacheOutOpQueryCursor(jobject obj, int type, long long memPtr, JniErrorInfo* errInfo = NULL);
jobject CacheOutOpContinuousQuery(jobject obj, int type, long long memPtr, JniErrorInfo* errInfo = NULL);
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/platforms/cpp/jni/project/vs/module.def
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/jni/project/vs/module.def b/modules/platforms/cpp/jni/project/vs/module.def
index 8159f8d..82cc41e 100644
--- a/modules/platforms/cpp/jni/project/vs/module.def
+++ b/modules/platforms/cpp/jni/project/vs/module.def
@@ -20,8 +20,6 @@ IgniteTargetInStreamOutLong @18
IgniteTargetOutStream @19
IgniteTargetInStreamOutStream @20
IgniteTargetInObjectStreamOutObjectStream @21
-IgniteTargetListenFuture @22
-IgniteTargetListenFutureForOperation @23
IgniteTargetInLongOutLong @24
IgniteTargetInStreamAsync @25
IgniteProcessorCompute @64
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/platforms/cpp/jni/src/exports.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/jni/src/exports.cpp b/modules/platforms/cpp/jni/src/exports.cpp
index 6c590e4..2aecd59 100644
--- a/modules/platforms/cpp/jni/src/exports.cpp
+++ b/modules/platforms/cpp/jni/src/exports.cpp
@@ -186,14 +186,6 @@ extern "C" {
ctx->TargetInStreamAsync(static_cast<jobject>(obj), opType, memPtr);
}
- void IGNITE_CALL IgniteTargetListenFuture(gcj::JniContext* ctx, void* obj, long long futId, int typ) {
- ctx->TargetListenFuture(static_cast<jobject>(obj), futId, typ);
- }
-
- void IGNITE_CALL IgniteTargetListenFutureForOperation(gcj::JniContext* ctx, void* obj, long long futId, int typ, int opId) {
- ctx->TargetListenFutureForOperation(static_cast<jobject>(obj), futId, typ, opId);
- }
-
void* IGNITE_CALL IgniteAcquire(gcj::JniContext* ctx, void* obj) {
return ctx->Acquire(static_cast<jobject>(obj));
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/platforms/cpp/jni/src/java.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/jni/src/java.cpp b/modules/platforms/cpp/jni/src/java.cpp
index 004a99c..809aa17 100644
--- a/modules/platforms/cpp/jni/src/java.cpp
+++ b/modules/platforms/cpp/jni/src/java.cpp
@@ -259,8 +259,6 @@ namespace ignite
JniMethod M_PLATFORM_TARGET_OUT_STREAM = JniMethod("outStream", "(IJ)V", false);
JniMethod M_PLATFORM_TARGET_OUT_OBJECT = JniMethod("outObject", "(I)Ljava/lang/Object;", false);
JniMethod M_PLATFORM_TARGET_IN_STREAM_ASYNC = JniMethod("inStreamAsync", "(IJ)V", false);
- JniMethod M_PLATFORM_TARGET_LISTEN_FUTURE = JniMethod("listenFuture", "(JI)V", false);
- JniMethod M_PLATFORM_TARGET_LISTEN_FOR_OPERATION = JniMethod("listenFutureForOperation", "(JII)V", false);
const char* C_PLATFORM_CALLBACK_UTILS = "org/apache/ignite/internal/processors/platform/callback/PlatformCallbackUtils";
@@ -592,8 +590,6 @@ namespace ignite
m_PlatformTarget_inStreamOutStream = FindMethod(env, c_PlatformTarget, M_PLATFORM_TARGET_IN_STREAM_OUT_STREAM);
m_PlatformTarget_inObjectStreamOutObjectStream = FindMethod(env, c_PlatformTarget, M_PLATFORM_TARGET_IN_OBJECT_STREAM_OUT_OBJECT_STREAM);
m_PlatformTarget_inStreamAsync = FindMethod(env, c_PlatformTarget, M_PLATFORM_TARGET_IN_STREAM_ASYNC);
- m_PlatformTarget_listenFuture = FindMethod(env, c_PlatformTarget, M_PLATFORM_TARGET_LISTEN_FUTURE);
- m_PlatformTarget_listenFutureForOperation = FindMethod(env, c_PlatformTarget, M_PLATFORM_TARGET_LISTEN_FOR_OPERATION);
c_PlatformUtils = FindClass(env, C_PLATFORM_UTILS);
m_PlatformUtils_reallocate = FindMethod(env, c_PlatformUtils, M_PLATFORM_UTILS_REALLOC);
@@ -1396,22 +1392,6 @@ namespace ignite
ExceptionCheck(env, err);
}
- void JniContext::TargetListenFuture(jobject obj, long long futId, int typ) {
- JNIEnv* env = Attach();
-
- env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformTarget_listenFuture, futId, typ);
-
- ExceptionCheck(env);
- }
-
- void JniContext::TargetListenFutureForOperation(jobject obj, long long futId, int typ, int opId) {
- JNIEnv* env = Attach();
-
- env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformTarget_listenFutureForOperation, futId, typ, opId);
-
- ExceptionCheck(env);
- }
-
jobject JniContext::CacheOutOpQueryCursor(jobject obj, int type, long long memPtr, JniErrorInfo* err) {
JNIEnv* env = Attach();
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/scalar/src/main/scala/org/apache/ignite/scalar/pimps/ScalarProjectionPimp.scala
----------------------------------------------------------------------
diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/pimps/ScalarProjectionPimp.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/pimps/ScalarProjectionPimp.scala
index 737a798..b1a6b4f 100644
--- a/modules/scalar/src/main/scala/org/apache/ignite/scalar/pimps/ScalarProjectionPimp.scala
+++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/pimps/ScalarProjectionPimp.scala
@@ -375,11 +375,9 @@ class ScalarProjectionPimp[A <: ClusterGroup] extends PimpedType[A] with Iterabl
*/
def callAsync$[R](@Nullable s: Seq[Call[R]], @Nullable p: NF):
IgniteFuture[java.util.Collection[R]] = {
- val comp = value.ignite().compute(forPredicate(p)).withAsync()
+ val comp = value.ignite().compute(forPredicate(p))
- comp.call[R](toJavaCollection(s, (f: Call[R]) => toCallable(f)))
-
- comp.future()
+ comp.callAsync[R](toJavaCollection(s, (f: Call[R]) => toCallable(f)))
}
/**
@@ -435,11 +433,9 @@ class ScalarProjectionPimp[A <: ClusterGroup] extends PimpedType[A] with Iterabl
* @see `org.apache.ignite.cluster.ClusterGroup.call(...)`
*/
def runAsync$(@Nullable s: Seq[Run], @Nullable p: NF): IgniteFuture[_] = {
- val comp = value.ignite().compute(forPredicate(p)).withAsync()
-
- comp.run(toJavaCollection(s, (f: Run) => toRunnable(f)))
+ val comp = value.ignite().compute(forPredicate(p))
- comp.future()
+ comp.runAsync(toJavaCollection(s, (f: Run) => toRunnable(f)))
}
/**
@@ -494,11 +490,9 @@ class ScalarProjectionPimp[A <: ClusterGroup] extends PimpedType[A] with Iterabl
def reduceAsync$[R1, R2](s: Seq[Call[R1]], r: Seq[R1] => R2, @Nullable p: NF): IgniteFuture[R2] = {
assert(s != null && r != null)
- val comp = value.ignite().compute(forPredicate(p)).withAsync()
+ val comp = value.ignite().compute(forPredicate(p))
- comp.call(toJavaCollection(s, (f: Call[R1]) => toCallable(f)), r)
-
- comp.future()
+ comp.callAsync(toJavaCollection(s, (f: Call[R1]) => toCallable(f)), r)
}
/**
@@ -648,10 +642,8 @@ class ScalarProjectionPimp[A <: ClusterGroup] extends PimpedType[A] with Iterabl
*/
def affinityRunAsync$(cacheName: String, @Nullable affKey: Any, @Nullable r: Run,
@Nullable p: NF): IgniteFuture[_] = {
- val comp = value.ignite().compute(forPredicate(p)).withAsync()
-
- comp.affinityRun(cacheName, affKey, toRunnable(r))
+ val comp = value.ignite().compute(forPredicate(p))
- comp.future()
+ comp.affinityRunAsync(cacheName, affKey, toRunnable(r))
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/ssh/src/test/java/org/apache/ignite/internal/IgniteProjectionStartStopRestartSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/ssh/src/test/java/org/apache/ignite/internal/IgniteProjectionStartStopRestartSelfTest.java b/modules/ssh/src/test/java/org/apache/ignite/internal/IgniteProjectionStartStopRestartSelfTest.java
index 22c6977..5de7363 100644
--- a/modules/ssh/src/test/java/org/apache/ignite/internal/IgniteProjectionStartStopRestartSelfTest.java
+++ b/modules/ssh/src/test/java/org/apache/ignite/internal/IgniteProjectionStartStopRestartSelfTest.java
@@ -1051,10 +1051,6 @@ public class IgniteProjectionStartStopRestartSelfTest extends GridCommonAbstract
boolean restart,
int timeout,
int maxConn) {
- cluster = cluster.withAsync();
-
- assertNull(cluster.startNodes(hosts, dflts, restart, timeout, maxConn));
-
- return cluster.<Collection<ClusterStartNodeResult>>future().get(WAIT_TIMEOUT);
+ return cluster.startNodesAsync(hosts, dflts, restart, timeout, maxConn).get(WAIT_TIMEOUT);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/tasks/VisorTasksCommandSpec.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/tasks/VisorTasksCommandSpec.scala b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/tasks/VisorTasksCommandSpec.scala
index cdc5b47..4291103 100644
--- a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/tasks/VisorTasksCommandSpec.scala
+++ b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/tasks/VisorTasksCommandSpec.scala
@@ -47,27 +47,17 @@ class VisorTasksCommandSpec extends FunSpec with Matchers with BeforeAndAfterAll
visor.open(config("visor-demo-node"), "n/a")
try {
- val compute = ignite.compute().withAsync
+ val compute = ignite.compute()
- compute.withName("TestTask1").execute(new TestTask1(), null)
+ val fut1 = compute.withName("TestTask1").executeAsync(new TestTask1(), null)
- val fut1 = compute.future()
+ val fut2 = compute.withName("TestTask1").executeAsync(new TestTask1(), null)
- compute.withName("TestTask1").execute(new TestTask1(), null)
+ val fut3 = compute.withName("TestTask1").executeAsync(new TestTask1(), null)
- val fut2 = compute.future()
+ val fut4 = compute.withName("TestTask2").executeAsync(new TestTask2(), null)
- compute.withName("TestTask1").execute(new TestTask1(), null)
-
- val fut3 = compute.future()
-
- compute.withName("TestTask2").execute(new TestTask2(), null)
-
- val fut4 = compute.future()
-
- compute.withName("Test3").execute(new Test3(), null)
-
- val fut5 = compute.future()
+ val fut5 = compute.withName("Test3").executeAsync(new Test3(), null)
fut1.get
fut2.get
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicInvokeRetryBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicInvokeRetryBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicInvokeRetryBenchmark.java
index 6e65746..f4e5ed7 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicInvokeRetryBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicInvokeRetryBenchmark.java
@@ -77,8 +77,7 @@ public class IgniteAtomicInvokeRetryBenchmark extends IgniteFailoverAbstractBenc
for (Map.Entry<String, AtomicLong> e : nextValMap.entrySet()) {
String key = e.getKey();
- asyncCache.get(key);
- Set set = asyncCache.<Set>future().get(timeout);
+ Set set = cache.getAsync(key).get(timeout);
if (set == null || e.getValue() == null || !Objects.equals(e.getValue().get(), (long)set.size()))
badCacheEntries.put(key, set);
@@ -102,8 +101,7 @@ public class IgniteAtomicInvokeRetryBenchmark extends IgniteFailoverAbstractBenc
for (int k2 = 0; k2 < range; k2++) {
String key2 = "key-" + k2;
- asyncCache.get(key2);
- Object val = asyncCache.future().get(timeout);
+ Object val = cache.getAsync(key2).get(timeout);
if (val != null)
println("Cache Entry [key=" + key2 + ", val=" + val + "]");
@@ -116,8 +114,7 @@ public class IgniteAtomicInvokeRetryBenchmark extends IgniteFailoverAbstractBenc
println("Clearing all data.");
- asyncCache.removeAll();
- asyncCache.future().get(timeout);
+ cache.removeAllAsync().get(timeout);
nextValMap.clear();
@@ -166,8 +163,7 @@ public class IgniteAtomicInvokeRetryBenchmark extends IgniteFailoverAbstractBenc
if (nextAtomicVal != null)
nextVal = nextAtomicVal.incrementAndGet();
- asyncCache.invoke(key, new AddInSetEntryProcessor(), nextVal);
- asyncCache.future().get(args.cacheOperationTimeoutMillis());
+ cache.invokeAsync(key, new AddInSetEntryProcessor(), nextVal).get(args.cacheOperationTimeoutMillis());
}
finally {
rwl.readLock().unlock();
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicRetriesBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicRetriesBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicRetriesBenchmark.java
index 4e60698..0e99bbc 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicRetriesBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicRetriesBenchmark.java
@@ -39,26 +39,22 @@ public class IgniteAtomicRetriesBenchmark extends IgniteFailoverAbstractBenchmar
switch (opNum) {
case 0:
- asyncCache.get(key);
- asyncCache.future().get(timeout);
+ cache.getAsync(key).get(timeout);
break;
case 1:
- asyncCache.put(key, String.valueOf(key));
- asyncCache.future().get(timeout);
+ cache.putAsync(key, String.valueOf(key)).get(timeout);
break;
case 2:
- asyncCache.invoke(key, new TestCacheEntryProcessor());
- asyncCache.future().get(timeout);
+ cache.invokeAsync(key, new TestCacheEntryProcessor()).get(timeout);
break;
case 3:
- asyncCache.remove(key);
- asyncCache.future().get(timeout);
+ cache.removeAsync(key).get(timeout);
break;
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteFailoverAbstractBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteFailoverAbstractBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteFailoverAbstractBenchmark.java
index 1a700c2..a025bb5 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteFailoverAbstractBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteFailoverAbstractBenchmark.java
@@ -57,17 +57,12 @@ public abstract class IgniteFailoverAbstractBenchmark<K, V> extends IgniteCacheA
/** */
private static final AtomicBoolean restarterStarted = new AtomicBoolean();
- /** Async Cache. */
- protected IgniteCache<K, V> asyncCache;
-
/** */
private final AtomicBoolean firtsExProcessed = new AtomicBoolean();
/** {@inheritDoc} */
@Override public void setUp(final BenchmarkConfiguration cfg) throws Exception {
super.setUp(cfg);
-
- asyncCache = cache.withAsync();
}
/** {@inheritDoc} */
@@ -116,11 +111,8 @@ public abstract class IgniteFailoverAbstractBenchmark<K, V> extends IgniteCacheA
println("Waiting for partitioned map exchage of all nodes");
- IgniteCompute asyncCompute = ignite.compute().withAsync();
-
- asyncCompute.broadcast(new AwaitPartitionMapExchangeTask());
-
- asyncCompute.future().get(args.cacheOperationTimeoutMillis());
+ ignite.compute().broadcastAsync(new AwaitPartitionMapExchangeTask())
+ .get(args.cacheOperationTimeoutMillis());
println("Start servers restarting [numNodesToRestart=" + numNodesToRestart
+ ", shuffledIds=" + ids + "]");
@@ -242,10 +234,8 @@ public abstract class IgniteFailoverAbstractBenchmark<K, V> extends IgniteCacheA
ClusterGroup srvs = ignite.cluster().forServers();
- IgniteCompute asyncCompute = ignite.compute(srvs).withAsync();
-
- asyncCompute.broadcast(new ThreadDumpPrinterTask(ignite.cluster().localNode().id(), e));
- asyncCompute.future().get(10_000);
+ ignite.compute(srvs).broadcastAsync(new ThreadDumpPrinterTask(ignite.cluster().localNode().id(), e))
+ .get(10_000);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalInvokeRetryBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalInvokeRetryBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalInvokeRetryBenchmark.java
index b5a08da..2c4046e 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalInvokeRetryBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalInvokeRetryBenchmark.java
@@ -79,8 +79,7 @@ public class IgniteTransactionalInvokeRetryBenchmark extends IgniteFailoverAbstr
for (int i = 0; i < keysCnt; i++) {
String key = "key-" + k + "-" + cfg.memberId() + "-" + i;
- asyncCache.get(key);
- Long cacheVal = asyncCache.<Long>future().get(timeout);
+ Long cacheVal = cache.getAsync(key).get(timeout);
AtomicLong aVal = map.get(key);
Long mapVal = aVal != null ? aVal.get() : null;
@@ -114,8 +113,7 @@ public class IgniteTransactionalInvokeRetryBenchmark extends IgniteFailoverAbstr
for (int i2 = 0; i2 < keysCnt; i2++) {
String key2 = "key-" + k2 + "-" + cfg.memberId() + "-" + i2;
- asyncCache.get(key2);
- Long val = asyncCache.<Long>future().get(timeout);
+ Long val = cache.getAsync(key2).get(timeout);
if (val != null)
println(cfg, "Entry [key=" + key2 + ", val=" + val + "]");
@@ -169,8 +167,8 @@ public class IgniteTransactionalInvokeRetryBenchmark extends IgniteFailoverAbstr
if (ex != null)
throw ex;
- asyncCache.invoke(key, new IncrementInvokeRetryCacheEntryProcessor());
- asyncCache.future().get(args.cacheOperationTimeoutMillis());
+ cache.invokeAsync(key, new IncrementInvokeRetryCacheEntryProcessor())
+ .get(args.cacheOperationTimeoutMillis());
AtomicLong prevVal = map.putIfAbsent(key, new AtomicLong(0));
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalWriteInvokeBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalWriteInvokeBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalWriteInvokeBenchmark.java
index 67044a1..46ebd8c 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalWriteInvokeBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalWriteInvokeBenchmark.java
@@ -128,14 +128,12 @@ public class IgniteTransactionalWriteInvokeBenchmark extends IgniteFailoverAbstr
case 0: // Read scenario.
Map<String, Long> map = new HashMap<>();
- asyncCache.get(masterKey);
- Long cacheVal = asyncCache.<Long>future().get(timeout);
+ Long cacheVal = cache.getAsync(masterKey).get(timeout);
map.put(masterKey, cacheVal);
for (String key : keys) {
- asyncCache.get(key);
- cacheVal = asyncCache.<Long>future().get(timeout);
+ cacheVal = cache.getAsync(key).get(timeout);
map.put(key, cacheVal);
}
@@ -147,18 +145,16 @@ public class IgniteTransactionalWriteInvokeBenchmark extends IgniteFailoverAbstr
break;
case 1: // Invoke scenario.
- asyncCache.get(masterKey);
- Long val = asyncCache.<Long>future().get(timeout);
+ Long val = cache.getAsync(masterKey).get(timeout);
if (val == null)
badKeys.add(masterKey);
- asyncCache.put(masterKey, val == null ? -1 : val + 1);
- asyncCache.future().get(timeout);
+ cache.putAsync(masterKey, val == null ? -1 : val + 1).get(timeout);
for (String key : keys) {
- asyncCache.invoke(key, new IncrementWriteInvokeCacheEntryProcessor(), cacheName());
- Object o = asyncCache.future().get(timeout);
+ Object o = cache.invokeAsync(key,
+ new IncrementWriteInvokeCacheEntryProcessor(), cacheName()).get(timeout);
if (o != null)
badKeys.add(key);
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalWriteReadBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalWriteReadBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalWriteReadBenchmark.java
index c4314ed..ef88056 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalWriteReadBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalWriteReadBenchmark.java
@@ -54,8 +54,7 @@ public class IgniteTransactionalWriteReadBenchmark extends IgniteFailoverAbstrac
final int timeout = args.cacheOperationTimeoutMillis();
for (String key : keys) {
- asyncCache.get(key);
- Long val = asyncCache.<Long>future().get(timeout);
+ Long val = cache.getAsync(key).get(timeout);
map.put(key, val);
}
@@ -72,8 +71,7 @@ public class IgniteTransactionalWriteReadBenchmark extends IgniteFailoverAbstrac
for (int i = 0; i < args.keysCount(); i++) {
String key = "key-" + k + "-" + i;
- asyncCache.get(key);
- Long val = asyncCache.<Long>future().get(timeout);
+ Long val = cache.getAsync(key).get(timeout);
if (val != null)
println(cfg, "Entry [key=" + key + ", val=" + val + "]");
@@ -87,10 +85,8 @@ public class IgniteTransactionalWriteReadBenchmark extends IgniteFailoverAbstrac
final Long newVal = oldVal == null ? 0 : oldVal + 1;
- for (String key : keys) {
- asyncCache.put(key, newVal);
- asyncCache.future().get(timeout);
- }
+ for (String key : keys)
+ cache.putAsync(key, newVal).get(timeout);
return true;
}
[02/10] ignite git commit: IGNITE-4475: New async API: now all async
methods are defined explicitly,
IgniteAsyncSupport is deprecated. This closes #1648.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/IgniteComputeConfigVariationsFullApiTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/IgniteComputeConfigVariationsFullApiTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/IgniteComputeConfigVariationsFullApiTest.java
index 485e811..231fc9e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/IgniteComputeConfigVariationsFullApiTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/IgniteComputeConfigVariationsFullApiTest.java
@@ -24,6 +24,7 @@ import java.io.ObjectOutput;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
@@ -43,6 +44,7 @@ import org.apache.ignite.compute.ComputeTaskSplitAdapter;
import org.apache.ignite.internal.util.typedef.T2;
import org.apache.ignite.lang.IgniteCallable;
import org.apache.ignite.lang.IgniteClosure;
+import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.lang.IgniteReducer;
import org.apache.ignite.lang.IgniteRunnable;
import org.apache.ignite.testframework.junits.IgniteConfigVariationsAbstractTest;
@@ -199,6 +201,30 @@ public class IgniteComputeConfigVariationsFullApiTest extends IgniteConfigVariat
/**
* @throws Exception If failed.
*/
+ public void testExecuteTaskClassAsync() throws Exception {
+ runTest(jobFactories, new ComputeTest() {
+ @Override public void test(Factory factory, Ignite ignite) throws Exception {
+ // Begin with negative to check 'null' value in the test.
+ final int[] i = {-1};
+
+ ComputeTaskFuture<List<Object>> fut = ignite.compute().executeAsync(
+ TestTask.class,
+ new T2<>((Factory<ComputeJobAdapter>)factory,
+ (Factory<Object>)new Factory<Object>() {
+ @Override public Object create() {
+ return value(i[0]++);
+ }
+ }));
+
+ checkResultsClassCount(MAX_JOB_COUNT - 1, fut.get(), value(0).getClass());
+ assertCollectionsEquals("Results value mismatch", createGoldenResults(), fut.get());
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testExecuteTask() throws Exception {
runTest(jobFactories, new ComputeTest() {
@Override public void test(Factory factory, Ignite ignite) throws Exception {
@@ -222,6 +248,29 @@ public class IgniteComputeConfigVariationsFullApiTest extends IgniteConfigVariat
/**
* @throws Exception If failed.
*/
+ public void testExecuteTaskAsync() throws Exception {
+ runTest(jobFactories, new ComputeTest() {
+ @Override public void test(Factory factory, Ignite ignite) throws Exception {
+ // Begin with negative to check 'null' value in the test.
+ final int[] i = {-1};
+
+ ComputeTaskFuture<List<Object>> fut = ignite.compute().executeAsync(new TestTask(),
+ new T2<>((Factory<ComputeJobAdapter>)factory,
+ (Factory<Object>)new Factory<Object>() {
+ @Override public Object create() {
+ return value(i[0]++);
+ }
+ }));
+
+ checkResultsClassCount(MAX_JOB_COUNT - 1, fut.get(), value(0).getClass());
+ assertCollectionsEquals("Results value mismatch", createGoldenResults(), fut.get());
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testBroadcastClosure() throws Exception {
runTest(closureFactories, new ComputeTest() {
@Override public void test(Factory factory, Ignite ignite) throws Exception {
@@ -245,6 +294,29 @@ public class IgniteComputeConfigVariationsFullApiTest extends IgniteConfigVariat
/**
* @throws Exception If failed.
*/
+ public void testBroadcastClosureAsync() throws Exception {
+ runTest(closureFactories, new ComputeTest() {
+ @Override public void test(Factory factory, Ignite ignite) throws Exception {
+ final Collection<Object> resultsAllNull = ignite.compute()
+ .broadcast((IgniteClosure<Object, Object>)factory.create(), null);
+
+ assertEquals("Result's size mismatch: job must be run on all server nodes",
+ gridCount() - clientsCount(), resultsAllNull.size());
+
+ for (Object o : resultsAllNull)
+ assertNull("All results must be null", o);
+
+ IgniteFuture<Collection<Object>> fut = ignite.compute()
+ .broadcastAsync((IgniteClosure<Object, Object>)factory.create(), value(0));
+
+ checkResultsClassCount(gridCount() - clientsCount(), fut.get(), value(0).getClass());
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testBroadcastCallable() throws Exception {
runTest(callableFactories, new ComputeTest() {
@Override public void test(Factory factory, Ignite ignite) throws Exception {
@@ -274,6 +346,35 @@ public class IgniteComputeConfigVariationsFullApiTest extends IgniteConfigVariat
/**
* @throws Exception If failed.
*/
+ public void testBroadcastCallableAsync() throws Exception {
+ runTest(callableFactories, new ComputeTest() {
+ @Override public void test(Factory factory, Ignite ignite) throws Exception {
+ EchoCallable job = (EchoCallable)factory.create();
+ job.setArg(null);
+
+ final IgniteFuture<Collection<Object>> futAllNull = ignite.compute()
+ .broadcastAsync(job);
+
+ assertEquals("Result's size mismatch: job must be run on all server nodes",
+ gridCount() - clientsCount(), futAllNull.get().size());
+
+ for (Object o : futAllNull.get())
+ assertNull("All results must be null", o);
+
+ job.setArg(value(0));
+ IgniteFuture<Collection<Object>> futNotNull = ignite.compute()
+ .broadcastAsync(job);
+
+ checkResultsClassCount(gridCount() - clientsCount(), futNotNull.get(), value(0).getClass());
+ for (Object o : futNotNull.get())
+ assertEquals("Invalid broadcast results", value(0), o);
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testBroadcastRunnable() throws Exception {
runTest(runnableFactories, new ComputeTest() {
@Override public void test(Factory factory, Ignite ignite) throws Exception {
@@ -288,6 +389,22 @@ public class IgniteComputeConfigVariationsFullApiTest extends IgniteConfigVariat
/**
* @throws Exception If failed.
*/
+ public void testBroadcastRunnableAsync() throws Exception {
+ runTest(runnableFactories, new ComputeTest() {
+ @Override public void test(Factory factory, Ignite ignite) throws Exception {
+ IgniteRunnable job = (IgniteRunnable)factory.create();
+
+ IgniteFuture<Void> fut = ignite.compute().broadcastAsync(job);
+
+ fut.get();
+ // All checks are inside the run() method of the job.
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testRun() throws Exception {
runTest(runnableFactories, new ComputeTest() {
@Override public void test(Factory factory, Ignite ignite) throws Exception {
@@ -310,24 +427,48 @@ public class IgniteComputeConfigVariationsFullApiTest extends IgniteConfigVariat
/**
* @throws Exception If failed.
*/
+ public void testRunAsync() throws Exception {
+ runTest(runnableFactories, new ComputeTest() {
+ @Override public void test(Factory factory, Ignite ignite) throws Exception {
+ IgniteRunnable job = (IgniteRunnable)factory.create();
+
+ IgniteFuture<Void> fut0 = ignite.compute().runAsync(job);
+
+ fut0.get();
+ // All checks are inside the run() method of the job.
+
+ Collection<IgniteRunnable> jobs = new ArrayList<>(MAX_JOB_COUNT);
+
+ for (int i = 0; i < MAX_JOB_COUNT; ++i)
+ jobs.add((IgniteRunnable)factory.create());
+
+ IgniteFuture<Void> fut1 = ignite.compute().runAsync(jobs);
+
+ fut1.get();
+ // All checks are inside the run() method of the job.
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testApplyAsync() throws Exception {
runTest(closureFactories, new ComputeTest() {
@Override public void test(Factory factory, Ignite ignite) throws Exception {
- final IgniteCompute comp = ignite.compute().withAsync();
+ final IgniteCompute comp = ignite.compute();
- Collection<ComputeTaskFuture<Object>> futures = new ArrayList<>(MAX_JOB_COUNT);
+ Collection<IgniteFuture<Object>> futures = new ArrayList<>(MAX_JOB_COUNT);
for (int i = 0; i < MAX_JOB_COUNT; ++i) {
// value(i - 1): use negative argument of the value method to generate nullong value.
- comp.apply((IgniteClosure<Object, Object>)factory.create(), value(i - 1));
-
- futures.add(comp.future());
+ futures.add(comp.applyAsync((IgniteClosure<Object, Object>)factory.create(), value(i - 1)));
}
// Wait for results.
Collection<Object> results = new ArrayList<>(MAX_JOB_COUNT);
- for (ComputeTaskFuture<Object> future : futures)
+ for (IgniteFuture<Object> future : futures)
results.add(future.get());
checkResultsClassCount(MAX_JOB_COUNT - 1, results, value(0).getClass());
@@ -339,7 +480,7 @@ public class IgniteComputeConfigVariationsFullApiTest extends IgniteConfigVariat
/**
* @throws Exception If failed.
*/
- public void testApplySync() throws Exception {
+ public void testApply() throws Exception {
runTest(closureFactories, new ComputeTest() {
@Override public void test(Factory factory, Ignite ignite) throws Exception {
Collection<Object> results = new ArrayList<>(MAX_JOB_COUNT);
@@ -383,6 +524,32 @@ public class IgniteComputeConfigVariationsFullApiTest extends IgniteConfigVariat
/**
* @throws Exception If failed.
*/
+ public void testApplyForCollectionAsync() throws Exception {
+ runTest(closureFactories, new ComputeTest() {
+ @Override public void test(Factory factory, Ignite ignite) throws Exception {
+ Collection params = new ArrayList<>(MAX_JOB_COUNT);
+
+ for (int i = 0; i < MAX_JOB_COUNT; ++i) {
+ // value(i - 1): use negative argument of the value method to generate nullong value.
+ params.add(value(i - 1));
+ }
+
+ IgniteClosure c = (IgniteClosure)factory.create();
+
+ // Use type casting to avoid ambiguous for apply(Callable, Object) vs apply(Callable, Collection<Object>).
+ IgniteFuture<Collection<Object>> fut = ignite.compute().applyAsync(
+ (IgniteClosure<TestObject, Object>)c,
+ (Collection<TestObject>)params);
+
+ checkResultsClassCount(MAX_JOB_COUNT - 1, fut.get(), value(0).getClass());
+ assertCollectionsEquals("Results value mismatch", createGoldenResults(), fut.get());
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testApplyForCollectionWithReducer() throws Exception {
runTest(closureFactories, new ComputeTest() {
@Override public void test(Factory factory, Ignite ignite) throws Exception {
@@ -409,6 +576,7 @@ public class IgniteComputeConfigVariationsFullApiTest extends IgniteConfigVariat
return true;
}
});
+
assertTrue(res);
}
});
@@ -417,24 +585,58 @@ public class IgniteComputeConfigVariationsFullApiTest extends IgniteConfigVariat
/**
* @throws Exception If failed.
*/
+ public void testApplyForCollectionWithReducerAsync() throws Exception {
+ runTest(closureFactories, new ComputeTest() {
+ @Override public void test(Factory factory, Ignite ignite) throws Exception {
+ Collection<Object> params = new ArrayList<>(MAX_JOB_COUNT);
+
+ for (int i = 0; i < MAX_JOB_COUNT; ++i) {
+ // value(i - 1): use negative argument of the value method to generate nullong value.
+ params.add(value(i - 1));
+ }
+
+ IgniteFuture<Boolean> fut = ignite.compute()
+ .applyAsync((IgniteClosure<Object, Object>)factory.create(), params, new IgniteReducer<Object, Boolean>() {
+
+ private Collection<Object> results = new ArrayList<>(MAX_JOB_COUNT);
+
+ @Override public boolean collect(@Nullable Object o) {
+ results.add(o);
+ return true;
+ }
+
+ @Override public Boolean reduce() {
+ checkResultsClassCount(MAX_JOB_COUNT - 1, results, value(0).getClass());
+ assertCollectionsEquals("Results value mismatch", createGoldenResults(), results);
+ return true;
+ }
+ });
+
+ assertTrue(fut.get());
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testCallAsync() throws Exception {
runTest(callableFactories, new ComputeTest() {
@Override public void test(Factory factory, Ignite ignite) throws Exception {
- final IgniteCompute comp = ignite.compute().withAsync();
+ final IgniteCompute comp = ignite.compute();
- Collection<ComputeTaskFuture<Object>> futures = new ArrayList<>(MAX_JOB_COUNT);
+ Collection<IgniteFuture<Object>> futures = new ArrayList<>(MAX_JOB_COUNT);
for (int i = 0; i < MAX_JOB_COUNT; ++i) {
EchoCallable job = (EchoCallable)factory.create();
job.setArg(value(i - 1));
- comp.call(job);
- futures.add(comp.future());
+ futures.add(comp.callAsync(job));
}
// Wait for results.
Collection<Object> results = new ArrayList<>(MAX_JOB_COUNT);
- for (ComputeTaskFuture<Object> future : futures)
+ for (IgniteFuture<Object> future : futures)
results.add(future.get());
checkResultsClassCount(MAX_JOB_COUNT - 1, results, value(0).getClass());
@@ -446,7 +648,7 @@ public class IgniteComputeConfigVariationsFullApiTest extends IgniteConfigVariat
/**
* @throws Exception If failed.
*/
- public void testCallSync() throws Exception {
+ public void testCall() throws Exception {
runTest(callableFactories, new ComputeTest() {
@Override public void test(Factory factory, Ignite ignite) throws Exception {
Collection<Object> results = new ArrayList<>(MAX_JOB_COUNT);
@@ -488,6 +690,28 @@ public class IgniteComputeConfigVariationsFullApiTest extends IgniteConfigVariat
/**
* @throws Exception If failed.
*/
+ public void testCallCollectionAsync() throws Exception {
+ runTest(callableFactories, new ComputeTest() {
+ @Override public void test(Factory factory, Ignite ignite) throws Exception {
+ Collection<EchoCallable> jobs = new ArrayList<>(MAX_JOB_COUNT);
+
+ for (int i = 0; i < MAX_JOB_COUNT; ++i) {
+ EchoCallable job = (EchoCallable)factory.create();
+ job.setArg(value(i - 1));
+ jobs.add(job);
+ }
+
+ IgniteFuture<Collection<Object>> fut = ignite.compute().callAsync(jobs);
+
+ checkResultsClassCount(MAX_JOB_COUNT - 1, fut.get(), value(0).getClass());
+ assertCollectionsEquals("Results value mismatch", createGoldenResults(), fut.get());
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testCallCollectionWithReducer() throws Exception {
runTest(callableFactories, new ComputeTest() {
@Override public void test(Factory factory, Ignite ignite) throws Exception {
@@ -522,7 +746,41 @@ public class IgniteComputeConfigVariationsFullApiTest extends IgniteConfigVariat
/**
* @throws Exception If failed.
*/
- public void testDummyAffinityCall() throws Exception {
+ public void testCallCollectionWithReducerAsync() throws Exception {
+ runTest(callableFactories, new ComputeTest() {
+ @Override public void test(Factory factory, Ignite ignite) throws Exception {
+ Collection<EchoCallable> jobs = new ArrayList<>(MAX_JOB_COUNT);
+
+ for (int i = 0; i < MAX_JOB_COUNT; ++i) {
+ EchoCallable job = (EchoCallable)factory.create();
+ job.setArg(value(i - 1));
+ jobs.add(job);
+ }
+
+ IgniteFuture<Boolean> fut = ignite.compute().callAsync(jobs, new IgniteReducer<Object, Boolean>() {
+ private Collection<Object> results = new ArrayList<>(MAX_JOB_COUNT);
+
+ @Override public boolean collect(@Nullable Object o) {
+ results.add(o);
+ return true;
+ }
+
+ @Override public Boolean reduce() {
+ checkResultsClassCount(MAX_JOB_COUNT - 1, results, value(0).getClass());
+ assertCollectionsEquals("Results value mismatch", createGoldenResults(), results);
+ return true;
+ }
+ });
+
+ assertTrue(fut.get());
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testAffinityCall() throws Exception {
runTest(callableFactories, new ComputeTest() {
@Override public void test(Factory factory, Ignite ignite) throws Exception {
ignite.getOrCreateCache(CACHE_NAME);
@@ -548,7 +806,147 @@ public class IgniteComputeConfigVariationsFullApiTest extends IgniteConfigVariat
/**
* @throws Exception If failed.
*/
- public void testDummyAffinityRun() throws Exception {
+ public void testAffinityCallAsync() throws Exception {
+ runTest(callableFactories, new ComputeTest() {
+ @Override public void test(Factory factory, Ignite ignite) throws Exception {
+ ignite.getOrCreateCache(CACHE_NAME);
+
+ final IgniteCompute comp = ignite.compute();
+
+ Collection<Object> results = new ArrayList<>(MAX_JOB_COUNT);
+
+ for (int i = 0; i < MAX_JOB_COUNT; ++i) {
+ EchoCallable job = (EchoCallable)factory.create();
+
+ job.setArg(value(i - 1));
+
+ IgniteFuture<Object> fut = comp.affinityCallAsync("test", key(0), job);
+
+ results.add(fut.get());
+ }
+
+ checkResultsClassCount(MAX_JOB_COUNT - 1, results, value(0).getClass());
+ assertCollectionsEquals("Results value mismatch", createGoldenResults(), results);
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMultiCacheAffinityCall() throws Exception {
+ runTest(callableFactories, new ComputeTest() {
+ @Override public void test(Factory factory, Ignite ignite) throws Exception {
+ ignite.getOrCreateCache("test0");
+ ignite.getOrCreateCache("test1");
+
+ final IgniteCompute comp = ignite.compute();
+
+ Collection<Object> results = new ArrayList<>(MAX_JOB_COUNT);
+
+ for (int i = 0; i < MAX_JOB_COUNT; ++i) {
+ EchoCallable job = (EchoCallable)factory.create();
+
+ job.setArg(value(i - 1));
+
+ results.add(comp.affinityCall(Arrays.asList("test0", "test1"), key(0), job));
+ }
+
+ checkResultsClassCount(MAX_JOB_COUNT - 1, results, value(0).getClass());
+ assertCollectionsEquals("Results value mismatch", createGoldenResults(), results);
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMultiCacheAffinityCallAsync() throws Exception {
+ runTest(callableFactories, new ComputeTest() {
+ @Override public void test(Factory factory, Ignite ignite) throws Exception {
+ ignite.getOrCreateCache("test0");
+ ignite.getOrCreateCache("test1");
+
+ final IgniteCompute comp = ignite.compute();
+
+ Collection<Object> results = new ArrayList<>(MAX_JOB_COUNT);
+
+ for (int i = 0; i < MAX_JOB_COUNT; ++i) {
+ EchoCallable job = (EchoCallable)factory.create();
+
+ job.setArg(value(i - 1));
+
+ IgniteFuture<Object> fut = comp.affinityCallAsync(Arrays.asList("test0", "test1"), key(0), job);
+
+ results.add(fut.get());
+ }
+
+ checkResultsClassCount(MAX_JOB_COUNT - 1, results, value(0).getClass());
+ assertCollectionsEquals("Results value mismatch", createGoldenResults(), results);
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMultiCacheByPartIdAffinityCall() throws Exception {
+ runTest(callableFactories, new ComputeTest() {
+ @Override public void test(Factory factory, Ignite ignite) throws Exception {
+ ignite.getOrCreateCache("test0");
+ ignite.getOrCreateCache("test1");
+
+ final IgniteCompute comp = ignite.compute();
+
+ Collection<Object> results = new ArrayList<>(MAX_JOB_COUNT);
+
+ for (int i = 0; i < MAX_JOB_COUNT; ++i) {
+ EchoCallable job = (EchoCallable)factory.create();
+
+ job.setArg(value(i - 1));
+
+ results.add(comp.affinityCall(Arrays.asList("test0", "test1"), 0, job));
+ }
+
+ checkResultsClassCount(MAX_JOB_COUNT - 1, results, value(0).getClass());
+ assertCollectionsEquals("Results value mismatch", createGoldenResults(), results);
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMultiCacheByPartIdAffinityCallAsync() throws Exception {
+ runTest(callableFactories, new ComputeTest() {
+ @Override public void test(Factory factory, Ignite ignite) throws Exception {
+ ignite.getOrCreateCache("test0");
+ ignite.getOrCreateCache("test1");
+
+ final IgniteCompute comp = ignite.compute();
+
+ Collection<Object> results = new ArrayList<>(MAX_JOB_COUNT);
+
+ for (int i = 0; i < MAX_JOB_COUNT; ++i) {
+ EchoCallable job = (EchoCallable)factory.create();
+
+ job.setArg(value(i - 1));
+
+ IgniteFuture fut = comp.affinityCallAsync(Arrays.asList("test0", "test1"), 0, job);
+
+ results.add(fut.get());
+ }
+
+ checkResultsClassCount(MAX_JOB_COUNT - 1, results, value(0).getClass());
+ assertCollectionsEquals("Results value mismatch", createGoldenResults(), results);
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testAffinityRun() throws Exception {
runTest(runnableFactories, new ComputeTest() {
@Override public void test(Factory factory, Ignite ignite) throws Exception {
ignite.getOrCreateCache(CACHE_NAME);
@@ -567,6 +965,111 @@ public class IgniteComputeConfigVariationsFullApiTest extends IgniteConfigVariat
/**
* @throws Exception If failed.
*/
+ public void testAffinityRunAsync() throws Exception {
+ runTest(runnableFactories, new ComputeTest() {
+ @Override public void test(Factory factory, Ignite ignite) throws Exception {
+ ignite.getOrCreateCache(CACHE_NAME);
+
+ final IgniteCompute comp = ignite.compute();
+
+ for (int i = 0; i < MAX_JOB_COUNT; ++i) {
+ IgniteRunnable job = (IgniteRunnable)factory.create();
+
+ IgniteFuture<Void> fut = comp.affinityRunAsync("test", key(0), job);
+
+ fut.get();
+ }
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMultiCacheAffinityRun() throws Exception {
+ runTest(runnableFactories, new ComputeTest() {
+ @Override public void test(Factory factory, Ignite ignite) throws Exception {
+ ignite.getOrCreateCache("test0");
+ ignite.getOrCreateCache("test1");
+
+ final IgniteCompute comp = ignite.compute();
+
+ for (int i = 0; i < MAX_JOB_COUNT; ++i) {
+ IgniteRunnable job = (IgniteRunnable)factory.create();
+
+ comp.affinityRun(Arrays.asList("test0", "test1"), key(0), job);
+ }
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMultiCacheAffinityRunAsync() throws Exception {
+ runTest(runnableFactories, new ComputeTest() {
+ @Override public void test(Factory factory, Ignite ignite) throws Exception {
+ ignite.getOrCreateCache("test0");
+ ignite.getOrCreateCache("test1");
+
+ final IgniteCompute comp = ignite.compute();
+
+ for (int i = 0; i < MAX_JOB_COUNT; ++i) {
+ IgniteRunnable job = (IgniteRunnable)factory.create();
+
+ IgniteFuture<Void> fut = comp.affinityRunAsync(Arrays.asList("test0", "test1"), key(0), job);
+
+ fut.get();
+ }
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMultiCacheByPartIdAffinityRun() throws Exception {
+ runTest(runnableFactories, new ComputeTest() {
+ @Override public void test(Factory factory, Ignite ignite) throws Exception {
+ ignite.getOrCreateCache("test0");
+ ignite.getOrCreateCache("test1");
+
+ final IgniteCompute comp = ignite.compute();
+
+ for (int i = 0; i < MAX_JOB_COUNT; ++i) {
+ IgniteRunnable job = (IgniteRunnable)factory.create();
+
+ comp.affinityRun(Arrays.asList("test0", "test1"), 0, job);
+ }
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMultiCacheByPartIdAffinityRunAsync() throws Exception {
+ runTest(runnableFactories, new ComputeTest() {
+ @Override public void test(Factory factory, Ignite ignite) throws Exception {
+ ignite.getOrCreateCache("test0");
+ ignite.getOrCreateCache("test1");
+
+ final IgniteCompute comp = ignite.compute();
+
+ for (int i = 0; i < MAX_JOB_COUNT; ++i) {
+ IgniteRunnable job = (IgniteRunnable)factory.create();
+
+ IgniteFuture<Void> fut = comp.affinityRunAsync(Arrays.asList("test0", "test1"), 0, job);
+
+ fut.get();
+ }
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testDeployExecuteByName() throws Exception {
runTest(jobFactories, new ComputeTest() {
@Override public void test(Factory factory, Ignite ignite) throws Exception {
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/continuous/GridEventConsumeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/continuous/GridEventConsumeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/continuous/GridEventConsumeSelfTest.java
index b50dfb7..1ee4744 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/continuous/GridEventConsumeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/continuous/GridEventConsumeSelfTest.java
@@ -29,7 +29,6 @@ import java.util.concurrent.LinkedBlockingQueue;
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.IgniteEvents;
import org.apache.ignite.IgniteException;
import org.apache.ignite.cluster.ClusterNode;
@@ -251,6 +250,175 @@ public class GridEventConsumeSelfTest extends GridCommonAbstractTest {
/**
* @throws Exception If failed.
*/
+ public void testApiAsyncOld() throws Exception {
+ IgniteEvents evtAsync = grid(0).events().withAsync();
+
+ try {
+ evtAsync.stopRemoteListen(null);
+ evtAsync.future().get();
+ }
+ catch (NullPointerException ignored) {
+ // No-op.
+ }
+
+ evtAsync.stopRemoteListen(UUID.randomUUID());
+ evtAsync.future().get();
+
+ UUID consumeId = null;
+
+ try {
+ evtAsync.remoteListen(
+ new P2<UUID, DiscoveryEvent>() {
+ @Override public boolean apply(UUID uuid, DiscoveryEvent evt) {
+ return false;
+ }
+ },
+ new P1<DiscoveryEvent>() {
+ @Override public boolean apply(DiscoveryEvent e) {
+ return false;
+ }
+ },
+ EVTS_DISCOVERY
+ );
+
+ consumeId = (UUID)evtAsync.future().get();
+
+ assertNotNull(consumeId);
+ }
+ finally {
+ evtAsync.stopRemoteListen(consumeId);
+ evtAsync.future().get();
+ }
+
+ try {
+ evtAsync.remoteListen(
+ new P2<UUID, DiscoveryEvent>() {
+ @Override public boolean apply(UUID uuid, DiscoveryEvent evt) {
+ return false;
+ }
+ },
+ new P1<DiscoveryEvent>() {
+ @Override public boolean apply(DiscoveryEvent e) {
+ return false;
+ }
+ }
+ );
+
+ consumeId = (UUID)evtAsync.future().get();
+
+ assertNotNull(consumeId);
+ }
+ finally {
+ evtAsync.stopRemoteListen(consumeId);
+ evtAsync.future().get();
+ }
+
+ try {
+ evtAsync.remoteListen(
+ new P2<UUID, Event>() {
+ @Override public boolean apply(UUID uuid, Event evt) {
+ return false;
+ }
+ },
+ new P1<Event>() {
+ @Override public boolean apply(Event e) {
+ return false;
+ }
+ }
+ );
+
+ consumeId = (UUID)evtAsync.future().get();
+
+ assertNotNull(consumeId);
+ }
+ finally {
+ evtAsync.stopRemoteListen(consumeId);
+ evtAsync.future().get();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testApiAsync() throws Exception {
+ IgniteEvents evt = grid(0).events();
+
+ try {
+ evt.stopRemoteListenAsync(null).get();
+ }
+ catch (NullPointerException ignored) {
+ // No-op.
+ }
+
+ evt.stopRemoteListenAsync(UUID.randomUUID()).get();
+
+ UUID consumeId = null;
+
+ try {
+ consumeId = evt.remoteListenAsync(
+ new P2<UUID, DiscoveryEvent>() {
+ @Override public boolean apply(UUID uuid, DiscoveryEvent evt) {
+ return false;
+ }
+ },
+ new P1<DiscoveryEvent>() {
+ @Override public boolean apply(DiscoveryEvent e) {
+ return false;
+ }
+ },
+ EVTS_DISCOVERY
+ ).get();
+
+ assertNotNull(consumeId);
+ }
+ finally {
+ evt.stopRemoteListenAsync(consumeId).get();
+ }
+
+ try {
+ consumeId = evt.remoteListenAsync(
+ new P2<UUID, DiscoveryEvent>() {
+ @Override public boolean apply(UUID uuid, DiscoveryEvent evt) {
+ return false;
+ }
+ },
+ new P1<DiscoveryEvent>() {
+ @Override public boolean apply(DiscoveryEvent e) {
+ return false;
+ }
+ }
+ ).get();
+
+ assertNotNull(consumeId);
+ }
+ finally {
+ evt.stopRemoteListenAsync(consumeId).get();
+ }
+
+ try {
+ consumeId = evt.remoteListenAsync(
+ new P2<UUID, Event>() {
+ @Override public boolean apply(UUID uuid, Event evt) {
+ return false;
+ }
+ },
+ new P1<Event>() {
+ @Override public boolean apply(Event e) {
+ return false;
+ }
+ }
+ ).get();
+
+ assertNotNull(consumeId);
+ }
+ finally {
+ evt.stopRemoteListenAsync(consumeId).get();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testAllEvents() throws Exception {
final Collection<UUID> nodeIds = new HashSet<>();
final AtomicInteger cnt = new AtomicInteger();
@@ -990,15 +1158,13 @@ public class GridEventConsumeSelfTest extends GridCommonAbstractTest {
int idx = rnd.nextInt(GRID_CNT);
try {
- IgniteEvents evts = grid(idx).events().withAsync();
+ IgniteEvents evts = grid(idx).events();
- evts.remoteListen(new P2<UUID, Event>() {
+ UUID consumeId = evts.remoteListenAsync(new P2<UUID, Event>() {
@Override public boolean apply(UUID uuid, Event evt) {
return true;
}
- }, null, EVT_JOB_STARTED);
-
- UUID consumeId = evts.<UUID>future().get(3000);
+ }, null, EVT_JOB_STARTED).get(3000);
started.add(consumeId);
@@ -1029,11 +1195,9 @@ public class GridEventConsumeSelfTest extends GridCommonAbstractTest {
UUID consumeId = t.get2();
try {
- IgniteEvents evts = grid(idx).events().withAsync();
-
- evts.stopRemoteListen(consumeId);
+ IgniteEvents evts = grid(idx).events();
- evts.future().get(3000);
+ evts.stopRemoteListenAsync(consumeId).get(3000);
stopped.add(consumeId);
}
@@ -1063,11 +1227,7 @@ public class GridEventConsumeSelfTest extends GridCommonAbstractTest {
int idx = rnd.nextInt(GRID_CNT);
try {
- IgniteCompute comp = grid(idx).compute().withAsync();
-
- comp.run(F.noop());
-
- comp.future().get(3000);
+ grid(idx).compute().runAsync(F.noop()).get(3000);
}
catch (IgniteException ignored) {
// Ignore all job execution related errors.
@@ -1089,11 +1249,7 @@ public class GridEventConsumeSelfTest extends GridCommonAbstractTest {
int idx = t.get1();
UUID consumeId = t.get2();
- IgniteEvents evts = grid(idx).events().withAsync();
-
- evts.stopRemoteListen(consumeId);
-
- evts.future().get(3000);
+ grid(idx).events().stopRemoteListenAsync(consumeId).get(3000);
stopped.add(consumeId);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMock.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMock.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMock.java
index 04c67dc..1217005 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMock.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMock.java
@@ -266,6 +266,13 @@ public class IgfsMock implements IgfsEx {
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Void> formatAsync() throws IgniteException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
@Override public <T, R> R execute(IgfsTask<T, R> task, @Nullable IgfsRecordResolver rslvr,
Collection<IgfsPath> paths, @Nullable T arg) throws IgniteException {
throwUnsupported();
@@ -274,6 +281,14 @@ public class IgfsMock implements IgfsEx {
}
/** {@inheritDoc} */
+ @Override public <T, R> IgniteFuture<R> executeAsync(IgfsTask<T, R> task, @Nullable IgfsRecordResolver rslvr,
+ Collection<IgfsPath> paths, @Nullable T arg) throws IgniteException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
@Override public <T, R> R execute(IgfsTask<T, R> task, @Nullable IgfsRecordResolver rslvr,
Collection<IgfsPath> paths, boolean skipNonExistentFiles, long maxRangeLen, @Nullable T arg)
throws IgniteException {
@@ -283,6 +298,15 @@ public class IgfsMock implements IgfsEx {
}
/** {@inheritDoc} */
+ @Override public <T, R> IgniteFuture<R> executeAsync(IgfsTask<T, R> task, @Nullable IgfsRecordResolver rslvr,
+ Collection<IgfsPath> paths, boolean skipNonExistentFiles, long maxRangeLen,
+ @Nullable T arg) throws IgniteException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
@Override public <T, R> R execute(Class<? extends IgfsTask<T, R>> taskCls, @Nullable IgfsRecordResolver rslvr,
Collection<IgfsPath> paths, @Nullable T arg) throws IgniteException {
throwUnsupported();
@@ -291,6 +315,14 @@ public class IgfsMock implements IgfsEx {
}
/** {@inheritDoc} */
+ @Override public <T, R> IgniteFuture<R> executeAsync(Class<? extends IgfsTask<T, R>> taskCls,
+ @Nullable IgfsRecordResolver rslvr, Collection<IgfsPath> paths, @Nullable T arg) throws IgniteException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
@Override public <T, R> R execute(Class<? extends IgfsTask<T, R>> taskCls, @Nullable IgfsRecordResolver rslvr,
Collection<IgfsPath> paths, boolean skipNonExistentFiles, long maxRangeLen, @Nullable T arg)
throws IgniteException {
@@ -300,6 +332,15 @@ public class IgfsMock implements IgfsEx {
}
/** {@inheritDoc} */
+ @Override public <T, R> IgniteFuture<R> executeAsync(Class<? extends IgfsTask<T, R>> taskCls,
+ @Nullable IgfsRecordResolver rslvr, Collection<IgfsPath> paths, boolean skipNonExistentFiles, long maxRangeLen,
+ @Nullable T arg) throws IgniteException {
+ throwUnsupported();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
@Override public boolean exists(IgfsPath path) {
throwUnsupported();
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsTaskSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsTaskSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsTaskSelfTest.java
index 0d468b4..36c99dc 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsTaskSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsTaskSelfTest.java
@@ -168,6 +168,25 @@ public class IgfsTaskSelfTest extends IgfsCommonAbstractTest {
}
/**
+ * Test task.
+ *
+ * @throws Exception If failed.
+ */
+ @SuppressWarnings("ConstantConditions")
+ public void testTaskAsync() throws Exception {
+ String arg = DICTIONARY[new Random(System.currentTimeMillis()).nextInt(DICTIONARY.length)];
+
+ generateFile(TOTAL_WORDS);
+ Long genLen = igfs.info(FILE).length();
+
+ IgniteBiTuple<Long, Integer> taskRes = igfs.executeAsync(new Task(),
+ new IgfsStringDelimiterRecordResolver(" "), Collections.singleton(FILE), arg).get();
+
+ assert F.eq(genLen, taskRes.getKey());
+ assert F.eq(TOTAL_WORDS, taskRes.getValue());
+ }
+
+ /**
* Generate file with random data and provided argument.
*
* @param wordCnt Word count.
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/messaging/IgniteMessagingConfigVariationFullApiTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/messaging/IgniteMessagingConfigVariationFullApiTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/messaging/IgniteMessagingConfigVariationFullApiTest.java
index 3e90a52..3e547d0 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/messaging/IgniteMessagingConfigVariationFullApiTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/messaging/IgniteMessagingConfigVariationFullApiTest.java
@@ -186,18 +186,7 @@ public class IgniteMessagingConfigVariationFullApiTest extends IgniteConfigVaria
public void testOrderedMessage() throws Exception {
runInAllDataModes(new TestRunnable() {
@Override public void run() throws Exception {
- orderedMessage(false);
- }
- });
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testOrderedMessageAsync() throws Exception {
- runInAllDataModes(new TestRunnable() {
- @Override public void run() throws Exception {
- orderedMessage(true);
+ orderedMessage();
}
});
}
@@ -211,26 +200,11 @@ public class IgniteMessagingConfigVariationFullApiTest extends IgniteConfigVaria
runInAllDataModes(new TestRunnable() {
@Override public void run() throws Exception {
- clientServerOrderedMessage(false);
- }
- });
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testClientServerOrderedMessageAsync() throws Exception {
- if (!testsCfg.withClients())
- return;
-
- runInAllDataModes(new TestRunnable() {
- @Override public void run() throws Exception {
- clientServerOrderedMessage(true);
+ clientServerOrderedMessage();
}
});
}
-
/**
* @throws Exception If failed.
*/
@@ -240,21 +214,7 @@ public class IgniteMessagingConfigVariationFullApiTest extends IgniteConfigVaria
runInAllDataModes(new TestRunnable() {
@Override public void run() throws Exception {
- clientClientOrderedMessage(false);
- }
- });
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testClientClientOrderedMessageAsync() throws Exception {
- if (!testsCfg.withClients())
- return;
-
- runInAllDataModes(new TestRunnable() {
- @Override public void run() throws Exception {
- clientClientOrderedMessage(true);
+ clientClientOrderedMessage();
}
});
}
@@ -268,21 +228,7 @@ public class IgniteMessagingConfigVariationFullApiTest extends IgniteConfigVaria
runInAllDataModes(new TestRunnable() {
@Override public void run() throws Exception {
- serverClientOrderedMessage(false);
- }
- });
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testServerClientOrderedMessageAsync() throws Exception {
- if (!testsCfg.withClients())
- return;
-
- runInAllDataModes(new TestRunnable() {
- @Override public void run() throws Exception {
- serverClientOrderedMessage(true);
+ serverClientOrderedMessage();
}
});
}
@@ -451,68 +397,63 @@ public class IgniteMessagingConfigVariationFullApiTest extends IgniteConfigVaria
}
/**
- * @param async Async message send flag.
* @throws Exception If fail.
*/
- private void orderedMessage(boolean async) throws Exception {
+ private void orderedMessage() throws Exception {
Ignite ignite = grid(SERVER_NODE_IDX);
ClusterGroup grp = gridCount() > 1 ? ignite.cluster().forRemotes() : ignite.cluster().forLocal();
assert grp.nodes().size() > 0;
- registerListenerAndSendOrderedMessages(ignite, grp, async);
+ registerListenerAndSendOrderedMessages(ignite, grp);
}
/**
- * @param async Async message send flag.
* @throws Exception If fail.
*/
- private void clientServerOrderedMessage(boolean async) throws Exception {
+ private void clientServerOrderedMessage() throws Exception {
Ignite ignite = grid(CLIENT_NODE_IDX);
ClusterGroup grp = ignite.cluster().forServers();
assert grp.nodes().size() > 0;
- registerListenerAndSendOrderedMessages(ignite, grp, async);
+ registerListenerAndSendOrderedMessages(ignite, grp);
}
/**
- * @param async Async message send flag.
* @throws Exception If fail.
*/
- private void clientClientOrderedMessage(boolean async) throws Exception {
+ private void clientClientOrderedMessage() throws Exception {
Ignite ignite = grid(CLIENT_NODE_IDX);
ClusterGroup grp = ignite.cluster().forClients();
assert grp.nodes().size() > 0;
- registerListenerAndSendOrderedMessages(ignite, grp, async);
+ registerListenerAndSendOrderedMessages(ignite, grp);
}
/**
- * @param async Async message send flag.
* @throws Exception If fail.
*/
- private void serverClientOrderedMessage(boolean async) throws Exception {
+ private void serverClientOrderedMessage() throws Exception {
Ignite ignite = grid(SERVER_NODE_IDX);
ClusterGroup grp = ignite.cluster().forClients();
assert grp.nodes().size() > 0;
- registerListenerAndSendOrderedMessages(ignite, grp, async);
+ registerListenerAndSendOrderedMessages(ignite, grp);
}
/**
* @param ignite Ignite.
* @param grp Cluster group.
- * @param async Async message send flag.
* @throws Exception If fail.
*/
- private void registerListenerAndSendOrderedMessages(Ignite ignite, ClusterGroup grp, boolean async) throws Exception {
+ private void registerListenerAndSendOrderedMessages(Ignite ignite, ClusterGroup grp) throws Exception {
int messages = MSGS;
LATCH = new CountDownLatch(grp.nodes().size() * messages);
@@ -520,12 +461,8 @@ public class IgniteMessagingConfigVariationFullApiTest extends IgniteConfigVaria
UUID opId = ignite.message(grp).remoteListen(MESSAGE_TOPIC, new OrderedMessageListener());
try {
- for (int i=0; i < messages; i++){
- if (async)
- ignite.message(grp).withAsync().sendOrdered(MESSAGE_TOPIC, value(i), 2000);
- else
- ignite.message(grp).sendOrdered(MESSAGE_TOPIC, value(i), 2000);
- }
+ for (int i=0; i < messages; i++)
+ ignite.message(grp).sendOrdered(MESSAGE_TOPIC, value(i), 2000);
assertTrue(LATCH.await(10, TimeUnit.SECONDS));
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorAbstractSelfTest.java
index c6505ba..f9d1632 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorAbstractSelfTest.java
@@ -147,8 +147,8 @@ public abstract class GridServiceProcessorAbstractSelfTest extends GridCommonAbs
/**
* @throws Exception If failed.
*/
- public void testSameConfiguration() throws Exception {
- String name = "dupService";
+ public void testSameConfigurationOld() throws Exception {
+ String name = "dupServiceOld";
IgniteServices svcs1 = randomGrid().services().withAsync();
IgniteServices svcs2 = randomGrid().services().withAsync();
@@ -176,8 +176,33 @@ public abstract class GridServiceProcessorAbstractSelfTest extends GridCommonAbs
/**
* @throws Exception If failed.
*/
- public void testDifferentConfiguration() throws Exception {
- String name = "dupService";
+ public void testSameConfiguration() throws Exception {
+ String name = "dupServiceOld";
+
+ IgniteServices svcs1 = randomGrid().services();
+ IgniteServices svcs2 = randomGrid().services();
+
+ IgniteFuture<?> fut1 = svcs1.deployClusterSingletonAsync(name, new DummyService());
+
+ IgniteFuture<?> fut2 = svcs2.deployClusterSingletonAsync(name, new DummyService());
+
+ info("Deployed service: " + name);
+
+ fut1.get();
+
+ info("Finished waiting for service future1: " + name);
+
+ // This must succeed without exception because configuration is the same.
+ fut2.get();
+
+ info("Finished waiting for service future2: " + name);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDifferentConfigurationOld() throws Exception {
+ String name = "dupServiceOld";
IgniteServices svcs1 = randomGrid().services().withAsync();
IgniteServices svcs2 = randomGrid().services().withAsync();
@@ -209,6 +234,35 @@ public abstract class GridServiceProcessorAbstractSelfTest extends GridCommonAbs
/**
* @throws Exception If failed.
*/
+ public void testDifferentConfiguration() throws Exception {
+ String name = "dupService";
+
+ IgniteServices svcs1 = randomGrid().services();
+ IgniteServices svcs2 = randomGrid().services();
+
+ IgniteFuture<?> fut1 = svcs1.deployClusterSingletonAsync(name, new DummyService());
+
+ IgniteFuture<?> fut2 = svcs2.deployNodeSingletonAsync(name, new DummyService());
+
+ info("Deployed service: " + name);
+
+ fut1.get();
+
+ info("Finished waiting for service future: " + name);
+
+ try {
+ fut2.get();
+
+ fail("Failed to receive mismatching configuration exception.");
+ }
+ catch (IgniteException e) {
+ info("Received mismatching configuration exception: " + e.getMessage());
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testGetServiceByName() throws Exception {
String name = "serviceByName";
@@ -255,10 +309,10 @@ public abstract class GridServiceProcessorAbstractSelfTest extends GridCommonAbs
/**
* @throws Exception If failed.
*/
- public void testDeployOnEachNode() throws Exception {
+ public void testDeployOnEachNodeOld() throws Exception {
Ignite g = randomGrid();
- String name = "serviceOnEachNode";
+ String name = "serviceOnEachNodeOld";
CountDownLatch latch = new CountDownLatch(nodeCount());
@@ -287,10 +341,38 @@ public abstract class GridServiceProcessorAbstractSelfTest extends GridCommonAbs
/**
* @throws Exception If failed.
*/
- public void testDeploySingleton() throws Exception {
+ public void testDeployOnEachNode() throws Exception {
Ignite g = randomGrid();
- String name = "serviceSingleton";
+ String name = "serviceOnEachNode";
+
+ CountDownLatch latch = new CountDownLatch(nodeCount());
+
+ DummyService.exeLatch(name, latch);
+
+ IgniteFuture<?> fut = g.services().deployNodeSingletonAsync(name, new DummyService());
+
+ info("Deployed service: " + name);
+
+ fut.get();
+
+ info("Finished waiting for service future: " + name);
+
+ latch.await();
+
+ assertEquals(name, nodeCount(), DummyService.started(name));
+ assertEquals(name, 0, DummyService.cancelled(name));
+
+ checkCount(name, g.services().serviceDescriptors(), nodeCount());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDeploySingletonOld() throws Exception {
+ Ignite g = randomGrid();
+
+ String name = "serviceSingletonOld";
CountDownLatch latch = new CountDownLatch(1);
@@ -319,7 +401,35 @@ public abstract class GridServiceProcessorAbstractSelfTest extends GridCommonAbs
/**
* @throws Exception If failed.
*/
- public void testAffinityDeploy() throws Exception {
+ public void testDeploySingleton() throws Exception {
+ Ignite g = randomGrid();
+
+ String name = "serviceSingleton";
+
+ CountDownLatch latch = new CountDownLatch(1);
+
+ DummyService.exeLatch(name, latch);
+
+ IgniteFuture<?> fut = g.services().deployClusterSingletonAsync(name, new DummyService());
+
+ info("Deployed service: " + name);
+
+ fut.get();
+
+ info("Finished waiting for service future: " + name);
+
+ latch.await();
+
+ assertEquals(name, 1, DummyService.started(name));
+ assertEquals(name, 0, DummyService.cancelled(name));
+
+ checkCount(name, g.services().serviceDescriptors(), 1);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testAffinityDeployOld() throws Exception {
Ignite g = randomGrid();
final Integer affKey = 1;
@@ -327,7 +437,7 @@ public abstract class GridServiceProcessorAbstractSelfTest extends GridCommonAbs
// Store a cache key.
g.cache(CACHE_NAME).put(affKey, affKey.toString());
- String name = "serviceAffinity";
+ String name = "serviceAffinityOld";
IgniteServices svcs = g.services().withAsync();
@@ -348,10 +458,35 @@ public abstract class GridServiceProcessorAbstractSelfTest extends GridCommonAbs
/**
* @throws Exception If failed.
*/
- public void testDeployMultiple1() throws Exception {
+ public void testAffinityDeploy() throws Exception {
Ignite g = randomGrid();
- String name = "serviceMultiple1";
+ final Integer affKey = 1;
+
+ // Store a cache key.
+ g.cache(CACHE_NAME).put(affKey, affKey.toString());
+
+ String name = "serviceAffinity";
+
+ IgniteFuture<?> fut = g.services().deployKeyAffinitySingletonAsync(name, new AffinityService(affKey),
+ CACHE_NAME, affKey);
+
+ info("Deployed service: " + name);
+
+ fut.get();
+
+ info("Finished waiting for service future: " + name);
+
+ checkCount(name, g.services().serviceDescriptors(), 1);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDeployMultiple1Old() throws Exception {
+ Ignite g = randomGrid();
+
+ String name = "serviceMultiple1Old";
CountDownLatch latch = new CountDownLatch(nodeCount() * 2);
@@ -380,10 +515,38 @@ public abstract class GridServiceProcessorAbstractSelfTest extends GridCommonAbs
/**
* @throws Exception If failed.
*/
- public void testDeployMultiple2() throws Exception {
+ public void testDeployMultiple1() throws Exception {
Ignite g = randomGrid();
- String name = "serviceMultiple2";
+ String name = "serviceMultiple1";
+
+ CountDownLatch latch = new CountDownLatch(nodeCount() * 2);
+
+ DummyService.exeLatch(name, latch);
+
+ IgniteFuture<?> fut = g.services().deployMultipleAsync(name, new DummyService(), nodeCount() * 2, 3);
+
+ info("Deployed service: " + name);
+
+ fut.get();
+
+ info("Finished waiting for service future: " + name);
+
+ latch.await();
+
+ assertEquals(name, nodeCount() * 2, DummyService.started(name));
+ assertEquals(name, 0, DummyService.cancelled(name));
+
+ checkCount(name, g.services().serviceDescriptors(), nodeCount() * 2);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDeployMultiple2Old() throws Exception {
+ Ignite g = randomGrid();
+
+ String name = "serviceMultiple2Old";
int cnt = nodeCount() * 2 + 1;
@@ -414,6 +577,36 @@ public abstract class GridServiceProcessorAbstractSelfTest extends GridCommonAbs
/**
* @throws Exception If failed.
*/
+ public void testDeployMultiple2() throws Exception {
+ Ignite g = randomGrid();
+
+ String name = "serviceMultiple2";
+
+ int cnt = nodeCount() * 2 + 1;
+
+ CountDownLatch latch = new CountDownLatch(cnt);
+
+ DummyService.exeLatch(name, latch);
+
+ IgniteFuture<?> fut = g.services().deployMultipleAsync(name, new DummyService(), cnt, 3);
+
+ info("Deployed service: " + name);
+
+ fut.get();
+
+ info("Finished waiting for service future: " + name);
+
+ latch.await();
+
+ assertEquals(name, cnt, DummyService.started(name));
+ assertEquals(name, 0, DummyService.cancelled(name));
+
+ checkCount(name, g.services().serviceDescriptors(), cnt);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testCancelSingleton() throws Exception {
Ignite g = randomGrid();
@@ -449,6 +642,41 @@ public abstract class GridServiceProcessorAbstractSelfTest extends GridCommonAbs
/**
* @throws Exception If failed.
*/
+ public void testCancelSingletonAsync() throws Exception {
+ Ignite g = randomGrid();
+
+ String name = "serviceCancelAsync";
+
+ CountDownLatch latch = new CountDownLatch(1);
+
+ DummyService.exeLatch(name, latch);
+
+ g.services().deployClusterSingleton(name, new DummyService());
+
+ info("Deployed service: " + name);
+
+ latch.await();
+
+ assertEquals(name, 1, DummyService.started(name));
+ assertEquals(name, 0, DummyService.cancelled(name));
+
+ latch = new CountDownLatch(1);
+
+ DummyService.cancelLatch(name, latch);
+
+ g.services().cancelAsync(name).get();
+
+ info("Cancelled service: " + name);
+
+ latch.await();
+
+ assertEquals(name, 1, DummyService.started(name));
+ assertEquals(name, 1, DummyService.cancelled(name));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testCancelEachNode() throws Exception {
Ignite g = randomGrid();
@@ -482,6 +710,41 @@ public abstract class GridServiceProcessorAbstractSelfTest extends GridCommonAbs
}
/**
+ * @throws Exception If failed.
+ */
+ public void testCancelAsyncEachNode() throws Exception {
+ Ignite g = randomGrid();
+
+ String name = "serviceCancelEachNodeAsync";
+
+ CountDownLatch latch = new CountDownLatch(nodeCount());
+
+ DummyService.exeLatch(name, latch);
+
+ g.services().deployNodeSingleton(name, new DummyService());
+
+ info("Deployed service: " + name);
+
+ latch.await();
+
+ assertEquals(name, nodeCount(), DummyService.started(name));
+ assertEquals(name, 0, DummyService.cancelled(name));
+
+ latch = new CountDownLatch(nodeCount());
+
+ DummyService.cancelLatch(name, latch);
+
+ g.services().cancelAsync(name).get();
+
+ info("Cancelled service: " + name);
+
+ latch.await();
+
+ assertEquals(name, nodeCount(), DummyService.started(name));
+ assertEquals(name, nodeCount(), DummyService.cancelled(name));
+ }
+
+ /**
* @param svcName Service name.
* @param descs Descriptors.
* @param cnt Expected count.
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorMultiNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorMultiNodeSelfTest.java
index 39336ef..9b787a2 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorMultiNodeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorMultiNodeSelfTest.java
@@ -44,11 +44,9 @@ public class GridServiceProcessorMultiNodeSelfTest extends GridServiceProcessorA
DummyService.exeLatch(name, latch);
- IgniteServices svcs = g.services().withAsync();
+ IgniteServices svcs = g.services();
- svcs.deployClusterSingleton(name, new DummyService());
-
- IgniteFuture<?> fut = svcs.future();
+ IgniteFuture<?> fut = svcs.deployClusterSingletonAsync(name, new DummyService());
info("Deployed service: " + name);
@@ -91,13 +89,11 @@ public class GridServiceProcessorMultiNodeSelfTest extends GridServiceProcessorA
String name = "serviceAffinityUpdateTopology";
- IgniteServices svcs = g.services().withAsync();
+ IgniteServices svcs = g.services();
- svcs.deployKeyAffinitySingleton(name, new AffinityService(affKey),
+ IgniteFuture<?> fut = svcs.deployKeyAffinitySingletonAsync(name, new AffinityService(affKey),
CACHE_NAME, affKey);
- IgniteFuture<?> fut = svcs.future();
-
info("Deployed service: " + name);
fut.get();
@@ -130,11 +126,9 @@ public class GridServiceProcessorMultiNodeSelfTest extends GridServiceProcessorA
DummyService.exeLatch(name, latch);
- IgniteServices svcs = g.services().withAsync();
-
- svcs.deployNodeSingleton(name, new DummyService());
+ IgniteServices svcs = g.services();
- IgniteFuture<?> fut = svcs.future();
+ IgniteFuture<?> fut = svcs.deployNodeSingletonAsync(name, new DummyService());
info("Deployed service: " + name);
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorStopSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorStopSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorStopSelfTest.java
index 03b00f4..8eefa20 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorStopSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorStopSelfTest.java
@@ -32,6 +32,7 @@ import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.services.Service;
import org.apache.ignite.services.ServiceContext;
import org.apache.ignite.testframework.GridTestUtils;
@@ -62,14 +63,12 @@ public class GridServiceProcessorStopSelfTest extends GridCommonAbstractTest {
@Override public Void call() throws Exception {
IgniteServices svcs = ignite.services();
- IgniteServices services = svcs.withAsync();
-
- services.deployClusterSingleton("myClusterSingletonService", new TestServiceImpl());
+ IgniteFuture f = svcs.deployClusterSingletonAsync("myClusterSingletonService", new TestServiceImpl());
depLatch.countDown();
try {
- services.future().get();
+ f.get();
}
catch (IgniteException ignored) {
finishLatch.countDown();
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/loadtest/GridSingleExecutionTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/loadtest/GridSingleExecutionTest.java b/modules/core/src/test/java/org/apache/ignite/loadtest/GridSingleExecutionTest.java
index 272c7ad..559cfc9 100644
--- a/modules/core/src/test/java/org/apache/ignite/loadtest/GridSingleExecutionTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/loadtest/GridSingleExecutionTest.java
@@ -29,7 +29,6 @@ import java.util.Map;
import java.util.UUID;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteCompute;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.compute.ComputeJob;
@@ -89,9 +88,8 @@ public final class GridSingleExecutionTest {
System.exit(1);
}
else if (args.length >= 2) {
- for (IgniteConfiguration cfg: getConfigurations(args[1], args[0])) {
+ for (IgniteConfiguration cfg: getConfigurations(args[1], args[0]))
G.start(cfg);
- }
}
boolean useSes = false;
@@ -104,12 +102,8 @@ public final class GridSingleExecutionTest {
try {
Ignite ignite = G.ignite();
- IgniteCompute comp = ignite.compute().withAsync();
-
// Execute Hello World task.
- comp.execute(!useSes ? TestTask.class : TestSessionTask.class, null);
-
- ComputeTaskFuture<Object> fut = comp.future();
+ ComputeTaskFuture<Object> fut = ignite.compute().executeAsync(!useSes ? TestTask.class : TestSessionTask.class, null);
if (useSes) {
fut.getTaskSession().setAttribute("attr1", 1);
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/loadtests/colocation/GridTestMain.java
----------------------------------------------------------------------
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 6a43fee..bf34545 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
@@ -26,7 +26,6 @@ import java.util.concurrent.Executors;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteCompute;
import org.apache.ignite.IgniteDataStreamer;
import org.apache.ignite.cache.CachePeekMode;
import org.apache.ignite.configuration.IgniteConfiguration;
@@ -88,13 +87,11 @@ public class GridTestMain {
long start = System.currentTimeMillis();
- IgniteCompute comp = g.compute().withAsync();
-
// Collocate computations and data.
for (long i = 0; i < GridTestConstants.ENTRY_COUNT; i++) {
final long key = i;
- comp.affinityRun("partitioned", GridTestKey.affinityKey(key), new IgniteRunnable() {
+ final IgniteFuture<?> f = g.compute().affinityRunAsync("partitioned", GridTestKey.affinityKey(key), new IgniteRunnable() {
// This code will execute on remote nodes by collocating keys with cached data.
@Override public void run() {
Long val = cache.localPeek(new GridTestKey(key), CachePeekMode.ONHEAP);
@@ -104,8 +101,6 @@ public class GridTestMain {
}
});
- final IgniteFuture<?> f = comp.future();
-
q.put(f);
f.listen(new CI1<IgniteFuture<?>>() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/loadtests/direct/multisplit/GridMultiSplitsLoadTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/direct/multisplit/GridMultiSplitsLoadTest.java b/modules/core/src/test/java/org/apache/ignite/loadtests/direct/multisplit/GridMultiSplitsLoadTest.java
index ab6b272..c764f67 100644
--- a/modules/core/src/test/java/org/apache/ignite/loadtests/direct/multisplit/GridMultiSplitsLoadTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/loadtests/direct/multisplit/GridMultiSplitsLoadTest.java
@@ -18,7 +18,6 @@
package org.apache.ignite.loadtests.direct.multisplit;
import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCompute;
import org.apache.ignite.IgniteException;
import org.apache.ignite.compute.ComputeTaskFuture;
import org.apache.ignite.configuration.IgniteConfiguration;
@@ -106,8 +105,6 @@ public class GridMultiSplitsLoadTest extends GridCommonAbstractTest {
GridTestUtils.runMultiThreaded(new Runnable() {
/** {@inheritDoc} */
@Override public void run() {
- IgniteCompute comp = ignite.compute().withAsync();
-
while (end - System.currentTimeMillis() > 0) {
int levels = 3;
@@ -116,9 +113,7 @@ public class GridMultiSplitsLoadTest extends GridCommonAbstractTest {
long start = System.currentTimeMillis();
try {
- comp.execute(GridLoadTestTask.class, levels);
-
- ComputeTaskFuture<Integer> fut = comp.future();
+ ComputeTaskFuture<Integer> fut = ignite.compute().executeAsync(GridLoadTestTask.class, levels);
int res = fut.get();
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/loadtests/direct/newnodes/GridSingleSplitsNewNodesAbstractLoadTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/direct/newnodes/GridSingleSplitsNewNodesAbstractLoadTest.java b/modules/core/src/test/java/org/apache/ignite/loadtests/direct/newnodes/GridSingleSplitsNewNodesAbstractLoadTest.java
index 5d909c9..6fb7cdf 100644
--- a/modules/core/src/test/java/org/apache/ignite/loadtests/direct/newnodes/GridSingleSplitsNewNodesAbstractLoadTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/loadtests/direct/newnodes/GridSingleSplitsNewNodesAbstractLoadTest.java
@@ -19,7 +19,6 @@ package org.apache.ignite.loadtests.direct.newnodes;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCompute;
import org.apache.ignite.compute.ComputeTaskFuture;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.util.typedef.G;
@@ -141,8 +140,6 @@ public abstract class GridSingleSplitsNewNodesAbstractLoadTest extends GridCommo
GridTestUtils.runMultiThreaded(new Runnable() {
/** {@inheritDoc} */
@Override public void run() {
- IgniteCompute comp = ignite.compute().withAsync();
-
while (end - System.currentTimeMillis() > 0
&& !Thread.currentThread().isInterrupted()) {
long start = System.currentTimeMillis();
@@ -150,9 +147,8 @@ public abstract class GridSingleSplitsNewNodesAbstractLoadTest extends GridCommo
try {
int levels = 3;
- comp.execute(new GridSingleSplitNewNodesTestTask(), levels);
-
- ComputeTaskFuture<Integer> fut = comp.future();
+ ComputeTaskFuture<Integer> fut = ignite.compute().executeAsync(
+ new GridSingleSplitNewNodesTestTask(), levels);
int res = fut.get();
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/loadtests/dsi/GridDsiClient.java
----------------------------------------------------------------------
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 a065580..9662882 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
@@ -114,7 +114,7 @@ public class GridDsiClient implements Callable {
/** {@inheritDoc} */
@SuppressWarnings({"unchecked", "InfiniteLoopStatement"})
@Nullable @Override public Object call() throws Exception {
- IgniteCompute comp = g.compute(g.cluster().forPredicate(serverNode())).withAsync();
+ IgniteCompute comp = g.compute(g.cluster().forPredicate(serverNode()));
while (!finish.get()) {
try {
@@ -122,9 +122,8 @@ public class GridDsiClient implements Callable {
long submitTime1 = t0;
- comp.execute(GridDsiRequestTask.class, new GridDsiMessage(terminalId, nodeId));
-
- ComputeTaskFuture<T3<Long, Integer, Integer>> f1 = comp.future();
+ ComputeTaskFuture<T3<Long, Integer, Integer>> f1 = comp.executeAsync(
+ GridDsiRequestTask.class, new GridDsiMessage(terminalId, nodeId));
submitTime.setIfGreater(System.currentTimeMillis() - submitTime1);
@@ -132,9 +131,8 @@ public class GridDsiClient implements Callable {
submitTime1 = System.currentTimeMillis();
- comp.execute(GridDsiResponseTask.class, new GridDsiMessage(terminalId, nodeId));
-
- ComputeTaskFuture<T3<Long, Integer, Integer>> f2 = comp.future();
+ ComputeTaskFuture<T3<Long, Integer, Integer>> f2 = comp.executeAsync(
+ GridDsiResponseTask.class, new GridDsiMessage(terminalId, nodeId));
submitTime.setIfGreater(System.currentTimeMillis() - submitTime1);
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/loadtests/job/GridJobExecutionLoadTestClientSemaphore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/job/GridJobExecutionLoadTestClientSemaphore.java b/modules/core/src/test/java/org/apache/ignite/loadtests/job/GridJobExecutionLoadTestClientSemaphore.java
index 8e55ff9..53c6f50 100644
--- a/modules/core/src/test/java/org/apache/ignite/loadtests/job/GridJobExecutionLoadTestClientSemaphore.java
+++ b/modules/core/src/test/java/org/apache/ignite/loadtests/job/GridJobExecutionLoadTestClientSemaphore.java
@@ -29,7 +29,6 @@ import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCompute;
import org.apache.ignite.IgniteException;
import org.apache.ignite.cluster.ClusterGroup;
-import org.apache.ignite.compute.ComputeTaskFuture;
import org.apache.ignite.internal.util.lang.GridAbsClosure;
import org.apache.ignite.internal.util.typedef.CI1;
import org.apache.ignite.internal.util.typedef.G;
@@ -75,16 +74,10 @@ public class GridJobExecutionLoadTestClientSemaphore implements Callable<Object>
ClusterGroup rmts = g.cluster().forRemotes();
- IgniteCompute comp = g.compute(rmts).withAsync();
-
while (!finish) {
tasksSem.acquire();
- comp.execute(GridJobExecutionLoadTestTask.class, null);
-
- ComputeTaskFuture<Object> f = comp.future();
-
- f.listen(lsnr);
+ g.compute(rmts).executeAsync(GridJobExecutionLoadTestTask.class, null).listen(lsnr);
txCnt.increment();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/loadtests/job/GridJobExecutionSingleNodeSemaphoreLoadTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/job/GridJobExecutionSingleNodeSemaphoreLoadTest.java b/modules/core/src/test/java/org/apache/ignite/loadtests/job/GridJobExecutionSingleNodeSemaphoreLoadTest.java
index 2e2ab20..2f94b48 100644
--- a/modules/core/src/test/java/org/apache/ignite/loadtests/job/GridJobExecutionSingleNodeSemaphoreLoadTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/loadtests/job/GridJobExecutionSingleNodeSemaphoreLoadTest.java
@@ -24,13 +24,11 @@ import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.Semaphore;
import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCompute;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.compute.ComputeJob;
import org.apache.ignite.compute.ComputeJobResult;
import org.apache.ignite.compute.ComputeJobResultPolicy;
import org.apache.ignite.compute.ComputeTask;
-import org.apache.ignite.compute.ComputeTaskFuture;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.IgniteInterruptedCheckedException;
import org.apache.ignite.internal.util.typedef.CI1;
@@ -188,13 +186,7 @@ public class GridJobExecutionSingleNodeSemaphoreLoadTest {
@Nullable @Override public Object call() throws Exception {
sem.acquire();
- IgniteCompute comp = g.compute().withAsync();
-
- comp.execute(GridJobExecutionLoadTestTask.class, null);
-
- ComputeTaskFuture<Object> f = comp.future();
-
- f.listen(lsnr);
+ g.compute().executeAsync(GridJobExecutionLoadTestTask.class, null).listen(lsnr);
iterCntr.increment();
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/loadtests/job/GridJobLoadTestSubmitter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/job/GridJobLoadTestSubmitter.java b/modules/core/src/test/java/org/apache/ignite/loadtests/job/GridJobLoadTestSubmitter.java
index 8dcd828..16a6af8 100644
--- a/modules/core/src/test/java/org/apache/ignite/loadtests/job/GridJobLoadTestSubmitter.java
+++ b/modules/core/src/test/java/org/apache/ignite/loadtests/job/GridJobLoadTestSubmitter.java
@@ -22,7 +22,6 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCompute;
import org.apache.ignite.IgniteException;
import org.apache.ignite.compute.ComputeTaskFuture;
import org.apache.ignite.lang.IgniteFutureCancelledException;
@@ -68,8 +67,6 @@ public class GridJobLoadTestSubmitter implements Runnable {
/** {@inheritDoc} */
@SuppressWarnings("BusyWait")
@Override public void run() {
- IgniteCompute comp = ignite.compute().withAsync();
-
while (true) {
checkCompletion();
@@ -83,9 +80,7 @@ public class GridJobLoadTestSubmitter implements Runnable {
}
try {
- comp.withTimeout(TIMEOUT).execute(GridJobLoadTestTask.class, params);
-
- futures.add(comp.<Integer>future());
+ futures.add(ignite.compute().withTimeout(TIMEOUT).executeAsync(GridJobLoadTestTask.class, params));
}
catch (IgniteException e) {
// Should not be thrown since uses asynchronous execution.
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/loadtests/mergesort/GridMergeSortLoadTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/mergesort/GridMergeSortLoadTask.java b/modules/core/src/test/java/org/apache/ignite/loadtests/mergesort/GridMergeSortLoadTask.java
index 8c8f039..cb609ef 100644
--- a/modules/core/src/test/java/org/apache/ignite/loadtests/mergesort/GridMergeSortLoadTask.java
+++ b/modules/core/src/test/java/org/apache/ignite/loadtests/mergesort/GridMergeSortLoadTask.java
@@ -22,7 +22,6 @@ import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCompute;
import org.apache.ignite.compute.ComputeJob;
import org.apache.ignite.compute.ComputeJobAdapter;
import org.apache.ignite.compute.ComputeJobContext;
@@ -77,12 +76,8 @@ public class GridMergeSortLoadTask extends ComputeTaskSplitAdapter<int[], int[]>
// Future is null before holdcc() is called and
// not null after callcc() is called.
if (fut == null) {
- IgniteCompute comp = ignite.compute().withAsync();
-
// Launch the recursive child task asynchronously.
- comp.execute(new GridMergeSortLoadTask(), arr);
-
- fut = comp.future();
+ fut = ignite.compute().executeAsync(new GridMergeSortLoadTask(), arr);
// Add a listener to the future, that will resume the
// parent task once the child one is completed.
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/messaging/GridMessagingSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/messaging/GridMessagingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/messaging/GridMessagingSelfTest.java
index 3f66c5d..b7ddc3e 100644
--- a/modules/core/src/test/java/org/apache/ignite/messaging/GridMessagingSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/messaging/GridMessagingSelfTest.java
@@ -1031,7 +1031,7 @@ public class GridMessagingSelfTest extends GridCommonAbstractTest implements Ser
/**
* @throws Exception If failed.
*/
- public void testAsync() throws Exception {
+ public void testAsyncOld() throws Exception {
final AtomicInteger msgCnt = new AtomicInteger();
TestTcpDiscoverySpi discoSpi = (TestTcpDiscoverySpi)ignite2.configuration().getDiscoverySpi();
@@ -1137,6 +1137,76 @@ public class GridMessagingSelfTest extends GridCommonAbstractTest implements Ser
}
/**
+ * @throws Exception If failed.
+ */
+ public void testAsync() throws Exception {
+ final AtomicInteger msgCnt = new AtomicInteger();
+
+ TestTcpDiscoverySpi discoSpi = (TestTcpDiscoverySpi)ignite2.configuration().getDiscoverySpi();
+
+ discoSpi.blockCustomEvent();
+
+ final String topic = "topic";
+
+ IgniteFuture<UUID> starFut = ignite2.message().remoteListenAsync(topic, new P2<UUID, Object>() {
+ @Override public boolean apply(UUID nodeId, Object msg) {
+ System.out.println(Thread.currentThread().getName() +
+ " Listener received new message [msg=" + msg + ", senderNodeId=" + nodeId + ']');
+
+ msgCnt.incrementAndGet();
+
+ return true;
+ }
+ });
+
+ Assert.assertNotNull(starFut);
+
+ U.sleep(500);
+
+ Assert.assertFalse(starFut.isDone());
+
+ discoSpi.stopBlock();
+
+ UUID id = starFut.get();
+
+ Assert.assertNotNull(id);
+
+ Assert.assertTrue(starFut.isDone());
+
+ discoSpi.blockCustomEvent();
+
+ message(ignite1.cluster().forRemotes()).send(topic, "msg1");
+
+ GridTestUtils.waitForCondition(new PA() {
+ @Override public boolean apply() {
+ return msgCnt.get() > 0;
+ }
+ }, 5000);
+
+ assertEquals(1, msgCnt.get());
+
+ IgniteFuture<?> stopFut = ignite2.message().stopRemoteListenAsync(id);
+
+ Assert.assertNotNull(stopFut);
+
+ U.sleep(500);
+
+ Assert.assertFalse(stopFut.isDone());
+
+ discoSpi.stopBlock();
+
+ stopFut.get();
+
+ Assert.assertTrue(stopFut.isDone());
+
+ message(ignite1.cluster().forRemotes()).send(topic, "msg2");
+
+ U.sleep(1000);
+
+ assertEquals(1, msgCnt.get());
+ }
+
+ /**
*
*/
static class TestTcpDiscoverySpi extends TcpDiscoverySpi {
@@ -1231,6 +1301,7 @@ public class GridMessagingSelfTest extends GridCommonAbstractTest implements Ser
/**
* @param expOldestIgnite Expected oldest ignite.
+ * @throws InterruptedException If failed.
*/
private void remoteListenForOldest(Ignite expOldestIgnite) throws InterruptedException {
ClusterGroup grp = ignite1.cluster().forOldest();
[07/10] ignite git commit: IGNITE-4475: New async API: now all async
methods are defined explicitly,
IgniteAsyncSupport is deprecated. This closes #1648.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TransactionProxyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TransactionProxyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TransactionProxyImpl.java
index 8ffec00..8750cab 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TransactionProxyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TransactionProxyImpl.java
@@ -24,6 +24,7 @@ import java.io.ObjectOutput;
import java.util.UUID;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteClientDisconnectedException;
+import org.apache.ignite.IgniteException;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
@@ -46,6 +47,7 @@ import org.apache.ignite.transactions.TransactionState;
/**
* Cache transaction proxy.
*/
+@SuppressWarnings("unchecked")
public class TransactionProxyImpl<K, V> implements TransactionProxy, Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -270,6 +272,18 @@ public class TransactionProxyImpl<K, V> implements TransactionProxy, Externaliza
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Void> commitAsync() throws IgniteException {
+ enter();
+
+ try {
+ return (IgniteFuture<Void>)createFuture(cctx.commitTxAsync(tx));
+ }
+ finally {
+ leave();
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public void close() {
enter();
@@ -304,6 +318,21 @@ public class TransactionProxyImpl<K, V> implements TransactionProxy, Externaliza
}
}
+ /** {@inheritDoc} */
+ @Override public IgniteFuture<Void> rollbackAsync() throws IgniteException {
+ enter();
+
+ try {
+ return (IgniteFuture<Void>)(new IgniteFutureImpl(cctx.rollbackTxAsync(tx)));
+ }
+ catch (IgniteCheckedException e) {
+ throw U.convertException(e);
+ }
+ finally {
+ leave();
+ }
+ }
+
/**
* @param res Result to convert to finished future.
*/
@@ -315,6 +344,14 @@ public class TransactionProxyImpl<K, V> implements TransactionProxy, Externaliza
* @param fut Internal future.
*/
private void saveFuture(IgniteInternalFuture<IgniteInternalTx> fut) {
+ asyncRes = createFuture(fut);
+ }
+
+ /**
+ * @param fut Internal future.
+ * @return User future.
+ */
+ private IgniteFuture<?> createFuture(IgniteInternalFuture<IgniteInternalTx> fut) {
IgniteInternalFuture<Transaction> fut0 = fut.chain(new CX1<IgniteInternalFuture<IgniteInternalTx>, Transaction>() {
@Override public Transaction applyx(IgniteInternalFuture<IgniteInternalTx> fut) throws IgniteCheckedException {
fut.get();
@@ -323,7 +360,7 @@ public class TransactionProxyImpl<K, V> implements TransactionProxy, Externaliza
}
});
- asyncRes = new IgniteFutureImpl(fut0);
+ return new IgniteFutureImpl(fut0);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAsyncImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAsyncImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAsyncImpl.java
index 106ef60..b5289a3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAsyncImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsAsyncImpl.java
@@ -21,6 +21,7 @@ import java.net.URI;
import java.util.Collection;
import java.util.Map;
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteFileSystem;
import org.apache.ignite.configuration.FileSystemConfiguration;
import org.apache.ignite.igfs.IgfsBlockLocation;
@@ -36,6 +37,7 @@ import org.apache.ignite.igfs.mapreduce.IgfsTask;
import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystem;
import org.apache.ignite.internal.AsyncSupportAdapter;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.lang.IgniteUuid;
import org.jetbrains.annotations.Nullable;
@@ -58,7 +60,7 @@ public class IgfsAsyncImpl extends AsyncSupportAdapter<IgniteFileSystem> impleme
/** {@inheritDoc} */
@Override public void format() {
try {
- saveOrGet(igfs.formatAsync());
+ saveOrGet(igfs.formatAsync0());
}
catch (IgniteCheckedException e) {
throw U.convertException(e);
@@ -66,10 +68,15 @@ public class IgfsAsyncImpl extends AsyncSupportAdapter<IgniteFileSystem> impleme
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Void> formatAsync() throws IgniteException {
+ return igfs.formatAsync();
+ }
+
+ /** {@inheritDoc} */
@Override public <T, R> R execute(IgfsTask<T, R> task, @Nullable IgfsRecordResolver rslvr,
Collection<IgfsPath> paths, @Nullable T arg) {
try {
- return saveOrGet(igfs.executeAsync(task, rslvr, paths, arg));
+ return saveOrGet(igfs.executeAsync0(task, rslvr, paths, arg));
}
catch (IgniteCheckedException e) {
throw U.convertException(e);
@@ -77,10 +84,16 @@ public class IgfsAsyncImpl extends AsyncSupportAdapter<IgniteFileSystem> impleme
}
/** {@inheritDoc} */
+ @Override public <T, R> IgniteFuture<R> executeAsync(IgfsTask<T, R> task, @Nullable IgfsRecordResolver rslvr,
+ Collection<IgfsPath> paths, @Nullable T arg) throws IgniteException {
+ return igfs.executeAsync(task, rslvr, paths, arg);
+ }
+
+ /** {@inheritDoc} */
@Override public <T, R> R execute(IgfsTask<T, R> task, @Nullable IgfsRecordResolver rslvr,
Collection<IgfsPath> paths, boolean skipNonExistentFiles, long maxRangeLen, @Nullable T arg) {
try {
- return saveOrGet(igfs.executeAsync(task, rslvr, paths, skipNonExistentFiles, maxRangeLen, arg));
+ return saveOrGet(igfs.executeAsync0(task, rslvr, paths, skipNonExistentFiles, maxRangeLen, arg));
}
catch (IgniteCheckedException e) {
throw U.convertException(e);
@@ -88,10 +101,17 @@ public class IgfsAsyncImpl extends AsyncSupportAdapter<IgniteFileSystem> impleme
}
/** {@inheritDoc} */
+ @Override public <T, R> IgniteFuture<R> executeAsync(IgfsTask<T, R> task, @Nullable IgfsRecordResolver rslvr,
+ Collection<IgfsPath> paths, boolean skipNonExistentFiles, long maxRangeLen,
+ @Nullable T arg) throws IgniteException {
+ return igfs.executeAsync(task, rslvr, paths, skipNonExistentFiles, maxRangeLen, arg);
+ }
+
+ /** {@inheritDoc} */
@Override public <T, R> R execute(Class<? extends IgfsTask<T, R>> taskCls,
@Nullable IgfsRecordResolver rslvr, Collection<IgfsPath> paths, @Nullable T arg) {
try {
- return saveOrGet(igfs.executeAsync(taskCls, rslvr, paths, arg));
+ return saveOrGet(igfs.executeAsync0(taskCls, rslvr, paths, arg));
}
catch (IgniteCheckedException e) {
throw U.convertException(e);
@@ -99,11 +119,17 @@ public class IgfsAsyncImpl extends AsyncSupportAdapter<IgniteFileSystem> impleme
}
/** {@inheritDoc} */
+ @Override public <T, R> IgniteFuture<R> executeAsync(Class<? extends IgfsTask<T, R>> taskCls,
+ @Nullable IgfsRecordResolver rslvr, Collection<IgfsPath> paths, @Nullable T arg) throws IgniteException {
+ return igfs.executeAsync(taskCls, rslvr, paths, arg);
+ }
+
+ /** {@inheritDoc} */
@Override public <T, R> R execute(Class<? extends IgfsTask<T, R>> taskCls,
@Nullable IgfsRecordResolver rslvr, Collection<IgfsPath> paths, boolean skipNonExistentFiles,
long maxRangeLen, @Nullable T arg) {
try {
- return saveOrGet(igfs.executeAsync(taskCls, rslvr, paths, skipNonExistentFiles, maxRangeLen, arg));
+ return saveOrGet(igfs.executeAsync0(taskCls, rslvr, paths, skipNonExistentFiles, maxRangeLen, arg));
}
catch (IgniteCheckedException e) {
throw U.convertException(e);
@@ -111,6 +137,13 @@ public class IgfsAsyncImpl extends AsyncSupportAdapter<IgniteFileSystem> impleme
}
/** {@inheritDoc} */
+ @Override public <T, R> IgniteFuture<R> executeAsync(Class<? extends IgfsTask<T, R>> taskCls,
+ @Nullable IgfsRecordResolver rslvr, Collection<IgfsPath> paths, boolean skipNonExistentFiles, long maxRangeLen,
+ @Nullable T arg) throws IgniteException {
+ return igfs.executeAsync(taskCls, rslvr, paths, skipNonExistentFiles, maxRangeLen, arg);
+ }
+
+ /** {@inheritDoc} */
@Override public void stop(boolean cancel) {
igfs.stop(cancel);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java
index 7165f31..18506cd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java
@@ -83,6 +83,7 @@ import org.apache.ignite.internal.processors.igfs.client.IgfsClientUpdateCallabl
import org.apache.ignite.internal.processors.task.GridInternal;
import org.apache.ignite.internal.util.GridSpinBusyLock;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
+import org.apache.ignite.internal.util.future.IgniteFutureImpl;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.T2;
import org.apache.ignite.internal.util.typedef.internal.A;
@@ -1430,12 +1431,17 @@ public final class IgfsImpl implements IgfsEx {
}
}
+ /** {@inheritDoc} */
+ @Override public IgniteFuture<Void> formatAsync() throws IgniteException {
+ return (IgniteFuture<Void>)createFuture(formatAsync0());
+ }
+
/**
* Formats the file system removing all existing entries from it.
*
* @return Future.
*/
- IgniteInternalFuture<?> formatAsync() {
+ IgniteInternalFuture<?> formatAsync0() {
GridFutureAdapter<?> fut = new GridFutureAdapter<>();
Thread t = new Thread(new FormatRunnable(fut), "igfs-format-" + cfg.getName() + "-" +
@@ -1452,7 +1458,7 @@ public final class IgfsImpl implements IgfsEx {
@Override public <T, R> R execute(IgfsTask<T, R> task, @Nullable IgfsRecordResolver rslvr,
Collection<IgfsPath> paths, @Nullable T arg) {
try {
- return executeAsync(task, rslvr, paths, arg).get();
+ return executeAsync0(task, rslvr, paths, arg).get();
}
catch (Exception e) {
throw IgfsUtils.toIgfsException(e);
@@ -1460,10 +1466,16 @@ public final class IgfsImpl implements IgfsEx {
}
/** {@inheritDoc} */
+ @Override public <T, R> IgniteFuture<R> executeAsync(IgfsTask<T, R> task, @Nullable IgfsRecordResolver rslvr,
+ Collection<IgfsPath> paths, @Nullable T arg) throws IgniteException {
+ return createFuture(executeAsync0(task, rslvr, paths, arg));
+ }
+
+ /** {@inheritDoc} */
@Override public <T, R> R execute(IgfsTask<T, R> task, @Nullable IgfsRecordResolver rslvr,
Collection<IgfsPath> paths, boolean skipNonExistentFiles, long maxRangeLen, @Nullable T arg) {
try {
- return executeAsync(task, rslvr, paths, skipNonExistentFiles, maxRangeLen, arg).get();
+ return executeAsync0(task, rslvr, paths, skipNonExistentFiles, maxRangeLen, arg).get();
}
catch (Exception e) {
throw IgfsUtils.toIgfsException(e);
@@ -1471,10 +1483,17 @@ public final class IgfsImpl implements IgfsEx {
}
/** {@inheritDoc} */
+ @Override public <T, R> IgniteFuture<R> executeAsync(IgfsTask<T, R> task, @Nullable IgfsRecordResolver rslvr,
+ Collection<IgfsPath> paths, boolean skipNonExistentFiles, long maxRangeLen,
+ @Nullable T arg) throws IgniteException {
+ return createFuture(executeAsync0(task, rslvr, paths, skipNonExistentFiles, maxRangeLen, arg));
+ }
+
+ /** {@inheritDoc} */
@Override public <T, R> R execute(Class<? extends IgfsTask<T, R>> taskCls,
@Nullable IgfsRecordResolver rslvr, Collection<IgfsPath> paths, @Nullable T arg) {
try {
- return executeAsync(taskCls, rslvr, paths, arg).get();
+ return executeAsync0(taskCls, rslvr, paths, arg).get();
}
catch (Exception e) {
throw IgfsUtils.toIgfsException(e);
@@ -1482,17 +1501,30 @@ public final class IgfsImpl implements IgfsEx {
}
/** {@inheritDoc} */
+ @Override public <T, R> IgniteFuture<R> executeAsync(Class<? extends IgfsTask<T, R>> taskCls,
+ @Nullable IgfsRecordResolver rslvr, Collection<IgfsPath> paths, @Nullable T arg) throws IgniteException {
+ return createFuture(executeAsync0(taskCls, rslvr, paths, arg));
+ }
+
+ /** {@inheritDoc} */
@Override public <T, R> R execute(Class<? extends IgfsTask<T, R>> taskCls,
@Nullable IgfsRecordResolver rslvr, Collection<IgfsPath> paths, boolean skipNonExistentFiles,
long maxRangeSize, @Nullable T arg) {
try {
- return executeAsync(taskCls, rslvr, paths, skipNonExistentFiles, maxRangeSize, arg).get();
+ return executeAsync0(taskCls, rslvr, paths, skipNonExistentFiles, maxRangeSize, arg).get();
}
catch (Exception e) {
throw IgfsUtils.toIgfsException(e);
}
}
+ /** {@inheritDoc} */
+ @Override public <T, R> IgniteFuture<R> executeAsync(Class<? extends IgfsTask<T, R>> taskCls,
+ @Nullable IgfsRecordResolver rslvr, Collection<IgfsPath> paths, boolean skipNonExistentFiles, long maxRangeLen,
+ @Nullable T arg) throws IgniteException {
+ return createFuture(executeAsync0(taskCls, rslvr, paths, skipNonExistentFiles, maxRangeLen, arg));
+ }
+
/**
* Executes IGFS task asynchronously.
*
@@ -1502,9 +1534,9 @@ public final class IgfsImpl implements IgfsEx {
* @param arg Optional task argument.
* @return Execution future.
*/
- <T, R> IgniteInternalFuture<R> executeAsync(IgfsTask<T, R> task, @Nullable IgfsRecordResolver rslvr,
+ <T, R> IgniteInternalFuture<R> executeAsync0(IgfsTask<T, R> task, @Nullable IgfsRecordResolver rslvr,
Collection<IgfsPath> paths, @Nullable T arg) {
- return executeAsync(task, rslvr, paths, true, cfg.getMaximumTaskRangeLength(), arg);
+ return executeAsync0(task, rslvr, paths, true, cfg.getMaximumTaskRangeLength(), arg);
}
/**
@@ -1521,7 +1553,7 @@ public final class IgfsImpl implements IgfsEx {
* @param arg Optional task argument.
* @return Execution future.
*/
- <T, R> IgniteInternalFuture<R> executeAsync(IgfsTask<T, R> task, @Nullable IgfsRecordResolver rslvr,
+ <T, R> IgniteInternalFuture<R> executeAsync0(IgfsTask<T, R> task, @Nullable IgfsRecordResolver rslvr,
Collection<IgfsPath> paths, boolean skipNonExistentFiles, long maxRangeLen, @Nullable T arg) {
return igfsCtx.kernalContext().task().execute(task, new IgfsTaskArgsImpl<>(cfg.getName(), paths, rslvr,
skipNonExistentFiles, maxRangeLen, arg));
@@ -1536,9 +1568,9 @@ public final class IgfsImpl implements IgfsEx {
* @param arg Optional task argument.
* @return Execution future.
*/
- <T, R> IgniteInternalFuture<R> executeAsync(Class<? extends IgfsTask<T, R>> taskCls,
+ <T, R> IgniteInternalFuture<R> executeAsync0(Class<? extends IgfsTask<T, R>> taskCls,
@Nullable IgfsRecordResolver rslvr, Collection<IgfsPath> paths, @Nullable T arg) {
- return executeAsync(taskCls, rslvr, paths, true, cfg.getMaximumTaskRangeLength(), arg);
+ return executeAsync0(taskCls, rslvr, paths, true, cfg.getMaximumTaskRangeLength(), arg);
}
/**
@@ -1555,7 +1587,7 @@ public final class IgfsImpl implements IgfsEx {
* @return Execution future.
*/
@SuppressWarnings("unchecked")
- <T, R> IgniteInternalFuture<R> executeAsync(Class<? extends IgfsTask<T, R>> taskCls,
+ <T, R> IgniteInternalFuture<R> executeAsync0(Class<? extends IgfsTask<T, R>> taskCls,
@Nullable IgfsRecordResolver rslvr, Collection<IgfsPath> paths, boolean skipNonExistentFiles,
long maxRangeLen, @Nullable T arg) {
return igfsCtx.kernalContext().task().execute((Class<IgfsTask<T, R>>)taskCls,
@@ -1780,6 +1812,14 @@ public final class IgfsImpl implements IgfsEx {
}
/**
+ * @param fut Internal future.
+ * @return Public API future.
+ */
+ private <R> IgniteFuture<R> createFuture(IgniteInternalFuture<R> fut) {
+ return new IgniteFutureImpl<>(fut);
+ }
+
+ /**
* IGFS thread factory.
*/
@SuppressWarnings("NullableProblems")
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractTarget.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractTarget.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractTarget.java
index 396e784..5e785e2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractTarget.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractTarget.java
@@ -33,7 +33,7 @@ import org.jetbrains.annotations.Nullable;
/**
* Abstract interop target.
*/
-public abstract class PlatformAbstractTarget implements PlatformTarget, PlatformAsyncTarget {
+public abstract class PlatformAbstractTarget implements PlatformTarget {
/** Constant: TRUE.*/
protected static final int TRUE = 1;
@@ -73,16 +73,6 @@ public abstract class PlatformAbstractTarget implements PlatformTarget, Platform
}
/** {@inheritDoc} */
- @Override public IgniteInternalFuture currentFuture() throws IgniteCheckedException {
- throw new IgniteCheckedException("Future listening is not supported in " + getClass());
- }
-
- /** {@inheritDoc} */
- @Override @Nullable public PlatformFutureUtils.Writer futureWriter(int opId){
- return null;
- }
-
- /** {@inheritDoc} */
@Override public long processInLongOutLong(int type, long val) throws IgniteCheckedException {
return throwUnsupported(type);
}
@@ -203,18 +193,6 @@ public abstract class PlatformAbstractTarget implements PlatformTarget, Platform
}
/**
- * Reads future information and listens.
- *
- * @param reader Reader.
- * @throws IgniteCheckedException In case of error.
- */
- protected long readAndListenFuture(BinaryRawReader reader) throws IgniteCheckedException {
- readAndListenFuture(reader, currentFuture(), null);
-
- return TRUE;
- }
-
- /**
* Wraps a listenable to be returned to platform.
*
* @param listenable Listenable.
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAsyncTarget.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAsyncTarget.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAsyncTarget.java
deleted file mode 100644
index a4d35c9..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAsyncTarget.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.platform;
-
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.processors.platform.utils.PlatformFutureUtils;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Async target.
- */
-public interface PlatformAsyncTarget {
- /**
- * Gets future for the current operation.
- *
- * @return current future.
- * @throws IgniteCheckedException If failed.
- */
- IgniteInternalFuture currentFuture() throws IgniteCheckedException;
-
- /**
- * Gets a custom future writer.
- *
- * @param opId Operation id.
- * @return A custom writer for given op id.
- */
- @Nullable PlatformFutureUtils.Writer futureWriter(int opId);
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformTargetProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformTargetProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformTargetProxy.java
index c2a0797..1ee57cb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformTargetProxy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformTargetProxy.java
@@ -17,7 +17,6 @@
package org.apache.ignite.internal.processors.platform;
-import org.apache.ignite.IgniteCheckedException;
import org.jetbrains.annotations.Nullable;
/**
@@ -106,27 +105,6 @@ public interface PlatformTargetProxy {
void inStreamAsync(int type, long memPtr) throws Exception;
/**
- * Start listening for the future.
- *
- * @param futId Future ID.
- * @param typ Result type.
- * @throws IgniteCheckedException In case of failure.
- */
- @SuppressWarnings("UnusedDeclaration")
- void listenFuture(final long futId, int typ) throws Exception;
-
- /**
- * Start listening for the future for specific operation type.
- *
- * @param futId Future ID.
- * @param typ Result type.
- * @param opId Operation ID required to pick correct result writer.
- * @throws IgniteCheckedException In case of failure.
- */
- @SuppressWarnings("UnusedDeclaration")
- void listenFutureForOperation(final long futId, int typ, int opId) throws Exception;
-
- /**
* Returns the underlying target.
*
* @return Underlying target.
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformTargetProxyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformTargetProxyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformTargetProxyImpl.java
index 7e0036d..44044b1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformTargetProxyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformTargetProxyImpl.java
@@ -17,9 +17,7 @@
package org.apache.ignite.internal.processors.platform;
-import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
-import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.binary.BinaryRawReaderEx;
import org.apache.ignite.internal.binary.BinaryRawWriterEx;
import org.apache.ignite.internal.processors.platform.memory.PlatformMemory;
@@ -37,6 +35,10 @@ public class PlatformTargetProxyImpl implements PlatformTargetProxy {
/** Underlying target. */
private final PlatformTarget target;
+ /**
+ * @param target Platform target.
+ * @param platformCtx Platform context.
+ */
public PlatformTargetProxyImpl(PlatformTarget target, PlatformContext platformCtx) {
assert platformCtx != null;
assert target != null;
@@ -115,15 +117,13 @@ public class PlatformTargetProxyImpl implements PlatformTargetProxy {
final PlatformAsyncResult res = target.processInStreamAsync(type, reader);
- if (res == null) {
+ if (res == null)
throw new IgniteException("PlatformTarget.processInStreamAsync should not return null.");
- }
IgniteFuture fut = res.future();
- if (fut == null) {
+ if (fut == null)
throw new IgniteException("PlatformAsyncResult.future() should not return null.");
- }
PlatformFutureUtils.listen(platformCtx, fut, futId, futTyp, new PlatformFutureUtils.Writer() {
/** {@inheritDoc} */
@@ -211,35 +211,11 @@ public class PlatformTargetProxyImpl implements PlatformTargetProxy {
}
/** {@inheritDoc} */
- @Override public void listenFuture(final long futId, int typ) throws Exception {
- PlatformFutureUtils.listen(platformCtx, currentFuture(), futId, typ, null, target);
- }
-
- /** {@inheritDoc} */
- @Override public void listenFutureForOperation(final long futId, int typ, int opId) throws Exception {
- PlatformFutureUtils.listen(platformCtx, currentFuture(), futId, typ, futureWriter(opId), target);
- }
-
- /** {@inheritDoc} */
@Override public PlatformTarget unwrap() {
return target;
}
/**
- * @return Future writer.
- */
- private PlatformFutureUtils.Writer futureWriter(int opId) {
- return ((PlatformAsyncTarget)target).futureWriter(opId);
- }
-
- /**
- * @return Current future.
- */
- private IgniteInternalFuture currentFuture() throws IgniteCheckedException {
- return ((PlatformAsyncTarget)target).currentFuture();
- }
-
- /**
* Wraps an object in a proxy when possible.
*
* @param obj Object to wrap.
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
index 2abcc0d..72f5d62 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
@@ -32,7 +32,6 @@ import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.cache.query.SqlQuery;
import org.apache.ignite.cache.query.TextQuery;
import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.binary.BinaryRawReaderEx;
import org.apache.ignite.internal.binary.BinaryRawWriterEx;
import org.apache.ignite.internal.processors.cache.CacheOperationContext;
@@ -56,7 +55,6 @@ import org.apache.ignite.internal.processors.platform.utils.PlatformListenable;
import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
import org.apache.ignite.internal.processors.platform.utils.PlatformWriterClosure;
import org.apache.ignite.internal.util.GridConcurrentFactory;
-import org.apache.ignite.internal.util.future.IgniteFutureImpl;
import org.apache.ignite.internal.util.typedef.C1;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.lang.IgniteBiInClosure;
@@ -334,9 +332,6 @@ public class PlatformCache extends PlatformAbstractTarget {
/** Initial JCache (not in binary mode). */
private final IgniteCache rawCache;
- /** Underlying JCache in async mode. */
- private final IgniteCache cacheAsync;
-
/** Whether this cache is created with "keepBinary" flag on the other side. */
private final boolean keepBinary;
@@ -386,8 +381,9 @@ public class PlatformCache extends PlatformAbstractTarget {
assert exts != null;
rawCache = cache;
+
IgniteCache binCache = cache.withKeepBinary();
- cacheAsync = binCache.withAsync();
+
this.cache = (IgniteCacheProxy)binCache;
this.keepBinary = keepBinary;
this.exts = exts;
@@ -448,12 +444,12 @@ public class PlatformCache extends PlatformAbstractTarget {
reader.readObjectDetached()) ? TRUE : FALSE;
case OP_LOC_LOAD_CACHE:
- loadCache0(reader, true, cache);
+ loadCache0(reader, true);
return TRUE;
case OP_LOAD_CACHE:
- loadCache0(reader, false, cache);
+ loadCache0(reader, false);
return TRUE;
@@ -553,66 +549,66 @@ public class PlatformCache extends PlatformAbstractTarget {
});
}
-
case OP_PUT_ASYNC: {
- cacheAsync.put(reader.readObjectDetached(), reader.readObjectDetached());
+ readAndListenFuture(reader,
+ cache.putAsync(reader.readObjectDetached(), reader.readObjectDetached()));
- return readAndListenFuture(reader);
+ return TRUE;
}
case OP_CLEAR_CACHE_ASYNC: {
- cacheAsync.clear();
+ readAndListenFuture(reader, cache.clearAsync());
- return readAndListenFuture(reader);
+ return TRUE;
}
case OP_CLEAR_ALL_ASYNC: {
- cacheAsync.clearAll(PlatformUtils.readSet(reader));
+ readAndListenFuture(reader, cache.clearAllAsync(PlatformUtils.readSet(reader)));
- return readAndListenFuture(reader);
+ return TRUE;
}
case OP_REMOVE_ALL2_ASYNC: {
- cacheAsync.removeAll();
+ readAndListenFuture(reader, cache.removeAllAsync());
- return readAndListenFuture(reader);
+ return TRUE;
}
case OP_SIZE_ASYNC: {
CachePeekMode[] modes = PlatformUtils.decodeCachePeekModes(reader.readInt());
- cacheAsync.size(modes);
+ readAndListenFuture(reader, cache.sizeAsync(modes));
- return readAndListenFuture(reader);
+ return TRUE;
}
case OP_CLEAR_ASYNC: {
- cacheAsync.clear(reader.readObjectDetached());
+ readAndListenFuture(reader, cache.clearAsync(reader.readObjectDetached()));
- return readAndListenFuture(reader);
+ return TRUE;
}
case OP_LOAD_CACHE_ASYNC: {
- loadCache0(reader, false, cacheAsync);
+ readAndListenFuture(reader, loadCacheAsync0(reader, false));
- return readAndListenFuture(reader);
+ return TRUE;
}
case OP_LOC_LOAD_CACHE_ASYNC: {
- loadCache0(reader, true, cacheAsync);
+ readAndListenFuture(reader, loadCacheAsync0(reader, true));
- return readAndListenFuture(reader);
+ return TRUE;
}
case OP_PUT_ALL_ASYNC:
- cacheAsync.putAll(PlatformUtils.readMap(reader));
+ readAndListenFuture(reader, cache.putAllAsync(PlatformUtils.readMap(reader)));
- return readAndListenFuture(reader);
+ return TRUE;
case OP_REMOVE_ALL_ASYNC:
- cacheAsync.removeAll(PlatformUtils.readSet(reader));
+ readAndListenFuture(reader, cache.removeAllAsync(PlatformUtils.readSet(reader)));
- return readAndListenFuture(reader);
+ return TRUE;
case OP_REBALANCE:
readAndListenFuture(reader, cache.rebalance());
@@ -620,79 +616,81 @@ public class PlatformCache extends PlatformAbstractTarget {
return TRUE;
case OP_GET_ASYNC:
- cacheAsync.get(reader.readObjectDetached());
+ readAndListenFuture(reader, cache.getAsync(reader.readObjectDetached()));
- return readAndListenFuture(reader);
+ return TRUE;
case OP_CONTAINS_KEY_ASYNC:
- cacheAsync.containsKey(reader.readObjectDetached());
+ readAndListenFuture(reader, cache.containsKeyAsync(reader.readObjectDetached()));
- return readAndListenFuture(reader);
+ return TRUE;
case OP_CONTAINS_KEYS_ASYNC:
- cacheAsync.containsKeys(PlatformUtils.readSet(reader));
+ readAndListenFuture(reader, cache.containsKeysAsync(PlatformUtils.readSet(reader)));
- return readAndListenFuture(reader);
+ return TRUE;
case OP_REMOVE_OBJ_ASYNC:
- cacheAsync.remove(reader.readObjectDetached());
+ readAndListenFuture(reader, cache.removeAsync(reader.readObjectDetached()));
- return readAndListenFuture(reader);
+ return TRUE;
case OP_REMOVE_BOOL_ASYNC:
- cacheAsync.remove(reader.readObjectDetached(), reader.readObjectDetached());
+ readAndListenFuture(reader,
+ cache.removeAsync(reader.readObjectDetached(), reader.readObjectDetached()));
- return readAndListenFuture(reader);
+ return TRUE;
case OP_GET_ALL_ASYNC: {
Set keys = PlatformUtils.readSet(reader);
- cacheAsync.getAll(keys);
-
- readAndListenFuture(reader, cacheAsync.future(), WRITER_GET_ALL);
+ readAndListenFuture(reader, cache.getAllAsync(keys), WRITER_GET_ALL);
return TRUE;
}
case OP_GET_AND_PUT_ASYNC:
- cacheAsync.getAndPut(reader.readObjectDetached(), reader.readObjectDetached());
+ readAndListenFuture(reader,
+ cache.getAndPutAsync(reader.readObjectDetached(), reader.readObjectDetached()));
- return readAndListenFuture(reader);
+ return TRUE;
case OP_GET_AND_PUT_IF_ABSENT_ASYNC:
- cacheAsync.getAndPutIfAbsent(reader.readObjectDetached(), reader.readObjectDetached());
+ readAndListenFuture(reader,
+ cache.getAndPutIfAbsentAsync(reader.readObjectDetached(), reader.readObjectDetached()));
- return readAndListenFuture(reader);
+ return TRUE;
case OP_GET_AND_REMOVE_ASYNC:
- cacheAsync.getAndRemove(reader.readObjectDetached());
+ readAndListenFuture(reader, cache.getAndRemoveAsync(reader.readObjectDetached()));
- return readAndListenFuture(reader);
+ return TRUE;
case OP_GET_AND_REPLACE_ASYNC:
- cacheAsync.getAndReplace(reader.readObjectDetached(), reader.readObjectDetached());
+ readAndListenFuture(reader,
+ cache.getAndReplaceAsync(reader.readObjectDetached(), reader.readObjectDetached()));
- return readAndListenFuture(reader);
+ return TRUE;
case OP_REPLACE_2_ASYNC:
- cacheAsync.replace(reader.readObjectDetached(), reader.readObjectDetached());
+ readAndListenFuture(reader,
+ cache.replaceAsync(reader.readObjectDetached(), reader.readObjectDetached()));
- return readAndListenFuture(reader);
+ return TRUE;
case OP_REPLACE_3_ASYNC:
- cacheAsync.replace(reader.readObjectDetached(), reader.readObjectDetached(),
- reader.readObjectDetached());
+ readAndListenFuture(reader,
+ cache.replaceAsync(reader.readObjectDetached(), reader.readObjectDetached(),
+ reader.readObjectDetached()));
- return readAndListenFuture(reader);
+ return TRUE;
case OP_INVOKE_ASYNC: {
Object key = reader.readObjectDetached();
CacheEntryProcessor proc = platformCtx.createCacheEntryProcessor(reader.readObjectDetached(), 0);
- cacheAsync.invoke(key, proc);
-
- readAndListenFuture(reader, cacheAsync.future(), WRITER_INVOKE);
+ readAndListenFuture(reader, cache.invokeAsync(key, proc), WRITER_INVOKE);
return TRUE;
}
@@ -702,17 +700,16 @@ public class PlatformCache extends PlatformAbstractTarget {
CacheEntryProcessor proc = platformCtx.createCacheEntryProcessor(reader.readObjectDetached(), 0);
- cacheAsync.invokeAll(keys, proc);
-
- readAndListenFuture(reader, cacheAsync.future(), WRITER_INVOKE_ALL);
+ readAndListenFuture(reader, cache.invokeAllAsync(keys, proc), WRITER_INVOKE_ALL);
return TRUE;
}
case OP_PUT_IF_ABSENT_ASYNC:
- cacheAsync.putIfAbsent(reader.readObjectDetached(), reader.readObjectDetached());
+ readAndListenFuture(reader,
+ cache.putIfAbsentAsync(reader.readObjectDetached(), reader.readObjectDetached()));
- return readAndListenFuture(reader);
+ return TRUE;
case OP_INVOKE: {
Object key = reader.readObjectDetached();
@@ -807,8 +804,45 @@ public class PlatformCache extends PlatformAbstractTarget {
/**
* Loads cache via localLoadCache or loadCache.
+ *
+ * @param reader Binary reader.
+ * @param loc Local flag.
+ * @return Cache async operation future.
*/
- private void loadCache0(BinaryRawReaderEx reader, boolean loc, IgniteCache cache) {
+ private void loadCache0(BinaryRawReaderEx reader, boolean loc) {
+ PlatformCacheEntryFilter filter = createPlatformCacheEntryFilter(reader);
+
+ Object[] args = readLoadCacheArgs(reader);
+
+ if (loc)
+ cache.localLoadCache(filter, args);
+ else
+ cache.loadCache(filter, args);
+ }
+
+ /**
+ * Asynchronously loads cache via localLoadCacheAsync or loadCacheAsync.
+ *
+ * @param reader Binary reader.
+ * @param loc Local flag.
+ * @return Cache async operation future.
+ */
+ private IgniteFuture<Void> loadCacheAsync0(BinaryRawReaderEx reader, boolean loc) {
+ PlatformCacheEntryFilter filter = createPlatformCacheEntryFilter(reader);
+
+ Object[] args = readLoadCacheArgs(reader);
+
+ if (loc)
+ return cache.localLoadCacheAsync(filter, args);
+ else
+ return cache.loadCacheAsync(filter, args);
+ }
+
+ /**
+ * @param reader Binary reader.
+ * @return created object.
+ */
+ @Nullable private PlatformCacheEntryFilter createPlatformCacheEntryFilter(BinaryRawReaderEx reader) {
PlatformCacheEntryFilter filter = null;
Object pred = reader.readObjectDetached();
@@ -816,6 +850,14 @@ public class PlatformCache extends PlatformAbstractTarget {
if (pred != null)
filter = platformCtx.createCacheEntryFilter(pred, 0);
+ return filter;
+ }
+
+ /**
+ * @param reader Binary reader.
+ * @return Arguments array.
+ */
+ @Nullable private Object[] readLoadCacheArgs(BinaryRawReaderEx reader) {
Object[] args = null;
int argCnt = reader.readInt();
@@ -827,10 +869,7 @@ public class PlatformCache extends PlatformAbstractTarget {
args[i] = reader.readObjectDetached();
}
- if (loc)
- cache.localLoadCache(filter, args);
- else
- cache.loadCache(filter, args);
+ return args;
}
/** {@inheritDoc} */
@@ -1130,25 +1169,6 @@ public class PlatformCache extends PlatformAbstractTarget {
}
}
- /** <inheritDoc /> */
- @Override public IgniteInternalFuture currentFuture() throws IgniteCheckedException {
- return ((IgniteFutureImpl) cacheAsync.future()).internalFuture();
- }
-
- /** <inheritDoc /> */
- @Nullable @Override public PlatformFutureUtils.Writer futureWriter(int opId) {
- if (opId == OP_GET_ALL)
- return WRITER_GET_ALL;
-
- if (opId == OP_INVOKE)
- return WRITER_INVOKE;
-
- if (opId == OP_INVOKE_ALL)
- return WRITER_INVOKE_ALL;
-
- return null;
- }
-
/**
* Get lock by id.
*
@@ -1179,6 +1199,10 @@ public class PlatformCache extends PlatformAbstractTarget {
/**
* Runs specified query.
+ *
+ * @param qry Query.
+ * @return Query cursor.
+ * @throws IgniteCheckedException On error.
*/
private PlatformQueryCursor runQuery(Query qry) throws IgniteCheckedException {
@@ -1195,6 +1219,10 @@ public class PlatformCache extends PlatformAbstractTarget {
/**
* Runs specified fields query.
+ *
+ * @param qry Query.
+ * @return Query cursor.
+ * @throws IgniteCheckedException On error.
*/
private PlatformFieldsQueryCursor runFieldsQuery(Query qry)
throws IgniteCheckedException {
@@ -1211,6 +1239,10 @@ public class PlatformCache extends PlatformAbstractTarget {
/**
* Reads the query of specified type.
+ *
+ * @param reader Binary reader.
+ * @return Query.
+ * @throws IgniteCheckedException On error.
*/
private Query readInitialQuery(BinaryRawReaderEx reader) throws IgniteCheckedException {
int typ = reader.readInt();
@@ -1234,6 +1266,9 @@ public class PlatformCache extends PlatformAbstractTarget {
/**
* Reads sql query.
+ *
+ * @param reader Binary reader.
+ * @return Query.
*/
private Query readSqlQuery(BinaryRawReaderEx reader) {
boolean loc = reader.readBoolean();
@@ -1250,6 +1285,9 @@ public class PlatformCache extends PlatformAbstractTarget {
/**
* Reads fields query.
+ *
+ * @param reader Binary reader.
+ * @return Query.
*/
private Query readFieldsQuery(BinaryRawReaderEx reader) {
boolean loc = reader.readBoolean();
@@ -1267,6 +1305,9 @@ public class PlatformCache extends PlatformAbstractTarget {
/**
* Reads text query.
+ *
+ * @param reader Binary reader.
+ * @return Query.
*/
private Query readTextQuery(BinaryRawReader reader) {
boolean loc = reader.readBoolean();
@@ -1279,6 +1320,9 @@ public class PlatformCache extends PlatformAbstractTarget {
/**
* Reads scan query.
+ *
+ * @param reader Binary reader.
+ * @return Query.
*/
private Query readScanQuery(BinaryRawReaderEx reader) {
boolean loc = reader.readBoolean();
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/compute/PlatformCompute.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/compute/PlatformCompute.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/compute/PlatformCompute.java
index 9d9a4d2..2b2a78a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/compute/PlatformCompute.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/compute/PlatformCompute.java
@@ -240,9 +240,10 @@ public class PlatformCompute extends PlatformAbstractTarget {
* Execute task.
*
* @param task Task.
+ * @return Target.
*/
private PlatformTarget executeNative0(final PlatformAbstractTask task) {
- IgniteInternalFuture fut = computeForPlatform.executeAsync(task, null);
+ IgniteInternalFuture fut = computeForPlatform.executeAsync0(task, null);
fut.listen(new IgniteInClosure<IgniteInternalFuture>() {
private static final long serialVersionUID = 0L;
@@ -266,7 +267,9 @@ public class PlatformCompute extends PlatformAbstractTarget {
* Execute task taking arguments from the given reader.
*
* @param reader Reader.
+ * @param async Execute asynchronously flag.
* @return Task result.
+ * @throws IgniteCheckedException On error.
*/
protected Object executeJavaTask(BinaryRawReaderEx reader, boolean async) throws IgniteCheckedException {
String taskName = reader.readString();
@@ -277,18 +280,13 @@ public class PlatformCompute extends PlatformAbstractTarget {
IgniteCompute compute0 = computeForTask(nodeIds);
- if (async)
- compute0 = compute0.withAsync();
-
if (!keepBinary && arg instanceof BinaryObjectImpl)
arg = ((BinaryObject)arg).deserialize();
- Object res = compute0.execute(taskName, arg);
-
if (async)
- return readAndListenFuture(reader, new ComputeConvertingFuture(compute0.future()));
+ return readAndListenFuture(reader, new ComputeConvertingFuture(compute0.executeAsync(taskName, arg)));
else
- return toBinary(res);
+ return toBinary(compute0.execute(taskName, arg));
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/entityframework/PlatformDotNetEntityFrameworkCacheExtension.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/entityframework/PlatformDotNetEntityFrameworkCacheExtension.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/entityframework/PlatformDotNetEntityFrameworkCacheExtension.java
index d4755de..cb27b19 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/entityframework/PlatformDotNetEntityFrameworkCacheExtension.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/entityframework/PlatformDotNetEntityFrameworkCacheExtension.java
@@ -20,7 +20,6 @@ package org.apache.ignite.internal.processors.platform.entityframework;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteCompute;
import org.apache.ignite.cache.CachePeekMode;
import org.apache.ignite.cluster.ClusterGroup;
import org.apache.ignite.cluster.ClusterNode;
@@ -187,11 +186,10 @@ public class PlatformDotNetEntityFrameworkCacheExtension implements PlatformCach
final ClusterGroup dataNodes = grid.cluster().forDataNodes(dataCacheName);
- IgniteCompute asyncCompute = grid.compute(dataNodes).withAsync();
+ IgniteFuture f = grid.compute(dataNodes).broadcastAsync(
+ new RemoveOldEntriesRunnable(dataCacheName, currentVersions));
- asyncCompute.broadcast(new RemoveOldEntriesRunnable(dataCacheName, currentVersions));
-
- asyncCompute.future().listen(new CleanupCompletionListener(metaCache, dataCacheName));
+ f.listen(new CleanupCompletionListener(metaCache, dataCacheName));
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/events/PlatformEvents.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/events/PlatformEvents.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/events/PlatformEvents.java
index 9ddcc37..845c06a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/events/PlatformEvents.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/events/PlatformEvents.java
@@ -17,11 +17,11 @@
package org.apache.ignite.internal.processors.platform.events;
+import java.util.List;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteEvents;
import org.apache.ignite.events.Event;
import org.apache.ignite.events.EventAdapter;
-import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.binary.BinaryRawReaderEx;
import org.apache.ignite.internal.binary.BinaryRawWriterEx;
import org.apache.ignite.internal.processors.platform.PlatformAbstractTarget;
@@ -29,8 +29,8 @@ import org.apache.ignite.internal.processors.platform.PlatformContext;
import org.apache.ignite.internal.processors.platform.PlatformEventFilterListener;
import org.apache.ignite.internal.processors.platform.PlatformTarget;
import org.apache.ignite.internal.processors.platform.utils.PlatformFutureUtils;
-import org.apache.ignite.internal.util.future.IgniteFutureImpl;
import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.lang.IgnitePredicate;
import org.jetbrains.annotations.Nullable;
@@ -91,9 +91,6 @@ public class PlatformEvents extends PlatformAbstractTarget {
private final IgniteEvents events;
/** */
- private final IgniteEvents eventsAsync;
-
- /** */
private final EventResultWriter eventResWriter;
/** */
@@ -111,7 +108,6 @@ public class PlatformEvents extends PlatformAbstractTarget {
assert events != null;
this.events = events;
- eventsAsync = events.withAsync();
eventResWriter = new EventResultWriter(platformCtx);
eventColResWriter = new EventCollectionResultWriter(platformCtx);
@@ -148,16 +144,12 @@ public class PlatformEvents extends PlatformAbstractTarget {
return TRUE;
case OP_REMOTE_QUERY_ASYNC:
- startRemoteQuery(reader, eventsAsync);
-
- readAndListenFuture(reader, currentFuture(), eventColResWriter);
+ readAndListenFuture(reader, startRemoteQueryAsync(reader, events), eventColResWriter);
return TRUE;
case OP_WAIT_FOR_LOCAL_ASYNC: {
- startWaitForLocal(reader, eventsAsync);
-
- readAndListenFuture(reader, currentFuture(), eventResWriter);
+ readAndListenFuture(reader, startWaitForLocalAsync(reader, events), eventResWriter);
return TRUE;
}
@@ -253,6 +245,23 @@ public class PlatformEvents extends PlatformAbstractTarget {
}
/**
+ * Starts the waitForLocal asynchronously.
+ *
+ * @param reader Reader
+ * @param events Events.
+ * @return Result.
+ */
+ private IgniteFuture<EventAdapter> startWaitForLocalAsync(BinaryRawReaderEx reader, IgniteEvents events) {
+ Long filterHnd = reader.readObject();
+
+ IgnitePredicate filter = filterHnd != null ? localFilter(filterHnd) : null;
+
+ int[] eventTypes = readEventTypes(reader);
+
+ return events.waitForLocalAsync(filter, eventTypes);
+ }
+
+ /**
* Starts the remote query.
*
* @param reader Reader.
@@ -271,6 +280,25 @@ public class PlatformEvents extends PlatformAbstractTarget {
return events.remoteQuery(filter, timeout);
}
+ /**
+ * Starts the remote query asynchronously.
+ *
+ * @param reader Reader.
+ * @param events Events.
+ * @return Result.
+ */
+ private IgniteFuture<List<Event>> startRemoteQueryAsync(BinaryRawReaderEx reader, IgniteEvents events) {
+ Object pred = reader.readObjectDetached();
+
+ long timeout = reader.readLong();
+
+ int[] types = readEventTypes(reader);
+
+ PlatformEventFilterListener filter = platformCtx.createRemoteEventFilter(pred, types);
+
+ return events.remoteQueryAsync(filter, timeout);
+ }
+
/** {@inheritDoc} */
@Override public void processOutStream(int type, BinaryRawWriterEx writer) throws IgniteCheckedException {
switch (type) {
@@ -310,24 +338,6 @@ public class PlatformEvents extends PlatformAbstractTarget {
return super.processInLongOutLong(type, val);
}
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture currentFuture() throws IgniteCheckedException {
- return ((IgniteFutureImpl)eventsAsync.future()).internalFuture();
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public PlatformFutureUtils.Writer futureWriter(int opId) {
- switch (opId) {
- case OP_WAIT_FOR_LOCAL:
- return eventResWriter;
-
- case OP_REMOTE_QUERY:
- return eventColResWriter;
- }
-
- return null;
- }
-
/**
* Reads event types array.
*
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessaging.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessaging.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessaging.java
index 6fe109e..8018986 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessaging.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessaging.java
@@ -19,7 +19,6 @@ package org.apache.ignite.internal.processors.platform.messaging;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteMessaging;
-import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.binary.BinaryRawReaderEx;
import org.apache.ignite.internal.binary.BinaryRawWriterEx;
import org.apache.ignite.internal.processors.platform.PlatformAbstractTarget;
@@ -27,7 +26,7 @@ import org.apache.ignite.internal.processors.platform.PlatformContext;
import org.apache.ignite.internal.processors.platform.PlatformTarget;
import org.apache.ignite.internal.processors.platform.message.PlatformMessageFilter;
import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
-import org.apache.ignite.internal.util.future.IgniteFutureImpl;
+import org.apache.ignite.lang.IgniteFuture;
import java.util.UUID;
@@ -68,9 +67,6 @@ public class PlatformMessaging extends PlatformAbstractTarget {
/** */
private final IgniteMessaging messaging;
- /** */
- private final IgniteMessaging messagingAsync;
-
/**
* Ctor.
*
@@ -83,7 +79,6 @@ public class PlatformMessaging extends PlatformAbstractTarget {
assert messaging != null;
this.messaging = messaging;
- messagingAsync = messaging.withAsync();
}
/** {@inheritDoc} */
@@ -132,15 +127,15 @@ public class PlatformMessaging extends PlatformAbstractTarget {
}
case OP_REMOTE_LISTEN_ASYNC: {
- startRemoteListen(reader, messagingAsync);
+ readAndListenFuture(reader, startRemoteListenAsync(reader, messaging));
- return readAndListenFuture(reader);
+ return TRUE;
}
case OP_STOP_REMOTE_LISTEN_ASYNC: {
- messagingAsync.stopRemoteListen(reader.readUuid());
+ readAndListenFuture(reader, messaging.stopRemoteListenAsync(reader.readUuid()));
- return readAndListenFuture(reader);
+ return TRUE;
}
default:
@@ -167,6 +162,7 @@ public class PlatformMessaging extends PlatformAbstractTarget {
/**
* Starts the remote listener.
* @param reader Reader.
+ * @param messaging Messaging.
* @return Listen id.
*/
private UUID startRemoteListen(BinaryRawReaderEx reader, IgniteMessaging messaging) {
@@ -181,9 +177,22 @@ public class PlatformMessaging extends PlatformAbstractTarget {
return messaging.remoteListen(topic, filter);
}
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture currentFuture() throws IgniteCheckedException {
- return ((IgniteFutureImpl)messagingAsync.future()).internalFuture();
+ /**
+ * Starts the remote listener.
+ * @param reader Reader.
+ * @param messaging Messaging.
+ * @return Future of the operation.
+ */
+ private IgniteFuture<UUID> startRemoteListenAsync(BinaryRawReaderEx reader, IgniteMessaging messaging) {
+ Object nativeFilter = reader.readObjectDetached();
+
+ long ptr = reader.readLong(); // interop pointer
+
+ Object topic = reader.readObjectDetached();
+
+ PlatformMessageFilter filter = platformCtx.createRemoteMessageFilter(nativeFilter, ptr);
+
+ return messaging.remoteListenAsync(topic, filter);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformServices.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformServices.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformServices.java
index 37727f5..827bc5a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformServices.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformServices.java
@@ -20,7 +20,6 @@ package org.apache.ignite.internal.processors.platform.services;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteServices;
-import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.binary.BinaryRawReaderEx;
import org.apache.ignite.internal.binary.BinaryRawWriterEx;
import org.apache.ignite.internal.processors.platform.PlatformAbstractTarget;
@@ -32,8 +31,8 @@ import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
import org.apache.ignite.internal.processors.platform.utils.PlatformWriterBiClosure;
import org.apache.ignite.internal.processors.platform.utils.PlatformWriterClosure;
import org.apache.ignite.internal.processors.service.GridServiceProxy;
-import org.apache.ignite.internal.util.future.IgniteFutureImpl;
import org.apache.ignite.internal.util.typedef.T3;
+import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.services.Service;
import org.apache.ignite.services.ServiceConfiguration;
@@ -46,6 +45,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
+import org.jetbrains.annotations.NotNull;
/**
* Interop services.
@@ -107,9 +107,6 @@ public class PlatformServices extends PlatformAbstractTarget {
/** */
private final IgniteServices services;
- /** */
- private final IgniteServices servicesAsync;
-
/** Server keep binary flag. */
private final boolean srvKeepBinary;
@@ -126,7 +123,6 @@ public class PlatformServices extends PlatformAbstractTarget {
assert services != null;
this.services = services;
- servicesAsync = services.withAsync();
this.srvKeepBinary = srvKeepBinary;
}
@@ -155,21 +151,21 @@ public class PlatformServices extends PlatformAbstractTarget {
}
case OP_DOTNET_DEPLOY_ASYNC: {
- dotnetDeploy(reader, servicesAsync);
+ readAndListenFuture(reader, dotnetDeployAsync(reader, services));
- return readAndListenFuture(reader);
+ return TRUE;
}
case OP_DOTNET_DEPLOY_MULTIPLE: {
- dotnetDeployMultiple(reader, services);
+ dotnetDeployMultiple(reader);
return TRUE;
}
case OP_DOTNET_DEPLOY_MULTIPLE_ASYNC: {
- dotnetDeployMultiple(reader, servicesAsync);
+ readAndListenFuture(reader, dotnetDeployMultipleAsync(reader));
- return readAndListenFuture(reader);
+ return TRUE;
}
case OP_CANCEL: {
@@ -179,15 +175,15 @@ public class PlatformServices extends PlatformAbstractTarget {
}
case OP_CANCEL_ASYNC: {
- servicesAsync.cancel(reader.readString());
+ readAndListenFuture(reader, services.cancelAsync(reader.readString()));
- return readAndListenFuture(reader);
+ return TRUE;
}
case OP_CANCEL_ALL_ASYNC: {
- servicesAsync.cancelAll();
+ readAndListenFuture(reader, services.cancelAllAsync());
- return readAndListenFuture(reader);
+ return TRUE;
}
default:
@@ -350,15 +346,12 @@ public class PlatformServices extends PlatformAbstractTarget {
return super.processInStreamOutObject(type, reader);
}
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture currentFuture() throws IgniteCheckedException {
- return ((IgniteFutureImpl)servicesAsync.future()).internalFuture();
- }
-
/**
* Deploys multiple dotnet services.
+ *
+ * @param reader Binary reader.
*/
- private void dotnetDeployMultiple(BinaryRawReaderEx reader, IgniteServices services) {
+ private void dotnetDeployMultiple(BinaryRawReaderEx reader) {
String name = reader.readString();
Object svc = reader.readObjectDetached();
int totalCnt = reader.readInt();
@@ -369,9 +362,53 @@ public class PlatformServices extends PlatformAbstractTarget {
}
/**
+ * Asynchronously deploys multiple dotnet services.
+ *
+ * @param reader Binary reader.
+ * @return Future of the operation.
+ */
+ private IgniteFuture<Void> dotnetDeployMultipleAsync(BinaryRawReaderEx reader) {
+ String name = reader.readString();
+ Object svc = reader.readObjectDetached();
+ int totalCnt = reader.readInt();
+ int maxPerNodeCnt = reader.readInt();
+
+ return services.deployMultipleAsync(name, new PlatformDotNetServiceImpl(svc, platformCtx, srvKeepBinary),
+ totalCnt, maxPerNodeCnt);
+ }
+
+ /**
* Deploys dotnet service.
+ *
+ * @param reader Binary reader.
+ * @param services Services.
*/
private void dotnetDeploy(BinaryRawReaderEx reader, IgniteServices services) {
+ ServiceConfiguration cfg = dotnetConfiguration(reader);
+
+ services.deploy(cfg);
+ }
+
+ /**
+ * Deploys dotnet service asynchronously.
+ *
+ * @param reader Binary reader.
+ * @param services Services.
+ * @return Future of the operation.
+ */
+ private IgniteFuture<Void> dotnetDeployAsync(BinaryRawReaderEx reader, IgniteServices services) {
+ ServiceConfiguration cfg = dotnetConfiguration(reader);
+
+ return services.deployAsync(cfg);
+ }
+
+ /**
+ * Read the dotnet service configuration.
+ *
+ * @param reader Binary reader,
+ * @return Service configuration.
+ */
+ @NotNull private ServiceConfiguration dotnetConfiguration(BinaryRawReaderEx reader) {
ServiceConfiguration cfg = new ServiceConfiguration();
cfg.setName(reader.readString());
@@ -386,7 +423,7 @@ public class PlatformServices extends PlatformAbstractTarget {
if (filter != null)
cfg.setNodeFilter(platformCtx.createClusterNodeFilter(filter));
- services.deploy(cfg);
+ return cfg;
}
/**
@@ -403,8 +440,8 @@ public class PlatformServices extends PlatformAbstractTarget {
/** */
private static final Map<Class<?>, Class<?>> PRIMITIVES_TO_WRAPPERS = new HashMap<>();
- /**
- * Class initializer.
+ /*
+ Class initializer.
*/
static {
PRIMITIVES_TO_WRAPPERS.put(boolean.class, Boolean.class);
@@ -422,6 +459,7 @@ public class PlatformServices extends PlatformAbstractTarget {
*
* @param proxy Proxy object.
* @param clazz Proxy class.
+ * @param ctx Platform context.
*/
private ServiceProxyHolder(Object proxy, Class clazz, PlatformContext ctx) {
super(ctx);
@@ -435,18 +473,18 @@ public class PlatformServices extends PlatformAbstractTarget {
/**
* Invokes the proxy.
+ *
* @param mthdName Method name.
* @param srvKeepBinary Binary flag.
* @param args Args.
* @return Invocation result.
- * @throws IgniteCheckedException
- * @throws NoSuchMethodException
+ * @throws IgniteCheckedException On error.
+ * @throws NoSuchMethodException On error.
*/
public Object invoke(String mthdName, boolean srvKeepBinary, Object[] args)
throws IgniteCheckedException, NoSuchMethodException {
- if (proxy instanceof PlatformService) {
+ if (proxy instanceof PlatformService)
return ((PlatformService)proxy).invokeMethod(mthdName, srvKeepBinary, args);
- }
else {
assert proxy instanceof GridServiceProxy;
@@ -467,6 +505,7 @@ public class PlatformServices extends PlatformAbstractTarget {
* @param mthdName Name.
* @param args Args.
* @return Method.
+ * @throws NoSuchMethodException On error.
*/
private static Method getMethod(Class clazz, String mthdName, Object[] args) throws NoSuchMethodException {
assert clazz != null;
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java
index 21f71fa..8f34343 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java
@@ -196,17 +196,16 @@ public class PlatformTransactions extends PlatformAbstractTarget {
@Override public long processInStreamOutLong(int type, BinaryRawReaderEx reader) throws IgniteCheckedException {
long txId = reader.readLong();
- final Transaction asyncTx = (Transaction)tx(txId).withAsync();
+ IgniteFuture fut0;
switch (type) {
case OP_COMMIT_ASYNC:
- asyncTx.commit();
+ fut0 = tx(txId).commitAsync();
break;
-
case OP_ROLLBACK_ASYNC:
- asyncTx.rollback();
+ fut0 = tx(txId).rollbackAsync();
break;
@@ -215,7 +214,7 @@ public class PlatformTransactions extends PlatformAbstractTarget {
}
// Future result is the tx itself, we do not want to return it to the platform.
- IgniteFuture fut = asyncTx.future().chain(new C1<IgniteFuture, Object>() {
+ IgniteFuture fut = fut0.chain(new C1<IgniteFuture, Object>() {
private static final long serialVersionUID = 0L;
@Override public Object apply(IgniteFuture fut) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTask.java
index ce74f17..7556e7c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTask.java
@@ -112,26 +112,20 @@ public class VisorCacheClearTask extends VisorOneNodeTask<String, IgniteBiTuple<
futs = new IgniteFuture[3];
if (futs[0] == null || futs[1] == null || futs[2] == null) {
- IgniteCache cache = ignite.cache(cacheName).withAsync();
+ IgniteCache cache = ignite.cache(cacheName);
if (futs[0] == null) {
- cache.size(CachePeekMode.PRIMARY);
-
- if (callAsync(cache.<Integer>future(), 0))
+ if (callAsync(cache.sizeAsync(CachePeekMode.PRIMARY), 0))
return null;
}
if (futs[1] == null) {
- cache.clear();
-
- if (callAsync(cache.<Integer>future(), 1))
+ if (callAsync(cache.clearAsync(), 1))
return null;
}
if (futs[2] == null) {
- cache.size(CachePeekMode.PRIMARY);
-
- if (callAsync(cache.<Integer>future(), 2))
+ if (callAsync(cache.sizeAsync(CachePeekMode.PRIMARY), 2))
return null;
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorGatewayTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorGatewayTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorGatewayTask.java
index a64ec6d..8f42eb2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorGatewayTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorGatewayTask.java
@@ -370,11 +370,9 @@ public class VisorGatewayTask implements ComputeTask<Object[], Object> {
}
}
- IgniteCompute comp = ignite.compute(ignite.cluster().forNodeIds(nids)).withAsync();
-
- comp.execute(taskName, new VisorTaskArgument<>(nids, jobArgs, false));
+ IgniteCompute comp = ignite.compute(ignite.cluster().forNodeIds(nids));
- fut = comp.future();
+ fut = comp.executeAsync(taskName, new VisorTaskArgument<>(nids, jobArgs, false));
fut.listen(new CI1<IgniteFuture<Object>>() {
@Override public void apply(IgniteFuture<Object> f) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/main/java/org/apache/ignite/lang/IgniteAsyncSupport.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/lang/IgniteAsyncSupport.java b/modules/core/src/main/java/org/apache/ignite/lang/IgniteAsyncSupport.java
index 50a8700..3e31b51 100644
--- a/modules/core/src/main/java/org/apache/ignite/lang/IgniteAsyncSupport.java
+++ b/modules/core/src/main/java/org/apache/ignite/lang/IgniteAsyncSupport.java
@@ -18,25 +18,75 @@
package org.apache.ignite.lang;
/**
- * Allows to enable asynchronous mode on Ignite APIs.
+ * Allows to enable asynchronous mode on Ignite APIs, e.g.
+ * <pre>
+ * IgniteFuture f = cache.getAsync();
+ * </pre>
+ * instead of old-style async API:
+ * <pre>
+ * IgniteCache asyncCache = cache.withAsync();
+ * asyncCache.get(key);
+ * IgniteFuture fut = asyncCache.future();
+ * </pre>
+ * @deprecated since 2.0. Please use specialized asynchronous methods.
*/
+@Deprecated
public interface IgniteAsyncSupport {
/**
* Gets instance of this component with asynchronous mode enabled.
*
* @return Instance of this component with asynchronous mode enabled.
+ *
+ * @deprecated since 2.0. Please use new specialized async method
+ * e.g.
+ * <pre>
+ * IgniteFuture f = cache.getAsync();
+ * </pre>
+ * instead of old-style async API:
+ * <pre>
+ * IgniteCache asyncCache = cache.withAsync();
+ * asyncCache.get(key);
+ * IgniteFuture fut = asyncCache.future();
+ * </pre>
*/
+ @Deprecated
public IgniteAsyncSupport withAsync();
/**
* @return {@code True} if asynchronous mode is enabled.
+ *
+ * @deprecated since 2.0. Please use new specialized async method
+ * e.g.
+ * <pre>
+ * IgniteFuture f = cache.getAsync();
+ * </pre>
+ * instead of old-style async API:
+ * <pre>
+ * IgniteCache asyncCache = cache.withAsync();
+ * asyncCache.get(key);
+ * IgniteFuture fut = asyncCache.future();
+ * </pre>
*/
+ @Deprecated
public boolean isAsync();
/**
* Gets and resets future for previous asynchronous operation.
*
* @return Future for previous asynchronous operation.
+ *
+ * @deprecated since 2.0. Please use new specialized async method
+ * e.g.
+ * <pre>
+ * IgniteFuture f = cache.getAsync();
+ * </pre>
+ * instead of old-style async API:
+ * <pre>
+ * IgniteCache asyncCache = cache.withAsync();
+ * asyncCache.get(key);
+ * IgniteFuture fut = asyncCache.future();
+ * </pre>
*/
+ @Deprecated
public <R> IgniteFuture<R> future();
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/main/java/org/apache/ignite/lang/IgniteAsyncSupported.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/lang/IgniteAsyncSupported.java b/modules/core/src/main/java/org/apache/ignite/lang/IgniteAsyncSupported.java
index 1bb7162..2dfea51 100644
--- a/modules/core/src/main/java/org/apache/ignite/lang/IgniteAsyncSupported.java
+++ b/modules/core/src/main/java/org/apache/ignite/lang/IgniteAsyncSupported.java
@@ -31,11 +31,13 @@ import java.lang.annotation.Target;
*
* TODO coding example.
*
+ * @deprecated since 2.0. Please use specialized asynchronous methods.
* @see IgniteAsyncSupport
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
+@Deprecated
public @interface IgniteAsyncSupported {
-
+ // No-op.
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/main/java/org/apache/ignite/transactions/Transaction.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/transactions/Transaction.java b/modules/core/src/main/java/org/apache/ignite/transactions/Transaction.java
index e2e7100..57a2b00 100644
--- a/modules/core/src/main/java/org/apache/ignite/transactions/Transaction.java
+++ b/modules/core/src/main/java/org/apache/ignite/transactions/Transaction.java
@@ -22,6 +22,7 @@ import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteTransactions;
import org.apache.ignite.lang.IgniteAsyncSupport;
import org.apache.ignite.lang.IgniteAsyncSupported;
+import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.lang.IgniteUuid;
/**
@@ -237,6 +238,19 @@ public interface Transaction extends AutoCloseable, IgniteAsyncSupport {
public void commit() throws IgniteException;
/**
+ * Asynchronously commits this transaction by initiating {@code two-phase-commit} process.
+ *
+ * @return a Future representing pending completion of the commit.
+ * @throws IgniteException If commit failed.
+ * @throws TransactionTimeoutException If transaction is timed out.
+ * @throws TransactionRollbackException If transaction is automatically rolled back.
+ * @throws TransactionOptimisticException If transaction concurrency is {@link TransactionConcurrency#OPTIMISTIC}
+ * and commit is optimistically failed.
+ * @throws TransactionHeuristicException If transaction has entered an unknown state.
+ */
+ public IgniteFuture<Void> commitAsync() throws IgniteException;
+
+ /**
* Ends the transaction. Transaction will be rolled back if it has not been committed.
*
* @throws IgniteException If transaction could not be gracefully ended.
@@ -250,4 +264,12 @@ public interface Transaction extends AutoCloseable, IgniteAsyncSupport {
*/
@IgniteAsyncSupported
public void rollback() throws IgniteException;
+
+ /**
+ * Asynchronously rolls back this transaction.
+ *
+ * @return a Future representing pending completion of the rollback.
+ * @throws IgniteException If rollback failed.
+ */
+ public IgniteFuture<Void> rollbackAsync() throws IgniteException;
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/cache/store/IgniteCacheExpiryStoreLoadSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/IgniteCacheExpiryStoreLoadSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/IgniteCacheExpiryStoreLoadSelfTest.java
index 4d94400..722e37f 100644
--- a/modules/core/src/test/java/org/apache/ignite/cache/store/IgniteCacheExpiryStoreLoadSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/cache/store/IgniteCacheExpiryStoreLoadSelfTest.java
@@ -102,13 +102,8 @@ public class IgniteCacheExpiryStoreLoadSelfTest extends GridCacheAbstractSelfTes
keys.add(primaryKey(jcache(1)));
keys.add(primaryKey(jcache(2)));
- if (async) {
- IgniteCache<String, Integer> asyncCache = cache.withAsync();
-
- asyncCache.loadCache(null, keys.toArray(new Integer[3]));
-
- asyncCache.future().get();
- }
+ if (async)
+ cache.loadCacheAsync(null, keys.toArray(new Integer[3])).get();
else
cache.loadCache(null, keys.toArray(new Integer[3]));
@@ -143,13 +138,8 @@ public class IgniteCacheExpiryStoreLoadSelfTest extends GridCacheAbstractSelfTes
List<Integer> keys = primaryKeys(cache, 3);
- if (async) {
- IgniteCache<String, Integer> asyncCache = cache.withAsync();
-
- asyncCache.localLoadCache(null, keys.toArray(new Integer[3]));
-
- asyncCache.future().get();
- }
+ if (async)
+ cache.localLoadCacheAsync(null, keys.toArray(new Integer[3])).get();
else
cache.localLoadCache(null, keys.toArray(new Integer[3]));
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/ClusterGroupAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/ClusterGroupAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/ClusterGroupAbstractTest.java
index 6fdaeb0..fbf938d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/ClusterGroupAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/ClusterGroupAbstractTest.java
@@ -33,7 +33,6 @@ import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCluster;
-import org.apache.ignite.IgniteCompute;
import org.apache.ignite.cluster.ClusterGroup;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.compute.ComputeJob;
@@ -356,11 +355,7 @@ public abstract class ClusterGroupAbstractTest extends GridCommonAbstractTest im
* @throws Exception If failed.
*/
private void run1(AtomicInteger cnt) throws Exception {
- IgniteCompute comp = compute(prj).withAsync();
-
- comp.broadcast(runJob);
-
- ComputeTaskFuture fut = comp.future();
+ IgniteFuture<Void> fut = compute(prj).broadcastAsync(runJob);
waitForExecution(fut);
@@ -378,11 +373,7 @@ public abstract class ClusterGroupAbstractTest extends GridCommonAbstractTest im
private void run2(AtomicInteger cnt) throws Exception {
Collection<IgniteRunnable> jobs = F.asList(runJob);
- IgniteCompute comp = compute(prj).withAsync();
-
- comp.run(jobs);
-
- ComputeTaskFuture fut = comp.future();
+ IgniteFuture<Void> fut = compute(prj).runAsync(jobs);
waitForExecution(fut);
@@ -398,11 +389,7 @@ public abstract class ClusterGroupAbstractTest extends GridCommonAbstractTest im
* @throws Exception If failed.
*/
private void call1(AtomicInteger cnt) throws Exception {
- IgniteCompute comp = compute(prj).withAsync();
-
- comp.broadcast(calJob);
-
- ComputeTaskFuture fut = comp.future();
+ IgniteFuture<Collection<String>> fut = compute(prj).broadcastAsync(calJob);
waitForExecution(fut);
@@ -418,13 +405,9 @@ public abstract class ClusterGroupAbstractTest extends GridCommonAbstractTest im
* @throws Exception If failed.
*/
private void call2(AtomicInteger cnt) throws Exception {
- IgniteCompute comp = compute(prj).withAsync();
-
Collection<IgniteCallable<String>> jobs = F.asList(calJob);
- comp.call(jobs);
-
- ComputeTaskFuture fut = comp.future();
+ IgniteFuture<Collection<String>> fut = compute(prj).callAsync(jobs);
waitForExecution(fut);
@@ -440,11 +423,7 @@ public abstract class ClusterGroupAbstractTest extends GridCommonAbstractTest im
* @throws Exception If failed.
*/
private void call3(AtomicInteger cnt) throws Exception {
- IgniteCompute comp = compute(prj).withAsync();
-
- comp.apply(clrJob, (String) null);
-
- ComputeTaskFuture fut = comp.future();
+ IgniteFuture<String> fut = compute(prj).applyAsync(clrJob, (String) null);
waitForExecution(fut);
@@ -462,11 +441,7 @@ public abstract class ClusterGroupAbstractTest extends GridCommonAbstractTest im
private void call4(AtomicInteger cnt) throws Exception {
Collection<String> args = F.asList("a", "b", "c");
- IgniteCompute comp = compute(prj).withAsync();
-
- comp.apply(clrJob, args);
-
- ComputeTaskFuture fut = comp.future();
+ IgniteFuture<Collection<String>> fut = compute(prj).applyAsync(clrJob, args);
waitForExecution(fut);
@@ -482,11 +457,7 @@ public abstract class ClusterGroupAbstractTest extends GridCommonAbstractTest im
* @throws Exception If failed.
*/
private void call5(AtomicInteger cnt) throws Exception {
- IgniteCompute comp = compute(prj).withAsync();
-
- comp.broadcast(new TestClosure(), "arg");
-
- ComputeTaskFuture<Collection<String>> fut = comp.future();
+ IgniteFuture<Collection<String>> fut = compute(prj).broadcastAsync(new TestClosure(), "arg");
waitForExecution(fut);
@@ -509,11 +480,7 @@ public abstract class ClusterGroupAbstractTest extends GridCommonAbstractTest im
private void forkjoin1(AtomicInteger cnt) throws Exception {
Collection<String> args = F.asList("a", "b", "c");
- IgniteCompute comp = compute(prj).withAsync();
-
- comp.apply(clrJob, args, rdc);
-
- ComputeTaskFuture fut = comp.future();
+ IgniteFuture fut = compute(prj).applyAsync(clrJob, args, rdc);
waitForExecution(fut);
@@ -531,11 +498,7 @@ public abstract class ClusterGroupAbstractTest extends GridCommonAbstractTest im
private void forkjoin2(AtomicInteger cnt) throws Exception {
Collection<IgniteCallable<String>> jobs = F.asList(calJob);
- IgniteCompute comp = compute(prj).withAsync();
-
- comp.call(jobs, rdc);
-
- ComputeTaskFuture fut = comp.future();
+ IgniteFuture<Object> fut = compute(prj).callAsync(jobs, rdc);
waitForExecution(fut);
@@ -676,26 +639,22 @@ public abstract class ClusterGroupAbstractTest extends GridCommonAbstractTest im
* @throws Exception If test failed.
*/
private void checkActiveFutures() throws Exception {
- IgniteCompute comp = compute(prj).withAsync();
-
- assertEquals(0, comp.activeTaskFutures().size());
+ assertEquals(0, compute(prj).activeTaskFutures().size());
cnt.set(0);
- Collection<ComputeTaskFuture<Object>> futsList = new ArrayList<>();
+ Collection<IgniteFuture<Object>> futsList = new ArrayList<>();
for (int i = 0; i < 10; i++) {
- comp.call(new TestWaitCallable<>());
-
- ComputeTaskFuture<Object> fut = comp.future();
+ IgniteFuture<Object> fut = compute(prj).callAsync(new TestWaitCallable<>());
assertFalse(fut.isDone());
- Map<IgniteUuid, ComputeTaskFuture<Object>> futs = comp.activeTaskFutures();
+ Map<IgniteUuid, ComputeTaskFuture<Object>> futs = compute(prj).activeTaskFutures();
assertEquals(i + 1, futs.size());
- assertTrue(futs.containsKey(fut.getTaskSession().getId()));
+ assertTrue(futs.containsKey(((ComputeTaskFuture)fut).getTaskSession().getId()));
futsList.add(fut);
}
@@ -706,10 +665,10 @@ public abstract class ClusterGroupAbstractTest extends GridCommonAbstractTest im
mux.notifyAll();
}
- for (ComputeTaskFuture<Object> fut : futsList)
+ for (IgniteFuture<Object> fut : futsList)
fut.get();
- assertEquals(0, comp.activeTaskFutures().size());
+ assertEquals(0, compute(prj).activeTaskFutures().size());
}
/**
[10/10] ignite git commit: IGNITE-4475: New async API: now all async
methods are defined explicitly,
IgniteAsyncSupport is deprecated. This closes #1648.
Posted by vo...@apache.org.
IGNITE-4475: New async API: now all async methods are defined explicitly, IgniteAsyncSupport is deprecated. This closes #1648.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/282b334f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/282b334f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/282b334f
Branch: refs/heads/master
Commit: 282b334f76479460613f28347d8cea97ba23f795
Parents: 906b692
Author: tledkov-gridgain <tl...@gridgain.com>
Authored: Mon Mar 27 13:19:47 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Mon Mar 27 13:19:49 2017 +0300
----------------------------------------------------------------------
.../computegrid/ComputeAsyncExample.java | 8 +-
.../ComputeFibonacciContinuationExample.java | 13 +-
.../examples/datagrid/CacheAsyncApiExample.java | 17 +-
.../datastructures/IgniteLockExample.java | 4 +-
.../datastructures/IgniteSemaphoreExample.java | 4 +-
.../examples/ScalarContinuationExample.scala | 10 +-
.../singlesplit/SingleSplitsLoadTest.java | 8 +-
.../ignite/tests/utils/TestTransaction.java | 11 +
.../internal/client/ClientStartNodeTask.java | 10 +-
.../java/org/apache/ignite/IgniteCache.java | 611 +++++++++++-
.../java/org/apache/ignite/IgniteCluster.java | 126 +++
.../java/org/apache/ignite/IgniteCompute.java | 262 ++++-
.../java/org/apache/ignite/IgniteEvents.java | 128 ++-
.../org/apache/ignite/IgniteFileSystem.java | 76 ++
.../java/org/apache/ignite/IgniteMessaging.java | 27 +
.../java/org/apache/ignite/IgniteServices.java | 221 ++++-
.../ignite/internal/IgniteComputeImpl.java | 546 +++++++++--
.../ignite/internal/IgniteEventsImpl.java | 79 ++
.../ignite/internal/IgniteMessagingImpl.java | 65 +-
.../ignite/internal/IgniteServicesImpl.java | 108 +++
.../internal/cluster/ClusterGroupAdapter.java | 2 +-
.../cluster/IgniteClusterAsyncImpl.java | 28 +-
.../internal/cluster/IgniteClusterImpl.java | 24 +-
.../ignite/internal/jdbc2/JdbcConnection.java | 6 +-
.../processors/cache/IgniteCacheProxy.java | 574 ++++++++++-
.../store/GridCacheStoreManagerAdapter.java | 10 +
.../transactions/TransactionProxyImpl.java | 39 +-
.../internal/processors/igfs/IgfsAsyncImpl.java | 43 +-
.../internal/processors/igfs/IgfsImpl.java | 62 +-
.../platform/PlatformAbstractTarget.java | 24 +-
.../platform/PlatformAsyncTarget.java | 44 -
.../platform/PlatformTargetProxy.java | 22 -
.../platform/PlatformTargetProxyImpl.java | 36 +-
.../platform/cache/PlatformCache.java | 218 +++--
.../platform/compute/PlatformCompute.java | 14 +-
...formDotNetEntityFrameworkCacheExtension.java | 8 +-
.../platform/events/PlatformEvents.java | 70 +-
.../platform/messaging/PlatformMessaging.java | 35 +-
.../platform/services/PlatformServices.java | 95 +-
.../transactions/PlatformTransactions.java | 9 +-
.../visor/cache/VisorCacheClearTask.java | 14 +-
.../visor/compute/VisorGatewayTask.java | 6 +-
.../apache/ignite/lang/IgniteAsyncSupport.java | 52 +-
.../ignite/lang/IgniteAsyncSupported.java | 4 +-
.../apache/ignite/transactions/Transaction.java | 22 +
.../IgniteCacheExpiryStoreLoadSelfTest.java | 18 +-
.../internal/ClusterGroupAbstractTest.java | 73 +-
.../ComputeJobCancelWithServiceSelfTest.java | 7 +-
.../internal/GridCancelOnGridStopSelfTest.java | 2 +-
.../GridCancelledJobsMetricsSelfTest.java | 11 +-
.../internal/GridContinuousTaskSelfTest.java | 21 +-
.../GridEventStorageCheckAllEventsSelfTest.java | 12 +-
.../GridFailoverCustomTopologySelfTest.java | 7 +-
.../GridJobMasterLeaveAwareSelfTest.java | 93 +-
.../internal/GridMultipleJobsSelfTest.java | 8 +-
.../ignite/internal/GridReduceSelfTest.java | 9 +-
.../GridTaskCancelSingleNodeSelfTest.java | 7 +-
.../internal/GridTaskExecutionSelfTest.java | 22 +-
.../GridTaskFailoverAffinityRunTest.java | 7 +-
.../GridTaskInstanceExecutionSelfTest.java | 7 +-
.../internal/GridTaskJobRejectSelfTest.java | 7 +-
.../IgniteClientReconnectApiExceptionTest.java | 10 +-
.../IgniteComputeEmptyClusterGroupTest.java | 26 +-
.../cache/CacheConcurrentReadThroughTest.java | 8 +-
.../cache/CacheFutureExceptionSelfTest.java | 6 +-
.../CachePutEventListenerErrorSelfTest.java | 7 +-
.../GridCacheAbstractFailoverSelfTest.java | 6 +-
...cheAbstractFullApiMultithreadedSelfTest.java | 105 +-
.../cache/GridCacheAbstractFullApiSelfTest.java | 876 ++++++++++++++---
.../cache/GridCacheAbstractMetricsSelfTest.java | 52 +-
.../GridCacheAsyncOperationsLimitSelfTest.java | 9 +-
.../GridCacheConcurrentTxMultiNodeTest.java | 10 +-
.../GridCacheInterceptorAbstractSelfTest.java | 31 +-
.../GridCacheMissingCommitVersionSelfTest.java | 6 +-
.../cache/GridCachePutAllFailoverSelfTest.java | 16 +-
.../GridCacheReferenceCleanupSelfTest.java | 15 +-
.../IgniteCacheAbstractStopBusySelfTest.java | 7 +-
.../IgniteCacheConfigVariationsFullApiTest.java | 965 +++++++++++++++++--
.../cache/IgniteCacheInvokeAbstractTest.java | 20 +-
.../IgniteCacheManyAsyncOperationsTest.java | 6 +-
.../cache/IgniteCachePeekModesAbstractTest.java | 35 +-
.../cache/WithKeepBinaryCacheFullApiTest.java | 228 ++---
.../CacheKeepBinaryWithInterceptorTest.java | 16 +-
.../GridCacheBinaryObjectsAbstractSelfTest.java | 75 +-
...eAbstractDataStructuresFailoverSelfTest.java | 7 +-
...ridCacheQueueJoinedNodeSelfAbstractTest.java | 12 +-
.../IgniteCountDownLatchAbstractSelfTest.java | 7 +-
.../IgniteLockAbstractSelfTest.java | 7 +-
.../IgniteSemaphoreAbstractSelfTest.java | 7 +-
...acheAsyncOperationsFailoverAbstractTest.java | 12 +-
.../distributed/CacheAsyncOperationsTest.java | 32 +-
.../CachePutAllFailoverAbstractTest.java | 8 +-
.../GridCacheAbstractJobExecutionTest.java | 15 +-
.../GridCacheBasicOpAbstractTest.java | 38 +-
.../distributed/GridCacheEventAbstractTest.java | 82 +-
.../GridCacheMultiNodeAbstractTest.java | 25 +-
...yMetadataUpdateChangingTopologySelfTest.java | 13 +-
.../IgniteCacheConnectionRecoveryTest.java | 10 +-
...eCacheMessageRecoveryIdleConnectionTest.java | 6 +-
...cOriginatingNodeFailureAbstractSelfTest.java | 6 +-
.../dht/GridCacheGlobalLoadTest.java | 21 +-
.../dht/GridCacheTxNodeFailureSelfTest.java | 12 +-
.../IgniteCachePutRetryAbstractSelfTest.java | 26 +-
.../atomic/IgniteCacheAtomicProtocolTest.java | 34 +-
...idCacheNearOnlyMultiNodeFullApiSelfTest.java | 11 +-
.../GridCachePartitionedLoadCacheSelfTest.java | 9 +-
.../GridCacheEmptyEntriesAbstractSelfTest.java | 21 +-
.../GridCacheContinuousQueryConcurrentTest.java | 5 +-
.../closure/GridClosureProcessorSelfTest.java | 74 +-
...ComputeJobExecutionErrorToLogManualTest.java | 10 +-
...gniteComputeConfigVariationsFullApiTest.java | 533 +++++++++-
.../continuous/GridEventConsumeSelfTest.java | 196 +++-
.../internal/processors/igfs/IgfsMock.java | 41 +
.../processors/igfs/IgfsTaskSelfTest.java | 19 +
...niteMessagingConfigVariationFullApiTest.java | 93 +-
.../GridServiceProcessorAbstractSelfTest.java | 291 +++++-
.../GridServiceProcessorMultiNodeSelfTest.java | 18 +-
.../GridServiceProcessorStopSelfTest.java | 7 +-
.../loadtest/GridSingleExecutionTest.java | 10 +-
.../loadtests/colocation/GridTestMain.java | 7 +-
.../multisplit/GridMultiSplitsLoadTest.java | 7 +-
...ridSingleSplitsNewNodesAbstractLoadTest.java | 8 +-
.../ignite/loadtests/dsi/GridDsiClient.java | 12 +-
...GridJobExecutionLoadTestClientSemaphore.java | 9 +-
...JobExecutionSingleNodeSemaphoreLoadTest.java | 10 +-
.../loadtests/job/GridJobLoadTestSubmitter.java | 7 +-
.../mergesort/GridMergeSortLoadTask.java | 7 +-
.../ignite/messaging/GridMessagingSelfTest.java | 73 +-
.../messaging/IgniteMessagingSendAsyncTest.java | 83 +-
...idSessionFutureWaitJobAttributeSelfTest.java | 7 +-
...GridSessionSetJobAttributeOrderSelfTest.java | 8 +-
...sionSetJobAttributeWaitListenerSelfTest.java | 7 +-
.../GridSessionSetTaskAttributeSelfTest.java | 7 +-
...GridSessionTaskWaitJobAttributeSelfTest.java | 7 +-
.../GridSessionWaitAttributeSelfTest.java | 9 +-
.../cache/GridAbstractCacheStoreSelfTest.java | 11 +
.../junits/common/GridCommonAbstractTest.java | 26 +-
.../multijvm/IgniteCacheProcessProxy.java | 172 ++++
.../multijvm/IgniteClusterProcessProxy.java | 13 +
.../multijvm/IgniteEventsProcessProxy.java | 31 +
...niteCacheLockPartitionOnAffinityRunTest.java | 6 +-
.../cache/IgniteCacheQueryLoadSelfTest.java | 20 +-
.../cpp/jni/include/ignite/jni/exports.h | 2 -
.../platforms/cpp/jni/include/ignite/jni/java.h | 4 -
modules/platforms/cpp/jni/project/vs/module.def | 2 -
modules/platforms/cpp/jni/src/exports.cpp | 8 -
modules/platforms/cpp/jni/src/java.cpp | 20 -
.../scalar/pimps/ScalarProjectionPimp.scala | 24 +-
...gniteProjectionStartStopRestartSelfTest.java | 6 +-
.../commands/tasks/VisorTasksCommandSpec.scala | 22 +-
.../IgniteAtomicInvokeRetryBenchmark.java | 12 +-
.../failover/IgniteAtomicRetriesBenchmark.java | 12 +-
.../IgniteFailoverAbstractBenchmark.java | 18 +-
...IgniteTransactionalInvokeRetryBenchmark.java | 10 +-
...IgniteTransactionalWriteInvokeBenchmark.java | 16 +-
.../IgniteTransactionalWriteReadBenchmark.java | 12 +-
156 files changed, 6806 insertions(+), 2268 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeAsyncExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeAsyncExample.java b/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeAsyncExample.java
index e8321a5..8064ace 100644
--- a/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeAsyncExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeAsyncExample.java
@@ -49,21 +49,19 @@ public class ComputeAsyncExample {
System.out.println("Compute asynchronous example started.");
// Enable asynchronous mode.
- IgniteCompute compute = ignite.compute().withAsync();
+ IgniteCompute compute = ignite.compute();
Collection<IgniteFuture<?>> futs = new ArrayList<>();
// Iterate through all words in the sentence and create runnable jobs.
for (final String word : "Print words using runnable".split(" ")) {
// Execute runnable on some node.
- compute.run(new IgniteRunnable() {
+ futs.add(compute.runAsync(new IgniteRunnable() {
@Override public void run() {
System.out.println();
System.out.println(">>> Printing '" + word + "' on this node from ignite job.");
}
- });
-
- futs.add(compute.future());
+ }));
}
// Wait for completion of all futures.
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeFibonacciContinuationExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeFibonacciContinuationExample.java b/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeFibonacciContinuationExample.java
index 6642e9d..0fe12f1 100644
--- a/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeFibonacciContinuationExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/computegrid/ComputeFibonacciContinuationExample.java
@@ -27,7 +27,6 @@ import org.apache.ignite.Ignition;
import org.apache.ignite.cluster.ClusterGroup;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.compute.ComputeJobContext;
-import org.apache.ignite.compute.ComputeTaskFuture;
import org.apache.ignite.examples.ExampleNodeStartup;
import org.apache.ignite.lang.IgniteClosure;
import org.apache.ignite.lang.IgniteFuture;
@@ -142,13 +141,12 @@ public final class ComputeFibonacciContinuationExample {
ClusterGroup p = ignite.cluster().forPredicate(nodeFilter);
- IgniteCompute compute = ignite.compute(p).withAsync();
+ IgniteCompute compute = ignite.compute(p);
// If future is not cached in node-local-map, cache it.
if (fut1 == null) {
- compute.apply(new ContinuationFibonacciClosure(nodeFilter), n - 1);
-
- ComputeTaskFuture<BigInteger> futVal = compute.future();
+ IgniteFuture<BigInteger> futVal = compute.applyAsync(
+ new ContinuationFibonacciClosure(nodeFilter), n - 1);
fut1 = locMap.putIfAbsent(n - 1, futVal);
@@ -158,9 +156,8 @@ public final class ComputeFibonacciContinuationExample {
// If future is not cached in node-local-map, cache it.
if (fut2 == null) {
- compute.apply(new ContinuationFibonacciClosure(nodeFilter), n - 2);
-
- ComputeTaskFuture<BigInteger> futVal = compute.<BigInteger>future();
+ IgniteFuture<BigInteger> futVal = compute.applyAsync(
+ new ContinuationFibonacciClosure(nodeFilter), n - 2);
fut2 = locMap.putIfAbsent(n - 2, futVal);
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheAsyncApiExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheAsyncApiExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheAsyncApiExample.java
index 3699361..69b23e7 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheAsyncApiExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheAsyncApiExample.java
@@ -53,27 +53,18 @@ public class CacheAsyncApiExample {
// Auto-close cache at the end of the example.
try (IgniteCache<Integer, String> cache = ignite.getOrCreateCache(CACHE_NAME)) {
- // Enable asynchronous mode.
- IgniteCache<Integer, String> asyncCache = cache.withAsync();
-
Collection<IgniteFuture<?>> futs = new ArrayList<>();
// Execute several puts asynchronously.
- for (int i = 0; i < 10; i++) {
- asyncCache.put(i, String.valueOf(i));
-
- futs.add(asyncCache.future());
- }
+ for (int i = 0; i < 10; i++)
+ futs.add(cache.putAsync(i, String.valueOf(i)));
// Wait for completion of all futures.
for (IgniteFuture<?> fut : futs)
fut.get();
- // Execute get operation asynchronously.
- asyncCache.get(1);
-
- // Asynchronously wait for result.
- asyncCache.<String>future().listen(new IgniteInClosure<IgniteFuture<String>>() {
+ // Execute get operation asynchronously and wait for result.
+ cache.getAsync(1).listen(new IgniteInClosure<IgniteFuture<String>>() {
@Override public void apply(IgniteFuture<String> fut) {
System.out.println("Get operation completed [value=" + fut.get() + ']');
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/examples/src/main/java/org/apache/ignite/examples/datastructures/IgniteLockExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datastructures/IgniteLockExample.java b/examples/src/main/java/org/apache/ignite/examples/datastructures/IgniteLockExample.java
index 1f84787..ba035ae 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datastructures/IgniteLockExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datastructures/IgniteLockExample.java
@@ -87,11 +87,11 @@ public class IgniteLockExample {
// Start consumers on all cluster nodes.
for (int i = 0; i < NUM_CONSUMERS; i++)
- ignite.compute().withAsync().run(new Consumer(reentrantLockName));
+ ignite.compute().runAsync(new Consumer(reentrantLockName));
// Start producers on all cluster nodes.
for (int i = 0; i < NUM_PRODUCERS; i++)
- ignite.compute().withAsync().run(new Producer(reentrantLockName));
+ ignite.compute().runAsync(new Producer(reentrantLockName));
System.out.println("Master node is waiting for all other nodes to finish...");
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/examples/src/main/java/org/apache/ignite/examples/datastructures/IgniteSemaphoreExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datastructures/IgniteSemaphoreExample.java b/examples/src/main/java/org/apache/ignite/examples/datastructures/IgniteSemaphoreExample.java
index 1c078b0..12d1eab 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datastructures/IgniteSemaphoreExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datastructures/IgniteSemaphoreExample.java
@@ -67,11 +67,11 @@ public class IgniteSemaphoreExample {
// Start consumers on all cluster nodes.
for (int i = 0; i < NUM_CONSUMERS; i++)
- ignite.compute().withAsync().run(new Consumer(semaphoreName));
+ ignite.compute().runAsync(new Consumer(semaphoreName));
// Start producers on all cluster nodes.
for (int i = 0; i < NUM_PRODUCERS; i++)
- ignite.compute().withAsync().run(new Producer(semaphoreName));
+ ignite.compute().runAsync(new Producer(semaphoreName));
System.out.println("Master node is waiting for all other nodes to finish...");
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarContinuationExample.scala
----------------------------------------------------------------------
diff --git a/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarContinuationExample.scala b/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarContinuationExample.scala
index 203f0b7..62b3a13 100644
--- a/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarContinuationExample.scala
+++ b/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarContinuationExample.scala
@@ -117,14 +117,12 @@ class FibonacciClosure (
// Group that excludes node with id passed in constructor if others exists.
val prj = if (ignite$.cluster().nodes().size() > 1) ignite$.cluster().forOthers(excludeNode) else ignite$.cluster().forNode(excludeNode)
- val comp = ignite$.compute(prj).withAsync()
+ val comp = ignite$.compute(prj)
// If future is not cached in node-local store, cache it.
// Note recursive execution!
if (fut1 == null) {
- comp.apply(new FibonacciClosure(excludeNodeId), n - 1)
-
- val futVal = comp.future[BigInteger]()
+ val futVal = comp.applyAsync(new FibonacciClosure(excludeNodeId), n - 1)
fut1 = store.putIfAbsent(n - 1, futVal)
@@ -134,9 +132,7 @@ class FibonacciClosure (
// If future is not cached in node-local store, cache it.
if (fut2 == null) {
- comp.apply(new FibonacciClosure(excludeNodeId), n - 2)
-
- val futVal = comp.future[BigInteger]()
+ val futVal = comp.applyAsync(new FibonacciClosure(excludeNodeId), n - 2)
fut2 = store.putIfAbsent(n - 2, futVal)
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/aop/src/test/java/org/apache/loadtests/direct/singlesplit/SingleSplitsLoadTest.java
----------------------------------------------------------------------
diff --git a/modules/aop/src/test/java/org/apache/loadtests/direct/singlesplit/SingleSplitsLoadTest.java b/modules/aop/src/test/java/org/apache/loadtests/direct/singlesplit/SingleSplitsLoadTest.java
index 402bdf4..b42ff71 100644
--- a/modules/aop/src/test/java/org/apache/loadtests/direct/singlesplit/SingleSplitsLoadTest.java
+++ b/modules/aop/src/test/java/org/apache/loadtests/direct/singlesplit/SingleSplitsLoadTest.java
@@ -18,7 +18,6 @@
package org.apache.loadtests.direct.singlesplit;
import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCompute;
import org.apache.ignite.IgniteException;
import org.apache.ignite.compute.ComputeTaskFuture;
import org.apache.ignite.configuration.IgniteConfiguration;
@@ -104,11 +103,8 @@ public class SingleSplitsLoadTest extends GridCommonAbstractTest {
try {
int levels = 20;
- IgniteCompute comp = ignite.compute().withAsync();
-
- comp.execute(new SingleSplitTestTask(), levels);
-
- ComputeTaskFuture<Integer> fut = comp.future();
+ ComputeTaskFuture<Integer> fut = ignite.compute().executeAsync(
+ new SingleSplitTestTask(), levels);
int res = fut.get();
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/cassandra/store/src/test/java/org/apache/ignite/tests/utils/TestTransaction.java
----------------------------------------------------------------------
diff --git a/modules/cassandra/store/src/test/java/org/apache/ignite/tests/utils/TestTransaction.java b/modules/cassandra/store/src/test/java/org/apache/ignite/tests/utils/TestTransaction.java
index 5f3ec69..4a03d25 100644
--- a/modules/cassandra/store/src/test/java/org/apache/ignite/tests/utils/TestTransaction.java
+++ b/modules/cassandra/store/src/test/java/org/apache/ignite/tests/utils/TestTransaction.java
@@ -17,6 +17,7 @@
package org.apache.ignite.tests.utils;
+import org.apache.ignite.IgniteException;
import org.apache.ignite.lang.IgniteAsyncSupport;
import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.lang.IgniteUuid;
@@ -106,6 +107,11 @@ public class TestTransaction implements Transaction {
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Void> commitAsync() throws IgniteException {
+ return null;
+ }
+
+ /** {@inheritDoc} */
@Override public void close() {
// No-op.
}
@@ -129,4 +135,9 @@ public class TestTransaction implements Transaction {
@Override public void rollback() {
// No-op.
}
+
+ /** {@inheritDoc} */
+ @Override public IgniteFuture<Void> rollbackAsync() throws IgniteException {
+ return null;
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientStartNodeTask.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientStartNodeTask.java b/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientStartNodeTask.java
index 48275e7..b3f69a3 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientStartNodeTask.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientStartNodeTask.java
@@ -25,7 +25,6 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCompute;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.compute.ComputeJobResult;
import org.apache.ignite.compute.ComputeJobResultPolicy;
@@ -159,14 +158,9 @@ public class ClientStartNodeTask extends TaskSingleJobSplitAdapter<String, Integ
private static void changeTopology(Ignite parent, int add, int rmv, String type) {
Collection<ComputeTaskFuture<?>> tasks = new ArrayList<>();
- IgniteCompute comp = parent.compute().withAsync();
-
// Start nodes in parallel.
- while (add-- > 0) {
- comp.execute(ClientStartNodeTask.class, type);
-
- tasks.add(comp.future());
- }
+ while (add-- > 0)
+ tasks.add(parent.compute().executeAsync(ClientStartNodeTask.class, type));
for (ComputeTaskFuture<?> task : tasks)
task.get();
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
index d7bccf5..33e0e8c 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
@@ -89,17 +89,13 @@ import org.jetbrains.annotations.Nullable;
* <h1 class="header">Transactions</h1>
* Cache API supports transactions. You can group and set of cache methods within a transaction
* to provide ACID-compliant behavior. See {@link IgniteTransactions} for more information.
- * <h1 class="header">Asynchronous Mode</h1>
- * Cache API supports asynchronous mode via {@link IgniteAsyncSupport} functionality. To turn on
- * asynchronous mode invoke {@link #withAsync()} method. Once asynchronous mode is enabled,
- * all methods with {@link IgniteAsyncSupported @IgniteAsyncSupported} annotation will be executed
- * asynchronously.
*
* @param <K> Cache key type.
* @param <V> Cache value type.
*/
public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncSupport {
/** {@inheritDoc} */
+ @Deprecated
@Override public IgniteCache<K, V> withAsync();
/** {@inheritDoc} */
@@ -191,6 +187,19 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
public void loadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) throws CacheException;
/**
+ * Asynchronously executes {@link #localLoadCache(IgniteBiPredicate, Object...)} on all cache nodes.
+ *
+ * @param p Optional predicate (may be {@code null}). If provided, will be used to
+ * filter values loaded from storage before they are put into cache.
+ * @param args Optional user arguments to be passed into
+ * {@link CacheStore#loadCache(IgniteBiInClosure, Object...)} method.
+ * @return a Future representing pending completion of the cache loading.
+ * @throws CacheException If loading failed.
+ */
+ public IgniteFuture<Void> loadCacheAsync(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args)
+ throws CacheException;
+
+ /**
* Delegates to {@link CacheStore#loadCache(IgniteBiInClosure,Object...)} method
* to load state from the underlying persistent storage. The loaded values
* will then be given to the optionally passed in predicate, and, if the predicate returns
@@ -215,6 +224,31 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
public void localLoadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) throws CacheException;
/**
+ * Asynchronously loads state from the underlying persistent storage by delegating
+ * to {@link CacheStore#loadCache(IgniteBiInClosure,Object...)} method. The loaded values
+ * will then be given to the optionally passed in predicate, and, if the predicate returns
+ * {@code true}, will be stored in cache. If predicate is {@code null}, then
+ * all loaded values will be stored in cache.
+ * <p>
+ * Note that this method does not receive keys as a parameter, so it is up to
+ * {@link CacheStore} implementation to provide all the data to be loaded.
+ * <p>
+ * This method is not transactional and may end up loading a stale value into
+ * cache if another thread has updated the value immediately after it has been
+ * loaded. It is mostly useful when pre-loading the cache from underlying
+ * data store before start, or for read-only caches.
+ *
+ * @param p Optional predicate (may be {@code null}). If provided, will be used to
+ * filter values to be put into cache.
+ * @param args Optional user arguments to be passed into
+ * {@link CacheStore#loadCache(IgniteBiInClosure, Object...)} method.
+ * @return a Future representing pending completion of the cache loading.
+ * @throws CacheException If loading failed.
+ */
+ public IgniteFuture<Void> localLoadCacheAsync(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args)
+ throws CacheException;
+
+ /**
* Stores given key-value pair in cache only if cache had no previous mapping for it. If cache
* previously contained value for the given key, then this value is returned.
* In case of {@link CacheMode#PARTITIONED} or {@link CacheMode#REPLICATED} caches,
@@ -247,6 +281,36 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
public V getAndPutIfAbsent(K key, V val) throws CacheException;
/**
+ * Asynchronously stores given key-value pair in cache only if cache had no previous mapping for it. If cache
+ * previously contained value for the given key, then this value is returned.
+ * In case of {@link CacheMode#PARTITIONED} or {@link CacheMode#REPLICATED} caches,
+ * the value will be loaded from the primary node, which in its turn may load the value
+ * from the swap storage, and consecutively, if it's not in swap,
+ * from the underlying persistent storage. If value has to be loaded from persistent
+ * storage, {@link CacheStore#load(Object)} method will be used.
+ * <p>
+ * If the returned value is not needed, method {@link #putIfAbsentAsync(Object, Object)} should
+ * always be used instead of this one to avoid the overhead associated with returning of the
+ * previous value.
+ * <p>
+ * If write-through is enabled, the stored value will be persisted to {@link CacheStore}
+ * via {@link CacheStore#write(javax.cache.Cache.Entry)} method.
+ * <h2 class="header">Transactions</h2>
+ * This method is transactional and will enlist the entry into ongoing transaction
+ * if there is one.
+ *
+ * @param key Key to store in cache.
+ * @param val Value to be associated with the given key.
+ * @return a Future representing pending completion of the operation.
+ * @throws NullPointerException If either key or value are {@code null}.
+ * @throws CacheException If put operation failed.
+ * @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
+ * @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
+ * @throws TransactionHeuristicException If operation performs within transaction that entered an unknown state.
+ */
+ public IgniteFuture<V> getAndPutIfAbsentAsync(K key, V val) throws CacheException;
+
+ /**
* Creates a {@link Lock} instance associated with passed key.
* This method does not acquire lock immediately, you have to call appropriate method on returned instance.
* Returned lock does not support {@link Lock#newCondition()} method,
@@ -363,6 +427,7 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
* This method does not participate in any transactions.
*
* @param key Entry key.
+ * @param peekModes Peek modes.
* @return Peeked value, or {@code null} if not found.
* @throws NullPointerException If key is {@code null}.
*/
@@ -388,11 +453,25 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
*
* @param peekModes Optional peek modes. If not provided, then total cache size is returned.
* @return Cache size across all nodes.
+ * @throws CacheException On error.
*/
@IgniteAsyncSupported
public int size(CachePeekMode... peekModes) throws CacheException;
/**
+ * Asynchronously gets the number of all entries cached across all nodes. By default,
+ * if {@code peekModes} value isn't defined, only size of primary copies across all nodes will be returned.
+ * This behavior is identical to calling this method with {@link CachePeekMode#PRIMARY} peek mode.
+ * <p>
+ * NOTE: this operation is distributed and will query all participating nodes for their cache sizes.
+ *
+ * @param peekModes Optional peek modes. If not provided, then total cache size is returned.
+ * @return a Future representing pending completion of the operation.
+ * @throws CacheException On error.
+ */
+ public IgniteFuture<Integer> sizeAsync(CachePeekMode... peekModes) throws CacheException;
+
+ /**
* Gets the number of all entries cached across all nodes as a long value. By default, if {@code peekModes} value
* isn't defined, only size of primary copies across all nodes will be returned. This behavior is identical to
* calling this method with {@link CachePeekMode#PRIMARY} peek mode.
@@ -401,11 +480,25 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
*
* @param peekModes Optional peek modes. If not provided, then total cache size is returned.
* @return Cache size across all nodes.
+ * @throws CacheException On error.
*/
@IgniteAsyncSupported
public long sizeLong(CachePeekMode... peekModes) throws CacheException;
/**
+ * Asynchronously gets the number of all entries cached across all nodes as a long value. By default,
+ * if {@code peekModes} value isn't defined, only size of primary copies across all nodes will be returned.
+ * This behavior is identical to calling this method with {@link CachePeekMode#PRIMARY} peek mode.
+ * <p>
+ * NOTE: this operation is distributed and will query all participating nodes for their cache sizes.
+ *
+ * @param peekModes Optional peek modes. If not provided, then total cache size is returned.
+ * @return a Future representing pending completion of the operation.
+ * @throws CacheException On error.
+ */
+ public IgniteFuture<Long> sizeLongAsync(CachePeekMode... peekModes) throws CacheException;
+
+ /**
* Gets the number of all entries cached in a partition as a long value. By default, if {@code peekModes} value
* isn't defined, only size of primary copies across all nodes will be returned. This behavior is identical to
* calling this method with {@link CachePeekMode#PRIMARY} peek mode.
@@ -414,12 +507,27 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
*
* @param partition partition.
* @param peekModes Optional peek modes. If not provided, then total partition cache size is returned.
- * @return Partion cache size across all nodes.
+ * @return Partition cache size across all nodes.
+ * @throws CacheException On error.
*/
@IgniteAsyncSupported
public long sizeLong(int partition, CachePeekMode... peekModes) throws CacheException;
/**
+ * Asynchronously gets the number of all entries cached in a partition as a long value. By default, if {@code peekModes} value
+ * isn't defined, only size of primary copies across all nodes will be returned. This behavior is identical to
+ * calling this method with {@link CachePeekMode#PRIMARY} peek mode.
+ * <p>
+ * NOTE: this operation is distributed and will query all participating nodes for their partition cache sizes.
+ *
+ * @param partition partition.
+ * @param peekModes Optional peek modes. If not provided, then total partition cache size is returned.
+ * @return a Future representing pending completion of the operation.
+ * @throws CacheException On error.
+ */
+ public IgniteFuture<Long> sizeLongAsync(int partition, CachePeekMode... peekModes) throws CacheException;
+
+ /**
* Gets the number of all entries cached on this node. By default, if {@code peekModes} value isn't defined,
* only size of primary copies will be returned. This behavior is identical to calling this method with
* {@link CachePeekMode#PRIMARY} peek mode.
@@ -466,6 +574,20 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
Object... args);
/**
+ * Asynchronously version of the {@link #invokeAll(Set, EntryProcessor, Object...)} method.
+ *
+ * @param map Map containing keys and entry processors to be applied to values.
+ * @param args Additional arguments to pass to the {@link EntryProcessor}.
+ * @return a Future representing pending completion of the operation. See more about future result
+ * at the {@link #invokeAll(Map, Object...)}.
+ * @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
+ * @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
+ * @throws TransactionHeuristicException If operation performs within transaction that entered an unknown state.
+ */
+ public <T> IgniteFuture<Map<K, EntryProcessorResult<T>>> invokeAllAsync(
+ Map<? extends K, ? extends EntryProcessor<K, V, T>> map, Object... args);
+
+ /**
* {@inheritDoc}
* @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
* @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
@@ -475,6 +597,18 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
@Override public V get(K key);
/**
+ * Asynchronously gets an entry from the cache.
+ * <p>
+ * If the cache is configured to use read-through, and a future result would be null
+ * because the entry is missing from the cache, the Cache's {@link CacheLoader}
+ * is called in an attempt to load the entry.
+ *
+ * @param key Key.
+ * @return a Future representing pending completion of the operation.
+ */
+ public IgniteFuture<V> getAsync(K key);
+
+ /**
* Gets an entry from the cache.
* <p>
* If the cache is configured to use read-through, and get would return null
@@ -497,6 +631,27 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
public CacheEntry<K, V> getEntry(K key);
/**
+ * Asynchronously gets an entry from the cache.
+ * <p>
+ * If the cache is configured to use read-through, and a future result would be null
+ * because the entry is missing from the cache, the Cache's {@link CacheLoader}
+ * is called in an attempt to load the entry.
+ *
+ * @param key The key whose associated value is to be returned.
+ * @return a Future representing pending completion of the operation.
+ * @throws IllegalStateException If the cache is {@link #isClosed()}.
+ * @throws NullPointerException If the key is {@code null}.
+ * @throws CacheException If there is a problem fetching the value.
+ * @throws ClassCastException If the implementation is configured to perform
+ * runtime-type-checking, and the key or value types are incompatible with those that have been
+ * configured for the {@link Cache}.
+ * @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
+ * @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
+ * @throws TransactionHeuristicException If operation performs within transaction that entered an unknown state.
+ */
+ public IgniteFuture<CacheEntry<K, V>> getEntryAsync(K key);
+
+ /**
* {@inheritDoc}
* @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
* @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
@@ -506,6 +661,24 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
@Override public Map<K, V> getAll(Set<? extends K> keys);
/**
+ * Asynchronously gets a collection of entries from the {@link Cache}, returning them as
+ * {@link Map} of the values associated with the set of keys requested.
+ * <p>
+ * If the cache is configured read-through, and a future result for a key would
+ * be null because an entry is missing from the cache, the Cache's
+ * {@link CacheLoader} is called in an attempt to load the entry. If an
+ * entry cannot be loaded for a given key, the key will not be present in
+ * the returned Map.
+ *
+ * @param keys Keys set.
+ * @return a Future representing pending completion of the operation.
+ * @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
+ * @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
+ * @throws TransactionHeuristicException If operation performs within transaction that entered an unknown state.
+ */
+ public IgniteFuture<Map<K, V>> getAllAsync(Set<? extends K> keys);
+
+ /**
* Gets a collection of entries from the {@link Cache}.
* <p>
* If the cache is configured read-through, and a get for a key would
@@ -531,6 +704,29 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
public Collection<CacheEntry<K, V>> getEntries(Set<? extends K> keys);
/**
+ * Asynchronously gets a collection of entries from the {@link Cache}.
+ * <p>
+ * If the cache is configured read-through, and a future result for a key would
+ * be null because an entry is missing from the cache, the Cache's
+ * {@link CacheLoader} is called in an attempt to load the entry. If an
+ * entry cannot be loaded for a given key, the key will not be present in
+ * the returned Collection.
+ *
+ * @param keys The keys whose associated values are to be returned.
+ * @return a Future representing pending completion of the operation.
+ * @throws NullPointerException If keys is null or if keys contains a {@code null}.
+ * @throws IllegalStateException If the cache is {@link #isClosed()}.
+ * @throws CacheException If there is a problem fetching the values.
+ * @throws ClassCastException If the implementation is configured to perform
+ * runtime-type-checking, and the key or value types are incompatible with those that have been
+ * configured for the {@link Cache}.
+ * @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
+ * @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
+ * @throws TransactionHeuristicException If operation performs within transaction that entered an unknown state.
+ */
+ public IgniteFuture<Collection<CacheEntry<K, V>>> getEntriesAsync(Set<? extends K> keys);
+
+ /**
* Gets values from cache. Will bypass started transaction, if any, i.e. will not enlist entries
* and will not lock any keys if pessimistic transaction is started by thread.
*
@@ -541,6 +737,15 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
public Map<K, V> getAllOutTx(Set<? extends K> keys);
/**
+ * Asynchronously gets values from cache. Will bypass started transaction, if any, i.e. will not enlist entries
+ * and will not lock any keys if pessimistic transaction is started by thread.
+ *
+ * @param keys The keys whose associated values are to be returned.
+ * @return a Future representing pending completion of the operation.
+ */
+ public IgniteFuture<Map<K, V>> getAllOutTxAsync(Set<? extends K> keys);
+
+ /**
* {@inheritDoc}
* @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
* @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
@@ -550,6 +755,21 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
@Override public boolean containsKey(K key);
/**
+ * Asynchronously determines if the {@link Cache} contains an entry for the specified key.
+ * <p>
+ * More formally, future result is <tt>true</tt> if and only if this cache contains a
+ * mapping for a key <tt>k</tt> such that <tt>key.equals(k)</tt>.
+ * (There can be at most one such mapping.)
+ *
+ * @param key Key.
+ * @return a Future representing pending completion of the operation.
+ * @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
+ * @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
+ * @throws TransactionHeuristicException If operation performs within transaction that entered an unknown state.
+ */
+ public IgniteFuture<Boolean> containsKeyAsync(K key);
+
+ /**
* Determines if the {@link Cache} contains entries for the specified keys.
*
* @param keys Key whose presence in this cache is to be tested.
@@ -562,6 +782,17 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
public boolean containsKeys(Set<? extends K> keys);
/**
+ * Asynchronously determines if the {@link Cache} contains entries for the specified keys.
+ *
+ * @param keys Key whose presence in this cache is to be tested.
+ * @return a Future representing pending completion of the operation.
+ * @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
+ * @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
+ * @throws TransactionHeuristicException If operation performs within transaction that entered an unknown state.
+ */
+ public IgniteFuture<Boolean> containsKeysAsync(Set<? extends K> keys);
+
+ /**
* {@inheritDoc}
* @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
* @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
@@ -571,6 +802,23 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
@Override public void put(K key, V val);
/**
+ * Asynchronously associates the specified value with the specified key in the cache.
+ * <p>
+ * If the {@link Cache} previously contained a mapping for the key, the old
+ * value is replaced by the specified value. (A cache <tt>c</tt> is said to
+ * contain a mapping for a key <tt>k</tt> if and only if {@link
+ * #containsKey(Object) c.containsKey(k)} would return <tt>true</tt>.)
+ *
+ * @param key Key.
+ * @param val Value.
+ * @return a Future representing pending completion of the operation.
+ * @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
+ * @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
+ * @throws TransactionHeuristicException If operation performs within transaction that entered an unknown state.
+ */
+ public IgniteFuture<Void> putAsync(K key, V val);
+
+ /**
* {@inheritDoc}
* @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
* @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
@@ -580,6 +828,28 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
@Override public V getAndPut(K key, V val);
/**
+ * Asynchronously associates the specified value with the specified key in this cache,
+ * returning an existing value if one existed as the future result.
+ * <p>
+ * If the cache previously contained a mapping for
+ * the key, the old value is replaced by the specified value. (A cache
+ * <tt>c</tt> is said to contain a mapping for a key <tt>k</tt> if and only
+ * if {@link #containsKey(Object) c.containsKey(k)} would return
+ * <tt>true</tt>.)
+ * <p>
+ * The previous value is returned as the future result, or future result is null if there was no value associated
+ * with the key previously.
+ *
+ * @param key Key.
+ * @param val Value.
+ * @return a Future representing pending completion of the operation.
+ * @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
+ * @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
+ * @throws TransactionHeuristicException If operation performs within transaction that entered an unknown state.
+ */
+ public IgniteFuture<V> getAndPutAsync(K key, V val);
+
+ /**
* {@inheritDoc}
* @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
* @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
@@ -589,6 +859,31 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
@Override public void putAll(Map<? extends K, ? extends V> map);
/**
+ * Asynchronously copies all of the entries from the specified map to the {@link Cache}.
+ * <p>
+ * The effect of this call is equivalent to that of calling
+ * {@link #putAsync(Object, Object)} putAsync(k, v)} on this cache once for each mapping
+ * from key <tt>k</tt> to value <tt>v</tt> in the specified map.
+ * <p>
+ * The order in which the individual puts occur is undefined.
+ * <p>
+ * The behavior of this operation is undefined if entries in the cache
+ * corresponding to entries in the map are modified or removed while this
+ * operation is in progress. or if map is modified while the operation is in
+ * progress.
+ * <p>
+ * In Default Consistency mode, individual puts occur atomically but not
+ * the entire putAll. Listeners may observe individual updates.
+ *
+ * @param map Map containing keys and values to put into the cache.
+ * @return a Future representing pending completion of the operation.
+ * @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
+ * @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
+ * @throws TransactionHeuristicException If operation performs within transaction that entered an unknown state.
+ */
+ public IgniteFuture<Void> putAllAsync(Map<? extends K, ? extends V> map);
+
+ /**
* {@inheritDoc}
* @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
* @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
@@ -598,6 +893,19 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
@Override public boolean putIfAbsent(K key, V val);
/**
+ * Asynchronously associates the specified key with the given value if it is
+ * not already associated with a value.
+ *
+ * @param key Key.
+ * @param val Value.
+ * @return a Future representing pending completion of the operation.
+ * @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
+ * @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
+ * @throws TransactionHeuristicException If operation performs within transaction that entered an unknown state.
+ */
+ public IgniteFuture<Boolean> putIfAbsentAsync(K key, V val);
+
+ /**
* {@inheritDoc}
* @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
* @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
@@ -607,6 +915,28 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
@Override public boolean remove(K key);
/**
+ * Asynchronously removes the mapping for a key from this cache if it is present.
+ * <p>
+ * More formally, if this cache contains a mapping from key <tt>k</tt> to
+ * value <tt>v</tt> such that
+ * <code>(key==null ? k==null : key.equals(k))</code>, that mapping is removed.
+ * (The cache can contain at most one such mapping.)
+ *
+ * <p>A future result is <tt>true</tt> if this cache previously associated the key,
+ * or <tt>false</tt> if the cache contained no mapping for the key.
+ * <p>
+ * The cache will not contain a mapping for the specified key once the
+ * returned future is completed.
+ *
+ * @param key Key.
+ * @return a Future representing pending completion of the operation.
+ * @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
+ * @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
+ * @throws TransactionHeuristicException If operation performs within transaction that entered an unknown state.
+ */
+ public IgniteFuture<Boolean> removeAsync(K key);
+
+ /**
* {@inheritDoc}
* @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
* @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
@@ -616,6 +946,19 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
@Override public boolean remove(K key, V oldVal);
/**
+ * Asynchronously removes the mapping for a key only if currently mapped to the
+ * given value.
+ *
+ * @param key Key.
+ * @param oldVal Old value.
+ * @return a Future representing pending completion of the operation.
+ * @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
+ * @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
+ * @throws TransactionHeuristicException If operation performs within transaction that entered an unknown state.
+ */
+ public IgniteFuture<Boolean> removeAsync(K key, V oldVal);
+
+ /**
* {@inheritDoc}
* @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
* @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
@@ -625,6 +968,18 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
@Override public V getAndRemove(K key);
/**
+ * Asynchronously removes the entry for a key only if currently mapped to some
+ * value.
+ *
+ * @param key Key.
+ * @return a Future representing pending completion of the operation.
+ * @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
+ * @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
+ * @throws TransactionHeuristicException If operation performs within transaction that entered an unknown state.
+ */
+ public IgniteFuture<V> getAndRemoveAsync(K key);
+
+ /**
* {@inheritDoc}
* @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
* @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
@@ -634,6 +989,19 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
@Override public boolean replace(K key, V oldVal, V newVal);
/**
+ * Asynchronous version of the {@link #replace(Object, Object, Object)}.
+ *
+ * @param key Key.
+ * @param oldVal Old value.
+ * @param newVal New value.
+ * @return a Future representing pending completion of the operation.
+ * @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
+ * @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
+ * @throws TransactionHeuristicException If operation performs within transaction that entered an unknown state.
+ */
+ public IgniteFuture<Boolean> replaceAsync(K key, V oldVal, V newVal);
+
+ /**
* {@inheritDoc}
* @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
* @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
@@ -643,6 +1011,19 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
@Override public boolean replace(K key, V val);
/**
+ * Asynchronously replaces the entry for a key only if currently mapped to a
+ * given value.
+ *
+ * @param key Key.
+ * @param val Value.
+ * @return a Future representing pending completion of the operation.
+ * @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
+ * @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
+ * @throws TransactionHeuristicException If operation performs within transaction that entered an unknown state.
+ */
+ public IgniteFuture<Boolean> replaceAsync(K key, V val);
+
+ /**
* {@inheritDoc}
* @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
* @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
@@ -652,6 +1033,19 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
@Override public V getAndReplace(K key, V val);
/**
+ * Asynchronously replaces the value for a given key if and only if there is a
+ * value currently mapped by the key.
+ *
+ * @param key Key.
+ * @param val Value.
+ * @return a Future representing pending completion of the operation.
+ * @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
+ * @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
+ * @throws TransactionHeuristicException If operation performs within transaction that entered an unknown state.
+ */
+ public IgniteFuture<V> getAndReplaceAsync(K key, V val);
+
+ /**
* {@inheritDoc}
* @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
* @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
@@ -661,6 +1055,26 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
@Override public void removeAll(Set<? extends K> keys);
/**
+ * Asynchronously removes entries for the specified keys.
+ * <p>
+ * The order in which the individual entries are removed is undefined.
+ * <p>
+ * For every entry in the key set, the following are called:
+ * <ul>
+ * <li>any registered {@link CacheEntryRemovedListener}s</li>
+ * <li>if the cache is a write-through cache, the {@link CacheWriter}</li>
+ * </ul>
+ * If the key set is empty, the {@link CacheWriter} is not called.
+ *
+ * @param keys Keys set.
+ * @return a Future representing pending completion of the operation.
+ * @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
+ * @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
+ * @throws TransactionHeuristicException If operation performs within transaction that entered an unknown state.
+ */
+ public IgniteFuture<Void> removeAllAsync(Set<? extends K> keys);
+
+ /**
* Removes all of the mappings from this cache.
* <p>
* The order that the individual entries are removed is undefined.
@@ -686,12 +1100,43 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
@IgniteAsyncSupported
@Override public void removeAll();
+ /**
+ * Asynchronously removes all of the mappings from this cache.
+ * <p>
+ * The order that the individual entries are removed is undefined.
+ * <p>
+ * For every mapping that exists the following are called:
+ * <ul>
+ * <li>any registered {@link CacheEntryRemovedListener}s</li>
+ * <li>if the cache is a write-through cache, the {@link CacheWriter}</li>
+ * </ul>
+ * If the cache is empty, the {@link CacheWriter} is not called.
+ * <p>
+ * This is potentially an expensive operation as listeners are invoked.
+ * Use {@link #clearAsync()} to avoid this.
+ *
+ * @return a Future representing pending completion of the operation.
+ * @throws IllegalStateException if the cache is {@link #isClosed()}
+ * @throws CacheException if there is a problem during the remove
+ * @see #clearAsync()
+ * @see CacheWriter#deleteAll
+ */
+ public IgniteFuture<Void> removeAllAsync();
+
/** {@inheritDoc} */
@IgniteAsyncSupported
@Override public void clear();
/**
- * Clear entry from the cache and swap storage, without notifying listeners or
+ * Asynchronously clears the contents of the cache, without notifying listeners or
+ * {@link CacheWriter}s.
+ *
+ * @return a Future representing pending completion of the operation.
+ */
+ public IgniteFuture<Void> clearAsync();
+
+ /**
+ * Clears entry from the cache and swap storage, without notifying listeners or
* {@link CacheWriter}s. Entry is cleared only if it is not currently locked,
* and is not participating in a transaction.
*
@@ -703,7 +1148,19 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
public void clear(K key);
/**
- * Clear entries from the cache and swap storage, without notifying listeners or
+ * Asynchronously clears entry from the cache and swap storage, without notifying listeners or
+ * {@link CacheWriter}s. Entry is cleared only if it is not currently locked,
+ * and is not participating in a transaction.
+ *
+ * @param key Key to clear.
+ * @return a Future representing pending completion of the operation.
+ * @throws IllegalStateException if the cache is {@link #isClosed()}
+ * @throws CacheException if there is a problem during the clear
+ */
+ public IgniteFuture<Void> clearAsync(K key);
+
+ /**
+ * Clears entries from the cache and swap storage, without notifying listeners or
* {@link CacheWriter}s. Entry is cleared only if it is not currently locked,
* and is not participating in a transaction.
*
@@ -715,7 +1172,19 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
public void clearAll(Set<? extends K> keys);
/**
- * Clear entry from the cache and swap storage, without notifying listeners or
+ * Asynchronously clears entries from the cache and swap storage, without notifying listeners or
+ * {@link CacheWriter}s. Entry is cleared only if it is not currently locked,
+ * and is not participating in a transaction.
+ *
+ * @param keys Keys to clear.
+ * @return a Future representing pending completion of the operation.
+ * @throws IllegalStateException if the cache is {@link #isClosed()}
+ * @throws CacheException if there is a problem during the clear
+ */
+ public IgniteFuture<Void> clearAllAsync(Set<? extends K> keys);
+
+ /**
+ * Clears entry from the cache and swap storage, without notifying listeners or
* {@link CacheWriter}s. Entry is cleared only if it is not currently locked,
* and is not participating in a transaction.
* <p/>
@@ -728,7 +1197,7 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
public void localClear(K key);
/**
- * Clear entries from the cache and swap storage, without notifying listeners or
+ * Clears entries from the cache and swap storage, without notifying listeners or
* {@link CacheWriter}s. Entry is cleared only if it is not currently locked,
* and is not participating in a transaction.
* <p/>
@@ -750,6 +1219,22 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
@Override public <T> T invoke(K key, EntryProcessor<K, V, T> entryProcessor, Object... arguments);
/**
+ * Asynchronously invokes an {@link EntryProcessor} against the {@link Entry} specified by
+ * the provided key. If an {@link Entry} does not exist for the specified key,
+ * an attempt is made to load it (if a loader is configured) or a surrogate
+ * {@link Entry}, consisting of the key with a null value is used instead.
+ *
+ * @param key The key to the entry.
+ * @param entryProcessor The {@link EntryProcessor} to invoke.
+ * @param arguments Additional arguments to pass to the {@link EntryProcessor}.
+ * @return a Future representing pending completion of the operation.
+ * @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
+ * @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
+ * @throws TransactionHeuristicException If operation performs within transaction that entered an unknown state.
+ */
+ public <T> IgniteFuture<T> invokeAsync(K key, EntryProcessor<K, V, T> entryProcessor, Object... arguments);
+
+ /**
* Invokes an {@link CacheEntryProcessor} against the {@link javax.cache.Cache.Entry} specified by
* the provided key. If an {@link javax.cache.Cache.Entry} does not exist for the specified key,
* an attempt is made to load it (if a loader is configured) or a surrogate
@@ -782,6 +1267,37 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
public <T> T invoke(K key, CacheEntryProcessor<K, V, T> entryProcessor, Object... arguments);
/**
+ * Asynchronously invokes an {@link CacheEntryProcessor} against the {@link javax.cache.Cache.Entry} specified by
+ * the provided key. If an {@link javax.cache.Cache.Entry} does not exist for the specified key,
+ * an attempt is made to load it (if a loader is configured) or a surrogate
+ * {@link javax.cache.Cache.Entry}, consisting of the key with a null value is used instead.
+ * <p>
+ * An instance of entry processor must be stateless as it may be invoked multiple times on primary and
+ * backup nodes in the cache. It is guaranteed that the value passed to the entry processor will be always
+ * the same.
+ *
+ * @param key The key to the entry.
+ * @param entryProcessor The {@link CacheEntryProcessor} to invoke.
+ * @param arguments Additional arguments to pass to the {@link CacheEntryProcessor}.
+ * @return a Future representing pending completion of the operation.
+ * @throws NullPointerException If key or {@link CacheEntryProcessor} is null
+ * @throws IllegalStateException If the cache is {@link #isClosed()}
+ * @throws ClassCastException If the implementation is configured to perform
+ * runtime-type-checking, and the key or value
+ * types are incompatible with those that have been
+ * configured for the {@link Cache}.
+ * @throws EntryProcessorException If an exception is thrown by the {@link
+ * CacheEntryProcessor}, a Caching Implementation
+ * must wrap any {@link Exception} thrown
+ * wrapped in an {@link EntryProcessorException}.
+ * @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
+ * @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
+ * @throws TransactionHeuristicException If operation performs within transaction that entered an unknown state.
+ * @see CacheEntryProcessor
+ */
+ public <T> IgniteFuture<T> invokeAsync(K key, CacheEntryProcessor<K, V, T> entryProcessor, Object... arguments);
+
+ /**
* {@inheritDoc}
* @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
* @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
@@ -792,6 +1308,39 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
EntryProcessor<K, V, T> entryProcessor, Object... args);
/**
+ * Asynchronously invokes an {@link EntryProcessor} against the set of {@link Entry}s
+ * specified by the set of keys.
+ * <p>
+ * If an {@link Entry} does not exist for the specified key, an attempt is made
+ * to load it (if a loader is configured) or a surrogate {@link Entry},
+ * consisting of the key and a value of null is provided.
+ * <p>
+ * The order that the entries for the keys are processed is undefined.
+ * Implementations may choose to process the entries in any order, including
+ * concurrently. Furthermore there is no guarantee implementations will
+ * use the same {@link EntryProcessor} instance to process each entry, as
+ * the case may be in a non-local cache topology.
+ * <p>
+ * The result of executing the {@link EntryProcessor} is returned in the future as a
+ * {@link Map} of {@link EntryProcessorResult}s, one result per key. Should the
+ * {@link EntryProcessor} or Caching implementation throw an exception, the
+ * exception is wrapped and re-thrown when a call to
+ * {@link javax.cache.processor.EntryProcessorResult#get()} is made.
+
+ *
+ * @param keys The set of keys.
+ * @param entryProcessor The {@link EntryProcessor} to invoke.
+ * @param args Additional arguments to pass to the {@link EntryProcessor}.
+ * @return a Future representing pending completion of the operation.
+ * @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
+ * @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
+ * @throws TransactionHeuristicException If operation performs within transaction that entered an unknown state.
+ */
+ public <T> IgniteFuture<Map<K, EntryProcessorResult<T>>> invokeAllAsync(Set<? extends K> keys,
+ EntryProcessor<K, V, T> entryProcessor, Object... args);
+
+
+ /**
* Invokes an {@link CacheEntryProcessor} against the set of {@link javax.cache.Cache.Entry}s
* specified by the set of keys.
* <p>
@@ -838,6 +1387,48 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
CacheEntryProcessor<K, V, T> entryProcessor, Object... args);
/**
+ * Asynchronously invokes an {@link CacheEntryProcessor} against the set of {@link javax.cache.Cache.Entry}s
+ * specified by the set of keys.
+ * <p>
+ * If an {@link javax.cache.Cache.Entry} does not exist for the specified key, an attempt is made
+ * to load it (if a loader is configured) or a surrogate {@link javax.cache.Cache.Entry},
+ * consisting of the key and a value of null is provided.
+ * <p>
+ * The order that the entries for the keys are processed is undefined.
+ * Implementations may choose to process the entries in any order, including
+ * concurrently. Furthermore there is no guarantee implementations will
+ * use the same {@link CacheEntryProcessor} instance to process each entry, as
+ * the case may be in a non-local cache topology.
+ * <p>
+ * The result of executing the {@link CacheEntryProcessor} is returned in the future as a
+ * {@link Map} of {@link EntryProcessorResult}s, one result per key. Should the
+ * {@link CacheEntryProcessor} or Caching implementation throw an exception, the
+ * exception is wrapped and re-thrown when a call to
+ * {@link javax.cache.processor.EntryProcessorResult#get()} is made.
+ * <p>
+ * An instance of entry processor must be stateless as it may be invoked multiple times on primary and
+ * backup nodes in the cache. It is guaranteed that the value passed to the entry processor will be always
+ * the same.
+ *
+ * @param keys The set of keys for entries to process.
+ * @param entryProcessor The {@link CacheEntryProcessor} to invoke.
+ * @param args Additional arguments to pass to the {@link CacheEntryProcessor}.
+ * @return a Future representing pending completion of the operation.
+ * @throws NullPointerException If keys or {@link CacheEntryProcessor} are {#code null}.
+ * @throws IllegalStateException If the cache is {@link #isClosed()}.
+ * @throws ClassCastException If the implementation is configured to perform
+ * runtime-type-checking, and the key or value
+ * types are incompatible with those that have been
+ * configured for the {@link Cache}.
+ * @throws TransactionTimeoutException If operation performs within transaction and timeout occurred.
+ * @throws TransactionRollbackException If operation performs within transaction that automatically rolled back.
+ * @throws TransactionHeuristicException If operation performs within transaction that entered an unknown state.
+ * @see CacheEntryProcessor
+ */
+ public <T> IgniteFuture<Map<K, EntryProcessorResult<T>>> invokeAllAsync(Set<? extends K> keys,
+ CacheEntryProcessor<K, V, T> entryProcessor, Object... args);
+
+ /**
* Closes this cache instance.
* <p>
* For local cache equivalent to {@link #destroy()}.
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/main/java/org/apache/ignite/IgniteCluster.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCluster.java b/modules/core/src/main/java/org/apache/ignite/IgniteCluster.java
index 23b03df..dc7b687 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteCluster.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCluster.java
@@ -188,6 +188,33 @@ public interface IgniteCluster extends ClusterGroup, IgniteAsyncSupport {
int maxConn) throws IgniteException;
/**
+ * Starts one or more nodes on remote host(s) asynchronously.
+ * <p>
+ * This method takes INI file which defines all startup parameters. It can contain one or
+ * more sections, each for a host or for range of hosts (note that they must have different
+ * names) and a special '{@code defaults}' section with default values. They are applied to
+ * undefined parameters in host's sections.
+ * <p>
+ * Completed future contains collection of tuples. Each tuple corresponds to one node start attempt and
+ * contains hostname, success flag and error message if attempt was not successful. Note that
+ * successful attempt doesn't mean that node was actually started and joined topology. For large
+ * topologies (> 100s nodes) it can take over 10 minutes for all nodes to start. See individual
+ * node logs for details.
+ *
+ * @param file Configuration file.
+ * @param restart Whether to stop existing nodes. If {@code true}, all existing
+ * nodes on the host will be stopped before starting new ones. If
+ * {@code false}, nodes will be started only if there are less
+ * nodes on the host than expected.
+ * @param timeout Connection timeout.
+ * @param maxConn Number of parallel SSH connections to one host.
+ * @return a Future representing pending completion of the starting nodes.
+ * @throws IgniteException In case of error.
+ */
+ public IgniteFuture<Collection<ClusterStartNodeResult>> startNodesAsync(File file, boolean restart, int timeout,
+ int maxConn) throws IgniteException;
+
+ /**
* Starts one or more nodes on remote host(s).
* <p>
* Each map in {@code hosts} collection
@@ -290,6 +317,104 @@ public interface IgniteCluster extends ClusterGroup, IgniteAsyncSupport {
@Nullable Map<String, Object> dflts, boolean restart, int timeout, int maxConn) throws IgniteException;
/**
+ * Starts one or more nodes on remote host(s) asynchronously.
+ * <p>
+ * Each map in {@code hosts} collection
+ * defines startup parameters for one host or for a range of hosts. The following
+ * parameters are supported:
+ * <table class="doctable">
+ * <tr>
+ * <th>Name</th>
+ * <th>Type</th>
+ * <th>Description</th>
+ * </tr>
+ * <tr>
+ * <td><b>host</b></td>
+ * <td>String</td>
+ * <td>
+ * Hostname (required). Can define several hosts if their IPs are sequential.
+ * E.g., {@code 10.0.0.1~5} defines range of five IP addresses. Other
+ * parameters are applied to all hosts equally.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td><b>port</b></td>
+ * <td>Integer</td>
+ * <td>Port number (default is {@code 22}).</td>
+ * </tr>
+ * <tr>
+ * <td><b>uname</b></td>
+ * <td>String</td>
+ * <td>Username (if not defined, current local username will be used).</td>
+ * </tr>
+ * <tr>
+ * <td><b>passwd</b></td>
+ * <td>String</td>
+ * <td>Password (if not defined, private key file must be defined).</td>
+ * </tr>
+ * <tr>
+ * <td><b>key</b></td>
+ * <td>File</td>
+ * <td>Private key file (if not defined, password must be defined).</td>
+ * </tr>
+ * <tr>
+ * <td><b>nodes</b></td>
+ * <td>Integer</td>
+ * <td>
+ * Expected number of nodes on the host. If some nodes are started
+ * already, then only remaining nodes will be started. If current count of
+ * nodes is equal to this number, and {@code restart} flag is {@code false},
+ * then nothing will happen.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td><b>igniteHome</b></td>
+ * <td>String</td>
+ * <td>
+ * Path to Ignite installation folder. If not defined, IGNITE_HOME
+ * environment variable must be set on remote hosts.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td><b>cfg</b></td>
+ * <td>String</td>
+ * <td>Path to configuration file (relative to {@code igniteHome}).</td>
+ * </tr>
+ * <tr>
+ * <td><b>script</b></td>
+ * <td>String</td>
+ * <td>
+ * Custom startup script file name and path (relative to {@code igniteHome}).
+ * You can also specify a space-separated list of parameters in the same
+ * string (for example: {@code "bin/my-custom-script.sh -v"}).
+ * </td>
+ * </tr>
+ * </table>
+ * <p>
+ * {@code dflts} map defines default values. They are applied to undefined parameters in
+ * {@code hosts} collection.
+ * <p>
+ * Completed future contains collection of tuples. Each tuple corresponds to one node start attempt and
+ * contains hostname, success flag and error message if attempt was not successful. Note that
+ * successful attempt doesn't mean that node was actually started and joined topology. For large
+ * topologies (> 100s nodes) it can take over 10 minutes for all nodes to start. See individual
+ * node logs for details.
+ *
+ * @param hosts Startup parameters.
+ * @param dflts Default values.
+ * @param restart Whether to stop existing nodes. If {@code true}, all existing
+ * nodes on the host will be stopped before starting new ones. If
+ * {@code false}, nodes will be started only if there are less
+ * nodes on the host than expected.
+ * @param timeout Connection timeout in milliseconds.
+ * @param maxConn Number of parallel SSH connections to one host.
+ * @return a Future representing pending completion of the starting nodes.
+ * @throws IgniteException In case of error.
+ */
+ public IgniteFuture<Collection<ClusterStartNodeResult>> startNodesAsync(Collection<Map<String, Object>> hosts,
+ @Nullable Map<String, Object> dflts, boolean restart, int timeout, int maxConn) throws IgniteException;
+
+ /**
* Stops nodes satisfying optional set of predicates.
* <p>
* <b>NOTE:</b> {@code System.exit(Ignition.KILL_EXIT_CODE)} will be executed on each
@@ -347,5 +472,6 @@ public interface IgniteCluster extends ClusterGroup, IgniteAsyncSupport {
@Nullable public IgniteFuture<?> clientReconnectFuture();
/** {@inheritDoc} */
+ @Deprecated
@Override public IgniteCluster withAsync();
}
[04/10] ignite git commit: IGNITE-4475: New async API: now all async
methods are defined explicitly,
IgniteAsyncSupport is deprecated. This closes #1648.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigVariationsFullApiTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigVariationsFullApiTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigVariationsFullApiTest.java
index e47a18d..4bada88 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigVariationsFullApiTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigVariationsFullApiTest.java
@@ -56,6 +56,7 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.IgniteTransactions;
+import org.apache.ignite.cache.CacheEntry;
import org.apache.ignite.cache.CacheEntryEventSerializableFilter;
import org.apache.ignite.cache.CacheEntryProcessor;
import org.apache.ignite.cache.CachePeekMode;
@@ -225,6 +226,41 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
for (int i = 0; i < gridCount(); i++)
assertEquals(globalPrimarySize, jcache(i).size(PRIMARY));
+ for (int i = 0; i < gridCount(); i++)
+ assertEquals(globalPrimarySize, jcache(i).sizeLong(PRIMARY));
+
+ for (int i = 0; i < gridCount(); i++)
+ assertEquals(globalPrimarySize, (int)jcache(i).sizeAsync(PRIMARY).get());
+
+ for (int i = 0; i < gridCount(); i++)
+ assertEquals((long)globalPrimarySize, (long)jcache(i).sizeLongAsync(PRIMARY).get());
+
+ for (int i = 0; i < gridCount(); i++) {
+ IgniteCacheProxy cache = (IgniteCacheProxy)jcache(i);
+
+ long cacheSize = 0;
+
+ int parts = cache.context().affinity().partitions();
+
+ for (int part = 0; part < parts; ++part)
+ cacheSize += jcache(i).sizeLong(part, PRIMARY);
+
+ assertEquals((long)globalPrimarySize, cacheSize);
+ }
+
+ for (int i = 0; i < gridCount(); i++) {
+ IgniteCacheProxy cache = (IgniteCacheProxy)jcache(i);
+
+ long cacheSize = 0;
+
+ int parts = cache.context().affinity().partitions();
+
+ for (int part = 0; part < parts; ++part)
+ cacheSize += jcache(i).sizeLongAsync(part, PRIMARY).get();
+
+ assertEquals((long)globalPrimarySize, cacheSize);
+ }
+
int times = 1;
if (cacheMode() == REPLICATED)
@@ -242,10 +278,21 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
* @throws Exception In case of error.
*/
public void testContainsKey() throws Exception {
- jcache().put("testContainsKey", 1);
- checkContainsKey(true, "testContainsKey");
+ Map<String, Integer> vals = new HashMap<>();
+
+ for (int i = 0; i < CNT; i++)
+ vals.put("key" + i, i);
+
+ jcache().putAll(vals);
+
+ checkContainsKey(true, "key0");
checkContainsKey(false, "testContainsKeyWrongKey");
+
+ for (int i = 0; i < gridCount(); i++) {
+ assertTrue(jcache(i).containsKeys(vals.keySet()));
+ assertTrue(jcache(i).containsKeysAsync(vals.keySet()).get());
+ }
}
/**
@@ -420,7 +467,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
/**
* @throws Exception In case of error.
*/
- public void testGetAsync() throws Exception {
+ public void testGetAsyncOld() throws Exception {
IgniteCache<String, Integer> cache = jcache();
cache.put("key1", 1);
@@ -448,6 +495,26 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
/**
* @throws Exception In case of error.
*/
+ public void testGetAsync() throws Exception {
+ IgniteCache<String, Integer> cache = jcache();
+
+ cache.put("key1", 1);
+ cache.put("key2", 2);
+
+ IgniteFuture<Integer> fut1 = cache.getAsync("key1");
+
+ IgniteFuture<Integer> fut2 = cache.getAsync("key2");
+
+ IgniteFuture<Integer> fut3 = cache.getAsync("wrongKey");
+
+ assert fut1.get() == 1;
+ assert fut2.get() == 2;
+ assert fut3.get() == null;
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
public void testGetAll() throws Exception {
runInAllDataModes(new TestRunnable() {
@Override public void run() {
@@ -570,7 +637,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
/**
* @throws Exception In case of error.
*/
- public void testGetAllAsync() throws Exception {
+ public void testGetAllAsyncOld() throws Exception {
final IgniteCache<String, Integer> cache = jcache();
final IgniteCache<String, Integer> cacheAsync = cache.withAsync();
@@ -601,6 +668,33 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
/**
* @throws Exception In case of error.
*/
+ public void testGetAllAsync() throws Exception {
+ final IgniteCache<String, Integer> cache = jcache();
+
+ cache.put("key1", 1);
+ cache.put("key2", 2);
+
+ GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ cache.getAllAsync(null);
+
+ return null;
+ }
+ }, NullPointerException.class, null);
+
+ IgniteFuture<Map<String, Integer>> fut2 = cache.getAllAsync(Collections.<String>emptySet());
+
+ IgniteFuture<Map<String, Integer>> fut3 = cache.getAllAsync(ImmutableSet.of("key1", "key2"));
+
+ assert fut2.get().isEmpty();
+ assert fut3.get().size() == 2 : "Invalid map: " + fut3.get();
+ assert fut3.get().get("key1") == 1;
+ assert fut3.get().get("key2") == 2;
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
public void testPut() throws Exception {
runInAllDataModes(new TestRunnable() {
@Override public void run() throws Exception {
@@ -899,6 +993,50 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
}
/**
+ * @throws Exception If failed.
+ */
+ public void testInvokeAllAsyncOptimisticReadCommitted() throws Exception {
+ runInAllDataModes(new TestRunnable() {
+ @Override public void run() throws Exception {
+ checkInvokeAllAsync(OPTIMISTIC, READ_COMMITTED);
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInvokeAllAsyncOptimisticRepeatableRead() throws Exception {
+ runInAllDataModes(new TestRunnable() {
+ @Override public void run() throws Exception {
+ checkInvokeAllAsync(OPTIMISTIC, REPEATABLE_READ);
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInvokeAllAsyncPessimisticReadCommitted() throws Exception {
+ runInAllDataModes(new TestRunnable() {
+ @Override public void run() throws Exception {
+ checkInvokeAllAsync(PESSIMISTIC, READ_COMMITTED);
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInvokeAllAsyncPessimisticRepeatableRead() throws Exception {
+ runInAllDataModes(new TestRunnable() {
+ @Override public void run() throws Exception {
+ checkInvokeAllAsync(PESSIMISTIC, REPEATABLE_READ);
+ }
+ });
+ }
+
+ /**
* @param concurrency Transaction concurrency.
* @param isolation Transaction isolation.
* @throws Exception If failed.
@@ -994,6 +1132,103 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
}
/**
+ * @param concurrency Transaction concurrency.
+ * @param isolation Transaction isolation.
+ * @throws Exception If failed.
+ */
+ private void checkInvokeAllAsync(TransactionConcurrency concurrency, TransactionIsolation isolation) throws Exception {
+ // TODO IGNITE-2664: enable tests for all modes when IGNITE-2664 will be fixed.
+ if (dataMode != DataMode.EXTERNALIZABLE && gridCount() > 1)
+ return;
+
+ final Object key1 = key(1);
+ final Object key2 = key(2);
+ final Object key3 = key(3);
+
+ final Object val1 = value(1);
+ final Object val2 = value(2);
+ final Object val3 = value(3);
+ final Object val4 = value(4);
+
+ final IgniteCache<Object, Object> cache = jcache();
+
+ cache.put(key2, val1);
+ cache.put(key3, val3);
+
+ if (txShouldBeUsed()) {
+ Map<Object, EntryProcessorResult<Object>> res;
+
+ try (Transaction tx = ignite(0).transactions().txStart(concurrency, isolation)) {
+ res = cache.invokeAllAsync(F.asSet(key1, key2, key3), INCR_PROCESSOR, dataMode).get();
+
+ tx.commit();
+ }
+
+ assertEquals(val1, cache.get(key1));
+ assertEquals(val2, cache.get(key2));
+ assertEquals(val4, cache.get(key3));
+
+ assertNull(res.get(key1));
+ assertEquals(val1, res.get(key2).get());
+ assertEquals(val3, res.get(key3).get());
+
+ assertEquals(2, res.size());
+
+ cache.remove(key1);
+ cache.put(key2, val1);
+ cache.put(key3, val3);
+ }
+
+ Map<Object, EntryProcessorResult<Object>> res =
+ cache.invokeAllAsync(F.asSet(key1, key2, key3), RMV_PROCESSOR).get();
+
+ for (int i = 0; i < gridCount(); i++) {
+ assertNull(jcache(i).localPeek(key1, ONHEAP));
+ assertNull(jcache(i).localPeek(key2, ONHEAP));
+ assertNull(jcache(i).localPeek(key3, ONHEAP));
+ }
+
+ assertNull(res.get(key1));
+ assertEquals(val1, res.get(key2).get());
+ assertEquals(val3, res.get(key3).get());
+
+ assertEquals(2, res.size());
+
+ cache.remove(key1);
+ cache.put(key2, val1);
+ cache.put(key3, val3);
+
+ res = cache.invokeAllAsync(F.asSet(key1, key2, key3), INCR_PROCESSOR, dataMode).get();
+
+ assertEquals(val1, cache.get(key1));
+ assertEquals(val2, cache.get(key2));
+ assertEquals(val4, cache.get(key3));
+
+ assertNull(res.get(key1));
+ assertEquals(val1, res.get(key2).get());
+ assertEquals(val3, res.get(key3).get());
+
+ assertEquals(2, res.size());
+
+ cache.remove(key1);
+ cache.put(key2, val1);
+ cache.put(key3, val3);
+
+ res = cache.invokeAllAsync(
+ F.asMap(key1, INCR_PROCESSOR, key2, INCR_PROCESSOR, key3, INCR_PROCESSOR), dataMode).get();
+
+ assertEquals(val1, cache.get(key1));
+ assertEquals(val2, cache.get(key2));
+ assertEquals(val4, cache.get(key3));
+
+ assertNull(res.get(key1));
+ assertEquals(val1, res.get(key2).get());
+ assertEquals(val3, res.get(key3).get());
+
+ assertEquals(2, res.size());
+ }
+
+ /**
* @throws Exception If failed.
*/
public void testInvokeAllWithNulls() throws Exception {
@@ -1295,7 +1530,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
/**
* @throws Exception In case of error.
*/
- public void testGetAndPutAsync() throws Exception {
+ public void testGetAndPutAsyncOld() throws Exception {
IgniteCache<String, Integer> cache = jcache();
IgniteCache<String, Integer> cacheAsync = cache.withAsync();
@@ -1321,7 +1556,27 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
/**
* @throws Exception In case of error.
*/
- public void testPutAsync0() throws Exception {
+ public void testGetAndPutAsync() throws Exception {
+ IgniteCache<String, Integer> cache = jcache();
+
+ cache.put("key1", 1);
+ cache.put("key2", 2);
+
+ IgniteFuture<Integer> fut1 = cache.getAndPutAsync("key1", 10);
+
+ IgniteFuture<Integer> fut2 = cache.getAndPutAsync("key2", 11);
+
+ assertEquals((Integer)1, fut1.get(5000));
+ assertEquals((Integer)2, fut2.get(5000));
+
+ assertEquals((Integer)10, cache.get("key1"));
+ assertEquals((Integer)11, cache.get("key2"));
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testPutAsyncOld0() throws Exception {
IgniteCache cacheAsync = jcache().withAsync();
cacheAsync.getAndPut("key1", 0);
@@ -1337,9 +1592,21 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
}
/**
+ * @throws Exception In case of error.
+ */
+ public void testPutAsync0() throws Exception {
+ IgniteFuture<?> fut1 = jcache().getAndPutAsync("key1", 0);
+
+ IgniteFuture<?> fut2 = jcache().getAndPutAsync("key2", 1);
+
+ assert fut1.get(5000) == null;
+ assert fut2.get(5000) == null;
+ }
+
+ /**
* @throws Exception If failed.
*/
- public void testInvokeAsync() throws Exception {
+ public void testInvokeAsyncOld() throws Exception {
runInAllDataModes(new TestRunnable() {
@Override public void run() throws Exception {
final Object key1 = key(1);
@@ -1386,6 +1653,46 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
/**
* @throws Exception If failed.
*/
+ public void testInvokeAsync() throws Exception {
+ runInAllDataModes(new TestRunnable() {
+ @Override public void run() throws Exception {
+ final Object key1 = key(1);
+ final Object key2 = key(2);
+ final Object key3 = key(3);
+
+ final Object val1 = value(1);
+ final Object val2 = value(2);
+ final Object val3 = value(3);
+
+ IgniteCache<Object, Object> cache = jcache();
+
+ cache.put(key2, val1);
+ cache.put(key3, val3);
+
+ IgniteFuture<?> fut0 = cache.invokeAsync(key1, INCR_PROCESSOR, dataMode);
+
+ IgniteFuture<?> fut1 = cache.invokeAsync(key2, INCR_PROCESSOR, dataMode);
+
+
+ IgniteFuture<?> fut2 = cache.invokeAsync(key3, RMV_PROCESSOR);
+
+ fut0.get();
+ fut1.get();
+ fut2.get();
+
+ assertEquals(val1, cache.get(key1));
+ assertEquals(val2, cache.get(key2));
+ assertNull(cache.get(key3));
+
+ for (int i = 0; i < gridCount(); i++)
+ assertNull(jcache(i).localPeek(key3, ONHEAP));
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testInvoke() throws Exception {
runInAllDataModes(new TestRunnable() {
@Override public void run() throws Exception {
@@ -1492,7 +1799,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
/**
* @throws Exception If failed.
*/
- public void testPutAsync() throws Exception {
+ public void testPutAsyncOld() throws Exception {
Transaction tx = txShouldBeUsed() ? transactions().txStart() : null;
IgniteCache cacheAsync = jcache().withAsync();
@@ -1535,6 +1842,45 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
}
/**
+ * @throws Exception If failed.
+ */
+ public void testPutAsync() throws Exception {
+ Transaction tx = txShouldBeUsed() ? transactions().txStart() : null;
+
+ try {
+ jcache().put("key2", 1);
+
+ IgniteFuture<?> fut1 = jcache().putAsync("key1", 10);
+
+ IgniteFuture<?> fut2 = jcache().putAsync("key2", 11);
+
+ IgniteFuture<Void> f = null;
+
+ if (tx != null)
+ f = tx.commitAsync();
+
+ assertNull(fut1.get());
+ assertNull(fut2.get());
+
+ try {
+ if (f != null)
+ f.get();
+ } catch (Throwable t) {
+ assert false : "Unexpected exception " + t;
+ }
+ }
+ finally {
+ if (tx != null)
+ tx.close();
+ }
+
+ checkSize(F.asSet("key1", "key2"));
+
+ assert (Integer)jcache().get("key1") == 10;
+ assert (Integer)jcache().get("key2") == 11;
+ }
+
+ /**
* @throws Exception In case of error.
*/
public void testPutAll() throws Exception {
@@ -1782,7 +2128,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
/**
* @throws Exception In case of error.
*/
- public void testPutAllAsync() throws Exception {
+ public void testPutAllAsyncOld() throws Exception {
Map<String, Integer> map = F.asMap("key1", 1, "key2", 2);
IgniteCache<String, Integer> cache = jcache();
@@ -1812,6 +2158,30 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
/**
* @throws Exception In case of error.
*/
+ public void testPutAllAsync() throws Exception {
+ Map<String, Integer> map = F.asMap("key1", 1, "key2", 2);
+
+ IgniteCache<String, Integer> cache = jcache();
+
+ IgniteFuture<?> f1 = cache.putAllAsync(map);
+
+ map.put("key1", 10);
+ map.put("key2", 20);
+
+ IgniteFuture<?> f2 = cache.putAllAsync(map);
+
+ assertNull(f2.get());
+ assertNull(f1.get());
+
+ checkSize(F.asSet("key1", "key2"));
+
+ assert cache.get("key1") == 10;
+ assert cache.get("key2") == 20;
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
public void testGetAndPutIfAbsent() throws Exception {
Transaction tx = txShouldBeUsed() ? transactions().txStart() : null;
@@ -1898,7 +2268,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
/**
* @throws Exception If failed.
*/
- public void testGetAndPutIfAbsentAsync() throws Exception {
+ public void testGetAndPutIfAbsentAsyncOld() throws Exception {
Transaction tx = txShouldBeUsed() ? transactions().txStart() : null;
IgniteCache<String, Integer> cache = jcache();
@@ -1979,6 +2349,75 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
/**
* @throws Exception If failed.
*/
+ public void testGetAndPutIfAbsentAsync() throws Exception {
+ Transaction tx = txShouldBeUsed() ? transactions().txStart() : null;
+
+ IgniteCache<String, Integer> cache = jcache();
+
+ try {
+ IgniteFuture<Integer> fut1 = cache.getAndPutIfAbsentAsync("key", 1);
+
+ assertNull(fut1.get());
+ assertEquals((Integer)1, cache.get("key"));
+
+ IgniteFuture<Integer> fut2 = cache.getAndPutIfAbsentAsync("key", 2);
+
+ assertEquals((Integer)1, fut2.get());
+ assertEquals((Integer)1, cache.get("key"));
+
+ if (tx != null)
+ tx.commit();
+ }
+ finally {
+ if (tx != null)
+ tx.close();
+ }
+
+ if (!storeEnabled())
+ return;
+
+ // Check swap.
+ cache.put("key2", 1);
+
+ cache.localEvict(Collections.singleton("key2"));
+
+ if (!isLoadPreviousValue())
+ cache.get("key2");
+
+ assertEquals((Integer)1, cache.getAndPutIfAbsentAsync("key2", 3).get());
+
+ // Check db.
+ if (storeEnabled() && isLoadPreviousValue() && !isMultiJvm()) {
+ putToStore("key3", 3);
+
+ assertEquals((Integer)3, cache.getAndPutIfAbsentAsync("key3", 4).get());
+ }
+
+ cache.localEvict(Collections.singleton("key2"));
+
+ if (!isLoadPreviousValue())
+ cache.get("key2");
+
+ // Same checks inside tx.
+ tx = txShouldBeUsed() ? transactions().txStart() : null;
+
+ try {
+ assertEquals(1, (int) cache.getAndPutIfAbsentAsync("key2", 3).get());
+
+ if (tx != null)
+ tx.commit();
+
+ assertEquals((Integer)1, cache.get("key2"));
+ }
+ finally {
+ if (tx != null)
+ tx.close();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testPutIfAbsent() throws Exception {
IgniteCache<String, Integer> cache = jcache();
@@ -2033,6 +2472,21 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
/**
* @throws Exception In case of error.
*/
+ public void testPutxIfAbsentAsyncOld() throws Exception {
+ if (txShouldBeUsed())
+ checkPutxIfAbsentAsyncOld(true);
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testPutxIfAbsentAsyncOldNoTx() throws Exception {
+ checkPutxIfAbsentAsyncOld(false);
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
public void testPutxIfAbsentAsync() throws Exception {
if (txShouldBeUsed())
checkPutxIfAbsentAsync(true);
@@ -2049,7 +2503,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
* @param inTx In tx flag.
* @throws Exception If failed.
*/
- private void checkPutxIfAbsentAsync(boolean inTx) throws Exception {
+ private void checkPutxIfAbsentAsyncOld(boolean inTx) throws Exception {
IgniteCache<String, Integer> cache = jcache();
IgniteCache<String, Integer> cacheAsync = cache.withAsync();
@@ -2126,9 +2580,74 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
}
/**
+ * @param inTx In tx flag.
+ * @throws Exception If failed.
+ */
+ private void checkPutxIfAbsentAsync(boolean inTx) throws Exception {
+ IgniteCache<String, Integer> cache = jcache();
+
+ IgniteFuture<Boolean> fut1 = cache.putIfAbsentAsync("key", 1);
+
+ assert fut1.get();
+ assert cache.get("key") != null && cache.get("key") == 1;
+
+ IgniteFuture<Boolean> fut2 = cache.putIfAbsentAsync("key", 2);
+
+ assert !fut2.get();
+ assert cache.get("key") != null && cache.get("key") == 1;
+
+ if (!storeEnabled())
+ return;
+
+ // Check swap.
+ cache.put("key2", 1);
+
+ cache.localEvict(Collections.singleton("key2"));
+
+ if (!isLoadPreviousValue())
+ cache.get("key2");
+
+ assertFalse(cache.putIfAbsentAsync("key2", 3).get());
+
+ // Check db.
+ if (storeEnabled() && isLoadPreviousValue() && !isMultiJvm()) {
+ putToStore("key3", 3);
+
+ assertFalse(cache.putIfAbsentAsync("key3", 4).get());
+ }
+
+ cache.localEvict(Collections.singletonList("key2"));
+
+ if (!isLoadPreviousValue())
+ cache.get("key2");
+
+ // Same checks inside tx.
+ Transaction tx = inTx ? transactions().txStart() : null;
+
+ try {
+ assertFalse(cache.putIfAbsentAsync("key2", 3).get());
+
+ if (storeEnabled() && isLoadPreviousValue() && !isMultiJvm())
+ assertFalse(cache.putIfAbsentAsync("key3", 4).get());
+
+ if (tx != null)
+ tx.commit();
+ }
+ finally {
+ if (tx != null)
+ tx.close();
+ }
+
+ assertEquals((Integer)1, cache.get("key2"));
+
+ if (storeEnabled() && isLoadPreviousValue() && !isMultiJvm())
+ assertEquals((Integer)3, cache.get("key3"));
+ }
+
+ /**
* @throws Exception In case of error.
*/
- public void testPutIfAbsentAsyncConcurrent() throws Exception {
+ public void testPutIfAbsentAsyncOldConcurrent() throws Exception {
IgniteCache cacheAsync = jcache().withAsync();
cacheAsync.putIfAbsent("key1", 1);
@@ -2144,6 +2663,20 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
}
/**
+ * @throws Exception In case of error.
+ */
+ public void testPutIfAbsentAsyncConcurrent() throws Exception {
+ IgniteCache cache = jcache();
+
+ IgniteFuture<Boolean> fut1 = cache.putIfAbsentAsync("key1", 1);
+
+ IgniteFuture<Boolean> fut2 = cache.putIfAbsentAsync("key2", 2);
+
+ assert fut1.get();
+ assert fut2.get();
+ }
+
+ /**
* @throws Exception If failed.
*/
public void testGetAndReplace() throws Exception {
@@ -2297,7 +2830,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
/**
* @throws Exception If failed.
*/
- public void testGetAndReplaceAsync() throws Exception {
+ public void testGetAndReplaceAsyncOld() throws Exception {
IgniteCache<String, Integer> cache = jcache();
IgniteCache<String, Integer> cacheAsync = cache.withAsync();
@@ -2386,7 +2919,78 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
/**
* @throws Exception If failed.
*/
- public void testReplacexAsync() throws Exception {
+ public void testGetAndReplaceAsync() throws Exception {
+ IgniteCache<String, Integer> cache = jcache();
+
+ cache.put("key", 1);
+
+ assert cache.get("key") == 1;
+
+ assert cache.getAndReplaceAsync("key", 2).get() == 1;
+
+ assert cache.get("key") == 2;
+
+ assert cache.getAndReplaceAsync("wrong", 0).get() == null;
+
+ assert cache.get("wrong") == null;
+
+ assert !cache.replaceAsync("key", 0, 3).get();
+
+ assert cache.get("key") == 2;
+
+ assert !cache.replaceAsync("key", 0, 3).get();
+
+ assert cache.get("key") == 2;
+
+ assert cache.replaceAsync("key", 2, 3).get();
+
+ assert cache.get("key") == 3;
+
+ if (!storeEnabled())
+ return;
+
+ cache.localEvict(Collections.singleton("key"));
+
+ if (!isLoadPreviousValue())
+ cache.get("key");
+
+ assert cache.replaceAsync("key", 3, 4).get();
+
+ assert cache.get("key") == 4;
+
+ if (storeEnabled() && isLoadPreviousValue() && !isMultiJvm()) {
+ putToStore("key2", 5);
+
+ assert cache.replaceAsync("key2", 5, 6).get();
+
+ assertEquals((Integer)6, cache.get("key2"));
+ }
+
+ cache.localEvict(Collections.singleton("key"));
+
+ if (!isLoadPreviousValue())
+ cache.get("key");
+
+ Transaction tx = txShouldBeUsed() ? transactions().txStart() : null;
+
+ try {
+ assert cache.replaceAsync("key", 4, 5).get();
+
+ if (tx != null)
+ tx.commit();
+ }
+ finally {
+ if (tx != null)
+ tx.close();
+ }
+
+ assert cache.get("key") == 5;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testReplacexAsyncOld() throws Exception {
IgniteCache<String, Integer> cache = jcache();
IgniteCache<String, Integer> cacheAsync = cache.withAsync();
@@ -2455,6 +3059,65 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
}
/**
+ * @throws Exception If failed.
+ */
+ public void testReplacexAsync() throws Exception {
+ IgniteCache<String, Integer> cache = jcache();
+
+ cache.put("key", 1);
+
+ assert cache.get("key") == 1;
+
+ assert cache.replaceAsync("key", 2).get();
+
+ info("Finished replace.");
+
+ assertEquals((Integer)2, cache.get("key"));
+
+ assert !cache.replaceAsync("wrond", 2).get();
+
+ if (!storeEnabled())
+ return;
+
+ cache.localEvict(Collections.singleton("key"));
+
+ if (!isLoadPreviousValue())
+ cache.get("key");
+
+ assert cache.replaceAsync("key", 4).get();
+
+ assert cache.get("key") == 4;
+
+ if (storeEnabled() && isLoadPreviousValue() && !isMultiJvm()) {
+ putToStore("key2", 5);
+
+ assert cache.replaceAsync("key2", 6).get();
+
+ assert cache.get("key2") == 6;
+ }
+
+ cache.localEvict(Collections.singleton("key"));
+
+ if (!isLoadPreviousValue())
+ cache.get("key");
+
+ Transaction tx = txShouldBeUsed() ? transactions().txStart() : null;
+
+ try {
+ assert cache.replaceAsync("key", 5).get();
+
+ if (tx != null)
+ tx.commit();
+ }
+ finally {
+ if (tx != null)
+ tx.close();
+ }
+
+ assert cache.get("key") == 5;
+ }
+
+ /**
* @throws Exception In case of error.
*/
public void testGetAndRemove() throws Exception {
@@ -2602,7 +3265,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
/**
* @throws Exception In case of error.
*/
- public void testRemoveAsync() throws Exception {
+ public void testRemoveAsyncOld() throws Exception {
IgniteCache<String, Integer> cache = jcache();
IgniteCache<String, Integer> cacheAsync = cache.withAsync();
@@ -2636,6 +3299,30 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
/**
* @throws Exception In case of error.
*/
+ public void testRemoveAsync() throws Exception {
+ IgniteCache<String, Integer> cache = jcache();
+
+ cache.put("key1", 1);
+ cache.put("key2", 2);
+
+ assert !cache.removeAsync("key1", 0).get();
+
+ assert cache.get("key1") != null && cache.get("key1") == 1;
+
+ assert cache.removeAsync("key1", 1).get();
+
+ assert cache.get("key1") == null;
+
+ assert cache.getAndRemoveAsync("key2").get() == 2;
+
+ assert cache.get("key2") == null;
+
+ assert cache.getAndRemoveAsync("key2").get() == null;
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
public void testRemove() throws Exception {
IgniteCache<String, Integer> cache = jcache();
@@ -2649,7 +3336,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
/**
* @throws Exception In case of error.
*/
- public void testRemovexAsync() throws Exception {
+ public void testRemovexAsyncOld() throws Exception {
IgniteCache<String, Integer> cache = jcache();
IgniteCache<String, Integer> cacheAsync = cache.withAsync();
@@ -2670,22 +3357,45 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
/**
* @throws Exception In case of error.
*/
+ public void testRemovexAsync() throws Exception {
+ IgniteCache<String, Integer> cache = jcache();
+
+ cache.put("key1", 1);
+
+ assert cache.removeAsync("key1").get();
+
+ assert cache.get("key1") == null;
+
+ assert !cache.removeAsync("key1").get();
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
public void testGlobalRemoveAll() throws Exception {
- globalRemoveAll(false);
+ globalRemoveAll(false, false);
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testGlobalRemoveAllAsyncOld() throws Exception {
+ globalRemoveAll(true, true);
}
/**
* @throws Exception In case of error.
*/
public void testGlobalRemoveAllAsync() throws Exception {
- globalRemoveAll(true);
+ globalRemoveAll(true, false);
}
/**
* @param async If {@code true} uses asynchronous operation.
+ * @param oldAsync Use old async API.
* @throws Exception In case of error.
*/
- private void globalRemoveAll(boolean async) throws Exception {
+ private void globalRemoveAll(boolean async, boolean oldAsync) throws Exception {
IgniteCache<String, Integer> cache = jcache();
cache.put("key1", 1);
@@ -2699,9 +3409,13 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
IgniteCache<String, Integer> asyncCache = cache.withAsync();
if (async) {
- asyncCache.removeAll(F.asSet("key1", "key2"));
+ if (oldAsync) {
+ asyncCache.removeAll(F.asSet("key1", "key2"));
- asyncCache.future().get();
+ asyncCache.future().get();
+ }
+ else
+ cache.removeAllAsync(F.asSet("key1", "key2")).get();
}
else
cache.removeAll(F.asSet("key1", "key2"));
@@ -2720,11 +3434,15 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
atomicClockModeDelay(cache);
if (async) {
- IgniteCache asyncCache0 = jcache(gridCount() > 1 ? 1 : 0).withAsync();
+ if (oldAsync) {
+ IgniteCache asyncCache0 = jcache(gridCount() > 1 ? 1 : 0).withAsync();
- asyncCache0.removeAll();
+ asyncCache0.removeAll();
- asyncCache0.future().get();
+ asyncCache0.future().get();
+ }
+ else
+ jcache(gridCount() > 1 ? 1 : 0).removeAllAsync().get();
}
else
jcache(gridCount() > 1 ? 1 : 0).removeAll();
@@ -2741,9 +3459,13 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
atomicClockModeDelay(cache);
if (async) {
- asyncCache.removeAll();
+ if (oldAsync) {
+ asyncCache.removeAll();
- asyncCache.future().get();
+ asyncCache.future().get();
+ }
+ else
+ cache.removeAllAsync().get();
}
else
cache.removeAll();
@@ -2843,7 +3565,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
/**
* @throws Exception In case of error.
*/
- public void testRemoveAllAsync() throws Exception {
+ public void testRemoveAllAsyncOld() throws Exception {
IgniteCache<String, Integer> cache = jcache();
IgniteCache<String, Integer> cacheAsync = cache.withAsync();
@@ -2868,6 +3590,27 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
/**
* @throws Exception In case of error.
*/
+ public void testRemoveAllAsync() throws Exception {
+ IgniteCache<String, Integer> cache = jcache();
+
+ cache.put("key1", 1);
+ cache.put("key2", 2);
+ cache.put("key3", 3);
+
+ checkSize(F.asSet("key1", "key2", "key3"));
+
+ assertNull(cache.removeAllAsync(F.asSet("key1", "key2")).get());
+
+ checkSize(F.asSet("key3"));
+
+ checkContainsKey(false, "key1");
+ checkContainsKey(false, "key2");
+ checkContainsKey(true, "key3");
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
public void testLoadAll() throws Exception {
if (!storeEnabled())
return;
@@ -3101,21 +3844,29 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
* @throws Exception If failed.
*/
public void testGlobalClearAll() throws Exception {
- globalClearAll(false);
+ globalClearAll(false, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGlobalClearAllAsyncOld() throws Exception {
+ globalClearAll(true, true);
}
/**
* @throws Exception If failed.
*/
public void testGlobalClearAllAsync() throws Exception {
- globalClearAll(true);
+ globalClearAll(true, false);
}
/**
* @param async If {@code true} uses async method.
+ * @param oldAsync Use old async API.
* @throws Exception If failed.
*/
- protected void globalClearAll(boolean async) throws Exception {
+ protected void globalClearAll(boolean async, boolean oldAsync) throws Exception {
// Save entries only on their primary nodes. If we didn't do so, clearLocally() will not remove all entries
// because some of them were blocked due to having readers.
for (int i = 0; i < gridCount(); i++) {
@@ -3124,11 +3875,15 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
}
if (async) {
- IgniteCache asyncCache = jcache().withAsync();
+ if (oldAsync) {
+ IgniteCache asyncCache = jcache().withAsync();
- asyncCache.clear();
+ asyncCache.clear();
- asyncCache.future().get();
+ asyncCache.future().get();
+ }
+ else
+ jcache().clearAsync().get();
}
else
jcache().clear();
@@ -4189,8 +4944,10 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
* @throws Exception If failed.
*/
private void checkContainsKey(boolean exp, Object key) throws Exception {
- if (nearEnabled())
+ if (nearEnabled()) {
assertEquals(exp, jcache().containsKey(key));
+ assertEquals(exp, (boolean)jcache().containsKeyAsync(key).get());
+ }
else {
boolean contains = false;
@@ -4207,6 +4964,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
/**
* @param key Key.
+ * @return Ignite instance of the primary node for the specified key.
*/
protected Ignite primaryIgnite(String key) {
ClusterNode node = grid(0).affinity(cacheName()).mapKeyToNode(key);
@@ -4235,6 +4993,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
/**
* @param gridIdx Grid index.
* @param cnt Keys count.
+ * @param startFrom Key value to start.
* @return Collection of keys for which given cache is primary.
*/
protected List<String> primaryKeysForCache(int gridIdx, int cnt, int startFrom) {
@@ -4633,36 +5392,51 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
* @throws Exception If failed.
*/
public void testGlobalClearKey() throws Exception {
- testGlobalClearKey(false, Arrays.asList("key25"));
+ testGlobalClearKey(false, false, Arrays.asList("key25"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGlobalClearKeyAsyncOld() throws Exception {
+ testGlobalClearKey(true, true, Arrays.asList("key25"));
}
/**
* @throws Exception If failed.
*/
public void testGlobalClearKeyAsync() throws Exception {
- testGlobalClearKey(true, Arrays.asList("key25"));
+ testGlobalClearKey(true, false, Arrays.asList("key25"));
}
/**
* @throws Exception If failed.
*/
public void testGlobalClearKeys() throws Exception {
- testGlobalClearKey(false, Arrays.asList("key25", "key100", "key150"));
+ testGlobalClearKey(false, false, Arrays.asList("key25", "key100", "key150"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGlobalClearKeysAsyncOld() throws Exception {
+ testGlobalClearKey(true, true, Arrays.asList("key25", "key100", "key150"));
}
/**
* @throws Exception If failed.
*/
public void testGlobalClearKeysAsync() throws Exception {
- testGlobalClearKey(true, Arrays.asList("key25", "key100", "key150"));
+ testGlobalClearKey(true, false, Arrays.asList("key25", "key100", "key150"));
}
/**
* @param async If {@code true} uses async method.
+ * @param oldAsync Use old async API.
* @param keysToRmv Keys to remove.
* @throws Exception If failed.
*/
- protected void testGlobalClearKey(boolean async, Collection<String> keysToRmv) throws Exception {
+ protected void testGlobalClearKey(boolean async, boolean oldAsync, Collection<String> keysToRmv) throws Exception {
// Save entries only on their primary nodes. If we didn't do so, clearLocally() will not remove all entries
// because some of them were blocked due to having readers.
for (int i = 0; i < 500; ++i) {
@@ -4674,14 +5448,22 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
}
if (async) {
- IgniteCache asyncCache = jcache().withAsync();
+ if (oldAsync) {
+ IgniteCache asyncCache = jcache().withAsync();
- if (keysToRmv.size() == 1)
- asyncCache.clear(F.first(keysToRmv));
- else
- asyncCache.clearAll(new HashSet<>(keysToRmv));
+ if (keysToRmv.size() == 1)
+ asyncCache.clear(F.first(keysToRmv));
+ else
+ asyncCache.clearAll(new HashSet<>(keysToRmv));
- asyncCache.future().get();
+ asyncCache.future().get();
+ }
+ else {
+ if (keysToRmv.size() == 1)
+ jcache().clearAsync(F.first(keysToRmv)).get();
+ else
+ jcache().clearAllAsync(new HashSet<>(keysToRmv)).get();
+ }
}
else {
if (keysToRmv.size() == 1)
@@ -5254,20 +6036,29 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
* @throws Exception If failed.
*/
public void testGetOutTx() throws Exception {
- checkGetOutTx(false);
+ checkGetOutTx(false, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGetOutTxAsyncOld() throws Exception {
+ checkGetOutTx(true, true);
}
/**
* @throws Exception If failed.
*/
public void testGetOutTxAsync() throws Exception {
- checkGetOutTx(true);
+ checkGetOutTx(true, false);
}
/**
+ * @param async Use async API.
+ * @param oldAsync Uase old style async API.
* @throws Exception If failed.
*/
- private void checkGetOutTx(boolean async) throws Exception {
+ private void checkGetOutTx(boolean async, boolean oldAsync) throws Exception {
final AtomicInteger lockEvtCnt = new AtomicInteger();
IgnitePredicate<Event> lsnr = new IgnitePredicate<Event>() {
@@ -5290,21 +6081,40 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
grid(0).events().localListen(lsnr, EVT_CACHE_OBJECT_LOCKED, EVT_CACHE_OBJECT_UNLOCKED);
- if (async)
+ if (async && oldAsync)
cache = cache.withAsync();
try (Transaction tx = transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
- Integer val0 = cache.get(keys.get(0));
+ Integer val0;
+
+ if (async) {
+ if (oldAsync) {
+ cache.get(keys.get(0));
+
+ val0 = cache.<Integer>future().get();
+ }
+ else
+ val0 = cache.getAsync(keys.get(0)).get();
+ }
+ else
+ val0 = cache.get(keys.get(0));
- if (async)
- val0 = cache.<Integer>future().get();
assertEquals(0, val0.intValue());
- Map<String, Integer> allOutTx = cache.getAllOutTx(F.asSet(keys.get(1)));
+ Map<String, Integer> allOutTx;
+
+ if (async) {
+ if (oldAsync) {
+ cache.getAllOutTx(F.asSet(keys.get(1)));
- if (async)
- allOutTx = cache.<Map<String, Integer>>future().get();
+ allOutTx = cache.<Map<String, Integer>>future().get();
+ }
+ else
+ allOutTx = cache.getAllOutTxAsync(F.asSet(keys.get(1))).get();
+ }
+ else
+ allOutTx = cache.getAllOutTx(F.asSet(keys.get(1)));
assertEquals(1, allOutTx.size());
@@ -5337,13 +6147,13 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
* @throws Exception If failed.
*/
public void testInvokeException() throws Exception {
- final IgniteCache cache = jcache().withAsync();
+ final IgniteCache cache = jcache();
- cache.invoke("key2", ERR_PROCESSOR);
+ final IgniteFuture fut = cache.invokeAsync("key2", ERR_PROCESSOR);
assertThrows(log, new Callable<Object>() {
@Override public Object call() throws Exception {
- IgniteFuture fut = cache.future().chain(new IgniteClosure<IgniteFuture, Object>() {
+ fut.chain(new IgniteClosure<IgniteFuture, Object>() {
@Override public Object apply(IgniteFuture o) {
return o.get();
}
@@ -5457,6 +6267,45 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar
}
/**
+ * @throws Exception If failed.
+ */
+ public void testGetEntry() throws Exception {
+ runInAllDataModes(new TestRunnable() {
+ @Override public void run() throws Exception {
+ Map<String, Integer> vals = new HashMap<>();
+
+ for (int i = 0; i < CNT; i++)
+ vals.put("key" + i, i);
+
+ jcache(0).putAll(vals);
+
+ for (int i = 0; i < gridCount(); i++) {
+ assertEquals(0, jcache(i).getEntry("key0").getValue());
+ assertEquals(0, jcache(i).getEntryAsync("key0").get().getValue());
+
+ assertTrue(
+ F.transform(
+ jcache(i).getEntries(vals.keySet()),
+ new IgniteClosure<CacheEntry<Object, Object>, Object>() {
+ @Override public Object apply(CacheEntry<Object, Object> entry) {
+ return entry.getValue();
+ }
+ }).containsAll(vals.values()));
+
+ assertTrue(
+ F.transform(
+ jcache(i).getEntriesAsync(vals.keySet()).get(),
+ new IgniteClosure<CacheEntry<Object, Object>, Object>() {
+ @Override public Object apply(CacheEntry<Object, Object> entry) {
+ return entry.getValue();
+ }
+ }).containsAll(vals.values()));
+ }
+ }
+ });
+ }
+
+ /**
* Sets given value, returns old value.
*/
public static final class SetValueProcessor implements EntryProcessor<String, Integer, Integer> {
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeAbstractTest.java
index 51a70b9..9681e97 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeAbstractTest.java
@@ -178,13 +178,7 @@ public abstract class IgniteCacheInvokeAbstractTest extends IgniteCacheAbstractT
checkValue(key, 63);
- IgniteCache<Integer, Integer> asyncCache = cache.withAsync();
-
- assertTrue(asyncCache.isAsync());
-
- assertNull(asyncCache.invoke(key, incProcessor));
-
- IgniteFuture<Integer> fut = asyncCache.future();
+ IgniteFuture<Integer> fut = cache.invokeAsync(key, incProcessor);
assertNotNull(fut);
@@ -484,13 +478,7 @@ public abstract class IgniteCacheInvokeAbstractTest extends IgniteCacheAbstractT
checkValue(key, null);
}
- IgniteCache<Integer, Integer> asyncCache = cache.withAsync();
-
- assertTrue(asyncCache.isAsync());
-
- assertNull(asyncCache.invokeAll(keys, new IncrementProcessor()));
-
- IgniteFuture<Map<Integer, EntryProcessorResult<Integer>>> fut = asyncCache.future();
+ IgniteFuture<Map<Integer, EntryProcessorResult<Integer>>> fut = cache.invokeAllAsync(keys, new IncrementProcessor());
Map<Integer, EntryProcessorResult<Integer>> resMap = fut.get();
@@ -509,9 +497,7 @@ public abstract class IgniteCacheInvokeAbstractTest extends IgniteCacheAbstractT
for (Integer key : keys)
invokeMap.put(key, incProcessor);
- assertNull(asyncCache.invokeAll(invokeMap));
-
- fut = asyncCache.future();
+ fut = cache.invokeAllAsync(invokeMap);
resMap = fut.get();
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheManyAsyncOperationsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheManyAsyncOperationsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheManyAsyncOperationsTest.java
index cb9c2d7..76667c5 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheManyAsyncOperationsTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheManyAsyncOperationsTest.java
@@ -74,7 +74,7 @@ public class IgniteCacheManyAsyncOperationsTest extends IgniteCacheAbstractTest
try (Ignite client = startGrid(gridCount())) {
assertTrue(client.configuration().isClientMode());
- IgniteCache<Object, Object> cache = client.cache(null).withAsync();
+ IgniteCache<Object, Object> cache = client.cache(null);
final int ASYNC_OPS = cache.getConfiguration(CacheConfiguration.class).getMaxConcurrentAsyncOperations();
@@ -91,9 +91,7 @@ public class IgniteCacheManyAsyncOperationsTest extends IgniteCacheAbstractTest
List<IgniteFuture<?>> futs = new ArrayList<>(ASYNC_OPS);
for (int i = 0; i < ASYNC_OPS; i++) {
- cache.putAll(map);
-
- futs.add(cache.future());
+ futs.add(cache.putAllAsync(map));
if (i % 50 == 0)
log.info("Created futures: " + (i + 1));
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekModesAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekModesAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekModesAbstractTest.java
index fa1677c..343653c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekModesAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekModesAbstractTest.java
@@ -394,8 +394,6 @@ public abstract class IgniteCachePeekModesAbstractTest extends IgniteCacheAbstra
if (cacheMode() == LOCAL) {
IgniteCache<Integer, String> cache0 = jcache(0);
- IgniteCache<Integer, String> cacheAsync0 = cache0.withAsync();
-
for (int i = 0; i < HEAP_ENTRIES; i++) {
cache0.put(i, String.valueOf(i));
@@ -413,13 +411,9 @@ public abstract class IgniteCachePeekModesAbstractTest extends IgniteCacheAbstra
assertEquals(size, cache0.size(NEAR));
assertEquals(size, cache0.size(ALL));
- cacheAsync0.size();
-
- assertEquals(size, cacheAsync0.future().get());
-
- cacheAsync0.size(PRIMARY);
+ assertEquals(size, (int) cache0.sizeAsync().get());
- assertEquals(size, cacheAsync0.future().get());
+ assertEquals(size, (int) cache0.sizeAsync(PRIMARY).get());
}
for (int i = 0; i < HEAP_ENTRIES; i++) {
@@ -439,9 +433,7 @@ public abstract class IgniteCachePeekModesAbstractTest extends IgniteCacheAbstra
assertEquals(size, cache0.size(NEAR));
assertEquals(size, cache0.size(ALL));
- cacheAsync0.size();
-
- assertEquals(size, cacheAsync0.future().get());
+ assertEquals(size, (int) cache0.sizeAsync().get());
}
checkEmpty();
@@ -514,8 +506,6 @@ public abstract class IgniteCachePeekModesAbstractTest extends IgniteCacheAbstra
int part = 0;
IgniteCache<Integer, String> cache0 = jcache(0);
- IgniteCache<Integer, String> cacheAsync0 = cache0.withAsync();
-
for (int i = 0; i < HEAP_ENTRIES; i++) {
cache0.put(i, String.valueOf(i));
@@ -533,13 +523,9 @@ public abstract class IgniteCachePeekModesAbstractTest extends IgniteCacheAbstra
assertEquals(size, cache0.sizeLong(part, NEAR));
assertEquals(size, cache0.sizeLong(part, ALL));
- cacheAsync0.size();
+ assertEquals(size, (long) cache0.sizeAsync().get());
- assertEquals(size, (long) cacheAsync0.<Integer>future().get());
-
- cacheAsync0.sizeLong(part, PRIMARY);
-
- assertEquals(size, cacheAsync0.future().get());
+ assertEquals(size, (long) cache0.sizeLongAsync(part, PRIMARY).get());
}
for (int i = 0; i < HEAP_ENTRIES; i++) {
@@ -559,9 +545,7 @@ public abstract class IgniteCachePeekModesAbstractTest extends IgniteCacheAbstra
assertEquals(size, cache0.sizeLong(part, NEAR));
assertEquals(size, cache0.sizeLong(part, ALL));
- cacheAsync0.size();
-
- assertEquals(size, (long) cacheAsync0.<Integer>future().get());
+ assertEquals(size, (long) cache0.sizeAsync().get());
}
}
@@ -995,6 +979,7 @@ public abstract class IgniteCachePeekModesAbstractTest extends IgniteCacheAbstra
* @param nodeIdx Node index.
* @param part Cache partition
* @return Tuple with number of primary and backup keys (one or both will be zero).
+ * @throws IgniteCheckedException If failed.
*/
private T2<Integer, Integer> swapKeysCount(int nodeIdx, int part) throws IgniteCheckedException {
GridCacheContext ctx = ((IgniteEx)ignite(nodeIdx)).context().cache().internalCache().context();
@@ -1331,15 +1316,11 @@ public abstract class IgniteCachePeekModesAbstractTest extends IgniteCacheAbstra
for (int i = 0; i < gridCount(); i++) {
IgniteCache<Integer, String> cache = jcache(i);
- IgniteCache<Integer, String> cacheAsync = cache.withAsync();
-
assertEquals(exp, cache.size(PRIMARY));
size += cache.localSize(PRIMARY);
- cacheAsync.size(PRIMARY);
-
- assertEquals(exp, cacheAsync.future().get());
+ assertEquals(exp, (int) cache.sizeAsync(PRIMARY).get());
}
assertEquals(exp, size);
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/WithKeepBinaryCacheFullApiTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/WithKeepBinaryCacheFullApiTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/WithKeepBinaryCacheFullApiTest.java
index 3e6b0b0..a8eb01d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/WithKeepBinaryCacheFullApiTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/WithKeepBinaryCacheFullApiTest.java
@@ -31,6 +31,7 @@ import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.cache.CacheEntry;
import org.apache.ignite.cache.CacheEntryProcessor;
import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.testframework.junits.IgniteCacheConfigVariationsAbstractTest;
import org.apache.ignite.transactions.Transaction;
import org.apache.ignite.transactions.TransactionConcurrency;
@@ -180,7 +181,7 @@ public class WithKeepBinaryCacheFullApiTest extends IgniteCacheConfigVariationsA
public void testRemovePutGetAsync() throws Exception {
runInAllDataModes(new TestRunnable() {
@Override public void run() throws Exception {
- final IgniteCache cache = jcache().withKeepBinary().withAsync();
+ final IgniteCache cache = jcache().withKeepBinary();
final Set keys = new LinkedHashSet() {{
for (int i = 0; i < CNT; i++)
@@ -189,22 +190,17 @@ public class WithKeepBinaryCacheFullApiTest extends IgniteCacheConfigVariationsA
runInAllTxModes(new TestRunnable() {
@Override public void run() throws Exception {
- for (Object key : keys) {
- cache.remove(key);
-
- cache.future().get();
- }
+ for (Object key : keys)
+ cache.removeAsync(key).get();
}
});
runInAllTxModes(new TestRunnable() {
@Override public void run() throws Exception {
for (Object key : keys) {
- cache.get(key);
- assertNull(cache.future().get());
+ assertNull(cache.getAsync(key).get());
- cache.getEntry(key);
- assertNull(cache.future().get());
+ assertNull(cache.getEntryAsync(key).get());
}
}
});
@@ -215,17 +211,14 @@ public class WithKeepBinaryCacheFullApiTest extends IgniteCacheConfigVariationsA
@Override public void run() throws Exception {
Object val = value(valueOf(key));
- cache.put(key, val);
-
- cache.future().get();
+ cache.putAsync(key, val).get();
- cache.get(key);
- BinaryObject retVal = (BinaryObject)cache.future().get();
+ BinaryObject retVal = (BinaryObject)cache.getAsync(key).get();
assertEquals(val, retVal.deserialize());
- cache.getEntry(key);
- CacheEntry<BinaryObject, BinaryObject> e = (CacheEntry<BinaryObject, BinaryObject>)cache.future().get();
+ CacheEntry<BinaryObject, BinaryObject> e =
+ (CacheEntry<BinaryObject, BinaryObject>)cache.getEntryAsync(key).get();
assertEquals(key, deserializeBinary(e.getKey()));
@@ -311,7 +304,7 @@ public class WithKeepBinaryCacheFullApiTest extends IgniteCacheConfigVariationsA
public void testPutAllGetAllAsync() throws Exception {
runInAllDataModes(new TestRunnable() {
@Override public void run() throws Exception {
- final IgniteCache cache = jcache().withKeepBinary().withAsync();
+ final IgniteCache cache = jcache().withKeepBinary();
final Set keys = new LinkedHashSet() {{
for (int i = 0; i < CNT; i++)
@@ -320,8 +313,7 @@ public class WithKeepBinaryCacheFullApiTest extends IgniteCacheConfigVariationsA
runInAllTxModes(new TestRunnable() {
@Override public void run() throws Exception {
- cache.getAll(keys);
- Map res = (Map)cache.future().get();
+ Map res = (Map)cache.getAllAsync(keys).get();
for (Object val : res.values())
assertNull(val);
@@ -330,9 +322,8 @@ public class WithKeepBinaryCacheFullApiTest extends IgniteCacheConfigVariationsA
runInAllTxModes(new TestRunnable() {
@Override public void run() throws Exception {
- cache.<CacheEntry>getEntries(keys);
-
- Collection<CacheEntry> entries = (Collection<CacheEntry>)cache.future().get();
+ Collection<CacheEntry> entries =
+ (Collection<CacheEntry>)cache.<CacheEntry>getEntriesAsync(keys).get();
for (CacheEntry e : entries)
assertNull(e.getValue());
@@ -349,12 +340,10 @@ public class WithKeepBinaryCacheFullApiTest extends IgniteCacheConfigVariationsA
}
}};
- cache.putAll(keyValMap);
-
- cache.future().get();
+ cache.putAllAsync(keyValMap).get();
- cache.getAll(keys);
- Set<Map.Entry<BinaryObject, BinaryObject>> set = ((Map)cache.future().get()).entrySet();
+ Set<Map.Entry<BinaryObject, BinaryObject>> set =
+ ((Map)cache.getAllAsync(keys).get()).entrySet();
for (Map.Entry<BinaryObject, BinaryObject> e : set) {
Object expVal = value(valueOf(e.getKey().deserialize()));
@@ -362,10 +351,8 @@ public class WithKeepBinaryCacheFullApiTest extends IgniteCacheConfigVariationsA
assertEquals(expVal, e.getValue().deserialize());
}
- cache.getEntries(keys);
-
Collection<CacheEntry<BinaryObject, BinaryObject>> entries =
- (Collection<CacheEntry<BinaryObject, BinaryObject>>)cache.future().get();
+ (Collection<CacheEntry<BinaryObject, BinaryObject>>)cache.getEntriesAsync(keys).get();
for (CacheEntry<BinaryObject, BinaryObject> e : entries) {
assertTrue(e.getKey() instanceof BinaryObject);
@@ -375,9 +362,8 @@ public class WithKeepBinaryCacheFullApiTest extends IgniteCacheConfigVariationsA
assertEquals(expVal, e.getValue().deserialize());
}
- cache.removeAll(keys);
+ cache.removeAllAsync(keys).get();
- cache.future().get();
}
});
}
@@ -575,7 +561,7 @@ public class WithKeepBinaryCacheFullApiTest extends IgniteCacheConfigVariationsA
public void testInvokeAsync() throws Exception {
runInAllDataModes(new TestRunnable() {
@Override public void run() throws Exception {
- final IgniteCache cache = jcache().withKeepBinary().withAsync();
+ final IgniteCache cache = jcache().withKeepBinary();
Set keys = new LinkedHashSet() {{
for (int i = 0; i < CNT; i++)
@@ -583,41 +569,27 @@ public class WithKeepBinaryCacheFullApiTest extends IgniteCacheConfigVariationsA
}};
for (final Object key : keys) {
- cache.invoke(key, NOOP_ENTRY_PROC);
-
- Object res = cache.future().get();
+ Object res = cache.invokeAsync(key, NOOP_ENTRY_PROC).get();
assertNull(res);
- cache.get(key);
-
- assertNull(cache.future().get());
+ assertNull(cache.getAsync(key).get());
}
for (final Object key : keys) {
- cache.invoke(key, INC_ENTRY_PROC_BINARY_OBJ, dataMode);
-
- Object res = cache.future().get();
+ Object res = cache.invokeAsync(key, INC_ENTRY_PROC_BINARY_OBJ, dataMode).get();
assertNull(res);
- cache.get(key);
-
- assertEquals(value(0), deserializeBinary(cache.future().get()));
-
- cache.invoke(key, INC_ENTRY_PROC_BINARY_OBJ, dataMode);
+ assertEquals(value(0), deserializeBinary(cache.getAsync(key).get()));
- res = cache.future().get();
+ res = cache.invokeAsync(key, INC_ENTRY_PROC_BINARY_OBJ, dataMode).get();
assertEquals(value(0), deserializeBinary(res));
- cache.get(key);
+ assertEquals(value(1), deserializeBinary(cache.getAsync(key).get()));
- assertEquals(value(1), deserializeBinary(cache.future().get()));
-
- cache.remove(key);
-
- assertTrue((Boolean)cache.future().get());
+ assertTrue((Boolean)cache.removeAsync(key).get());
}
// TODO IGNITE-2973: should be always false.
@@ -625,30 +597,20 @@ public class WithKeepBinaryCacheFullApiTest extends IgniteCacheConfigVariationsA
try {
for (final Object key : keys) {
- cache.invoke(key, INC_ENTRY_PROC_USER_OBJ, dataMode);
-
- Object res = cache.future().get();
+ Object res = cache.invokeAsync(key, INC_ENTRY_PROC_USER_OBJ, dataMode).get();
assertNull(res);
- cache.get(key);
-
- assertEquals(value(0), deserializeBinary(cache.future().get()));
+ assertEquals(value(0), deserializeBinary(cache.getAsync(key).get()));
- cache.invoke(key, INC_ENTRY_PROC_USER_OBJ, dataMode);
-
- res = cache.future().get();
+ res = cache.invokeAsync(key, INC_ENTRY_PROC_USER_OBJ, dataMode).get();
// TODO IGNITE-2953: uncomment the following assert when the issue will be fixed.
// assertEquals(value(0), res);
- cache.get(key);
-
- assertEquals(value(1), deserializeBinary(cache.future().get()));
+ assertEquals(value(1), deserializeBinary(cache.getAsync(key).get()));
- cache.remove(key);
-
- assertTrue((Boolean)cache.future().get());
+ assertTrue((Boolean)cache.removeAsync(key).get());
}
}
finally {
@@ -683,7 +645,7 @@ public class WithKeepBinaryCacheFullApiTest extends IgniteCacheConfigVariationsA
public void checkInvokeAsyncTx(final TransactionConcurrency conc, final TransactionIsolation isolation) throws Exception {
runInAllDataModes(new TestRunnable() {
@Override public void run() throws Exception {
- final IgniteCache cache = jcache().withKeepBinary().withAsync();
+ final IgniteCache cache = jcache().withKeepBinary();
Set keys = new LinkedHashSet() {{
for (int i = 0; i < CNT; i++)
@@ -692,15 +654,11 @@ public class WithKeepBinaryCacheFullApiTest extends IgniteCacheConfigVariationsA
try (Transaction tx = testedGrid().transactions().txStart(conc, isolation)) {
for (final Object key : keys) {
- cache.invoke(key, NOOP_ENTRY_PROC);
-
- Object res = cache.future().get();
+ Object res = cache.invokeAsync(key, NOOP_ENTRY_PROC).get();
assertNull(res);
- cache.get(key);
-
- assertNull(cache.future().get());
+ assertNull(cache.getAsync(key).get());
}
tx.commit();
@@ -710,37 +668,31 @@ public class WithKeepBinaryCacheFullApiTest extends IgniteCacheConfigVariationsA
Object res;
try (Transaction tx = testedGrid().transactions().txStart(conc, isolation)) {
- cache.invoke(key, INC_ENTRY_PROC_BINARY_OBJ, dataMode);
-
- res = cache.future().get();
+ res = cache.invokeAsync(key, INC_ENTRY_PROC_BINARY_OBJ, dataMode).get();
tx.commit();
}
assertNull(res);
- cache.get(key);
+ assertEquals(value(0), deserializeBinary(cache.getAsync(key).get()));
- assertEquals(value(0), deserializeBinary(cache.future().get()));
+ IgniteFuture f;
try (Transaction tx = testedGrid().transactions().txStart(conc, isolation)) {
- cache.invoke(key, INC_ENTRY_PROC_BINARY_OBJ, dataMode);
+ f = cache.invokeAsync(key, INC_ENTRY_PROC_BINARY_OBJ, dataMode);
tx.commit();
}
- res = cache.future().get();
+ res = f.get();
assertEquals(value(0), deserializeBinary(res));
- cache.get(key);
-
- assertEquals(value(1), deserializeBinary(cache.future().get()));
+ assertEquals(value(1), deserializeBinary(cache.getAsync(key).get()));
try (Transaction tx = testedGrid().transactions().txStart(conc, isolation)) {
- cache.remove(key);
-
- assertTrue((Boolean)cache.future().get());
+ assertTrue((Boolean)cache.removeAsync(key).get());
tx.commit();
}
@@ -754,23 +706,17 @@ public class WithKeepBinaryCacheFullApiTest extends IgniteCacheConfigVariationsA
Object res;
try (Transaction tx = testedGrid().transactions().txStart(conc, isolation)) {
- cache.invoke(key, INC_ENTRY_PROC_USER_OBJ, dataMode);
-
- res = cache.future().get();
+ res = cache.invokeAsync(key, INC_ENTRY_PROC_USER_OBJ, dataMode).get();
tx.commit();
}
assertNull(res);
- cache.get(key);
-
- assertEquals(value(0), deserializeBinary(cache.future().get()));
+ assertEquals(value(0), deserializeBinary(cache.getAsync(key).get()));
try (Transaction tx = testedGrid().transactions().txStart(conc, isolation)) {
- cache.invoke(key, INC_ENTRY_PROC_USER_OBJ, dataMode);
-
- res = cache.future().get();
+ res = cache.invokeAsync(key, INC_ENTRY_PROC_USER_OBJ, dataMode).get();
tx.commit();
}
@@ -778,14 +724,10 @@ public class WithKeepBinaryCacheFullApiTest extends IgniteCacheConfigVariationsA
// TODO IGNITE-2953: uncomment the following assert when the issue will be fixed.
// assertEquals(value(0), res);
- cache.get(key);
-
- assertEquals(value(1), deserializeBinary(cache.future().get()));
+ assertEquals(value(1), deserializeBinary(cache.getAsync(key).get()));
try (Transaction tx = testedGrid().transactions().txStart(conc, isolation)) {
- cache.remove(key);
-
- assertTrue((Boolean)cache.future().get());
+ assertTrue((Boolean)cache.removeAsync(key).get());
tx.commit();
}
@@ -988,17 +930,15 @@ public class WithKeepBinaryCacheFullApiTest extends IgniteCacheConfigVariationsA
public void testInvokeAllAsync() throws Exception {
runInAllDataModes(new TestRunnable() {
@Override public void run() throws Exception {
- final IgniteCache cache = jcache().withKeepBinary().withAsync();
+ final IgniteCache cache = jcache().withKeepBinary();
final Set keys = new LinkedHashSet() {{
for (int i = 0; i < CNT; i++)
add(key(i));
}};
- cache.invokeAll(keys, NOOP_ENTRY_PROC);
-
Map<Object, EntryProcessorResult<Object>> resMap =
- (Map<Object, EntryProcessorResult<Object>>)cache.future().get();
+ (Map<Object, EntryProcessorResult<Object>>)cache.invokeAllAsync(keys, NOOP_ENTRY_PROC).get();
for (Map.Entry<Object, EntryProcessorResult<Object>> e : resMap.entrySet()) {
assertTrue("Wrong key type, binary object expected: " + e.getKey(), e.getKey() instanceof BinaryObject);
@@ -1006,41 +946,33 @@ public class WithKeepBinaryCacheFullApiTest extends IgniteCacheConfigVariationsA
assertNull(e.getValue().get());
}
- cache.invokeAll(keys, INC_ENTRY_PROC_BINARY_OBJ, dataMode);
-
- resMap = (Map<Object, EntryProcessorResult<Object>>)cache.future().get();
+ resMap = (Map<Object, EntryProcessorResult<Object>>)
+ cache.invokeAllAsync(keys, INC_ENTRY_PROC_BINARY_OBJ, dataMode).get();
checkInvokeAllAsyncResult(cache, resMap, null, value(0), true);
- cache.invokeAll(keys, INC_ENTRY_PROC_BINARY_OBJ, dataMode);
-
- resMap = (Map<Object, EntryProcessorResult<Object>>)cache.future().get();
+ resMap = (Map<Object, EntryProcessorResult<Object>>)
+ cache.invokeAllAsync(keys, INC_ENTRY_PROC_BINARY_OBJ, dataMode).get();
checkInvokeAllAsyncResult(cache, resMap, value(0), value(1), true);
- cache.removeAll(keys);
-
- cache.future().get();
+ cache.removeAllAsync(keys).get();
// TODO IGNITE-2973: should be always false.
interceptorBinaryObjExp = atomicityMode() == TRANSACTIONAL;
try {
- cache.invokeAll(keys, INC_ENTRY_PROC_USER_OBJ, dataMode);
-
- resMap = (Map<Object, EntryProcessorResult<Object>>)cache.future().get();
+ resMap = (Map<Object, EntryProcessorResult<Object>>)
+ cache.invokeAllAsync(keys, INC_ENTRY_PROC_USER_OBJ, dataMode).get();
checkInvokeAllAsyncResult(cache, resMap, null, value(0), false);
- cache.invokeAll(keys, INC_ENTRY_PROC_USER_OBJ, dataMode);
-
- resMap = (Map<Object, EntryProcessorResult<Object>>)cache.future().get();
+ resMap = (Map<Object, EntryProcessorResult<Object>>)
+ cache.invokeAllAsync(keys, INC_ENTRY_PROC_USER_OBJ, dataMode).get();
checkInvokeAllAsyncResult(cache, resMap, value(0), value(1), false);
- cache.removeAll(keys);
-
- cache.future().get();
+ cache.removeAllAsync(keys).get();
}
finally {
interceptorBinaryObjExp = true;
@@ -1070,12 +1002,12 @@ public class WithKeepBinaryCacheFullApiTest extends IgniteCacheConfigVariationsA
*
* @param conc Concurrency.
* @param isolation Isolation.
- * @throws Exception
+ * @throws Exception If failed.
*/
private void checkInvokeAllAsycnTx(final TransactionConcurrency conc, final TransactionIsolation isolation) throws Exception {
runInAllDataModes(new TestRunnable() {
@Override public void run() throws Exception {
- final IgniteCache cache = jcache().withKeepBinary().withAsync();
+ final IgniteCache cache = jcache().withKeepBinary();
final Set keys = new LinkedHashSet() {{
for (int i = 0; i < CNT; i++)
@@ -1085,9 +1017,8 @@ public class WithKeepBinaryCacheFullApiTest extends IgniteCacheConfigVariationsA
Map<Object, EntryProcessorResult<Object>> resMap;
try (Transaction tx = testedGrid().transactions().txStart(conc, isolation)) {
- cache.invokeAll(keys, NOOP_ENTRY_PROC);
-
- resMap = (Map<Object, EntryProcessorResult<Object>>)cache.future().get();
+ resMap = (Map<Object, EntryProcessorResult<Object>>)
+ cache.invokeAllAsync(keys, NOOP_ENTRY_PROC).get();
tx.commit();
}
@@ -1099,9 +1030,8 @@ public class WithKeepBinaryCacheFullApiTest extends IgniteCacheConfigVariationsA
}
try (Transaction tx = testedGrid().transactions().txStart(conc, isolation)) {
- cache.invokeAll(keys, INC_ENTRY_PROC_BINARY_OBJ, dataMode);
-
- resMap = (Map<Object, EntryProcessorResult<Object>>)cache.future().get();
+ resMap = (Map<Object, EntryProcessorResult<Object>>)
+ cache.invokeAllAsync(keys, INC_ENTRY_PROC_BINARY_OBJ, dataMode).get();
tx.commit();
}
@@ -1109,9 +1039,8 @@ public class WithKeepBinaryCacheFullApiTest extends IgniteCacheConfigVariationsA
checkInvokeAllAsyncResult(cache, resMap, null, value(0), true);
try (Transaction tx = testedGrid().transactions().txStart(conc, isolation)) {
- cache.invokeAll(keys, INC_ENTRY_PROC_BINARY_OBJ, dataMode);
-
- resMap = (Map<Object, EntryProcessorResult<Object>>)cache.future().get();
+ resMap = (Map<Object, EntryProcessorResult<Object>>)
+ cache.invokeAllAsync(keys, INC_ENTRY_PROC_BINARY_OBJ, dataMode).get();
tx.commit();
}
@@ -1119,9 +1048,7 @@ public class WithKeepBinaryCacheFullApiTest extends IgniteCacheConfigVariationsA
checkInvokeAllAsyncResult(cache, resMap, value(0), value(1), true);
try (Transaction tx = testedGrid().transactions().txStart(conc, isolation)) {
- cache.removeAll(keys);
-
- cache.future().get();
+ cache.removeAllAsync(keys).get();
tx.commit();
}
@@ -1131,9 +1058,8 @@ public class WithKeepBinaryCacheFullApiTest extends IgniteCacheConfigVariationsA
try {
try (Transaction tx = testedGrid().transactions().txStart(conc, isolation)) {
- cache.invokeAll(keys, INC_ENTRY_PROC_USER_OBJ, dataMode);
-
- resMap = (Map<Object, EntryProcessorResult<Object>>)cache.future().get();
+ resMap = (Map<Object, EntryProcessorResult<Object>>)
+ cache.invokeAllAsync(keys, INC_ENTRY_PROC_USER_OBJ, dataMode).get();
tx.commit();
}
@@ -1141,9 +1067,8 @@ public class WithKeepBinaryCacheFullApiTest extends IgniteCacheConfigVariationsA
checkInvokeAllAsyncResult(cache, resMap, null, value(0), false);
try (Transaction tx = testedGrid().transactions().txStart(conc, isolation)) {
- cache.invokeAll(keys, INC_ENTRY_PROC_USER_OBJ, dataMode);
-
- resMap = (Map<Object, EntryProcessorResult<Object>>)cache.future().get();
+ resMap = (Map<Object, EntryProcessorResult<Object>>)
+ cache.invokeAllAsync(keys, INC_ENTRY_PROC_USER_OBJ, dataMode).get();
tx.commit();
}
@@ -1151,9 +1076,7 @@ public class WithKeepBinaryCacheFullApiTest extends IgniteCacheConfigVariationsA
checkInvokeAllAsyncResult(cache, resMap, value(0), value(1), false);
try (Transaction tx = testedGrid().transactions().txStart(conc, isolation)) {
- cache.removeAll(keys);
-
- cache.future().get();
+ cache.removeAllAsync(keys).get();
tx.commit();
}
@@ -1185,9 +1108,7 @@ public class WithKeepBinaryCacheFullApiTest extends IgniteCacheConfigVariationsA
if (deserializeRes)
assertEquals(expRes, deserializeRes ? deserializeBinary(res) : res);
- cache.get(e.getKey());
-
- assertEquals(cacheVal, deserializeBinary(cache.future().get()));
+ assertEquals(cacheVal, deserializeBinary(cache.getAsync(e.getKey()).get()));
}
}
@@ -1203,6 +1124,7 @@ public class WithKeepBinaryCacheFullApiTest extends IgniteCacheConfigVariationsA
/**
* @param task Task.
+ * @throws Exception If failed.
*/
protected void runInAllTxModes(TestRunnable task) throws Exception {
info("Executing implicite tx");
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/CacheKeepBinaryWithInterceptorTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/CacheKeepBinaryWithInterceptorTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/CacheKeepBinaryWithInterceptorTest.java
index 1e05400..bc9214f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/CacheKeepBinaryWithInterceptorTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/CacheKeepBinaryWithInterceptorTest.java
@@ -102,8 +102,6 @@ public class CacheKeepBinaryWithInterceptorTest extends GridCommonAbstractTest {
IgniteCache cache = ignite(0).cache(null).withKeepBinary();
- IgniteCache asyncCache = cache.withAsync();
-
cache.put(new TestKey(1), new TestValue(10));
cache.put(new TestKey(1), new TestValue(10));
@@ -111,16 +109,14 @@ public class CacheKeepBinaryWithInterceptorTest extends GridCommonAbstractTest {
BinaryObject obj = (BinaryObject)cache.get(new TestKey(1));
assertEquals(10, (int)obj.field("val"));
- asyncCache.get(new TestKey(1));
- obj = (BinaryObject)asyncCache.future().get();
+ obj = (BinaryObject)cache.getAsync(new TestKey(1)).get();
assertEquals(10, (int)obj.field("val"));
Cache.Entry<BinaryObject, BinaryObject> e = (Cache.Entry)cache.getEntry(new TestKey(1));
assertEquals(1, (int)e.getKey().field("key"));
assertEquals(10, (int)e.getValue().field("val"));
- asyncCache.getEntry(new TestKey(1));
- e = (Cache.Entry)asyncCache.future().get();
+ e = (Cache.Entry)cache.getEntryAsync(new TestKey(1)).get();
assertEquals(1, (int)e.getKey().field("key"));
assertEquals(10, (int)e.getValue().field("val"));
@@ -157,8 +153,6 @@ public class CacheKeepBinaryWithInterceptorTest extends GridCommonAbstractTest {
IgniteCache cache = ignite(0).cache(null).withKeepBinary();
- IgniteCache asyncCache = cache.withAsync();
-
cache.put(1, 10);
cache.put(1, 10);
@@ -166,16 +160,14 @@ public class CacheKeepBinaryWithInterceptorTest extends GridCommonAbstractTest {
Integer obj = (Integer)cache.get(1);
assertEquals((Integer)10, obj);
- asyncCache.get(1);
- obj = (Integer)asyncCache.future().get();
+ obj = (Integer)cache.getAsync(1).get();
assertEquals((Integer)10, obj);
Cache.Entry<Integer, Integer> e = (Cache.Entry)cache.getEntry(1);
assertEquals((Integer)1, e.getKey());
assertEquals((Integer)10, e.getValue());
- asyncCache.getEntry(1);
- e = (Cache.Entry)asyncCache.future().get();
+ e = (Cache.Entry)cache.getEntryAsync(1).get();
assertEquals((Integer)1, e.getKey());
assertEquals((Integer)10, e.getValue());
[05/10] ignite git commit: IGNITE-4475: New async API: now all async
methods are defined explicitly,
IgniteAsyncSupport is deprecated. This closes #1648.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/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 b39dabc..20bd9eb 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
@@ -711,6 +711,26 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
cache.put("key1", 1);
cache.put("key2", 2);
+ IgniteFuture<Integer> fut1 = cache.getAsync("key1");
+
+ IgniteFuture<Integer> fut2 = cache.getAsync("key2");
+
+ IgniteFuture<Integer> fut3 = cache.getAsync("wrongKey");
+
+ assert fut1.get() == 1;
+ assert fut2.get() == 2;
+ assert fut3.get() == null;
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testGetAsyncOld() throws Exception {
+ IgniteCache<String, Integer> cache = jcache();
+
+ cache.put("key1", 1);
+ cache.put("key2", 2);
+
IgniteCache<String, Integer> cacheAsync = cache.withAsync();
cacheAsync.get("key1");
@@ -730,6 +750,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
assert fut3.get() == null;
}
+
/**
* @throws Exception In case of error.
*/
@@ -963,6 +984,33 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
public void testGetAllAsync() throws Exception {
final IgniteCache<String, Integer> cache = jcache();
+ cache.put("key1", 1);
+ cache.put("key2", 2);
+
+ GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ cache.getAllAsync(null);
+
+ return null;
+ }
+ }, NullPointerException.class, null);
+
+ IgniteFuture<Map<String, Integer>> fut2 = cache.getAllAsync(Collections.<String>emptySet());
+
+ IgniteFuture<Map<String, Integer>> fut3 = cache.getAllAsync(ImmutableSet.of("key1", "key2"));
+
+ assert fut2.get().isEmpty();
+ assert fut3.get().size() == 2 : "Invalid map: " + fut3.get();
+ assert fut3.get().get("key1") == 1;
+ assert fut3.get().get("key2") == 2;
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testGetAllAsyncOld() throws Exception {
+ final IgniteCache<String, Integer> cache = jcache();
+
final IgniteCache<String, Integer> cacheAsync = cache.withAsync();
cache.put("key1", 1);
@@ -1581,7 +1629,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
/**
* @throws Exception In case of error.
*/
- public void testGetAndPutAsync() throws Exception {
+ public void testGetAndPutAsyncOld() throws Exception {
IgniteCache<String, Integer> cache = jcache();
IgniteCache<String, Integer> cacheAsync = cache.withAsync();
@@ -1607,7 +1655,27 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
/**
* @throws Exception In case of error.
*/
- public void testPutAsync0() throws Exception {
+ public void testGetAndPutAsync() throws Exception {
+ IgniteCache<String, Integer> cache = jcache();
+
+ cache.put("key1", 1);
+ cache.put("key2", 2);
+
+ IgniteFuture<Integer> fut1 = cache.getAndPutAsync("key1", 10);
+
+ IgniteFuture<Integer> fut2 = cache.getAndPutAsync("key2", 11);
+
+ assertEquals((Integer)1, fut1.get(5000));
+ assertEquals((Integer)2, fut2.get(5000));
+
+ assertEquals((Integer)10, cache.get("key1"));
+ assertEquals((Integer)11, cache.get("key2"));
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testPutAsyncOld0() throws Exception {
IgniteCache<String, Integer> cacheAsync = jcache().withAsync();
cacheAsync.getAndPut("key1", 0);
@@ -1623,9 +1691,23 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
}
/**
+ * @throws Exception In case of error.
+ */
+ public void testPutAsync0() throws Exception {
+ IgniteCache<String, Integer> cache = jcache();
+
+ IgniteFuture<Integer> fut1 = cache.getAndPutAsync("key1", 0);
+
+ IgniteFuture<Integer> fut2 = cache.getAndPutAsync("key2", 1);
+
+ assert fut1.get(5000) == null;
+ assert fut2.get(5000) == null;
+ }
+
+ /**
* @throws Exception If failed.
*/
- public void testInvokeAsync() throws Exception {
+ public void testInvokeAsyncOld() throws Exception {
IgniteCache<String, Integer> cache = jcache();
cache.put("key2", 1);
@@ -1660,6 +1742,33 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
/**
* @throws Exception If failed.
*/
+ public void testInvokeAsync() throws Exception {
+ IgniteCache<String, Integer> cache = jcache();
+
+ cache.put("key2", 1);
+ cache.put("key3", 3);
+
+ IgniteFuture<?> fut0 = cache.invokeAsync("key1", INCR_PROCESSOR);
+
+ IgniteFuture<?> fut1 = cache.invokeAsync("key2", INCR_PROCESSOR);
+
+ IgniteFuture<?> fut2 = cache.invokeAsync("key3", RMV_PROCESSOR);
+
+ fut0.get();
+ fut1.get();
+ fut2.get();
+
+ assertEquals((Integer)1, cache.get("key1"));
+ assertEquals((Integer)2, cache.get("key2"));
+ assertNull(cache.get("key3"));
+
+ for (int i = 0; i < gridCount(); i++)
+ assertNull(jcache(i).localPeek("key3", ONHEAP));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testInvoke() throws Exception {
final IgniteCache<String, Integer> cache = jcache();
@@ -1755,7 +1864,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
/**
* @throws Exception If failed.
*/
- public void testPutAsync() throws Exception {
+ public void testPutAsyncOld() throws Exception {
Transaction tx = txShouldBeUsed() ? transactions().txStart() : null;
IgniteCache<String, Integer> cacheAsync = jcache().withAsync();
@@ -1798,6 +1907,45 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
}
/**
+ * @throws Exception If failed.
+ */
+ public void testPutAsync() throws Exception {
+ Transaction tx = txShouldBeUsed() ? transactions().txStart() : null;
+
+ try {
+ jcache().put("key2", 1);
+
+ IgniteFuture<?> fut1 = jcache().putAsync("key1", 10);
+
+ IgniteFuture<?> fut2 = jcache().putAsync("key2", 11);
+
+ IgniteFuture<Void> f = null;
+
+ if (tx != null)
+ f = tx.commitAsync();
+
+ assertNull(fut1.get());
+ assertNull(fut2.get());
+
+ try {
+ if (f != null)
+ f.get();
+ } catch (Throwable t) {
+ assert false : "Unexpected exception " + t;
+ }
+ }
+ finally {
+ if (tx != null)
+ tx.close();
+ }
+
+ checkSize(F.asSet("key1", "key2"));
+
+ assert jcache().get("key1") == 10;
+ assert jcache().get("key2") == 11;
+ }
+
+ /**
* @throws Exception In case of error.
*/
public void testPutAll() throws Exception {
@@ -2045,7 +2193,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
/**
* @throws Exception In case of error.
*/
- public void testPutAllAsync() throws Exception {
+ public void testPutAllAsyncOld() throws Exception {
Map<String, Integer> map = F.asMap("key1", 1, "key2", 2);
IgniteCache<String, Integer> cache = jcache();
@@ -2075,6 +2223,30 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
/**
* @throws Exception In case of error.
*/
+ public void testPutAllAsync() throws Exception {
+ Map<String, Integer> map = F.asMap("key1", 1, "key2", 2);
+
+ IgniteCache<String, Integer> cache = jcache();
+
+ IgniteFuture<?> f1 = cache.putAllAsync(map);
+
+ map.put("key1", 10);
+ map.put("key2", 20);
+
+ IgniteFuture<?> f2 = cache.putAllAsync(map);
+
+ assertNull(f2.get());
+ assertNull(f1.get());
+
+ checkSize(F.asSet("key1", "key2"));
+
+ assert cache.get("key1") == 10;
+ assert cache.get("key2") == 20;
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
public void testGetAndPutIfAbsent() throws Exception {
Transaction tx = txShouldBeUsed() ? transactions().txStart() : null;
@@ -2152,7 +2324,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
/**
* @throws Exception If failed.
*/
- public void testGetAndPutIfAbsentAsync() throws Exception {
+ public void testGetAndPutIfAbsentAsyncOld() throws Exception {
Transaction tx = txShouldBeUsed() ? transactions().txStart() : null;
IgniteCache<String, Integer> cache = jcache();
@@ -2224,6 +2396,67 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
/**
* @throws Exception If failed.
*/
+ public void testGetAndPutIfAbsentAsync() throws Exception {
+ Transaction tx = txShouldBeUsed() ? transactions().txStart() : null;
+
+ IgniteCache<String, Integer> cache = jcache();
+
+
+ try {
+ IgniteFuture<Integer> fut1 = cache.getAndPutIfAbsentAsync("key", 1);
+
+ assertNull(fut1.get());
+ assertEquals((Integer)1, cache.get("key"));
+
+ IgniteFuture<Integer> fut2 = cache.getAndPutIfAbsentAsync("key", 2);
+
+ assertEquals((Integer)1, fut2.get());
+ assertEquals((Integer)1, cache.get("key"));
+
+ if (tx != null)
+ tx.commit();
+ }
+ finally {
+ if (tx != null)
+ tx.close();
+ }
+
+ // Check swap.
+ cache.put("key2", 1);
+
+ cache.localEvict(Collections.singleton("key2"));
+
+ assertEquals((Integer)1, cache.getAndPutIfAbsentAsync("key2", 3).get());
+
+ // Check db.
+ if (!isMultiJvm()) {
+ storeStgy.putToStore("key3", 3);
+
+ assertEquals((Integer)3, cache.getAndPutIfAbsentAsync("key3", 4).get());
+ }
+
+ cache.localEvict(Collections.singleton("key2"));
+
+ // Same checks inside tx.
+ tx = txShouldBeUsed() ? transactions().txStart() : null;
+
+ try {
+ assertEquals(1, (int)cache.getAndPutIfAbsentAsync("key2", 3).get());
+
+ if (tx != null)
+ tx.commit();
+
+ assertEquals((Integer)1, cache.get("key2"));
+ }
+ finally {
+ if (tx != null)
+ tx.close();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testPutIfAbsent() throws Exception {
IgniteCache<String, Integer> cache = jcache();
@@ -2285,7 +2518,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
* @param inTx In tx flag.
* @throws Exception If failed.
*/
- private void checkPutxIfAbsentAsync(boolean inTx) throws Exception {
+ private void checkPutxIfAbsentAsyncOld(boolean inTx) throws Exception {
IgniteCache<String, Integer> cache = jcache();
IgniteCache<String, Integer> cacheAsync = cache.withAsync();
@@ -2353,9 +2586,65 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
}
/**
+ * @param inTx In tx flag.
+ * @throws Exception If failed.
+ */
+ private void checkPutxIfAbsentAsync(boolean inTx) throws Exception {
+ IgniteCache<String, Integer> cache = jcache();
+
+ IgniteFuture<Boolean> fut1 = cache.putIfAbsentAsync("key", 1);
+
+ assert fut1.get();
+ assert cache.get("key") != null && cache.get("key") == 1;
+
+ IgniteFuture<Boolean> fut2 = cache.putIfAbsentAsync("key", 2);
+
+ assert !fut2.get();
+ assert cache.get("key") != null && cache.get("key") == 1;
+
+ // Check swap.
+ cache.put("key2", 1);
+
+ cache.localEvict(Collections.singleton("key2"));
+
+ assertFalse(cache.putIfAbsentAsync("key2", 3).get());
+
+ // Check db.
+ if (!isMultiJvm()) {
+ storeStgy.putToStore("key3", 3);
+
+ assertFalse(cache.putIfAbsentAsync("key3", 4).get());
+ }
+
+ cache.localEvict(Collections.singletonList("key2"));
+
+ // Same checks inside tx.
+ Transaction tx = inTx ? transactions().txStart() : null;
+
+ try {
+ assertFalse(cache.putIfAbsentAsync("key2", 3).get());
+
+ if (!isMultiJvm())
+ assertFalse(cache.putIfAbsentAsync("key3", 4).get());
+
+ if (tx != null)
+ tx.commit();
+ }
+ finally {
+ if (tx != null)
+ tx.close();
+ }
+
+ assertEquals((Integer)1, cache.get("key2"));
+
+ if (!isMultiJvm())
+ assertEquals((Integer)3, cache.get("key3"));
+ }
+
+ /**
* @throws Exception In case of error.
*/
- public void testPutIfAbsentAsyncConcurrent() throws Exception {
+ public void testPutIfAbsentAsyncConcurrentOld() throws Exception {
IgniteCache<String, Integer> cacheAsync = jcache().withAsync();
cacheAsync.putIfAbsent("key1", 1);
@@ -2371,6 +2660,20 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
}
/**
+ * @throws Exception In case of error.
+ */
+ public void testPutIfAbsentAsyncConcurrent() throws Exception {
+ IgniteCache<String, Integer> cache = jcache();
+
+ IgniteFuture<Boolean> fut1 = cache.putIfAbsentAsync("key1", 1);
+
+ IgniteFuture<Boolean> fut2 = cache.putIfAbsentAsync("key2", 2);
+
+ assert fut1.get();
+ assert fut2.get();
+ }
+
+ /**
* @throws Exception If failed.
*/
public void testGetAndReplace() throws Exception {
@@ -2461,26 +2764,168 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
public void testReplace() throws Exception {
IgniteCache<String, Integer> cache = jcache();
- cache.put("key", 1);
+ cache.put("key", 1);
+
+ assert cache.get("key") == 1;
+
+ assert cache.replace("key", 2);
+
+ assert cache.get("key") == 2;
+
+ assert !cache.replace("wrong", 2);
+
+ cache.localEvict(Collections.singleton("key"));
+
+ assert cache.replace("key", 4);
+
+ assert cache.get("key") == 4;
+
+ if (!isMultiJvm()) {
+ storeStgy.putToStore("key2", 5);
+
+ assert cache.replace("key2", 6);
+
+ assertEquals((Integer)6, cache.get("key2"));
+ }
+
+ cache.localEvict(Collections.singleton("key"));
+
+ Transaction tx = txShouldBeUsed() ? transactions().txStart() : null;
+
+ try {
+ assert cache.replace("key", 5);
+
+ if (tx != null)
+ tx.commit();
+ }
+ finally {
+ if (tx != null)
+ tx.close();
+ }
+
+ assert cache.get("key") == 5;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGetAndReplaceAsyncOld() throws Exception {
+ IgniteCache<String, Integer> cache = jcache();
+
+ IgniteCache<String, Integer> cacheAsync = cache.withAsync();
+
+ cache.put("key", 1);
+
+ assert cache.get("key") == 1;
+
+ cacheAsync.getAndReplace("key", 2);
+
+ assert cacheAsync.<Integer>future().get() == 1;
+
+ assert cache.get("key") == 2;
+
+ cacheAsync.getAndReplace("wrong", 0);
+
+ assert cacheAsync.future().get() == null;
+
+ assert cache.get("wrong") == null;
+
+ cacheAsync.replace("key", 0, 3);
+
+ assert !cacheAsync.<Boolean>future().get();
+
+ assert cache.get("key") == 2;
+
+ cacheAsync.replace("key", 0, 3);
+
+ assert !cacheAsync.<Boolean>future().get();
+
+ assert cache.get("key") == 2;
+
+ cacheAsync.replace("key", 2, 3);
+
+ assert cacheAsync.<Boolean>future().get();
+
+ assert cache.get("key") == 3;
+
+ cache.localEvict(Collections.singleton("key"));
+
+ cacheAsync.replace("key", 3, 4);
+
+ assert cacheAsync.<Boolean>future().get();
+
+ assert cache.get("key") == 4;
+
+ if (!isMultiJvm()) {
+ storeStgy.putToStore("key2", 5);
+
+ cacheAsync.replace("key2", 5, 6);
+
+ assert cacheAsync.<Boolean>future().get();
+
+ assertEquals((Integer)6, cache.get("key2"));
+ }
+
+ cache.localEvict(Collections.singleton("key"));
+
+ Transaction tx = txShouldBeUsed() ? transactions().txStart() : null;
+
+ try {
+ cacheAsync.replace("key", 4, 5);
+
+ assert cacheAsync.<Boolean>future().get();
+
+ if (tx != null)
+ tx.commit();
+ }
+ finally {
+ if (tx != null)
+ tx.close();
+ }
+
+ assert cache.get("key") == 5;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGetAndReplaceAsync() throws Exception {
+ IgniteCache<String, Integer> cache = jcache();
+
+ cache.put("key", 1);
+
+ assert cache.get("key") == 1;
+
+ assert cache.getAndReplaceAsync("key", 2).get() == 1;
+
+ assert cache.get("key") == 2;
+
+ assert cache.getAndReplaceAsync("wrong", 0).get() == null;
+
+ assert cache.get("wrong") == null;
+
+ assert !cache.replaceAsync("key", 0, 3).get();
- assert cache.get("key") == 1;
+ assert cache.get("key") == 2;
- assert cache.replace("key", 2);
+ assert !cache.replaceAsync("key", 0, 3).get();
assert cache.get("key") == 2;
- assert !cache.replace("wrong", 2);
+ assert cache.replaceAsync("key", 2, 3).get();
+
+ assert cache.get("key") == 3;
cache.localEvict(Collections.singleton("key"));
- assert cache.replace("key", 4);
+ assert cache.replaceAsync("key", 3, 4).get();
assert cache.get("key") == 4;
if (!isMultiJvm()) {
storeStgy.putToStore("key2", 5);
- assert cache.replace("key2", 6);
+ assert cache.replaceAsync("key2", 5, 6).get();
assertEquals((Integer)6, cache.get("key2"));
}
@@ -2490,7 +2935,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
Transaction tx = txShouldBeUsed() ? transactions().txStart() : null;
try {
- assert cache.replace("key", 5);
+ assert cache.replaceAsync("key", 4, 5).get();
if (tx != null)
tx.commit();
@@ -2506,7 +2951,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
/**
* @throws Exception If failed.
*/
- public void testGetAndReplaceAsync() throws Exception {
+ public void testReplacexAsyncOld() throws Exception {
IgniteCache<String, Integer> cache = jcache();
IgniteCache<String, Integer> cacheAsync = cache.withAsync();
@@ -2515,39 +2960,21 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
assert cache.get("key") == 1;
- cacheAsync.getAndReplace("key", 2);
-
- assert cacheAsync.<Integer>future().get() == 1;
-
- assert cache.get("key") == 2;
-
- cacheAsync.getAndReplace("wrong", 0);
-
- assert cacheAsync.future().get() == null;
-
- assert cache.get("wrong") == null;
+ cacheAsync.replace("key", 2);
- cacheAsync.replace("key", 0, 3);
+ assert cacheAsync.<Boolean>future().get();
- assert !cacheAsync.<Boolean>future().get();
+ info("Finished replace.");
- assert cache.get("key") == 2;
+ assertEquals((Integer)2, cache.get("key"));
- cacheAsync.replace("key", 0, 3);
+ cacheAsync.replace("wrond", 2);
assert !cacheAsync.<Boolean>future().get();
- assert cache.get("key") == 2;
-
- cacheAsync.replace("key", 2, 3);
-
- assert cacheAsync.<Boolean>future().get();
-
- assert cache.get("key") == 3;
-
cache.localEvict(Collections.singleton("key"));
- cacheAsync.replace("key", 3, 4);
+ cacheAsync.replace("key", 4);
assert cacheAsync.<Boolean>future().get();
@@ -2556,11 +2983,11 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
if (!isMultiJvm()) {
storeStgy.putToStore("key2", 5);
- cacheAsync.replace("key2", 5, 6);
+ cacheAsync.replace("key2", 6);
assert cacheAsync.<Boolean>future().get();
- assertEquals((Integer)6, cache.get("key2"));
+ assert cache.get("key2") == 6;
}
cache.localEvict(Collections.singleton("key"));
@@ -2568,7 +2995,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
Transaction tx = txShouldBeUsed() ? transactions().txStart() : null;
try {
- cacheAsync.replace("key", 4, 5);
+ cacheAsync.replace("key", 5);
assert cacheAsync.<Boolean>future().get();
@@ -2589,38 +3016,28 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
public void testReplacexAsync() throws Exception {
IgniteCache<String, Integer> cache = jcache();
- IgniteCache<String, Integer> cacheAsync = cache.withAsync();
-
cache.put("key", 1);
assert cache.get("key") == 1;
- cacheAsync.replace("key", 2);
-
- assert cacheAsync.<Boolean>future().get();
+ assert cache.replaceAsync("key", 2).get();
info("Finished replace.");
assertEquals((Integer)2, cache.get("key"));
- cacheAsync.replace("wrond", 2);
-
- assert !cacheAsync.<Boolean>future().get();
+ assert !cache.replaceAsync("wrond", 2).get();
cache.localEvict(Collections.singleton("key"));
- cacheAsync.replace("key", 4);
-
- assert cacheAsync.<Boolean>future().get();
+ assert cache.replaceAsync("key", 4).get();
assert cache.get("key") == 4;
if (!isMultiJvm()) {
storeStgy.putToStore("key2", 5);
- cacheAsync.replace("key2", 6);
-
- assert cacheAsync.<Boolean>future().get();
+ assert cache.replaceAsync("key2", 6).get();
assert cache.get("key2") == 6;
}
@@ -2630,9 +3047,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
Transaction tx = txShouldBeUsed() ? transactions().txStart() : null;
try {
- cacheAsync.replace("key", 5);
-
- assert cacheAsync.<Boolean>future().get();
+ assert cache.replaceAsync("key", 5).get();
if (tx != null)
tx.commit();
@@ -2769,9 +3184,43 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
}
/**
+ * @throws Exception If failed.
+ */
+ public void testRemoveLoadAsync() throws Exception {
+ if (isMultiJvm())
+ return;
+
+ int cnt = 10;
+
+ Set<String> keys = new HashSet<>();
+
+ for (int i = 0; i < cnt; i++)
+ keys.add(String.valueOf(i));
+
+ jcache().removeAllAsync(keys).get();
+
+ for (String key : keys)
+ storeStgy.putToStore(key, Integer.parseInt(key));
+
+ for (int g = 0; g < gridCount(); g++)
+ grid(g).cache(null).localLoadCacheAsync(null).get();
+
+ for (int g = 0; g < gridCount(); g++) {
+ for (int i = 0; i < cnt; i++) {
+ String key = String.valueOf(i);
+
+ if (grid(0).affinity(null).mapKeyToPrimaryAndBackups(key).contains(grid(g).localNode()))
+ assertEquals((Integer)i, peek(jcache(g), key));
+ else
+ assertNull(peek(jcache(g), key));
+ }
+ }
+ }
+
+ /**
* @throws Exception In case of error.
*/
- public void testRemoveAsync() throws Exception {
+ public void testRemoveAsyncOld() throws Exception {
IgniteCache<String, Integer> cache = jcache();
IgniteCache<String, Integer> cacheAsync = cache.withAsync();
@@ -2805,6 +3254,30 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
/**
* @throws Exception In case of error.
*/
+ public void testRemoveAsync() throws Exception {
+ IgniteCache<String, Integer> cache = jcache();
+
+ cache.put("key1", 1);
+ cache.put("key2", 2);
+
+ assert !cache.removeAsync("key1", 0).get();
+
+ assert cache.get("key1") != null && cache.get("key1") == 1;
+
+ assert cache.removeAsync("key1", 1).get();
+
+ assert cache.get("key1") == null;
+
+ assert cache.getAndRemoveAsync("key2").get() == 2;
+
+ assert cache.get("key2") == null;
+
+ assert cache.getAndRemoveAsync("key2").get() == null;
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
public void testRemove() throws Exception {
IgniteCache<String, Integer> cache = jcache();
@@ -2818,7 +3291,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
/**
* @throws Exception In case of error.
*/
- public void testRemovexAsync() throws Exception {
+ public void testRemovexAsyncOld() throws Exception {
IgniteCache<String, Integer> cache = jcache();
IgniteCache<String, Integer> cacheAsync = cache.withAsync();
@@ -2839,6 +3312,21 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
/**
* @throws Exception In case of error.
*/
+ public void testRemovexAsync() throws Exception {
+ IgniteCache<String, Integer> cache = jcache();
+
+ cache.put("key1", 1);
+
+ assert cache.removeAsync("key1").get();
+
+ assert cache.get("key1") == null;
+
+ assert !cache.removeAsync("key1").get();
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
public void testGlobalRemoveAll() throws Exception {
globalRemoveAll(false);
}
@@ -2854,7 +3342,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
* @param async If {@code true} uses asynchronous operation.
* @throws Exception In case of error.
*/
- private void globalRemoveAll(boolean async) throws Exception {
+ private void globalRemoveAllOld(boolean async) throws Exception {
IgniteCache<String, Integer> cache = jcache();
cache.put("key1", 1);
@@ -2922,6 +3410,64 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
}
/**
+ * @param async If {@code true} uses asynchronous operation.
+ * @throws Exception In case of error.
+ */
+ private void globalRemoveAll(boolean async) throws Exception {
+ IgniteCache<String, Integer> cache = jcache();
+
+ cache.put("key1", 1);
+ cache.put("key2", 2);
+ cache.put("key3", 3);
+
+ checkSize(F.asSet("key1", "key2", "key3"));
+
+ atomicClockModeDelay(cache);
+
+ if (async)
+ cache.removeAllAsync(F.asSet("key1", "key2")).get();
+ else
+ cache.removeAll(F.asSet("key1", "key2"));
+
+ checkSize(F.asSet("key3"));
+
+ checkContainsKey(false, "key1");
+ checkContainsKey(false, "key2");
+ checkContainsKey(true, "key3");
+
+ // Put values again.
+ cache.put("key1", 1);
+ cache.put("key2", 2);
+ cache.put("key3", 3);
+
+ atomicClockModeDelay(cache);
+
+ if (async)
+ jcache(gridCount() > 1 ? 1 : 0).removeAllAsync().get();
+ else
+ jcache(gridCount() > 1 ? 1 : 0).removeAll();
+
+ assertEquals(0, cache.localSize());
+ long entryCnt = hugeRemoveAllEntryCount();
+
+ for (int i = 0; i < entryCnt; i++)
+ cache.put(String.valueOf(i), i);
+
+ for (int i = 0; i < entryCnt; i++)
+ assertEquals(Integer.valueOf(i), cache.get(String.valueOf(i)));
+
+ atomicClockModeDelay(cache);
+
+ if (async)
+ cache.removeAllAsync().get();
+ else
+ cache.removeAll();
+
+ for (int i = 0; i < entryCnt; i++)
+ assertNull(cache.get(String.valueOf(i)));
+ }
+
+ /**
* @return Count of entries to be removed in removeAll() test.
*/
protected long hugeRemoveAllEntryCount() {
@@ -3012,7 +3558,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
/**
* @throws Exception In case of error.
*/
- public void testRemoveAllAsync() throws Exception {
+ public void testRemoveAllAsyncOld() throws Exception {
IgniteCache<String, Integer> cache = jcache();
IgniteCache<String, Integer> cacheAsync = cache.withAsync();
@@ -3037,6 +3583,27 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
/**
* @throws Exception In case of error.
*/
+ public void testRemoveAllAsync() throws Exception {
+ IgniteCache<String, Integer> cache = jcache();
+
+ cache.put("key1", 1);
+ cache.put("key2", 2);
+ cache.put("key3", 3);
+
+ checkSize(F.asSet("key1", "key2", "key3"));
+
+ assertNull(cache.removeAllAsync(F.asSet("key1", "key2")).get());
+
+ checkSize(F.asSet("key3"));
+
+ checkContainsKey(false, "key1");
+ checkContainsKey(false, "key2");
+ checkContainsKey(true, "key3");
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
public void testLoadAll() throws Exception {
IgniteCache<String, Integer> cache = jcache();
@@ -3267,21 +3834,29 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
* @throws Exception If failed.
*/
public void testGlobalClearAll() throws Exception {
- globalClearAll(false);
+ globalClearAll(false, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGlobalClearAllAsyncOld() throws Exception {
+ globalClearAll(true, true);
}
/**
* @throws Exception If failed.
*/
public void testGlobalClearAllAsync() throws Exception {
- globalClearAll(true);
+ globalClearAll(true, false);
}
/**
* @param async If {@code true} uses async method.
+ * @param oldAsync Use old async API.
* @throws Exception If failed.
*/
- protected void globalClearAll(boolean async) throws Exception {
+ protected void globalClearAll(boolean async, boolean oldAsync) throws Exception {
// Save entries only on their primary nodes. If we didn't do so, clearLocally() will not remove all entries
// because some of them were blocked due to having readers.
for (int i = 0; i < gridCount(); i++) {
@@ -3290,11 +3865,14 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
}
if (async) {
- IgniteCache<String, Integer> asyncCache = jcache().withAsync();
+ if(oldAsync) {
+ IgniteCache<String, Integer> asyncCache = jcache().withAsync();
- asyncCache.clear();
+ asyncCache.clear();
- asyncCache.future().get();
+ asyncCache.future().get();
+ } else
+ jcache().clearAsync().get();
}
else
jcache().clear();
@@ -4328,6 +4906,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
/**
* @param key Key.
+ * @return Ignite instance for primary node.
*/
protected Ignite primaryIgnite(String key) {
ClusterNode node = grid(0).affinity(null).mapKeyToNode(key);
@@ -4356,6 +4935,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
/**
* @param cache Cache.
* @param cnt Keys count.
+ * @param startFrom Begin value ofthe key.
* @return Collection of keys for which given cache is primary.
*/
protected List<String> primaryKeysForCache(IgniteCache<String, Integer> cache, int cnt, int startFrom) {
@@ -4771,36 +5351,51 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
* @throws Exception If failed.
*/
public void testGlobalClearKey() throws Exception {
- testGlobalClearKey(false, Arrays.asList("key25"));
+ testGlobalClearKey(false, Arrays.asList("key25"), false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGlobalClearKeyAsyncOld() throws Exception {
+ testGlobalClearKey(true, Arrays.asList("key25"), true);
}
/**
* @throws Exception If failed.
*/
public void testGlobalClearKeyAsync() throws Exception {
- testGlobalClearKey(true, Arrays.asList("key25"));
+ testGlobalClearKey(true, Arrays.asList("key25"), false);
}
/**
* @throws Exception If failed.
*/
public void testGlobalClearKeys() throws Exception {
- testGlobalClearKey(false, Arrays.asList("key25", "key100", "key150"));
+ testGlobalClearKey(false, Arrays.asList("key25", "key100", "key150"), false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGlobalClearKeysAsyncOld() throws Exception {
+ testGlobalClearKey(true, Arrays.asList("key25", "key100", "key150"), true);
}
/**
* @throws Exception If failed.
*/
public void testGlobalClearKeysAsync() throws Exception {
- testGlobalClearKey(true, Arrays.asList("key25", "key100", "key150"));
+ testGlobalClearKey(true, Arrays.asList("key25", "key100", "key150"), false);
}
/**
* @param async If {@code true} uses async method.
* @param keysToRmv Keys to remove.
+ * @param oldAsync Use old async API.
* @throws Exception If failed.
*/
- protected void testGlobalClearKey(boolean async, Collection<String> keysToRmv) throws Exception {
+ protected void testGlobalClearKey(boolean async, Collection<String> keysToRmv, boolean oldAsync) throws Exception {
// Save entries only on their primary nodes. If we didn't do so, clearLocally() will not remove all entries
// because some of them were blocked due to having readers.
for (int i = 0; i < 500; ++i) {
@@ -4812,14 +5407,22 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
}
if (async) {
- IgniteCache<String, Integer> asyncCache = jcache().withAsync();
+ if (oldAsync) {
+ IgniteCache<String, Integer> asyncCache = jcache().withAsync();
- if (keysToRmv.size() == 1)
- asyncCache.clear(F.first(keysToRmv));
- else
- asyncCache.clearAll(new HashSet<>(keysToRmv));
+ if (keysToRmv.size() == 1)
+ asyncCache.clear(F.first(keysToRmv));
+ else
+ asyncCache.clearAll(new HashSet<>(keysToRmv));
- asyncCache.future().get();
+ asyncCache.future().get();
+ } else {
+
+ if (keysToRmv.size() == 1)
+ jcache().clearAsync(F.first(keysToRmv)).get();
+ else
+ jcache().clearAllAsync(new HashSet<>(keysToRmv)).get();
+ }
}
else {
if (keysToRmv.size() == 1)
@@ -5437,21 +6040,22 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
grid(0).events().localListen(lsnr, EVT_CACHE_OBJECT_LOCKED, EVT_CACHE_OBJECT_UNLOCKED);
- if (async)
- cache = cache.withAsync();
-
try (Transaction tx = transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
- Integer val0 = cache.get(keys.get(0));
+ Integer val0;
if (async)
- val0 = cache.<Integer>future().get();
+ val0 = cache.getAsync(keys.get(0)).get();
+ else
+ val0 = cache.get(keys.get(0));
assertEquals(0, val0.intValue());
- Map<String, Integer> allOutTx = cache.getAllOutTx(F.asSet(keys.get(1)));
+ Map<String, Integer> allOutTx;
if (async)
- allOutTx = cache.<Map<String, Integer>>future().get();
+ allOutTx = cache.getAllOutTxAsync(F.asSet(keys.get(1))).get();
+ else
+ allOutTx = cache.getAllOutTx(F.asSet(keys.get(1)));
assertEquals(1, allOutTx.size());
@@ -5484,13 +6088,11 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
* @throws Exception If failed.
*/
public void testTransformException() throws Exception {
- final IgniteCache<String, Integer> cache = jcache().withAsync();
-
- cache.invoke("key2", ERR_PROCESSOR);
+ final IgniteCache<String, Integer> cache = jcache();
assertThrows(log, new Callable<Object>() {
@Override public Object call() throws Exception {
- IgniteFuture fut = cache.future().chain(new IgniteClosure<IgniteFuture, Object>() {
+ IgniteFuture fut = cache.invokeAsync("key2", ERR_PROCESSOR).chain(new IgniteClosure<IgniteFuture, Object>() {
@Override public Object apply(IgniteFuture o) {
return o.get();
}
@@ -5554,27 +6156,32 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
IgniteCache<String, Integer> cache = jcache();
Ignite ignite = ignite(0);
- doTransformResourceInjection(ignite, cache);
- doTransformResourceInjection(ignite, cache.withAsync());
+ doTransformResourceInjection(ignite, cache, false, false);
+ doTransformResourceInjection(ignite, cache, true, false);
+ doTransformResourceInjection(ignite, cache, true, true);
if (txEnabled()) {
- doTransformResourceInjectionInTx(ignite, cache);
- doTransformResourceInjectionInTx(ignite, cache.withAsync());
+ doTransformResourceInjectionInTx(ignite, cache, false, false);
+ doTransformResourceInjectionInTx(ignite, cache, true, false);
+ doTransformResourceInjectionInTx(ignite, cache, true, true);
}
}
/**
* @param ignite Node.
* @param cache Cache.
+ * @param async Use async API.
+ * @param oldAsync Use old async API.
* @throws Exception If failed.
*/
- private void doTransformResourceInjectionInTx(Ignite ignite, IgniteCache<String, Integer> cache) throws Exception {
+ private void doTransformResourceInjectionInTx(Ignite ignite, IgniteCache<String, Integer> cache, boolean async,
+ boolean oldAsync) throws Exception {
for (TransactionConcurrency concurrency : TransactionConcurrency.values()) {
for (TransactionIsolation isolation : TransactionIsolation.values()) {
IgniteTransactions txs = ignite.transactions();
try (Transaction tx = txs.txStart(concurrency, isolation)) {
- doTransformResourceInjection(ignite, cache);
+ doTransformResourceInjection(ignite, cache, async, oldAsync);
tx.commit();
}
@@ -5585,9 +6192,12 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
/**
* @param ignite Node.
* @param cache Cache.
+ * @param async Use async API.
+ * @param oldAsync Use old async API.
* @throws Exception If failed.
*/
- private void doTransformResourceInjection(Ignite ignite, IgniteCache<String, Integer> cache) throws Exception {
+ private void doTransformResourceInjection(Ignite ignite, IgniteCache<String, Integer> cache, boolean async,
+ boolean oldAsync) throws Exception {
final Collection<ResourceType> required = Arrays.asList(ResourceType.IGNITE_INSTANCE,
ResourceType.CACHE_NAME,
ResourceType.LOGGER,
@@ -5600,11 +6210,11 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
UUID opId = evts.remoteListen(lsnr, null, EventType.EVT_CACHE_OBJECT_READ);
try {
- checkResourceInjectionOnInvoke(cache, required);
+ checkResourceInjectionOnInvoke(cache, required, async, oldAsync);
- checkResourceInjectionOnInvokeAll(cache, required);
+ checkResourceInjectionOnInvokeAll(cache, required, async, oldAsync);
- checkResourceInjectionOnInvokeAllMap(cache, required);
+ checkResourceInjectionOnInvokeAllMap(cache, required, async, oldAsync);
}
finally {
evts.stopRemoteListen(opId);
@@ -5616,9 +6226,11 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
*
* @param cache Cache.
* @param required Expected injected resources.
+ * @param async Use async API.
+ * @param oldAsync Use old async API.
*/
private void checkResourceInjectionOnInvokeAllMap(IgniteCache<String, Integer> cache,
- Collection<ResourceType> required) {
+ Collection<ResourceType> required, boolean async, boolean oldAsync) {
Map<String, EntryProcessorResult<Integer>> results;
Map<String, EntryProcessor<String, Integer, Integer>> map = new HashMap<>();
@@ -5628,10 +6240,19 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
map.put(UUID.randomUUID().toString(), new ResourceInjectionEntryProcessor());
map.put(UUID.randomUUID().toString(), new ResourceInjectionEntryProcessor());
- results = cache.invokeAll(map);
+ if (async) {
+ if (oldAsync) {
+ IgniteCache<String, Integer> acache = cache.withAsync();
- if (cache.isAsync())
- results = cache.<Map<String, EntryProcessorResult<Integer>>>future().get();
+ acache.invokeAll(map);
+
+ results = acache.<Map<String, EntryProcessorResult<Integer>>>future().get();
+ }
+ else
+ results = cache.invokeAllAsync(map).get();
+ }
+ else
+ results = cache.invokeAll(map);
assertEquals(map.size(), results.size());
@@ -5648,19 +6269,31 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
*
* @param cache Cache.
* @param required Expected injected resources.
+ * @param async Use async API.
+ * @param oldAsync Use old async API.
*/
private void checkResourceInjectionOnInvokeAll(IgniteCache<String, Integer> cache,
- Collection<ResourceType> required) {
+ Collection<ResourceType> required, boolean async, boolean oldAsync) {
Set<String> keys = new HashSet<>(Arrays.asList(UUID.randomUUID().toString(),
UUID.randomUUID().toString(),
UUID.randomUUID().toString(),
UUID.randomUUID().toString()));
- Map<String, EntryProcessorResult<Integer>> results = cache.invokeAll(keys,
- new ResourceInjectionEntryProcessor());
+ Map<String, EntryProcessorResult<Integer>> results;
+
+ if (async) {
+ if (oldAsync) {
+ IgniteCache<String, Integer> acache = cache.withAsync();
+
+ acache.invokeAll(keys, new ResourceInjectionEntryProcessor());
- if (cache.isAsync())
- results = cache.<Map<String, EntryProcessorResult<Integer>>>future().get();
+ results = acache.<Map<String, EntryProcessorResult<Integer>>>future().get();
+ }
+ else
+ results = cache.invokeAllAsync(keys, new ResourceInjectionEntryProcessor()).get();
+ }
+ else
+ results = cache.invokeAll(keys, new ResourceInjectionEntryProcessor());
assertEquals(keys.size(), results.size());
@@ -5677,13 +6310,30 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
*
* @param cache Cache.
* @param required Expected injected resources.
+ * @param async Use async API.
+ * @param oldAsync Use old async API.
*/
private void checkResourceInjectionOnInvoke(IgniteCache<String, Integer> cache,
- Collection<ResourceType> required) {
+ Collection<ResourceType> required, boolean async, boolean oldAsync) {
String key = UUID.randomUUID().toString();
- Integer flags = cache.invoke(key, new GridCacheAbstractFullApiSelfTest.ResourceInjectionEntryProcessor());
+ Integer flags;
+
+ if (async) {
+ if (oldAsync) {
+ IgniteCache<String, Integer> acache = cache.withAsync();
+
+ acache.invoke(key, new GridCacheAbstractFullApiSelfTest.ResourceInjectionEntryProcessor());
+
+ flags = acache.<Integer>future().get();
+ }
+ else
+ flags = cache.invokeAsync(key,
+ new GridCacheAbstractFullApiSelfTest.ResourceInjectionEntryProcessor()).get();
+ }
+ else
+ flags = cache.invoke(key, new GridCacheAbstractFullApiSelfTest.ResourceInjectionEntryProcessor());
if (cache.isAsync())
flags = cache.<Integer>future().get();
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/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 5ad7e5c..a858085 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
@@ -171,20 +171,13 @@ public abstract class GridCacheAbstractMetricsSelfTest extends GridCacheAbstract
public void testGetAndRemoveAsyncAvgTime() throws Exception {
IgniteCache<Object, Object> cache = grid(0).cache(null);
- IgniteCache<Object, Object> cacheAsync = cache.withAsync();
-
for (int i = 0; i < KEY_CNT; i++)
cache.put(i, i);
assertEquals(cache.localMetrics().getAverageRemoveTime(), 0.0, 0.0);
- for (int i = 0; i < KEY_CNT; i++) {
- cacheAsync.getAndRemove(i);
-
- IgniteFuture<Object> fut = cacheAsync.future();
-
- fut.get();
- }
+ for (int i = 0; i < KEY_CNT; i++)
+ cache.getAndRemoveAsync(i).get();
assert cache.localMetrics().getAverageRemoveTime() > 0;
}
@@ -194,7 +187,6 @@ public abstract class GridCacheAbstractMetricsSelfTest extends GridCacheAbstract
*/
public void testRemoveAsyncValAvgTime() throws Exception {
IgniteCache<Object, Object> cache = grid(0).cache(null);
- IgniteCache<Object, Object> cacheAsync = cache.withAsync();
Integer key = 0;
@@ -210,9 +202,7 @@ public abstract class GridCacheAbstractMetricsSelfTest extends GridCacheAbstract
cache.put(key, key);
- cacheAsync.remove(key, key);
-
- IgniteFuture<Boolean> fut = cacheAsync.future();
+ IgniteFuture<Boolean> fut = cache.removeAsync(key, key);
assertTrue(fut.get());
@@ -265,7 +255,6 @@ public abstract class GridCacheAbstractMetricsSelfTest extends GridCacheAbstract
*/
public void testRemoveAllAsyncAvgTime() throws Exception {
IgniteCache<Object, Object> cache = grid(0).cache(null);
- IgniteCache<Object, Object> cacheAsync = cache.withAsync();
Set<Integer> keys = new LinkedHashSet<>();
@@ -282,9 +271,7 @@ public abstract class GridCacheAbstractMetricsSelfTest extends GridCacheAbstract
assertEquals(cache.localMetrics().getAverageRemoveTime(), 0.0, 0.0);
- cacheAsync.removeAll(keys);
-
- IgniteFuture<?> fut = cacheAsync.future();
+ IgniteFuture<?> fut = cache.removeAllAsync(keys);
fut.get();
@@ -342,7 +329,6 @@ public abstract class GridCacheAbstractMetricsSelfTest extends GridCacheAbstract
*/
public void testGetAllAsyncAvgTime() throws Exception {
IgniteCache<Object, Object> cache = grid(0).cache(null);
- IgniteCache<Object, Object> cacheAsync = cache.withAsync();
assertEquals(0.0, cache.localMetrics().getAverageGetTime(), 0.0);
@@ -357,9 +343,7 @@ public abstract class GridCacheAbstractMetricsSelfTest extends GridCacheAbstract
keys.add(2);
keys.add(3);
- cacheAsync.getAll(keys);
-
- IgniteFuture<Map<Object, Object>> fut = cacheAsync.future();
+ IgniteFuture<Map<Object, Object>> fut = cache.getAllAsync(keys);
fut.get();
@@ -390,14 +374,11 @@ public abstract class GridCacheAbstractMetricsSelfTest extends GridCacheAbstract
*/
public void testPutAsyncAvgTime() throws Exception {
IgniteCache<Object, Object> cache = grid(0).cache(null);
- IgniteCache<Object, Object> cacheAsync = cache.withAsync();
assertEquals(0.0, cache.localMetrics().getAveragePutTime(), 0.0);
assertEquals(0, cache.localMetrics().getCachePuts());
- cacheAsync.put(1, 1);
-
- cacheAsync.future().get();
+ cache.putAsync(1, 1).get();
TimeUnit.MILLISECONDS.sleep(100L);
@@ -409,7 +390,6 @@ public abstract class GridCacheAbstractMetricsSelfTest extends GridCacheAbstract
*/
public void testGetAndPutAsyncAvgTime() throws Exception {
IgniteCache<Object, Object> cache = grid(0).cache(null);
- IgniteCache<Object, Object> cacheAsync = cache.withAsync();
Integer key = null;
@@ -424,11 +404,7 @@ public abstract class GridCacheAbstractMetricsSelfTest extends GridCacheAbstract
assertEquals(0.0, cache.localMetrics().getAveragePutTime(), 0.0);
assertEquals(0.0, cache.localMetrics().getAverageGetTime(), 0.0);
- cacheAsync.getAndPut(key, key);
-
- IgniteFuture<?> fut = cacheAsync.future();
-
- fut.get();
+ cache.getAndPutAsync(key, key).get();
TimeUnit.MILLISECONDS.sleep(100L);
@@ -441,7 +417,6 @@ public abstract class GridCacheAbstractMetricsSelfTest extends GridCacheAbstract
*/
public void testPutIfAbsentAsyncAvgTime() throws Exception {
IgniteCache<Object, Object> cache = grid(0).cache(null);
- IgniteCache<Object, Object> cacheAsync = cache.withAsync();
Integer key = null;
@@ -455,11 +430,7 @@ public abstract class GridCacheAbstractMetricsSelfTest extends GridCacheAbstract
assertEquals(0.0f, cache.localMetrics().getAveragePutTime());
- cacheAsync.putIfAbsent(key, key);
-
- IgniteFuture<Boolean> fut = cacheAsync.future();
-
- fut.get();
+ cache.putIfAbsentAsync(key, key).get();
TimeUnit.MILLISECONDS.sleep(100L);
@@ -471,7 +442,6 @@ public abstract class GridCacheAbstractMetricsSelfTest extends GridCacheAbstract
*/
public void testGetAndPutIfAbsentAsyncAvgTime() throws Exception {
IgniteCache<Object, Object> cache = grid(0).cache(null);
- IgniteCache<Object, Object> cacheAsync = cache.withAsync();
Integer key = null;
@@ -485,11 +455,7 @@ public abstract class GridCacheAbstractMetricsSelfTest extends GridCacheAbstract
assertEquals(0.0f, cache.localMetrics().getAveragePutTime());
- cacheAsync.getAndPutIfAbsent(key, key);
-
- IgniteFuture<?> fut = cacheAsync.future();
-
- fut.get();
+ cache.getAndPutIfAbsentAsync(key, key).get();
TimeUnit.MILLISECONDS.sleep(100L);
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAsyncOperationsLimitSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAsyncOperationsLimitSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAsyncOperationsLimitSelfTest.java
index 84f4cc2..cebab2f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAsyncOperationsLimitSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAsyncOperationsLimitSelfTest.java
@@ -18,7 +18,6 @@
package org.apache.ignite.internal.processors.cache;
import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.ignite.IgniteCache;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.internal.util.GridAtomicInteger;
import org.apache.ignite.internal.util.typedef.CI1;
@@ -57,13 +56,7 @@ public class GridCacheAsyncOperationsLimitSelfTest extends GridCacheAbstractSelf
cnt.incrementAndGet();
- IgniteCache<String, Integer> cacheAsync = jcache().withAsync();
-
- cacheAsync.put("key" + i, i);
-
- IgniteFuture<?> fut = cacheAsync.future();
-
- fut.listen(new CI1<IgniteFuture<?>>() {
+ jcache().putAsync("key" + i, i).listen(new CI1<IgniteFuture<?>>() {
@Override public void apply(IgniteFuture<?> t) {
cnt.decrementAndGet();
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentTxMultiNodeTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentTxMultiNodeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentTxMultiNodeTest.java
index 41232c0..589f910 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentTxMultiNodeTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentTxMultiNodeTest.java
@@ -342,11 +342,9 @@ public class GridCacheConcurrentTxMultiNodeTest extends GridCommonAbstractTest {
long submitTime1 = t0;
- IgniteCompute comp = g.compute(g.cluster().forPredicate(serverNode)).withAsync();
+ IgniteCompute comp = g.compute(g.cluster().forPredicate(serverNode));
- comp.execute(RequestTask.class, new Message(terminalId, nodeId));
-
- ComputeTaskFuture<Void> f1 = comp.future();
+ ComputeTaskFuture<Void> f1 = comp.executeAsync(RequestTask.class, new Message(terminalId, nodeId));
submitTime.setIfGreater(System.currentTimeMillis() - submitTime1);
@@ -354,9 +352,7 @@ public class GridCacheConcurrentTxMultiNodeTest extends GridCommonAbstractTest {
submitTime1 = System.currentTimeMillis();
- comp.execute(ResponseTask.class, new Message(terminalId, nodeId));
-
- ComputeTaskFuture<Void> f2 = comp.future();
+ ComputeTaskFuture<Void> f2 = comp.executeAsync(ResponseTask.class, new Message(terminalId, nodeId));
submitTime.setIfGreater(System.currentTimeMillis() - submitTime1);
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheInterceptorAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheInterceptorAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheInterceptorAbstractSelfTest.java
index 73cd89d..26c69e8 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheInterceptorAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheInterceptorAbstractSelfTest.java
@@ -254,18 +254,11 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
log.info("GetAsync 1.");
- IgniteCache<String, Integer> cacheAsync = cache.withAsync();
- if (needVer) {
- cacheAsync.getEntry(key);
-
- assertEquals((Integer)101, cacheAsync.<CacheEntry<String, Integer>>future().get().getValue());
- }
- else {
- cacheAsync.get(key);
-
- assertEquals((Integer)101, cacheAsync.<Integer>future().get());
- }
+ if (needVer)
+ assertEquals((Integer)101, cache.getEntryAsync(key).get().getValue());
+ else
+ assertEquals((Integer)101, cache.getAsync(key).get());
assertEquals(1, interceptor.invokeCnt.get());
@@ -303,8 +296,6 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
IgniteCache<String, Integer> cache = jcache(0);
- IgniteCache<String, Integer> cacheAsync = cache.withAsync();
-
Collection<CacheEntry<String, Integer>> c;
Map<String, Integer> map;
@@ -368,11 +359,8 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
if (needVer) {
if (j == 0)
c = cache.getEntries(keys);
- else {
- cacheAsync.getEntries(keys);
-
- c = cacheAsync.<Collection<CacheEntry<String, Integer>>>future().get();
- }
+ else
+ c = cache.getEntriesAsync(keys).get();
for (CacheEntry<String, Integer> e : c) {
int k = Integer.valueOf(e.getKey());
@@ -398,11 +386,8 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
else {
if (j == 0)
map = cache.getAll(keys);
- else {
- cacheAsync.getAll(keys);
-
- map = cacheAsync.<Map<String, Integer>>future().get();
- }
+ else
+ map = cache.getAllAsync(keys).get();
int i = 0;
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMissingCommitVersionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMissingCommitVersionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMissingCommitVersionSelfTest.java
index ac56d18..f3d2434 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMissingCommitVersionSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMissingCommitVersionSelfTest.java
@@ -123,11 +123,7 @@ public class GridCacheMissingCommitVersionSelfTest extends GridCommonAbstractTes
for (Integer key : q) {
log.info("Trying to update " + key);
- IgniteCache<Integer, Integer> asyncCache = cache.withAsync();
-
- asyncCache.put(key, 2);
-
- IgniteFuture<?> fut = asyncCache.future();
+ IgniteFuture<?> fut = cache.putAsync(key, 2);
try {
fut.get(5000);
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePutAllFailoverSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePutAllFailoverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePutAllFailoverSelfTest.java
index 406194c..d700856 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePutAllFailoverSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePutAllFailoverSelfTest.java
@@ -318,7 +318,7 @@ public class GridCachePutAllFailoverSelfTest extends GridCommonAbstractTest {
final AtomicBoolean inputExhausted = new AtomicBoolean();
- IgniteCompute comp = compute(master.cluster().forPredicate(workerNodesFilter)).withAsync();
+ IgniteCompute comp = compute(master.cluster().forPredicate(workerNodesFilter));
for (Integer key : testKeys) {
dataChunk.add(key);
@@ -331,14 +331,12 @@ public class GridCachePutAllFailoverSelfTest extends GridCommonAbstractTest {
log.info("Pushing data chunk [chunkNo=" + chunkCntr + "]");
- comp.execute(
+ ComputeTaskFuture<Void> fut = comp.executeAsync(
new GridCachePutAllTask(
runningWorkers.get(rnd.nextInt(runningWorkers.size())).cluster().localNode().id(),
CACHE_NAME),
dataChunk);
- ComputeTaskFuture<Void> fut = comp.future();
-
resQueue.put(fut); // Blocks if queue is full.
fut.listen(new CI1<IgniteFuture<Void>>() {
@@ -514,7 +512,7 @@ public class GridCachePutAllFailoverSelfTest extends GridCommonAbstractTest {
final AtomicBoolean inputExhausted = new AtomicBoolean();
- IgniteCompute comp = compute(master.cluster().forPredicate(workerNodesFilter)).withAsync();
+ IgniteCompute comp = compute(master.cluster().forPredicate(workerNodesFilter));
for (Integer key : testKeys) {
ClusterNode mappedNode = master.affinity(CACHE_NAME).mapKeyToNode(key);
@@ -536,9 +534,7 @@ public class GridCachePutAllFailoverSelfTest extends GridCommonAbstractTest {
log.info("Pushing data chunk [chunkNo=" + chunkCntr + "]");
- comp.execute(new GridCachePutAllTask(nodeId, CACHE_NAME), data);
-
- ComputeTaskFuture<Void> fut = comp.future();
+ ComputeTaskFuture<Void> fut = comp.executeAsync(new GridCachePutAllTask(nodeId, CACHE_NAME), data);
resQueue.put(fut); // Blocks if queue is full.
@@ -587,9 +583,7 @@ public class GridCachePutAllFailoverSelfTest extends GridCommonAbstractTest {
}
for (Map.Entry<UUID, Collection<Integer>> entry : dataChunks.entrySet()) {
- comp.execute(new GridCachePutAllTask(entry.getKey(), CACHE_NAME), entry.getValue());
-
- ComputeTaskFuture<Void> fut = comp.future();
+ ComputeTaskFuture<Void> fut = comp.executeAsync(new GridCachePutAllTask(entry.getKey(), CACHE_NAME), entry.getValue());
resQueue.put(fut); // Blocks if queue is full.
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReferenceCleanupSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReferenceCleanupSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReferenceCleanupSelfTest.java
index 0eb8ccc..42bba79 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReferenceCleanupSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReferenceCleanupSelfTest.java
@@ -357,7 +357,6 @@ public class GridCacheReferenceCleanupSelfTest extends GridCommonAbstractTest {
try {
IgniteCache<Integer, TestValue> cache = g.cache(null);
- IgniteCache<Integer, TestValue> cacheAsync = cache.withAsync();
refs.add(new WeakReference<Object>(cacheContext(cache)));
@@ -365,9 +364,7 @@ public class GridCacheReferenceCleanupSelfTest extends GridCommonAbstractTest {
refs.add(new WeakReference<Object>(val));
- cacheAsync.putIfAbsent(0, val);
-
- cacheAsync.future().get();
+ cache.putIfAbsentAsync(0, val).get();
}
finally {
G.stop(g.name(), cancel);
@@ -393,7 +390,6 @@ public class GridCacheReferenceCleanupSelfTest extends GridCommonAbstractTest {
try {
IgniteCache<Integer, TestValue> cache = g.cache(null);
- IgniteCache<Integer, TestValue> cacheAsync = cache.withAsync();
refs.add(new WeakReference<Object>(cacheContext(cache)));
@@ -404,9 +400,7 @@ public class GridCacheReferenceCleanupSelfTest extends GridCommonAbstractTest {
refs.add(new WeakReference<Object>(val));
- cacheAsync.putIfAbsent(0, val);
-
- futs.add(cacheAsync.future());
+ futs.add(cache.putIfAbsentAsync(0, val));
}
for (IgniteFuture<?> fut : futs)
@@ -473,7 +467,6 @@ public class GridCacheReferenceCleanupSelfTest extends GridCommonAbstractTest {
try {
IgniteCache<Integer, TestValue> cache = g.cache(null);
- IgniteCache<Integer, TestValue> cacheAsync = cache.withAsync();
refs.add(new WeakReference<Object>(cacheContext(cache)));
@@ -484,9 +477,7 @@ public class GridCacheReferenceCleanupSelfTest extends GridCommonAbstractTest {
refs.add(new WeakReference<Object>(val));
- cacheAsync.put(i, val);
-
- cacheAsync.future().get();
+ cache.putAsync(i, val).get();
}
tx.commit();
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractStopBusySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractStopBusySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractStopBusySelfTest.java
index a131307..dc357f1 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractStopBusySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractStopBusySelfTest.java
@@ -41,6 +41,7 @@ import org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetR
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearSingleGetRequest;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.lang.IgniteInClosure;
import org.apache.ignite.plugin.extensions.communication.Message;
import org.apache.ignite.spi.IgniteSpiException;
@@ -206,13 +207,11 @@ public abstract class IgniteCacheAbstractStopBusySelfTest extends GridCommonAbst
@Override public Object call() throws Exception {
info("Start operation.");
- IgniteCache<Object, Object> cache = clientCache().withAsync();
-
- cache.getAndPut(1, 1);
+ IgniteFuture f = clientCache().getAndPutAsync(1, 1);
info("Stop operation.");
- return cache.future().get();
+ return f.get();
}
});
}
[03/10] ignite git commit: IGNITE-4475: New async API: now all async
methods are defined explicitly,
IgniteAsyncSupport is deprecated. This closes #1648.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java
index 20b5db8..f3b14b1 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java
@@ -471,15 +471,11 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
public void testGetAsync() throws Exception {
IgniteCache<Integer, TestObject> c = jcache(0);
- IgniteCache<Integer, TestObject> cacheAsync = c.withAsync();
-
for (int i = 0; i < ENTRY_CNT; i++)
c.put(i, new TestObject(i));
for (int i = 0; i < ENTRY_CNT; i++) {
- cacheAsync.get(i);
-
- TestObject obj = cacheAsync.<TestObject>future().get();
+ TestObject obj = c.getAsync(i).get();
assertNotNull(obj);
@@ -488,12 +484,8 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
IgniteCache<Integer, BinaryObject> kpc = keepBinaryCache();
- IgniteCache<Integer, BinaryObject> cacheBinaryAsync = kpc.withAsync();
-
for (int i = 0; i < ENTRY_CNT; i++) {
- cacheBinaryAsync.get(i);
-
- BinaryObject po = cacheBinaryAsync.<BinaryObject>future().get();
+ BinaryObject po = kpc.getAsync(i).get();
assertEquals(i, (int)po.field("val"));
}
@@ -644,18 +636,15 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
return;
IgniteCache<Integer, TestObject> c = jcache(0);
- IgniteCache<Integer, TestObject> cAsync = c.withAsync();
IgniteCache<Integer, BinaryObject> kbCache = keepBinaryCache();
- IgniteCache<Integer, BinaryObject> kbCacheAsync = kbCache.withAsync();
for (int i = 0; i < ENTRY_CNT; i++)
c.put(i, new TestObject(i));
for (int i = 0; i < ENTRY_CNT; i++) {
try (Transaction tx = grid(0).transactions().txStart(concurrency, isolation)) {
- cAsync.get(i);
- TestObject obj = (TestObject)cAsync.future().get();
+ TestObject obj = c.getAsync(i).get();
assertEquals(i, obj.val);
@@ -665,17 +654,13 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
for (int i = 0; i < ENTRY_CNT; i++) {
try (Transaction tx = grid(0).transactions().txStart(concurrency, isolation)) {
- kbCacheAsync.get(i);
-
- BinaryObject val = (BinaryObject)kbCacheAsync.future().get();
+ BinaryObject val = kbCache.getAsync(i).get();
assertFalse("Key=" + i, val instanceof BinaryObjectOffheapImpl);
assertEquals(i, (int)val.field("val"));
- kbCacheAsync.put(i, val);
-
- kbCacheAsync.future().get();
+ kbCache.putAsync(i, val).get();
tx.commit();
}
@@ -691,16 +676,12 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
IgniteCache<Integer, TestObject> c = jcache(0);
- IgniteCache<Integer, TestObject> cacheAsync = c.withAsync();
-
for (int i = 0; i < ENTRY_CNT; i++)
c.put(i, new TestObject(i));
for (int i = 0; i < ENTRY_CNT; i++) {
try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
- cacheAsync.get(i);
-
- TestObject obj = cacheAsync.<TestObject>future().get();
+ TestObject obj = c.getAsync(i).get();
assertEquals(i, obj.val);
@@ -709,13 +690,10 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
}
IgniteCache<Integer, BinaryObject> kpc = keepBinaryCache();
- IgniteCache<Integer, BinaryObject> cacheBinaryAsync = kpc.withAsync();
for (int i = 0; i < ENTRY_CNT; i++) {
try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
- cacheBinaryAsync.get(i);
-
- BinaryObject po = cacheBinaryAsync.<BinaryObject>future().get();
+ BinaryObject po = kpc.getAsync(i).get();
assertEquals(i, (int)po.field("val"));
@@ -770,8 +748,6 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
public void testGetAllAsync() throws Exception {
IgniteCache<Integer, TestObject> c = jcache(0);
- IgniteCache<Integer, TestObject> cacheAsync = c.withAsync();
-
for (int i = 0; i < ENTRY_CNT; i++)
c.put(i, new TestObject(i));
@@ -781,9 +757,7 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
for (int j = 0; j < 10; j++)
keys.add(i++);
- cacheAsync.getAll(keys);
-
- Map<Integer, TestObject> objs = cacheAsync.<Map<Integer, TestObject>>future().get();
+ Map<Integer, TestObject> objs = c.getAllAsync(keys).get();
assertEquals(10, objs.size());
@@ -792,7 +766,6 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
}
IgniteCache<Integer, BinaryObject> kpc = keepBinaryCache();
- IgniteCache<Integer, BinaryObject> cacheBinaryAsync = kpc.withAsync();
for (int i = 0; i < ENTRY_CNT; ) {
Set<Integer> keys = new HashSet<>();
@@ -800,9 +773,7 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
for (int j = 0; j < 10; j++)
keys.add(i++);
- cacheBinaryAsync.getAll(keys);
-
- Map<Integer, BinaryObject> objs = cacheBinaryAsync.<Map<Integer, BinaryObject>>future().get();
+ Map<Integer, BinaryObject> objs = kpc.getAllAsync(keys).get();
assertEquals(10, objs.size());
@@ -906,7 +877,6 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
return;
IgniteCache<Integer, TestObject> c = jcache(0);
- IgniteCache<Integer, TestObject> cacheAsync = c.withAsync();
for (int i = 0; i < ENTRY_CNT; i++)
c.put(i, new TestObject(i));
@@ -918,9 +888,7 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
keys.add(i++);
try (Transaction tx = grid(0).transactions().txStart(concurrency, isolation)) {
- cacheAsync.getAll(keys);
-
- Map<Integer, TestObject> objs = cacheAsync.<Map<Integer, TestObject>>future().get();
+ Map<Integer, TestObject> objs = c.getAllAsync(keys).get();
assertEquals(10, objs.size());
@@ -939,12 +907,8 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
for (int j = 0; j < 10; j++)
keys.add(i++);
- IgniteCache<Integer, BinaryObject> asyncCache = cache.withAsync();
-
try (Transaction tx = grid(0).transactions().txStart(concurrency, isolation)) {
- asyncCache.getAll(keys);
-
- Map<Integer, BinaryObject> objs = asyncCache.<Map<Integer, BinaryObject>>future().get();
+ Map<Integer, BinaryObject> objs = cache.getAllAsync(keys).get();
assertEquals(10, objs.size());
@@ -1160,13 +1124,8 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
* @throws Exception If failed.
*/
public void testLoadCacheAsync() throws Exception {
- for (int i = 0; i < gridCount(); i++) {
- IgniteCache<Object, Object> jcache = jcache(i).withAsync();
-
- jcache.loadCache(null);
-
- jcache.future().get();
- }
+ for (int i = 0; i < gridCount(); i++)
+ jcache(i).loadCacheAsync(null).get();
IgniteCache<Integer, TestObject> cache = jcache(0);
@@ -1182,15 +1141,13 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
*/
public void testLoadCacheFilteredAsync() throws Exception {
for (int i = 0; i < gridCount(); i++) {
- IgniteCache<Integer, TestObject> c = this.<Integer, TestObject>jcache(i).withAsync();
+ IgniteCache<Integer, TestObject> c = jcache(i);
- c.loadCache(new P2<Integer, TestObject>() {
+ c.loadCacheAsync(new P2<Integer, TestObject>() {
@Override public boolean apply(Integer key, TestObject val) {
return val.val < 3;
}
- });
-
- c.future().get();
+ }).get();
}
IgniteCache<Integer, TestObject> cache = jcache(0);
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAbstractDataStructuresFailoverSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAbstractDataStructuresFailoverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAbstractDataStructuresFailoverSelfTest.java
index f6465eb..285ea6e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAbstractDataStructuresFailoverSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAbstractDataStructuresFailoverSelfTest.java
@@ -53,6 +53,7 @@ import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiTuple;
import org.apache.ignite.lang.IgniteCallable;
import org.apache.ignite.lang.IgniteClosure;
+import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.resources.IgniteInstanceResource;
import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
@@ -614,9 +615,7 @@ public abstract class GridCacheAbstractDataStructuresFailoverSelfTest extends Ig
IgniteSemaphore semaphore = server.semaphore("sync", 0, true, true);
- IgniteCompute compute = client.compute().withAsync();
-
- compute.apply(new IgniteClosure<Ignite, Object>() {
+ IgniteFuture fut = client.compute().applyAsync(new IgniteClosure<Ignite, Object>() {
@Override public Object apply(Ignite ignite) {
final IgniteLock l = ignite.reentrantLock("lock", true, fair, true);
@@ -662,7 +661,7 @@ public abstract class GridCacheAbstractDataStructuresFailoverSelfTest extends Ig
for (int i = 0; i < gridCount(); i++)
stopGrid(i);
- compute.future().get();
+ fut.get();
client.close();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueJoinedNodeSelfAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueJoinedNodeSelfAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueJoinedNodeSelfAbstractTest.java
index b664db8..eb8c3c0 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueJoinedNodeSelfAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueJoinedNodeSelfAbstractTest.java
@@ -70,11 +70,9 @@ public abstract class GridCacheQueueJoinedNodeSelfAbstractTest extends IgniteCol
PutJob putJob = new PutJob(queueName);
- IgniteCompute comp = compute(grid(0).cluster().forLocal()).withAsync();
+ IgniteCompute comp = compute(grid(0).cluster().forLocal());
- comp.run(putJob);
-
- IgniteFuture<?> fut = comp.future();
+ IgniteFuture<?> fut = comp.runAsync(putJob);
Collection<IgniteFuture<?>> futs = new ArrayList<>(GRID_CNT - 1);
@@ -89,11 +87,9 @@ public abstract class GridCacheQueueJoinedNodeSelfAbstractTest extends IgniteCol
jobs.add(job);
- comp = compute(grid(i).cluster().forLocal()).withAsync();
-
- comp.call(job);
+ comp = compute(grid(i).cluster().forLocal());
- futs.add(comp.future());
+ futs.add(comp.callAsync(job));
itemsLeft -= cnt;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteCountDownLatchAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteCountDownLatchAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteCountDownLatchAbstractSelfTest.java
index 88966b0..4714acf 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteCountDownLatchAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteCountDownLatchAbstractSelfTest.java
@@ -30,7 +30,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteCompute;
import org.apache.ignite.IgniteCountDownLatch;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cluster.ClusterGroup;
@@ -136,9 +135,7 @@ public abstract class IgniteCountDownLatchAbstractSelfTest extends IgniteAtomics
assertEquals(2, latch1.count());
- IgniteCompute comp = grid(0).compute().withAsync();
-
- comp.call(new IgniteCallable<Object>() {
+ IgniteFuture<Object> fut = grid(0).compute().callAsync(new IgniteCallable<Object>() {
@IgniteInstanceResource
private Ignite ignite;
@@ -173,8 +170,6 @@ public abstract class IgniteCountDownLatchAbstractSelfTest extends IgniteAtomics
}
});
- IgniteFuture<Object> fut = comp.future();
-
Thread.sleep(3000);
assert latch1.countDown() == 1;
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteLockAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteLockAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteLockAbstractSelfTest.java
index 27e05b9..cccb8ab 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteLockAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteLockAbstractSelfTest.java
@@ -36,7 +36,6 @@ import java.util.concurrent.atomic.AtomicReference;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteCompute;
import org.apache.ignite.IgniteCondition;
import org.apache.ignite.IgniteCountDownLatch;
import org.apache.ignite.IgniteException;
@@ -243,9 +242,7 @@ public abstract class IgniteLockAbstractSelfTest extends IgniteAtomicsAbstractTe
lock1.lock();
- IgniteCompute comp = grid(0).compute().withAsync();
-
- comp.call(new IgniteCallable<Object>() {
+ IgniteFuture<Object> fut = grid(0).compute().callAsync(new IgniteCallable<Object>() {
@IgniteInstanceResource
private Ignite ignite;
@@ -282,8 +279,6 @@ public abstract class IgniteLockAbstractSelfTest extends IgniteAtomicsAbstractTe
}
});
- IgniteFuture<Object> fut = comp.future();
-
Thread.sleep(3000);
assert lock1.isHeldByCurrentThread();
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteSemaphoreAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteSemaphoreAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteSemaphoreAbstractSelfTest.java
index 56b260f..c39fdb0 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteSemaphoreAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteSemaphoreAbstractSelfTest.java
@@ -28,7 +28,6 @@ import java.util.concurrent.Callable;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteCompute;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.IgniteSemaphore;
import org.apache.ignite.configuration.CacheConfiguration;
@@ -225,9 +224,7 @@ public abstract class IgniteSemaphoreAbstractSelfTest extends IgniteAtomicsAbstr
assertEquals(-2, semaphore1.availablePermits());
- IgniteCompute comp = grid(0).compute().withAsync();
-
- comp.call(new IgniteCallable<Object>() {
+ IgniteFuture<Object> fut = grid(0).compute().callAsync(new IgniteCallable<Object>() {
@IgniteInstanceResource
private Ignite ignite;
@@ -264,8 +261,6 @@ public abstract class IgniteSemaphoreAbstractSelfTest extends IgniteAtomicsAbstr
}
});
- IgniteFuture<Object> fut = comp.future();
-
Thread.sleep(3000);
semaphore1.release(2);
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAsyncOperationsFailoverAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAsyncOperationsFailoverAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAsyncOperationsFailoverAbstractTest.java
index cf49cef..f2ae9ce 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAsyncOperationsFailoverAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAsyncOperationsFailoverAbstractTest.java
@@ -111,7 +111,7 @@ public abstract class CacheAsyncOperationsFailoverAbstractTest extends GridCache
* @throws Exception If failed.
*/
public void testAsyncFailover() throws Exception {
- IgniteCache<TestKey, TestValue> cache = ignite(0).<TestKey, TestValue>cache(null).withAsync();
+ IgniteCache<TestKey, TestValue> cache = ignite(0).cache(null);
int ops = cache.getConfiguration(CacheConfiguration.class).getMaxConcurrentAsyncOperations();
@@ -178,9 +178,7 @@ public abstract class CacheAsyncOperationsFailoverAbstractTest extends GridCache
for (int k = 0; k < keys; k++)
map.put(new TestKey(rnd.nextInt(10_000)), new TestValue(k));
- cache.putAll(map);
-
- IgniteFuture<?> fut = cache.future();
+ IgniteFuture<?> fut = cache.putAllAsync(map);
assertNotNull(fut);
@@ -227,7 +225,7 @@ public abstract class CacheAsyncOperationsFailoverAbstractTest extends GridCache
});
try {
- final IgniteCache<TestKey, TestValue> cache = ignite(0).<TestKey, TestValue>cache(null).withAsync();
+ final IgniteCache<TestKey, TestValue> cache = ignite(0).cache(null);
GridTestUtils.runMultiThreaded(new Callable<Object>() {
@Override public Object call() throws Exception {
@@ -253,9 +251,7 @@ public abstract class CacheAsyncOperationsFailoverAbstractTest extends GridCache
for (int k = 0; k < keys; k++)
map.put(new TestKey(rnd.nextInt(10_000)), new TestValue(iter));
- cache.putAll(map);
-
- IgniteFuture<?> fut = cache.future();
+ IgniteFuture<?> fut = cache.putAllAsync(map);
assertNotNull(fut);
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAsyncOperationsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAsyncOperationsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAsyncOperationsTest.java
index 34cbb5b..06baa09 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAsyncOperationsTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAsyncOperationsTest.java
@@ -122,19 +122,11 @@ public class CacheAsyncOperationsTest extends GridCommonAbstractTest {
latch = new CountDownLatch(1);
- IgniteCache<Integer, Integer> asyncCache = cache.withAsync();
+ IgniteFuture<?> fut1 = cache.putAsync(0, 0);
- asyncCache.put(0, 0);
+ IgniteFuture<?> fut2 = cache.getAndPutAsync(1, 2);
- IgniteFuture<?> fut1 = asyncCache.future();
-
- asyncCache.getAndPut(1, 2);
-
- IgniteFuture<?> fut2 = asyncCache.future();
-
- asyncCache.getAndPut(1, 3);
-
- IgniteFuture<?> fut3 = asyncCache.future();
+ IgniteFuture<?> fut3 = cache.getAndPutAsync(1, 3);
assertFalse(fut1.isDone());
assertFalse(fut2.isDone());
@@ -166,23 +158,13 @@ public class CacheAsyncOperationsTest extends GridCommonAbstractTest {
latch = new CountDownLatch(1);
- IgniteCache<Integer, Integer> asyncCache = cache.withAsync();
-
- asyncCache.put(0, 0);
-
- IgniteFuture<?> fut1 = asyncCache.future();
-
- asyncCache.put(0, 0);
-
- IgniteFuture<?> fut2 = asyncCache.future();
-
- asyncCache.getAndPut(1, 2);
+ IgniteFuture<?> fut1 = cache.putAsync(0, 0);
- IgniteFuture<?> fut3 = asyncCache.future();
+ IgniteFuture<?> fut2 = cache.putAsync(0, 0);
- asyncCache.put(0, 0);
+ IgniteFuture<?> fut3 = cache.getAndPutAsync(1, 2);
- IgniteFuture<?> fut4 = asyncCache.future();
+ IgniteFuture<?> fut4 = cache.putAsync(0, 0);
assertFalse(fut1.isDone());
assertFalse(fut2.isDone());
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CachePutAllFailoverAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CachePutAllFailoverAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CachePutAllFailoverAbstractTest.java
index 2d74e21..1e3f081 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CachePutAllFailoverAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CachePutAllFailoverAbstractTest.java
@@ -142,9 +142,7 @@ public abstract class CachePutAllFailoverAbstractTest extends GridCacheAbstractS
});
try {
- IgniteCache<TestKey, TestValue> cache0 = ignite(0).cache(null);
-
- final IgniteCache<TestKey, TestValue> cache = test == Test.PUT_ALL_ASYNC ? cache0.withAsync() : cache0;
+ final IgniteCache<TestKey, TestValue> cache = ignite(0).cache(null);
GridTestUtils.runMultiThreaded(new Callable<Object>() {
@Override public Object call() throws Exception {
@@ -184,9 +182,7 @@ public abstract class CachePutAllFailoverAbstractTest extends GridCacheAbstractS
for (int k = 0; k < 100; k++)
map.put(new TestKey(rnd.nextInt(200)), new TestValue(iter));
- cache.putAll(map);
-
- IgniteFuture<?> fut = cache.future();
+ IgniteFuture<?> fut = cache.putAllAsync(map);
assertNotNull(fut);
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/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 1769e14..6a61fbb 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
@@ -22,13 +22,12 @@ import java.util.LinkedList;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteCompute;
-import org.apache.ignite.compute.ComputeTaskFuture;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
import org.apache.ignite.internal.util.typedef.CX1;
import org.apache.ignite.internal.util.typedef.X;
+import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.resources.IgniteInstanceResource;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
@@ -132,16 +131,14 @@ public abstract class GridCacheAbstractJobExecutionTest extends GridCommonAbstra
Ignite ignite = grid(0);
- Collection<ComputeTaskFuture<?>> futs = new LinkedList<>();
+ Collection<IgniteFuture<?>> futs = new LinkedList<>();
final String key = "TestKey";
info("Primary node for test key: " + grid(0).affinity(null).mapKeyToNode(key));
- IgniteCompute comp = ignite.compute().withAsync();
-
for (int i = 0; i < jobCnt; i++) {
- comp.apply(new CX1<Integer, Void>() {
+ futs.add(ignite.compute().applyAsync(new CX1<Integer, Void>() {
@IgniteInstanceResource
private Ignite ignite;
@@ -168,12 +165,10 @@ public abstract class GridCacheAbstractJobExecutionTest extends GridCommonAbstra
return null;
}
- }, i);
-
- futs.add(comp.future());
+ }, i));
}
- for (ComputeTaskFuture<?> fut : futs)
+ for (IgniteFuture<?> fut : futs)
fut.get(); // Wait for completion.
for (int i = 0; i < GRID_CNT; i++) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheBasicOpAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheBasicOpAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheBasicOpAbstractTest.java
index 6085fca..cd7e513 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheBasicOpAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheBasicOpAbstractTest.java
@@ -181,29 +181,20 @@ public abstract class GridCacheBasicOpAbstractTest extends GridCommonAbstractTes
try {
IgniteCache<String, String> cache1 = ignite1.cache(null);
- IgniteCache<String, String> cache1Async = cache1.withAsync();
IgniteCache<String, String> cache2 = ignite2.cache(null);
- IgniteCache<String, String> cache2Async = cache2.withAsync();
IgniteCache<String, String> cache3 = ignite3.cache(null);
- IgniteCache<String, String> cache3Async = cache3.withAsync();
ignite1.events().localListen(lsnr, EVT_CACHE_OBJECT_PUT, EVT_CACHE_OBJECT_REMOVED);
ignite2.events().localListen(lsnr, EVT_CACHE_OBJECT_PUT, EVT_CACHE_OBJECT_REMOVED);
ignite3.events().localListen(lsnr, EVT_CACHE_OBJECT_PUT, EVT_CACHE_OBJECT_REMOVED);
- cache1Async.get("async1");
-
- IgniteFuture<String> f1 = cache1Async.future();
+ IgniteFuture<String> f1 = cache1.getAsync("async1");
assert f1.get() == null;
- cache1Async.put("async1", "asyncval1");
-
- cache1Async.future().get();
+ cache1.putAsync("async1", "asyncval1").get();
- cache1Async.get("async1");
-
- f1 = cache1Async.future();
+ f1 = cache1.getAsync("async1");
String v1 = f1.get();
@@ -212,13 +203,10 @@ public abstract class GridCacheBasicOpAbstractTest extends GridCommonAbstractTes
assert latch.await(5, SECONDS);
- cache2Async.get("async1");
-
- IgniteFuture<String> f2 = cache2Async.future();
+ IgniteFuture<String> f2 = cache2.getAsync("async1");
- cache3Async.get("async1");
+ IgniteFuture<String> f3 = cache3.getAsync("async1");
- IgniteFuture<String> f3 = cache3Async.future();
String v2 = f2.get();
String v3 = f3.get();
@@ -231,25 +219,17 @@ public abstract class GridCacheBasicOpAbstractTest extends GridCommonAbstractTes
lsnr.setLatch(latch = new CountDownLatch(3));
- cache2Async.getAndRemove("async1");
-
- f2 = cache2Async.future();
+ f2 = cache2.getAndRemoveAsync("async1");
assert "asyncval1".equals(f2.get());
assert latch.await(5, SECONDS);
- cache1Async.get("async1");
-
- f1 = cache1Async.future();
-
- cache2Async.get("async1");
-
- f2 = cache2Async.future();
+ f1 = cache1.getAsync("async1");
- cache3Async.get("async1");
+ f2 = cache2.getAsync("async1");
- f3 = cache3Async.future();
+ f3 = cache3.getAsync("async1");
v1 = f1.get();
v2 = f2.get();
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEventAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEventAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEventAbstractTest.java
index ee63ba9..8d916a7 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEventAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEventAbstractTest.java
@@ -311,8 +311,6 @@ public abstract class GridCacheEventAbstractTest extends GridCacheAbstractSelfTe
public void testGetPutRemoveAsync() throws Exception {
runTest(new TestCacheRunnable() {
@Override public void run(IgniteCache<String, Integer> cache) throws IgniteCheckedException {
- IgniteCache<String, Integer> asyncCache = cache.withAsync();
-
Map.Entry<String, Integer> e = F.first(pairs(1).entrySet());
assert e != null;
@@ -320,19 +318,13 @@ public abstract class GridCacheEventAbstractTest extends GridCacheAbstractSelfTe
String key = e.getKey();
Integer val = e.getValue();
- asyncCache.getAndPut(key, val);
-
- assert asyncCache.future().get() == null;
+ assert cache.getAndPutAsync(key, val).get() == null;
assert cache.containsKey(key);
- asyncCache.get(key);
-
- assert val.equals(asyncCache.future().get());
+ assert val.equals(cache.getAsync(key).get());
- asyncCache.getAndRemove(key);
-
- assert val.equals(asyncCache.future().get());
+ assert val.equals(cache.getAndRemoveAsync(key).get());
assert !cache.containsKey(key);
}
@@ -345,8 +337,6 @@ public abstract class GridCacheEventAbstractTest extends GridCacheAbstractSelfTe
public void testGetPutRemoveAsyncTx1() throws Exception {
runTest(new TestCacheRunnable() {
@Override public void run(IgniteCache<String, Integer> cache) throws IgniteCheckedException {
- IgniteCache<String, Integer> asyncCache = cache.withAsync();
-
Map.Entry<String, Integer> e = F.first(pairs(1).entrySet());
assert e != null;
@@ -356,19 +346,13 @@ public abstract class GridCacheEventAbstractTest extends GridCacheAbstractSelfTe
Transaction tx = cache.unwrap(Ignite.class).transactions().txStart();
- asyncCache.getAndPut(key, val);
-
- assert asyncCache.future().get() == null;
+ assert cache.getAndPutAsync(key, val).get() == null;
assert cache.containsKey(key);
- asyncCache.get(key);
+ assert val.equals(cache.getAsync(key).get());
- assert val.equals(asyncCache.future().get());
-
- asyncCache.getAndRemove(key);
-
- assert val.equals(asyncCache.future().get());
+ assert val.equals(cache.getAndRemoveAsync(key).get());
assert !cache.containsKey(key);
@@ -385,8 +369,6 @@ public abstract class GridCacheEventAbstractTest extends GridCacheAbstractSelfTe
public void testGetPutRemoveAsyncTx2() throws Exception {
runTest(new TestCacheRunnable() {
@Override public void run(IgniteCache<String, Integer> cache) throws IgniteCheckedException {
- IgniteCache<String, Integer> asyncCache = cache.withAsync();
-
Map.Entry<String, Integer> e = F.first(pairs(1).entrySet());
assert e != null;
@@ -396,25 +378,17 @@ public abstract class GridCacheEventAbstractTest extends GridCacheAbstractSelfTe
Transaction tx = cache.unwrap(Ignite.class).transactions().txStart();
- asyncCache.getAndPut(key, val);
-
- assert asyncCache.future().get() == null;
+ assert cache.getAndPutAsync(key, val).get() == null;
assert cache.containsKey(key);
- asyncCache.get(key);
-
- assert val.equals(asyncCache.future().get());
-
- asyncCache.getAndRemove(key);
+ assert val.equals(cache.getAsync(key).get());
- assert val.equals(asyncCache.future().get());
+ assert val.equals(cache.getAndRemoveAsync(key).get());
assert !cache.containsKey(key);
- asyncCache.getAndPut(key, val);
-
- assert asyncCache.future().get() == null;
+ assert cache.getAndPutAsync(key, val).get() == null;
assert cache.containsKey(key);
@@ -588,8 +562,6 @@ public abstract class GridCacheEventAbstractTest extends GridCacheAbstractSelfTe
public void testPutIfAbsentAsync() throws Exception {
runTest(new TestCacheRunnable() {
@Override public void run(IgniteCache<String, Integer> cache) throws IgniteCheckedException {
- IgniteCache<String, Integer> asyncCache = cache.withAsync();
-
Iterator<Map.Entry<String, Integer>> iter = pairs(2).entrySet().iterator();
Map.Entry<String, Integer> e = iter.next();
@@ -597,13 +569,9 @@ public abstract class GridCacheEventAbstractTest extends GridCacheAbstractSelfTe
String key = e.getKey();
Integer val = e.getValue();
- asyncCache.getAndPutIfAbsent(key, val);
-
- assert asyncCache.future().get() == null;
+ assert cache.getAndPutIfAbsentAsync(key, val).get() == null;
- asyncCache.getAndPutIfAbsent(key, val);
-
- assert val.equals(asyncCache.future().get());
+ assert val.equals(cache.getAndPutIfAbsentAsync(key, val).get());
assert cache.containsKey(key);
@@ -612,13 +580,9 @@ public abstract class GridCacheEventAbstractTest extends GridCacheAbstractSelfTe
key = e.getKey();
val = e.getValue();
- asyncCache.putIfAbsent(key, val);
-
- assert ((Boolean)asyncCache.future().get()).booleanValue();
-
- asyncCache.putIfAbsent(key, val);
+ assert cache.putIfAbsentAsync(key, val).get().booleanValue();
- assert !((Boolean)asyncCache.future().get()).booleanValue();
+ assert !cache.putIfAbsentAsync(key, val).get().booleanValue();
assert cache.containsKey(key);
}
@@ -634,8 +598,6 @@ public abstract class GridCacheEventAbstractTest extends GridCacheAbstractSelfTe
runTest(new TestCacheRunnable() {
@Override public void run(IgniteCache<String, Integer> cache) throws IgniteCheckedException {
- IgniteCache<String, Integer> asyncCache = cache.withAsync();
-
Iterator<Map.Entry<String, Integer>> iter = pairs(2).entrySet().iterator();
// Optimistic transaction.
@@ -645,13 +607,9 @@ public abstract class GridCacheEventAbstractTest extends GridCacheAbstractSelfTe
String key = e.getKey();
Integer val = e.getValue();
- asyncCache.getAndPutIfAbsent(key, val);
-
- assert asyncCache.future().get() == null;
-
- asyncCache.getAndPutIfAbsent(key, val);
+ assert cache.getAndPutIfAbsentAsync(key, val).get() == null;
- assert val.equals(asyncCache.future().get());
+ assert val.equals(cache.getAndPutIfAbsentAsync(key, val).get());
assert cache.containsKey(key);
@@ -660,13 +618,9 @@ public abstract class GridCacheEventAbstractTest extends GridCacheAbstractSelfTe
key = e.getKey();
val = e.getValue();
- asyncCache.putIfAbsent(key, val);
-
- assert ((Boolean)asyncCache.future().get()).booleanValue();
-
- asyncCache.putIfAbsent(key, val);
+ assert cache.putIfAbsentAsync(key, val).get().booleanValue();
- assert !((Boolean)asyncCache.future().get()).booleanValue();
+ assert !cache.putIfAbsentAsync(key, val).get().booleanValue();
assert cache.containsKey(key);
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultiNodeAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultiNodeAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultiNodeAbstractTest.java
index 93dabb8..67327be 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultiNodeAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultiNodeAbstractTest.java
@@ -66,15 +66,6 @@ public abstract class GridCacheMultiNodeAbstractTest extends GridCommonAbstractT
/** Cache 3. */
private static IgniteCache<Integer, String> cache3;
- /** Cache 1. */
- private static IgniteCache<Integer, String> cache1Async;
-
- /** Cache 2. */
- private static IgniteCache<Integer, String> cache2Async;
-
- /** Cache 3. */
- private static IgniteCache<Integer, String> cache3Async;
-
/** */
private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
@@ -103,10 +94,6 @@ public abstract class GridCacheMultiNodeAbstractTest extends GridCommonAbstractT
cache1 = ignite1.cache(null);
cache2 = ignite2.cache(null);
cache3 = ignite3.cache(null);
-
- cache1Async = cache1.withAsync();
- cache2Async = cache2.withAsync();
- cache3Async = cache3.withAsync();
}
/** {@inheritDoc} */
@@ -297,17 +284,11 @@ public abstract class GridCacheMultiNodeAbstractTest extends GridCommonAbstractT
addListener(ignite2, lsnr);
addListener(ignite3, lsnr);
- cache1Async.getAndPut(2, "val1");
-
- IgniteFuture<String> f1 = cache1Async.future();
-
- cache2Async.getAndPut(2, "val2");
-
- IgniteFuture<String> f2 = cache2Async.future();
+ IgniteFuture<String> f1 = cache1.getAndPutAsync(2, "val1");
- cache3Async.getAndPut(2, "val3");
+ IgniteFuture<String> f2 = cache2.getAndPutAsync(2, "val2");
- IgniteFuture<String> f3 = cache3Async.future();
+ IgniteFuture<String> f3 = cache3.getAndPutAsync(2, "val3");
String v1 = f1.get(20000);
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteBinaryMetadataUpdateChangingTopologySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteBinaryMetadataUpdateChangingTopologySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteBinaryMetadataUpdateChangingTopologySelfTest.java
index b07c437..68bce5e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteBinaryMetadataUpdateChangingTopologySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteBinaryMetadataUpdateChangingTopologySelfTest.java
@@ -40,6 +40,7 @@ import org.apache.ignite.internal.managers.communication.GridIoMessage;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareResponse;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.T2;
+import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.lang.IgniteInClosure;
import org.apache.ignite.plugin.extensions.communication.Message;
import org.apache.ignite.resources.LoggerResource;
@@ -104,9 +105,9 @@ public class IgniteBinaryMetadataUpdateChangingTopologySelfTest extends GridComm
spi.blockMessages(GridNearTxPrepareResponse.class, ignite(0).cluster().localNode().id());
- IgniteCache<Object, Object> cache = ignite(0).cache("cache").withAsync();
+ IgniteCache<Object, Object> cache = ignite(0).cache("cache");
- cache.putAll(F.asMap(key1, "val1", key2, new TestValue1()));
+ IgniteFuture futPutAll = cache.putAllAsync(F.asMap(key1, "val1", key2, new TestValue1()));
try {
Thread.sleep(500);
@@ -123,7 +124,7 @@ public class IgniteBinaryMetadataUpdateChangingTopologySelfTest extends GridComm
spi.stopBlock();
- cache.future().get();
+ futPutAll.get();
fut.get();
}
@@ -143,9 +144,9 @@ public class IgniteBinaryMetadataUpdateChangingTopologySelfTest extends GridComm
spi.blockMessages(GridNearTxPrepareResponse.class, ignite(0).cluster().localNode().id());
- IgniteCache<Object, Object> cache = ignite(0).cache("cache").withAsync();
+ IgniteCache<Object, Object> cache = ignite(0).cache("cache");
- cache.invokeAll(F.asSet(key1, key2), new TestEntryProcessor());
+ IgniteFuture futInvokeAll = cache.invokeAllAsync(F.asSet(key1, key2), new TestEntryProcessor());
try {
Thread.sleep(500);
@@ -162,7 +163,7 @@ public class IgniteBinaryMetadataUpdateChangingTopologySelfTest extends GridComm
spi.stopBlock();
- cache.future().get();
+ futInvokeAll.get();
fut.get();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheConnectionRecoveryTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheConnectionRecoveryTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheConnectionRecoveryTest.java
index 450ab9a..7c454e6 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheConnectionRecoveryTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheConnectionRecoveryTest.java
@@ -122,18 +122,16 @@ public class IgniteCacheConnectionRecoveryTest extends GridCommonAbstractTest {
Thread.currentThread().setName("test-thread-" + idx0 + "-" + node.name());
- IgniteCache cache1 = node.cache("cache1").withAsync();
- IgniteCache cache2 = node.cache("cache2").withAsync();
+ IgniteCache cache1 = node.cache("cache1");
+ IgniteCache cache2 = node.cache("cache2");
int iter = 0;
while (U.currentTimeMillis() < stopTime) {
try {
- cache1.putAll(data);
- cache1.future().get(15, SECONDS);
+ cache1.putAllAsync(data).get(15, SECONDS);
- cache2.putAll(data);
- cache2.future().get(15, SECONDS);
+ cache2.putAllAsync(data).get(15, SECONDS);
CyclicBarrier b = barrierRef.get();
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheMessageRecoveryIdleConnectionTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheMessageRecoveryIdleConnectionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheMessageRecoveryIdleConnectionTest.java
index c47e1e1..10bb3c1 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheMessageRecoveryIdleConnectionTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheMessageRecoveryIdleConnectionTest.java
@@ -113,7 +113,7 @@ public class IgniteCacheMessageRecoveryIdleConnectionTest extends GridCommonAbst
ccfg.setCacheMode(REPLICATED);
ccfg.setWriteSynchronizationMode(FULL_SYNC);
- IgniteCache<Object, Object> cache = ignite(0).createCache(ccfg).withAsync();
+ IgniteCache<Object, Object> cache = ignite(0).createCache(ccfg);
try {
ThreadLocalRandom rnd = ThreadLocalRandom.current();
@@ -126,9 +126,7 @@ public class IgniteCacheMessageRecoveryIdleConnectionTest extends GridCommonAbst
if (iter++ % 50 == 0)
log.info("Iteration: " + iter);
- cache.put(iter, 1);
-
- IgniteFuture<?> fut = cache.future();
+ IgniteFuture<?> fut = cache.putAsync(iter, 1);
try {
fut.get(10_000);
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest.java
index 4997b20..13772d5 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest.java
@@ -204,11 +204,7 @@ public abstract class IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest
info("Before commitAsync");
- tx = (Transaction)tx.withAsync();
-
- tx.commit();
-
- IgniteFuture<Transaction> fut = tx.future();
+ IgniteFuture<?> fut = tx.commitAsync();
info("Got future for commitAsync().");
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheGlobalLoadTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheGlobalLoadTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheGlobalLoadTest.java
index aa4f5bd..82823a9 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheGlobalLoadTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheGlobalLoadTest.java
@@ -73,21 +73,29 @@ public class GridCacheGlobalLoadTest extends IgniteCacheAbstractTest {
* @throws Exception If failed.
*/
public void testLoadCache() throws Exception {
- loadCache(false);
+ loadCache(false, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testLoadCacheAsyncOld() throws Exception {
+ loadCache(true, true);
}
/**
* @throws Exception If failed.
*/
public void testLoadCacheAsync() throws Exception {
- loadCache(true);
+ loadCache(true, false);
}
/**
* @param async If {@code true} uses asynchronous method.
+ * @param oldAsyncApi Flag to use old async API.
* @throws Exception If failed.
*/
- private void loadCache(boolean async) throws Exception {
+ private void loadCache(boolean async, boolean oldAsyncApi) throws Exception {
IgniteCache<Integer, Integer> cache = jcache();
IgniteCache<Integer, Integer> asyncCache = cache.withAsync();
@@ -97,9 +105,12 @@ public class GridCacheGlobalLoadTest extends IgniteCacheAbstractTest {
map = new ConcurrentHashMap8<>();
if (async) {
- asyncCache.loadCache(null, 1, 2, 3);
+ if (oldAsyncApi) {
+ asyncCache.loadCache(null, 1, 2, 3);
- asyncCache.future().get();
+ asyncCache.future().get();
+ } else
+ cache.loadCacheAsync(null, 1, 2, 3).get();
}
else
cache.loadCache(null, 1, 2, 3);
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
index d8120ac..1371612 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
@@ -237,15 +237,11 @@ public class GridCacheTxNodeFailureSelfTest extends GridCommonAbstractTest {
try (Transaction tx = ignite.transactions().txStart(conc, REPEATABLE_READ)) {
cache.put(key, key);
- Transaction asyncTx = (Transaction)tx.withAsync();
-
- asyncTx.commit();
+ IgniteFuture<?> fut = tx.commitAsync();
commitLatch.countDown();
try {
- IgniteFuture<Object> fut = asyncTx.future();
-
fut.get();
if (!commit) {
@@ -266,16 +262,14 @@ public class GridCacheTxNodeFailureSelfTest extends GridCommonAbstractTest {
}
}
else {
- IgniteCache<Object, Object> cache0 = cache.withAsync();
-
- cache0.put(key, key);
+ IgniteFuture fut = cache.putAsync(key, key);
Thread.sleep(1000);
commitLatch.countDown();
try {
- cache0.future().get();
+ fut.get();
if (!commit) {
error("Transaction has been committed");
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAbstractSelfTest.java
index 2971f81..e42ddcf 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAbstractSelfTest.java
@@ -371,22 +371,14 @@ public abstract class IgniteCachePutRetryAbstractSelfTest extends GridCommonAbst
}
case PUT_ASYNC: {
- IgniteCache<Integer, Integer> cache0 = cache.withAsync();
-
while (System.currentTimeMillis() < stopTime) {
Integer val = ++iter;
- for (int i = 0; i < keysCnt; i++) {
- cache0.put(i, val);
-
- cache0.future().get();
- }
-
- for (int i = 0; i < keysCnt; i++) {
- cache0.get(i);
+ for (int i = 0; i < keysCnt; i++)
+ cache.putAsync(i, val).get();
- assertEquals(val, cache0.future().get());
- }
+ for (int i = 0; i < keysCnt; i++)
+ assertEquals(val, cache.getAsync(i).get());
}
break;
@@ -556,19 +548,13 @@ public abstract class IgniteCachePutRetryAbstractSelfTest extends GridCommonAbst
IgniteCache<Object, Object> cache = ignite(0).cache(null).withNoRetries();
- if (async)
- cache = cache.withAsync();
-
long stopTime = System.currentTimeMillis() + 60_000;
while (System.currentTimeMillis() < stopTime) {
for (int i = 0; i < keysCnt; i++) {
try {
- if (async) {
- cache.put(i, i);
-
- cache.future().get();
- }
+ if (async)
+ cache.putAsync(i, i).get();
else
cache.put(i, i);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java
index 6d90d0e..eda030c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java
@@ -167,7 +167,6 @@ public class IgniteCacheAtomicProtocolTest extends GridCommonAbstractTest {
Ignite client = startGrid(4);
IgniteCache<Integer, Integer> nearCache = client.cache(TEST_CACHE);
- IgniteCache<Integer, Integer> nearAsyncCache = nearCache.withAsync();
if (!blockRebalance)
awaitPartitionMapExchange();
@@ -196,9 +195,7 @@ public class IgniteCacheAtomicProtocolTest extends GridCommonAbstractTest {
log.info("Start put [key1=" + key1 + ", key2=" + key2 + ']');
- nearAsyncCache.putAll(map);
-
- IgniteFuture<?> fut = nearAsyncCache.future();
+ IgniteFuture<?> fut = nearCache.putAllAsync(map);
U.sleep(500);
@@ -244,7 +241,6 @@ public class IgniteCacheAtomicProtocolTest extends GridCommonAbstractTest {
Ignite client = startGrid(4);
IgniteCache<Integer, Integer> nearCache = client.cache(TEST_CACHE);
- IgniteCache<Integer, Integer> nearAsyncCache = nearCache.withAsync();
if (!blockRebalance)
awaitPartitionMapExchange();
@@ -264,9 +260,7 @@ public class IgniteCacheAtomicProtocolTest extends GridCommonAbstractTest {
log.info("Start put [map=" + map + ']');
- nearAsyncCache.putAll(map);
-
- IgniteFuture<?> fut = nearAsyncCache.future();
+ IgniteFuture<?> fut = nearCache.putAllAsync(map);
U.sleep(500);
@@ -308,7 +302,6 @@ public class IgniteCacheAtomicProtocolTest extends GridCommonAbstractTest {
Ignite client = startGrid(4);
IgniteCache<Integer, Integer> nearCache = client.cache(TEST_CACHE);
- IgniteCache<Integer, Integer> nearAsyncCache = nearCache.withAsync();
if (!blockRebalance)
awaitPartitionMapExchange();
@@ -323,9 +316,7 @@ public class IgniteCacheAtomicProtocolTest extends GridCommonAbstractTest {
log.info("Start put [key=" + key + ']');
- nearAsyncCache.put(key, key);
-
- IgniteFuture<?> fut = nearAsyncCache.future();
+ IgniteFuture<?> fut = nearCache.putAsync(key, key);
U.sleep(500);
@@ -438,7 +429,6 @@ public class IgniteCacheAtomicProtocolTest extends GridCommonAbstractTest {
client = false;
final IgniteCache<Integer, Integer> nearCache = clientNode.createCache(cacheConfiguration(1, PRIMARY_SYNC));
- IgniteCache<Integer, Integer> nearAsyncCache = nearCache.withAsync();
awaitPartitionMapExchange();
@@ -449,9 +439,7 @@ public class IgniteCacheAtomicProtocolTest extends GridCommonAbstractTest {
testSpi(srv0).blockMessages(GridDhtAtomicSingleUpdateRequest.class, srv1.name());
- nearAsyncCache.put(key, key);
-
- IgniteFuture<?> fut = nearAsyncCache.future();
+ IgniteFuture<?> fut = nearCache.putAsync(key, key);
fut.get(5, TimeUnit.SECONDS);
@@ -481,7 +469,6 @@ public class IgniteCacheAtomicProtocolTest extends GridCommonAbstractTest {
Ignite clientNode = startGrid(2);
final IgniteCache<Integer, Integer> nearCache = clientNode.createCache(cacheConfiguration(1, FULL_SYNC));
- IgniteCache<Integer, Integer> nearAsyncCache = nearCache.withAsync();
awaitPartitionMapExchange();
@@ -490,7 +477,7 @@ public class IgniteCacheAtomicProtocolTest extends GridCommonAbstractTest {
final Integer key = primaryKey(srv0.cache(TEST_CACHE));
- nearAsyncCache.put(key, key);
+ nearCache.putAsync(key, key);
testSpi(srv1).blockMessages(GridDhtAtomicNearResponse.class, clientNode.name());
@@ -521,7 +508,6 @@ public class IgniteCacheAtomicProtocolTest extends GridCommonAbstractTest {
Ignite clientNode = startGrid(SRVS);
final IgniteCache<Integer, Integer> nearCache = clientNode.createCache(cacheConfiguration(1, FULL_SYNC));
- IgniteCache<Integer, Integer> nearAsyncCache = nearCache.withAsync();
awaitPartitionMapExchange();
@@ -533,7 +519,7 @@ public class IgniteCacheAtomicProtocolTest extends GridCommonAbstractTest {
for (int i = 0; i < 100; i++)
map.put(i, i);
- nearAsyncCache.putAll(map);
+ nearCache.putAllAsync(map);
boolean wait = GridTestUtils.waitForCondition(new GridAbsPredicate() {
@Override public boolean apply() {
@@ -678,7 +664,6 @@ public class IgniteCacheAtomicProtocolTest extends GridCommonAbstractTest {
Ignite client = startGrid(4);
IgniteCache<Integer, Integer> nearCache = client.cache(TEST_CACHE);
- IgniteCache<Integer, Integer> nearAsyncCache = nearCache.withAsync();
testSpi(ignite(0)).blockMessages(new IgnitePredicate<GridIoMessage>() {
@Override public boolean apply(GridIoMessage msg) {
@@ -690,8 +675,7 @@ public class IgniteCacheAtomicProtocolTest extends GridCommonAbstractTest {
log.info("Start put [key=" + key + ']');
- nearAsyncCache.put(key, key);
- IgniteFuture<?> fut = nearAsyncCache.future();
+ IgniteFuture<?> fut = nearCache.putAsync(key, key);
U.sleep(500);
@@ -735,7 +719,6 @@ public class IgniteCacheAtomicProtocolTest extends GridCommonAbstractTest {
Ignite client = startGrid(4);
IgniteCache<Integer, Integer> nearCache = client.cache(TEST_CACHE);
- IgniteCache<Integer, Integer> nearAsyncCache = nearCache.withAsync();
if (fail0) {
testSpi(ignite(0)).blockMessages(new IgnitePredicate<GridIoMessage>() {
@@ -761,8 +744,7 @@ public class IgniteCacheAtomicProtocolTest extends GridCommonAbstractTest {
map.put(key1, 10);
map.put(key2, 20);
- nearAsyncCache.putAll(map);
- IgniteFuture<?> fut = nearAsyncCache.future();
+ IgniteFuture<?> fut = nearCache.putAllAsync(map);
U.sleep(500);
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/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 23fbf2f..5d2ec39 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
@@ -517,7 +517,7 @@ public class GridCacheNearOnlyMultiNodeFullApiSelfTest extends GridCachePartitio
* @param async If {@code true} uses async method.
* @throws Exception If failed.
*/
- @Override protected void globalClearAll(boolean async) throws Exception {
+ @Override protected void globalClearAll(boolean async, boolean oldAsync) throws Exception {
// Save entries only on their primary nodes. If we didn't do so, clearLocally() will not remove all entries
// because some of them were blocked due to having readers.
for (int i = 0; i < gridCount(); i++) {
@@ -528,11 +528,14 @@ public class GridCacheNearOnlyMultiNodeFullApiSelfTest extends GridCachePartitio
}
if (async) {
- IgniteCache<String, Integer> asyncCache = jcache(nearIdx).withAsync();
+ if (oldAsync) {
+ IgniteCache<String, Integer> asyncCache = jcache(nearIdx).withAsync();
- asyncCache.clear();
+ asyncCache.clear();
- asyncCache.future().get();
+ asyncCache.future().get();
+ } else
+ jcache(nearIdx).clearAsync().get();
}
else
jcache(nearIdx).clear();
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedLoadCacheSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedLoadCacheSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedLoadCacheSelfTest.java
index c6bb85e..69310a7 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedLoadCacheSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedLoadCacheSelfTest.java
@@ -98,13 +98,8 @@ public class GridCachePartitionedLoadCacheSelfTest extends GridCommonAbstractTes
IgniteCache<Integer, String> cache = jcache(0);
- if (async) {
- IgniteCache<Integer, String> asyncCache = cache.withAsync();
-
- asyncCache.localLoadCache(null, PUT_CNT);
-
- asyncCache.future().get();
- }
+ if (async)
+ cache.localLoadCacheAsync(null, PUT_CNT).get();
else
cache.localLoadCache(null, PUT_CNT);
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheEmptyEntriesAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheEmptyEntriesAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheEmptyEntriesAbstractSelfTest.java
index e066764..0c14fb0 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheEmptyEntriesAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheEmptyEntriesAbstractSelfTest.java
@@ -204,17 +204,11 @@ public abstract class GridCacheEmptyEntriesAbstractSelfTest extends GridCommonAb
private void checkImplicitTx(IgniteCache<String, String> cache) throws Exception {
assertNull(cache.get("key1"));
- IgniteCache<String, String> asyncCache = cache.withAsync();
-
- asyncCache.get("key2");
-
- assertNull(asyncCache.future().get());
+ assertNull(cache.getAsync("key2").get());
assertTrue(cache.getAll(F.asSet("key3", "key4")).isEmpty());
- asyncCache.getAll(F.asSet("key5", "key6"));
-
- assertTrue(((Map)asyncCache.future().get()).isEmpty());
+ assertTrue(((Map)cache.getAllAsync(F.asSet("key5", "key6")).get()).isEmpty());
cache.put("key7", "key7");
cache.remove("key7", "key7");
@@ -226,12 +220,11 @@ public abstract class GridCacheEmptyEntriesAbstractSelfTest extends GridCommonAb
/**
* Checks that gets work for implicit txs.
*
+ * @param ignite Ignite instance.
* @param cache Cache to test.
* @throws Exception If failed.
*/
private void checkExplicitTx(Ignite ignite, IgniteCache<String, String> cache) throws Exception {
- IgniteCache<String, String> asyncCache = cache.withAsync();
-
Transaction tx = ignite.transactions().txStart();
try {
@@ -246,9 +239,7 @@ public abstract class GridCacheEmptyEntriesAbstractSelfTest extends GridCommonAb
tx = ignite.transactions().txStart();
try {
- asyncCache.get("key2");
-
- assertNull(asyncCache.future().get());
+ assertNull(cache.getAsync("key2").get());
tx.commit();
}
@@ -270,9 +261,7 @@ public abstract class GridCacheEmptyEntriesAbstractSelfTest extends GridCommonAb
tx = ignite.transactions().txStart();
try {
- asyncCache.getAll(F.asSet("key5", "key6"));
-
- assertTrue(((Map)asyncCache.future().get()).isEmpty());
+ assertTrue(((Map)cache.getAllAsync(F.asSet("key5", "key6")).get()).isEmpty());
tx.commit();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryConcurrentTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryConcurrentTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryConcurrentTest.java
index 586d1595..26574f1 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryConcurrentTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryConcurrentTest.java
@@ -345,11 +345,8 @@ public class GridCacheContinuousQueryConcurrentTest extends GridCommonAbstractTe
// Now must check the cache again, to make sure that we didn't miss the key insert while we
// were busy setting up the cache listener.
// Check asynchronously.
- IgniteCache<Integer, String> asyncCache = cache.withAsync();
- asyncCache.get(key);
-
// Complete the promise if the key was inserted concurrently.
- asyncCache.<String>future().listen(new IgniteInClosure<IgniteFuture<String>>() {
+ cache.getAsync(key).listen(new IgniteInClosure<IgniteFuture<String>>() {
@Override public void apply(IgniteFuture<String> f) {
String value = f.get();
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/closure/GridClosureProcessorSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/closure/GridClosureProcessorSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/closure/GridClosureProcessorSelfTest.java
index b6542ab..fec0637 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/closure/GridClosureProcessorSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/closure/GridClosureProcessorSelfTest.java
@@ -31,11 +31,11 @@ import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cluster.ClusterGroup;
import org.apache.ignite.cluster.ClusterNode;
-import org.apache.ignite.compute.ComputeTaskFuture;
import org.apache.ignite.compute.ComputeTaskTimeoutException;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.lang.IgniteCallable;
+import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.lang.IgniteReducer;
import org.apache.ignite.lang.IgniteRunnable;
@@ -114,7 +114,7 @@ public class GridClosureProcessorSelfTest extends GridCommonAbstractTest {
@LoggerResource
private IgniteLogger log;
- /** @{inheritDoc} */
+ /** {@inheritDoc} */
@Override public void run() {
log.info("Runnable job executed on node: " + ignite.cluster().localNode().id());
@@ -198,7 +198,7 @@ public class GridClosureProcessorSelfTest extends GridCommonAbstractTest {
* @param p Optional node predicate.
* @return Future object.
*/
- private ComputeTaskFuture<?> runAsync(int idx, IgniteRunnable job, @Nullable IgnitePredicate<ClusterNode> p) {
+ private IgniteFuture<?> runAsync(int idx, IgniteRunnable job, @Nullable IgnitePredicate<ClusterNode> p) {
assert idx >= 0 && idx < NODES_CNT;
assert job != null;
@@ -206,11 +206,7 @@ public class GridClosureProcessorSelfTest extends GridCommonAbstractTest {
IgniteCompute comp = p != null ? compute(grid(idx).cluster().forPredicate(p)) : grid(idx).compute();
- comp = comp.withAsync();
-
- comp.run(job);
-
- return comp.future();
+ return comp.runAsync(job);
}
/**
@@ -219,7 +215,7 @@ public class GridClosureProcessorSelfTest extends GridCommonAbstractTest {
* @param p Optional node predicate.
* @return Future object.
*/
- private ComputeTaskFuture<?> broadcast(int idx, IgniteRunnable job, @Nullable IgnitePredicate<ClusterNode> p) {
+ private IgniteFuture<?> broadcast(int idx, IgniteRunnable job, @Nullable IgnitePredicate<ClusterNode> p) {
assert idx >= 0 && idx < NODES_CNT;
assert job != null;
@@ -230,11 +226,7 @@ public class GridClosureProcessorSelfTest extends GridCommonAbstractTest {
if (p != null)
prj = prj.forPredicate(p);
- IgniteCompute comp = compute(prj).withAsync();
-
- comp.broadcast(job);
-
- return comp.future();
+ return compute(prj).broadcastAsync(job);
}
/**
@@ -243,7 +235,7 @@ public class GridClosureProcessorSelfTest extends GridCommonAbstractTest {
* @param p Optional node predicate.
* @return Future object.
*/
- private ComputeTaskFuture<?> runAsync(int idx,
+ private IgniteFuture<?> runAsync(int idx,
Collection<ClosureTestRunnable> jobs,
@Nullable IgnitePredicate<ClusterNode> p)
{
@@ -254,11 +246,7 @@ public class GridClosureProcessorSelfTest extends GridCommonAbstractTest {
IgniteCompute comp = p != null ? compute(grid(idx).cluster().forPredicate(p)) : grid(idx).compute();
- comp = comp.withAsync();
-
- comp.run(jobs);
-
- return comp.future();
+ return comp.runAsync(jobs);
}
/**
@@ -267,7 +255,7 @@ public class GridClosureProcessorSelfTest extends GridCommonAbstractTest {
* @param p Optional node predicate.
* @return Future object.
*/
- private ComputeTaskFuture<Integer> callAsync(int idx,
+ private IgniteFuture<Integer> callAsync(int idx,
IgniteCallable<Integer> job, @Nullable
IgnitePredicate<ClusterNode> p) {
assert idx >= 0 && idx < NODES_CNT;
@@ -277,11 +265,7 @@ public class GridClosureProcessorSelfTest extends GridCommonAbstractTest {
IgniteCompute comp = p != null ? compute(grid(idx).cluster().forPredicate(p)) : grid(idx).compute();
- comp = comp.withAsync();
-
- comp.call(job);
-
- return comp.future();
+ return comp.callAsync(job);
}
/**
@@ -290,7 +274,7 @@ public class GridClosureProcessorSelfTest extends GridCommonAbstractTest {
* @param p Optional node predicate.
* @return Future object.
*/
- private ComputeTaskFuture<Collection<Integer>> broadcast(int idx, IgniteCallable<Integer> job,
+ private IgniteFuture<Collection<Integer>> broadcast(int idx, IgniteCallable<Integer> job,
@Nullable IgnitePredicate<ClusterNode> p) {
assert idx >= 0 && idx < NODES_CNT;
assert job != null;
@@ -299,11 +283,7 @@ public class GridClosureProcessorSelfTest extends GridCommonAbstractTest {
IgniteCompute comp = p != null ? compute(grid(idx).cluster().forPredicate(p)) : grid(idx).compute();
- comp = comp.withAsync();
-
- comp.broadcast(job);
-
- return comp.future();
+ return comp.broadcastAsync(job);
}
/**
@@ -312,7 +292,7 @@ public class GridClosureProcessorSelfTest extends GridCommonAbstractTest {
* @param p Optional node predicate.
* @return Future object.
*/
- private ComputeTaskFuture<Collection<Integer>> callAsync(int idx, Collection<ClosureTestCallable> jobs,
+ private IgniteFuture<Collection<Integer>> callAsync(int idx, Collection<ClosureTestCallable> jobs,
@Nullable IgnitePredicate<ClusterNode> p) {
assert idx >= 0 && idx < NODES_CNT;
assert !F.isEmpty(jobs);
@@ -321,11 +301,7 @@ public class GridClosureProcessorSelfTest extends GridCommonAbstractTest {
IgniteCompute comp = p != null ? compute(grid(idx).cluster().forPredicate(p)) : grid(idx).compute();
- comp = comp.withAsync();
-
- comp.call(jobs);
-
- return comp.future();
+ return comp.callAsync(jobs);
}
/**
@@ -346,7 +322,7 @@ public class GridClosureProcessorSelfTest extends GridCommonAbstractTest {
public void testRunAsyncSingle() throws Exception {
IgniteRunnable job = new ClosureTestRunnable();
- ComputeTaskFuture<?> fut = broadcast(0, job, null);
+ IgniteFuture<?> fut = broadcast(0, job, null);
assert fut.get() == null;
@@ -372,7 +348,7 @@ public class GridClosureProcessorSelfTest extends GridCommonAbstractTest {
public void testRunAsyncMultiple() throws Exception {
Collection<ClosureTestRunnable> jobs = F.asList(new ClosureTestRunnable(), new ClosureTestRunnable());
- ComputeTaskFuture<?> fut = runAsync(0, jobs, null);
+ IgniteFuture<?> fut = runAsync(0, jobs, null);
assert fut.get() == null : "Execution result must be null.";
@@ -386,7 +362,7 @@ public class GridClosureProcessorSelfTest extends GridCommonAbstractTest {
public void testCallAsyncSingle() throws Exception {
IgniteCallable<Integer> job = new ClosureTestCallable();
- ComputeTaskFuture<Collection<Integer>> fut1 = broadcast(0, job, null);
+ IgniteFuture<Collection<Integer>> fut1 = broadcast(0, job, null);
assert fut1.get() != null;
@@ -399,7 +375,7 @@ public class GridClosureProcessorSelfTest extends GridCommonAbstractTest {
assertEquals(1, execCntr.get());
- ComputeTaskFuture<Integer> fut2 = callAsync(0, job, null);
+ IgniteFuture<Integer> fut2 = callAsync(0, job, null);
assert fut2.get() == 1 :
"Execution result must be equal to 1, actual: " + fut2.get();
@@ -412,11 +388,9 @@ public class GridClosureProcessorSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testCallAsyncErrorNoFailover() throws Exception {
- IgniteCompute comp = compute(grid(0).cluster().forPredicate(F.notEqualTo(grid(0).localNode()))).withAsync();
-
- comp.withNoFailover().call(new ClosureTestCallableError());
+ IgniteCompute comp = compute(grid(0).cluster().forPredicate(F.notEqualTo(grid(0).localNode())));
- ComputeTaskFuture<Integer> fut = comp.future();
+ IgniteFuture<Integer> fut = comp.withNoFailover().callAsync(new ClosureTestCallableError());
try {
fut.get();
@@ -472,7 +446,7 @@ public class GridClosureProcessorSelfTest extends GridCommonAbstractTest {
public void testCallAsyncMultiple() throws Exception {
Collection<ClosureTestCallable> jobs = F.asList(new ClosureTestCallable(), new ClosureTestCallable());
- ComputeTaskFuture<Collection<Integer>> fut = callAsync(0, jobs, null);
+ IgniteFuture<Collection<Integer>> fut = callAsync(0, jobs, null);
Collection<Integer> results = fut.get();
@@ -491,11 +465,7 @@ public class GridClosureProcessorSelfTest extends GridCommonAbstractTest {
public void testReduceAsync() throws Exception {
Collection<ClosureTestCallable> jobs = F.asList(new ClosureTestCallable(), new ClosureTestCallable());
- IgniteCompute comp = grid(0).compute().withAsync();
-
- comp.call(jobs, F.sumIntReducer());
-
- ComputeTaskFuture<Integer> fut = comp.future();
+ IgniteFuture<Integer> fut = grid(0).compute().callAsync(jobs, F.sumIntReducer());
// Sum of arithmetic progression.
int exp = (1 + jobs.size()) * jobs.size() / 2;
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/GridComputeJobExecutionErrorToLogManualTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/GridComputeJobExecutionErrorToLogManualTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/GridComputeJobExecutionErrorToLogManualTest.java
index ce89e81..939101f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/GridComputeJobExecutionErrorToLogManualTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/compute/GridComputeJobExecutionErrorToLogManualTest.java
@@ -18,7 +18,6 @@
package org.apache.ignite.internal.processors.compute;
import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCompute;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.lang.IgniteInClosure;
@@ -67,8 +66,7 @@ public class GridComputeJobExecutionErrorToLogManualTest extends GridCommonAbstr
public void testRuntimeException() throws Exception {
Ignite ignite = grid(0);
- IgniteCompute async = ignite.compute().withAsync();
- async.run(new IgniteRunnable() {
+ ignite.compute().runAsync(new IgniteRunnable() {
@Override public void run() {
try {
Thread.sleep(500);
@@ -77,10 +75,8 @@ public class GridComputeJobExecutionErrorToLogManualTest extends GridCommonAbstr
// No-op.
}
}
- });
-
- async.future().listen(new IgniteInClosure<IgniteFuture<Object>>() {
- @Override public void apply(IgniteFuture<Object> future) {
+ }).listen(new IgniteInClosure<IgniteFuture<Void>>() {
+ @Override public void apply(IgniteFuture<Void> future) {
throw new RuntimeException();
}
});
[09/10] ignite git commit: IGNITE-4475: New async API: now all async
methods are defined explicitly,
IgniteAsyncSupport is deprecated. This closes #1648.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/main/java/org/apache/ignite/IgniteCompute.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCompute.java b/modules/core/src/main/java/org/apache/ignite/IgniteCompute.java
index b5c6261..ad675c0 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteCompute.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCompute.java
@@ -28,6 +28,7 @@ import org.apache.ignite.lang.IgniteAsyncSupport;
import org.apache.ignite.lang.IgniteAsyncSupported;
import org.apache.ignite.lang.IgniteCallable;
import org.apache.ignite.lang.IgniteClosure;
+import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.lang.IgniteReducer;
import org.apache.ignite.lang.IgniteRunnable;
import org.apache.ignite.lang.IgniteUuid;
@@ -113,6 +114,7 @@ import org.jetbrains.annotations.Nullable;
* checkpoints, etc.). If you need to override configured defaults, you should use compute task together with
* {@link ComputeTaskSpis} annotation. Refer to {@link ComputeTask} documentation for more information.
*/
+@SuppressWarnings("deprecation")
public interface IgniteCompute extends IgniteAsyncSupport {
/**
* Gets cluster group to which this {@code IgniteCompute} instance belongs.
@@ -137,6 +139,20 @@ public interface IgniteCompute extends IgniteAsyncSupport {
public void affinityRun(@Nullable String cacheName, Object affKey, IgniteRunnable job) throws IgniteException;
/**
+ * Executes given job asynchronously on the node where data for provided affinity key is located
+ * (a.k.a. affinity co-location). The data of the partition where affKey is stored
+ * will not be migrated from the target node while the job is executed.
+ *
+ * @param cacheName Name of the cache to use for affinity co-location.
+ * @param affKey Affinity key.
+ * @param job Job which will be co-located on the node with given affinity key.
+ * @return a Future representing pending completion of the affinity run.
+ * @throws IgniteException If job failed.
+ */
+ public IgniteFuture<Void> affinityRunAsync(@Nullable String cacheName, Object affKey, IgniteRunnable job)
+ throws IgniteException;
+
+ /**
* Executes given job on the node where data for provided affinity key is located
* (a.k.a. affinity co-location).
* </p>
@@ -154,6 +170,21 @@ public interface IgniteCompute extends IgniteAsyncSupport {
throws IgniteException;
/**
+ * Executes given job asynchronously on the node where data for provided affinity key is located
+ * (a.k.a. affinity co-location). The data of the partition where affKey is stored
+ * will not be migrated from the target node while the job is executed. The data
+ * of the extra caches' partitions with the same partition number also will not be migrated.
+ *
+ * @param cacheNames Names of the caches to to reserve the partition. The first cache uses for affinity co-location.
+ * @param affKey Affinity key.
+ * @param job Job which will be co-located on the node with given affinity key.
+ * @return a Future representing pending completion of the affinity run.
+ * @throws IgniteException If job failed.
+ */
+ public IgniteFuture<Void> affinityRunAsync(@NotNull Collection<String> cacheNames, Object affKey,
+ IgniteRunnable job) throws IgniteException;
+
+ /**
* Executes given job on the node where partition is located (the partition is primary on the node)
* </p>
* It's guaranteed that the data of all the partitions of all participating caches,
@@ -170,6 +201,21 @@ public interface IgniteCompute extends IgniteAsyncSupport {
throws IgniteException;
/**
+ * Executes given job asynchronously on the node where partition is located (the partition is primary on the node)
+ * The data of the partition will not be migrated from the target node
+ * while the job is executed. The data of the extra caches' partitions with the same partition number
+ * also will not be migrated.
+ *
+ * @param cacheNames Names of the caches to to reserve the partition. The first cache uses for affinity co-location.
+ * @param partId Partition number.
+ * @param job Job which will be co-located on the node with given affinity key.
+ * @return a Future representing pending completion of the affinity run.
+ * @throws IgniteException If job failed.
+ */
+ public IgniteFuture<Void> affinityRunAsync(@NotNull Collection<String> cacheNames, int partId,
+ IgniteRunnable job) throws IgniteException;
+
+ /**
* Executes given job on the node where data for provided affinity key is located
* (a.k.a. affinity co-location).
* </p>
@@ -186,6 +232,20 @@ public interface IgniteCompute extends IgniteAsyncSupport {
public <R> R affinityCall(@Nullable String cacheName, Object affKey, IgniteCallable<R> job) throws IgniteException;
/**
+ * Executes given job asynchronously on the node where data for provided affinity key is located
+ * (a.k.a. affinity co-location). The data of the partition where affKey is stored
+ * will not be migrated from the target node while the job is executed.
+ *
+ * @param cacheName Name of the cache to use for affinity co-location.
+ * @param affKey Affinity key.
+ * @param job Job which will be co-located on the node with given affinity key.
+ * @return a Future representing pending completion of the affinity call.
+ * @throws IgniteException If job failed.
+ */
+ public <R> IgniteFuture<R> affinityCallAsync(@Nullable String cacheName, Object affKey, IgniteCallable<R> job)
+ throws IgniteException;
+
+ /**
* Executes given job on the node where data for provided affinity key is located
* (a.k.a. affinity co-location).
* </p>
@@ -203,6 +263,21 @@ public interface IgniteCompute extends IgniteAsyncSupport {
throws IgniteException;
/**
+ * Executes given job asynchronously on the node where data for provided affinity key is located
+ * (a.k.a. affinity co-location). The data of the partition where affKey is stored
+ * will not be migrated from the target node while the job is executed. The data
+ * of the extra caches' partitions with the same partition number also will not be migrated.
+ *
+ * @param cacheNames Names of the caches to to reserve the partition. The first cache uses for affinity co-location.
+ * @param affKey Affinity key.
+ * @param job Job which will be co-located on the node with given affinity key.
+ * @return a Future representing pending completion of the affinity call.
+ * @throws IgniteException If job failed.
+ */
+ public <R> IgniteFuture<R> affinityCallAsync(@NotNull Collection<String> cacheNames, Object affKey,
+ IgniteCallable<R> job) throws IgniteException;
+
+ /**
* Executes given job on the node where partition is located (the partition is primary on the node)
* </p>
* It's guaranteed that the data of all the partitions of all participating caches,
@@ -219,6 +294,21 @@ public interface IgniteCompute extends IgniteAsyncSupport {
throws IgniteException;
/**
+ * Executes given job asynchronously on the node where partition is located (the partition is primary on the node)
+ * The data of the partition will not be migrated from the target node
+ * while the job is executed. The data of the extra caches' partitions with the same partition number
+ * also will not be migrated.
+ *
+ * @param cacheNames Names of the caches to to reserve the partition. The first cache uses for affinity co-location.
+ * @param partId Partition to reserve.
+ * @param job Job which will be co-located on the node with given affinity key.
+ * @return a Future representing pending completion of the affinity call.
+ * @throws IgniteException If job failed.
+ */
+ public <R> IgniteFuture<R> affinityCallAsync(@NotNull Collection<String> cacheNames, int partId,
+ IgniteCallable<R> job) throws IgniteException;
+
+ /**
* Executes given task on within the cluster group. For step-by-step explanation of task execution process
* refer to {@link ComputeTask} documentation.
*
@@ -233,6 +323,20 @@ public interface IgniteCompute extends IgniteAsyncSupport {
public <T, R> R execute(Class<? extends ComputeTask<T, R>> taskCls, @Nullable T arg) throws IgniteException;
/**
+ * Executes given task asynchronously on within the cluster group. For step-by-step explanation of task execution
+ * process refer to {@link ComputeTask} documentation.
+ *
+ * @param taskCls Class of the task to execute. If class has {@link ComputeTaskName} annotation,
+ * then task is deployed under a name specified within annotation. Otherwise, full
+ * class name is used as task name.
+ * @param arg Optional argument of task execution, can be {@code null}.
+ * @return a Future representing pending completion of the task.
+ * @throws IgniteException If task failed.
+ */
+ public <T, R> ComputeTaskFuture<R> executeAsync(Class<? extends ComputeTask<T, R>> taskCls, @Nullable T arg)
+ throws IgniteException;
+
+ /**
* Executes given task within the cluster group. For step-by-step explanation of task execution process
* refer to {@link ComputeTask} documentation.
*
@@ -247,6 +351,19 @@ public interface IgniteCompute extends IgniteAsyncSupport {
public <T, R> R execute(ComputeTask<T, R> task, @Nullable T arg) throws IgniteException;
/**
+ * Executes given task asynchronously within the cluster group. For step-by-step explanation of task execution
+ * process refer to {@link ComputeTask} documentation.
+ *
+ * @param task Instance of task to execute. If task class has {@link ComputeTaskName} annotation,
+ * then task is deployed under a name specified within annotation. Otherwise, full
+ * class name is used as task name.
+ * @param arg Optional argument of task execution, can be {@code null}.
+ * @return a Future representing pending completion of the task.
+ * @throws IgniteException If task failed.
+ */
+ public <T, R> ComputeTaskFuture<R> executeAsync(ComputeTask<T, R> task, @Nullable T arg) throws IgniteException;
+
+ /**
* Executes given task within the cluster group. For step-by-step explanation of task execution process
* refer to {@link ComputeTask} documentation.
* <p>
@@ -263,6 +380,21 @@ public interface IgniteCompute extends IgniteAsyncSupport {
public <T, R> R execute(String taskName, @Nullable T arg) throws IgniteException;
/**
+ * Executes given task asynchronously within the cluster group. For step-by-step explanation of task execution
+ * process refer to {@link ComputeTask} documentation.
+ * <p>
+ * If task for given name has not been deployed yet, then {@code taskName} will be
+ * used as task class name to auto-deploy the task (see {@link #localDeployTask(Class, ClassLoader)} method).
+ *
+ * @param taskName Name of the task to execute.
+ * @param arg Optional argument of task execution, can be {@code null}.
+ * @return a Future representing pending completion of the task.
+ * @throws IgniteException If task failed.
+ * @see ComputeTask for information about task execution.
+ */
+ public <T, R> ComputeTaskFuture<R> executeAsync(String taskName, @Nullable T arg) throws IgniteException;
+
+ /**
* Broadcasts given job to all nodes in the cluster group.
*
* @param job Job to broadcast to all cluster group nodes.
@@ -272,6 +404,15 @@ public interface IgniteCompute extends IgniteAsyncSupport {
public void broadcast(IgniteRunnable job) throws IgniteException;
/**
+ * Broadcasts given job asynchronously to all nodes in the cluster group.
+ *
+ * @param job Job to broadcast to all cluster group nodes.
+ * @return a Future representing pending completion of the broadcast execution of the job.
+ * @throws IgniteException If job failed.
+ */
+ public IgniteFuture<Void> broadcastAsync(IgniteRunnable job) throws IgniteException;
+
+ /**
* Broadcasts given job to all nodes in cluster group. Every participating node will return a
* job result. Collection of all returned job results is returned from the result future.
*
@@ -283,6 +424,16 @@ public interface IgniteCompute extends IgniteAsyncSupport {
public <R> Collection<R> broadcast(IgniteCallable<R> job) throws IgniteException;
/**
+ * Broadcasts given job asynchronously to all nodes in cluster group. Every participating node will return a
+ * job result. Collection of all returned job results is returned from the result future.
+ *
+ * @param job Job to broadcast to all cluster group nodes.
+ * @return a Future representing pending completion of the broadcast execution of the job.
+ * @throws IgniteException If execution failed.
+ */
+ public <R> IgniteFuture<Collection<R>> broadcastAsync(IgniteCallable<R> job) throws IgniteException;
+
+ /**
* Broadcasts given closure job with passed in argument to all nodes in the cluster group.
* Every participating node will return a job result. Collection of all returned job results
* is returned from the result future.
@@ -296,6 +447,19 @@ public interface IgniteCompute extends IgniteAsyncSupport {
public <R, T> Collection<R> broadcast(IgniteClosure<T, R> job, @Nullable T arg) throws IgniteException;
/**
+ * Broadcasts given closure job asynchronously with passed in argument to all nodes in the cluster group.
+ * Every participating node will return a job result. Collection of all returned job results
+ * is returned from the result future.
+ *
+ * @param job Job to broadcast to all cluster group nodes.
+ * @param arg Job closure argument.
+ * @return a Future representing pending completion of the broadcast execution of the job.
+ * @throws IgniteException If execution failed.
+ */
+ public <R, T> IgniteFuture<Collection<R>> broadcastAsync(IgniteClosure<T, R> job, @Nullable T arg)
+ throws IgniteException;
+
+ /**
* Executes provided job on a node within the underlying cluster group.
*
* @param job Job closure to execute.
@@ -305,6 +469,15 @@ public interface IgniteCompute extends IgniteAsyncSupport {
public void run(IgniteRunnable job) throws IgniteException;
/**
+ * Executes provided job asynchronously on a node within the underlying cluster group.
+ *
+ * @param job Job closure to execute.
+ * @return a Future representing pending completion of the job.
+ * @throws IgniteException If execution failed.
+ */
+ public IgniteFuture<Void> runAsync(IgniteRunnable job) throws IgniteException;
+
+ /**
* Executes collection of jobs on grid nodes within the underlying cluster group.
*
* @param jobs Collection of jobs to execute.
@@ -314,6 +487,16 @@ public interface IgniteCompute extends IgniteAsyncSupport {
public void run(Collection<? extends IgniteRunnable> jobs) throws IgniteException;
/**
+ * Executes collection of jobs asynchronously on grid nodes within the underlying cluster group.
+ * Executes asynchronously. Returns control immediately.
+ *
+ * @param jobs Collection of jobs to execute.
+ * @return a Future representing pending completion of the job.
+ * @throws IgniteException If execution failed.
+ */
+ public IgniteFuture<Void> runAsync(Collection<? extends IgniteRunnable> jobs) throws IgniteException;
+
+ /**
* Executes provided job on a node within the underlying cluster group. The result of the
* job execution is returned from the result closure.
*
@@ -325,6 +508,16 @@ public interface IgniteCompute extends IgniteAsyncSupport {
public <R> R call(IgniteCallable<R> job) throws IgniteException;
/**
+ * Executes provided job asynchronously on a node within the underlying cluster group. The result of the
+ * job execution is returned from the result closure.
+ *
+ * @param job Job to execute.
+ * @return a Future representing pending completion of the job.
+ * @throws IgniteException If execution failed.
+ */
+ public <R> IgniteFuture<R> callAsync(IgniteCallable<R> job) throws IgniteException;
+
+ /**
* Executes collection of jobs on nodes within the underlying cluster group.
* Collection of all returned job results is returned from the result future.
*
@@ -336,12 +529,23 @@ public interface IgniteCompute extends IgniteAsyncSupport {
public <R> Collection<R> call(Collection<? extends IgniteCallable<R>> jobs) throws IgniteException;
/**
+ * Executes collection of jobs asynchronously on nodes within the underlying cluster group.
+ * Collection of all returned job results is returned from the result future.
+ *
+ * @param jobs Collection of jobs to execute.
+ * @return a Future representing pending completion of the job.
+ * @throws IgniteException If execution failed.
+ */
+ public <R> IgniteFuture<Collection<R>> callAsync(Collection<? extends IgniteCallable<R>> jobs)
+ throws IgniteException;
+
+ /**
* Executes collection of jobs on nodes within the underlying cluster group. The returned
* job results will be reduced into an individual result by provided reducer.
*
* @param jobs Collection of jobs to execute.
* @param rdc Reducer to reduce all job results into one individual return value.
- * @return Future with reduced job result for this execution.
+ * @return Reduced job result for this execution.
* @throws IgniteException If execution failed.
*/
@IgniteAsyncSupported
@@ -349,6 +553,18 @@ public interface IgniteCompute extends IgniteAsyncSupport {
throws IgniteException;
/**
+ * Executes collection of jobs asynchronously on nodes within the underlying cluster group. The returned
+ * job results will be reduced into an individual result by provided reducer.
+ *
+ * @param jobs Collection of jobs to execute.
+ * @param rdc Reducer to reduce all job results into one individual return value.
+ * @return a Future with reduced job result for this execution.
+ * @throws IgniteException If execution failed.
+ */
+ public <R1, R2> IgniteFuture<R2> callAsync(Collection<? extends IgniteCallable<R1>> jobs,
+ IgniteReducer<R1, R2> rdc) throws IgniteException;
+
+ /**
* Executes provided closure job on a node within the underlying cluster group. This method is different
* from {@code run(...)} and {@code call(...)} methods in a way that it receives job argument
* which is then passed into the closure at execution time.
@@ -362,6 +578,18 @@ public interface IgniteCompute extends IgniteAsyncSupport {
public <R, T> R apply(IgniteClosure<T, R> job, @Nullable T arg) throws IgniteException;
/**
+ * Executes provided closure job asynchronously on a node within the underlying cluster group.
+ * This method is different from {@code run(...)} and {@code call(...)} methods in a way that
+ * it receives job argument which is then passed into the closure at execution time.
+ *
+ * @param job Job to run.
+ * @param arg Job argument.
+ * @return a Future representing pending completion of the job.
+ * @throws IgniteException If execution failed.
+ */
+ public <R, T> IgniteFuture<R> applyAsync(IgniteClosure<T, R> job, @Nullable T arg) throws IgniteException;
+
+ /**
* Executes provided closure job on nodes within the underlying cluster group. A new job is executed for
* every argument in the passed in collection. The number of actual job executions will be
* equal to size of the job arguments collection.
@@ -375,6 +603,19 @@ public interface IgniteCompute extends IgniteAsyncSupport {
public <T, R> Collection<R> apply(IgniteClosure<T, R> job, Collection<? extends T> args) throws IgniteException;
/**
+ * Executes provided closure job asynchronously on nodes within the underlying cluster group. A new job is executed
+ * for every argument in the passed in collection. The number of actual job executions will be
+ * equal to size of the job arguments collection.
+ *
+ * @param job Job to run.
+ * @param args Job arguments.
+ * @return a Future representing pending completion of the job.
+ * @throws IgniteException If execution failed.
+ */
+ public <T, R> IgniteFuture<Collection<R>> applyAsync(IgniteClosure<T, R> job, Collection<? extends T> args)
+ throws IgniteException;
+
+ /**
* Executes provided closure job on nodes within the underlying cluster group. A new job is executed for
* every argument in the passed in collection. The number of actual job executions will be
* equal to size of the job arguments collection. The returned job results will be reduced
@@ -383,7 +624,7 @@ public interface IgniteCompute extends IgniteAsyncSupport {
* @param job Job to run.
* @param args Job arguments.
* @param rdc Reducer to reduce all job results into one individual return value.
- * @return Future with reduced job result for this execution.
+ * @return Reduced job result for this execution.
* @throws IgniteException If execution failed.
*/
@IgniteAsyncSupported
@@ -391,6 +632,21 @@ public interface IgniteCompute extends IgniteAsyncSupport {
IgniteReducer<R1, R2> rdc) throws IgniteException;
/**
+ * Executes provided closure job asynchronously on nodes within the underlying cluster group. A new job is executed
+ * for every argument in the passed in collection. The number of actual job executions will be
+ * equal to size of the job arguments collection. The returned job results will be reduced
+ * into an individual result by provided reducer.
+ *
+ * @param job Job to run.
+ * @param args Job arguments.
+ * @param rdc Reducer to reduce all job results into one individual return value.
+ * @return a Future with reduced job result for this execution.
+ * @throws IgniteException If execution failed.
+ */
+ public <R1, R2, T> IgniteFuture<R2> applyAsync(IgniteClosure<T, R1> job, Collection<? extends T> args,
+ IgniteReducer<R1, R2> rdc) throws IgniteException;
+
+ /**
* Gets tasks future for active tasks started on local node.
*
* @return Map of active tasks keyed by their task task session ID.
@@ -489,8 +745,10 @@ public interface IgniteCompute extends IgniteAsyncSupport {
public void undeployTask(String taskName) throws IgniteException;
/** {@inheritDoc} */
+ @Deprecated
@Override public <R> ComputeTaskFuture<R> future();
/** {@inheritDoc} */
+ @Deprecated
@Override public IgniteCompute withAsync();
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/main/java/org/apache/ignite/IgniteEvents.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteEvents.java b/modules/core/src/main/java/org/apache/ignite/IgniteEvents.java
index c0e4d3b..c081f2f 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteEvents.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteEvents.java
@@ -25,6 +25,7 @@ import org.apache.ignite.events.Event;
import org.apache.ignite.lang.IgniteAsyncSupport;
import org.apache.ignite.lang.IgniteAsyncSupported;
import org.apache.ignite.lang.IgniteBiPredicate;
+import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.lang.IgnitePredicate;
import org.jetbrains.annotations.Nullable;
@@ -90,13 +91,27 @@ public interface IgniteEvents extends IgniteAsyncSupport {
throws IgniteException;
/**
+ * Asynchronously queries nodes in this cluster group for events using passed in predicate filter for event
+ * selection.
+ *
+ * @param p Predicate filter used to query events on remote nodes.
+ * @param timeout Maximum time to wait for result, {@code 0} to wait forever.
+ * @param types Event types to be queried.
+ * @return a Future representing pending completion of the query. The completed future contains
+ * collection of grid events returned from specified nodes.
+ * @throws IgniteException If query failed.
+ */
+ public <T extends Event> IgniteFuture<List<T>> remoteQueryAsync(IgnitePredicate<T> p, long timeout,
+ @Nullable int... types) throws IgniteException;
+
+ /**
* Adds event listener for specified events to all nodes in the cluster group (possibly including
* local node if it belongs to the cluster group as well). This means that all events occurring on
* any node within this cluster group that pass remote filter will be sent to local node for
* local listener notifications.
* <p>
* The listener can be unsubscribed automatically if local node stops, if {@code locLsnr} callback
- * returns {@code false} or if {@link #stopRemoteListen(UUID)} is called.
+ * returns {@code false} or if {@link #stopRemoteListen(UUID)} or {@link #stopRemoteListenAsync(UUID)} are called.
*
* @param locLsnr Listener callback that is called on local node. If {@code null}, this events will be handled
* on remote nodes by passed in {@code rmtFilter}.
@@ -108,7 +123,8 @@ public interface IgniteEvents extends IgniteAsyncSupport {
* @param types Types of events to listen for. If not provided, all events that pass the
* provided remote filter will be sent to local node.
* @param <T> Type of the event.
- * @return {@code Operation ID} that can be passed to {@link #stopRemoteListen(UUID)} method to stop listening.
+ * @return {@code Operation ID} that can be passed to {@link #stopRemoteListen(UUID)} or
+ * {@link #stopRemoteListenAsync(UUID)} methods to stop listening.
* @throws IgniteException If failed to add listener.
*/
@IgniteAsyncSupported
@@ -118,6 +134,35 @@ public interface IgniteEvents extends IgniteAsyncSupport {
throws IgniteException;
/**
+ * Asynchronously adds event listener for specified events to all nodes in the cluster group (possibly including
+ * local node if it belongs to the cluster group as well). This means that all events occurring on
+ * any node within this cluster group that pass remote filter will be sent to local node for
+ * local listener notifications.
+ * <p>
+ * The listener can be unsubscribed automatically if local node stops, if {@code locLsnr} callback
+ * returns {@code false} or if {@link #stopRemoteListen(UUID)} or {@link #stopRemoteListenAsync(UUID)} are called.
+ *
+ * @param <T> Type of the event.
+ * @param locLsnr Listener callback that is called on local node. If {@code null}, this events will be handled
+ * on remote nodes by passed in {@code rmtFilter}.
+ * @param rmtFilter Filter callback that is called on remote node. Only events that pass the remote filter
+ * will be sent to local node. If {@code null}, all events of specified types will
+ * be sent to local node. This remote filter can be used to pre-handle events remotely,
+ * before they are passed in to local callback. It will be auto-unsubsribed on the node
+ * where event occurred in case if it returns {@code false}.
+ * @param types Types of events to listen for. If not provided, all events that pass the
+ * provided remote filter will be sent to local node.
+ * @return a Future representing pending completion of the operation. The completed future contains
+ * {@code Operation ID} that can be passed to {@link #stopRemoteListen(UUID)} or
+ * {@link #stopRemoteListenAsync(UUID)} methods to stop listening.
+ * @throws IgniteException If failed to add listener.
+ */
+ public <T extends Event> IgniteFuture<UUID> remoteListenAsync(@Nullable IgniteBiPredicate<UUID, T> locLsnr,
+ @Nullable IgnitePredicate<T> rmtFilter,
+ @Nullable int... types)
+ throws IgniteException;
+
+ /**
* Adds event listener for specified events to all nodes in the cluster group (possibly including
* local node if it belongs to the cluster group as well). This means that all events occurring on
* any node within this cluster group that pass remote filter will be sent to local node for
@@ -148,9 +193,11 @@ public interface IgniteEvents extends IgniteAsyncSupport {
* @param types Types of events to listen for. If not provided, all events that pass the
* provided remote filter will be sent to local node.
* @param <T> Type of the event.
- * @return {@code Operation ID} that can be passed to {@link #stopRemoteListen(UUID)} method to stop listening.
- * @see #stopRemoteListen(UUID)
+ * @return {@code Operation ID} that can be passed to {@link #stopRemoteListen(UUID)} or
+ * {@link #stopRemoteListen(UUID)} methods to stop listening.
* @throws IgniteException If failed to add listener.
+ * @see #stopRemoteListen(UUID)
+ * @see #stopRemoteListenAsync(UUID)
*/
@IgniteAsyncSupported
public <T extends Event> UUID remoteListen(int bufSize,
@@ -162,6 +209,50 @@ public interface IgniteEvents extends IgniteAsyncSupport {
throws IgniteException;
/**
+ * Asynchronously adds event listener for specified events to all nodes in the cluster group (possibly including
+ * local node if it belongs to the cluster group as well). This means that all events occurring on
+ * any node within this cluster group that pass remote filter will be sent to local node for
+ * local listener notification.
+ *
+ * @param <T> Type of the event.
+ * @param bufSize Remote events buffer size. Events from remote nodes won't be sent until buffer
+ * is full or time interval is exceeded.
+ * @param interval Maximum time interval after which events from remote node will be sent. Events
+ * from remote nodes won't be sent until buffer is full or time interval is exceeded.
+ * @param autoUnsubscribe Flag indicating that event listeners on remote nodes should be
+ * automatically unregistered if master node (node that initiated event listening) leaves
+ * topology. If this flag is {@code false}, listeners will be unregistered only when
+ * {@link #stopRemoteListen(UUID)} method is called, or the {@code 'callback (locLsnr)'}
+ * passed in returns {@code false}.
+ * @param locLsnr Callback that is called on local node. If this predicate returns {@code true},
+ * the implementation will continue listening to events. Otherwise, events
+ * listening will be stopped and listeners will be unregistered on all nodes
+ * in the cluster group. If {@code null}, this events will be handled on remote nodes by
+ * passed in {@code rmtFilter} until local node stops (if {@code 'autoUnsubscribe'} is {@code true})
+ * or until {@link #stopRemoteListen(UUID)} is called.
+ * @param rmtFilter Filter callback that is called on remote node. Only events that pass the remote filter
+ * will be sent to local node. If {@code null}, all events of specified types will
+ * be sent to local node. This remote filter can be used to pre-handle events remotely,
+ * before they are passed in to local callback. It will be auto-unsubsribed on the node
+ * where event occurred in case if it returns {@code false}.
+ * @param types Types of events to listen for. If not provided, all events that pass the
+ * provided remote filter will be sent to local node.
+ * @return a Future representing pending completion of the operation. The completed future contains
+ * {@code Operation ID} that can be passed to {@link #stopRemoteListen(UUID)}
+ * or {@link #stopRemoteListen(UUID)} methods to stop listening.
+ * @throws IgniteException If failed to add listener.
+ * @see #stopRemoteListen(UUID)
+ * @see #stopRemoteListenAsync(UUID)
+ */
+ public <T extends Event> IgniteFuture<UUID> remoteListenAsync(int bufSize,
+ long interval,
+ boolean autoUnsubscribe,
+ @Nullable IgniteBiPredicate<UUID, T> locLsnr,
+ @Nullable IgnitePredicate<T> rmtFilter,
+ @Nullable int... types)
+ throws IgniteException;
+
+ /**
* Stops listening to remote events. This will unregister all listeners identified with provided
* operation ID on all nodes defined by {@link #clusterGroup()}.
* <p>
@@ -169,13 +260,27 @@ public interface IgniteEvents extends IgniteAsyncSupport {
*
* @param opId Operation ID that was returned from
* {@link #remoteListen(IgniteBiPredicate, IgnitePredicate, int...)} method.
- * @see #remoteListen(IgniteBiPredicate, IgnitePredicate, int...)
* @throws IgniteException If failed to stop listeners.
+ * @see #remoteListen(IgniteBiPredicate, IgnitePredicate, int...)
+ * @see #remoteListenAsync(int, long, boolean, IgniteBiPredicate, IgnitePredicate, int...)
*/
@IgniteAsyncSupported
public void stopRemoteListen(UUID opId) throws IgniteException;
/**
+ * Asynchronously stops listening to remote events. This will unregister all listeners identified with provided
+ * operation ID on all nodes defined by {@link #clusterGroup()}.
+ *
+ * @param opId Operation ID that was returned from
+ * {@link #remoteListen(IgniteBiPredicate, IgnitePredicate, int...)} method.
+ * @return a Future representing pending completion of the operation.
+ * @throws IgniteException If failed to stop listeners.
+ * @see #remoteListen(IgniteBiPredicate, IgnitePredicate, int...)
+ * @see #remoteListenAsync(int, long, boolean, IgniteBiPredicate, IgnitePredicate, int...)
+ */
+ public IgniteFuture<Void> stopRemoteListenAsync(UUID opId) throws IgniteException;
+
+ /**
* Waits for the specified events.
* <p>
* Supports asynchronous execution (see {@link IgniteAsyncSupport}).
@@ -191,6 +296,18 @@ public interface IgniteEvents extends IgniteAsyncSupport {
throws IgniteException;
/**
+ * Create future to wait for the specified events.
+ *
+ * @param filter Optional filtering predicate. Only if predicates evaluates to {@code true} will the event
+ * end the wait.
+ * @param types Types of the events to wait for. If not provided, all events will be passed to the filter.
+ * @return a Future representing pending completion of the operation. The completed future contains grid event.
+ * @throws IgniteException If wait was interrupted.
+ */
+ public <T extends Event> IgniteFuture<T> waitForLocalAsync(@Nullable IgnitePredicate<T> filter,
+ @Nullable int... types) throws IgniteException;
+
+ /**
* Queries local node for events using passed-in predicate filter for event selection.
*
* @param p Predicate to filter events. All predicates must be satisfied for the
@@ -269,5 +386,6 @@ public interface IgniteEvents extends IgniteAsyncSupport {
public boolean isEnabled(int type);
/** {@inheritDoc} */
+ @Deprecated
@Override public IgniteEvents withAsync();
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/main/java/org/apache/ignite/IgniteFileSystem.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteFileSystem.java b/modules/core/src/main/java/org/apache/ignite/IgniteFileSystem.java
index 8fb4fcd..78c86dc 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteFileSystem.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteFileSystem.java
@@ -32,6 +32,7 @@ import org.apache.ignite.igfs.mapreduce.IgfsRecordResolver;
import org.apache.ignite.igfs.mapreduce.IgfsTask;
import org.apache.ignite.lang.IgniteAsyncSupport;
import org.apache.ignite.lang.IgniteAsyncSupported;
+import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.lang.IgniteUuid;
import org.jetbrains.annotations.Nullable;
import org.apache.ignite.igfs.IgfsPathNotFoundException;
@@ -275,6 +276,15 @@ public interface IgniteFileSystem extends IgniteAsyncSupport {
public void format() throws IgniteException;
/**
+ * Asynchronously formats the file system removing all existing entries from it.
+ * <p>
+ *
+ * @return a Future representing pending completion of the format operation.
+ * @throws IgniteException In case format has failed.
+ */
+ public IgniteFuture<Void> formatAsync() throws IgniteException;
+
+ /**
* Executes IGFS task.
* <p>
* Supports asynchronous execution (see {@link IgniteAsyncSupport}).
@@ -291,6 +301,20 @@ public interface IgniteFileSystem extends IgniteAsyncSupport {
Collection<IgfsPath> paths, @Nullable T arg) throws IgniteException;
/**
+ * Executes IGFS task asynchronously.
+ *
+ * @param task Task to execute.
+ * @param rslvr Optional resolver to control split boundaries.
+ * @param paths Collection of paths to be processed within this task.
+ * @param arg Optional task argument.
+ * @return a Future representing pending completion of the task.
+ * @throws IgniteException If execution failed.
+ */
+ public <T, R> IgniteFuture<R> executeAsync(IgfsTask<T, R> task, @Nullable IgfsRecordResolver rslvr,
+ Collection<IgfsPath> paths, @Nullable T arg) throws IgniteException;
+
+
+ /**
* Executes IGFS task with overridden maximum range length (see
* {@link org.apache.ignite.configuration.FileSystemConfiguration#getMaximumTaskRangeLength()} for more information).
* <p>
@@ -313,6 +337,25 @@ public interface IgniteFileSystem extends IgniteAsyncSupport {
throws IgniteException;
/**
+ * Executes IGFS task asynchronously with overridden maximum range length (see
+ * {@link org.apache.ignite.configuration.FileSystemConfiguration#getMaximumTaskRangeLength()} for more information).
+ *
+ * @param task Task to execute.
+ * @param rslvr Optional resolver to control split boundaries.
+ * @param paths Collection of paths to be processed within this task.
+ * @param skipNonExistentFiles Whether to skip non existent files. If set to {@code true} non-existent files will
+ * be ignored. Otherwise an exception will be thrown.
+ * @param maxRangeLen Optional maximum range length. If {@code 0}, then by default all consecutive
+ * IGFS blocks will be included.
+ * @param arg Optional task argument.
+ * @return a Future representing pending completion of the task.
+ * @throws IgniteException If execution failed.
+ */
+ public <T, R> IgniteFuture<R> executeAsync(IgfsTask<T, R> task, @Nullable IgfsRecordResolver rslvr,
+ Collection<IgfsPath> paths, boolean skipNonExistentFiles, long maxRangeLen, @Nullable T arg)
+ throws IgniteException;
+
+ /**
* Executes IGFS task.
* <p>
* Supports asynchronous execution (see {@link IgniteAsyncSupport}).
@@ -329,6 +372,20 @@ public interface IgniteFileSystem extends IgniteAsyncSupport {
@Nullable IgfsRecordResolver rslvr, Collection<IgfsPath> paths, @Nullable T arg) throws IgniteException;
/**
+ * Executes IGFS task asynchronously.
+ *
+ * @param taskCls Task class to execute.
+ * @param rslvr Optional resolver to control split boundaries.
+ * @param paths Collection of paths to be processed within this task.
+ * @param arg Optional task argument.
+ * @return a Future representing pending completion of the task.
+ * @throws IgniteException If execution failed.
+ */
+ public <T, R> IgniteFuture<R> executeAsync(Class<? extends IgfsTask<T, R>> taskCls,
+ @Nullable IgfsRecordResolver rslvr, Collection<IgfsPath> paths, @Nullable T arg) throws IgniteException;
+
+
+ /**
* Executes IGFS task with overridden maximum range length (see
* {@link org.apache.ignite.configuration.FileSystemConfiguration#getMaximumTaskRangeLength()} for more information).
* <p>
@@ -350,6 +407,24 @@ public interface IgniteFileSystem extends IgniteAsyncSupport {
long maxRangeLen, @Nullable T arg) throws IgniteException;
/**
+ * Executes IGFS task asynchronously with overridden maximum range length (see
+ * {@link org.apache.ignite.configuration.FileSystemConfiguration#getMaximumTaskRangeLength()} for more information).
+ *
+ * @param taskCls Task class to execute.
+ * @param rslvr Optional resolver to control split boundaries.
+ * @param paths Collection of paths to be processed within this task.
+ * @param skipNonExistentFiles Whether to skip non existent files. If set to {@code true} non-existent files will
+ * be ignored. Otherwise an exception will be thrown.
+ * @param maxRangeLen Maximum range length.
+ * @param arg Optional task argument.
+ * @return a Future representing pending completion of the task.
+ * @throws IgniteException If execution failed.
+ */
+ public <T, R> IgniteFuture<R> executeAsync(Class<? extends IgfsTask<T, R>> taskCls,
+ @Nullable IgfsRecordResolver rslvr, Collection<IgfsPath> paths, boolean skipNonExistentFiles,
+ long maxRangeLen, @Nullable T arg) throws IgniteException;
+
+ /**
* Checks if the specified path exists in the file system.
*
* @param path Path to check for existence in the file system.
@@ -473,5 +548,6 @@ public interface IgniteFileSystem extends IgniteAsyncSupport {
public long usedSpaceSize() throws IgniteException;
/** {@inheritDoc} */
+ @Deprecated
@Override public IgniteFileSystem withAsync();
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/main/java/org/apache/ignite/IgniteMessaging.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteMessaging.java b/modules/core/src/main/java/org/apache/ignite/IgniteMessaging.java
index e64ded5..f8257d3 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteMessaging.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteMessaging.java
@@ -25,6 +25,7 @@ import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.lang.IgniteAsyncSupport;
import org.apache.ignite.lang.IgniteAsyncSupported;
import org.apache.ignite.lang.IgniteBiPredicate;
+import org.apache.ignite.lang.IgniteFuture;
import org.jetbrains.annotations.Nullable;
/**
@@ -159,6 +160,22 @@ public interface IgniteMessaging extends IgniteAsyncSupport {
public UUID remoteListen(@Nullable Object topic, IgniteBiPredicate<UUID, ?> p) throws IgniteException;
/**
+ * Asynchronously adds a message listener for a given topic to all nodes in the cluster group (possibly including
+ * this node if it belongs to the cluster group as well). This means that any node within this cluster
+ * group can send a message for a given topic and all nodes within the cluster group will receive
+ * listener notifications.
+ *
+ * @param topic Topic to subscribe to, {@code null} means default topic.
+ * @param p Predicate that is called on each node for each received message. If predicate returns {@code false},
+ * then it will be unsubscribed from any further notifications.
+ * @return a Future representing pending completion of the operation. The completed future contains
+ * {@code Operation ID} that can be passed to {@link #stopRemoteListen(UUID)} method to stop listening.
+ * @throws IgniteException If failed to add listener.
+ */
+ public IgniteFuture<UUID> remoteListenAsync(@Nullable Object topic, IgniteBiPredicate<UUID, ?> p)
+ throws IgniteException;
+
+ /**
* Unregisters all listeners identified with provided operation ID on all nodes in the cluster group.
* <p>
* Supports asynchronous execution (see {@link IgniteAsyncSupport}).
@@ -169,6 +186,16 @@ public interface IgniteMessaging extends IgniteAsyncSupport {
@IgniteAsyncSupported
public void stopRemoteListen(UUID opId) throws IgniteException;
+ /**
+ * Asynchronously unregisters all listeners identified with provided operation ID on all nodes in the cluster group.
+ *
+ * @param opId Listen ID that was returned from {@link #remoteListen(Object, IgniteBiPredicate)} method.
+ * @return a Future representing pending completion of the operation.
+ * @throws IgniteException If failed to unregister listeners.
+ */
+ public IgniteFuture<Void> stopRemoteListenAsync(UUID opId) throws IgniteException;
+
/** {@inheritDoc} */
+ @Deprecated
@Override IgniteMessaging withAsync();
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/main/java/org/apache/ignite/IgniteServices.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteServices.java b/modules/core/src/main/java/org/apache/ignite/IgniteServices.java
index 8365ec7..1c01598 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteServices.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteServices.java
@@ -22,6 +22,7 @@ import org.apache.ignite.cluster.ClusterGroup;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.lang.IgniteAsyncSupport;
import org.apache.ignite.lang.IgniteAsyncSupported;
+import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.resources.IgniteInstanceResource;
import org.apache.ignite.services.Service;
import org.apache.ignite.services.ServiceConfiguration;
@@ -150,7 +151,8 @@ public interface IgniteServices extends IgniteAsyncSupport {
* when a singleton service instance will be active on more than one node (e.g. crash detection delay).
* <p>
* This method is analogous to calling
- * {@link #deployMultiple(String, org.apache.ignite.services.Service, int, int) deployMultiple(name, svc, 1, 1)} method.
+ * {@link #deployMultiple(String, org.apache.ignite.services.Service, int, int) deployMultiple(name, svc, 1, 1)}
+ * method.
*
* @param name Service name.
* @param svc Service instance.
@@ -160,13 +162,35 @@ public interface IgniteServices extends IgniteAsyncSupport {
public void deployClusterSingleton(String name, Service svc) throws IgniteException;
/**
+ * Asynchronously deploys a cluster-wide singleton service. Ignite will guarantee that there is always
+ * one instance of the service in the cluster. In case if grid node on which the service
+ * was deployed crashes or stops, Ignite will automatically redeploy it on another node.
+ * However, if the node on which the service is deployed remains in topology, then the
+ * service will always be deployed on that node only, regardless of topology changes.
+ * <p>
+ * Note that in case of topology changes, due to network delays, there may be a temporary situation
+ * when a singleton service instance will be active on more than one node (e.g. crash detection delay).
+ * <p>
+ * This method is analogous to calling
+ * {@link #deployMultipleAsync(String, org.apache.ignite.services.Service, int, int)
+ * deployMultipleAsync(name, svc, 1, 1)} method.
+ *
+ * @param name Service name.
+ * @param svc Service instance.
+ * @return a Future representing pending completion of the operation.
+ * @throws IgniteException If failed to deploy service.
+ */
+ public IgniteFuture<Void> deployClusterSingletonAsync(String name, Service svc) throws IgniteException;
+
+ /**
* Deploys a per-node singleton service. Ignite will guarantee that there is always
* one instance of the service running on each node. Whenever new nodes are started
* within the underlying cluster group, Ignite will automatically deploy one instance of
* the service on every new node.
* <p>
* This method is analogous to calling
- * {@link #deployMultiple(String, org.apache.ignite.services.Service, int, int) deployMultiple(name, svc, 0, 1)} method.
+ * {@link #deployMultiple(String, org.apache.ignite.services.Service, int, int) deployMultiple(name, svc, 0, 1)}
+ * method.
*
* @param name Service name.
* @param svc Service instance.
@@ -176,6 +200,23 @@ public interface IgniteServices extends IgniteAsyncSupport {
public void deployNodeSingleton(String name, Service svc) throws IgniteException;
/**
+ * Asynchronously deploys a per-node singleton service. Ignite will guarantee that there is always
+ * one instance of the service running on each node. Whenever new nodes are started
+ * within the underlying cluster group, Ignite will automatically deploy one instance of
+ * the service on every new node.
+ * <p>
+ * This method is analogous to calling
+ * {@link #deployMultipleAsync(String, org.apache.ignite.services.Service, int, int)
+ * deployMultipleAsync(name, svc, 0, 1)} method.
+ *
+ * @param name Service name.
+ * @param svc Service instance.
+ * @return a Future representing pending completion of the operation.
+ * @throws IgniteException If failed to deploy service.
+ */
+ public IgniteFuture<Void> deployNodeSingletonAsync(String name, Service svc) throws IgniteException;
+
+ /**
* Deploys one instance of this service on the primary node for a given affinity key.
* Whenever topology changes and primary node assignment changes, Ignite will always
* make sure that the service is undeployed on the previous primary node and deployed
@@ -184,8 +225,8 @@ public interface IgniteServices extends IgniteAsyncSupport {
* Note that in case of topology changes, due to network delays, there may be a temporary situation
* when a service instance will be active on more than one node (e.g. crash detection delay).
* <p>
- * This method is analogous to the invocation of {@link #deploy(org.apache.ignite.services.ServiceConfiguration)} method
- * as follows:
+ * This method is analogous to the invocation of {@link #deploy(org.apache.ignite.services.ServiceConfiguration)}
+ * method as follows:
* <pre name="code" class="java">
* ServiceConfiguration cfg = new ServiceConfiguration();
*
@@ -211,6 +252,41 @@ public interface IgniteServices extends IgniteAsyncSupport {
throws IgniteException;
/**
+ * Asynchronously deploys one instance of this service on the primary node for a given affinity key.
+ * Whenever topology changes and primary node assignment changes, Ignite will always
+ * make sure that the service is undeployed on the previous primary node and deployed
+ * on the new primary node.
+ * <p>
+ * Note that in case of topology changes, due to network delays, there may be a temporary situation
+ * when a service instance will be active on more than one node (e.g. crash detection delay).
+ * <p>
+ * This method is analogous to the invocation of
+ * {@link #deployAsync(org.apache.ignite.services.ServiceConfiguration)} method as follows:
+ * <pre name="code" class="java">
+ * ServiceConfiguration cfg = new ServiceConfiguration();
+ *
+ * cfg.setName(name);
+ * cfg.setService(svc);
+ * cfg.setCacheName(cacheName);
+ * cfg.setAffinityKey(affKey);
+ * cfg.setTotalCount(1);
+ * cfg.setMaxPerNodeCount(1);
+ *
+ * ignite.services().deployAsync(cfg);
+ * </pre>
+ *
+ * @param name Service name.
+ * @param svc Service instance.
+ * @param cacheName Name of the cache on which affinity for key should be calculated, {@code null} for
+ * default cache.
+ * @param affKey Affinity cache key.
+ * @return a Future representing pending completion of the operation.
+ * @throws IgniteException If failed to deploy service.
+ */
+ public IgniteFuture<Void> deployKeyAffinitySingletonAsync(String name, Service svc, @Nullable String cacheName,
+ Object affKey) throws IgniteException;
+
+ /**
* Deploys multiple instances of the service on the grid. Ignite will deploy a
* maximum amount of services equal to {@code 'totalCnt'} parameter making sure that
* there are no more than {@code 'maxPerNodeCnt'} service instances running
@@ -221,8 +297,8 @@ public interface IgniteServices extends IgniteAsyncSupport {
* Note that at least one of {@code 'totalCnt'} or {@code 'maxPerNodeCnt'} parameters must have
* value greater than {@code 0}.
* <p>
- * This method is analogous to the invocation of {@link #deploy(org.apache.ignite.services.ServiceConfiguration)} method
- * as follows:
+ * This method is analogous to the invocation of {@link #deploy(org.apache.ignite.services.ServiceConfiguration)}
+ * method as follows:
* <pre name="code" class="java">
* ServiceConfiguration cfg = new ServiceConfiguration();
*
@@ -244,20 +320,57 @@ public interface IgniteServices extends IgniteAsyncSupport {
public void deployMultiple(String name, Service svc, int totalCnt, int maxPerNodeCnt) throws IgniteException;
/**
+ * Asynchronously deploys multiple instances of the service on the grid. Ignite will deploy a
+ * maximum amount of services equal to {@code 'totalCnt'} parameter making sure that
+ * there are no more than {@code 'maxPerNodeCnt'} service instances running
+ * on each node. Whenever topology changes, Ignite will automatically rebalance
+ * the deployed services within cluster to make sure that each node will end up with
+ * about equal number of deployed instances whenever possible.
+ * <p>
+ * Note that at least one of {@code 'totalCnt'} or {@code 'maxPerNodeCnt'} parameters must have
+ * value greater than {@code 0}.
+ * <p>
+ * This method is analogous to the invocation of
+ * {@link #deployAsync(org.apache.ignite.services.ServiceConfiguration)} method as follows:
+ * <pre name="code" class="java">
+ * ServiceConfiguration cfg = new ServiceConfiguration();
+ *
+ * cfg.setName(name);
+ * cfg.setService(svc);
+ * cfg.setTotalCount(totalCnt);
+ * cfg.setMaxPerNodeCount(maxPerNodeCnt);
+ *
+ * ignite.services().deployAsync(cfg);
+ * </pre>
+ *
+ * @param name Service name.
+ * @param svc Service instance.
+ * @param totalCnt Maximum number of deployed services in the grid, {@code 0} for unlimited.
+ * @param maxPerNodeCnt Maximum number of deployed services on each node, {@code 0} for unlimited.
+ * @return a Future representing pending completion of the operation.
+ * @throws IgniteException If failed to deploy service.
+ */
+ public IgniteFuture<Void> deployMultipleAsync(String name, Service svc, int totalCnt, int maxPerNodeCnt)
+ throws IgniteException;
+
+ /**
* Deploys multiple instances of the service on the grid according to provided
* configuration. Ignite will deploy a maximum amount of services equal to
* {@link org.apache.ignite.services.ServiceConfiguration#getTotalCount() cfg.getTotalCount()} parameter
- * making sure that there are no more than {@link org.apache.ignite.services.ServiceConfiguration#getMaxPerNodeCount() cfg.getMaxPerNodeCount()}
+ * making sure that there are no more than
+ * {@link org.apache.ignite.services.ServiceConfiguration#getMaxPerNodeCount() cfg.getMaxPerNodeCount()}
* service instances running on each node. Whenever topology changes, Ignite will automatically rebalance
* the deployed services within cluster to make sure that each node will end up with
* about equal number of deployed instances whenever possible.
* <p>
- * If {@link org.apache.ignite.services.ServiceConfiguration#getAffinityKey() cfg.getAffinityKey()} is not {@code null}, then Ignite
- * will deploy the service on the primary node for given affinity key. The affinity will be calculated
- * on the cache with {@link org.apache.ignite.services.ServiceConfiguration#getCacheName() cfg.getCacheName()} name.
+ * If {@link org.apache.ignite.services.ServiceConfiguration#getAffinityKey() cfg.getAffinityKey()}
+ * is not {@code null}, then Ignite will deploy the service on the primary node for given affinity key.
+ * The affinity will be calculated on the cache with
+ * {@link org.apache.ignite.services.ServiceConfiguration#getCacheName() cfg.getCacheName()} name.
* <p>
- * If {@link org.apache.ignite.services.ServiceConfiguration#getNodeFilter() cfg.getNodeFilter()} is not {@code null}, then
- * Ignite will deploy service on all grid nodes for which the provided filter evaluates to {@code true}.
+ * If {@link org.apache.ignite.services.ServiceConfiguration#getNodeFilter() cfg.getNodeFilter()}
+ * is not {@code null}, then Ignite will deploy service on all grid nodes for which
+ * the provided filter evaluates to {@code true}.
* The node filter will be checked in addition to the underlying cluster group filter, or the
* whole grid, if the underlying cluster group includes all the cluster nodes.
* <p>
@@ -283,12 +396,56 @@ public interface IgniteServices extends IgniteAsyncSupport {
public void deploy(ServiceConfiguration cfg) throws IgniteException;
/**
+ * Asynchronously deploys multiple instances of the service on the grid according to provided
+ * configuration. Ignite will deploy a maximum amount of services equal to
+ * {@link org.apache.ignite.services.ServiceConfiguration#getTotalCount() cfg.getTotalCount()} parameter
+ * making sure that there are no more than
+ * {@link org.apache.ignite.services.ServiceConfiguration#getMaxPerNodeCount() cfg.getMaxPerNodeCount()}
+ * service instances running on each node. Whenever topology changes, Ignite will automatically rebalance
+ * the deployed services within cluster to make sure that each node will end up with
+ * about equal number of deployed instances whenever possible.
+ * <p>
+ * If {@link org.apache.ignite.services.ServiceConfiguration#getAffinityKey() cfg.getAffinityKey()}
+ * is not {@code null}, then Ignite
+ * will deploy the service on the primary node for given affinity key. The affinity will be calculated
+ * on the cache with {@link org.apache.ignite.services.ServiceConfiguration#getCacheName() cfg.getCacheName()} name.
+ * <p>
+ * If {@link org.apache.ignite.services.ServiceConfiguration#getNodeFilter() cfg.getNodeFilter()}
+ * is not {@code null}, then Ignite will deploy service on all grid nodes
+ * for which the provided filter evaluates to {@code true}.
+ * The node filter will be checked in addition to the underlying cluster group filter, or the
+ * whole grid, if the underlying cluster group includes all the cluster nodes.
+ * <p>
+ * Note that at least one of {@code 'totalCnt'} or {@code 'maxPerNodeCnt'} parameters must have
+ * value greater than {@code 0}.
+ * <p>
+ * Here is an example of creating service deployment configuration:
+ * <pre name="code" class="java">
+ * ServiceConfiguration cfg = new ServiceConfiguration();
+ *
+ * cfg.setName(name);
+ * cfg.setService(svc);
+ * cfg.setTotalCount(0); // Unlimited.
+ * cfg.setMaxPerNodeCount(2); // Deploy 2 instances of service on each node.
+ *
+ * ignite.services().deployAsync(cfg);
+ * </pre>
+ *
+ * @param cfg Service configuration.
+ * @return a Future representing pending completion of the operation.
+ * @throws IgniteException If failed to deploy service.
+ */
+ public IgniteFuture<Void> deployAsync(ServiceConfiguration cfg) throws IgniteException;
+
+ /**
* Cancels service deployment. If a service with specified name was deployed on the grid,
- * then {@link org.apache.ignite.services.Service#cancel(org.apache.ignite.services.ServiceContext)} method will be called on it.
+ * then {@link org.apache.ignite.services.Service#cancel(org.apache.ignite.services.ServiceContext)}
+ * method will be called on it.
* <p>
- * Note that Ignite cannot guarantee that the service exits from {@link org.apache.ignite.services.Service#execute(org.apache.ignite.services.ServiceContext)}
- * method whenever {@link org.apache.ignite.services.Service#cancel(org.apache.ignite.services.ServiceContext)} is called. It is up to the user to
- * make sure that the service code properly reacts to cancellations.
+ * Note that Ignite cannot guarantee that the service exits from
+ * {@link org.apache.ignite.services.Service#execute(org.apache.ignite.services.ServiceContext)}
+ * method whenever {@link org.apache.ignite.services.Service#cancel(org.apache.ignite.services.ServiceContext)}
+ * is called. It is up to the user to make sure that the service code properly reacts to cancellations.
* <p>
* Supports asynchronous execution (see {@link IgniteAsyncSupport}).
*
@@ -299,6 +456,23 @@ public interface IgniteServices extends IgniteAsyncSupport {
public void cancel(String name) throws IgniteException;
/**
+ * Asynchronously cancels service deployment. If a service with specified name was deployed on the grid,
+ * then {@link org.apache.ignite.services.Service#cancel(org.apache.ignite.services.ServiceContext)}
+ * method will be called on it.
+ * <p>
+ * Note that Ignite cannot guarantee that the service exits from
+ * {@link org.apache.ignite.services.Service#execute(org.apache.ignite.services.ServiceContext)}
+ * method whenever {@link org.apache.ignite.services.Service#cancel(org.apache.ignite.services.ServiceContext)}
+ * is called. It is up to the user to
+ * make sure that the service code properly reacts to cancellations.
+ *
+ * @param name Name of service to cancel.
+ * @return a Future representing pending completion of the operation.
+ * @throws IgniteException If failed to cancel service.
+ */
+ public IgniteFuture<Void> cancelAsync(String name) throws IgniteException;
+
+ /**
* Cancels all deployed services.
* <p>
* Note that depending on user logic, it may still take extra time for a service to
@@ -312,6 +486,17 @@ public interface IgniteServices extends IgniteAsyncSupport {
public void cancelAll() throws IgniteException;
/**
+ * Asynchronously cancels all deployed services.
+ * <p>
+ * Note that depending on user logic, it may still take extra time for a service to
+ * finish execution, even after it was cancelled.
+ *
+ * @return a Future representing pending completion of the operation.
+ * @throws IgniteException If failed to cancel services.
+ */
+ public IgniteFuture<Void> cancelAllAsync() throws IgniteException;
+
+ /**
* Gets metadata about all deployed services in the grid.
*
* @return Metadata about all deployed services in the grid.
@@ -364,8 +549,10 @@ public interface IgniteServices extends IgniteAsyncSupport {
* @return Either proxy over remote service or local service if it is deployed locally.
* @throws IgniteException If failed to create service proxy.
*/
- public <T> T serviceProxy(String name, Class<? super T> svcItf, boolean sticky, long timeout) throws IgniteException;
+ public <T> T serviceProxy(String name, Class<? super T> svcItf, boolean sticky, long timeout)
+ throws IgniteException;
/** {@inheritDoc} */
+ @Deprecated
@Override public IgniteServices withAsync();
}
[06/10] ignite git commit: IGNITE-4475: New async API: now all async
methods are defined explicitly,
IgniteAsyncSupport is deprecated. This closes #1648.
Posted by vo...@apache.org.
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
[08/10] ignite git commit: IGNITE-4475: New async API: now all async
methods are defined explicitly,
IgniteAsyncSupport is deprecated. This closes #1648.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/main/java/org/apache/ignite/internal/IgniteComputeImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteComputeImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteComputeImpl.java
index 58ce001..7499a5d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteComputeImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteComputeImpl.java
@@ -30,6 +30,7 @@ import java.util.concurrent.Callable;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteCompute;
import org.apache.ignite.IgniteDeploymentException;
+import org.apache.ignite.IgniteException;
import org.apache.ignite.cluster.ClusterGroup;
import org.apache.ignite.compute.ComputeTask;
import org.apache.ignite.compute.ComputeTaskFuture;
@@ -83,9 +84,18 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
* @param ctx Kernal context.
* @param prj Projection.
* @param subjId Subject ID.
+ */
+ public IgniteComputeImpl(GridKernalContext ctx, ClusterGroupAdapter prj, UUID subjId) {
+ this(ctx, prj, subjId, false);
+ }
+
+ /**
+ * @param ctx Kernal context.
+ * @param prj Projection.
+ * @param subjId Subject ID.
* @param async Async support flag.
*/
- public IgniteComputeImpl(GridKernalContext ctx, ClusterGroupAdapter prj, UUID subjId, boolean async) {
+ private IgniteComputeImpl(GridKernalContext ctx, ClusterGroupAdapter prj, UUID subjId, boolean async) {
super(async);
this.ctx = ctx;
@@ -105,6 +115,29 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
/** {@inheritDoc} */
@Override public void affinityRun(@Nullable String cacheName, Object affKey, IgniteRunnable job) {
+ try {
+ saveOrGet(affinityRunAsync0(cacheName, affKey, job));
+ }
+ catch (IgniteCheckedException e) {
+ throw U.convertException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteFuture<Void> affinityRunAsync(@Nullable String cacheName, Object affKey,
+ IgniteRunnable job) throws IgniteException {
+ return (IgniteFuture<Void>)createFuture(affinityRunAsync0(cacheName, affKey, job));
+ }
+
+ /**
+ * Affinity run implementation.
+ *
+ * @param cacheName Cache name.
+ * @param affKey Affinity key.
+ * @param job Job.
+ * @return Internal future.
+ */
+ private IgniteInternalFuture<?> affinityRunAsync0(@Nullable String cacheName, Object affKey, IgniteRunnable job) {
A.notNull(affKey, "affKey");
A.notNull(job, "job");
@@ -119,7 +152,7 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
throw new IgniteCheckedException("Failed map key to partition: [cache=" + cacheName + " key="
+ affKey + ']');
- saveOrGet(ctx.closure().affinityRun(Collections.singletonList(cacheName), partId, job, prj.nodes()));
+ return ctx.closure().affinityRun(Collections.singletonList(cacheName), partId, job, prj.nodes());
}
catch (IgniteCheckedException e) {
throw U.convertException(e);
@@ -131,6 +164,30 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
/** {@inheritDoc} */
@Override public void affinityRun(@NotNull Collection<String> cacheNames, Object affKey, IgniteRunnable job) {
+ try {
+ saveOrGet(affinityRunAsync0(cacheNames, affKey, job));
+ }
+ catch (IgniteCheckedException e) {
+ throw U.convertException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteFuture<Void> affinityRunAsync(@NotNull Collection<String> cacheNames, Object affKey,
+ IgniteRunnable job) throws IgniteException {
+ return (IgniteFuture<Void>)createFuture(affinityRunAsync0(cacheNames, affKey, job));
+ }
+
+ /**
+ * Affinity run implementation.
+ *
+ * @param cacheNames Cache names collection.
+ * @param affKey Affinity key.
+ * @param job Job.
+ * @return Internal future.
+ */
+ private IgniteInternalFuture<?> affinityRunAsync0(@NotNull Collection<String> cacheNames, Object affKey,
+ IgniteRunnable job) {
A.notNull(affKey, "affKey");
A.notNull(job, "job");
A.ensure(!cacheNames.isEmpty(), "cachesNames mustn't be empty");
@@ -148,7 +205,7 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
throw new IgniteCheckedException("Failed map key to partition: [cache=" + cacheName + " key="
+ affKey + ']');
- saveOrGet(ctx.closure().affinityRun(cacheNames, partId, job, prj.nodes()));
+ return ctx.closure().affinityRun(cacheNames, partId, job, prj.nodes());
}
catch (IgniteCheckedException e) {
throw U.convertException(e);
@@ -160,6 +217,30 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
/** {@inheritDoc} */
@Override public void affinityRun(@NotNull Collection<String> cacheNames, int partId, IgniteRunnable job) {
+ try {
+ saveOrGet(affinityRunAsync0(cacheNames, partId, job));
+ }
+ catch (IgniteCheckedException e) {
+ throw U.convertException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteFuture<Void> affinityRunAsync(@NotNull Collection<String> cacheNames, int partId,
+ IgniteRunnable job) throws IgniteException {
+ return (IgniteFuture<Void>)createFuture(affinityRunAsync0(cacheNames, partId, job));
+ }
+
+ /**
+ * Affinity run implementation.
+ *
+ * @param cacheNames Cache names collection.
+ * @param partId partition ID.
+ * @param job Job.
+ * @return Internal future.
+ */
+ private IgniteInternalFuture<?> affinityRunAsync0(@NotNull Collection<String> cacheNames, int partId,
+ IgniteRunnable job) {
A.ensure(partId >= 0, "partId = " + partId);
A.notNull(job, "job");
A.ensure(!cacheNames.isEmpty(), "cachesNames mustn't be empty");
@@ -167,7 +248,7 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
guard();
try {
- saveOrGet(ctx.closure().affinityRun(cacheNames, partId, job, prj.nodes()));
+ return ctx.closure().affinityRun(cacheNames, partId, job, prj.nodes());
}
catch (IgniteCheckedException e) {
throw U.convertException(e);
@@ -179,6 +260,30 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
/** {@inheritDoc} */
@Override public <R> R affinityCall(@Nullable String cacheName, Object affKey, IgniteCallable<R> job) {
+ try {
+ return saveOrGet(affinityCallAsync0(cacheName, affKey, job));
+ }
+ catch (IgniteCheckedException e) {
+ throw U.convertException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public <R> IgniteFuture<R> affinityCallAsync(@Nullable String cacheName, Object affKey,
+ IgniteCallable<R> job) throws IgniteException {
+ return createFuture(affinityCallAsync0(cacheName, affKey, job));
+ }
+
+ /**
+ * Affinity call implementation.
+
+ * @param cacheName Cache name.
+ * @param affKey Affinity key.
+ * @param job Job.
+ * @return Internal future.
+ */
+ private <R> IgniteInternalFuture<R> affinityCallAsync0(@Nullable String cacheName, Object affKey,
+ IgniteCallable<R> job) {
A.notNull(affKey, "affKey");
A.notNull(job, "job");
@@ -193,8 +298,7 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
throw new IgniteCheckedException("Failed map key to partition: [cache=" + cacheName + " key="
+ affKey + ']');
- return saveOrGet(ctx.closure().affinityCall(Collections.singletonList(cacheName), partId, job,
- prj.nodes()));
+ return ctx.closure().affinityCall(Collections.singletonList(cacheName), partId, job, prj.nodes());
}
catch (IgniteCheckedException e) {
throw U.convertException(e);
@@ -206,8 +310,30 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
/** {@inheritDoc} */
@Override public <R> R affinityCall(@NotNull Collection<String> cacheNames, Object affKey, IgniteCallable<R> job) {
+ try {
+ return saveOrGet(affinityCallAsync0(cacheNames, affKey, job));
+ }
+ catch (IgniteCheckedException e) {
+ throw U.convertException(e);
+ }
+ }
+ /** {@inheritDoc} */
+ @Override public <R> IgniteFuture<R> affinityCallAsync(@NotNull Collection<String> cacheNames, Object affKey,
+ IgniteCallable<R> job) throws IgniteException {
+ return createFuture(affinityCallAsync0(cacheNames, affKey, job));
+ }
+ /**
+ * Affinity call implementation.
+
+ * @param cacheNames Cache names collection.
+ * @param affKey Affinity key.
+ * @param job Job.
+ * @return Internal future.
+ */
+ private <R> IgniteInternalFuture<R> affinityCallAsync0(@NotNull Collection<String> cacheNames, Object affKey,
+ IgniteCallable<R> job) {
A.notNull(affKey, "affKey");
A.notNull(job, "job");
A.ensure(!cacheNames.isEmpty(), "cachesNames mustn't be empty");
@@ -225,7 +351,7 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
throw new IgniteCheckedException("Failed map key to partition: [cache=" + cacheName + " key="
+ affKey + ']');
- return saveOrGet(ctx.closure().affinityCall(cacheNames, partId, job, prj.nodes()));
+ return ctx.closure().affinityCall(cacheNames, partId, job, prj.nodes());
}
catch (IgniteCheckedException e) {
throw U.convertException(e);
@@ -237,6 +363,30 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
/** {@inheritDoc} */
@Override public <R> R affinityCall(@NotNull Collection<String> cacheNames, int partId, IgniteCallable<R> job) {
+ try {
+ return saveOrGet(affinityCallAsync0(cacheNames, partId, job));
+ }
+ catch (IgniteCheckedException e) {
+ throw U.convertException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public <R> IgniteFuture<R> affinityCallAsync(@NotNull Collection<String> cacheNames, int partId,
+ IgniteCallable<R> job) throws IgniteException {
+ return createFuture(affinityCallAsync0(cacheNames, partId, job));
+ }
+
+ /**
+ * Affinity call implementation.
+
+ * @param cacheNames Cache names collection.
+ * @param partId Partition ID.
+ * @param job Job.
+ * @return Internal future.
+ */
+ private <R> IgniteInternalFuture<R> affinityCallAsync0(@NotNull Collection<String> cacheNames, int partId,
+ IgniteCallable<R> job) {
A.ensure(partId >= 0, "partId = " + partId);
A.notNull(job, "job");
A.ensure(!cacheNames.isEmpty(), "cachesNames mustn't be empty");
@@ -244,7 +394,7 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
guard();
try {
- return saveOrGet(ctx.closure().affinityCall(cacheNames, partId, job, prj.nodes()));
+ return ctx.closure().affinityCall(cacheNames, partId, job, prj.nodes());
}
catch (IgniteCheckedException e) {
throw U.convertException(e);
@@ -257,6 +407,28 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override public <T, R> R execute(String taskName, @Nullable T arg) {
+ try {
+ return (R)saveOrGet(executeAsync0(taskName, arg));
+ }
+ catch (IgniteCheckedException e) {
+ throw U.convertException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public <T, R> ComputeTaskFuture<R> executeAsync(String taskName, @Nullable T arg) throws IgniteException {
+ return (ComputeTaskFuture<R>)createFuture(executeAsync0(taskName, arg));
+ }
+
+ /**
+ * Execute implementation.
+ *
+ * @param taskName Task name.
+ * @param arg Argument.
+ * @return Internal future.
+ */
+ @SuppressWarnings("unchecked")
+ private <T, R> IgniteInternalFuture<R> executeAsync0(String taskName, @Nullable T arg) {
A.notNull(taskName, "taskName");
guard();
@@ -265,10 +437,7 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
ctx.task().setThreadContextIfNotNull(TC_SUBGRID, prj.nodes());
ctx.task().setThreadContextIfNotNull(TC_SUBJ_ID, subjId);
- return (R)saveOrGet(ctx.task().execute(taskName, arg));
- }
- catch (IgniteCheckedException e) {
- throw U.convertException(e);
+ return ctx.task().execute(taskName, arg);
}
finally {
unguard();
@@ -277,6 +446,29 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
/** {@inheritDoc} */
@Override public <T, R> R execute(Class<? extends ComputeTask<T, R>> taskCls, @Nullable T arg) {
+ try {
+ return (R)saveOrGet(executeAsync0(taskCls, arg));
+ }
+ catch (IgniteCheckedException e) {
+ throw U.convertException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public <T, R> ComputeTaskFuture<R> executeAsync(Class<? extends ComputeTask<T, R>> taskCls,
+ @Nullable T arg) throws IgniteException {
+ return (ComputeTaskFuture<R>)createFuture(executeAsync0(taskCls, arg));
+ }
+
+ /**
+ * Execute implementation.
+ *
+ * @param taskCls Task class.
+ * @param arg Argument.
+ * @return Internal future.
+ */
+ @SuppressWarnings("unchecked")
+ private <T, R> IgniteInternalFuture<R> executeAsync0(Class<? extends ComputeTask<T, R>> taskCls, @Nullable T arg) {
A.notNull(taskCls, "taskCls");
guard();
@@ -285,10 +477,7 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
ctx.task().setThreadContextIfNotNull(TC_SUBGRID, prj.nodes());
ctx.task().setThreadContextIfNotNull(TC_SUBJ_ID, subjId);
- return saveOrGet(ctx.task().execute(taskCls, arg));
- }
- catch (IgniteCheckedException e) {
- throw U.convertException(e);
+ return ctx.task().execute(taskCls, arg);
}
finally {
unguard();
@@ -297,30 +486,28 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
/** {@inheritDoc} */
@Override public <T, R> R execute(ComputeTask<T, R> task, @Nullable T arg) {
- A.notNull(task, "task");
-
- guard();
-
try {
- ctx.task().setThreadContextIfNotNull(TC_SUBGRID, prj.nodes());
- ctx.task().setThreadContextIfNotNull(TC_SUBJ_ID, subjId);
-
- return saveOrGet(ctx.task().execute(task, arg));
+ return (R)saveOrGet(executeAsync0(task, arg));
}
catch (IgniteCheckedException e) {
throw U.convertException(e);
}
- finally {
- unguard();
- }
+ }
+
+ /** {@inheritDoc} */
+ @Override public <T, R> ComputeTaskFuture<R> executeAsync(ComputeTask<T, R> task, @Nullable T arg)
+ throws IgniteException {
+ return (ComputeTaskFuture<R>)createFuture(executeAsync0(task, arg));
}
/**
+ * Execute implementation.
+ *
* @param task Task.
* @param arg Task argument.
* @return Task future.
*/
- public <T, R> ComputeTaskInternalFuture<R> executeAsync(ComputeTask<T, R> task, @Nullable T arg) {
+ public <T, R> ComputeTaskInternalFuture<R> executeAsync0(ComputeTask<T, R> task, @Nullable T arg) {
A.notNull(task, "task");
guard();
@@ -336,21 +523,34 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
}
}
+ /** {@inheritDoc} */
+ @Override public void broadcast(IgniteRunnable job) {
+ try {
+ saveOrGet(broadcastAsync0(job));
+ }
+ catch (IgniteCheckedException e) {
+ throw U.convertException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteFuture<Void> broadcastAsync(IgniteRunnable job) throws IgniteException {
+ return (IgniteFuture<Void>)createFuture(broadcastAsync0(job));
+ }
+
/**
- * @param taskName Task name.
- * @param arg Task argument.
- * @return Task future.
+ * Broadcast implementation.
+ *
+ * @param job Job.
+ * @return Internal future.
*/
- public <T, R> ComputeTaskInternalFuture<R> executeAsync(String taskName, @Nullable T arg) {
- A.notNull(taskName, "taskName");
+ private IgniteInternalFuture<?> broadcastAsync0(IgniteRunnable job) {
+ A.notNull(job, "job");
guard();
try {
- ctx.task().setThreadContextIfNotNull(TC_SUBGRID, prj.nodes());
- ctx.task().setThreadContextIfNotNull(TC_SUBJ_ID, subjId);
-
- return ctx.task().execute(taskName, arg);
+ return ctx.closure().runAsync(BROADCAST, job, prj.nodes());
}
finally {
unguard();
@@ -358,33 +558,33 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
}
/** {@inheritDoc} */
- @Override public void broadcast(IgniteRunnable job) {
- A.notNull(job, "job");
-
- guard();
-
+ @Override public <R> Collection<R> broadcast(IgniteCallable<R> job) {
try {
- saveOrGet(ctx.closure().runAsync(BROADCAST, job, prj.nodes()));
+ return saveOrGet(broadcastAsync0(job));
}
catch (IgniteCheckedException e) {
throw U.convertException(e);
}
- finally {
- unguard();
- }
}
/** {@inheritDoc} */
- @Override public <R> Collection<R> broadcast(IgniteCallable<R> job) {
+ @Override public <R> IgniteFuture<Collection<R>> broadcastAsync(IgniteCallable<R> job) throws IgniteException {
+ return createFuture(broadcastAsync0(job));
+ }
+
+ /**
+ * Broadcast implementation.
+ *
+ * @param job Job.
+ * @return Internal future.
+ */
+ private <R> IgniteInternalFuture<Collection<R>> broadcastAsync0(IgniteCallable<R> job) {
A.notNull(job, "job");
guard();
try {
- return saveOrGet(ctx.closure().callAsync(BROADCAST, Collections.singletonList(job), prj.nodes()));
- }
- catch (IgniteCheckedException e) {
- throw U.convertException(e);
+ return ctx.closure().callAsync(BROADCAST, Collections.singletonList(job), prj.nodes());
}
finally {
unguard();
@@ -393,15 +593,34 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
/** {@inheritDoc} */
@Override public <R, T> Collection<R> broadcast(IgniteClosure<T, R> job, @Nullable T arg) {
+ try {
+ return saveOrGet(broadcastAsync0(job, arg));
+ }
+ catch (IgniteCheckedException e) {
+ throw U.convertException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public <R, T> IgniteFuture<Collection<R>> broadcastAsync(IgniteClosure<T, R> job,
+ @Nullable T arg) throws IgniteException {
+ return createFuture(broadcastAsync0(job, arg));
+ }
+
+ /**
+ * Broadcast implementation.
+ *
+ * @param job Job.
+ * @param arg Argument.
+ * @return Internal future.
+ */
+ private <R, T> IgniteInternalFuture<Collection<R>> broadcastAsync0(IgniteClosure<T, R> job, @Nullable T arg) {
A.notNull(job, "job");
guard();
try {
- return saveOrGet(ctx.closure().broadcast(job, arg, prj.nodes()));
- }
- catch (IgniteCheckedException e) {
- throw U.convertException(e);
+ return ctx.closure().broadcast(job, arg, prj.nodes());
}
finally {
unguard();
@@ -410,15 +629,32 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
/** {@inheritDoc} */
@Override public void run(IgniteRunnable job) {
+ try {
+ saveOrGet(runAsync0(job));
+ }
+ catch (IgniteCheckedException e) {
+ throw U.convertException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteFuture<Void> runAsync(IgniteRunnable job) throws IgniteException {
+ return (IgniteFuture<Void>)createFuture(runAsync0(job));
+ }
+
+ /**
+ * Run implementation.
+ *
+ * @param job Job.
+ * @return Internal future.
+ */
+ private IgniteInternalFuture<?> runAsync0(IgniteRunnable job) {
A.notNull(job, "job");
guard();
try {
- saveOrGet(ctx.closure().runAsync(BALANCE, job, prj.nodes()));
- }
- catch (IgniteCheckedException e) {
- throw U.convertException(e);
+ return ctx.closure().runAsync(BALANCE, job, prj.nodes());
}
finally {
unguard();
@@ -427,15 +663,33 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
/** {@inheritDoc} */
@Override public void run(Collection<? extends IgniteRunnable> jobs) {
+ try {
+ saveOrGet(runAsync0(jobs));
+ }
+ catch (IgniteCheckedException e) {
+ throw U.convertException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteFuture<Void> runAsync(Collection<? extends IgniteRunnable> jobs)
+ throws IgniteException {
+ return (IgniteFuture<Void>)createFuture(runAsync0(jobs));
+ }
+
+ /**
+ * Run implementation.
+ *
+ * @param jobs Jobs.
+ * @return Internal future.
+ */
+ private IgniteInternalFuture<?> runAsync0(Collection<? extends IgniteRunnable> jobs) {
A.notEmpty(jobs, "jobs");
guard();
try {
- saveOrGet(ctx.closure().runAsync(BALANCE, jobs, prj.nodes()));
- }
- catch (IgniteCheckedException e) {
- throw U.convertException(e);
+ return ctx.closure().runAsync(BALANCE, jobs, prj.nodes());
}
finally {
unguard();
@@ -444,15 +698,34 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
/** {@inheritDoc} */
@Override public <R, T> R apply(IgniteClosure<T, R> job, @Nullable T arg) {
+ try {
+ return saveOrGet(applyAsync0(job, arg));
+ }
+ catch (IgniteCheckedException e) {
+ throw U.convertException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public <R, T> IgniteFuture<R> applyAsync(IgniteClosure<T, R> job, @Nullable T arg)
+ throws IgniteException {
+ return (IgniteFuture<R>)createFuture(applyAsync0(job, arg));
+ }
+
+ /**
+ * Apply implementation.
+ *
+ * @param job Job.
+ * @param arg Argument.
+ * @return Internal future.
+ */
+ private <R, T> IgniteInternalFuture<R> applyAsync0(IgniteClosure<T, R> job, @Nullable T arg) {
A.notNull(job, "job");
guard();
try {
- return saveOrGet(ctx.closure().callAsync(job, arg, prj.nodes()));
- }
- catch (IgniteCheckedException e) {
- throw U.convertException(e);
+ return ctx.closure().callAsync(job, arg, prj.nodes());
}
finally {
unguard();
@@ -461,15 +734,32 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
/** {@inheritDoc} */
@Override public <R> R call(IgniteCallable<R> job) {
+ try {
+ return saveOrGet(callAsync0(job));
+ }
+ catch (IgniteCheckedException e) {
+ throw U.convertException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public <R> IgniteFuture<R> callAsync(IgniteCallable<R> job) throws IgniteException {
+ return (IgniteFuture<R>)createFuture(callAsync0(job));
+ }
+
+ /**
+ * Call implementation.
+ *
+ * @param job Job.
+ * @return Internal future.
+ */
+ private <R> IgniteInternalFuture<R> callAsync0(IgniteCallable<R> job) {
A.notNull(job, "job");
guard();
try {
- return saveOrGet(ctx.closure().callAsync(BALANCE, job, prj.nodes()));
- }
- catch (IgniteCheckedException e) {
- throw U.convertException(e);
+ return ctx.closure().callAsync(BALANCE, job, prj.nodes());
}
finally {
unguard();
@@ -478,15 +768,33 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
/** {@inheritDoc} */
@Override public <R> Collection<R> call(Collection<? extends IgniteCallable<R>> jobs) {
+ try {
+ return saveOrGet(callAsync0(jobs));
+ }
+ catch (IgniteCheckedException e) {
+ throw U.convertException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public <R> IgniteFuture<Collection<R>> callAsync(
+ Collection<? extends IgniteCallable<R>> jobs) throws IgniteException {
+ return (IgniteFuture<Collection<R>>)createFuture(callAsync0(jobs));
+ }
+
+ /**
+ * Call implementation.
+ *
+ * @param jobs Jobs.
+ * @return Internal future.
+ */
+ private <R> IgniteInternalFuture<Collection<R>> callAsync0(Collection<? extends IgniteCallable<R>> jobs) {
A.notEmpty(jobs, "jobs");
guard();
try {
- return saveOrGet(ctx.closure().callAsync(BALANCE, (Collection<? extends Callable<R>>)jobs, prj.nodes()));
- }
- catch (IgniteCheckedException e) {
- throw U.convertException(e);
+ return ctx.closure().callAsync(BALANCE, (Collection<? extends Callable<R>>)jobs, prj.nodes());
}
finally {
unguard();
@@ -495,16 +803,36 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
/** {@inheritDoc} */
@Override public <T, R> Collection<R> apply(final IgniteClosure<T, R> job, @Nullable Collection<? extends T> args) {
+ try {
+ return saveOrGet(applyAsync0(job, args));
+ }
+ catch (IgniteCheckedException e) {
+ throw U.convertException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public <T, R> IgniteFuture<Collection<R>> applyAsync(IgniteClosure<T, R> job,
+ Collection<? extends T> args) throws IgniteException {
+ return (IgniteFuture<Collection<R>>)createFuture(applyAsync0(job, args));
+ }
+
+ /**
+ * Apply implementation.
+ *
+ * @param job Job.
+ * @param args Arguments/
+ * @return Internal future.
+ */
+ private <T, R> IgniteInternalFuture<Collection<R>> applyAsync0(final IgniteClosure<T, R> job,
+ @Nullable Collection<? extends T> args) {
A.notNull(job, "job");
A.notNull(args, "args");
guard();
try {
- return saveOrGet(ctx.closure().callAsync(job, args, prj.nodes()));
- }
- catch (IgniteCheckedException e) {
- throw U.convertException(e);
+ return ctx.closure().callAsync(job, args, prj.nodes());
}
finally {
unguard();
@@ -513,16 +841,36 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
/** {@inheritDoc} */
@Override public <R1, R2> R2 call(Collection<? extends IgniteCallable<R1>> jobs, IgniteReducer<R1, R2> rdc) {
+ try {
+ return saveOrGet(callAsync0(jobs, rdc));
+ }
+ catch (IgniteCheckedException e) {
+ throw U.convertException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public <R1, R2> IgniteFuture<R2> callAsync(Collection<? extends IgniteCallable<R1>> jobs,
+ IgniteReducer<R1, R2> rdc) throws IgniteException {
+ return (IgniteFuture<R2>)createFuture(callAsync0(jobs, rdc));
+ }
+
+ /**
+ * Call with reducer implementation.
+ *
+ * @param jobs Jobs.
+ * @param rdc Reducer.
+ * @return Internal future.
+ */
+ private <R1, R2> IgniteInternalFuture<R2> callAsync0(Collection<? extends IgniteCallable<R1>> jobs,
+ IgniteReducer<R1, R2> rdc) {
A.notEmpty(jobs, "jobs");
A.notNull(rdc, "rdc");
guard();
try {
- return saveOrGet(ctx.closure().forkjoinAsync(BALANCE, jobs, rdc, prj.nodes()));
- }
- catch (IgniteCheckedException e) {
- throw U.convertException(e);
+ return ctx.closure().forkjoinAsync(BALANCE, jobs, rdc, prj.nodes());
}
finally {
unguard();
@@ -532,6 +880,30 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
/** {@inheritDoc} */
@Override public <R1, R2, T> R2 apply(IgniteClosure<T, R1> job, Collection<? extends T> args,
IgniteReducer<R1, R2> rdc) {
+ try {
+ return saveOrGet(applyAsync0(job, args, rdc));
+ }
+ catch (IgniteCheckedException e) {
+ throw U.convertException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public <R1, R2, T> IgniteFuture<R2> applyAsync(IgniteClosure<T, R1> job,
+ Collection<? extends T> args, IgniteReducer<R1, R2> rdc) throws IgniteException {
+ return createFuture(applyAsync0(job, args, rdc));
+ }
+
+ /**
+ * Apply with reducer implementation.
+ *
+ * @param job Job
+ * @param args Arguments.
+ * @param rdc Reducer.
+ * @return Internal future.
+ */
+ private <R1, R2, T> IgniteInternalFuture<R2> applyAsync0(IgniteClosure<T, R1> job, Collection<? extends T> args,
+ IgniteReducer<R1, R2> rdc) {
A.notNull(job, "job");
A.notNull(rdc, "rdc");
A.notNull(args, "args");
@@ -539,10 +911,7 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
guard();
try {
- return saveOrGet(ctx.closure().callAsync(job, args, rdc, prj.nodes()));
- }
- catch (IgniteCheckedException e) {
- throw U.convertException(e);
+ return ctx.closure().callAsync(job, args, rdc, prj.nodes());
}
finally {
unguard();
@@ -646,7 +1015,8 @@ public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute>
guard();
try {
- ctx.deploy().undeployTask(taskName, prj.node(ctx.localNodeId()) != null, prj.forRemotes().nodes());
+ ctx.deploy().undeployTask(taskName, prj.node(ctx.localNodeId()) != null,
+ prj.forRemotes().nodes());
}
finally {
unguard();
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/main/java/org/apache/ignite/internal/IgniteEventsImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteEventsImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteEventsImpl.java
index 3c6218d..9acccab 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteEventsImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteEventsImpl.java
@@ -27,13 +27,16 @@ import java.util.List;
import java.util.UUID;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteEvents;
+import org.apache.ignite.IgniteException;
import org.apache.ignite.cluster.ClusterGroup;
import org.apache.ignite.events.Event;
import org.apache.ignite.internal.cluster.ClusterGroupAdapter;
+import org.apache.ignite.internal.util.future.IgniteFutureImpl;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.A;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiPredicate;
+import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.lang.IgnitePredicate;
import org.jetbrains.annotations.Nullable;
@@ -93,12 +96,34 @@ public class IgniteEventsImpl extends AsyncSupportAdapter<IgniteEvents> implemen
}
/** {@inheritDoc} */
+ @Override public <T extends Event> IgniteFuture<List<T>> remoteQueryAsync(IgnitePredicate<T> p, long timeout,
+ @Nullable int... types) throws IgniteException {
+
+ guard();
+
+ try {
+ return new IgniteFutureImpl<>(ctx.event().remoteEventsAsync(compoundPredicate(p, types),
+ prj.nodes(), timeout));
+ }
+ finally {
+ unguard();
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public <T extends Event> UUID remoteListen(@Nullable IgniteBiPredicate<UUID, T> locLsnr,
@Nullable IgnitePredicate<T> rmtFilter, @Nullable int... types) {
return remoteListen(1, 0, true, locLsnr, rmtFilter, types);
}
/** {@inheritDoc} */
+ @Override public <T extends Event> IgniteFuture<UUID> remoteListenAsync(
+ @Nullable IgniteBiPredicate<UUID, T> locLsnr, @Nullable IgnitePredicate<T> rmtFilter,
+ @Nullable int... types) throws IgniteException {
+ return remoteListenAsync(1, 0, true, locLsnr, rmtFilter, types);
+ }
+
+ /** {@inheritDoc} */
@Override public <T extends Event> UUID remoteListen(int bufSize, long interval,
boolean autoUnsubscribe, @Nullable IgniteBiPredicate<UUID, T> locLsnr, @Nullable IgnitePredicate<T> rmtFilter,
@Nullable int... types) {
@@ -128,6 +153,32 @@ public class IgniteEventsImpl extends AsyncSupportAdapter<IgniteEvents> implemen
}
/** {@inheritDoc} */
+ @Override public <T extends Event> IgniteFuture<UUID> remoteListenAsync(int bufSize, long interval,
+ boolean autoUnsubscribe, @Nullable IgniteBiPredicate<UUID, T> locLsnr, @Nullable IgnitePredicate<T> rmtFilter,
+ @Nullable int... types) throws IgniteException {
+ A.ensure(bufSize > 0, "bufSize > 0");
+ A.ensure(interval >= 0, "interval >= 0");
+
+ guard();
+
+ try {
+ GridEventConsumeHandler hnd = new GridEventConsumeHandler((IgniteBiPredicate<UUID, Event>)locLsnr,
+ (IgnitePredicate<Event>)rmtFilter, types);
+
+ return new IgniteFutureImpl<>(ctx.continuous().startRoutine(
+ hnd,
+ false,
+ bufSize,
+ interval,
+ autoUnsubscribe,
+ prj.predicate()));
+ }
+ finally {
+ unguard();
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public void stopRemoteListen(UUID opId) {
A.notNull(opId, "consumeId");
@@ -145,6 +196,21 @@ public class IgniteEventsImpl extends AsyncSupportAdapter<IgniteEvents> implemen
}
/** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override public IgniteFuture<Void> stopRemoteListenAsync(UUID opId) throws IgniteException {
+ A.notNull(opId, "consumeId");
+
+ guard();
+
+ try {
+ return (IgniteFuture<Void>)new IgniteFutureImpl<>(ctx.continuous().stopRoutine(opId));
+ }
+ finally {
+ unguard();
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public <T extends Event> T waitForLocal(@Nullable IgnitePredicate<T> filter,
@Nullable int... types) {
guard();
@@ -161,6 +227,19 @@ public class IgniteEventsImpl extends AsyncSupportAdapter<IgniteEvents> implemen
}
/** {@inheritDoc} */
+ @Override public <T extends Event> IgniteFuture<T> waitForLocalAsync(@Nullable IgnitePredicate<T> filter,
+ @Nullable int... types) throws IgniteException {
+ guard();
+
+ try {
+ return new IgniteFutureImpl<>(ctx.event().waitForEvent(filter, types));
+ }
+ finally {
+ unguard();
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public <T extends Event> Collection<T> localQuery(IgnitePredicate<T> p, @Nullable int... types) {
A.notNull(p, "p");
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/main/java/org/apache/ignite/internal/IgniteMessagingImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteMessagingImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteMessagingImpl.java
index 541fad4..4c23dd5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteMessagingImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteMessagingImpl.java
@@ -25,15 +25,18 @@ import java.io.ObjectStreamException;
import java.util.Collection;
import java.util.UUID;
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteMessaging;
import org.apache.ignite.cluster.ClusterGroup;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.internal.cluster.ClusterGroupAdapter;
import org.apache.ignite.internal.processors.continuous.GridContinuousHandler;
+import org.apache.ignite.internal.util.future.IgniteFutureImpl;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.A;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiPredicate;
+import org.apache.ignite.lang.IgniteFuture;
import org.jetbrains.annotations.Nullable;
/**
@@ -76,6 +79,17 @@ public class IgniteMessagingImpl extends AsyncSupportAdapter<IgniteMessaging>
/** {@inheritDoc} */
@Override public void send(@Nullable Object topic, Object msg) {
+ send0(topic, msg, isAsync());
+ }
+
+ /**
+ * Implementation of send.
+ * @param topic Topic.
+ * @param msg Message.
+ * @param async Async flag.
+ * @throws IgniteException On error.
+ */
+ private void send0(@Nullable Object topic, Object msg, boolean async) throws IgniteException {
A.notNull(msg, "msg");
guard();
@@ -86,7 +100,7 @@ public class IgniteMessagingImpl extends AsyncSupportAdapter<IgniteMessaging>
if (snapshot.isEmpty())
throw U.emptyTopologyException();
- ctx.io().sendUserMessage(snapshot, msg, topic, false, 0, isAsync());
+ ctx.io().sendUserMessage(snapshot, msg, topic, false, 0, async);
}
catch (IgniteCheckedException e) {
throw U.convertException(e);
@@ -98,6 +112,17 @@ public class IgniteMessagingImpl extends AsyncSupportAdapter<IgniteMessaging>
/** {@inheritDoc} */
@Override public void send(@Nullable Object topic, Collection<?> msgs) {
+ send0(topic, msgs, isAsync());
+ }
+
+ /**
+ * Implementation of send.
+ * @param topic Topic.
+ * @param msgs Messages.
+ * @param async Async flag.
+ * @throws IgniteException On error.
+ */
+ private void send0(@Nullable Object topic, Collection<?> msgs, boolean async) throws IgniteException {
A.ensure(!F.isEmpty(msgs), "msgs cannot be null or empty");
guard();
@@ -111,7 +136,7 @@ public class IgniteMessagingImpl extends AsyncSupportAdapter<IgniteMessaging>
for (Object msg : msgs) {
A.notNull(msg, "msg");
- ctx.io().sendUserMessage(snapshot, msg, topic, false, 0, isAsync());
+ ctx.io().sendUserMessage(snapshot, msg, topic, false, 0, async);
}
}
catch (IgniteCheckedException e) {
@@ -200,6 +225,28 @@ public class IgniteMessagingImpl extends AsyncSupportAdapter<IgniteMessaging>
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<UUID> remoteListenAsync(@Nullable Object topic,
+ IgniteBiPredicate<UUID, ?> p) throws IgniteException {
+ A.notNull(p, "p");
+
+ guard();
+
+ try {
+ GridContinuousHandler hnd = new GridMessageListenHandler(topic, (IgniteBiPredicate<UUID, Object>)p);
+
+ return new IgniteFutureImpl<>(ctx.continuous().startRoutine(hnd,
+ false,
+ 1,
+ 0,
+ false,
+ prj.predicate()));
+ }
+ finally {
+ unguard();
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public void stopRemoteListen(UUID opId) {
A.notNull(opId, "opId");
@@ -216,6 +263,20 @@ public class IgniteMessagingImpl extends AsyncSupportAdapter<IgniteMessaging>
}
}
+ /** {@inheritDoc} */
+ @Override public IgniteFuture<Void> stopRemoteListenAsync(UUID opId) throws IgniteException {
+ A.notNull(opId, "opId");
+
+ guard();
+
+ try {
+ return (IgniteFuture<Void>)new IgniteFutureImpl<>(ctx.continuous().stopRoutine(opId));
+ }
+ finally {
+ unguard();
+ }
+ }
+
/**
* <tt>ctx.gateway().readLock()</tt>
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/main/java/org/apache/ignite/internal/IgniteServicesImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteServicesImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteServicesImpl.java
index df6e5df..607dccc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteServicesImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteServicesImpl.java
@@ -28,8 +28,10 @@ import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteServices;
import org.apache.ignite.cluster.ClusterGroup;
import org.apache.ignite.internal.cluster.ClusterGroupAdapter;
+import org.apache.ignite.internal.util.future.IgniteFutureImpl;
import org.apache.ignite.internal.util.typedef.internal.A;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.services.Service;
import org.apache.ignite.services.ServiceConfiguration;
import org.apache.ignite.services.ServiceDescriptor;
@@ -38,6 +40,7 @@ import org.jetbrains.annotations.Nullable;
/**
* {@link org.apache.ignite.IgniteServices} implementation.
*/
+@SuppressWarnings("unchecked")
public class IgniteServicesImpl extends AsyncSupportAdapter implements IgniteServices, Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -91,6 +94,21 @@ public class IgniteServicesImpl extends AsyncSupportAdapter implements IgniteSer
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Void> deployNodeSingletonAsync(String name, Service svc) throws IgniteException {
+ A.notNull(name, "name");
+ A.notNull(svc, "svc");
+
+ guard();
+
+ try {
+ return (IgniteFuture<Void>)new IgniteFutureImpl<>(ctx.service().deployNodeSingleton(prj, name, svc));
+ }
+ finally {
+ unguard();
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public void deployClusterSingleton(String name, Service svc) {
A.notNull(name, "name");
A.notNull(svc, "svc");
@@ -109,6 +127,21 @@ public class IgniteServicesImpl extends AsyncSupportAdapter implements IgniteSer
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Void> deployClusterSingletonAsync(String name, Service svc) throws IgniteException {
+ A.notNull(name, "name");
+ A.notNull(svc, "svc");
+
+ guard();
+
+ try {
+ return (IgniteFuture<Void>)new IgniteFutureImpl<>(ctx.service().deployClusterSingleton(prj, name, svc));
+ }
+ finally {
+ unguard();
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public void deployMultiple(String name, Service svc, int totalCnt, int maxPerNodeCnt) {
A.notNull(name, "name");
A.notNull(svc, "svc");
@@ -127,6 +160,23 @@ public class IgniteServicesImpl extends AsyncSupportAdapter implements IgniteSer
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Void> deployMultipleAsync(String name, Service svc, int totalCnt,
+ int maxPerNodeCnt) throws IgniteException {
+ A.notNull(name, "name");
+ A.notNull(svc, "svc");
+
+ guard();
+
+ try {
+ return (IgniteFuture<Void>)new IgniteFutureImpl<>(ctx.service().deployMultiple(prj, name, svc,
+ totalCnt, maxPerNodeCnt));
+ }
+ finally {
+ unguard();
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public void deployKeyAffinitySingleton(String name, Service svc, @Nullable String cacheName,
Object affKey) {
A.notNull(name, "name");
@@ -147,6 +197,24 @@ public class IgniteServicesImpl extends AsyncSupportAdapter implements IgniteSer
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Void> deployKeyAffinitySingletonAsync(String name, Service svc,
+ @Nullable String cacheName, Object affKey) throws IgniteException {
+ A.notNull(name, "name");
+ A.notNull(svc, "svc");
+ A.notNull(affKey, "affKey");
+
+ guard();
+
+ try {
+ return (IgniteFuture<Void>)new IgniteFutureImpl<>(ctx.service().deployKeyAffinitySingleton(name, svc,
+ cacheName, affKey));
+ }
+ finally {
+ unguard();
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public void deploy(ServiceConfiguration cfg) {
A.notNull(cfg, "cfg");
@@ -164,6 +232,20 @@ public class IgniteServicesImpl extends AsyncSupportAdapter implements IgniteSer
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Void> deployAsync(ServiceConfiguration cfg) throws IgniteException {
+ A.notNull(cfg, "cfg");
+
+ guard();
+
+ try {
+ return (IgniteFuture<Void>)new IgniteFutureImpl<>(ctx.service().deploy(cfg));
+ }
+ finally {
+ unguard();
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public void cancel(String name) {
A.notNull(name, "name");
@@ -181,6 +263,20 @@ public class IgniteServicesImpl extends AsyncSupportAdapter implements IgniteSer
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Void> cancelAsync(String name) throws IgniteException {
+ A.notNull(name, "name");
+
+ guard();
+
+ try {
+ return (IgniteFuture<Void>)new IgniteFutureImpl<>(ctx.service().cancel(name));
+ }
+ finally {
+ unguard();
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public void cancelAll() {
guard();
@@ -196,6 +292,18 @@ public class IgniteServicesImpl extends AsyncSupportAdapter implements IgniteSer
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Void> cancelAllAsync() throws IgniteException {
+ guard();
+
+ try {
+ return (IgniteFuture<Void>)new IgniteFutureImpl<>(ctx.service().cancelAll());
+ }
+ finally {
+ unguard();
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public Collection<ServiceDescriptor> serviceDescriptors() {
guard();
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterGroupAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterGroupAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterGroupAdapter.java
index 5d5c06f..75c9a71 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterGroupAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterGroupAdapter.java
@@ -212,7 +212,7 @@ public class ClusterGroupAdapter implements ClusterGroupEx, Externalizable {
if (compute == null) {
assert ctx != null;
- compute = new IgniteComputeImpl(ctx, this, subjId, false);
+ compute = new IgniteComputeImpl(ctx, this, subjId);
}
return compute;
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/main/java/org/apache/ignite/internal/cluster/IgniteClusterAsyncImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/cluster/IgniteClusterAsyncImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/cluster/IgniteClusterAsyncImpl.java
index fb9b190..d392813 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/cluster/IgniteClusterAsyncImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/cluster/IgniteClusterAsyncImpl.java
@@ -22,7 +22,6 @@ import java.io.File;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
-import java.io.ObjectStreamException;
import java.util.Collection;
import java.util.Map;
import java.util.UUID;
@@ -30,6 +29,7 @@ import java.util.concurrent.ConcurrentMap;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteCluster;
+import org.apache.ignite.IgniteException;
import org.apache.ignite.cluster.ClusterGroup;
import org.apache.ignite.cluster.ClusterMetrics;
import org.apache.ignite.cluster.ClusterNode;
@@ -115,7 +115,7 @@ public class IgniteClusterAsyncImpl extends AsyncSupportAdapter<IgniteCluster>
int maxConn)
{
try {
- return saveOrGet(cluster.startNodesAsync(file, restart, timeout, maxConn));
+ return saveOrGet(cluster.startNodesAsync0(file, restart, timeout, maxConn));
}
catch (IgniteCheckedException e) {
throw U.convertException(e);
@@ -123,6 +123,12 @@ public class IgniteClusterAsyncImpl extends AsyncSupportAdapter<IgniteCluster>
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Collection<ClusterStartNodeResult>> startNodesAsync(File file, boolean restart,
+ int timeout, int maxConn) throws IgniteException {
+ return cluster.startNodesAsync(file, restart, timeout, maxConn);
+ }
+
+ /** {@inheritDoc} */
@Override public Collection<ClusterStartNodeResult> startNodes(
Collection<Map<String, Object>> hosts,
@Nullable Map<String, Object> dflts,
@@ -131,7 +137,7 @@ public class IgniteClusterAsyncImpl extends AsyncSupportAdapter<IgniteCluster>
int maxConn)
{
try {
- return saveOrGet(cluster.startNodesAsync(hosts, dflts, restart, timeout, maxConn));
+ return saveOrGet(cluster.startNodesAsync0(hosts, dflts, restart, timeout, maxConn));
}
catch (IgniteCheckedException e) {
throw U.convertException(e);
@@ -139,6 +145,13 @@ public class IgniteClusterAsyncImpl extends AsyncSupportAdapter<IgniteCluster>
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Collection<ClusterStartNodeResult>> startNodesAsync(
+ Collection<Map<String, Object>> hosts, @Nullable Map<String, Object> dflts,
+ boolean restart, int timeout, int maxConn) throws IgniteException {
+ return cluster.startNodesAsync(hosts, dflts, restart, timeout, maxConn);
+ }
+
+ /** {@inheritDoc} */
@Override public void stopNodes() {
cluster.stopNodes();
}
@@ -312,13 +325,4 @@ public class IgniteClusterAsyncImpl extends AsyncSupportAdapter<IgniteCluster>
@Override public void writeExternal(ObjectOutput out) throws IOException {
out.writeObject(cluster);
}
-
- /**
- * @return Cluster async instance.
- *
- * @throws ObjectStreamException If failed.
- */
- protected Object readResolve() throws ObjectStreamException {
- return cluster.withAsync();
- }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/main/java/org/apache/ignite/internal/cluster/IgniteClusterImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/cluster/IgniteClusterImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/cluster/IgniteClusterImpl.java
index 58a2128..e429547 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/cluster/IgniteClusterImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/cluster/IgniteClusterImpl.java
@@ -47,6 +47,7 @@ import org.apache.ignite.internal.IgniteComponentType;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.util.future.GridCompoundFuture;
import org.apache.ignite.internal.util.future.GridFinishedFuture;
+import org.apache.ignite.internal.util.future.IgniteFutureImpl;
import org.apache.ignite.internal.util.nodestart.IgniteRemoteStartSpecification;
import org.apache.ignite.internal.util.nodestart.IgniteSshHelper;
import org.apache.ignite.internal.util.nodestart.StartNodeCallable;
@@ -222,7 +223,7 @@ public class IgniteClusterImpl extends ClusterGroupAdapter implements IgniteClus
throws IgniteException
{
try {
- return startNodesAsync(file, restart, timeout, maxConn).get();
+ return startNodesAsync0(file, restart, timeout, maxConn).get();
}
catch (IgniteCheckedException e) {
throw U.convertException(e);
@@ -230,6 +231,12 @@ public class IgniteClusterImpl extends ClusterGroupAdapter implements IgniteClus
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Collection<ClusterStartNodeResult>> startNodesAsync(File file, boolean restart,
+ int timeout, int maxConn) throws IgniteException {
+ return new IgniteFutureImpl<>(startNodesAsync0(file, restart, timeout, maxConn));
+ }
+
+ /** {@inheritDoc} */
@Override public Collection<ClusterStartNodeResult> startNodes(Collection<Map<String, Object>> hosts,
@Nullable Map<String, Object> dflts,
boolean restart,
@@ -238,7 +245,7 @@ public class IgniteClusterImpl extends ClusterGroupAdapter implements IgniteClus
throws IgniteException
{
try {
- return startNodesAsync(hosts, dflts, restart, timeout, maxConn).get();
+ return startNodesAsync0(hosts, dflts, restart, timeout, maxConn).get();
}
catch (IgniteCheckedException e) {
throw U.convertException(e);
@@ -246,6 +253,13 @@ public class IgniteClusterImpl extends ClusterGroupAdapter implements IgniteClus
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Collection<ClusterStartNodeResult>> startNodesAsync(
+ Collection<Map<String, Object>> hosts, @Nullable Map<String, Object> dflts,
+ boolean restart, int timeout, int maxConn) throws IgniteException {
+ return new IgniteFutureImpl<>(startNodesAsync0(hosts, dflts, restart, timeout, maxConn));
+ }
+
+ /** {@inheritDoc} */
@Override public void stopNodes() throws IgniteException {
guard();
@@ -330,7 +344,7 @@ public class IgniteClusterImpl extends ClusterGroupAdapter implements IgniteClus
* @return Future with results.
* @see IgniteCluster#startNodes(java.io.File, boolean, int, int)
*/
- IgniteInternalFuture<Collection<ClusterStartNodeResult>> startNodesAsync(File file,
+ IgniteInternalFuture<Collection<ClusterStartNodeResult>> startNodesAsync0(File file,
boolean restart,
int timeout,
int maxConn)
@@ -342,7 +356,7 @@ public class IgniteClusterImpl extends ClusterGroupAdapter implements IgniteClus
try {
IgniteBiTuple<Collection<Map<String, Object>>, Map<String, Object>> t = parseFile(file);
- return startNodesAsync(t.get1(), t.get2(), restart, timeout, maxConn);
+ return startNodesAsync0(t.get1(), t.get2(), restart, timeout, maxConn);
}
catch (IgniteCheckedException e) {
return new GridFinishedFuture<>(e);
@@ -358,7 +372,7 @@ public class IgniteClusterImpl extends ClusterGroupAdapter implements IgniteClus
* @return Future with results.
* @see IgniteCluster#startNodes(java.util.Collection, java.util.Map, boolean, int, int)
*/
- IgniteInternalFuture<Collection<ClusterStartNodeResult>> startNodesAsync(
+ IgniteInternalFuture<Collection<ClusterStartNodeResult>> startNodesAsync0(
Collection<Map<String, Object>> hosts,
@Nullable Map<String, Object> dflts,
boolean restart,
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcConnection.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcConnection.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcConnection.java
index 2220bfe..5ee28f7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcConnection.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcConnection.java
@@ -623,11 +623,7 @@ public class JdbcConnection implements Connection {
throw new SQLException("Failed to establish connection with node (is it a server node?): " +
nodeId);
- IgniteCompute compute = ignite.compute(grp).withAsync();
-
- compute.call(task);
-
- return compute.<Boolean>future().get(timeout, SECONDS);
+ return ignite.compute(grp).callAsync(task).get(timeout, SECONDS);
}
else
return task.call();
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
index 0e8c263..28cf0db 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
@@ -93,6 +93,7 @@ import org.jetbrains.annotations.Nullable;
/**
* Cache proxy.
*/
+@SuppressWarnings("unchecked")
public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V>>
implements IgniteCache<K, V>, Externalizable {
/** */
@@ -378,10 +379,9 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
try {
if (isAsync()) {
- if (ctx.cache().isLocal())
- setFuture(ctx.cache().localLoadCacheAsync(p, args));
- else
- setFuture(ctx.cache().globalLoadCacheAsync(p, args));
+ setFuture(ctx.cache().isLocal() ?
+ ctx.cache().localLoadCacheAsync(p, args)
+ : ctx.cache().globalLoadCacheAsync(p, args));
}
else {
if (ctx.cache().isLocal())
@@ -400,6 +400,27 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Void> loadCacheAsync(@Nullable IgniteBiPredicate<K, V> p,
+ @Nullable Object... args) throws CacheException {
+ try {
+ GridCacheGateway<K, V> gate = this.gate;
+
+ CacheOperationContext prev = onEnter(gate, opCtx);
+
+ try {
+ return (IgniteFuture<Void>)createFuture(ctx.cache().isLocal() ?
+ ctx.cache().localLoadCacheAsync(p, args) : ctx.cache().globalLoadCacheAsync(p, args));
+ }
+ finally {
+ onLeave(gate, prev);
+ }
+ }
+ catch (IgniteCheckedException e) {
+ throw cacheException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public void localLoadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) {
try {
GridCacheGateway<K, V> gate = this.gate;
@@ -422,6 +443,21 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Void> localLoadCacheAsync(@Nullable IgniteBiPredicate<K, V> p,
+ @Nullable Object... args) throws CacheException {
+ GridCacheGateway<K, V> gate = this.gate;
+
+ CacheOperationContext prev = onEnter(gate, opCtx);
+
+ try {
+ return (IgniteFuture<Void>)createFuture(delegate.localLoadCacheAsync(p, args));
+ }
+ finally {
+ onLeave(gate, prev);
+ }
+ }
+
+ /** {@inheritDoc} */
@Nullable @Override public V getAndPutIfAbsent(K key, V val) throws CacheException {
try {
GridCacheGateway<K, V> gate = this.gate;
@@ -447,6 +483,20 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<V> getAndPutIfAbsentAsync(K key, V val) throws CacheException {
+ GridCacheGateway<K, V> gate = this.gate;
+
+ CacheOperationContext prev = onEnter(gate, opCtx);
+
+ try {
+ return createFuture(delegate.getAndPutIfAbsentAsync(key, val));
+ }
+ finally {
+ onLeave(gate, prev);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public Lock lock(K key) throws CacheException {
return lockAll(Collections.singleton(key));
}
@@ -475,6 +525,7 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
* @param transformer Transformer
* @param grp Optional cluster group.
* @return Cursor.
+ * @throws IgniteCheckedException If failed.
*/
@SuppressWarnings("unchecked")
private <T, R> QueryCursor<R> query(
@@ -535,6 +586,7 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
* @param filter Filter.
* @param grp Optional cluster group.
* @return Cursor.
+ * @throws IgniteCheckedException If failed.
*/
@SuppressWarnings("unchecked")
private QueryCursor<Cache.Entry<K, V>> query(final Query filter, @Nullable ClusterGroup grp)
@@ -643,6 +695,7 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
*
* @param qry Query.
* @param loc Local flag.
+ * @param keepBinary Keep binary flag.
* @return Initial iteration cursor.
*/
@SuppressWarnings("unchecked")
@@ -1004,6 +1057,20 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Integer> sizeAsync(CachePeekMode... peekModes) throws CacheException {
+ GridCacheGateway<K, V> gate = this.gate;
+
+ CacheOperationContext prev = onEnter(gate, opCtx);
+
+ try {
+ return createFuture(delegate.sizeAsync(peekModes));
+ }
+ finally {
+ onLeave(gate, prev);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public long sizeLong(CachePeekMode... peekModes) throws CacheException {
GridCacheGateway<K, V> gate = this.gate;
@@ -1027,6 +1094,20 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Long> sizeLongAsync(CachePeekMode... peekModes) throws CacheException {
+ GridCacheGateway<K, V> gate = this.gate;
+
+ CacheOperationContext prev = onEnter(gate, opCtx);
+
+ try {
+ return createFuture(delegate.sizeLongAsync(peekModes));
+ }
+ finally {
+ onLeave(gate, prev);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public long sizeLong(int part, CachePeekMode... peekModes) throws CacheException {
GridCacheGateway<K, V> gate = this.gate;
@@ -1050,6 +1131,20 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Long> sizeLongAsync(int part, CachePeekMode... peekModes) throws CacheException {
+ GridCacheGateway<K, V> gate = this.gate;
+
+ CacheOperationContext prev = onEnter(gate, opCtx);
+
+ try {
+ return createFuture(delegate.sizeLongAsync(part, peekModes));
+ }
+ finally {
+ onLeave(gate, prev);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public int localSize(CachePeekMode... peekModes) {
GridCacheGateway<K, V> gate = this.gate;
@@ -1126,6 +1221,20 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<V> getAsync(K key) {
+ GridCacheGateway<K, V> gate = this.gate;
+
+ CacheOperationContext prev = onEnter(gate, opCtx);
+
+ try {
+ return createFuture(delegate.getAsync(key));
+ }
+ finally {
+ onLeave(gate, prev);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public CacheEntry<K, V> getEntry(K key) {
try {
GridCacheGateway<K, V> gate = this.gate;
@@ -1151,6 +1260,20 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<CacheEntry<K, V>> getEntryAsync(K key) {
+ GridCacheGateway<K, V> gate = this.gate;
+
+ CacheOperationContext prev = onEnter(gate, opCtx);
+
+ try {
+ return createFuture(delegate.getEntryAsync(key));
+ }
+ finally {
+ onLeave(gate, prev);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public Map<K, V> getAll(Set<? extends K> keys) {
try {
GridCacheGateway<K, V> gate = this.gate;
@@ -1176,6 +1299,20 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Map<K, V>> getAllAsync(Set<? extends K> keys) {
+ GridCacheGateway<K, V> gate = this.gate;
+
+ CacheOperationContext prev = onEnter(gate, opCtx);
+
+ try {
+ return createFuture(delegate.getAllAsync(keys));
+ }
+ finally {
+ onLeave(gate, prev);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public Collection<CacheEntry<K, V>> getEntries(Set<? extends K> keys) {
try {
GridCacheGateway<K, V> gate = this.gate;
@@ -1201,6 +1338,20 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Collection<CacheEntry<K, V>>> getEntriesAsync(Set<? extends K> keys) {
+ GridCacheGateway<K, V> gate = this.gate;
+
+ CacheOperationContext prev = onEnter(gate, opCtx);
+
+ try {
+ return createFuture(delegate.getEntriesAsync(keys));
+ }
+ finally {
+ onLeave(gate, prev);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public Map<K, V> getAllOutTx(Set<? extends K> keys) {
try {
GridCacheGateway<K, V> gate = this.gate;
@@ -1225,6 +1376,20 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
}
+ /** {@inheritDoc} */
+ @Override public IgniteFuture<Map<K, V>> getAllOutTxAsync(Set<? extends K> keys) {
+ GridCacheGateway<K, V> gate = this.gate;
+
+ CacheOperationContext prev = onEnter(gate, opCtx);
+
+ try {
+ return createFuture(delegate.getAllOutTxAsync(keys));
+ }
+ finally {
+ onLeave(gate, prev);
+ }
+ }
+
/**
* @param keys Keys.
* @return Values map.
@@ -1293,6 +1458,20 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Boolean> containsKeyAsync(K key) {
+ GridCacheGateway<K, V> gate = this.gate;
+
+ CacheOperationContext prev = onEnter(gate, opCtx);
+
+ try {
+ return createFuture(delegate.containsKeyAsync(key));
+ }
+ finally {
+ onLeave(gate, prev);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public boolean containsKeys(Set<? extends K> keys) {
GridCacheGateway<K, V> gate = this.gate;
@@ -1313,6 +1492,20 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Boolean> containsKeysAsync(Set<? extends K> keys) {
+ GridCacheGateway<K, V> gate = this.gate;
+
+ CacheOperationContext prev = onEnter(gate, opCtx);
+
+ try {
+ return createFuture(delegate.containsKeysAsync(keys));
+ }
+ finally {
+ onLeave(gate, prev);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public void loadAll(
Set<? extends K> keys,
boolean replaceExisting,
@@ -1353,24 +1546,8 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
CacheOperationContext prev = onEnter(gate, opCtx);
try {
- if (isAsync()) {
- IgniteInternalFuture<Boolean> fut = delegate.putAsync(key, val);
-
- IgniteInternalFuture<Void> fut0 = fut.chain(new CX1<IgniteInternalFuture<Boolean>, Void>() {
- @Override public Void applyx(IgniteInternalFuture<Boolean> fut) throws IgniteCheckedException {
- try {
- fut.get();
- }
- catch (RuntimeException e) {
- throw new GridClosureException(e);
- }
-
- return null;
- }
- });
-
- setFuture(fut0);
- }
+ if (isAsync())
+ setFuture(putAsync0(key, val));
else
delegate.put(key, val);
}
@@ -1384,6 +1561,44 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Void> putAsync(K key, V val) {
+ GridCacheGateway<K, V> gate = this.gate;
+
+ CacheOperationContext prev = onEnter(gate, opCtx);
+
+ try {
+ return createFuture(putAsync0(key, val));
+ }
+ finally {
+ onLeave(gate, prev);
+ }
+ }
+
+ /**
+ * Put async internal operation implementation.
+ *
+ * @param key Key.
+ * @param val Value.
+ * @return Internal future.
+ */
+ private IgniteInternalFuture<Void> putAsync0(K key, V val) {
+ IgniteInternalFuture<Boolean> fut = delegate.putAsync(key, val);
+
+ return fut.chain(new CX1<IgniteInternalFuture<Boolean>, Void>() {
+ @Override public Void applyx(IgniteInternalFuture<Boolean> fut1) throws IgniteCheckedException {
+ try {
+ fut1.get();
+ }
+ catch (RuntimeException e) {
+ throw new GridClosureException(e);
+ }
+
+ return null;
+ }
+ });
+ }
+
+ /** {@inheritDoc} */
@Override public V getAndPut(K key, V val) {
try {
GridCacheGateway<K, V> gate = this.gate;
@@ -1409,6 +1624,20 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<V> getAndPutAsync(K key, V val) {
+ GridCacheGateway<K, V> gate = this.gate;
+
+ CacheOperationContext prev = onEnter(gate, opCtx);
+
+ try {
+ return createFuture(delegate.getAndPutAsync(key, val));
+ }
+ finally {
+ onLeave(gate, prev);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public void putAll(Map<? extends K, ? extends V> map) {
try {
GridCacheGateway<K, V> gate = this.gate;
@@ -1431,6 +1660,20 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Void> putAllAsync(Map<? extends K, ? extends V> map) {
+ GridCacheGateway<K, V> gate = this.gate;
+
+ CacheOperationContext prev = onEnter(gate, opCtx);
+
+ try {
+ return (IgniteFuture<Void>)createFuture(delegate.putAllAsync(map));
+ }
+ finally {
+ onLeave(gate, prev);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public boolean putIfAbsent(K key, V val) {
try {
GridCacheGateway<K, V> gate = this.gate;
@@ -1456,6 +1699,20 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Boolean> putIfAbsentAsync(K key, V val) {
+ GridCacheGateway<K, V> gate = this.gate;
+
+ CacheOperationContext prev = onEnter(gate, opCtx);
+
+ try {
+ return createFuture(delegate.putIfAbsentAsync(key, val));
+ }
+ finally {
+ onLeave(gate, prev);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public boolean remove(K key) {
try {
GridCacheGateway<K, V> gate = this.gate;
@@ -1481,6 +1738,20 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Boolean> removeAsync(K key) {
+ GridCacheGateway<K, V> gate = this.gate;
+
+ CacheOperationContext prev = onEnter(gate, opCtx);
+
+ try {
+ return createFuture(delegate.removeAsync(key));
+ }
+ finally {
+ onLeave(gate, prev);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public boolean remove(K key, V oldVal) {
try {
GridCacheGateway<K, V> gate = this.gate;
@@ -1506,6 +1777,20 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Boolean> removeAsync(K key, V oldVal) {
+ GridCacheGateway<K, V> gate = this.gate;
+
+ CacheOperationContext prev = onEnter(gate, opCtx);
+
+ try {
+ return createFuture(delegate.removeAsync(key, oldVal));
+ }
+ finally {
+ onLeave(gate, prev);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public V getAndRemove(K key) {
try {
GridCacheGateway<K, V> gate = this.gate;
@@ -1531,6 +1816,20 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<V> getAndRemoveAsync(K key) {
+ GridCacheGateway<K, V> gate = this.gate;
+
+ CacheOperationContext prev = onEnter(gate, opCtx);
+
+ try {
+ return createFuture(delegate.getAndRemoveAsync(key));
+ }
+ finally {
+ onLeave(gate, prev);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public boolean replace(K key, V oldVal, V newVal) {
try {
GridCacheGateway<K, V> gate = this.gate;
@@ -1556,6 +1855,20 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Boolean> replaceAsync(K key, V oldVal, V newVal) {
+ GridCacheGateway<K, V> gate = this.gate;
+
+ CacheOperationContext prev = onEnter(gate, opCtx);
+
+ try {
+ return createFuture(delegate.replaceAsync(key, oldVal, newVal));
+ }
+ finally {
+ onLeave(gate, prev);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public boolean replace(K key, V val) {
try {
GridCacheGateway<K, V> gate = this.gate;
@@ -1581,6 +1894,20 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Boolean> replaceAsync(K key, V val) {
+ GridCacheGateway<K, V> gate = this.gate;
+
+ CacheOperationContext prev = onEnter(gate, opCtx);
+
+ try {
+ return createFuture(delegate.replaceAsync(key, val));
+ }
+ finally {
+ onLeave(gate, prev);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public V getAndReplace(K key, V val) {
try {
GridCacheGateway<K, V> gate = this.gate;
@@ -1606,6 +1933,20 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<V> getAndReplaceAsync(K key, V val) {
+ GridCacheGateway<K, V> gate = this.gate;
+
+ CacheOperationContext prev = onEnter(gate, opCtx);
+
+ try {
+ return createFuture(delegate.getAndReplaceAsync(key, val));
+ }
+ finally {
+ onLeave(gate, prev);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public void removeAll(Set<? extends K> keys) {
try {
GridCacheGateway<K, V> gate = this.gate;
@@ -1628,6 +1969,20 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Void> removeAllAsync(Set<? extends K> keys) {
+ GridCacheGateway<K, V> gate = this.gate;
+
+ CacheOperationContext prev = onEnter(gate, opCtx);
+
+ try {
+ return (IgniteFuture<Void>)createFuture(delegate.removeAllAsync(keys));
+ }
+ finally {
+ onLeave(gate, prev);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public void removeAll() {
GridCacheGateway<K, V> gate = this.gate;
@@ -1648,6 +2003,20 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Void> removeAllAsync() {
+ GridCacheGateway<K, V> gate = this.gate;
+
+ CacheOperationContext prev = onEnter(gate, opCtx);
+
+ try {
+ return (IgniteFuture<Void>)createFuture(delegate.removeAllAsync());
+ }
+ finally {
+ onLeave(gate, prev);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public void clear(K key) {
GridCacheGateway<K, V> gate = this.gate;
@@ -1668,6 +2037,20 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Void> clearAsync(K key) {
+ GridCacheGateway<K, V> gate = this.gate;
+
+ CacheOperationContext prev = onEnter(gate, opCtx);
+
+ try {
+ return (IgniteFuture<Void>)createFuture(delegate.clearAsync(key));
+ }
+ finally {
+ onLeave(gate, prev);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public void clearAll(Set<? extends K> keys) {
GridCacheGateway<K, V> gate = this.gate;
@@ -1688,6 +2071,20 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Void> clearAllAsync(Set<? extends K> keys) {
+ GridCacheGateway<K, V> gate = this.gate;
+
+ CacheOperationContext prev = onEnter(gate, opCtx);
+
+ try {
+ return (IgniteFuture<Void>)createFuture(delegate.clearAllAsync(keys));
+ }
+ finally {
+ onLeave(gate, prev);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public void clear() {
GridCacheGateway<K, V> gate = this.gate;
@@ -1708,6 +2105,20 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Void> clearAsync() {
+ GridCacheGateway<K, V> gate = this.gate;
+
+ CacheOperationContext prev = onEnter(gate, opCtx);
+
+ try {
+ return (IgniteFuture<Void>)createFuture(delegate.clearAsync());
+ }
+ finally {
+ onLeave(gate, prev);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public void localClear(K key) {
GridCacheGateway<K, V> gate = this.gate;
@@ -1746,23 +2157,7 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
try {
if (isAsync()) {
- IgniteInternalFuture<EntryProcessorResult<T>> fut = delegate.invokeAsync(key, entryProcessor, args);
-
- IgniteInternalFuture<T> fut0 = fut.chain(new CX1<IgniteInternalFuture<EntryProcessorResult<T>>, T>() {
- @Override public T applyx(IgniteInternalFuture<EntryProcessorResult<T>> fut)
- throws IgniteCheckedException {
- try {
- EntryProcessorResult<T> res = fut.get();
-
- return res != null ? res.get() : null;
- }
- catch (RuntimeException e) {
- throw new GridClosureException(e);
- }
- }
- });
-
- setFuture(fut0);
+ setFuture(invokeAsync0(key, entryProcessor, args));
return null;
}
@@ -1782,11 +2177,59 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/** {@inheritDoc} */
+ @Override public <T> IgniteFuture<T> invokeAsync(K key, EntryProcessor<K, V, T> entryProcessor,
+ Object... args) {
+ GridCacheGateway<K, V> gate = this.gate;
+
+ CacheOperationContext prev = onEnter(gate, opCtx);
+
+ try {
+ return createFuture(invokeAsync0(key, entryProcessor, args));
+ }
+ finally {
+ onLeave(gate, prev);
+ }
+ }
+
+ /**
+ * Invoke async operation internal implementation.
+ *
+ * @param key Key.
+ * @param entryProcessor Processor.
+ * @param args Arguments.
+ * @return Internal future.
+ */
+ private <T> IgniteInternalFuture<T> invokeAsync0(K key, EntryProcessor<K, V, T> entryProcessor, Object[] args) {
+ IgniteInternalFuture<EntryProcessorResult<T>> fut = delegate.invokeAsync(key, entryProcessor, args);
+
+ return fut.chain(new CX1<IgniteInternalFuture<EntryProcessorResult<T>>, T>() {
+ @Override public T applyx(IgniteInternalFuture<EntryProcessorResult<T>> fut1)
+ throws IgniteCheckedException {
+ try {
+ EntryProcessorResult<T> res = fut1.get();
+
+ return res != null ? res.get() : null;
+ }
+ catch (RuntimeException e) {
+ throw new GridClosureException(e);
+ }
+ }
+ });
+ }
+
+
+ /** {@inheritDoc} */
@Override public <T> T invoke(K key, CacheEntryProcessor<K, V, T> entryProcessor, Object... args)
throws EntryProcessorException {
return invoke(key, (EntryProcessor<K, V, T>)entryProcessor, args);
}
+ /** {@inheritDoc} */
+ @Override public <T> IgniteFuture<T> invokeAsync(K key, CacheEntryProcessor<K, V, T> entryProcessor,
+ Object... args) {
+ return invokeAsync(key, (EntryProcessor<K, V, T>)entryProcessor, args);
+ }
+
/**
* @param topVer Locked topology version.
* @param key Key.
@@ -1849,6 +2292,21 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/** {@inheritDoc} */
+ @Override public <T> IgniteFuture<Map<K, EntryProcessorResult<T>>> invokeAllAsync(Set<? extends K> keys,
+ EntryProcessor<K, V, T> entryProcessor, Object... args) {
+ GridCacheGateway<K, V> gate = this.gate;
+
+ CacheOperationContext prev = onEnter(gate, opCtx);
+
+ try {
+ return createFuture(delegate.invokeAllAsync(keys, entryProcessor, args));
+ }
+ finally {
+ onLeave(gate, prev);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public <T> Map<K, EntryProcessorResult<T>> invokeAll(Set<? extends K> keys,
CacheEntryProcessor<K, V, T> entryProcessor,
Object... args) {
@@ -1876,6 +2334,21 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/** {@inheritDoc} */
+ @Override public <T> IgniteFuture<Map<K, EntryProcessorResult<T>>> invokeAllAsync(Set<? extends K> keys,
+ CacheEntryProcessor<K, V, T> entryProcessor, Object... args) {
+ GridCacheGateway<K, V> gate = this.gate;
+
+ CacheOperationContext prev = onEnter(gate, opCtx);
+
+ try {
+ return createFuture(delegate.invokeAllAsync(keys, entryProcessor, args));
+ }
+ finally {
+ onLeave(gate, prev);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public <T> Map<K, EntryProcessorResult<T>> invokeAll(
Map<? extends K, ? extends EntryProcessor<K, V, T>> map,
Object... args) {
@@ -1903,6 +2376,21 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/** {@inheritDoc} */
+ @Override public <T> IgniteFuture<Map<K, EntryProcessorResult<T>>> invokeAllAsync(
+ Map<? extends K, ? extends EntryProcessor<K, V, T>> map, Object... args) {
+ GridCacheGateway<K, V> gate = this.gate;
+
+ CacheOperationContext prev = onEnter(gate, opCtx);
+
+ try {
+ return createFuture(delegate.invokeAllAsync(map, args));
+ }
+ finally {
+ onLeave(gate, prev);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public String getName() {
return delegate.name();
}
@@ -2109,6 +2597,7 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/**
+ * @param dataCenterId Data center ID.
* @return Projection for data center id.
*/
@SuppressWarnings("unchecked")
@@ -2186,7 +2675,12 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
* @param fut Future for async operation.
*/
private <R> void setFuture(IgniteInternalFuture<R> fut) {
- curFut.set(new IgniteCacheFutureImpl<>(fut));
+ curFut.set(createFuture(fut));
+ }
+
+ /** {@inheritDoc} */
+ @Override protected <R> IgniteFuture<R> createFuture(IgniteInternalFuture<R> fut) {
+ return new IgniteCacheFutureImpl<>(fut);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/282b334f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java
index 7a69a6f..ca4edb6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java
@@ -1394,6 +1394,11 @@ public abstract class GridCacheStoreManagerAdapter extends GridCacheManagerAdapt
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Void> commitAsync() throws IgniteException {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
@Override public void close() throws IgniteException {
throw new UnsupportedOperationException();
}
@@ -1404,6 +1409,11 @@ public abstract class GridCacheStoreManagerAdapter extends GridCacheManagerAdapt
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Void> rollbackAsync() throws IgniteException {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
@Override public IgniteAsyncSupport withAsync() {
throw new UnsupportedOperationException();
}