use of org.apache.ignite.transactions.TransactionConcurrency in project ignite by apache.
the class IgniteCacheTxStoreSessionTest method testStoreSessionTx.
/**
* @throws Exception If failed.
*/
public void testStoreSessionTx() throws Exception {
testTxPut(jcache(0), null, null);
testTxPut(ignite(0).cache(CACHE_NAME1), null, null);
testTxRemove(null, null);
testTxPutRemove(null, null);
for (TransactionConcurrency concurrency : F.asList(PESSIMISTIC)) {
for (TransactionIsolation isolation : F.asList(REPEATABLE_READ)) {
testTxPut(jcache(0), concurrency, isolation);
testTxRemove(concurrency, isolation);
testTxPutRemove(concurrency, isolation);
}
}
}
use of org.apache.ignite.transactions.TransactionConcurrency in project ignite by apache.
the class GridCacheStopSelfTest method testStop.
/**
* @param startTx If {@code true} starts transactions.
* @throws Exception If failed.
*/
private void testStop(final boolean startTx) throws Exception {
for (int i = 0; i < 10; i++) {
startGrid(0);
final int PUT_THREADS = 50;
final CountDownLatch stopLatch = new CountDownLatch(1);
final CountDownLatch readyLatch = new CountDownLatch(PUT_THREADS);
final IgniteCache<Integer, Integer> cache = grid(0).cache(DEFAULT_CACHE_NAME);
assertNotNull(cache);
CacheConfiguration ccfg = cache.getConfiguration(CacheConfiguration.class);
assertEquals(atomic ? ATOMIC : TRANSACTIONAL, ccfg.getAtomicityMode());
assertEquals(replicated ? REPLICATED : PARTITIONED, ccfg.getCacheMode());
Collection<IgniteInternalFuture<?>> putFuts = new ArrayList<>();
for (int j = 0; j < PUT_THREADS; j++) {
final int key = j;
putFuts.add(GridTestUtils.runAsync(new Callable<Void>() {
@Override
public Void call() throws Exception {
try {
if (startTx) {
TransactionConcurrency concurrency = key % 2 == 0 ? OPTIMISTIC : PESSIMISTIC;
try (Transaction tx = grid(0).transactions().txStart(concurrency, REPEATABLE_READ)) {
cache.put(key, key);
readyLatch.countDown();
stopLatch.await();
tx.commit();
}
} else {
readyLatch.countDown();
stopLatch.await();
cache.put(key, key);
}
} catch (CacheException | IgniteException | IllegalStateException e) {
log.info("Ignore error: " + e);
}
return null;
}
}, "cache-thread"));
}
readyLatch.await();
stopLatch.countDown();
stopGrid(0);
for (IgniteInternalFuture<?> fut : putFuts) fut.get();
try {
cache.put(1, 1);
} catch (IllegalStateException e) {
if (!e.getMessage().startsWith(EXPECTED_MSG))
e.printStackTrace();
assertTrue("Unexpected error message: " + e.getMessage(), e.getMessage().startsWith(EXPECTED_MSG));
}
}
}
use of org.apache.ignite.transactions.TransactionConcurrency in project ignite by apache.
the class IgniteTxStoreExceptionAbstractSelfTest method testPutMultipleKeysTx.
/**
* @throws Exception If failed.
*/
public void testPutMultipleKeysTx() throws Exception {
for (TransactionConcurrency concurrency : TransactionConcurrency.values()) {
for (TransactionIsolation isolation : TransactionIsolation.values()) {
checkPutTx(true, concurrency, isolation, keyForNode(grid(0).localNode(), PRIMARY), keyForNode(grid(0).localNode(), PRIMARY), keyForNode(grid(0).localNode(), PRIMARY));
checkPutTx(false, concurrency, isolation, keyForNode(grid(0).localNode(), PRIMARY), keyForNode(grid(0).localNode(), PRIMARY), keyForNode(grid(0).localNode(), PRIMARY));
if (gridCount() > 1) {
checkPutTx(true, concurrency, isolation, keyForNode(grid(1).localNode(), PRIMARY), keyForNode(grid(1).localNode(), PRIMARY), keyForNode(grid(1).localNode(), PRIMARY));
checkPutTx(false, concurrency, isolation, keyForNode(grid(1).localNode(), PRIMARY), keyForNode(grid(1).localNode(), PRIMARY), keyForNode(grid(1).localNode(), PRIMARY));
}
}
}
}
use of org.apache.ignite.transactions.TransactionConcurrency in project ignite by apache.
the class IgniteTxExceptionAbstractSelfTest method testPutMultipleKeysTx.
/**
* @throws Exception If failed.
*/
public void testPutMultipleKeysTx() throws Exception {
for (TransactionConcurrency concurrency : TransactionConcurrency.values()) {
for (TransactionIsolation isolation : TransactionIsolation.values()) {
checkPutTx(true, concurrency, isolation, keyForNode(grid(0).localNode(), PRIMARY), keyForNode(grid(0).localNode(), PRIMARY), keyForNode(grid(0).localNode(), PRIMARY));
checkPutTx(false, concurrency, isolation, keyForNode(grid(0).localNode(), PRIMARY), keyForNode(grid(0).localNode(), PRIMARY), keyForNode(grid(0).localNode(), PRIMARY));
if (gridCount() > 1) {
checkPutTx(true, concurrency, isolation, keyForNode(grid(1).localNode(), PRIMARY), keyForNode(grid(1).localNode(), PRIMARY), keyForNode(grid(1).localNode(), PRIMARY));
checkPutTx(false, concurrency, isolation, keyForNode(grid(1).localNode(), PRIMARY), keyForNode(grid(1).localNode(), PRIMARY), keyForNode(grid(1).localNode(), PRIMARY));
}
}
}
}
use of org.apache.ignite.transactions.TransactionConcurrency in project ignite by apache.
the class IgniteTxExceptionAbstractSelfTest method testPutBackupTx.
/**
* @throws Exception If failed.
*/
public void testPutBackupTx() throws Exception {
for (TransactionConcurrency concurrency : TransactionConcurrency.values()) {
for (TransactionIsolation isolation : TransactionIsolation.values()) {
checkPutTx(true, concurrency, isolation, keyForNode(grid(0).localNode(), BACKUP));
checkPutTx(false, concurrency, isolation, keyForNode(grid(0).localNode(), BACKUP));
}
}
}
Aggregations