use of org.apache.ignite.yardstick.cache.model.Branches 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