Search in sources :

Example 51 with IgniteSpiException

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();
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) TcpDiscoveryAbstractMessage(org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage) IgniteInterruptedException(org.apache.ignite.IgniteInterruptedException) IgniteSpiException(org.apache.ignite.spi.IgniteSpiException) CountDownLatch(java.util.concurrent.CountDownLatch) IgniteInterruptedException(org.apache.ignite.IgniteInterruptedException) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 52 with IgniteSpiException

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);
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) IgniteSpiTimeoutObject(org.apache.ignite.spi.IgniteSpiTimeoutObject) IgniteSpiException(org.apache.ignite.spi.IgniteSpiException)

Example 53 with IgniteSpiException

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);
    }
}
Also used : ArrayList(java.util.ArrayList) IgniteSpiException(org.apache.ignite.spi.IgniteSpiException)

Example 54 with IgniteSpiException

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);
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteSpiException(org.apache.ignite.spi.IgniteSpiException)

Example 55 with IgniteSpiException

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"));
}
Also used : IgniteSpiException(org.apache.ignite.spi.IgniteSpiException) IgniteSpiException(org.apache.ignite.spi.IgniteSpiException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) Test(org.junit.Test)

Aggregations

IgniteSpiException (org.apache.ignite.spi.IgniteSpiException)131 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)59 IOException (java.io.IOException)32 InetSocketAddress (java.net.InetSocketAddress)22 ClusterNode (org.apache.ignite.cluster.ClusterNode)21 IgniteInterruptedCheckedException (org.apache.ignite.internal.IgniteInterruptedCheckedException)21 IgniteException (org.apache.ignite.IgniteException)20 ArrayList (java.util.ArrayList)14 ClusterTopologyCheckedException (org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)14 HashMap (java.util.HashMap)13 UUID (java.util.UUID)13 Nullable (org.jetbrains.annotations.Nullable)12 Test (org.junit.Test)12 File (java.io.File)10 Message (org.apache.ignite.plugin.extensions.communication.Message)10 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)9 SSLException (javax.net.ssl.SSLException)8 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)8 SocketTimeoutException (java.net.SocketTimeoutException)7 Ignite (org.apache.ignite.Ignite)7