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()));
}
use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method testSubmitCallableToMembers_withMemberSelector.
@Test
public void testSubmitCallableToMembers_withMemberSelector() throws Exception {
IExecutorService service = client.getExecutorService(randomString());
Callable<String> getUuidCallable = new GetMemberUuidTask();
MemberSelector selectAll = new SelectAllMembers();
Map<Member, Future<String>> map = service.submitToMembers(getUuidCallable, selectAll);
for (Member member : map.keySet()) {
Future<String> result = map.get(member);
String uuid = result.get();
assertEquals(member.getUuid(), uuid);
}
}
Aggregations