Search in sources :

Example 21 with MapPutRunnable

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

the class ClientExecutorServiceExecuteTest method testExecuteOnMembers_withEmptyCollection.

@Test
public void testExecuteOnMembers_withEmptyCollection() {
    IExecutorService service = client.getExecutorService(randomString());
    String mapName = randomString();
    Collection<Member> collection = new ArrayList<Member>();
    service.executeOnMembers(new MapPutRunnable(mapName), collection);
    IMap map = client.getMap(mapName);
    assertSizeEventually(0, map);
}
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 22 with MapPutRunnable

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

the class ClientExecutorServiceSubmitTest method submitRunnableToMember_withExecutionCallback.

@Test
public void submitRunnableToMember_withExecutionCallback() {
    IExecutorService service = client.getExecutorService(randomString());
    String mapName = randomString();
    Runnable runnable = new MapPutRunnable(mapName);
    Member member = server.getCluster().getLocalMember();
    final CountDownLatch responseLatch = new CountDownLatch(1);
    service.submitToMember(runnable, member, new ExecutionCallback() {

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

        public void onFailure(Throwable t) {
        }
    });
    Map map = client.getMap(mapName);
    assertOpenEventually("responseLatch", responseLatch);
    assertEquals(1, map.size());
}
Also used : MapPutPartitionAwareRunnable(com.hazelcast.client.executor.tasks.MapPutPartitionAwareRunnable) MapPutRunnable(com.hazelcast.client.executor.tasks.MapPutRunnable) MapPutRunnable(com.hazelcast.client.executor.tasks.MapPutRunnable) IExecutorService(com.hazelcast.core.IExecutorService) HazelcastTestSupport.randomString(com.hazelcast.test.HazelcastTestSupport.randomString) CountDownLatch(java.util.concurrent.CountDownLatch) Member(com.hazelcast.cluster.Member) Map(java.util.Map) IMap(com.hazelcast.map.IMap) 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 23 with MapPutRunnable

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

Example 24 with MapPutRunnable

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

the class ClientExecutorServiceSubmitTest method submitRunnableToKeyOwner.

@Test
public void submitRunnableToKeyOwner() {
    IExecutorService service = client.getExecutorService(randomString());
    String mapName = randomString();
    Runnable runnable = new MapPutRunnable(mapName);
    final CountDownLatch responseLatch = new CountDownLatch(1);
    service.submitToKeyOwner(runnable, "key", 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) MapPutPartitionAwareRunnable(com.hazelcast.client.executor.tasks.MapPutPartitionAwareRunnable) MapPutRunnable(com.hazelcast.client.executor.tasks.MapPutRunnable) MapPutRunnable(com.hazelcast.client.executor.tasks.MapPutRunnable) 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 25 with MapPutRunnable

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

the class ClientExecutorServiceSubmitTest method submitRunnableToMembers_withExecutionCallback.

@Test
public void submitRunnableToMembers_withExecutionCallback() {
    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);
    MemberSelector selector = new SelectAllMembers();
    service.submitToMembers(runnable, selector, 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());
}
Also used : MultiExecutionCallback(com.hazelcast.core.MultiExecutionCallback) 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) Member(com.hazelcast.cluster.Member) 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