Search in sources :

Example 11 with IMap

use of com.hazelcast.core.IMap 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").andThen(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 : DurableExecutorService(com.hazelcast.durableexecutor.DurableExecutorService) IMap(com.hazelcast.core.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) ExecutionCallback(com.hazelcast.core.ExecutionCallback) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 12 with IMap

use of com.hazelcast.core.IMap in project hazelcast by hazelcast.

the class ClientDurableExecutorServiceSubmitTest method submitRunnablePartitionAware_withExecutionCallback.

@Test
public void submitRunnablePartitionAware_withExecutionCallback() {
    DurableExecutorService service = client.getDurableExecutorService(randomString());
    String mapName = randomString();
    String key = HazelcastTestSupport.generateKeyOwnedBy(server);
    Member member = server.getCluster().getLocalMember();
    Runnable runnable = new MapPutPartitionAwareRunnable<String>(mapName, key);
    final CountDownLatch responseLatch = new CountDownLatch(1);
    service.submit(runnable).andThen(new ExecutionCallback() {

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

        @Override
        public void onFailure(Throwable t) {
        }
    });
    IMap map = client.getMap(mapName);
    assertOpenEventually("responseLatch", responseLatch);
    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) HazelcastTestSupport.randomString(com.hazelcast.test.HazelcastTestSupport.randomString) MapPutPartitionAwareRunnable(com.hazelcast.client.executor.tasks.MapPutPartitionAwareRunnable) CountDownLatch(java.util.concurrent.CountDownLatch) Member(com.hazelcast.core.Member) ExecutionCallback(com.hazelcast.core.ExecutionCallback) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 13 with IMap

use of com.hazelcast.core.IMap in project hazelcast by hazelcast.

the class ClientExecutorServiceSubmitTest method testSubmitRunnable_withExecutionCallback.

@Test
public void testSubmitRunnable_withExecutionCallback() throws Exception {
    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.core.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) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 14 with IMap

use of com.hazelcast.core.IMap 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.core.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) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 15 with IMap

use of com.hazelcast.core.IMap in project hazelcast by hazelcast.

the class ClientExecutorServiceSubmitTest method submitRunnablePartitionAware.

@Test
public void submitRunnablePartitionAware() throws Exception {
    IExecutorService service = client.getExecutorService(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 : IMap(com.hazelcast.core.IMap) MapPutPartitionAwareRunnable(com.hazelcast.client.executor.tasks.MapPutPartitionAwareRunnable) MapPutRunnable(com.hazelcast.client.executor.tasks.MapPutRunnable) AssertTask(com.hazelcast.test.AssertTask) IExecutorService(com.hazelcast.core.IExecutorService) HazelcastTestSupport.randomString(com.hazelcast.test.HazelcastTestSupport.randomString) MapPutPartitionAwareRunnable(com.hazelcast.client.executor.tasks.MapPutPartitionAwareRunnable) Member(com.hazelcast.core.Member) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

IMap (com.hazelcast.core.IMap)258 Test (org.junit.Test)241 QuickTest (com.hazelcast.test.annotation.QuickTest)218 ParallelTest (com.hazelcast.test.annotation.ParallelTest)211 HazelcastInstance (com.hazelcast.core.HazelcastInstance)140 Config (com.hazelcast.config.Config)80 HazelcastTestSupport.randomString (com.hazelcast.test.HazelcastTestSupport.randomString)80 Map (java.util.Map)65 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)62 HashMap (java.util.HashMap)53 CountDownLatch (java.util.concurrent.CountDownLatch)49 NightlyTest (com.hazelcast.test.annotation.NightlyTest)39 AssertTask (com.hazelcast.test.AssertTask)36 MapStoreConfig (com.hazelcast.config.MapStoreConfig)34 MapConfig (com.hazelcast.config.MapConfig)31 TransactionalMap (com.hazelcast.core.TransactionalMap)29 IExecutorService (com.hazelcast.core.IExecutorService)28 MapPutRunnable (com.hazelcast.client.executor.tasks.MapPutRunnable)27 TransactionContext (com.hazelcast.transaction.TransactionContext)21 TransactionException (com.hazelcast.transaction.TransactionException)21