use of com.hazelcast.core.ICompletableFuture in project hazelcast by hazelcast.
the class NearCachedClientMapProxy method submitToKeyInternal.
@Override
public ICompletableFuture submitToKeyInternal(Data keyData, EntryProcessor entryProcessor) {
ICompletableFuture future = super.submitToKeyInternal(keyData, entryProcessor);
invalidateNearCache(keyData);
return future;
}
use of com.hazelcast.core.ICompletableFuture in project hazelcast by hazelcast.
the class ExecutorServiceTest method test_registerCallback_multipleTimes_futureIsCompletedOnOtherNode.
@Test
public void test_registerCallback_multipleTimes_futureIsCompletedOnOtherNode() throws Exception {
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
HazelcastInstance instance1 = factory.newHazelcastInstance();
HazelcastInstance instance2 = factory.newHazelcastInstance();
assertTrue(instance1.getCountDownLatch("latch").trySetCount(1));
String name = randomString();
IExecutorService executorService = instance2.getExecutorService(name);
ICountDownLatchAwaitCallable task = new ICountDownLatchAwaitCallable("latch");
String key = generateKeyOwnedBy(instance1);
ICompletableFuture<Boolean> future = (ICompletableFuture<Boolean>) executorService.submitToKeyOwner(task, key);
CountDownLatch latch = new CountDownLatch(2);
CountingDownExecutionCallback<Boolean> callback = new CountingDownExecutionCallback<Boolean>(latch);
future.andThen(callback);
future.andThen(callback);
instance1.getCountDownLatch("latch").countDown();
assertTrue(future.get());
assertOpenEventually(latch, 10);
}
use of com.hazelcast.core.ICompletableFuture in project hazelcast by hazelcast.
the class ExecutorServiceTest method test_registerCallback_beforeFutureIsCompletedOnOtherNode.
@Test
public void test_registerCallback_beforeFutureIsCompletedOnOtherNode() throws Exception {
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
HazelcastInstance instance1 = factory.newHazelcastInstance();
HazelcastInstance instance2 = factory.newHazelcastInstance();
assertTrue(instance1.getCountDownLatch("latch").trySetCount(1));
String name = randomString();
IExecutorService executorService = instance2.getExecutorService(name);
ICountDownLatchAwaitCallable task = new ICountDownLatchAwaitCallable("latch");
String key = generateKeyOwnedBy(instance1);
ICompletableFuture<Boolean> future = (ICompletableFuture<Boolean>) executorService.submitToKeyOwner(task, key);
CountingDownExecutionCallback<Boolean> callback = new CountingDownExecutionCallback<Boolean>(1);
future.andThen(callback);
instance1.getCountDownLatch("latch").countDown();
assertTrue(future.get());
assertOpenEventually(callback.getLatch());
}
use of com.hazelcast.core.ICompletableFuture in project hazelcast by hazelcast.
the class ClientCancellableDelegatingFuture method waitForRequestToBeSend.
protected void waitForRequestToBeSend() throws InterruptedException {
ICompletableFuture future = getFuture();
ClientInvocationFuture clientCallFuture = (ClientInvocationFuture) future;
clientCallFuture.getInvocation().getSendConnectionOrWait();
}
use of com.hazelcast.core.ICompletableFuture in project hazelcast by hazelcast.
the class DelegatingFutureTest method test_andThen_Object.
@Test
public void test_andThen_Object() {
Object value = "value";
ICompletableFuture future = new DelegatingFuture(new FakeCompletableFuture(value), null);
TestExecutionCallback callback = new TestExecutionCallback();
future.andThen(callback, new CallerRunsExecutor());
assertEquals(value, callback.value);
}
Aggregations