Search in sources :

Example 91 with IMap

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

the class ClientExecutorServiceExecuteTest method testExecuteOnKeyOwner.

@Test
public void testExecuteOnKeyOwner() {
    IExecutorService service = client.getExecutorService(randomString());
    String mapName = randomString();
    Member member = server1.getCluster().getLocalMember();
    final UUID targetUuid = member.getUuid();
    String key = generateKeyOwnedBy(server1);
    service.executeOnKeyOwner(new MapPutRunnable(mapName), key);
    final IMap map = client.getMap(mapName);
    assertTrueEventually(() -> assertTrue(map.containsKey(targetUuid)));
}
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) 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 92 with IMap

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

the class ClientExecutorServiceExecuteTest method testExecuteOnMembers_withSelector.

@Test
public void testExecuteOnMembers_withSelector() {
    IExecutorService service = client.getExecutorService(randomString());
    String mapName = randomString();
    MemberSelector selector = new SelectAllMembers();
    service.executeOnMembers(new MapPutRunnable(mapName), selector);
    IMap map = client.getMap(mapName);
    assertSizeEventually(CLUSTER_SIZE, map);
}
Also used : IMap(com.hazelcast.map.IMap) MemberSelector(com.hazelcast.cluster.MemberSelector) 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) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 93 with IMap

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

the class ClientExecutorServiceExecuteTest method testExecute_withMemberSelector.

@Test
public void testExecute_withMemberSelector() {
    IExecutorService service = client.getExecutorService(randomString());
    String mapName = randomString();
    MemberSelector selector = new SelectAllMembers();
    service.execute(new MapPutRunnable(mapName), selector);
    IMap map = client.getMap(mapName);
    assertSizeEventually(1, map);
}
Also used : IMap(com.hazelcast.map.IMap) MemberSelector(com.hazelcast.cluster.MemberSelector) 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) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 94 with IMap

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

the class ClientExecutorServiceExecuteTest method testExecuteOnMember.

@Test
public void testExecuteOnMember() {
    IExecutorService service = client.getExecutorService(randomString());
    String mapName = randomString();
    Member member = server1.getCluster().getLocalMember();
    final UUID targetUuid = member.getUuid();
    service.executeOnMember(new MapPutRunnable(mapName), member);
    final IMap map = client.getMap(mapName);
    assertTrueEventually(() -> assertTrue(map.containsKey(targetUuid)));
}
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) 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 95 with IMap

use of com.hazelcast.map.IMap 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)

Aggregations

IMap (com.hazelcast.map.IMap)292 Test (org.junit.Test)259 QuickTest (com.hazelcast.test.annotation.QuickTest)237 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)228 HazelcastInstance (com.hazelcast.core.HazelcastInstance)139 Config (com.hazelcast.config.Config)103 HazelcastTestSupport.randomString (com.hazelcast.test.HazelcastTestSupport.randomString)82 Map (java.util.Map)73 CountDownLatch (java.util.concurrent.CountDownLatch)65 MapStoreConfig (com.hazelcast.config.MapStoreConfig)54 Category (org.junit.experimental.categories.Category)51 Assert.assertEquals (org.junit.Assert.assertEquals)50 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)48 HashMap (java.util.HashMap)48 Collection (java.util.Collection)41 RunWith (org.junit.runner.RunWith)41 MapConfig (com.hazelcast.config.MapConfig)36 Set (java.util.Set)34 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)33 AssertTask (com.hazelcast.test.AssertTask)32