use of com.hazelcast.durableexecutor.DurableExecutorService in project hazelcast by hazelcast.
the class ClientDurableExecutorServiceTest method testFullRingBuffer_WithExecutionCallback.
public void testFullRingBuffer_WithExecutionCallback() throws InterruptedException {
String key = randomString();
DurableExecutorService service = client.getDurableExecutorService(SINGLE_TASK + randomString());
service.submitToKeyOwner(new SleepingTask(100), key);
DurableExecutorServiceFuture<String> future = service.submitToKeyOwner(new BasicTestCallable(), key);
final CountDownLatch latch = new CountDownLatch(1);
future.andThen(new ExecutionCallback<String>() {
@Override
public void onResponse(String response) {
}
@Override
public void onFailure(Throwable t) {
if (t.getCause() instanceof RejectedExecutionException) {
latch.countDown();
}
}
});
assertOpenEventually(latch);
assertTrue(future.isDone());
assertFalse(future.cancel(true));
assertFalse(future.isCancelled());
}
use of com.hazelcast.durableexecutor.DurableExecutorService in project hazelcast by hazelcast.
the class ClientDurableExecutionDelayTest method runClient.
private void runClient(Task task, int executions) throws Exception {
ClientConfig clientConfig = new ClientConfig();
clientConfig.getNetworkConfig().setRedoOperation(true);
HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
DurableExecutorService executor = client.getDurableExecutorService("executor");
for (int i = 0; i < executions; i++) {
Future future = executor.submitToKeyOwner(task, i);
future.get();
Thread.sleep(100);
}
}
use of com.hazelcast.durableexecutor.DurableExecutorService in project hazelcast by hazelcast.
the class ClientDurableExecutorServiceExecuteTest method testExecuteOnKeyOwner.
@Test
public void testExecuteOnKeyOwner() {
DurableExecutorService service = client.getDurableExecutorService(randomString());
String mapName = randomString();
Member member = server.getCluster().getLocalMember();
final String targetUuid = member.getUuid();
String key = generateKeyOwnedBy(server);
service.executeOnKeyOwner(new MapPutRunnable(mapName), key);
final IMap map = client.getMap(mapName);
assertTrueEventually(new AssertTask() {
public void run() throws Exception {
assertTrue(map.containsKey(targetUuid));
}
});
}
use of com.hazelcast.durableexecutor.DurableExecutorService in project hazelcast by hazelcast.
the class ClientDurableExecutorServiceExecuteTest method testExecute_whenTaskNull.
@Test(expected = NullPointerException.class)
@SuppressWarnings("ConstantConditions")
public void testExecute_whenTaskNull() {
DurableExecutorService service = client.getDurableExecutorService(randomString());
service.execute(null);
}
use of com.hazelcast.durableexecutor.DurableExecutorService in project hazelcast by hazelcast.
the class ClientDurableExecutorServiceTest method testIsShutdown.
@Test
public void testIsShutdown() {
DurableExecutorService service = client.getDurableExecutorService(randomString());
assertFalse(service.isShutdown());
}
Aggregations