use of com.hazelcast.client.executor.tasks.MapPutRunnable in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method testSubmitRunnable_withExecutionCallback.
@Test
public void testSubmitRunnable_withExecutionCallback() {
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.client.executor.tasks.MapPutRunnable 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 UUID targetUuid = member.getUuid();
String key = generateKeyOwnedBy(server);
service.executeOnKeyOwner(new MapPutRunnable(mapName), key);
final IMap map = client.getMap(mapName);
assertTrueEventually(() -> assertTrue(map.containsKey(targetUuid)));
}
use of com.hazelcast.client.executor.tasks.MapPutRunnable in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method submitRunnableToMembers_withMultiExecutionCallback.
@Test
public void submitRunnableToMembers_withMultiExecutionCallback() {
IExecutorService service = client.getExecutorService(randomString());
String mapName = randomString();
Runnable runnable = new MapPutRunnable(mapName);
Collection<Member> collection = server.getCluster().getMembers();
final CountDownLatch responseLatch = new CountDownLatch(CLUSTER_SIZE);
final CountDownLatch completeLatch = new CountDownLatch(1);
service.submitToMembers(runnable, collection, new MultiExecutionCallback() {
public void onResponse(Member member, Object value) {
responseLatch.countDown();
}
public void onComplete(Map<Member, Object> values) {
completeLatch.countDown();
}
});
Map map = client.getMap(mapName);
assertOpenEventually("responseLatch", responseLatch);
assertOpenEventually("completeLatch", completeLatch);
assertEquals(CLUSTER_SIZE, map.size());
}
use of com.hazelcast.client.executor.tasks.MapPutRunnable in project hazelcast by hazelcast.
the class ClientDurableExecutorServiceExecuteTest method testExecute.
@Test
public void testExecute() {
DurableExecutorService service = client.getDurableExecutorService(randomString());
String mapName = randomString();
service.execute(new MapPutRunnable(mapName));
IMap map = client.getMap(mapName);
assertSizeEventually(1, map);
}
use of com.hazelcast.client.executor.tasks.MapPutRunnable in project hazelcast by hazelcast.
the class ClientDurableExecutorServiceExecuteTest method testExecuteOnKeyOwner_whenKeyNull.
@Test(expected = NullPointerException.class)
public void testExecuteOnKeyOwner_whenKeyNull() {
DurableExecutorService service = client.getDurableExecutorService(randomString());
service.executeOnKeyOwner(new MapPutRunnable("map"), null);
}
Aggregations