use of com.hazelcast.durableexecutor.DurableExecutorService in project hazelcast by hazelcast.
the class ClientDurableExecutorServiceSubmitTest method submitCallablePartitionAware_WithExecutionCallback.
@Test
public void submitCallablePartitionAware_WithExecutionCallback() {
DurableExecutorService service = client.getDurableExecutorService(randomString());
String mapName = randomString();
IMap map = client.getMap(mapName);
String key = HazelcastTestSupport.generateKeyOwnedBy(server);
Member member = server.getCluster().getLocalMember();
Callable<String> runnable = new MapPutPartitionAwareCallable<String, String>(mapName, key);
final AtomicReference<String> result = new AtomicReference<String>();
final CountDownLatch responseLatch = new CountDownLatch(1);
service.submit(runnable).andThen(new ExecutionCallback<String>() {
public void onResponse(String response) {
result.set(response);
responseLatch.countDown();
}
public void onFailure(Throwable t) {
}
});
assertOpenEventually("responseLatch", responseLatch);
assertEquals(member.getUuid(), result.get());
assertTrue(map.containsKey(member.getUuid()));
}
use of com.hazelcast.durableexecutor.DurableExecutorService in project hazelcast by hazelcast.
the class ClientDurableExecutorServiceTest method testSubmitFailingCallableReasonExceptionCause.
@Test
public void testSubmitFailingCallableReasonExceptionCause() throws Exception {
DurableExecutorService service = client.getDurableExecutorService(randomString());
Future<String> future = service.submit(new FailingCallable());
expectedException.expect(new RootCauseMatcher(IllegalStateException.class));
future.get();
}
use of com.hazelcast.durableexecutor.DurableExecutorService in project hazelcast by hazelcast.
the class ClientDurableExecutorServiceTest method test_whenRingBufferIsFull_thenThrowRejectedExecutionException.
@Test
public void test_whenRingBufferIsFull_thenThrowRejectedExecutionException() throws Exception {
String key = randomString();
DurableExecutorService service = client.getDurableExecutorService(SINGLE_TASK + randomString());
service.submitToKeyOwner(new SleepingTask(100), key);
DurableExecutorServiceFuture<String> future = service.submitToKeyOwner(new BasicTestCallable(), key);
expectedException.expect(new RootCauseMatcher(RejectedExecutionException.class));
future.get();
}
use of com.hazelcast.durableexecutor.DurableExecutorService in project hazelcast by hazelcast.
the class ClientDurableExecutorServiceTest method testCallableSerializedOnce.
@Test
public void testCallableSerializedOnce() throws Exception {
String name = randomString();
DurableExecutorService service = client.getDurableExecutorService(name);
SerializedCounterCallable counterCallable = new SerializedCounterCallable();
Future future = service.submitToKeyOwner(counterCallable, name);
assertEquals(2, future.get());
}
use of com.hazelcast.durableexecutor.DurableExecutorService in project hazelcast by hazelcast.
the class ClientDurableExecutorServiceExecuteTest method testExecuteOnKeyOwner_whenKeyNull.
@Test(expected = NullPointerException.class)
public void testExecuteOnKeyOwner_whenKeyNull() {
DurableExecutorService service = client.getDurableExecutorService(randomString());
service.executeOnKeyOwner(new MapPutRunnable("map"), null);
}
Aggregations