use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method submitRunnable_withExecutionCallback.
@Test
public void submitRunnable_withExecutionCallback() {
IExecutorService service = client.getExecutorService(randomString());
final CountDownLatch responseLatch = new CountDownLatch(1);
String mapName = randomString();
Runnable runnable = new MapPutRunnable(mapName);
MemberSelector selector = new SelectAllMembers();
service.submit(runnable, selector, new ExecutionCallback() {
public void onResponse(Object response) {
responseLatch.countDown();
}
public void onFailure(Throwable t) {
}
});
IMap map = client.getMap(mapName);
assertOpenEventually("responseLatch", responseLatch);
assertEquals(1, map.size());
}
use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class ClientExecutorServiceTest method testGetFutureAfterCancel.
@Test(expected = CancellationException.class)
public void testGetFutureAfterCancel() throws InterruptedException, ExecutionException, TimeoutException {
IExecutorService service = client.getExecutorService(randomString());
CancellationAwareTask task = new CancellationAwareTask(Long.MAX_VALUE);
Future future = service.submit(task);
try {
future.get(1, TimeUnit.SECONDS);
} catch (TimeoutException ignored) {
}
future.cancel(true);
future.get();
}
use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class ClientExecutorServiceTest method testSubmitFailingCallableReasonExceptionCause.
@Test(expected = IllegalStateException.class)
public void testSubmitFailingCallableReasonExceptionCause() throws Throwable {
IExecutorService service = client.getExecutorService(randomString());
Future<String> failingFuture = service.submit(new FailingCallable());
try {
failingFuture.get();
} catch (ExecutionException e) {
throw e.getCause();
}
}
use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class ClientExecutorServiceTest method testShutdownMultipleTimes.
@Test
public void testShutdownMultipleTimes() throws InterruptedException, ExecutionException, TimeoutException {
final IExecutorService service = client.getExecutorService(randomString());
service.shutdownNow();
service.shutdown();
assertTrueEventually(new AssertTask() {
public void run() throws Exception {
assertTrue(service.isShutdown());
}
});
}
use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class ClientExecutorServiceTest method testCallableSerializedOnce_submitToAddress.
@Test
public void testCallableSerializedOnce_submitToAddress() throws ExecutionException, InterruptedException {
String name = randomString();
IExecutorService service = client.getExecutorService(name);
SerializedCounterCallable counterCallable = new SerializedCounterCallable();
Future future = service.submitToMember(counterCallable, instance.getCluster().getLocalMember());
assertEquals(2, future.get());
}
Aggregations