use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class MBeanDestroyTest method testExecutor.
@Test
public void testExecutor() throws Exception {
IExecutorService executor = holder.getHz().getExecutorService("executor");
executor.submit(new DummyRunnable()).get();
holder.assertMBeanExistEventually("IExecutorService", executor.getName());
destroyObjectAndAssert(executor, "IExecutorService");
}
use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class SmallClusterTest method submitToMembers_callable.
@Test
public void submitToMembers_callable() {
int sum = 0;
ResponseCountingMultiExecutionCallback callback = new ResponseCountingMultiExecutionCallback(instances.length);
Set<Member> membersSet = instances[0].getCluster().getMembers();
Member[] members = membersSet.toArray(new Member[membersSet.size()]);
Random random = new Random();
String name = "testSubmitToMembersCallable";
for (HazelcastInstance instance : instances) {
IExecutorService service = instance.getExecutorService(name);
int n = random.nextInt(instances.length) + 1;
sum += n;
Member[] m = new Member[n];
System.arraycopy(members, 0, m, 0, n);
service.submitToMembers(new IncrementAtomicLongCallable(name), Arrays.asList(m), callback);
}
assertOpenEventually(callback.getLatch());
IAtomicLong result = instances[0].getAtomicLong(name);
assertEquals(sum, result.get());
assertEquals(sum, callback.getCount());
}
use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class SmallClusterTest method submitToMembers_runnable.
@Test
public void submitToMembers_runnable() {
int sum = 0;
Set<Member> membersSet = instances[0].getCluster().getMembers();
Member[] members = membersSet.toArray(new Member[membersSet.size()]);
Random random = new Random();
ResponseCountingMultiExecutionCallback callback = new ResponseCountingMultiExecutionCallback(instances.length);
for (HazelcastInstance instance : instances) {
IExecutorService service = instance.getExecutorService("testSubmitToMembersRunnable");
int n = random.nextInt(instances.length) + 1;
sum += n;
Member[] m = new Member[n];
System.arraycopy(members, 0, m, 0, n);
service.submitToMembers(new IncrementAtomicLongRunnable("testSubmitToMembersRunnable"), Arrays.asList(m), callback);
}
assertOpenEventually(callback.getLatch());
IAtomicLong result = instances[0].getAtomicLong("testSubmitToMembersRunnable");
assertEquals(sum, result.get());
assertEquals(sum, callback.getCount());
}
use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class SmallClusterTest method submitToKeyOwner_callable.
@Test(timeout = TEST_TIMEOUT)
public void submitToKeyOwner_callable() throws Exception {
List<Future> futures = new ArrayList<Future>();
for (HazelcastInstance instance : instances) {
IExecutorService service = instance.getExecutorService("testSubmitToKeyOwnerCallable");
Member localMember = instance.getCluster().getLocalMember();
int key = findNextKeyForMember(instance, localMember);
Future future = service.submitToKeyOwner(new MemberUUIDCheckCallable(localMember.getUuid()), key);
futures.add(future);
}
for (Future future : futures) {
assertTrue((Boolean) future.get(60, TimeUnit.SECONDS));
}
}
use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.
the class SmallClusterTest method submitToMember_callable_withCallback.
@Test(timeout = TEST_TIMEOUT)
public void submitToMember_callable_withCallback() {
BooleanSuccessResponseCountingCallback callback = new BooleanSuccessResponseCountingCallback(instances.length);
for (HazelcastInstance instance : instances) {
IExecutorService service = instance.getExecutorService("testSubmitToMemberCallable");
Member localMember = instance.getCluster().getLocalMember();
service.submitToMember(new MemberUUIDCheckCallable(localMember.getUuid()), localMember, callback);
}
assertOpenEventually(callback.getResponseLatch());
assertEquals(instances.length, callback.getSuccessResponseCount());
}
Aggregations