Search in sources :

Example 11 with MapPutRunnable

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

the class ClientExecutorServiceExecuteTest method testExecuteOnAllMembers.

@Test
public void testExecuteOnAllMembers() {
    IExecutorService service = client.getExecutorService(randomString());
    String mapName = randomString();
    service.executeOnAllMembers(new MapPutRunnable(mapName));
    IMap map = client.getMap(mapName);
    assertSizeEventually(CLUSTER_SIZE, map);
}
Also used : IMap(com.hazelcast.map.IMap) 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)

Example 12 with MapPutRunnable

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

the class ClientExecutorServiceExecuteTest method testExecute.

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

Example 13 with MapPutRunnable

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

the class ClientExecutorServiceSubmitTest method testSubmitRunnable_WithResult.

@Test
public void testSubmitRunnable_WithResult() throws ExecutionException, InterruptedException {
    IExecutorService service = client.getExecutorService(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 : IMap(com.hazelcast.map.IMap) MapPutRunnable(com.hazelcast.client.executor.tasks.MapPutRunnable) Future(java.util.concurrent.Future) 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 14 with MapPutRunnable

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

the class ClientExecutorServiceSubmitTest method submitRunnable.

@Test
public void submitRunnable() {
    IExecutorService service = client.getExecutorService(randomString());
    String mapName = randomString();
    Runnable runnable = new MapPutRunnable(mapName);
    service.submit(runnable);
    IMap map = client.getMap(mapName);
    assertSizeEventually(1, map);
}
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) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 15 with MapPutRunnable

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

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