use of com.hazelcast.client.executor.tasks.MapPutRunnable in project hazelcast by hazelcast.
the class ClientExecutorServiceExecuteTest method testExecuteOnMembers_withEmptyCollection.
@Test
public void testExecuteOnMembers_withEmptyCollection() {
IExecutorService service = client.getExecutorService(randomString());
String mapName = randomString();
Collection<Member> collection = new ArrayList<Member>();
service.executeOnMembers(new MapPutRunnable(mapName), collection);
IMap map = client.getMap(mapName);
assertSizeEventually(0, map);
}
use of com.hazelcast.client.executor.tasks.MapPutRunnable in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method submitRunnableToMember_withExecutionCallback.
@Test
public void submitRunnableToMember_withExecutionCallback() {
IExecutorService service = client.getExecutorService(randomString());
String mapName = randomString();
Runnable runnable = new MapPutRunnable(mapName);
Member member = server.getCluster().getLocalMember();
final CountDownLatch responseLatch = new CountDownLatch(1);
service.submitToMember(runnable, member, new ExecutionCallback() {
public void onResponse(Object response) {
responseLatch.countDown();
}
public void onFailure(Throwable t) {
}
});
Map 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 ClientExecutorServiceSubmitTest method submitRunnableToAllMembers_withMultiExecutionCallback.
@Test
public void submitRunnableToAllMembers_withMultiExecutionCallback() {
IExecutorService service = client.getExecutorService(randomString());
final CountDownLatch responseLatch = new CountDownLatch(CLUSTER_SIZE);
final CountDownLatch completeLatch = new CountDownLatch(1);
String mapName = randomString();
Runnable runnable = new MapPutRunnable(mapName);
service.submitToAllMembers(runnable, new MultiExecutionCallback() {
public void onResponse(Member member, Object value) {
responseLatch.countDown();
}
public void onComplete(Map<Member, Object> values) {
completeLatch.countDown();
}
});
IMap 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 ClientExecutorServiceSubmitTest method submitRunnableToKeyOwner.
@Test
public void submitRunnableToKeyOwner() {
IExecutorService service = client.getExecutorService(randomString());
String mapName = randomString();
Runnable runnable = new MapPutRunnable(mapName);
final CountDownLatch responseLatch = new CountDownLatch(1);
service.submitToKeyOwner(runnable, "key", 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 ClientExecutorServiceSubmitTest method submitRunnableToMembers_withExecutionCallback.
@Test
public void submitRunnableToMembers_withExecutionCallback() {
IExecutorService service = client.getExecutorService(randomString());
final CountDownLatch responseLatch = new CountDownLatch(CLUSTER_SIZE);
final CountDownLatch completeLatch = new CountDownLatch(1);
String mapName = randomString();
Runnable runnable = new MapPutRunnable(mapName);
MemberSelector selector = new SelectAllMembers();
service.submitToMembers(runnable, selector, new MultiExecutionCallback() {
public void onResponse(Member member, Object value) {
responseLatch.countDown();
}
public void onComplete(Map<Member, Object> values) {
completeLatch.countDown();
}
});
IMap map = client.getMap(mapName);
assertOpenEventually("responseLatch", responseLatch);
assertOpenEventually("completeLatch", completeLatch);
assertEquals(CLUSTER_SIZE, map.size());
}
Aggregations