use of org.apache.ignite.IgniteException in project ignite by apache.
the class IgniteProjectionStartStopRestartSelfTest method testStartThreeNodesAndTryToStartOneNode.
/**
* @throws Exception If failed.
*/
public void testStartThreeNodesAndTryToStartOneNode() throws Exception {
joinedLatch = new CountDownLatch(3);
Collection<ClusterStartNodeResult> res = startNodes(ignite.cluster(), maps(Collections.singleton(HOST), SSH_UNAME, pwd, key, 3, U.getIgniteHome(), CFG_NO_ATTR, null), null, false, 0, 16);
assert res.size() == 3;
F.forEach(res, new CI1<ClusterStartNodeResult>() {
@Override
public void apply(ClusterStartNodeResult t) {
assert t.getHostName().equals(HOST);
if (!t.isSuccess())
throw new IgniteException(t.getError());
}
});
assert joinedLatch.await(WAIT_TIMEOUT, MILLISECONDS);
assert joinedCnt.get() == 3;
assert leftCnt.get() == 0;
assert ignite.cluster().nodes().size() == 3;
res = startNodes(ignite.cluster(), maps(Collections.singleton(HOST), SSH_UNAME, pwd, key, 1, U.getIgniteHome(), CFG_NO_ATTR, null), null, false, 0, 16);
assert res.isEmpty();
assert joinedCnt.get() == 3;
assert leftCnt.get() == 0;
assert ignite.cluster().nodes().size() == 3;
}
use of org.apache.ignite.IgniteException in project ignite by apache.
the class IgniteProjectionStartStopRestartSelfTest method testRestartNodesByIds.
/**
* @throws Exception If failed.
*/
public void testRestartNodesByIds() throws Exception {
joinedLatch = new CountDownLatch(3);
Collection<ClusterStartNodeResult> res = startNodes(ignite.cluster(), maps(Collections.singleton(HOST), SSH_UNAME, pwd, key, 3, U.getIgniteHome(), CFG_NO_ATTR, null), null, false, 0, 16);
assert res.size() == 3;
F.forEach(res, new CI1<ClusterStartNodeResult>() {
@Override
public void apply(ClusterStartNodeResult t) {
assert t.getHostName().equals(HOST);
if (!t.isSuccess())
throw new IgniteException(t.getError());
}
});
assert joinedLatch.await(WAIT_TIMEOUT, MILLISECONDS);
assert ignite.cluster().nodes().size() == 3;
joinedLatch = new CountDownLatch(2);
leftLatch = new CountDownLatch(2);
Iterator<ClusterNode> it = ignite.cluster().nodes().iterator();
ignite.cluster().restartNodes(F.asList(it.next().id(), it.next().id()));
assert joinedLatch.await(WAIT_TIMEOUT, MILLISECONDS);
assert leftLatch.await(WAIT_TIMEOUT, MILLISECONDS);
assert ignite.cluster().nodes().size() == 3;
}
use of org.apache.ignite.IgniteException in project ignite by apache.
the class SpringTransactionManager method doRollback.
/**
* {@inheritDoc}
*/
@Override
protected void doRollback(DefaultTransactionStatus status) throws TransactionException {
IgniteTransactionObject txObj = (IgniteTransactionObject) status.getTransaction();
Transaction tx = txObj.getTransactionHolder().getTransaction();
if (status.isDebug() && log.isDebugEnabled())
log.debug("Rolling back Ignite transaction: " + tx);
try {
tx.rollback();
} catch (IgniteException e) {
throw new TransactionSystemException("Could not rollback Ignite transaction", e);
}
}
use of org.apache.ignite.IgniteException in project ignite by apache.
the class GridFactorySelfTest method testDefaultGridGetOrStart.
/**
* Tests default grid
*/
public void testDefaultGridGetOrStart() throws Exception {
IgniteConfiguration cfg = getConfiguration(null);
try (Ignite ignite = Ignition.getOrStart(cfg)) {
try {
Ignition.start(cfg);
fail("Expected exception after grid started");
} catch (IgniteException ignored) {
}
Ignite ignite2 = Ignition.getOrStart(cfg);
assertEquals("Must return same instance", ignite, ignite2);
}
assertTrue(G.allGrids().isEmpty());
}
use of org.apache.ignite.IgniteException in project ignite by apache.
the class GridFactorySelfTest method testConcurrentGridGetOrStartCon.
/**
* Tests concurrent grid initialization
*/
public void testConcurrentGridGetOrStartCon() throws Exception {
final IgniteConfiguration cfg = getConfiguration(null);
final AtomicReference<Ignite> ref = new AtomicReference<>();
try {
GridTestUtils.runMultiThreaded(new Runnable() {
@Override
public void run() {
try {
Ignite ignite = Ignition.getOrStart(cfg);
boolean set = ref.compareAndSet(null, ignite);
if (!set)
assertEquals(ref.get(), ignite);
} catch (IgniteException e) {
throw new RuntimeException("Ignite error", e);
}
}
}, CONCURRENCY, "GridCreatorThread");
} catch (Exception ignored) {
fail("Exception is not expected");
}
G.stopAll(true);
assertTrue(G.allGrids().isEmpty());
}
Aggregations