use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method testSubmitRunnable_withExecutionCallback.
@Test
public void testSubmitRunnable_withExecutionCallback() throws Exception {
IExecutorService service = client.getExecutorService(randomString());
String mapName = randomString();
Runnable runnable = new MapPutRunnable(mapName);
final CountDownLatch responseLatch = new CountDownLatch(1);
service.submit(runnable, 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 ClientExecutorServiceSubmitTest method submitRunnable.
@Test
public void submitRunnable() {
IExecutorService service = client.getExecutorService(randomString());
String mapName = randomString();
Runnable runnable = new MapPutRunnable(mapName);
service.submit(runnable);
IMap map = client.getMap(mapName);
assertSizeEventually(1, map);
}
use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method submitRunnablePartitionAware.
@Test
public void submitRunnablePartitionAware() throws Exception {
IExecutorService service = client.getExecutorService(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.core.IExecutorService in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method submitRunnablePartitionAware_withResult.
@Test
public void submitRunnablePartitionAware_withResult() throws Exception {
IExecutorService service = client.getExecutorService(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.core.IExecutorService in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method submitCallableToKeyOwner.
@Test
public void submitCallableToKeyOwner() throws Exception {
IExecutorService service = client.getExecutorService(randomString());
String msg = randomString();
Callable<String> callable = new AppendCallable(msg);
Future<String> result = service.submitToKeyOwner(callable, "key");
assertEquals(msg + AppendCallable.APPENDAGE, result.get());
}
Aggregations