use of org.apache.ignite.IgniteTransactions 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();
}
}
use of org.apache.ignite.IgniteTransactions in project ignite by apache.
the class IgniteNativeTxBenchmark method test.
/** {@inheritDoc} */
@SuppressWarnings("SimplifiableIfStatement")
@Override
public boolean test(Map<Object, Object> ctx) throws Exception {
long aid = ThreadLocalRandom.current().nextLong(accRows);
long bid = ThreadLocalRandom.current().nextLong(branchRows);
long tid = ThreadLocalRandom.current().nextLong(tellRows);
final long delta = ThreadLocalRandom.current().nextLong(1000);
IgniteTransactions transactions = ignite().transactions();
try (Transaction tx = transactions.txStart(args.txConcurrency(), args.txIsolation())) {
accounts.invoke(aid, new EntryProcessor<Long, Accounts, Object>() {
@Override
public Long process(MutableEntry<Long, Accounts> entry, Object... objects) throws EntryProcessorException {
long newVal = entry.getValue().getVal() + delta;
entry.setValue(entry.getValue().setVal(newVal));
return newVal;
}
});
tellers.invoke(tid, new EntryProcessor<Long, Tellers, Object>() {
@Override
public Long process(MutableEntry<Long, Tellers> entry, Object... objects) throws EntryProcessorException {
long newVal = entry.getValue().getVal() + delta;
entry.setValue(entry.getValue().setVal(newVal));
return null;
}
});
branches.invoke(bid, new EntryProcessor<Long, Branches, Object>() {
@Override
public Long process(MutableEntry<Long, Branches> entry, Object... objects) throws EntryProcessorException {
long newVal = entry.getValue().getVal() + delta;
entry.setValue(entry.getValue().setVal(newVal));
return null;
}
});
hist.put(cnt.getAndIncrement(), new History(tid, bid, aid, delta));
tx.commit();
}
return true;
}
Aggregations