use of org.apache.ignite.transactions.TransactionConcurrency in project ignite by apache.
the class IgniteCacheInvokeReadThroughAbstractTest method invokeReadThrough.
/**
* @param ccfg Cache configuration.
* @throws Exception If failed.
*/
@SuppressWarnings("unchecked")
protected void invokeReadThrough(CacheConfiguration ccfg) throws Exception {
Ignite ignite0 = ignite(0);
ignite0.createCache(ccfg);
try {
int key = 0;
for (Ignite node : G.allGrids()) {
if (node.configuration().isClientMode() && ccfg.getNearConfiguration() != null)
node.createNearCache(ccfg.getName(), ccfg.getNearConfiguration());
}
for (Ignite node : G.allGrids()) {
log.info("Test for node: " + node.name());
IgniteCache<Object, Object> cache = node.cache(ccfg.getName());
for (int i = 0; i < 50; i++) checkReadThrough(cache, key++, null, null);
Set<Object> keys = new HashSet<>();
for (int i = 0; i < 5; i++) keys.add(key++);
checkReadThroughInvokeAll(cache, keys, null, null);
keys = new HashSet<>();
for (int i = 0; i < 100; i++) keys.add(key++);
checkReadThroughInvokeAll(cache, keys, null, null);
if (ccfg.getAtomicityMode() == TRANSACTIONAL) {
for (TransactionConcurrency concurrency : TransactionConcurrency.values()) {
for (TransactionIsolation isolation : TransactionIsolation.values()) {
log.info("Test tx [concurrency=" + concurrency + ", isolation=" + isolation + ']');
for (int i = 0; i < 50; i++) checkReadThrough(cache, key++, concurrency, isolation);
keys = new HashSet<>();
for (int i = 0; i < 5; i++) keys.add(key++);
checkReadThroughInvokeAll(cache, keys, concurrency, isolation);
keys = new HashSet<>();
for (int i = 0; i < 100; i++) keys.add(key++);
checkReadThroughInvokeAll(cache, keys, concurrency, isolation);
}
}
for (TransactionConcurrency concurrency : TransactionConcurrency.values()) {
for (TransactionIsolation isolation : TransactionIsolation.values()) {
log.info("Test tx2 [concurrency=" + concurrency + ", isolation=" + isolation + ']');
for (int i = 0; i < 50; i++) checkReadThroughGetAndInvoke(cache, key++, concurrency, isolation);
}
}
}
}
ignite0.cache(ccfg.getName()).removeAll();
} finally {
ignite0.destroyCache(ccfg.getName());
}
}
use of org.apache.ignite.transactions.TransactionConcurrency 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();
}
}
}
}
use of org.apache.ignite.transactions.TransactionConcurrency 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();
}
}
Aggregations