use of org.apache.ignite.spi.IgniteSpiException in project ignite by apache.
the class TcpClientDiscoverySpiSelfTest method testTimeoutWaitingNodeAddedMessage.
/**
* @throws Exception If any error occurs.
*/
@Test
public void testTimeoutWaitingNodeAddedMessage() throws Exception {
longSockTimeouts = true;
clientFailureDetectionTimeout = 20_000;
startServerNodes(2);
final CountDownLatch cnt = new CountDownLatch(1);
((TcpDiscoverySpi) G.ignite("server-1").configuration().getDiscoverySpi()).addSendMessageListener(new IgniteInClosure<TcpDiscoveryAbstractMessage>() {
@Override
public void apply(TcpDiscoveryAbstractMessage msg) {
try {
cnt.await(10, MINUTES);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IgniteInterruptedException(e);
}
}
});
try {
netTimeout = 500;
startClientGrid("client-0");
assert false;
} catch (IgniteCheckedException e) {
cnt.countDown();
IgniteSpiException spiEx = e.getCause(IgniteSpiException.class);
assert spiEx != null : e;
assert spiEx.getMessage().contains("Join process timed out") : spiEx.getMessage();
}
}
use of org.apache.ignite.spi.IgniteSpiException in project ignite by apache.
the class ZookeeperDiscoveryImpl method marshalCredentialsOnJoin.
/**
* Marshalls credentials with discovery SPI marshaller (will replace attribute value).
*
* @param node Node to marshall credentials for.
* @throws IgniteSpiException If marshalling failed.
*/
private void marshalCredentialsOnJoin(ZookeeperClusterNode node) throws IgniteSpiException {
try {
// Use security-unsafe getter.
Map<String, Object> attrs0 = node.getAttributes();
Object creds = attrs0.get(ATTR_SECURITY_CREDENTIALS);
if (creds != null) {
Map<String, Object> attrs = new HashMap<>(attrs0);
assert !(creds instanceof byte[]);
attrs.put(ATTR_SECURITY_CREDENTIALS, marshalZip(creds));
node.setAttributes(attrs);
}
} catch (IgniteCheckedException e) {
throw new IgniteSpiException("Failed to marshal node security credentials: " + node.id(), e);
}
}
use of org.apache.ignite.spi.IgniteSpiException in project ignite by apache.
the class ZookeeperDiscoveryImpl method initZkNodes.
/**
* @throws InterruptedException If interrupted.
*/
private void initZkNodes() throws InterruptedException {
try {
ZookeeperClient client = rtState.zkClient;
if (!client.exists(zkPaths.clusterDir)) {
createRootPathParents(zkPaths.clusterDir, client);
client.createIfNeeded(zkPaths.clusterDir, null, PERSISTENT);
}
List<String> createdDirs = client.getChildren(zkPaths.clusterDir);
String[] requiredDirs = { zkPaths.evtsPath, zkPaths.joinDataDir, zkPaths.customEvtsDir, zkPaths.customEvtsPartsDir, zkPaths.customEvtsAcksDir, zkPaths.aliveNodesDir, zkPaths.stoppedNodesFlagsDir };
List<String> dirs = new ArrayList<>();
for (String dir : requiredDirs) {
String dir0 = dir.substring(zkPaths.clusterDir.length() + 1);
if (!createdDirs.contains(dir0))
dirs.add(dir);
}
if (!dirs.isEmpty())
client.createAll(dirs, PERSISTENT);
} catch (ZookeeperClientFailedException e) {
throw new IgniteSpiException("Failed to initialize Zookeeper nodes", e);
}
}
use of org.apache.ignite.spi.IgniteSpiException in project ignite by apache.
the class ZookeeperDiscoveryImpl method pingNode.
/**
* @param nodeId Node ID.
* @return Ping result.
*/
public boolean pingNode(UUID nodeId) {
checkState();
ZkRuntimeState rtState = this.rtState;
ZookeeperClusterNode node = rtState.top.nodesById.get(nodeId);
if (node == null)
return false;
if (node.isLocal())
return true;
PingFuture fut = pingFuts.get(node.order());
if (fut == null) {
fut = new PingFuture(rtState, node);
PingFuture old = pingFuts.putIfAbsent(node.order(), fut);
if (old == null) {
if (fut.checkNodeAndState())
spi.getSpiContext().addTimeoutObject(fut);
else
assert fut.isDone();
} else
fut = old;
}
try {
return fut.get();
} catch (IgniteCheckedException e) {
throw new IgniteSpiException(e);
}
}
use of org.apache.ignite.spi.IgniteSpiException in project ignite by apache.
the class ZookeeperDiscoveryClientDisconnectTest method testStartNoServers_FailOnTimeout.
/**
*/
@Test
public void testStartNoServers_FailOnTimeout() {
joinTimeout = 3000;
long start = System.currentTimeMillis();
Throwable err = GridTestUtils.assertThrows(log, new Callable<Void>() {
@Override
public Void call() throws Exception {
startClientGrid(0);
return null;
}
}, IgniteCheckedException.class, null);
assertTrue(System.currentTimeMillis() >= start + joinTimeout);
IgniteSpiException spiErr = X.cause(err, IgniteSpiException.class);
assertNotNull(spiErr);
assertTrue(spiErr.getMessage().contains("Failed to connect to cluster within configured timeout"));
}
Aggregations