Search in sources :

Example 6 with AppendCallable

use of com.hazelcast.client.test.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());
    }
}
Also used : AppendCallable(com.hazelcast.client.test.executor.tasks.AppendCallable) Future(java.util.concurrent.Future) IExecutorService(com.hazelcast.core.IExecutorService) HazelcastTestSupport.randomString(com.hazelcast.test.HazelcastTestSupport.randomString) Member(com.hazelcast.cluster.Member) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 7 with AppendCallable

use of com.hazelcast.client.test.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());
}
Also used : AppendCallable(com.hazelcast.client.test.executor.tasks.AppendCallable) IExecutorService(com.hazelcast.core.IExecutorService) HazelcastTestSupport.randomString(com.hazelcast.test.HazelcastTestSupport.randomString) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 8 with AppendCallable

use of com.hazelcast.client.test.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());
}
Also used : MemberSelector(com.hazelcast.cluster.MemberSelector) AppendCallable(com.hazelcast.client.test.executor.tasks.AppendCallable) SelectAllMembers(com.hazelcast.client.test.executor.tasks.SelectAllMembers) IExecutorService(com.hazelcast.core.IExecutorService) HazelcastTestSupport.randomString(com.hazelcast.test.HazelcastTestSupport.randomString) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 9 with AppendCallable

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

Example 10 with AppendCallable

use of com.hazelcast.client.test.executor.tasks.AppendCallable in project hazelcast by hazelcast.

the class ClientExecutorServiceSubmitTest method testSubmitCallable.

@Test
public void testSubmitCallable() throws Exception {
    IExecutorService service = client.getExecutorService(randomString());
    String msg = randomString();
    Callable callable = new AppendCallable(msg);
    Future result = service.submit(callable);
    assertEquals(msg + AppendCallable.APPENDAGE, result.get());
}
Also used : AppendCallable(com.hazelcast.client.test.executor.tasks.AppendCallable) Future(java.util.concurrent.Future) IExecutorService(com.hazelcast.core.IExecutorService) HazelcastTestSupport.randomString(com.hazelcast.test.HazelcastTestSupport.randomString) NullCallable(com.hazelcast.client.test.executor.tasks.NullCallable) Callable(java.util.concurrent.Callable) AppendCallable(com.hazelcast.client.test.executor.tasks.AppendCallable) MapPutPartitionAwareCallable(com.hazelcast.client.test.executor.tasks.MapPutPartitionAwareCallable) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

AppendCallable (com.hazelcast.client.test.executor.tasks.AppendCallable)18 HazelcastTestSupport.randomString (com.hazelcast.test.HazelcastTestSupport.randomString)18 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)18 QuickTest (com.hazelcast.test.annotation.QuickTest)18 Test (org.junit.Test)18 IExecutorService (com.hazelcast.core.IExecutorService)14 Callable (java.util.concurrent.Callable)9 CountDownLatch (java.util.concurrent.CountDownLatch)8 MapPutPartitionAwareCallable (com.hazelcast.client.test.executor.tasks.MapPutPartitionAwareCallable)5 AtomicReference (java.util.concurrent.atomic.AtomicReference)5 NullCallable (com.hazelcast.client.test.executor.tasks.NullCallable)4 Member (com.hazelcast.cluster.Member)4 MultiExecutionCallback (com.hazelcast.core.MultiExecutionCallback)4 DurableExecutorService (com.hazelcast.durableexecutor.DurableExecutorService)4 ArrayList (java.util.ArrayList)4 Future (java.util.concurrent.Future)4 SelectAllMembers (com.hazelcast.client.test.executor.tasks.SelectAllMembers)3 MemberSelector (com.hazelcast.cluster.MemberSelector)3 ExecutionCallback (com.hazelcast.core.ExecutionCallback)1