Search in sources :

Example 1 with SQL

use of org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.ReadMode.SQL in project ignite by apache.

the class CacheMvccAbstractTest method readAllByMode.

/**
 * Reads value from cache for the given key using given read mode.
 *
 * @param cache Cache.
 * @param keys Key.
 * @param readMode Read mode.
 * @param codec Value codec.
 * @return Value.
 */
@SuppressWarnings("unchecked")
protected Map readAllByMode(IgniteCache cache, Set keys, ReadMode readMode, ObjectCodec codec) {
    assert cache != null && keys != null && readMode != null;
    assert readMode != SQL || codec != null;
    boolean emulateLongQry = ThreadLocalRandom.current().nextBoolean();
    switch(readMode) {
        case GET:
            return cache.getAll(keys);
        case SCAN:
            ScanQuery scanQry = new ScanQuery(new IgniteBiPredicate() {

                @Override
                public boolean apply(Object k, Object v) {
                    if (emulateLongQry)
                        doSleep(ThreadLocalRandom.current().nextInt(50));
                    return keys.contains(k);
                }
            });
            Map res;
            try (QueryCursor qry = cache.query(scanQry)) {
                res = (Map) qry.getAll().stream().collect(Collectors.toMap(v -> ((IgniteBiTuple) v).getKey(), v -> ((IgniteBiTuple) v).getValue()));
                assertTrue("res.size()=" + res.size() + ", keys.size()=" + keys.size(), res.size() <= keys.size());
            }
            return res;
        case SQL:
            StringBuilder b = new StringBuilder("SELECT " + codec.columnsNames() + " FROM " + codec.tableName() + " WHERE _key IN (");
            boolean first = true;
            for (Object key : keys) {
                if (first)
                    first = false;
                else
                    b.append(", ");
                b.append(key);
            }
            b.append(')');
            String qry = b.toString();
            SqlFieldsQuery sqlFieldsQry = new SqlFieldsQuery(qry);
            if (emulateLongQry)
                sqlFieldsQry.setLazy(true).setPageSize(1);
            List<List> rows;
            try (FieldsQueryCursor<List> cur = cache.query(sqlFieldsQry)) {
                if (emulateLongQry) {
                    rows = new ArrayList<>();
                    for (List row : cur) {
                        rows.add(row);
                        doSleep(ThreadLocalRandom.current().nextInt(50));
                    }
                } else
                    rows = cur.getAll();
            }
            if (rows.isEmpty())
                return Collections.emptyMap();
            res = new HashMap();
            for (List row : rows) res.put(row.get(0), codec.decode(row));
            return res;
        case SQL_SUM:
            b = new StringBuilder("SELECT SUM(" + codec.aggregateColumnName() + ") FROM " + codec.tableName() + " WHERE _key IN (");
            first = true;
            for (Object key : keys) {
                if (first)
                    first = false;
                else
                    b.append(", ");
                b.append(key);
            }
            b.append(')');
            qry = b.toString();
            FieldsQueryCursor<List> cur = cache.query(new SqlFieldsQuery(qry));
            rows = cur.getAll();
            if (rows.isEmpty())
                return Collections.emptyMap();
            res = new HashMap();
            for (List row : rows) res.put(row.get(0), row.get(0));
            return res;
        default:
            throw new AssertionError("Unsupported read mode: " + readMode);
    }
}
Also used : IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) GridCompoundIdentityFuture(org.apache.ignite.internal.util.future.GridCompoundIdentityFuture) IgniteTxRollbackCheckedException(org.apache.ignite.internal.transactions.IgniteTxRollbackCheckedException) SqlFieldsQuery(org.apache.ignite.cache.query.SqlFieldsQuery) Transaction(org.apache.ignite.transactions.Transaction) TRANSACTIONAL_SNAPSHOT(org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT) IgniteEx(org.apache.ignite.internal.IgniteEx) REPEATABLE_READ(org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) IgniteFutureCancelledCheckedException(org.apache.ignite.internal.IgniteFutureCancelledCheckedException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) SqlQuery(org.apache.ignite.cache.query.SqlQuery) GridAbsPredicate(org.apache.ignite.internal.util.lang.GridAbsPredicate) X(org.apache.ignite.internal.util.typedef.X) Cache(javax.cache.Cache) PARTITIONED(org.apache.ignite.cache.CacheMode.PARTITIONED) ReadWriteLock(java.util.concurrent.locks.ReadWriteLock) IgniteKernal(org.apache.ignite.internal.IgniteKernal) GridInClosure3(org.apache.ignite.internal.util.lang.GridInClosure3) WALMode(org.apache.ignite.configuration.WALMode) IgniteInClosure(org.apache.ignite.lang.IgniteInClosure) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) QuerySqlField(org.apache.ignite.cache.query.annotations.QuerySqlField) IgniteTxTimeoutCheckedException(org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException) Collection(java.util.Collection) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) TransactionConcurrency(org.apache.ignite.transactions.TransactionConcurrency) Set(java.util.Set) TransactionConfiguration(org.apache.ignite.configuration.TransactionConfiguration) Collectors(java.util.stream.Collectors) IgniteCache(org.apache.ignite.IgniteCache) IgniteCacheProxy(org.apache.ignite.internal.processors.cache.IgniteCacheProxy) StopNodeFailureHandler(org.apache.ignite.failure.StopNodeFailureHandler) IgniteBiTuple(org.apache.ignite.lang.IgniteBiTuple) GridTestUtils(org.apache.ignite.testframework.GridTestUtils) SQL_SUM(org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.ReadMode.SQL_SUM) Objects(java.util.Objects) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) QueryCursor(org.apache.ignite.cache.query.QueryCursor) PESSIMISTIC(org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC) TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject) FieldsQueryCursor(org.apache.ignite.cache.query.FieldsQueryCursor) ScanQuery(org.apache.ignite.cache.query.ScanQuery) DML(org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.WriteMode.DML) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) TransactionIsolation(org.apache.ignite.transactions.TransactionIsolation) IgniteBiPredicate(org.apache.ignite.lang.IgniteBiPredicate) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) U(org.apache.ignite.internal.util.typedef.internal.U) HashMap(java.util.HashMap) Callable(java.util.concurrent.Callable) ReentrantReadWriteLock(java.util.concurrent.locks.ReentrantReadWriteLock) ClusterTopologyException(org.apache.ignite.cluster.ClusterTopologyException) SQL(org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.ReadMode.SQL) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) GridKernalContext(org.apache.ignite.internal.GridKernalContext) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteClosure(org.apache.ignite.lang.IgniteClosure) IgnitePredicate(org.apache.ignite.lang.IgnitePredicate) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) CacheWriteSynchronizationMode(org.apache.ignite.cache.CacheWriteSynchronizationMode) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) CacheException(javax.cache.CacheException) TransactionException(org.apache.ignite.transactions.TransactionException) TransactionSerializationException(org.apache.ignite.transactions.TransactionSerializationException) LinkedHashSet(java.util.LinkedHashSet) G(org.apache.ignite.internal.util.typedef.G) F(org.apache.ignite.internal.util.typedef.F) Iterator(java.util.Iterator) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException) Ignite(org.apache.ignite.Ignite) FULL_SYNC(org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC) GridCloseableIterator(org.apache.ignite.internal.util.lang.GridCloseableIterator) REPLICATED(org.apache.ignite.cache.CacheMode.REPLICATED) SF(org.apache.ignite.testframework.GridTestUtils.SF) IgniteSQLException(org.apache.ignite.internal.processors.query.IgniteSQLException) TreeMap(java.util.TreeMap) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) Collections(java.util.Collections) IgniteTransactions(org.apache.ignite.IgniteTransactions) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) CacheMode(org.apache.ignite.cache.CacheMode) IgniteBiPredicate(org.apache.ignite.lang.IgniteBiPredicate) IgniteBiTuple(org.apache.ignite.lang.IgniteBiTuple) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ScanQuery(org.apache.ignite.cache.query.ScanQuery) SqlFieldsQuery(org.apache.ignite.cache.query.SqlFieldsQuery) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) TreeMap(java.util.TreeMap) QueryCursor(org.apache.ignite.cache.query.QueryCursor) FieldsQueryCursor(org.apache.ignite.cache.query.FieldsQueryCursor)

Example 2 with SQL

use of org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.ReadMode.SQL in project ignite by apache.

the class MvccRepeatableReadOperationsTest method testReplaceConsistency.

/**
 * Check getAndPut/getAndRemove operations consistency.
 *
 * @throws IgniteCheckedException If failed.
 */
@Test
public void testReplaceConsistency() throws IgniteCheckedException {
    Ignite node1 = grid(0);
    TestCache<Integer, MvccTestAccount> cache1 = new TestCache<>(node1.cache(DEFAULT_CACHE_NAME));
    final Set<Integer> existedKeys = new HashSet<>(3);
    final Set<Integer> nonExistedKeys = new HashSet<>(3);
    final Set<Integer> allKeys = generateKeySet(grid(0).cache(DEFAULT_CACHE_NAME), existedKeys, nonExistedKeys);
    final Map<Integer, MvccTestAccount> initialMap = existedKeys.stream().collect(Collectors.toMap(k -> k, k -> new MvccTestAccount(k, 1)));
    Map<Integer, MvccTestAccount> updateMap = existedKeys.stream().collect(Collectors.toMap(k -> k, k -> new MvccTestAccount(k, 3)));
    cache1.cache.putAll(initialMap);
    IgniteTransactions txs = node1.transactions();
    try (Transaction tx = txs.txStart(TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ)) {
        for (Integer key : allKeys) {
            MvccTestAccount newVal = new MvccTestAccount(key, 2);
            if (existedKeys.contains(key)) {
                assertTrue(cache1.cache.replace(key, new MvccTestAccount(key, 1), newVal));
                assertEquals(newVal, cache1.cache.getAndReplace(key, new MvccTestAccount(key, 3)));
            } else {
                assertFalse(cache1.cache.replace(key, new MvccTestAccount(key, 1), newVal));
                assertNull(cache1.cache.getAndReplace(key, new MvccTestAccount(key, 3)));
            }
        }
        assertEquals(updateMap, getEntries(cache1, allKeys, SQL));
        assertEquals(updateMap, getEntries(cache1, allKeys, GET));
        tx.commit();
    }
    assertEquals(updateMap, getEntries(cache1, allKeys, SQL));
    assertEquals(updateMap, getEntries(cache1, allKeys, GET));
}
Also used : TransactionIsolation(org.apache.ignite.transactions.TransactionIsolation) GET(org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.ReadMode.GET) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) Transaction(org.apache.ignite.transactions.Transaction) TransactionConcurrency(org.apache.ignite.transactions.TransactionConcurrency) Set(java.util.Set) HashMap(java.util.HashMap) Test(org.junit.Test) Ignite(org.apache.ignite.Ignite) Collectors(java.util.stream.Collectors) SQL(org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.ReadMode.SQL) HashSet(java.util.HashSet) CacheEntryProcessor(org.apache.ignite.cache.CacheEntryProcessor) Map(java.util.Map) IgniteTransactions(org.apache.ignite.IgniteTransactions) Transaction(org.apache.ignite.transactions.Transaction) Ignite(org.apache.ignite.Ignite) IgniteTransactions(org.apache.ignite.IgniteTransactions) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 3 with SQL

use of org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.ReadMode.SQL in project ignite by apache.

the class MvccRepeatableReadOperationsTest method testGetAndUpdateOperations.

/**
 * Check getAndPut/getAndRemove operations consistency.
 *
 * @throws IgniteCheckedException If failed.
 */
@Test
public void testGetAndUpdateOperations() throws IgniteCheckedException {
    Ignite node1 = grid(0);
    TestCache<Integer, MvccTestAccount> cache1 = new TestCache<>(node1.cache(DEFAULT_CACHE_NAME));
    final Set<Integer> keysForUpdate = new HashSet<>(3);
    final Set<Integer> keysForRemove = new HashSet<>(3);
    final Set<Integer> allKeys = generateKeySet(grid(0).cache(DEFAULT_CACHE_NAME), keysForUpdate, keysForRemove);
    final Map<Integer, MvccTestAccount> initialMap = keysForRemove.stream().collect(Collectors.toMap(k -> k, k -> new MvccTestAccount(k, 1)));
    Map<Integer, MvccTestAccount> updateMap = keysForUpdate.stream().collect(Collectors.toMap(k -> k, k -> new MvccTestAccount(k, 3)));
    cache1.cache.putAll(initialMap);
    IgniteTransactions txs = node1.transactions();
    try (Transaction tx = txs.txStart(TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ)) {
        for (Integer key : keysForUpdate) {
            MvccTestAccount newVal1 = new MvccTestAccount(key, 1);
            // Check create.
            assertNull(cache1.cache.getAndPut(key, newVal1));
            MvccTestAccount newVal2 = new MvccTestAccount(key, 2);
            // Check update.
            assertEquals(newVal1, cache1.cache.getAndPut(key, newVal2));
        }
        for (Integer key : keysForRemove) {
            // Check remove existed.
            assertEquals(initialMap.get(key), cache1.cache.getAndRemove(key));
            // Check remove non-existed.
            assertNull(cache1.cache.getAndRemove(key));
        }
        for (Integer key : allKeys) {
            MvccTestAccount oldVal = new MvccTestAccount(key, 2);
            MvccTestAccount newVal = new MvccTestAccount(key, 3);
            if (keysForRemove.contains(key))
                // Omit update 'null'.
                assertNull(cache1.cache.getAndReplace(key, newVal));
            else
                // Check updated.
                assertEquals(oldVal, cache1.cache.getAndReplace(key, newVal));
        }
        assertEquals(updateMap, getEntries(cache1, allKeys, SQL));
        assertEquals(updateMap, getEntries(cache1, allKeys, GET));
        tx.commit();
    }
    assertEquals(updateMap, getEntries(cache1, allKeys, SQL));
    assertEquals(updateMap, getEntries(cache1, allKeys, GET));
}
Also used : TransactionIsolation(org.apache.ignite.transactions.TransactionIsolation) GET(org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.ReadMode.GET) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) Transaction(org.apache.ignite.transactions.Transaction) TransactionConcurrency(org.apache.ignite.transactions.TransactionConcurrency) Set(java.util.Set) HashMap(java.util.HashMap) Test(org.junit.Test) Ignite(org.apache.ignite.Ignite) Collectors(java.util.stream.Collectors) SQL(org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.ReadMode.SQL) HashSet(java.util.HashSet) CacheEntryProcessor(org.apache.ignite.cache.CacheEntryProcessor) Map(java.util.Map) IgniteTransactions(org.apache.ignite.IgniteTransactions) Transaction(org.apache.ignite.transactions.Transaction) Ignite(org.apache.ignite.Ignite) IgniteTransactions(org.apache.ignite.IgniteTransactions) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with SQL

use of org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.ReadMode.SQL in project ignite by apache.

the class MvccRepeatableReadOperationsTest method testPutIfAbsentConsistency.

/**
 * Check getAndPut/getAndRemove operations consistency.
 *
 * @throws IgniteCheckedException If failed.
 */
@Test
public void testPutIfAbsentConsistency() throws IgniteCheckedException {
    Ignite node1 = grid(0);
    TestCache<Integer, MvccTestAccount> cache1 = new TestCache<>(node1.cache(DEFAULT_CACHE_NAME));
    final Set<Integer> keysForCreate = new HashSet<>(3);
    final Set<Integer> keysForUpdate = new HashSet<>(3);
    final Set<Integer> allKeys = generateKeySet(grid(0).cache(DEFAULT_CACHE_NAME), keysForCreate, keysForUpdate);
    final Map<Integer, MvccTestAccount> initialMap = keysForUpdate.stream().collect(Collectors.toMap(k -> k, k -> new MvccTestAccount(k, 1)));
    Map<Integer, MvccTestAccount> updatedMap = allKeys.stream().collect(Collectors.toMap(k -> k, k -> new MvccTestAccount(k, 1)));
    cache1.cache.putAll(initialMap);
    IgniteTransactions txs = node1.transactions();
    try (Transaction tx = txs.txStart(TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ)) {
        for (Integer key : keysForUpdate) // Check update.
        assertFalse(cache1.cache.putIfAbsent(key, new MvccTestAccount(key, 2)));
        for (Integer key : keysForCreate) // Check create.
        assertTrue(cache1.cache.putIfAbsent(key, new MvccTestAccount(key, 1)));
        assertEquals(updatedMap, getEntries(cache1, allKeys, SQL));
        tx.commit();
    }
    assertEquals(updatedMap, getEntries(cache1, allKeys, SQL));
    assertEquals(updatedMap, getEntries(cache1, allKeys, GET));
}
Also used : TransactionIsolation(org.apache.ignite.transactions.TransactionIsolation) GET(org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.ReadMode.GET) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) Transaction(org.apache.ignite.transactions.Transaction) TransactionConcurrency(org.apache.ignite.transactions.TransactionConcurrency) Set(java.util.Set) HashMap(java.util.HashMap) Test(org.junit.Test) Ignite(org.apache.ignite.Ignite) Collectors(java.util.stream.Collectors) SQL(org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.ReadMode.SQL) HashSet(java.util.HashSet) CacheEntryProcessor(org.apache.ignite.cache.CacheEntryProcessor) Map(java.util.Map) IgniteTransactions(org.apache.ignite.IgniteTransactions) Transaction(org.apache.ignite.transactions.Transaction) Ignite(org.apache.ignite.Ignite) IgniteTransactions(org.apache.ignite.IgniteTransactions) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 5 with SQL

use of org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.ReadMode.SQL in project ignite by apache.

the class MvccRepeatableReadBulkOpsTest method checkOperations.

/**
 * Checks SQL and CacheAPI operation isolation consistency.
 *
 * @param readModeBefore read mode used before value updated.
 * @param readModeAfter read mode used after value updated.
 * @param writeMode write mode used for update.
 * @throws Exception If failed.
 */
private void checkOperations(ReadMode readModeBefore, ReadMode readModeAfter, WriteMode writeMode, boolean readFromClient) throws Exception {
    Ignite node1 = grid(readFromClient ? nodesCount() - 1 : 0);
    Ignite node2 = grid(readFromClient ? 0 : nodesCount() - 1);
    TestCache<Integer, MvccTestAccount> cache1 = new TestCache<>(node1.cache(DEFAULT_CACHE_NAME));
    TestCache<Integer, MvccTestAccount> cache2 = new TestCache<>(node2.cache(DEFAULT_CACHE_NAME));
    final Set<Integer> keysForUpdate = new HashSet<>(3);
    final Set<Integer> keysForRemove = new HashSet<>(3);
    final Set<Integer> allKeys = generateKeySet(grid(0).cache(DEFAULT_CACHE_NAME), keysForUpdate, keysForRemove);
    final Map<Integer, MvccTestAccount> initialMap = allKeys.stream().collect(Collectors.toMap(k -> k, k -> new MvccTestAccount(k, 1)));
    final Map<Integer, MvccTestAccount> updateMap = keysForUpdate.stream().collect(Collectors.toMap(Function.identity(), k -> new MvccTestAccount(k, 2)));
    /* Removed keys are excluded. */
    cache1.cache.putAll(initialMap);
    IgniteTransactions txs1 = node1.transactions();
    IgniteTransactions txs2 = node2.transactions();
    CountDownLatch updateStart = new CountDownLatch(1);
    CountDownLatch updateFinish = new CountDownLatch(1);
    // Start concurrent transactions and check isolation.
    IgniteInternalFuture<Void> updater = GridTestUtils.runAsync(new Callable<Void>() {

        @Override
        public Void call() throws Exception {
            updateStart.await();
            assertEquals(initialMap.size(), cache2.cache.size());
            try (Transaction tx = txs2.txStart(TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ)) {
                tx.timeout(TX_TIMEOUT);
                updateEntries(cache2, updateMap, writeMode);
                removeEntries(cache2, keysForRemove, writeMode);
                assertEquals(updateMap, cache2.cache.getAll(allKeys));
                tx.commit();
            } finally {
                updateFinish.countDown();
            }
            assertEquals(updateMap.size(), cache2.cache.size());
            return null;
        }
    });
    IgniteInternalFuture<Void> reader = GridTestUtils.runAsync(new Callable<Void>() {

        @Override
        public Void call() throws Exception {
            try (Transaction tx = txs1.txStart(TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ)) {
                assertEquals(initialMap, getEntries(cache1, allKeys, readModeBefore));
                checkContains(cache1, true, allKeys);
                updateStart.countDown();
                updateFinish.await();
                assertEquals(initialMap, getEntries(cache1, allKeys, readModeAfter));
                checkContains(cache1, true, allKeys);
                tx.commit();
            }
            return null;
        }
    });
    try {
        updater.get(3_000, TimeUnit.MILLISECONDS);
        reader.get(3_000, TimeUnit.MILLISECONDS);
    } catch (Throwable e) {
        throw new AssertionError(e);
    } finally {
        updateStart.countDown();
        updateFinish.countDown();
    }
    assertEquals(updateMap, cache1.cache.getAll(allKeys));
}
Also used : IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) TransactionIsolation(org.apache.ignite.transactions.TransactionIsolation) PUT(org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.WriteMode.PUT) GET(org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.ReadMode.GET) EntryProcessorResult(javax.cache.processor.EntryProcessorResult) Transaction(org.apache.ignite.transactions.Transaction) HashMap(java.util.HashMap) Callable(java.util.concurrent.Callable) Function(java.util.function.Function) EntryProcessorException(javax.cache.processor.EntryProcessorException) SQL(org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.ReadMode.SQL) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) MutableEntry(javax.cache.processor.MutableEntry) Map(java.util.Map) LinkedHashSet(java.util.LinkedHashSet) F(org.apache.ignite.internal.util.typedef.F) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) TransactionConcurrency(org.apache.ignite.transactions.TransactionConcurrency) Set(java.util.Set) Test(org.junit.Test) Ignite(org.apache.ignite.Ignite) Collectors(java.util.stream.Collectors) FULL_SYNC(org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC) IgniteCache(org.apache.ignite.IgniteCache) GridTestUtils(org.apache.ignite.testframework.GridTestUtils) TimeUnit(java.util.concurrent.TimeUnit) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) CacheEntryProcessor(org.apache.ignite.cache.CacheEntryProcessor) INVOKE(org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.ReadMode.INVOKE) IgniteTransactions(org.apache.ignite.IgniteTransactions) DML(org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.WriteMode.DML) CacheMode(org.apache.ignite.cache.CacheMode) IgniteTransactions(org.apache.ignite.IgniteTransactions) CountDownLatch(java.util.concurrent.CountDownLatch) EntryProcessorException(javax.cache.processor.EntryProcessorException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) Transaction(org.apache.ignite.transactions.Transaction) Ignite(org.apache.ignite.Ignite) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Aggregations

HashMap (java.util.HashMap)6 HashSet (java.util.HashSet)6 Map (java.util.Map)6 Set (java.util.Set)6 Collectors (java.util.stream.Collectors)6 Ignite (org.apache.ignite.Ignite)6 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)6 IgniteTransactions (org.apache.ignite.IgniteTransactions)6 SQL (org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.ReadMode.SQL)6 Transaction (org.apache.ignite.transactions.Transaction)6 TransactionConcurrency (org.apache.ignite.transactions.TransactionConcurrency)6 TransactionIsolation (org.apache.ignite.transactions.TransactionIsolation)6 CacheEntryProcessor (org.apache.ignite.cache.CacheEntryProcessor)5 GET (org.apache.ignite.internal.processors.cache.mvcc.CacheMvccAbstractTest.ReadMode.GET)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)3 LinkedHashSet (java.util.LinkedHashSet)3 List (java.util.List)3 Callable (java.util.concurrent.Callable)3 IgniteCache (org.apache.ignite.IgniteCache)3