use of com.hazelcast.spi.impl.InternalCompletableFuture in project hazelcast by hazelcast.
the class SmallClusterTest method executionCallback_notified.
@Test
public void executionCallback_notified() throws Exception {
IExecutorService executorService = instances[1].getExecutorService(randomString());
BasicTestCallable task = new BasicTestCallable();
String key = generateKeyOwnedBy(instances[0]);
InternalCompletableFuture<String> future = (InternalCompletableFuture<String>) executorService.submitToKeyOwner(task, key);
CountingDownExecutionCallback<String> callback = new CountingDownExecutionCallback<>(1);
future.whenCompleteAsync(callback);
future.get();
assertOpenEventually(callback.getLatch(), 10);
}
use of com.hazelcast.spi.impl.InternalCompletableFuture in project hazelcast by hazelcast.
the class ChainingFutureTest method testTopologyChangesExceptionsAreIgnored.
@Test
public void testTopologyChangesExceptionsAreIgnored() {
InternalCompletableFuture<Object> future1 = newFuture();
InternalCompletableFuture<Object> future2 = newFuture();
InternalCompletableFuture<Object> future3 = newFuture();
CountingIterator<InternalCompletableFuture<Object>> iterator = toIterator(future1, future2, future3);
ChainingFuture.ExceptionHandler handler = repairingIterator;
ChainingFuture<Object> future = new ChainingFuture<>(iterator, handler);
assertEquals(1, iterator.getHasNextCounter());
assertEquals(1, iterator.getNextCounter());
assertFalse(future.isDone());
future1.complete(new MemberLeftException("this should be ignored"));
assertEquals(2, iterator.getHasNextCounter());
assertEquals(2, iterator.getNextCounter());
assertFalse(future.isDone());
future2.complete(new TargetNotMemberException("this should be ignored"));
assertEquals(3, iterator.getHasNextCounter());
assertEquals(3, iterator.getNextCounter());
assertFalse(future.isDone());
future3.complete("foo");
assertTrue(future.isDone());
assertEquals(4, iterator.getHasNextCounter());
assertEquals(3, iterator.getNextCounter());
}
use of com.hazelcast.spi.impl.InternalCompletableFuture in project hazelcast by hazelcast.
the class ClientSessionManagerTest method testClientSessionManagerShutdown.
@Test
public void testClientSessionManagerShutdown() throws ExecutionException, InterruptedException {
AbstractProxySessionManager sessionManager = getSessionManager();
SessionProxyImpl proxy = new SessionProxyImpl(sessionManager, groupId);
proxy.createSession();
Map<RaftGroupId, InternalCompletableFuture<Object>> futures = sessionManager.shutdown();
assertEquals(1, futures.size());
Entry<RaftGroupId, InternalCompletableFuture<Object>> e = futures.entrySet().iterator().next();
assertEquals(groupId, e.getKey());
e.getValue().get();
exception.expect(IllegalStateException.class);
proxy.createSession();
}
use of com.hazelcast.spi.impl.InternalCompletableFuture in project hazelcast by hazelcast.
the class ClientInvocation_ExceptionTest method test.
@Test
public void test() throws Exception {
IExecutorService executorService = client.getExecutorService("test");
InternalCompletableFuture f = (InternalCompletableFuture) executorService.submit(new ExceptionThrowingCallable(exception));
assertCompletesEventually(f);
expected.expect(expectedExceptionClass);
expected.expectCause(exceptionCauseMatcher);
waitForFuture(f, futureSyncMethod);
}
use of com.hazelcast.spi.impl.InternalCompletableFuture in project hazelcast by hazelcast.
the class ClientCacheProxySupport method callPutAsync.
protected CompletableFuture callPutAsync(K key, Data keyData, V value, Data valueData, Data expiryPolicyData, boolean isGet, boolean withCompletionEvent, BiConsumer<V, Throwable> statsCallback) {
ClientInvocationFuture invocationFuture = putInternal(keyData, valueData, expiryPolicyData, isGet, withCompletionEvent);
InternalCompletableFuture future = newDelegatingFuture(invocationFuture, CachePutCodec::decodeResponse);
return addCallback(future, statsCallback);
}
Aggregations