Search in sources :

Example 26 with EntryProcessorResult

use of javax.cache.processor.EntryProcessorResult in project ignite by apache.

the class IgniteCacheInvokeReadThroughAbstractTest method checkReadThroughInvokeAll.

/**
     * @param cache Cache.
     * @param keys Key.
     * @param concurrency Transaction concurrency.
     * @param isolation Transaction isolation.
     * @throws Exception If failed.
     */
private void checkReadThroughInvokeAll(IgniteCache<Object, Object> cache, Set<Object> keys, @Nullable TransactionConcurrency concurrency, @Nullable TransactionIsolation isolation) throws Exception {
    Map<Object, Object> data = U.newHashMap(keys.size());
    for (Object key : keys) data.put(key, key);
    putDataInStore(data, cache.getName());
    Transaction tx = isolation != null ? cache.unwrap(Ignite.class).transactions().txStart(concurrency, isolation) : null;
    try {
        Map<Object, EntryProcessorResult<Object>> ret = cache.invokeAll(keys, new TestEntryProcessor());
        assertEquals(ret.size(), keys.size());
        for (Object key : keys) {
            EntryProcessorResult<Object> res = ret.get(key);
            assertNotNull(res);
            assertEquals(key, res.get());
        }
        if (tx != null)
            tx.commit();
    } finally {
        if (tx != null)
            tx.close();
    }
    for (Object key : keys) checkValue(cache.getName(), key, (Integer) key + 1);
}
Also used : EntryProcessorResult(javax.cache.processor.EntryProcessorResult) Transaction(org.apache.ignite.transactions.Transaction) Ignite(org.apache.ignite.Ignite)

Aggregations

EntryProcessorResult (javax.cache.processor.EntryProcessorResult)26 Map (java.util.Map)11 LinkedHashMap (java.util.LinkedHashMap)10 HashMap (java.util.HashMap)8 HashSet (java.util.HashSet)8 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)7 EntryProcessor (javax.cache.processor.EntryProcessor)5 EntryProcessorException (javax.cache.processor.EntryProcessorException)5 Transaction (org.apache.ignite.transactions.Transaction)5 ParallelTest (com.hazelcast.test.annotation.ParallelTest)4 QuickTest (com.hazelcast.test.annotation.QuickTest)4 Ignite (org.apache.ignite.Ignite)4 BinaryObject (org.apache.ignite.binary.BinaryObject)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)3 Set (java.util.Set)3 ConcurrentMap (java.util.concurrent.ConcurrentMap)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 CacheObject (org.apache.ignite.internal.processors.cache.CacheObject)3 CachePartialUpdateCheckedException (org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException)3