use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method testSubmitCallable_withMemberSelector.
@Test
public void testSubmitCallable_withMemberSelector() throws Exception {
IExecutorService service = client.getExecutorService(randomString());
String msg = randomString();
Callable<String> callable = new AppendCallable(msg);
MemberSelector selectAll = new SelectAllMembers();
Future<String> f = service.submit(callable, selectAll);
assertEquals(msg + AppendCallable.APPENDAGE, f.get());
}
use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method submitCallableToAllMembers.
@Test
public void submitCallableToAllMembers() throws Exception {
IExecutorService service = client.getExecutorService(randomString());
String msg = randomString();
Callable<String> callable = new AppendCallable(msg);
Map<Member, Future<String>> map = service.submitToAllMembers(callable);
for (Member member : map.keySet()) {
Future<String> result = map.get(member);
assertEquals(msg + AppendCallable.APPENDAGE, result.get());
}
}
use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method testSubmitRunnable_WithResult.
@Test
public void testSubmitRunnable_WithResult() throws ExecutionException, InterruptedException {
IExecutorService service = client.getExecutorService(randomString());
String mapName = randomString();
Object givenResult = "givenResult";
Future future = service.submit(new MapPutRunnable(mapName), givenResult);
Object result = future.get();
IMap map = client.getMap(mapName);
assertEquals(givenResult, result);
assertEquals(1, map.size());
}
use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method submitCallablePartitionAware_WithExecutionCallback.
@Test
public void submitCallablePartitionAware_WithExecutionCallback() throws Exception {
IExecutorService service = client.getExecutorService(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, 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.core.IExecutorService in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method submitCallablePartitionAware.
@Test
public void submitCallablePartitionAware() throws Exception {
IExecutorService service = client.getExecutorService(randomString());
String mapName = randomString();
IMap map = client.getMap(mapName);
String key = HazelcastTestSupport.generateKeyOwnedBy(server);
Member member = server.getCluster().getLocalMember();
Callable<String> callable = new MapPutPartitionAwareCallable<String, String>(mapName, key);
Future<String> result = service.submit(callable);
assertEquals(member.getUuid(), result.get());
assertTrue(map.containsKey(member.getUuid()));
}
Aggregations