Search in sources :

Example 56 with IgniteSpiException

use of org.apache.ignite.spi.IgniteSpiException in project ignite by apache.

the class ZookeeperDiscoveryCommunicationFailureTest method communicationFailureResolve_KillNodes.

/**
 * @param startNodes Number of nodes to start.
 * @param killNodes Nodes to kill by resolve process.
 * @throws Exception If failed.
 */
private void communicationFailureResolve_KillNodes(int startNodes, Collection<Long> killNodes) throws Exception {
    testCommSpi = true;
    commFailureRslvr = TestNodeKillCommunicationFailureResolver.factory(killNodes);
    startGrids(startNodes);
    ZkTestCommunicationSpi commSpi = ZkTestCommunicationSpi.testSpi(ignite(0));
    commSpi.checkRes = new BitSet(startNodes);
    ZookeeperDiscoverySpi spi = null;
    UUID killNodeId = null;
    for (Ignite node : G.allGrids()) {
        ZookeeperDiscoverySpi spi0 = spi(node);
        if (!killNodes.contains(node.cluster().localNode().order()))
            spi = spi0;
        else
            killNodeId = node.cluster().localNode().id();
    }
    assertNotNull(spi);
    assertNotNull(killNodeId);
    try {
        spi.resolveCommunicationFailure(spi.getNode(killNodeId), new Exception("test"));
        fail("Exception is not thrown");
    } catch (IgniteSpiException e) {
        assertTrue("Unexpected exception: " + e, e.getCause() instanceof ClusterTopologyCheckedException);
    }
    int expNodes = startNodes - killNodes.size();
    waitForTopology(expNodes);
    for (Ignite node : G.allGrids()) assertFalse(killNodes.contains(node.cluster().localNode().order()));
    startGrid(startNodes);
    waitForTopology(expNodes + 1);
}
Also used : BitSet(java.util.BitSet) ZookeeperDiscoverySpi(org.apache.ignite.spi.discovery.zk.ZookeeperDiscoverySpi) Ignite(org.apache.ignite.Ignite) IgniteSpiException(org.apache.ignite.spi.IgniteSpiException) UUID(java.util.UUID) IgniteSpiException(org.apache.ignite.spi.IgniteSpiException) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)

Example 57 with IgniteSpiException

use of org.apache.ignite.spi.IgniteSpiException 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++;
    }
}
Also used : ZookeeperDiscoverySpi(org.apache.ignite.spi.discovery.zk.ZookeeperDiscoverySpi) Ignite(org.apache.ignite.Ignite) IgniteSpiException(org.apache.ignite.spi.IgniteSpiException) UUID(java.util.UUID) IgniteSpiException(org.apache.ignite.spi.IgniteSpiException) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException) Test(org.junit.Test)

Example 58 with IgniteSpiException

use of org.apache.ignite.spi.IgniteSpiException 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);
    }
}
Also used : ZookeeperDiscoverySpi(org.apache.ignite.spi.discovery.zk.ZookeeperDiscoverySpi) Ignite(org.apache.ignite.Ignite) IgniteSpiException(org.apache.ignite.spi.IgniteSpiException) IgniteSpiException(org.apache.ignite.spi.IgniteSpiException) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 59 with IgniteSpiException

use of org.apache.ignite.spi.IgniteSpiException in project ignite by apache.

the class ZookeeperDiscoveryMiscTest method testLocalAuthenticationFails.

/**
 * @throws Exception If failed.
 */
@Test
public void testLocalAuthenticationFails() throws Exception {
    auth = ZkTestNodeAuthenticator.factory(getTestIgniteInstanceName(0));
    Throwable err = GridTestUtils.assertThrows(log, new Callable<Void>() {

        @Override
        public Void call() throws Exception {
            startGrid(0);
            return null;
        }
    }, IgniteCheckedException.class, null);
    IgniteSpiException spiErr = X.cause(err, IgniteSpiException.class);
    assertNotNull(spiErr);
    assertTrue(spiErr.getMessage().contains("Failed to authenticate local node"));
    startGrid(1);
    startGrid(2);
    checkTestSecuritySubject(2);
}
Also used : IgniteSpiException(org.apache.ignite.spi.IgniteSpiException) IgniteSpiException(org.apache.ignite.spi.IgniteSpiException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) Test(org.junit.Test)

Example 60 with IgniteSpiException

use of org.apache.ignite.spi.IgniteSpiException in project ignite by apache.

the class GridUriDeploymentDiscovery method getClasses.

/**
 * Load classes from given file. File could be either directory or JAR file.
 *
 * @param clsLdr Class loader to load files.
 * @param file Either directory or JAR file which contains classes or
 *      references to them.
 * @return Set of found and loaded classes or empty set if file does not
 *      exist.
 * @throws org.apache.ignite.spi.IgniteSpiException Thrown if given JAR file references to none
 *      existed class or IOException occurred during processing.
 */
static Set<Class<? extends ComputeTask<?, ?>>> getClasses(ClassLoader clsLdr, File file) throws IgniteSpiException {
    Set<Class<? extends ComputeTask<?, ?>>> rsrcs = new HashSet<>();
    if (!file.exists())
        return rsrcs;
    GridUriDeploymentFileResourceLoader fileRsrcLdr = new GridUriDeploymentFileResourceLoader(clsLdr, file);
    if (file.isDirectory())
        findResourcesInDirectory(fileRsrcLdr, file, rsrcs);
    else {
        try {
            for (JarEntry entry : U.asIterable(new JarFile(file.getAbsolutePath()).entries())) {
                Class<? extends ComputeTask<?, ?>> rsrc = fileRsrcLdr.createResource(entry.getName(), false);
                if (rsrc != null)
                    rsrcs.add(rsrc);
            }
        } catch (IOException e) {
            throw new IgniteSpiException("Failed to discover classes in file: " + file.getAbsolutePath(), e);
        }
    }
    return rsrcs;
}
Also used : ComputeTask(org.apache.ignite.compute.ComputeTask) IOException(java.io.IOException) IgniteSpiException(org.apache.ignite.spi.IgniteSpiException) JarEntry(java.util.jar.JarEntry) JarFile(java.util.jar.JarFile) HashSet(java.util.HashSet)

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