Search in sources :

Example 11 with TransactionIsolation

use of org.apache.ignite.transactions.TransactionIsolation in project ignite by apache.

the class IgniteTxExceptionAbstractSelfTest method testPutNearTx.

/**
     * @throws Exception If failed.
     */
public void testPutNearTx() throws Exception {
    for (TransactionConcurrency concurrency : TransactionConcurrency.values()) {
        for (TransactionIsolation isolation : TransactionIsolation.values()) {
            checkPutTx(true, concurrency, isolation, keyForNode(grid(0).localNode(), NOT_PRIMARY_AND_BACKUP));
            checkPutTx(false, concurrency, isolation, keyForNode(grid(0).localNode(), NOT_PRIMARY_AND_BACKUP));
        }
    }
}
Also used : TransactionConcurrency(org.apache.ignite.transactions.TransactionConcurrency) TransactionIsolation(org.apache.ignite.transactions.TransactionIsolation)

Example 12 with TransactionIsolation

use of org.apache.ignite.transactions.TransactionIsolation in project ignite by apache.

the class WithKeepBinaryCacheFullApiTest method testInvokeAllAsyncTx.

/**
     * @throws Exception If failed.
     */
@SuppressWarnings("serial")
public void testInvokeAllAsyncTx() throws Exception {
    if (!txShouldBeUsed())
        return;
    for (TransactionConcurrency conc : TransactionConcurrency.values()) {
        for (TransactionIsolation isolation : TransactionIsolation.values()) {
            checkInvokeAllAsycnTx(conc, isolation);
            jcache().removeAll();
        }
    }
}
Also used : TransactionConcurrency(org.apache.ignite.transactions.TransactionConcurrency) TransactionIsolation(org.apache.ignite.transactions.TransactionIsolation)

Example 13 with TransactionIsolation

use of org.apache.ignite.transactions.TransactionIsolation in project ignite by apache.

the class IndexingSpiQuerySelfTest method testIndexingSpiFailure.

/**
     * @throws Exception If failed.
     */
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
public void testIndexingSpiFailure() throws Exception {
    IgniteConfiguration cfg = configuration();
    cfg.setIndexingSpi(new MyBrokenIndexingSpi());
    Ignite ignite = Ignition.start(cfg);
    CacheConfiguration<Integer, Integer> ccfg = cacheConfiguration(CACHE_NAME);
    ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
    final IgniteCache<Integer, Integer> cache = ignite.createCache(ccfg);
    final IgniteTransactions txs = ignite.transactions();
    for (final TransactionConcurrency concurrency : TransactionConcurrency.values()) {
        for (final TransactionIsolation isolation : TransactionIsolation.values()) {
            System.out.println("Run in transaction: " + concurrency + " " + isolation);
            GridTestUtils.assertThrowsWithCause(new Callable<Void>() {

                @Override
                public Void call() throws Exception {
                    Transaction tx;
                    try (Transaction tx0 = tx = txs.txStart(concurrency, isolation)) {
                        cache.put(1, 1);
                        tx0.commit();
                    }
                    assertEquals(TransactionState.ROLLED_BACK, tx.state());
                    return null;
                }
            }, IgniteTxHeuristicCheckedException.class);
        }
    }
}
Also used : TransactionIsolation(org.apache.ignite.transactions.TransactionIsolation) IgniteTransactions(org.apache.ignite.IgniteTransactions) IgniteSpiException(org.apache.ignite.spi.IgniteSpiException) IgniteTxHeuristicCheckedException(org.apache.ignite.internal.transactions.IgniteTxHeuristicCheckedException) TransactionConcurrency(org.apache.ignite.transactions.TransactionConcurrency) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Transaction(org.apache.ignite.transactions.Transaction) Ignite(org.apache.ignite.Ignite)

Example 14 with TransactionIsolation

use of org.apache.ignite.transactions.TransactionIsolation in project ignite by apache.

the class IndexingSpiQueryTxSelfTest method testIndexingSpiWithTx.

/**
     * @throws Exception If failed.
     */
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
public void testIndexingSpiWithTx() throws Exception {
    IgniteEx ignite = grid(0);
    final IgniteCache<Integer, Integer> cache = ignite.cache("test-cache");
    final IgniteTransactions txs = ignite.transactions();
    for (final TransactionConcurrency concurrency : TransactionConcurrency.values()) {
        for (final TransactionIsolation isolation : TransactionIsolation.values()) {
            System.out.println("Run in transaction: " + concurrency + " " + isolation);
            GridTestUtils.assertThrowsWithCause(new Callable<Void>() {

                @Override
                public Void call() throws Exception {
                    Transaction tx;
                    try (Transaction tx0 = tx = txs.txStart(concurrency, isolation)) {
                        cache.put(1, 1);
                        tx0.commit();
                    }
                    assertEquals(TransactionState.ROLLED_BACK, tx.state());
                    return null;
                }
            }, IgniteTxHeuristicCheckedException.class);
        }
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TransactionConcurrency(org.apache.ignite.transactions.TransactionConcurrency) Transaction(org.apache.ignite.transactions.Transaction) IgniteEx(org.apache.ignite.internal.IgniteEx) TransactionIsolation(org.apache.ignite.transactions.TransactionIsolation) IgniteTransactions(org.apache.ignite.IgniteTransactions) IgniteTxHeuristicCheckedException(org.apache.ignite.internal.transactions.IgniteTxHeuristicCheckedException) IgniteSpiException(org.apache.ignite.spi.IgniteSpiException)

Example 15 with TransactionIsolation

use of org.apache.ignite.transactions.TransactionIsolation in project ignite by apache.

the class WithKeepBinaryCacheFullApiTest method testInvokeAsyncTx.

/**
     * @throws Exception If failed.
     */
public void testInvokeAsyncTx() throws Exception {
    if (!txShouldBeUsed())
        return;
    for (TransactionConcurrency conc : TransactionConcurrency.values()) {
        for (TransactionIsolation isolation : TransactionIsolation.values()) {
            checkInvokeAsyncTx(conc, isolation);
            jcache().removeAll();
        }
    }
}
Also used : TransactionConcurrency(org.apache.ignite.transactions.TransactionConcurrency) TransactionIsolation(org.apache.ignite.transactions.TransactionIsolation)

Aggregations

TransactionConcurrency (org.apache.ignite.transactions.TransactionConcurrency)42 TransactionIsolation (org.apache.ignite.transactions.TransactionIsolation)42 Transaction (org.apache.ignite.transactions.Transaction)24 Ignite (org.apache.ignite.Ignite)15 IgniteTransactions (org.apache.ignite.IgniteTransactions)9 IgniteCache (org.apache.ignite.IgniteCache)6 HashMap (java.util.HashMap)3 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 HashSet (java.util.HashSet)2 IgniteException (org.apache.ignite.IgniteException)2 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)2 IgniteEx (org.apache.ignite.internal.IgniteEx)2 IgniteTxHeuristicCheckedException (org.apache.ignite.internal.transactions.IgniteTxHeuristicCheckedException)2 IgniteSpiException (org.apache.ignite.spi.IgniteSpiException)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 Callable (java.util.concurrent.Callable)1 CyclicBarrier (java.util.concurrent.CyclicBarrier)1