use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class SmallClusterTest method submitToSeveralNodes_callable.
@Test
public void submitToSeveralNodes_callable() throws Exception {
for (int i = 0; i < instances.length; i++) {
IExecutorService service = instances[i].getExecutorService("testSubmitMultipleNode");
Future future = service.submit(new IncrementAtomicLongCallable("testSubmitMultipleNode"));
assertEquals((long) (i + 1), future.get());
}
}
use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class SmallClusterTest method submitToMember_callable.
@Test(timeout = TEST_TIMEOUT)
public void submitToMember_callable() throws Exception {
List<Future> futures = new ArrayList<Future>();
for (HazelcastInstance instance : instances) {
IExecutorService service = instance.getExecutorService("testSubmitToMemberCallable");
Member localMember = instance.getCluster().getLocalMember();
Future future = service.submitToMember(new MemberUUIDCheckCallable(localMember.getUuid()), localMember);
futures.add(future);
}
for (Future future : futures) {
assertTrue((Boolean) future.get());
}
}
use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class SmallClusterTest method submitToAllMembers_callable.
@Test
public void submitToAllMembers_callable() {
ResponseCountingMultiExecutionCallback callback = new ResponseCountingMultiExecutionCallback(instances.length);
for (HazelcastInstance instance : instances) {
IExecutorService service = instance.getExecutorService("testSubmitToAllMembersCallable");
service.submitToAllMembers(new IncrementAtomicLongCallable("testSubmitToAllMembersCallable"), callback);
}
assertOpenEventually(callback.getLatch());
IAtomicLong result = instances[0].getAtomicLong("testSubmitToAllMembersCallable");
assertEquals(instances.length * instances.length, result.get());
assertEquals(instances.length * instances.length, callback.getCount());
}
use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class SmallClusterTest method submitToKeyOwner_runnable.
@Test
public void submitToKeyOwner_runnable() {
NullResponseCountingCallback callback = new NullResponseCountingCallback(instances.length);
for (HazelcastInstance instance : instances) {
IExecutorService service = instance.getExecutorService("testSubmitToKeyOwnerRunnable");
Member localMember = instance.getCluster().getLocalMember();
int key = findNextKeyForMember(instance, localMember);
service.submitToKeyOwner(new IncrementAtomicLongIfMemberUUIDNotMatchRunnable(localMember.getUuid(), "testSubmitToKeyOwnerRunnable"), key, callback);
}
assertOpenEventually(callback.getResponseLatch());
assertEquals(0, instances[0].getAtomicLong("testSubmitToKeyOwnerRunnable").get());
assertEquals(instances.length, callback.getNullResponseCount());
}
use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class SpecificSetupTest method statsIssue2039.
@Test
public void statsIssue2039() throws Exception {
Config config = new Config();
String name = "testStatsIssue2039";
config.addExecutorConfig(new ExecutorConfig(name).setQueueCapacity(1).setPoolSize(1));
HazelcastInstance instance = createHazelcastInstance(config);
IExecutorService executorService = instance.getExecutorService(name);
SleepLatchRunnable runnable = new SleepLatchRunnable();
executorService.execute(runnable);
assertTrue(SleepLatchRunnable.startLatch.await(30, SECONDS));
Future waitingInQueue = executorService.submit(new EmptyRunnable());
Future rejected = executorService.submit(new EmptyRunnable());
try {
rejected.get(1, MINUTES);
} catch (Exception e) {
if (!(e.getCause() instanceof RejectedExecutionException)) {
fail(e.toString());
}
} finally {
SleepLatchRunnable.sleepLatch.countDown();
}
waitingInQueue.get(1, MINUTES);
LocalExecutorStats stats = executorService.getLocalExecutorStats();
assertEquals(2, stats.getStartedTaskCount());
assertEquals(0, stats.getPendingTaskCount());
}
Aggregations