use of com.hazelcast.client.test.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.test.executor.tasks.SelectAllMembers in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method submitRunnableToMembers_withExecutionCallback.
@Test
public void submitRunnableToMembers_withExecutionCallback() {
IExecutorService service = client.getExecutorService(randomString());
final CountDownLatch responseLatch = new CountDownLatch(CLUSTER_SIZE);
final CountDownLatch completeLatch = new CountDownLatch(1);
String mapName = randomString();
Runnable runnable = new MapPutRunnable(mapName);
MemberSelector selector = new SelectAllMembers();
service.submitToMembers(runnable, selector, new MultiExecutionCallback() {
public void onResponse(Member member, Object value) {
responseLatch.countDown();
}
public void onComplete(Map<Member, Object> values) {
completeLatch.countDown();
}
});
IMap map = client.getMap(mapName);
assertOpenEventually("responseLatch", responseLatch);
assertOpenEventually("completeLatch", completeLatch);
assertEquals(CLUSTER_SIZE, map.size());
}
use of com.hazelcast.client.test.executor.tasks.SelectAllMembers in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method submitCallable_withExecutionCallback.
@Test
public void submitCallable_withExecutionCallback() {
IExecutorService service = client.getExecutorService(randomString());
final CountDownLatch responseLatch = new CountDownLatch(1);
String msg = randomString();
Callable runnable = new AppendCallable(msg);
MemberSelector selector = new SelectAllMembers();
final AtomicReference<Object> result = new AtomicReference<Object>();
service.submit(runnable, selector, new ExecutionCallback() {
public void onResponse(Object response) {
result.set(response);
responseLatch.countDown();
}
public void onFailure(Throwable t) {
}
});
assertOpenEventually("responseLatch", responseLatch);
assertEquals(msg + AppendCallable.APPENDAGE, result.get());
}
Aggregations