Search in sources :

Example 11 with TransactionConcurrency

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

the class IgniteTxStoreExceptionAbstractSelfTest 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 TransactionConcurrency

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

the class IgniteTxExceptionAbstractSelfTest method testPutPrimaryTx.

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

Example 13 with TransactionConcurrency

use of org.apache.ignite.transactions.TransactionConcurrency 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 14 with TransactionConcurrency

use of org.apache.ignite.transactions.TransactionConcurrency 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 15 with TransactionConcurrency

use of org.apache.ignite.transactions.TransactionConcurrency 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)

Aggregations

TransactionConcurrency (org.apache.ignite.transactions.TransactionConcurrency)48 TransactionIsolation (org.apache.ignite.transactions.TransactionIsolation)42 Transaction (org.apache.ignite.transactions.Transaction)27 Ignite (org.apache.ignite.Ignite)18 IgniteTransactions (org.apache.ignite.IgniteTransactions)11 IgniteCache (org.apache.ignite.IgniteCache)7 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 IgniteException (org.apache.ignite.IgniteException)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 CacheException (javax.cache.CacheException)4 Map (java.util.Map)3 TreeMap (java.util.TreeMap)3 Callable (java.util.concurrent.Callable)3 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)3 HashSet (java.util.HashSet)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 FactoryBuilder (javax.cache.configuration.FactoryBuilder)2 MutableEntry (javax.cache.processor.MutableEntry)2