Search in sources :

Example 16 with EntryProcessorException

use of javax.cache.processor.EntryProcessorException 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

EntryProcessorException (javax.cache.processor.EntryProcessorException)16 MutableEntry (javax.cache.processor.MutableEntry)5 Ignite (org.apache.ignite.Ignite)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 CacheException (javax.cache.CacheException)4 IgniteCache (org.apache.ignite.IgniteCache)4 IgniteException (org.apache.ignite.IgniteException)4 Transaction (org.apache.ignite.transactions.Transaction)4 HashMap (java.util.HashMap)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)3 CacheEntryListenerException (javax.cache.event.CacheEntryListenerException)3 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)3 CacheEntryProcessor (org.apache.ignite.cache.CacheEntryProcessor)3 ContinuousQuery (org.apache.ignite.cache.query.ContinuousQuery)3 Data (com.hazelcast.nio.serialization.Data)2 CacheEntryEvent (javax.cache.event.CacheEntryEvent)2 EntryProcessor (javax.cache.processor.EntryProcessor)2 EntryProcessorResult (javax.cache.processor.EntryProcessorResult)2 IgniteTransactions (org.apache.ignite.IgniteTransactions)2