use of com.hazelcast.durableexecutor.DurableExecutorService in project hazelcast by hazelcast.
the class ClientDurableExecutorServiceSubmitTest method submitRunnablePartitionAware_withResult.
@Test
public void submitRunnablePartitionAware_withResult() throws Exception {
DurableExecutorService service = client.getDurableExecutorService(randomString());
String expectedResult = "result";
String mapName = randomString();
String key = HazelcastTestSupport.generateKeyOwnedBy(server);
final Member member = server.getCluster().getLocalMember();
Runnable runnable = new MapPutPartitionAwareRunnable<String>(mapName, key);
Future result = service.submit(runnable, expectedResult);
final IMap map = client.getMap(mapName);
assertEquals(expectedResult, result.get());
assertTrueEventually(new AssertTask() {
public void run() throws Exception {
assertTrue(map.containsKey(member.getUuid()));
}
});
}
use of com.hazelcast.durableexecutor.DurableExecutorService in project hazelcast by hazelcast.
the class ClientDurableExecutorServiceSubmitTest method testSubmitCallableNullTask.
@Test(expected = NullPointerException.class)
@SuppressWarnings("ConstantConditions")
public void testSubmitCallableNullTask() {
DurableExecutorService service = client.getDurableExecutorService(randomString());
Callable callable = null;
service.submit(callable);
}
use of com.hazelcast.durableexecutor.DurableExecutorService in project hazelcast by hazelcast.
the class ClientDurableExecutorServiceSubmitTest method submitRunnablePartitionAware.
@Test
public void submitRunnablePartitionAware() {
DurableExecutorService service = client.getDurableExecutorService(randomString());
String mapName = randomString();
String key = HazelcastTestSupport.generateKeyOwnedBy(server);
final Member member = server.getCluster().getLocalMember();
// this task should execute on a node owning the given key argument,
// the action is to put the UUid of the executing node into a map with the given name
Runnable runnable = new MapPutPartitionAwareRunnable<String>(mapName, key);
service.submit(runnable);
final IMap map = client.getMap(mapName);
assertTrueEventually(new AssertTask() {
public void run() throws Exception {
assertTrue(map.containsKey(member.getUuid()));
}
});
}
use of com.hazelcast.durableexecutor.DurableExecutorService in project hazelcast by hazelcast.
the class ClientDurableExecutorServiceSubmitTest method submitCallableToKeyOwner_withExecutionCallback.
@Test
public void submitCallableToKeyOwner_withExecutionCallback() {
DurableExecutorService service = client.getDurableExecutorService(randomString());
String msg = randomString();
Callable<String> callable = new AppendCallable(msg);
final CountDownLatch responseLatch = new CountDownLatch(1);
final AtomicReference<String> result = new AtomicReference<String>();
service.submitToKeyOwner(callable, "key").andThen(new ExecutionCallback<String>() {
public void onResponse(String response) {
result.set(response);
responseLatch.countDown();
}
public void onFailure(Throwable t) {
}
});
assertOpenEventually("responseLatch", responseLatch);
assertEquals(msg + AppendCallable.APPENDAGE, result.get());
}
use of com.hazelcast.durableexecutor.DurableExecutorService in project hazelcast by hazelcast.
the class ClientDurableExecutorServiceSubmitTest method testSubmitCallable.
@Test
public void testSubmitCallable() throws Exception {
DurableExecutorService service = client.getDurableExecutorService(randomString());
String msg = randomString();
Callable callable = new AppendCallable(msg);
Future result = service.submit(callable);
assertEquals(msg + AppendCallable.APPENDAGE, result.get());
}
Aggregations