Search in sources :

Example 1 with MapPutRunnable

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

the class ClientDurableExecutorServiceSubmitTest method submitRunnableToKeyOwner.

@Test
public void submitRunnableToKeyOwner() {
    DurableExecutorService service = client.getDurableExecutorService(randomString());
    String mapName = randomString();
    Runnable runnable = new MapPutRunnable(mapName);
    final CountDownLatch responseLatch = new CountDownLatch(1);
    service.submitToKeyOwner(runnable, "key").thenRun(() -> responseLatch.countDown());
    IMap map = client.getMap(mapName);
    assertOpenEventually("responseLatch", responseLatch);
    assertEquals(1, map.size());
}
Also used : DurableExecutorService(com.hazelcast.durableexecutor.DurableExecutorService) 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) HazelcastTestSupport.randomString(com.hazelcast.test.HazelcastTestSupport.randomString) CountDownLatch(java.util.concurrent.CountDownLatch) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with MapPutRunnable

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

the class ClientDurableExecutorServiceSubmitTest method submitRunnable.

@Test
public void submitRunnable() {
    DurableExecutorService service = client.getDurableExecutorService(randomString());
    String mapName = randomString();
    Runnable runnable = new MapPutRunnable(mapName);
    service.submit(runnable);
    IMap map = client.getMap(mapName);
    assertSizeEventually(1, map);
}
Also used : DurableExecutorService(com.hazelcast.durableexecutor.DurableExecutorService) 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) 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 MapPutRunnable

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

the class ClientDurableExecutorServiceSubmitTest method testSubmitRunnable_WithResult.

@Test
public void testSubmitRunnable_WithResult() throws Exception {
    DurableExecutorService service = client.getDurableExecutorService(randomString());
    String mapName = randomString();
    Object givenResult = "givenResult";
    Future future = service.submit(new MapPutRunnable(mapName), givenResult);
    Object result = future.get();
    IMap map = client.getMap(mapName);
    assertEquals(givenResult, result);
    assertEquals(1, map.size());
}
Also used : DurableExecutorService(com.hazelcast.durableexecutor.DurableExecutorService) IMap(com.hazelcast.map.IMap) MapPutRunnable(com.hazelcast.client.executor.tasks.MapPutRunnable) Future(java.util.concurrent.Future) HazelcastTestSupport.randomString(com.hazelcast.test.HazelcastTestSupport.randomString) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 4 with MapPutRunnable

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

the class ClientDurableExecutorServiceSubmitTest method testSubmitRunnable_withExecutionCallback.

@Test
public void testSubmitRunnable_withExecutionCallback() {
    DurableExecutorService service = client.getDurableExecutorService(randomString());
    String mapName = randomString();
    Runnable runnable = new MapPutRunnable(mapName);
    final CountDownLatch responseLatch = new CountDownLatch(1);
    service.submit(runnable).thenRun(() -> responseLatch.countDown());
    IMap map = client.getMap(mapName);
    assertOpenEventually("responseLatch", responseLatch);
    assertEquals(1, map.size());
}
Also used : DurableExecutorService(com.hazelcast.durableexecutor.DurableExecutorService) 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) HazelcastTestSupport.randomString(com.hazelcast.test.HazelcastTestSupport.randomString) CountDownLatch(java.util.concurrent.CountDownLatch) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 5 with MapPutRunnable

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

the class ClientExecutorServiceExecuteTest method testExecuteOnKeyOwner_whenKeyNull.

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

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