Search in sources :

Example 6 with MapPutPartitionAwareRunnable

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

the class ClientDurableExecutorServiceSubmitTest method submitRunnablePartitionAware.

@Test
public void submitRunnablePartitionAware() {
    DurableExecutorService service = client.getDurableExecutorService(randomString());
    String mapName = randomString();
    String key = HazelcastTestSupport.generateKeyOwnedBy(server);
    final Member member = server.getCluster().getLocalMember();
    // this task should execute on a node owning the given key argument,
    // the action is to put the UUid of the executing node into a map with the given name
    Runnable runnable = new MapPutPartitionAwareRunnable<String>(mapName, key);
    service.submit(runnable);
    final IMap map = client.getMap(mapName);
    assertTrueEventually(new AssertTask() {

        public void run() throws Exception {
            assertTrue(map.containsKey(member.getUuid()));
        }
    });
}
Also used : DurableExecutorService(com.hazelcast.durableexecutor.DurableExecutorService) IMap(com.hazelcast.core.IMap) MapPutPartitionAwareRunnable(com.hazelcast.client.executor.tasks.MapPutPartitionAwareRunnable) MapPutRunnable(com.hazelcast.client.executor.tasks.MapPutRunnable) AssertTask(com.hazelcast.test.AssertTask) HazelcastTestSupport.randomString(com.hazelcast.test.HazelcastTestSupport.randomString) MapPutPartitionAwareRunnable(com.hazelcast.client.executor.tasks.MapPutPartitionAwareRunnable) Member(com.hazelcast.core.Member) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

MapPutPartitionAwareRunnable (com.hazelcast.client.executor.tasks.MapPutPartitionAwareRunnable)6 MapPutRunnable (com.hazelcast.client.executor.tasks.MapPutRunnable)6 IMap (com.hazelcast.core.IMap)6 Member (com.hazelcast.core.Member)6 HazelcastTestSupport.randomString (com.hazelcast.test.HazelcastTestSupport.randomString)6 ParallelTest (com.hazelcast.test.annotation.ParallelTest)6 QuickTest (com.hazelcast.test.annotation.QuickTest)6 Test (org.junit.Test)6 AssertTask (com.hazelcast.test.AssertTask)4 IExecutorService (com.hazelcast.core.IExecutorService)3 DurableExecutorService (com.hazelcast.durableexecutor.DurableExecutorService)3 ExecutionCallback (com.hazelcast.core.ExecutionCallback)2 IOException (java.io.IOException)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 ExecutionException (java.util.concurrent.ExecutionException)2 Future (java.util.concurrent.Future)2 MultiExecutionCallback (com.hazelcast.core.MultiExecutionCallback)1