use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method submitCallableWithNullResultToAllMembers_withMultiExecutionCallback.
@Test
public void submitCallableWithNullResultToAllMembers_withMultiExecutionCallback() throws Exception {
IExecutorService service = client.getExecutorService(randomString());
final CountDownLatch responseLatch = new CountDownLatch(CLUSTER_SIZE);
final CountDownLatch completeLatch = new CountDownLatch(CLUSTER_SIZE);
Callable callable = new NullCallable();
service.submitToAllMembers(callable, new MultiExecutionCallback() {
public void onResponse(Member member, Object value) {
if (value == null) {
responseLatch.countDown();
}
}
public void onComplete(Map<Member, Object> values) {
for (Member member : values.keySet()) {
Object value = values.get(member);
if (value == null) {
completeLatch.countDown();
}
}
}
});
assertOpenEventually("responseLatch", responseLatch);
assertOpenEventually("completeLatch", completeLatch);
}
use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method testSubmitCallableToMembers.
@Test
public void testSubmitCallableToMembers() throws Exception {
IExecutorService service = client.getExecutorService(randomString());
Callable<String> getUuidCallable = new GetMemberUuidTask();
Collection<Member> collection = server.getCluster().getMembers();
Map<Member, Future<String>> map = service.submitToMembers(getUuidCallable, collection);
for (Member member : map.keySet()) {
Future<String> result = map.get(member);
String uuid = result.get();
assertEquals(member.getUuid(), uuid);
}
}
use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method submitCallableToKeyOwner_withExecutionCallback.
@Test
public void submitCallableToKeyOwner_withExecutionCallback() throws Exception {
IExecutorService service = client.getExecutorService(randomString());
String msg = randomString();
Callable<String> callable = new AppendCallable(msg);
final CountDownLatch responseLatch = new CountDownLatch(1);
final AtomicReference<String> result = new AtomicReference<String>();
service.submitToKeyOwner(callable, "key", 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());
}
use of com.hazelcast.core.IExecutorService 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.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());
}
Aggregations