use of com.hazelcast.map.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.map.IMap in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method submitCallablePartitionAware_WithExecutionCallback.
@Test
public void submitCallablePartitionAware_WithExecutionCallback() {
IExecutorService service = client.getExecutorService(randomString());
String mapName = randomString();
IMap map = client.getMap(mapName);
String key = HazelcastTestSupport.generateKeyOwnedBy(server);
Member member = server.getCluster().getLocalMember();
Callable<UUID> runnable = new MapPutPartitionAwareCallable<>(mapName, key);
final AtomicReference<UUID> result = new AtomicReference<>();
final CountDownLatch responseLatch = new CountDownLatch(1);
service.submit(runnable, new ExecutionCallback<UUID>() {
public void onResponse(UUID response) {
result.set(response);
responseLatch.countDown();
}
public void onFailure(Throwable t) {
}
});
assertOpenEventually("responseLatch", responseLatch);
assertEquals(member.getUuid(), result.get());
assertTrue(map.containsKey(member.getUuid()));
}
use of com.hazelcast.map.IMap in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method submitRunnablePartitionAware_withExecutionCallback.
@Test
public void submitRunnablePartitionAware_withExecutionCallback() {
IExecutorService service = client.getExecutorService(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, 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.map.IMap in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method testSubmitRunnable_WithResult.
@Test
public void testSubmitRunnable_WithResult() throws ExecutionException, InterruptedException {
IExecutorService service = client.getExecutorService(randomString());
String mapName = randomString();
Object givenResult = "givenResult";
Future future = service.submit(new MapPutRunnable(mapName), givenResult);
Object result = future.get();
IMap map = client.getMap(mapName);
assertEquals(givenResult, result);
assertEquals(1, map.size());
}
use of com.hazelcast.map.IMap in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method submitRunnablePartitionAware.
@Test
public void submitRunnablePartitionAware() {
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() {
assertTrue(map.containsKey(member.getUuid()));
}
});
}
Aggregations