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());
}
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()));
}
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());
}
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);
}
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()));
}
});
}
Aggregations