use of com.hazelcast.core.MemberLeftException in project hazelcast by hazelcast.
the class Invocation_NetworkSplitTest method testWaitingInvocations_whenNodeSplitFromCluster.
private void testWaitingInvocations_whenNodeSplitFromCluster(SplitAction action) {
Config config = createConfig();
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(3);
final HazelcastInstance hz1 = factory.newHazelcastInstance(config);
final HazelcastInstance hz2 = factory.newHazelcastInstance(config);
final HazelcastInstance hz3 = factory.newHazelcastInstance(config);
warmUpPartitions(hz1, hz2, hz3);
int partitionId = getPartitionId(hz2);
Operation op = new AlwaysBlockingOperation();
Future<Object> future = getNodeEngineImpl(hz3).getOperationService().invokeOnPartition("", op, partitionId);
assertTrueEventually(new AssertTask() {
@Override
public void run() {
final OperationParkerImpl waitNotifyService3 = (OperationParkerImpl) getNodeEngineImpl(hz2).getOperationParker();
assertEquals(1, waitNotifyService3.getTotalParkedOperationCount());
}
});
// execute the given split action
action.run(hz1, hz2, hz3);
unblock(hz1, hz2, hz3);
// Let node3 detect the split and merge it back to other two.
ClusterServiceImpl clusterService3 = (ClusterServiceImpl) getClusterService(hz3);
clusterService3.merge(getAddress(hz1));
assertClusterSizeEventually(3, hz1, hz2, hz3);
try {
future.get(1, TimeUnit.MINUTES);
fail("Future.get() should fail with a MemberLeftException!");
} catch (MemberLeftException expected) {
ignore(expected);
} catch (Exception e) {
fail(e.getClass().getName() + ": " + e.getMessage());
}
}
use of com.hazelcast.core.MemberLeftException in project hazelcast by hazelcast.
the class Invocation_OnMemberLeftTest method whenMemberRestarts.
private void whenMemberRestarts(Runnable restartAction) throws Exception {
Future<Object> futureBeforeShutdown = localOperationService.invokeOnTarget(null, new UnresponsiveTargetOperation(), remoteMember.getAddress());
final CountDownLatch blockMonitorLatch = new CountDownLatch(1);
final CountDownLatch resumeMonitorLatch = new CountDownLatch(1);
localInvocationMonitor.execute(() -> {
blockMonitorLatch.countDown();
assertOpenEventually(resumeMonitorLatch);
});
assertOpenEventually(blockMonitorLatch);
// Unresponsive operation should be executed before shutting down the node
assertUnresponsiveOperationStarted();
remote.getLifecycleService().terminate();
restartAction.run();
assertTrue(remote.getLifecycleService().isRunning());
Future<Object> futureAfterRestart = localOperationService.invokeOnTarget(null, new UnresponsiveTargetOperation(), remoteMember.getAddress());
resumeMonitorLatch.countDown();
try {
futureBeforeShutdown.get();
fail("Invocation should have failed with MemberLeftException!");
} catch (MemberLeftException e) {
ignore(e);
}
try {
futureAfterRestart.get(1, TimeUnit.SECONDS);
fail("future.get() should have failed with TimeoutException!");
} catch (TimeoutException e) {
ignore(e);
}
}
Aggregations