use of org.apache.ignite.spi.discovery.zk.ZookeeperDiscoverySpi in project ignite by apache.
the class ZookeeperDiscoveryCommunicationFailureTest method testCommunicationFailureResolve_KillCoordinator_5.
/**
* @throws Exception If failed.
*/
@Test
public void testCommunicationFailureResolve_KillCoordinator_5() throws Exception {
sesTimeout = 2000;
testCommSpi = true;
commFailureRslvr = KillCoordinatorCommunicationFailureResolver.FACTORY;
startGrids(10);
int crd = 0;
int nodeIdx = 10;
for (int i = 0; i < GridTestUtils.SF.applyLB(4, 2); i++) {
info("Iteration: " + i);
for (Ignite node : G.allGrids()) ZkTestCommunicationSpi.testSpi(node).initCheckResult(10);
UUID crdId = ignite(crd).cluster().localNode().id();
ZookeeperDiscoverySpi spi = spi(ignite(crd + 1));
try {
spi.resolveCommunicationFailure(spi.getNode(crdId), new Exception("test"));
fail("Exception is not thrown");
} catch (IgniteSpiException e) {
assertTrue("Unexpected exception: " + e, e.getCause() instanceof ClusterTopologyCheckedException);
}
waitForTopology(9);
startGrid(nodeIdx++);
waitForTopology(10);
crd++;
}
}
use of org.apache.ignite.spi.discovery.zk.ZookeeperDiscoverySpi in project ignite by apache.
the class ZookeeperDiscoveryCommunicationFailureTest method testCommunicationFailureResolve_KillRandom.
/**
* @throws Exception If failed.
*/
@Ignore("https://issues.apache.org/jira/browse/IGNITE-10988")
@Test
public void testCommunicationFailureResolve_KillRandom() throws Exception {
sesTimeout = 2000;
testCommSpi = true;
commFailureRslvr = KillRandomCommunicationFailureResolver.FACTORY;
startGridsMultiThreaded(10);
startClientGridsMultiThreaded(10, 5);
int nodesCnt = 15;
waitForTopology(nodesCnt);
int nodeIdx = 15;
for (int i = 0; i < GridTestUtils.SF.applyLB(10, 2); i++) {
info("Iteration: " + i);
ZookeeperDiscoverySpi spi = null;
for (Ignite node : G.allGrids()) {
ZkTestCommunicationSpi.testSpi(node).initCheckResult(100);
spi = spi(node);
}
assert spi != null;
try {
spi.resolveCommunicationFailure(spi.getRemoteNodes().iterator().next(), new Exception("test"));
} catch (IgniteSpiException ignore) {
// No-op.
}
if (ThreadLocalRandom.current().nextBoolean())
startClientGrid(nodeIdx++);
else
startGrid(nodeIdx++);
nodesCnt = nodesCnt - KillRandomCommunicationFailureResolver.LAST_KILLED_NODES.size() + 1;
waitForTopology(nodesCnt);
}
}
use of org.apache.ignite.spi.discovery.zk.ZookeeperDiscoverySpi in project ignite by apache.
the class ZookeeperDiscoveryCommunicationFailureTest method communicationFailureResolve_Simple.
/**
* @param nodes Nodes number.
* @throws Exception If failed.
*/
private void communicationFailureResolve_Simple(int nodes) throws Exception {
assert nodes > 1;
sesTimeout = 2000;
commFailureRslvr = NoOpCommunicationFailureResolver.FACTORY;
startGridsMultiThreaded(nodes);
ThreadLocalRandom rnd = ThreadLocalRandom.current();
for (int i = 0; i < 3; i++) {
info("Iteration: " + i);
int idx1 = rnd.nextInt(nodes);
int idx2;
do {
idx2 = rnd.nextInt(nodes);
} while (idx1 == idx2);
ZookeeperDiscoverySpi spi = spi(ignite(idx1));
spi.resolveCommunicationFailure(ignite(idx2).cluster().localNode(), new Exception("test"));
checkInternalStructuresCleanup();
}
}
use of org.apache.ignite.spi.discovery.zk.ZookeeperDiscoverySpi in project ignite by apache.
the class ZookeeperDiscoverySegmentationAndConnectionRestoreTest method connectionRestore_NonCoordinator.
/**
* @param failWhenDisconnected {@code True} if fail node while another node is disconnected.
* @throws Exception If failed.
*/
private void connectionRestore_NonCoordinator(boolean failWhenDisconnected) throws Exception {
testSockNio = true;
Ignite node0 = startGrid(0);
Ignite node1 = startGrid(1);
ZkTestClientCnxnSocketNIO c1 = ZkTestClientCnxnSocketNIO.forNode(node1);
c1.closeSocket(true);
IgniteInternalFuture<?> fut = GridTestUtils.runAsync(new Callable<Void>() {
@Override
public Void call() {
try {
startGrid(2);
} catch (Exception e) {
info("Start error: " + e);
}
return null;
}
}, "start-node");
helper.checkEvents(node0, evts, ZookeeperDiscoverySpiTestHelper.joinEvent(3));
if (failWhenDisconnected) {
ZookeeperDiscoverySpi spi = spis.get(getTestIgniteInstanceName(2));
closeZkClient(spi);
helper.checkEvents(node0, evts, ZookeeperDiscoverySpiTestHelper.leftEvent(4, true));
}
c1.allowConnect();
helper.checkEvents(ignite(1), evts, ZookeeperDiscoverySpiTestHelper.joinEvent(3));
if (failWhenDisconnected) {
helper.checkEvents(ignite(1), evts, ZookeeperDiscoverySpiTestHelper.leftEvent(4, true));
IgnitionEx.stop(getTestIgniteInstanceName(2), true, ShutdownPolicy.IMMEDIATE, true);
}
fut.get();
waitForTopology(failWhenDisconnected ? 2 : 3);
}
use of org.apache.ignite.spi.discovery.zk.ZookeeperDiscoverySpi in project ignite by apache.
the class ZookeeperDiscoverySegmentationAndConnectionRestoreTest method connectionRestore_Coordinator.
/**
* @param initNodes Number of initially started nodes.
* @param startNodes Number of nodes to start after coordinator loose connection.
* @param failCnt Number of nodes to stop after coordinator loose connection.
* @throws Exception If failed.
*/
private void connectionRestore_Coordinator(final int initNodes, int startNodes, int failCnt) throws Exception {
sesTimeout = 30_000;
testSockNio = true;
Ignite node0 = startGrids(initNodes);
ZkTestClientCnxnSocketNIO c0 = ZkTestClientCnxnSocketNIO.forNode(node0);
c0.closeSocket(true);
final AtomicInteger nodeIdx = new AtomicInteger(initNodes);
IgniteInternalFuture<?> fut = GridTestUtils.runMultiThreadedAsync(new Callable<Void>() {
@Override
public Void call() {
try {
startGrid(nodeIdx.getAndIncrement());
} catch (Exception e) {
error("Start failed: " + e);
}
return null;
}
}, startNodes, "start-node");
int cnt = 0;
DiscoveryEvent[] expEvts = new DiscoveryEvent[startNodes - failCnt];
int expEvtCnt = 0;
sesTimeout = 1000;
List<ZkTestClientCnxnSocketNIO> blockedC = new ArrayList<>();
final List<String> failedZkNodes = new ArrayList<>(failCnt);
for (int i = initNodes; i < initNodes + startNodes; i++) {
final ZookeeperDiscoverySpi spi = helper.waitSpi(getTestIgniteInstanceName(i), spis);
assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicate() {
@Override
public boolean apply() {
Object spiImpl = GridTestUtils.getFieldValue(spi, "impl");
if (spiImpl == null)
return false;
long internalOrder = GridTestUtils.getFieldValue(spiImpl, "rtState", "internalOrder");
return internalOrder > 0;
}
}, 10_000));
if (cnt++ < failCnt) {
ZkTestClientCnxnSocketNIO c = ZkTestClientCnxnSocketNIO.forNode(getTestIgniteInstanceName(i));
c.closeSocket(true);
blockedC.add(c);
failedZkNodes.add(ZookeeperDiscoverySpiTestHelper.aliveZkNodePath(spi));
} else {
expEvts[expEvtCnt] = ZookeeperDiscoverySpiTestHelper.joinEvent(initNodes + expEvtCnt + 1);
expEvtCnt++;
}
}
ZookeeperDiscoverySpiTestHelper.waitNoAliveZkNodes(log, zkCluster.getConnectString(), failedZkNodes, 30_000);
c0.allowConnect();
for (ZkTestClientCnxnSocketNIO c : blockedC) c.allowConnect();
if (expEvts.length > 0) {
for (int i = 0; i < initNodes; i++) helper.checkEvents(ignite(i), evts, expEvts);
}
fut.get();
waitForTopology(initNodes + startNodes - failCnt);
}
Aggregations