Search in sources :

Example 1 with SelectAllMembers

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

the class ClientExecutorServiceExecuteTest method testExecuteOnMembers_withSelector.

@Test
public void testExecuteOnMembers_withSelector() {
    IExecutorService service = client.getExecutorService(randomString());
    String mapName = randomString();
    MemberSelector selector = new SelectAllMembers();
    service.executeOnMembers(new MapPutRunnable(mapName), selector);
    IMap map = client.getMap(mapName);
    assertSizeEventually(CLUSTER_SIZE, map);
}
Also used : IMap(com.hazelcast.map.IMap) MemberSelector(com.hazelcast.cluster.MemberSelector) MapPutRunnable(com.hazelcast.client.executor.tasks.MapPutRunnable) 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 2 with SelectAllMembers

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

the class ClientExecutorServiceExecuteTest method testExecute_withMemberSelector.

@Test
public void testExecute_withMemberSelector() {
    IExecutorService service = client.getExecutorService(randomString());
    String mapName = randomString();
    MemberSelector selector = new SelectAllMembers();
    service.execute(new MapPutRunnable(mapName), selector);
    IMap map = client.getMap(mapName);
    assertSizeEventually(1, map);
}
Also used : IMap(com.hazelcast.map.IMap) MemberSelector(com.hazelcast.cluster.MemberSelector) MapPutRunnable(com.hazelcast.client.executor.tasks.MapPutRunnable) 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 3 with SelectAllMembers

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

the class ClientExecutorServiceSubmitTest method testSubmitCallableToMembers_withMemberSelector.

@Test
public void testSubmitCallableToMembers_withMemberSelector() throws Exception {
    IExecutorService service = client.getExecutorService(randomString());
    Callable<UUID> getUuidCallable = new GetMemberUuidTask();
    MemberSelector selectAll = new SelectAllMembers();
    Map<Member, Future<UUID>> map = service.submitToMembers(getUuidCallable, selectAll);
    for (Member member : map.keySet()) {
        Future<UUID> result = map.get(member);
        UUID uuid = result.get();
        assertEquals(member.getUuid(), uuid);
    }
}
Also used : GetMemberUuidTask(com.hazelcast.client.test.executor.tasks.GetMemberUuidTask) MemberSelector(com.hazelcast.cluster.MemberSelector) SelectAllMembers(com.hazelcast.client.test.executor.tasks.SelectAllMembers) Future(java.util.concurrent.Future) IExecutorService(com.hazelcast.core.IExecutorService) UUID(java.util.UUID) Member(com.hazelcast.cluster.Member) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 4 with SelectAllMembers

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

the class ClientExecutorServiceSubmitTest method submitRunnable_withExecutionCallback.

@Test
public void submitRunnable_withExecutionCallback() {
    IExecutorService service = client.getExecutorService(randomString());
    final CountDownLatch responseLatch = new CountDownLatch(1);
    String mapName = randomString();
    Runnable runnable = new MapPutRunnable(mapName);
    MemberSelector selector = new SelectAllMembers();
    service.submit(runnable, selector, new ExecutionCallback() {

        public void onResponse(Object response) {
            responseLatch.countDown();
        }

        public void onFailure(Throwable t) {
        }
    });
    IMap map = client.getMap(mapName);
    assertOpenEventually("responseLatch", responseLatch);
    assertEquals(1, map.size());
}
Also used : IMap(com.hazelcast.map.IMap) MemberSelector(com.hazelcast.cluster.MemberSelector) MapPutPartitionAwareRunnable(com.hazelcast.client.executor.tasks.MapPutPartitionAwareRunnable) MapPutRunnable(com.hazelcast.client.executor.tasks.MapPutRunnable) MapPutRunnable(com.hazelcast.client.executor.tasks.MapPutRunnable) 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) MultiExecutionCallback(com.hazelcast.core.MultiExecutionCallback) ExecutionCallback(com.hazelcast.core.ExecutionCallback) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 5 with SelectAllMembers

use of com.hazelcast.client.test.executor.tasks.SelectAllMembers 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)

Aggregations

SelectAllMembers (com.hazelcast.client.test.executor.tasks.SelectAllMembers)8 MemberSelector (com.hazelcast.cluster.MemberSelector)8 IExecutorService (com.hazelcast.core.IExecutorService)8 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)8 QuickTest (com.hazelcast.test.annotation.QuickTest)8 Test (org.junit.Test)8 HazelcastTestSupport.randomString (com.hazelcast.test.HazelcastTestSupport.randomString)7 MapPutRunnable (com.hazelcast.client.executor.tasks.MapPutRunnable)4 MultiExecutionCallback (com.hazelcast.core.MultiExecutionCallback)4 IMap (com.hazelcast.map.IMap)4 CountDownLatch (java.util.concurrent.CountDownLatch)4 AppendCallable (com.hazelcast.client.test.executor.tasks.AppendCallable)3 Member (com.hazelcast.cluster.Member)3 MapPutPartitionAwareRunnable (com.hazelcast.client.executor.tasks.MapPutPartitionAwareRunnable)2 MapPutPartitionAwareCallable (com.hazelcast.client.test.executor.tasks.MapPutPartitionAwareCallable)2 NullCallable (com.hazelcast.client.test.executor.tasks.NullCallable)2 ExecutionCallback (com.hazelcast.core.ExecutionCallback)2 Callable (java.util.concurrent.Callable)2 GetMemberUuidTask (com.hazelcast.client.test.executor.tasks.GetMemberUuidTask)1 UUID (java.util.UUID)1