use of org.apache.ignite.transactions.TransactionIsolation in project ignite by apache.
the class IgniteCacheClusterReadOnlyModeSelfTest method testGetAllOutTxAsyncAllowed.
/**
*/
@Test
public void testGetAllOutTxAsyncAllowed() {
performAction((node, cache) -> {
for (TransactionConcurrency level : TransactionConcurrency.values()) {
for (TransactionIsolation isolation : TransactionIsolation.values()) {
CacheConfiguration cfg = cache.getConfiguration(CacheConfiguration.class);
if (level == OPTIMISTIC && cfg.getAtomicityMode() == TRANSACTIONAL_SNAPSHOT) {
// Only pessimistic transactions are supported when MVCC is enabled.
continue;
}
Transaction tx = node.transactions().txStart(level, isolation);
try {
cache.get(UNKNOWN_KEY);
assertEquals(kvMap, cache.getAllOutTxAsync(kvMap.keySet()).get());
tx.commit();
} catch (Exception e) {
RuntimeException ex = new RuntimeException(new AssertionError("Got exception on node: " + node.name() + " cache: " + cache.getName() + " isolation: " + isolation + " txLevel: " + level, e));
log.error("", ex);
tx.rollback();
throw ex;
}
}
}
}, TX_CACHES_PRED.or(MVCC_CACHES_PRED));
}
use of org.apache.ignite.transactions.TransactionIsolation in project ignite by apache.
the class IgniteCacheClusterReadOnlyModeSelfTest method testGetAllOutTxAllowed.
/**
*/
@Test
public void testGetAllOutTxAllowed() {
performAction((node, cache) -> {
for (TransactionConcurrency level : TransactionConcurrency.values()) {
for (TransactionIsolation isolation : TransactionIsolation.values()) {
CacheConfiguration cfg = cache.getConfiguration(CacheConfiguration.class);
if (level == OPTIMISTIC && cfg.getAtomicityMode() == TRANSACTIONAL_SNAPSHOT) {
// Only pessimistic transactions are supported when MVCC is enabled.
continue;
}
Transaction tx = node.transactions().txStart(level, isolation);
try {
cache.get(UNKNOWN_KEY);
assertEquals(kvMap, cache.getAllOutTx(kvMap.keySet()));
tx.commit();
} catch (Exception e) {
RuntimeException ex = new RuntimeException(new AssertionError("Got exception on node: " + node.name() + " cache: " + cache.getName() + " isolation: " + isolation + " txLevel: " + level, e));
log.error("", ex);
tx.rollback();
throw ex;
}
}
}
}, TX_CACHES_PRED.or(MVCC_CACHES_PRED));
}
use of org.apache.ignite.transactions.TransactionIsolation in project ignite by apache.
the class CacheLateAffinityAssignmentTest method cacheOperations.
/**
* @param cache Cache
*/
private void cacheOperations(IgniteCache<Object, Object> cache) {
ThreadLocalRandom rnd = ThreadLocalRandom.current();
final int KEYS = 10_000;
try {
cache.get(rnd.nextInt(KEYS));
cache.put(rnd.nextInt(KEYS), rnd.nextInt(10));
cache.getAndPut(rnd.nextInt(KEYS), rnd.nextInt(10));
cache.remove(rnd.nextInt(KEYS));
cache.getAndRemove(rnd.nextInt(KEYS));
cache.remove(rnd.nextInt(KEYS), rnd.nextInt(10));
cache.putIfAbsent(rnd.nextInt(KEYS), rnd.nextInt(10));
cache.replace(rnd.nextInt(KEYS), rnd.nextInt(10));
cache.replace(rnd.nextInt(KEYS), rnd.nextInt(10), rnd.nextInt(10));
cache.invoke(rnd.nextInt(KEYS), new TestEntryProcessor(rnd.nextInt(10)));
if (cache.getConfiguration(CacheConfiguration.class).getAtomicityMode() == TRANSACTIONAL) {
IgniteTransactions txs = cache.unwrap(Ignite.class).transactions();
for (TransactionConcurrency concurrency : TransactionConcurrency.values()) {
for (TransactionIsolation isolation : TransactionIsolation.values()) {
try (Transaction tx = txs.txStart(concurrency, isolation)) {
Integer key = rnd.nextInt(KEYS);
cache.getAndPut(key, rnd.nextInt(10));
cache.invoke(key + 1, new TestEntryProcessor(rnd.nextInt(10)));
cache.get(key + 2);
tx.commit();
}
}
}
}
} catch (Exception e) {
log.info("Cache operation failed: " + e);
}
}
use of org.apache.ignite.transactions.TransactionIsolation in project ignite by apache.
the class TxOptimisticPrepareOnUnstableTopologyTest method testPrepareOnUnstableTopology.
/**
*/
@Test
public void testPrepareOnUnstableTopology() throws Exception {
for (TransactionIsolation isolation : TransactionIsolation.values()) {
doPrepareOnUnstableTopology(4, false, isolation, 0);
doPrepareOnUnstableTopology(4, true, isolation, 0);
doPrepareOnUnstableTopology(4, false, isolation, TimeUnit.DAYS.toMillis(1));
doPrepareOnUnstableTopology(4, true, isolation, TimeUnit.DAYS.toMillis(1));
}
}
use of org.apache.ignite.transactions.TransactionIsolation in project ignite by apache.
the class TxRollbackOnTimeoutTest method testTimeoutOnPrimaryDHTNode.
/**
* Tests timeout on DHT primary node for all tx configurations.
*
* @throws Exception If failed.
*/
@Test
public void testTimeoutOnPrimaryDHTNode() throws Exception {
final ClusterNode n0 = grid(0).affinity(CACHE_NAME).mapKeyToNode(0);
final Ignite prim = G.ignite(n0.id());
for (TransactionConcurrency concurrency : TransactionConcurrency.values()) {
for (TransactionIsolation isolation : TransactionIsolation.values()) testTimeoutOnPrimaryDhtNode0(prim, concurrency, isolation);
}
}
Aggregations