use of com.hazelcast.client.executor.tasks.AppendCallable 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.AppendCallable 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.client.executor.tasks.AppendCallable in project hazelcast by hazelcast.
the class ClientExecutorServiceInvokeTest method testInvokeAll_withTimeOut.
@Test(expected = UnsupportedOperationException.class)
public void testInvokeAll_withTimeOut() throws Throwable {
IExecutorService service = client.getExecutorService(randomString());
Collection<Callable<String>> collection = new ArrayList<Callable<String>>();
collection.add(new AppendCallable());
collection.add(new AppendCallable());
service.invokeAll(collection, 1, TimeUnit.MINUTES);
}
use of com.hazelcast.client.executor.tasks.AppendCallable in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method submitCallableToMember_withMultiExecutionCallback.
@Test
public void submitCallableToMember_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<String> callable = new AppendCallable(msg);
Collection<Member> collection = server.getCluster().getMembers();
service.submitToMembers(callable, collection, 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 ClientDurableExecutorServiceSubmitTest method submitCallableToKeyOwner_withExecutionCallback.
@Test
public void submitCallableToKeyOwner_withExecutionCallback() {
DurableExecutorService service = client.getDurableExecutorService(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").andThen(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