Search in sources :

Example 41 with TransactionIsolation

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

the class GridCacheBinaryObjectsAbstractSelfTest method testKeepBinaryTxOverwrite.

/**
     * @throws Exception if failed.
     */
public void testKeepBinaryTxOverwrite() throws Exception {
    if (atomicityMode() != TRANSACTIONAL)
        return;
    IgniteCache<Integer, TestObject> cache = ignite(0).cache(DEFAULT_CACHE_NAME);
    cache.put(0, new TestObject(1));
    for (TransactionConcurrency conc : TransactionConcurrency.values()) {
        for (TransactionIsolation iso : TransactionIsolation.values()) {
            try (Transaction tx = ignite(0).transactions().txStart(conc, iso)) {
                cache.withKeepBinary().get(0);
                cache.invoke(0, new ObjectEntryProcessor());
                tx.commit();
            }
        }
    }
}
Also used : TransactionConcurrency(org.apache.ignite.transactions.TransactionConcurrency) Transaction(org.apache.ignite.transactions.Transaction) TransactionIsolation(org.apache.ignite.transactions.TransactionIsolation)

Example 42 with TransactionIsolation

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

the class GridTransformSpringInjectionSelfTest method testTransformResourceInjection.

/**
     * @throws Exception If failed.
     */
public void testTransformResourceInjection() throws Exception {
    Ignite grid = grid(0);
    IgniteCache<String, Integer> cache = grid.createCache(cacheConfiguration(ATOMIC));
    try {
        doTransformResourceInjection(cache);
    } finally {
        cache.destroy();
    }
    cache = grid.createCache(cacheConfiguration(TRANSACTIONAL));
    try {
        doTransformResourceInjection(cache);
        for (TransactionConcurrency concurrency : TransactionConcurrency.values()) {
            for (TransactionIsolation isolation : TransactionIsolation.values()) {
                IgniteTransactions txs = grid.transactions();
                try (Transaction tx = txs.txStart(concurrency, isolation)) {
                    doTransformResourceInjection(cache);
                    tx.commit();
                }
            }
        }
    } finally {
        cache.destroy();
    }
}
Also used : TransactionConcurrency(org.apache.ignite.transactions.TransactionConcurrency) Transaction(org.apache.ignite.transactions.Transaction) TransactionIsolation(org.apache.ignite.transactions.TransactionIsolation) Ignite(org.apache.ignite.Ignite) IgniteTransactions(org.apache.ignite.IgniteTransactions)

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