Search in sources :

Example 61 with TransactionIsolation

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

the class TxDeadlockCauseTest method testCause.

/**
 * @throws Exception If failed.
 */
@Test
public void testCause() throws Exception {
    startGrids(1);
    for (TransactionIsolation isolation : TransactionIsolation.values()) {
        checkCauseObject(1, 2, 1000, isolation, true);
        checkCauseObject(1, 2, 1000, isolation, false);
    }
}
Also used : TransactionIsolation(org.apache.ignite.transactions.TransactionIsolation) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 62 with TransactionIsolation

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

the class TxDeadlockCauseTest method testCauseSeveralNodes.

/**
 * @throws Exception If failed.
 */
@Test
public void testCauseSeveralNodes() throws Exception {
    startGrids(2);
    for (TransactionIsolation isolation : TransactionIsolation.values()) {
        checkCauseObject(2, 2, 1500, isolation, true);
        checkCauseObject(2, 2, 1500, isolation, false);
    }
}
Also used : TransactionIsolation(org.apache.ignite.transactions.TransactionIsolation) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 63 with TransactionIsolation

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

the class TxDeadlockCauseTest method testCauseNear.

/**
 * @throws Exception If failed.
 */
@Test
public void testCauseNear() throws Exception {
    ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME).setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL).setNearConfiguration(new NearCacheConfiguration());
    startGrids(1);
    for (TransactionIsolation isolation : TransactionIsolation.values()) {
        checkCauseObject(1, 2, 1000, isolation, true);
        checkCauseObject(1, 2, 1000, isolation, false);
    }
}
Also used : TransactionIsolation(org.apache.ignite.transactions.TransactionIsolation) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 64 with TransactionIsolation

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

the class TxDeadlockCauseTest method testCauseSeveralNodesNear.

/**
 * @throws Exception If failed.
 */
@Test
public void testCauseSeveralNodesNear() throws Exception {
    ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME).setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL).setNearConfiguration(new NearCacheConfiguration());
    startGrids(4);
    for (TransactionIsolation isolation : TransactionIsolation.values()) {
        checkCauseObject(2, 2, 2000, isolation, true);
        checkCauseObject(2, 2, 2000, isolation, false);
    }
}
Also used : TransactionIsolation(org.apache.ignite.transactions.TransactionIsolation) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 65 with TransactionIsolation

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

the class CacheReadThroughRestartSelfTest method testReadThroughInTx.

/**
 * @throws Exception If failed.
 */
private void testReadThroughInTx(boolean needVer) throws Exception {
    IgniteCache<String, Integer> cache = grid(1).cache(DEFAULT_CACHE_NAME);
    for (int k = 0; k < 1000; k++) cache.put("key" + k, k);
    stopAllGrids();
    startGrids(2);
    awaitPartitionMapExchange();
    Ignite ignite = grid(1);
    cache = ignite.cache(DEFAULT_CACHE_NAME).withAllowAtomicOpsInTx();
    for (TransactionConcurrency txConcurrency : TransactionConcurrency.values()) {
        for (TransactionIsolation txIsolation : TransactionIsolation.values()) {
            if (MvccFeatureChecker.forcedMvcc() && !MvccFeatureChecker.isSupported(txConcurrency, txIsolation))
                continue;
            try (Transaction tx = ignite.transactions().txStart(txConcurrency, txIsolation, 100000, 1000)) {
                for (int k = 0; k < 1000; k++) {
                    String key = "key" + k;
                    if (needVer) {
                        assertNotNull("Null value for key: " + key, cache.getEntry(key));
                        assertNotNull("Null value for key: " + key, cache.getEntry(key));
                    } else {
                        assertNotNull("Null value for key: " + key, cache.get(key));
                        assertNotNull("Null value for key: " + key, cache.get(key));
                    }
                }
                tx.commit();
            }
        }
    }
}
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)

Aggregations

TransactionIsolation (org.apache.ignite.transactions.TransactionIsolation)88 TransactionConcurrency (org.apache.ignite.transactions.TransactionConcurrency)71 Test (org.junit.Test)53 Transaction (org.apache.ignite.transactions.Transaction)52 Ignite (org.apache.ignite.Ignite)33 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)27 IgniteCache (org.apache.ignite.IgniteCache)14 IgniteTransactions (org.apache.ignite.IgniteTransactions)13 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)12 ArrayList (java.util.ArrayList)9 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)9 IgniteEx (org.apache.ignite.internal.IgniteEx)9 IgniteException (org.apache.ignite.IgniteException)8 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)7 HashMap (java.util.HashMap)6 Map (java.util.Map)5 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)5 TransactionTimeoutException (org.apache.ignite.transactions.TransactionTimeoutException)5 List (java.util.List)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)4