Search in sources :

Example 1 with NullCallable

use of com.hazelcast.client.executor.tasks.NullCallable 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);
}
Also used : MultiExecutionCallback(com.hazelcast.core.MultiExecutionCallback) NullCallable(com.hazelcast.client.executor.tasks.NullCallable) IExecutorService(com.hazelcast.core.IExecutorService) CountDownLatch(java.util.concurrent.CountDownLatch) Member(com.hazelcast.core.Member) NullCallable(com.hazelcast.client.executor.tasks.NullCallable) Callable(java.util.concurrent.Callable) MapPutPartitionAwareCallable(com.hazelcast.client.executor.tasks.MapPutPartitionAwareCallable) AppendCallable(com.hazelcast.client.executor.tasks.AppendCallable) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

AppendCallable (com.hazelcast.client.executor.tasks.AppendCallable)1 MapPutPartitionAwareCallable (com.hazelcast.client.executor.tasks.MapPutPartitionAwareCallable)1 NullCallable (com.hazelcast.client.executor.tasks.NullCallable)1 IExecutorService (com.hazelcast.core.IExecutorService)1 Member (com.hazelcast.core.Member)1 MultiExecutionCallback (com.hazelcast.core.MultiExecutionCallback)1 ParallelTest (com.hazelcast.test.annotation.ParallelTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 Callable (java.util.concurrent.Callable)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Test (org.junit.Test)1