use of com.hazelcast.core.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 String targetUuid = member.getUuid();
String key = generateKeyOwnedBy(server1);
service.executeOnKeyOwner(new MapPutRunnable(mapName), key);
final IMap map = client.getMap(mapName);
assertTrueEventually(new AssertTask() {
public void run() throws Exception {
assertTrue(map.containsKey(targetUuid));
}
});
}
use of com.hazelcast.core.IMap 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);
}
use of com.hazelcast.core.IMap in project hazelcast by hazelcast.
the class ExecutorServiceLiteMemberTest method test_executeRunnable_onLiteMember.
@Test
public void test_executeRunnable_onLiteMember() {
final HazelcastInstance lite1 = factory.newHazelcastInstance(liteConfig);
final HazelcastInstance lite2 = factory.newHazelcastInstance(liteConfig);
factory.newHazelcastInstance();
final HazelcastInstance client = factory.newHazelcastClient();
final String name = randomString();
final IExecutorService executor = client.getExecutorService(name);
executor.execute(new ResultSettingRunnable(name), LITE_MEMBER_SELECTOR);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
final IMap<Object, Object> results = lite1.getMap(name);
assertEquals(1, results.size());
final boolean executedOnLite1 = results.containsKey(lite1.getCluster().getLocalMember());
final boolean executedOnLite2 = results.containsKey(lite2.getCluster().getLocalMember());
assertTrue(executedOnLite1 || executedOnLite2);
}
});
}
use of com.hazelcast.core.IMap in project hazelcast by hazelcast.
the class ClientDurableExecutorServiceExecuteTest method testExecuteOnKeyOwner.
@Test
public void testExecuteOnKeyOwner() {
DurableExecutorService service = client.getDurableExecutorService(randomString());
String mapName = randomString();
Member member = server.getCluster().getLocalMember();
final String targetUuid = member.getUuid();
String key = generateKeyOwnedBy(server);
service.executeOnKeyOwner(new MapPutRunnable(mapName), key);
final IMap map = client.getMap(mapName);
assertTrueEventually(new AssertTask() {
public void run() throws Exception {
assertTrue(map.containsKey(targetUuid));
}
});
}
use of com.hazelcast.core.IMap in project hazelcast by hazelcast.
the class ClientMapBasicTest method testEntrySet_withPredicate.
@Test
public void testEntrySet_withPredicate() {
int max = 44;
IMap<Integer, String> map = client.getMap(randomString());
for (int key = 0; key < max; key++) {
String value = key + "value";
map.put(key, value);
}
Set<Map.Entry<Integer, String>> entrySet = map.entrySet(new SqlPredicate("this == 1value"));
assertEquals(1, entrySet.size());
Map.Entry<Integer, String> entry = entrySet.iterator().next();
assertEquals(1, (int) entry.getKey());
assertEquals("1value", entry.getValue());
}
Aggregations