use of com.hazelcast.client.executor.tasks.SelectAllMembers in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method submitCallableToMembers_withExecutionCallback.
@Test
public void submitCallableToMembers_withExecutionCallback() {
IExecutorService service = client.getExecutorService(randomString());
final CountDownLatch responseLatch = new CountDownLatch(CLUSTER_SIZE);
final CountDownLatch completeLatch = new CountDownLatch(1);
final String msg = randomString();
Callable callable = new AppendCallable(msg);
MemberSelector selector = new SelectAllMembers();
service.submitToMembers(callable, selector, new MultiExecutionCallback() {
public void onResponse(Member member, Object value) {
if (value.equals(msg + AppendCallable.APPENDAGE)) {
responseLatch.countDown();
}
}
public void onComplete(Map<Member, Object> values) {
completeLatch.countDown();
}
});
assertOpenEventually("responseLatch", responseLatch);
assertOpenEventually("completeLatch", completeLatch);
}
use of com.hazelcast.client.executor.tasks.SelectAllMembers 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.client.executor.tasks.SelectAllMembers 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);
}
}
use of com.hazelcast.client.executor.tasks.SelectAllMembers in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method submitRunnable_withExecutionCallback.
@Test
public void submitRunnable_withExecutionCallback() {
IExecutorService service = client.getExecutorService(randomString());
final CountDownLatch responseLatch = new CountDownLatch(1);
String mapName = randomString();
Runnable runnable = new MapPutRunnable(mapName);
MemberSelector selector = new SelectAllMembers();
service.submit(runnable, selector, 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.client.executor.tasks.SelectAllMembers in project hazelcast by hazelcast.
the class ClientExecutorServiceExecuteTest method testExecute_withMemberSelector.
@Test
public void testExecute_withMemberSelector() {
IExecutorService service = client.getExecutorService(randomString());
String mapName = randomString();
MemberSelector selector = new SelectAllMembers();
service.execute(new MapPutRunnable(mapName), selector);
IMap map = client.getMap(mapName);
assertSizeEventually(1, map);
}
Aggregations