Search in sources :

Example 26 with MapPutRunnable

use of com.hazelcast.client.executor.tasks.MapPutRunnable in project hazelcast by hazelcast.

the class ClientExecutorServiceExecuteTest method testExecuteOnMembers.

@Test
public void testExecuteOnMembers() {
    IExecutorService service = client.getExecutorService(randomString());
    String mapName = randomString();
    Collection<Member> collection = new ArrayList<Member>();
    final Member member1 = server1.getCluster().getLocalMember();
    final Member member2 = server2.getCluster().getLocalMember();
    collection.add(member1);
    collection.add(member2);
    service.executeOnMembers(new MapPutRunnable(mapName), collection);
    final IMap map = client.getMap(mapName);
    assertTrueEventually(() -> {
        assertTrue(map.containsKey(member1.getUuid()));
        assertTrue(map.containsKey(member2.getUuid()));
    });
}
Also used : IMap(com.hazelcast.map.IMap) ArrayList(java.util.ArrayList) MapPutRunnable(com.hazelcast.client.executor.tasks.MapPutRunnable) 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 27 with MapPutRunnable

use of com.hazelcast.client.executor.tasks.MapPutRunnable in project hazelcast by hazelcast.

the class ClientExecutorServiceExecuteTest method testExecuteOnMembers_whenSelectorNull.

@Test(expected = NullPointerException.class)
public void testExecuteOnMembers_whenSelectorNull() {
    IExecutorService service = client.getExecutorService(randomString());
    MemberSelector selector = null;
    service.executeOnMembers(new MapPutRunnable("task"), selector);
}
Also used : MemberSelector(com.hazelcast.cluster.MemberSelector) MapPutRunnable(com.hazelcast.client.executor.tasks.MapPutRunnable) IExecutorService(com.hazelcast.core.IExecutorService) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 28 with MapPutRunnable

use of com.hazelcast.client.executor.tasks.MapPutRunnable in project hazelcast by hazelcast.

the class ClientExecutorServiceExecuteTest method testExecuteOnMembers_WhenCollectionNull.

@Test(expected = NullPointerException.class)
public void testExecuteOnMembers_WhenCollectionNull() {
    IExecutorService service = client.getExecutorService(randomString());
    Collection<Member> collection = null;
    service.executeOnMembers(new MapPutRunnable("task"), collection);
}
Also used : MapPutRunnable(com.hazelcast.client.executor.tasks.MapPutRunnable) IExecutorService(com.hazelcast.core.IExecutorService) Member(com.hazelcast.cluster.Member) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 29 with MapPutRunnable

use of com.hazelcast.client.executor.tasks.MapPutRunnable in project hazelcast by hazelcast.

the class ClientExecutorServiceTest method testExecute_withNoMemberSelected.

@Test(expected = RejectedExecutionException.class)
public void testExecute_withNoMemberSelected() {
    IExecutorService service = client.getExecutorService(randomString());
    String mapName = randomString();
    MemberSelector selector = new SelectNoMembers();
    service.execute(new MapPutRunnable(mapName), selector);
}
Also used : SelectNoMembers(com.hazelcast.client.test.executor.tasks.SelectNoMembers) MemberSelector(com.hazelcast.cluster.MemberSelector) MapPutRunnable(com.hazelcast.client.executor.tasks.MapPutRunnable) 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

MapPutRunnable (com.hazelcast.client.executor.tasks.MapPutRunnable)29 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)29 QuickTest (com.hazelcast.test.annotation.QuickTest)29 Test (org.junit.Test)29 HazelcastTestSupport.randomString (com.hazelcast.test.HazelcastTestSupport.randomString)24 IMap (com.hazelcast.map.IMap)23 IExecutorService (com.hazelcast.core.IExecutorService)22 MapPutPartitionAwareRunnable (com.hazelcast.client.executor.tasks.MapPutPartitionAwareRunnable)11 Member (com.hazelcast.cluster.Member)10 CountDownLatch (java.util.concurrent.CountDownLatch)9 MultiExecutionCallback (com.hazelcast.core.MultiExecutionCallback)7 DurableExecutorService (com.hazelcast.durableexecutor.DurableExecutorService)7 MemberSelector (com.hazelcast.cluster.MemberSelector)6 SelectAllMembers (com.hazelcast.client.test.executor.tasks.SelectAllMembers)4 ExecutionCallback (com.hazelcast.core.ExecutionCallback)4 UUID (java.util.UUID)3 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 Future (java.util.concurrent.Future)2 SelectNoMembers (com.hazelcast.client.test.executor.tasks.SelectNoMembers)1