Search in sources :

Example 51 with IgniteException

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;
}
Also used : IgniteException(org.apache.ignite.IgniteException) CountDownLatch(java.util.concurrent.CountDownLatch) ClusterStartNodeResult(org.apache.ignite.cluster.ClusterStartNodeResult)

Example 52 with IgniteException

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;
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteException(org.apache.ignite.IgniteException) CountDownLatch(java.util.concurrent.CountDownLatch) ClusterStartNodeResult(org.apache.ignite.cluster.ClusterStartNodeResult)

Example 53 with IgniteException

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);
    }
}
Also used : Transaction(org.apache.ignite.transactions.Transaction) IgniteException(org.apache.ignite.IgniteException) TransactionSystemException(org.springframework.transaction.TransactionSystemException)

Example 54 with IgniteException

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());
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) IgniteException(org.apache.ignite.IgniteException) Ignite(org.apache.ignite.Ignite)

Example 55 with IgniteException

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());
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) IgniteException(org.apache.ignite.IgniteException) IgniteRunnable(org.apache.ignite.lang.IgniteRunnable) Ignite(org.apache.ignite.Ignite) AtomicReference(java.util.concurrent.atomic.AtomicReference) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) IgniteSpiException(org.apache.ignite.spi.IgniteSpiException) BeansException(org.springframework.beans.BeansException)

Aggregations

IgniteException (org.apache.ignite.IgniteException)498 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)160 Ignite (org.apache.ignite.Ignite)97 ClusterNode (org.apache.ignite.cluster.ClusterNode)54 ArrayList (java.util.ArrayList)52 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)45 CountDownLatch (java.util.concurrent.CountDownLatch)44 UUID (java.util.UUID)43 IOException (java.io.IOException)39 CacheException (javax.cache.CacheException)35 HashMap (java.util.HashMap)34 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)34 Transaction (org.apache.ignite.transactions.Transaction)34 List (java.util.List)24 CyclicBarrier (java.util.concurrent.CyclicBarrier)21 Map (java.util.Map)20 Collection (java.util.Collection)18 ClusterStartNodeResult (org.apache.ignite.cluster.ClusterStartNodeResult)18 ClusterTopologyCheckedException (org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)18 IgniteClientDisconnectedException (org.apache.ignite.IgniteClientDisconnectedException)17