Search in sources :

Example 1 with Tellers

use of org.apache.ignite.yardstick.cache.model.Tellers 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;
}
Also used : Branches(org.apache.ignite.yardstick.cache.model.Branches) IgniteTransactions(org.apache.ignite.IgniteTransactions) History(org.apache.ignite.yardstick.cache.model.History) Transaction(org.apache.ignite.transactions.Transaction) EntryProcessorException(javax.cache.processor.EntryProcessorException) AtomicLong(java.util.concurrent.atomic.AtomicLong) Tellers(org.apache.ignite.yardstick.cache.model.Tellers) Accounts(org.apache.ignite.yardstick.cache.model.Accounts)

Aggregations

AtomicLong (java.util.concurrent.atomic.AtomicLong)1 EntryProcessorException (javax.cache.processor.EntryProcessorException)1 IgniteTransactions (org.apache.ignite.IgniteTransactions)1 Transaction (org.apache.ignite.transactions.Transaction)1 Accounts (org.apache.ignite.yardstick.cache.model.Accounts)1 Branches (org.apache.ignite.yardstick.cache.model.Branches)1 History (org.apache.ignite.yardstick.cache.model.History)1 Tellers (org.apache.ignite.yardstick.cache.model.Tellers)1