use of com.hazelcast.core.MultiExecutionCallback in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method testSubmitToMembersSerializesTheTaskOnlyOnce_withSelectorAndCallback.
@Test
public void testSubmitToMembersSerializesTheTaskOnlyOnce_withSelectorAndCallback() throws InterruptedException {
IExecutorService executorService = client.getExecutorService(randomName());
ExecutorServiceTestSupport.SerializationCountingCallable countingCallable = new ExecutorServiceTestSupport.SerializationCountingCallable();
CountDownLatch complete = new CountDownLatch(1);
executorService.submitToMembers(countingCallable, MemberSelectors.DATA_MEMBER_SELECTOR, new MultiExecutionCallback() {
@Override
public void onResponse(Member member, Object value) {
}
@Override
public void onComplete(Map<Member, Object> values) {
complete.countDown();
}
});
complete.await();
assertEquals(1, countingCallable.getSerializationCount());
}
use of com.hazelcast.core.MultiExecutionCallback in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method testSubmitToMembersSerializesTheTaskOnlyOnce_withCollectionAndCallback.
@Test
public void testSubmitToMembersSerializesTheTaskOnlyOnce_withCollectionAndCallback() throws InterruptedException {
IExecutorService executorService = client.getExecutorService(randomName());
ExecutorServiceTestSupport.SerializationCountingCallable countingCallable = new ExecutorServiceTestSupport.SerializationCountingCallable();
CountDownLatch complete = new CountDownLatch(1);
executorService.submitToMembers(countingCallable, client.getCluster().getMembers(), new MultiExecutionCallback() {
@Override
public void onResponse(Member member, Object value) {
}
@Override
public void onComplete(Map<Member, Object> values) {
complete.countDown();
}
});
complete.await();
assertEquals(1, countingCallable.getSerializationCount());
}
use of com.hazelcast.core.MultiExecutionCallback in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method submitRunnableToMembers_withMultiExecutionCallback.
@Test
public void submitRunnableToMembers_withMultiExecutionCallback() {
IExecutorService service = client.getExecutorService(randomString());
String mapName = randomString();
Runnable runnable = new MapPutRunnable(mapName);
Collection<Member> collection = server.getCluster().getMembers();
final CountDownLatch responseLatch = new CountDownLatch(CLUSTER_SIZE);
final CountDownLatch completeLatch = new CountDownLatch(1);
service.submitToMembers(runnable, collection, new MultiExecutionCallback() {
public void onResponse(Member member, Object value) {
responseLatch.countDown();
}
public void onComplete(Map<Member, Object> values) {
completeLatch.countDown();
}
});
Map map = client.getMap(mapName);
assertOpenEventually("responseLatch", responseLatch);
assertOpenEventually("completeLatch", completeLatch);
assertEquals(CLUSTER_SIZE, map.size());
}
use of com.hazelcast.core.MultiExecutionCallback in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method testSubmitToAllMembersSerializesTheTaskOnlyOnce_withCallback.
@Test
public void testSubmitToAllMembersSerializesTheTaskOnlyOnce_withCallback() throws InterruptedException {
IExecutorService executorService = client.getExecutorService(randomName());
ExecutorServiceTestSupport.SerializationCountingCallable countingCallable = new ExecutorServiceTestSupport.SerializationCountingCallable();
CountDownLatch complete = new CountDownLatch(1);
executorService.submitToAllMembers(countingCallable, new MultiExecutionCallback() {
@Override
public void onResponse(Member member, Object value) {
}
@Override
public void onComplete(Map<Member, Object> values) {
complete.countDown();
}
});
complete.await();
assertEquals(1, countingCallable.getSerializationCount());
}
use of com.hazelcast.core.MultiExecutionCallback in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method submitRunnableToAllMembers_withMultiExecutionCallback.
@Test
public void submitRunnableToAllMembers_withMultiExecutionCallback() {
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);
service.submitToAllMembers(runnable, 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());
}
Aggregations