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);
}
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++;
}
}
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);
}
}
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);
}
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;
}
Aggregations