use of com.hazelcast.client.executor.tasks.AppendCallable in project hazelcast by hazelcast.
the class ClientDurableExecutorServiceSubmitTest method submitCallableToKeyOwner.
@Test
public void submitCallableToKeyOwner() throws Exception {
DurableExecutorService service = client.getDurableExecutorService(randomString());
String msg = randomString();
Callable<String> callable = new AppendCallable(msg);
Future<String> result = service.submitToKeyOwner(callable, "key");
assertEquals(msg + AppendCallable.APPENDAGE, result.get());
}
use of com.hazelcast.client.executor.tasks.AppendCallable in project hazelcast by hazelcast.
the class ClientDurableExecutorServiceSubmitTest method testSubmitCallable_withExecutionCallback.
@Test
public void testSubmitCallable_withExecutionCallback() {
DurableExecutorService service = client.getDurableExecutorService(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).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());
}
use of com.hazelcast.client.executor.tasks.AppendCallable in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method submitCallableToKeyOwner.
@Test
public void submitCallableToKeyOwner() throws Exception {
IExecutorService service = client.getExecutorService(randomString());
String msg = randomString();
Callable<String> callable = new AppendCallable(msg);
Future<String> result = service.submitToKeyOwner(callable, "key");
assertEquals(msg + AppendCallable.APPENDAGE, result.get());
}
use of com.hazelcast.client.executor.tasks.AppendCallable 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.client.executor.tasks.AppendCallable 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);
}
Aggregations