Search in sources :

Example 16 with MapPutRunnable

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

the class ClientExecutorServiceSubmitTest method testSubmitRunnable_withExecutionCallback.

@Test
public void testSubmitRunnable_withExecutionCallback() {
    IExecutorService service = client.getExecutorService(randomString());
    String mapName = randomString();
    Runnable runnable = new MapPutRunnable(mapName);
    final CountDownLatch responseLatch = new CountDownLatch(1);
    service.submit(runnable, 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 17 with MapPutRunnable

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

the class ClientDurableExecutorServiceExecuteTest method testExecuteOnKeyOwner.

@Test
public void testExecuteOnKeyOwner() {
    DurableExecutorService service = client.getDurableExecutorService(randomString());
    String mapName = randomString();
    Member member = server.getCluster().getLocalMember();
    final UUID targetUuid = member.getUuid();
    String key = generateKeyOwnedBy(server);
    service.executeOnKeyOwner(new MapPutRunnable(mapName), key);
    final IMap map = client.getMap(mapName);
    assertTrueEventually(() -> assertTrue(map.containsKey(targetUuid)));
}
Also used : DurableExecutorService(com.hazelcast.durableexecutor.DurableExecutorService) IMap(com.hazelcast.map.IMap) MapPutRunnable(com.hazelcast.client.executor.tasks.MapPutRunnable) HazelcastTestSupport.randomString(com.hazelcast.test.HazelcastTestSupport.randomString) 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 18 with MapPutRunnable

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

the class ClientExecutorServiceSubmitTest method submitRunnableToMembers_withMultiExecutionCallback.

@Test
public void submitRunnableToMembers_withMultiExecutionCallback() {
    IExecutorService service = client.getExecutorService(randomString());
    String mapName = randomString();
    Runnable runnable = new MapPutRunnable(mapName);
    Collection<Member> collection = server.getCluster().getMembers();
    final CountDownLatch responseLatch = new CountDownLatch(CLUSTER_SIZE);
    final CountDownLatch completeLatch = new CountDownLatch(1);
    service.submitToMembers(runnable, collection, new MultiExecutionCallback() {

        public void onResponse(Member member, Object value) {
            responseLatch.countDown();
        }

        public void onComplete(Map<Member, Object> values) {
            completeLatch.countDown();
        }
    });
    Map map = client.getMap(mapName);
    assertOpenEventually("responseLatch", responseLatch);
    assertOpenEventually("completeLatch", completeLatch);
    assertEquals(CLUSTER_SIZE, map.size());
}
Also used : MultiExecutionCallback(com.hazelcast.core.MultiExecutionCallback) 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) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 19 with MapPutRunnable

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

the class ClientDurableExecutorServiceExecuteTest method testExecute.

@Test
public void testExecute() {
    DurableExecutorService service = client.getDurableExecutorService(randomString());
    String mapName = randomString();
    service.execute(new MapPutRunnable(mapName));
    IMap map = client.getMap(mapName);
    assertSizeEventually(1, map);
}
Also used : DurableExecutorService(com.hazelcast.durableexecutor.DurableExecutorService) IMap(com.hazelcast.map.IMap) MapPutRunnable(com.hazelcast.client.executor.tasks.MapPutRunnable) HazelcastTestSupport.randomString(com.hazelcast.test.HazelcastTestSupport.randomString) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 20 with MapPutRunnable

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

the class ClientDurableExecutorServiceExecuteTest method testExecuteOnKeyOwner_whenKeyNull.

@Test(expected = NullPointerException.class)
public void testExecuteOnKeyOwner_whenKeyNull() {
    DurableExecutorService service = client.getDurableExecutorService(randomString());
    service.executeOnKeyOwner(new MapPutRunnable("map"), null);
}
Also used : DurableExecutorService(com.hazelcast.durableexecutor.DurableExecutorService) MapPutRunnable(com.hazelcast.client.executor.tasks.MapPutRunnable) 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