use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class SmallClusterTest method submitToAllMembers_runnable.
@Test
public void submitToAllMembers_runnable() {
ResponseCountingMultiExecutionCallback callback = new ResponseCountingMultiExecutionCallback(instances.length);
for (HazelcastInstance instance : instances) {
IExecutorService service = instance.getExecutorService("testSubmitToAllMembersRunnable");
service.submitToAllMembers(new IncrementAtomicLongRunnable("testSubmitToAllMembersRunnable"), callback);
}
assertOpenEventually(callback.getLatch());
IAtomicLong result = instances[0].getAtomicLong("testSubmitToAllMembersRunnable");
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_callable_withCallback.
@Test(timeout = TEST_TIMEOUT)
public void submitToKeyOwner_callable_withCallback() {
BooleanSuccessResponseCountingCallback callback = new BooleanSuccessResponseCountingCallback(instances.length);
for (HazelcastInstance instance : instances) {
IExecutorService service = instance.getExecutorService("testSubmitToKeyOwnerCallable");
Member localMember = instance.getCluster().getLocalMember();
int key = findNextKeyForMember(instance, localMember);
service.submitToKeyOwner(new MemberUUIDCheckCallable(localMember.getUuid()), key, callback);
}
assertOpenEventually(callback.getResponseLatch());
assertEquals(instances.length, callback.getSuccessResponseCount());
}
use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class SmallClusterTest method executionCallback_notified.
@Test
public void executionCallback_notified() throws Exception {
IExecutorService executorService = instances[1].getExecutorService(randomString());
BasicTestCallable task = new BasicTestCallable();
String key = generateKeyOwnedBy(instances[0]);
ICompletableFuture<String> future = (ICompletableFuture<String>) executorService.submitToKeyOwner(task, key);
CountingDownExecutionCallback<String> callback = new CountingDownExecutionCallback<String>(1);
future.andThen(callback);
future.get();
assertOpenEventually(callback.getLatch(), 10);
}
use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class SpecificSetupTest method operationTimeoutConfigProp.
@Test
public void operationTimeoutConfigProp() throws Exception {
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
Config config = new Config();
int timeoutSeconds = 3;
config.setProperty(OPERATION_CALL_TIMEOUT_MILLIS.getName(), String.valueOf(SECONDS.toMillis(timeoutSeconds)));
HazelcastInstance hz1 = factory.newHazelcastInstance(config);
HazelcastInstance hz2 = factory.newHazelcastInstance(config);
IExecutorService executor = hz1.getExecutorService(randomString());
Future<Boolean> future = executor.submitToMember(new SleepingTask(3 * timeoutSeconds), hz2.getCluster().getLocalMember());
Boolean result = future.get(1, MINUTES);
assertTrue(result);
}
use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class DistributedExecutorServiceTest method testExecutorConfigCache_whenUsedExecutorShutdown_thenConfigRemoved.
@Test
public void testExecutorConfigCache_whenUsedExecutorShutdown_thenConfigRemoved() throws Exception {
final IExecutorService executorService = hz.getExecutorService(EXECUTOR_NAME);
Future future = executorService.submit(new EmptyRunnable());
future.get();
executorService.shutdown();
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertTrue(executorService.isShutdown());
}
});
assertTrue("Executor config cache should not contain cached configuration for executor that was already shutdown", distributedExecutorService.executorConfigCache.isEmpty());
}
Aggregations