use of org.apache.zookeeper.ZkTestClientCnxnSocketNIO in project ignite by apache.
the class ZookeeperDiscoveryRandomStopOrFailConcurrentTest method stopOrKillMultithreaded.
/**
*/
private void stopOrKillMultithreaded(final List<Integer> stopIndices) throws Exception {
log.info("Stopping or killing nodes by idx: " + stopIndices.toString());
final StopMode mode = stopMode;
GridTestUtils.runMultiThreaded((idx) -> {
try {
Random rnd = ThreadLocalRandom.current();
int nodeIdx = stopIndices.get(idx);
if (mode == StopMode.FAIL_ONLY || (mode == StopMode.RANDOM && rnd.nextBoolean())) {
ZkTestClientCnxnSocketNIO c0 = ZkTestClientCnxnSocketNIO.forNode(grid(nodeIdx));
c0.closeSocket(true);
nodesFailed.incrementAndGet();
} else {
stopGrid(nodeIdx);
nodesLeft.incrementAndGet();
}
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}, stopIndices.size(), "stop-node");
}
use of org.apache.zookeeper.ZkTestClientCnxnSocketNIO in project ignite by apache.
the class ZookeeperDiscoveryClientDisconnectTest method testReconnectDisabled_ConnectionLost.
/**
* @throws Exception If failed.
*/
@Test
public void testReconnectDisabled_ConnectionLost() throws Exception {
clientReconnectDisabled = true;
startGrid(0);
sesTimeout = 3000;
testSockNio = true;
Ignite client = startClientGrid(1);
final CountDownLatch latch = new CountDownLatch(1);
client.events().localListen(new IgnitePredicate<Event>() {
@Override
public boolean apply(Event evt) {
latch.countDown();
return false;
}
}, EventType.EVT_NODE_SEGMENTED);
ZkTestClientCnxnSocketNIO nio = ZkTestClientCnxnSocketNIO.forNode(client);
nio.closeSocket(true);
try {
ZookeeperDiscoverySpiTestHelper.waitNoAliveZkNodes(log, zkCluster.getConnectString(), Collections.singletonList(ZookeeperDiscoverySpiTestHelper.aliveZkNodePath(client)), 10_000);
} finally {
nio.allowConnect();
}
assertTrue(latch.await(10, SECONDS));
}
use of org.apache.zookeeper.ZkTestClientCnxnSocketNIO in project ignite by apache.
the class ZookeeperDiscoveryCommunicationFailureTest method testNoOpCommunicationErrorResolve_3.
/**
* Tests case when one node fails before sending communication status.
*
* @throws Exception If failed.
*/
@Test
public void testNoOpCommunicationErrorResolve_3() throws Exception {
sesTimeout = 2000;
commFailureRslvr = NoOpCommunicationFailureResolver.FACTORY;
startGridsMultiThreaded(3);
sesTimeout = 10_000;
testSockNio = true;
sesTimeout = 5000;
startGrid(3);
IgniteInternalFuture<?> fut = GridTestUtils.runAsync(new Callable<Object>() {
@Override
public Object call() {
ZookeeperDiscoverySpi spi = spi(ignite(0));
spi.resolveCommunicationFailure(ignite(1).cluster().localNode(), new Exception("test"));
return null;
}
});
U.sleep(1000);
ZkTestClientCnxnSocketNIO nio = ZkTestClientCnxnSocketNIO.forNode(ignite(3));
nio.closeSocket(true);
try {
stopGrid(3);
fut.get();
} finally {
nio.allowConnect();
}
waitForTopology(3);
}
use of org.apache.zookeeper.ZkTestClientCnxnSocketNIO 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.zookeeper.ZkTestClientCnxnSocketNIO in project ignite by apache.
the class ZookeeperDiscoverySegmentationAndConnectionRestoreTest method testConnectionRestore2.
/**
* @throws Exception If failed.
*/
@Test
public void testConnectionRestore2() throws Exception {
testSockNio = true;
Ignite node0 = startGrid(0);
ZkTestClientCnxnSocketNIO c0 = ZkTestClientCnxnSocketNIO.forNode(node0);
c0.closeSocket(false);
startGridsMultiThreaded(1, 5);
}
Aggregations