use of org.apache.ignite.plugin.segmentation.SegmentationPolicy in project ignite by apache.
the class TcpDiscoverySelfTest method checkFailedCoordinatorNode.
/**
* @param segPlc Segmentation policy.
* @throws Exception If failed.
*/
private void checkFailedCoordinatorNode(SegmentationPolicy segPlc) throws Exception {
try {
this.segPlc = segPlc;
IgniteEx coord = (IgniteEx) startGridsMultiThreaded(3);
UUID coordId = coord.localNode().id();
IgniteEx ignite1 = grid(1);
AtomicBoolean coordSegmented = new AtomicBoolean();
coord.events().localListen(evt -> {
assertEquals(EVT_NODE_SEGMENTED, evt.type());
UUID nodeId = ((DiscoveryEvent) evt).eventNode().id();
if (coordId.equals(nodeId))
coordSegmented.set(true);
return true;
}, EVT_NODE_SEGMENTED);
CountDownLatch failedLatch = new CountDownLatch(2);
IgnitePredicate<Event> failLsnr = evt -> {
assertEquals(EVT_NODE_FAILED, evt.type());
UUID nodeId = ((DiscoveryEvent) evt).eventNode().id();
if (coordId.equals(nodeId))
failedLatch.countDown();
return true;
};
ignite1.events().localListen(failLsnr, EVT_NODE_FAILED);
grid(2).events().localListen(failLsnr, EVT_NODE_FAILED);
ignite1.configuration().getDiscoverySpi().failNode(coordId, null);
assertTrue(failedLatch.await(2000, MILLISECONDS));
assertTrue(coordSegmented.get());
if (segPlc == SegmentationPolicy.STOP) {
assertTrue(coord.context().isStopping());
waitNodeStop(coord.name());
} else
assertFalse(coord.context().isStopping());
assertEquals(2, ignite1.context().discovery().allNodes().size());
} finally {
stopAllGrids();
}
}
Aggregations