use of com.hazelcast.client.executor.tasks.AppendCallable 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());
}
use of com.hazelcast.client.executor.tasks.AppendCallable in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method submitCallableToAllMembers_withMultiExecutionCallback.
@Test
public void submitCallableToAllMembers_withMultiExecutionCallback() throws Exception {
IExecutorService service = client.getExecutorService(randomString());
final CountDownLatch responseLatch = new CountDownLatch(CLUSTER_SIZE);
final CountDownLatch completeLatch = new CountDownLatch(CLUSTER_SIZE);
final String msg = randomString();
Callable callable = new AppendCallable(msg);
service.submitToAllMembers(callable, new MultiExecutionCallback() {
public void onResponse(Member member, Object value) {
if (value.equals(msg + AppendCallable.APPENDAGE)) {
responseLatch.countDown();
}
}
public void onComplete(Map<Member, Object> values) {
for (Member member : values.keySet()) {
Object value = values.get(member);
if (value.equals(msg + AppendCallable.APPENDAGE)) {
completeLatch.countDown();
}
}
}
});
assertOpenEventually("responseLatch", responseLatch);
assertOpenEventually("completeLatch", completeLatch);
}
use of com.hazelcast.client.executor.tasks.AppendCallable in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method testSubmitCallable_withExecutionCallback.
@Test
public void testSubmitCallable_withExecutionCallback() throws Exception {
IExecutorService service = client.getExecutorService(randomString());
String msg = randomString();
Callable<String> callable = new AppendCallable(msg);
final AtomicReference<String> result = new AtomicReference<String>();
final CountDownLatch responseLatch = new CountDownLatch(1);
service.submit(callable, new ExecutionCallback<String>() {
public void onResponse(String response) {
result.set(response);
responseLatch.countDown();
}
public void onFailure(Throwable t) {
}
});
assertOpenEventually("responseLatch", responseLatch);
assertEquals(msg + AppendCallable.APPENDAGE, result.get());
}
Aggregations