You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2018/10/15 14:42:55 UTC
[3/5] ignite git commit: IGNITE-7953: MVCC: Continuous queries
support. This closes #4767.
http://git-wip-us.apache.org/repos/asf/ignite/blob/51a202a4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryAsyncFilterListenerTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryAsyncFilterListenerTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryAsyncFilterListenerTest.java
index e66e7f1..328b023 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryAsyncFilterListenerTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryAsyncFilterListenerTest.java
@@ -57,6 +57,7 @@ import org.apache.ignite.transactions.Transaction;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
import static org.apache.ignite.cache.CacheMode.REPLICATED;
import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
@@ -127,6 +128,20 @@ public class CacheContinuousQueryAsyncFilterListenerTest extends GridCommonAbstr
/**
* @throws Exception If failed.
*/
+ public void testNonDeadLockInListenerMvccTx() throws Exception {
+ testNonDeadLockInListener(cacheConfiguration(PARTITIONED, 2, TRANSACTIONAL_SNAPSHOT), true, true, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNonDeadLockInListenerMvccTxJCacheApi() throws Exception {
+ testNonDeadLockInListener(cacheConfiguration(PARTITIONED, 2, TRANSACTIONAL_SNAPSHOT), true, true, true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testNonDeadLockInListenerAtomic() throws Exception {
testNonDeadLockInListener(cacheConfiguration(PARTITIONED, 2, ATOMIC), true, true, false);
}
@@ -194,6 +209,27 @@ public class CacheContinuousQueryAsyncFilterListenerTest extends GridCommonAbstr
testNonDeadLockInListener(cacheConfiguration(REPLICATED, 2, TRANSACTIONAL), true, true, true);
}
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNonDeadLockInListenerMvcc() throws Exception {
+ testNonDeadLockInListener(cacheConfiguration(PARTITIONED, 2, TRANSACTIONAL_SNAPSHOT), true, true, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNonDeadLockInListenerReplicatedMvcc() throws Exception {
+ testNonDeadLockInListener(cacheConfiguration(REPLICATED, 2, TRANSACTIONAL_SNAPSHOT), true, true, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNonDeadLockInListenerReplicatedJCacheApiMvcc() throws Exception {
+ testNonDeadLockInListener(cacheConfiguration(REPLICATED, 2, TRANSACTIONAL_SNAPSHOT), true, true, true);
+ }
+
///
/// ASYNC FILTER AND LISTENER. TEST FILTER.
///
@@ -215,6 +251,20 @@ public class CacheContinuousQueryAsyncFilterListenerTest extends GridCommonAbstr
/**
* @throws Exception If failed.
*/
+ public void testNonDeadLockInFilterMvccTx() throws Exception {
+ testNonDeadLockInFilter(cacheConfiguration(PARTITIONED, 2, TRANSACTIONAL_SNAPSHOT), true, true, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNonDeadLockInFilterMvccTxJCacheApi() throws Exception {
+ testNonDeadLockInFilter(cacheConfiguration(PARTITIONED, 2, TRANSACTIONAL_SNAPSHOT), true, true, true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testNonDeadLockInFilterAtomic() throws Exception {
testNonDeadLockInFilter(cacheConfiguration(PARTITIONED, 2, ATOMIC), true, true, false);
}
@@ -261,6 +311,27 @@ public class CacheContinuousQueryAsyncFilterListenerTest extends GridCommonAbstr
testNonDeadLockInFilter(cacheConfiguration(REPLICATED, 2, TRANSACTIONAL), true, true, false);
}
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNonDeadLockInFilterMvcc() throws Exception {
+ testNonDeadLockInFilter(cacheConfiguration(PARTITIONED, 2, TRANSACTIONAL_SNAPSHOT), true, true, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNonDeadLockInFilterReplicatedMvcc() throws Exception {
+ testNonDeadLockInFilter(cacheConfiguration(REPLICATED, 2, TRANSACTIONAL_SNAPSHOT), true, true, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNonDeadLockInFilterReplicatedJCacheApiMvcc() throws Exception {
+ testNonDeadLockInFilter(cacheConfiguration(REPLICATED, 2, TRANSACTIONAL_SNAPSHOT), true, true, false);
+ }
+
///
/// ASYNC LISTENER. TEST LISTENER.
///
@@ -275,6 +346,13 @@ public class CacheContinuousQueryAsyncFilterListenerTest extends GridCommonAbstr
/**
* @throws Exception If failed.
*/
+ public void testNonDeadLockInFilterMvccTxSyncFilter() throws Exception {
+ testNonDeadLockInListener(cacheConfiguration(PARTITIONED, 2, TRANSACTIONAL_SNAPSHOT), false, true, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testNonDeadLockInFilterAtomicSyncFilter() throws Exception {
testNonDeadLockInListener(cacheConfiguration(PARTITIONED, 2, ATOMIC), false, true, false);
}
@@ -308,6 +386,20 @@ public class CacheContinuousQueryAsyncFilterListenerTest extends GridCommonAbstr
}
/**
+ * @throws Exception If failed.
+ */
+ public void testNonDeadLockInFilterSyncFilterMvcc() throws Exception {
+ testNonDeadLockInListener(cacheConfiguration(PARTITIONED, 2, TRANSACTIONAL_SNAPSHOT), false, true, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNonDeadLockInFilterReplicatedSyncFilterMvcc() throws Exception {
+ testNonDeadLockInListener(cacheConfiguration(REPLICATED, 2, TRANSACTIONAL_SNAPSHOT), false, true, false);
+ }
+
+ /**
* @param ccfg Cache configuration.
* @param asyncFltr Async filter.
* @param asyncLsnr Async listener.
@@ -371,18 +463,41 @@ public class CacheContinuousQueryAsyncFilterListenerTest extends GridCommonAbstr
else if (!val.equals(val0))
return;
- Transaction tx = null;
+ // For MVCC mode we need to wait until updated value becomes visible. Usually this is
+ // several ms to wait - mvcc coordinator need some time to register tx as finished.
+ if (ccfg.getAtomicityMode() == TRANSACTIONAL_SNAPSHOT) {
+ Object v = null;
- try {
- if (cache0.getConfiguration(CacheConfiguration.class).getAtomicityMode() == TRANSACTIONAL)
- tx = ignite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ);
+ while (v == null && !Thread.currentThread().isInterrupted()) {
+ v = cache0.get(key);
+ if (v == null)
+ doSleep(50);
+ }
+ }
+
+ try {
assertEquals(val, val0);
- cache0.put(key, newVal);
+ if (cache0.getConfiguration(CacheConfiguration.class).getAtomicityMode() != ATOMIC) {
+ boolean committed = false;
- if (tx != null)
- tx.commit();
+ while (!committed && !Thread.currentThread().isInterrupted()) {
+ try (Transaction tx = ignite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
+ cache0.put(key, newVal);
+
+ tx.commit();
+
+ committed =true;
+ }
+ catch (Exception ex) {
+ assertTrue(ex.toString(),
+ ex.getMessage() != null && ex.getMessage().contains("Cannot serialize transaction due to write conflict"));
+ }
+ }
+ }
+ else
+ cache0.put(key, newVal);
latch.countDown();
}
@@ -391,10 +506,6 @@ public class CacheContinuousQueryAsyncFilterListenerTest extends GridCommonAbstr
throw new IgniteException(exp);
}
- finally {
- if (tx != null)
- tx.close();
- }
}
};
@@ -521,19 +632,29 @@ public class CacheContinuousQueryAsyncFilterListenerTest extends GridCommonAbstr
else if (!val.equals(val0))
return;
- Transaction tx = null;
-
try {
- if (cache0.getConfiguration(CacheConfiguration.class)
- .getAtomicityMode() == TRANSACTIONAL)
- tx = ignite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ);
-
assertEquals(val, val0);
- cache0.put(key, newVal);
+ if (cache0.getConfiguration(CacheConfiguration.class).getAtomicityMode() != ATOMIC) {
+ boolean committed = false;
- if (tx != null)
- tx.commit();
+ while (!committed && !Thread.currentThread().isInterrupted()) {
+ try (Transaction tx = ignite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
+
+ cache0.put(key, newVal);
+
+ tx.commit();
+
+ committed =true;
+ }
+ catch (Exception ex) {
+ assertTrue(ex.toString(),
+ ex.getMessage() != null && ex.getMessage().contains("Cannot serialize transaction due to write conflict"));
+ }
+ }
+ }
+ else
+ cache0.put(key, newVal);
latch.countDown();
}
@@ -542,10 +663,6 @@ public class CacheContinuousQueryAsyncFilterListenerTest extends GridCommonAbstr
throw new IgniteException(exp);
}
- finally {
- if (tx != null)
- tx.close();
- }
}
};
http://git-wip-us.apache.org/repos/asf/ignite/blob/51a202a4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryConcurrentPartitionUpdateTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryConcurrentPartitionUpdateTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryConcurrentPartitionUpdateTest.java
index 6c0db43..53a1715 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryConcurrentPartitionUpdateTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryConcurrentPartitionUpdateTest.java
@@ -23,10 +23,12 @@ import java.util.concurrent.Callable;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
+import javax.cache.CacheException;
import javax.cache.event.CacheEntryEvent;
import javax.cache.event.CacheEntryUpdatedListener;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteTransactions;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.affinity.Affinity;
import org.apache.ignite.cache.query.ContinuousQuery;
@@ -42,10 +44,14 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.transactions.Transaction;
import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT;
import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
+import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
/**
*
@@ -92,6 +98,13 @@ public class CacheContinuousQueryConcurrentPartitionUpdateTest extends GridCommo
/**
* @throws Exception If failed.
*/
+ public void testConcurrentUpdatePartitionMvccTx() throws Exception {
+ concurrentUpdatePartition(TRANSACTIONAL_SNAPSHOT, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testConcurrentUpdatePartitionAtomicCacheGroup() throws Exception {
concurrentUpdatePartition(ATOMIC, true);
}
@@ -104,6 +117,13 @@ public class CacheContinuousQueryConcurrentPartitionUpdateTest extends GridCommo
}
/**
+ * @throws Exception If failed.
+ */
+ public void testConcurrentUpdatePartitionMvccTxCacheGroup() throws Exception {
+ concurrentUpdatePartition(TRANSACTIONAL_SNAPSHOT, true);
+ }
+
+ /**
* @param atomicityMode Cache atomicity mode.
* @param cacheGrp {@code True} if test cache multiple caches in the same group.
* @throws Exception If failed.
@@ -179,8 +199,30 @@ public class CacheContinuousQueryConcurrentPartitionUpdateTest extends GridCommo
ThreadLocalRandom rnd = ThreadLocalRandom.current();
for (int i = 0; i < UPDATES; i++) {
- for (int c = 0; c < srvCaches.size(); c++)
- srvCaches.get(c).put(keys.get(rnd.nextInt(KEYS)), i);
+ for (int c = 0; c < srvCaches.size(); c++) {
+ if (atomicityMode == ATOMIC)
+ srvCaches.get(c).put(keys.get(rnd.nextInt(KEYS)), i);
+ else {
+ IgniteCache<Object, Object> cache0 = srvCaches.get(c);
+ IgniteTransactions txs = cache0.unwrap(Ignite.class).transactions();
+
+ boolean committed = false;
+
+ while (!committed) {
+ try (Transaction tx = txs.txStart(PESSIMISTIC, REPEATABLE_READ)) {
+ cache0.put(keys.get(rnd.nextInt(KEYS)), i);
+
+ tx.commit();
+
+ committed = true;
+ }
+ catch (CacheException e) {
+ assertTrue(e.getMessage() != null &&
+ e.getMessage().contains("Cannot serialize transaction due to write conflict"));
+ }
+ }
+ }
+ }
}
return null;
@@ -246,6 +288,13 @@ public class CacheContinuousQueryConcurrentPartitionUpdateTest extends GridCommo
/**
* @throws Exception If failed.
*/
+ public void testConcurrentUpdatesAndQueryStartMvccTx() throws Exception {
+ concurrentUpdatesAndQueryStart(TRANSACTIONAL_SNAPSHOT, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testConcurrentUpdatesAndQueryStartAtomicCacheGroup() throws Exception {
concurrentUpdatesAndQueryStart(ATOMIC, true);
}
@@ -258,6 +307,13 @@ public class CacheContinuousQueryConcurrentPartitionUpdateTest extends GridCommo
}
/**
+ * @throws Exception If failed.
+ */
+ public void testConcurrentUpdatesAndQueryStartMvccTxCacheGroup() throws Exception {
+ concurrentUpdatesAndQueryStart(TRANSACTIONAL_SNAPSHOT, true);
+ }
+
+ /**
* @param atomicityMode Cache atomicity mode.
* @param cacheGrp {@code True} if test cache multiple caches in the same group.
* @throws Exception If failed.
@@ -333,8 +389,29 @@ public class CacheContinuousQueryConcurrentPartitionUpdateTest extends GridCommo
ThreadLocalRandom rnd = ThreadLocalRandom.current();
while (!stop.get()) {
- for (IgniteCache<Object, Object> srvCache : srvCaches)
- srvCache.put(keys.get(rnd.nextInt(KEYS)), rnd.nextInt(100) - 200);
+ for (IgniteCache<Object, Object> srvCache : srvCaches) {
+ if (atomicityMode == ATOMIC)
+ srvCache.put(keys.get(rnd.nextInt(KEYS)), rnd.nextInt(100) - 200);
+ else {
+ IgniteTransactions txs = srvCache.unwrap(Ignite.class).transactions();
+
+ boolean committed = false;
+
+ while (!committed) {
+ try (Transaction tx = txs.txStart(PESSIMISTIC, REPEATABLE_READ)) {
+ srvCache.put(keys.get(rnd.nextInt(KEYS)), rnd.nextInt(100) - 200);
+
+ tx.commit();
+
+ committed = true;
+ }
+ catch (CacheException e) {
+ assertTrue(e.getMessage() != null &&
+ e.getMessage().contains("Cannot serialize transaction due to write conflict"));
+ }
+ }
+ }
+ }
}
return null;
@@ -361,8 +438,29 @@ public class CacheContinuousQueryConcurrentPartitionUpdateTest extends GridCommo
ThreadLocalRandom rnd = ThreadLocalRandom.current();
for (int i = 0; i < UPDATES; i++) {
- for (IgniteCache<Object, Object> srvCache : srvCaches)
- srvCache.put(keys.get(rnd.nextInt(KEYS)), i);
+ for (IgniteCache<Object, Object> srvCache : srvCaches) {
+ if (atomicityMode == ATOMIC)
+ srvCache.put(keys.get(rnd.nextInt(KEYS)), i);
+ else {
+ IgniteTransactions txs = srvCache.unwrap(Ignite.class).transactions();
+
+ boolean committed = false;
+
+ while (!committed) {
+ try (Transaction tx = txs.txStart(PESSIMISTIC, REPEATABLE_READ)) {
+ srvCache.put(keys.get(rnd.nextInt(KEYS)), i);
+
+ tx.commit();
+
+ committed = true;
+ }
+ catch (CacheException e) {
+ assertTrue(e.getMessage() != null &&
+ e.getMessage().contains("Cannot serialize transaction due to write conflict"));
+ }
+ }
+ }
+ }
}
return null;
http://git-wip-us.apache.org/repos/asf/ignite/blob/51a202a4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryExecuteInPrimaryTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryExecuteInPrimaryTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryExecuteInPrimaryTest.java
index ffc7fd9..789504c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryExecuteInPrimaryTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryExecuteInPrimaryTest.java
@@ -50,6 +50,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT;
import static org.apache.ignite.cache.CacheMode.LOCAL;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
import static org.apache.ignite.cache.CacheMode.REPLICATED;
@@ -159,6 +160,38 @@ public class CacheContinuousQueryExecuteInPrimaryTest extends GridCommonAbstract
/**
* @throws Exception If failed.
*/
+ public void testMvccTransactionLocalCache() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-9530");
+
+ CacheConfiguration<Integer, String> ccfg = cacheConfiguration(TRANSACTIONAL_SNAPSHOT, LOCAL);
+
+ doTestWithoutEventsEntries(ccfg);
+ doTestWithEventsEntries(ccfg);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMvccTransactionReplicatedCache() throws Exception {
+ CacheConfiguration<Integer, String> ccfg = cacheConfiguration(TRANSACTIONAL_SNAPSHOT, REPLICATED);
+
+ doTestWithoutEventsEntries(ccfg);
+ doTestWithEventsEntries(ccfg);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMvccTransactionPartitionedCache() throws Exception {
+ CacheConfiguration<Integer, String> ccfg = cacheConfiguration(TRANSACTIONAL_SNAPSHOT, PARTITIONED);
+
+ doTestWithoutEventsEntries(ccfg);
+ doTestWithEventsEntries(ccfg);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
private void doTestWithoutEventsEntries(CacheConfiguration<Integer, String> ccfg) throws Exception {
try (IgniteCache<Integer, String> cache = grid(0).createCache(ccfg)) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/51a202a4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFactoryFilterRandomOperationTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFactoryFilterRandomOperationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFactoryFilterRandomOperationTest.java
index 993ef79..d216d4f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFactoryFilterRandomOperationTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFactoryFilterRandomOperationTest.java
@@ -46,6 +46,7 @@ import javax.cache.event.CacheEntryRemovedListener;
import javax.cache.event.CacheEntryUpdatedListener;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheEntryEventSerializableFilter;
import org.apache.ignite.cache.affinity.Affinity;
import org.apache.ignite.cache.query.CacheQueryEntryEvent;
@@ -61,11 +62,12 @@ import org.jetbrains.annotations.NotNull;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
-import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT;
import static org.apache.ignite.cache.CacheMode.REPLICATED;
import static org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFactoryFilterRandomOperationTest.NonSerializableFilter.isAccepted;
import static org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryRandomOperationsTest.ContinuousDeploy.CLIENT;
import static org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryRandomOperationsTest.ContinuousDeploy.SERVER;
+import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED;
import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
import static org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE;
@@ -274,8 +276,16 @@ public class CacheContinuousQueryFactoryFilterRandomOperationTest extends CacheC
Transaction tx = null;
- if (cache.getConfiguration(CacheConfiguration.class).getAtomicityMode() == TRANSACTIONAL && rnd.nextBoolean())
- tx = ignite.transactions().txStart(txRandomConcurrency(rnd), txRandomIsolation(rnd));
+ CacheAtomicityMode atomicityMode = cache.getConfiguration(CacheConfiguration.class).getAtomicityMode();
+
+ boolean mvccEnabled = atomicityMode == TRANSACTIONAL_SNAPSHOT;
+
+ if (atomicityMode != ATOMIC && rnd.nextBoolean()) {
+ TransactionConcurrency concurrency = mvccEnabled ? PESSIMISTIC : txRandomConcurrency(rnd);
+ TransactionIsolation isolation = mvccEnabled ? REPEATABLE_READ : txRandomIsolation(rnd);
+
+ tx = ignite.transactions().txStart(concurrency, isolation);
+ }
try {
// log.info("Random operation [key=" + key + ", op=" + op + ']');
@@ -287,7 +297,7 @@ public class CacheContinuousQueryFactoryFilterRandomOperationTest extends CacheC
if (tx != null)
tx.commit();
- updatePartitionCounter(cache, key, partCntr);
+ updatePartitionCounter(cache, key, partCntr, false);
waitAndCheckEvent(evtsQueues, partCntr, affinity(cache), key, newVal, oldVal);
@@ -302,7 +312,7 @@ public class CacheContinuousQueryFactoryFilterRandomOperationTest extends CacheC
if (tx != null)
tx.commit();
- updatePartitionCounter(cache, key, partCntr);
+ updatePartitionCounter(cache, key, partCntr, false);
waitAndCheckEvent(evtsQueues, partCntr, affinity(cache), key, newVal, oldVal);
@@ -312,12 +322,13 @@ public class CacheContinuousQueryFactoryFilterRandomOperationTest extends CacheC
}
case 2: {
- cache.remove(key);
+ boolean res = cache.remove(key);
if (tx != null)
tx.commit();
- updatePartitionCounter(cache, key, partCntr);
+ // We don't update part counter if nothing was removed when MVCC enabled.
+ updatePartitionCounter(cache, key, partCntr, mvccEnabled && !res);
waitAndCheckEvent(evtsQueues, partCntr, affinity(cache), key, oldVal, oldVal);
@@ -327,12 +338,13 @@ public class CacheContinuousQueryFactoryFilterRandomOperationTest extends CacheC
}
case 3: {
- cache.getAndRemove(key);
+ Object res = cache.getAndRemove(key);
if (tx != null)
tx.commit();
- updatePartitionCounter(cache, key, partCntr);
+ // We don't update part counter if nothing was removed when MVCC enabled.
+ updatePartitionCounter(cache, key, partCntr, mvccEnabled && res == null);
waitAndCheckEvent(evtsQueues, partCntr, affinity(cache), key, oldVal, oldVal);
@@ -347,7 +359,7 @@ public class CacheContinuousQueryFactoryFilterRandomOperationTest extends CacheC
if (tx != null)
tx.commit();
- updatePartitionCounter(cache, key, partCntr);
+ updatePartitionCounter(cache, key, partCntr, false);
waitAndCheckEvent(evtsQueues, partCntr, affinity(cache), key, newVal, oldVal);
@@ -357,12 +369,15 @@ public class CacheContinuousQueryFactoryFilterRandomOperationTest extends CacheC
}
case 5: {
- cache.invoke(key, new EntrySetValueProcessor(null, rnd.nextBoolean()));
+ EntrySetValueProcessor proc = new EntrySetValueProcessor(null, rnd.nextBoolean());
+
+ cache.invoke(key, proc);
if (tx != null)
tx.commit();
- updatePartitionCounter(cache, key, partCntr);
+ // We don't update part counter if nothing was removed when MVCC enabled.
+ updatePartitionCounter(cache, key, partCntr, mvccEnabled && proc.getOldVal() == null);
waitAndCheckEvent(evtsQueues, partCntr, affinity(cache), key, oldVal, oldVal);
@@ -378,7 +393,7 @@ public class CacheContinuousQueryFactoryFilterRandomOperationTest extends CacheC
tx.commit();
if (oldVal == null) {
- updatePartitionCounter(cache, key, partCntr);
+ updatePartitionCounter(cache, key, partCntr, false);
waitAndCheckEvent(evtsQueues, partCntr, affinity(cache), key, newVal, null);
@@ -397,7 +412,7 @@ public class CacheContinuousQueryFactoryFilterRandomOperationTest extends CacheC
tx.commit();
if (oldVal == null) {
- updatePartitionCounter(cache, key, partCntr);
+ updatePartitionCounter(cache, key, partCntr, false);
waitAndCheckEvent(evtsQueues, partCntr, affinity(cache), key, newVal, null);
@@ -416,7 +431,7 @@ public class CacheContinuousQueryFactoryFilterRandomOperationTest extends CacheC
tx.commit();
if (oldVal != null) {
- updatePartitionCounter(cache, key, partCntr);
+ updatePartitionCounter(cache, key, partCntr, false);
waitAndCheckEvent(evtsQueues, partCntr, affinity(cache), key, newVal, oldVal);
@@ -435,7 +450,7 @@ public class CacheContinuousQueryFactoryFilterRandomOperationTest extends CacheC
tx.commit();
if (oldVal != null) {
- updatePartitionCounter(cache, key, partCntr);
+ updatePartitionCounter(cache, key, partCntr, false);
waitAndCheckEvent(evtsQueues, partCntr, affinity(cache), key, newVal, oldVal);
@@ -459,7 +474,7 @@ public class CacheContinuousQueryFactoryFilterRandomOperationTest extends CacheC
if (tx != null)
tx.commit();
- updatePartitionCounter(cache, key, partCntr);
+ updatePartitionCounter(cache, key, partCntr, false);
waitAndCheckEvent(evtsQueues, partCntr, affinity(cache), key, newVal, oldVal);
@@ -523,8 +538,10 @@ public class CacheContinuousQueryFactoryFilterRandomOperationTest extends CacheC
* @param cache Cache.
* @param key Key
* @param cntrs Partition counters.
+ * @param skipUpdCntr Skip update counter flag.
*/
- private void updatePartitionCounter(IgniteCache<Object, Object> cache, Object key, Map<Integer, Long> cntrs) {
+ private void updatePartitionCounter(IgniteCache<Object, Object> cache, Object key, Map<Integer, Long> cntrs,
+ boolean skipUpdCntr) {
Affinity<Object> aff = cache.unwrap(Ignite.class).affinity(cache.getName());
int part = aff.partition(key);
@@ -534,7 +551,10 @@ public class CacheContinuousQueryFactoryFilterRandomOperationTest extends CacheC
if (partCntr == null)
partCntr = 0L;
- cntrs.put(part, ++partCntr);
+ if (!skipUpdCntr)
+ partCntr++;
+
+ cntrs.put(part, partCntr);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/51a202a4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryLostPartitionTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryLostPartitionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryLostPartitionTest.java
index bcbf1e0..150d94d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryLostPartitionTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryLostPartitionTest.java
@@ -38,6 +38,7 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import static javax.cache.configuration.FactoryBuilder.factoryOf;
import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
import static org.apache.ignite.cache.CacheRebalanceMode.SYNC;
import static org.apache.ignite.cache.CacheWriteSynchronizationMode.PRIMARY_SYNC;
@@ -55,6 +56,9 @@ public class CacheContinuousQueryLostPartitionTest extends GridCommonAbstractTes
/** Cache name. */
public static final String TX_CACHE_NAME = "tx_test_cache";
+ /** Cache name. */
+ public static final String MVCC_TX_CACHE_NAME = "mvcc_tx_test_cache";
+
/** {@inheritDoc} */
@Override protected void beforeTest() throws Exception {
super.beforeTest();
@@ -83,6 +87,13 @@ public class CacheContinuousQueryLostPartitionTest extends GridCommonAbstractTes
/**
* @throws Exception If failed.
*/
+ public void testMvccTxEvent() throws Exception {
+ testEvent(MVCC_TX_CACHE_NAME, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testAtomicEvent() throws Exception {
testEvent(CACHE_NAME, false);
}
@@ -97,6 +108,13 @@ public class CacheContinuousQueryLostPartitionTest extends GridCommonAbstractTes
/**
* @throws Exception If failed.
*/
+ public void testMvccTxClientEvent() throws Exception {
+ testEvent(MVCC_TX_CACHE_NAME, true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testAtomicClientEvent() throws Exception {
testEvent(CACHE_NAME, true);
}
@@ -202,7 +220,7 @@ public class CacheContinuousQueryLostPartitionTest extends GridCommonAbstractTes
spi.setIpFinder(ipFinder);
cfg.setDiscoverySpi(spi);
- cfg.setCacheConfiguration(cache(TX_CACHE_NAME), cache(CACHE_NAME));
+ cfg.setCacheConfiguration(cache(TX_CACHE_NAME), cache(CACHE_NAME), cache(MVCC_TX_CACHE_NAME));
if (igniteInstanceName.endsWith("3"))
cfg.setClientMode(true);
@@ -221,8 +239,10 @@ public class CacheContinuousQueryLostPartitionTest extends GridCommonAbstractTes
if (cacheName.equals(CACHE_NAME))
cfg.setAtomicityMode(ATOMIC);
- else
+ else if (cacheName.equals(TX_CACHE_NAME))
cfg.setAtomicityMode(TRANSACTIONAL);
+ else
+ cfg.setAtomicityMode(TRANSACTIONAL_SNAPSHOT);
cfg.setRebalanceMode(SYNC);
cfg.setWriteSynchronizationMode(PRIMARY_SYNC);
http://git-wip-us.apache.org/repos/asf/ignite/blob/51a202a4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryOperationFromCallbackTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryOperationFromCallbackTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryOperationFromCallbackTest.java
index 0540b43..3cb13bf 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryOperationFromCallbackTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryOperationFromCallbackTest.java
@@ -63,10 +63,13 @@ import org.jetbrains.annotations.Nullable;
import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
import static org.apache.ignite.cache.CacheMode.REPLICATED;
import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
import static org.apache.ignite.cache.CacheWriteSynchronizationMode.PRIMARY_SYNC;
+import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
+import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
/**
*
@@ -197,6 +200,60 @@ public class CacheContinuousQueryOperationFromCallbackTest extends GridCommonAbs
}
/**
+ * @throws Exception If failed.
+ */
+ public void testMvccTxTwoBackupsFilter() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED, 2, TRANSACTIONAL_SNAPSHOT, FULL_SYNC);
+
+ doTest(ccfg, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMvccTxTwoBackupsFilterPrimary() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED, 2, TRANSACTIONAL_SNAPSHOT, PRIMARY_SYNC);
+
+ doTest(ccfg, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMvccTxReplicatedFilter() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(REPLICATED, 0, TRANSACTIONAL_SNAPSHOT, FULL_SYNC);
+
+ doTest(ccfg, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMvccTxTwoBackup() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED, 2, TRANSACTIONAL_SNAPSHOT, FULL_SYNC);
+
+ doTest(ccfg, true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMvccTxReplicated() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(REPLICATED, 2, TRANSACTIONAL_SNAPSHOT, FULL_SYNC);
+
+ doTest(ccfg, true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMvccTxReplicatedPrimary() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(REPLICATED, 2, TRANSACTIONAL_SNAPSHOT, PRIMARY_SYNC);
+
+ doTest(ccfg, true);
+ }
+
+ /**
* @param ccfg Cache configuration.
* @throws Exception If failed.
*/
@@ -252,33 +309,50 @@ public class CacheContinuousQueryOperationFromCallbackTest extends GridCommonAbs
QueryTestKey key = new QueryTestKey(rnd.nextInt(KEYS));
- boolean startTx = cache.getConfiguration(CacheConfiguration.class).getAtomicityMode() ==
- TRANSACTIONAL && rnd.nextBoolean();
+ boolean startTx = cache.getConfiguration(CacheConfiguration.class).getAtomicityMode() !=
+ ATOMIC && rnd.nextBoolean();
Transaction tx = null;
- if (startTx)
- tx = cache.unwrap(Ignite.class).transactions().txStart();
+ boolean committed = false;
- try {
- if ((cache.get(key) == null) || rnd.nextBoolean())
- cache.invoke(key, new IncrementTestEntryProcessor());
- else {
- QueryTestValue val;
- QueryTestValue newVal;
+ while (!committed && !Thread.currentThread().isInterrupted()) {
+ try {
+ if (startTx)
+ tx = cache.unwrap(Ignite.class).transactions().txStart(PESSIMISTIC, REPEATABLE_READ);
- do {
- val = cache.get(key);
+ if ((cache.get(key) == null) || rnd.nextBoolean())
+ cache.invoke(key, new IncrementTestEntryProcessor());
+ else {
+ QueryTestValue val;
+ QueryTestValue newVal;
- newVal = val == null ?
- new QueryTestValue(0) : new QueryTestValue(val.val1 + 1);
+ do {
+ val = cache.get(key);
+
+ newVal = val == null ?
+ new QueryTestValue(0) : new QueryTestValue(val.val1 + 1);
+ }
+ while (!cache.replace(key, val, newVal));
}
- while (!cache.replace(key, val, newVal));
+
+ if (tx != null)
+ tx.commit();
+
+ committed = true;
+ }
+ catch (Exception e) {
+ assertTrue(e.getMessage(), e.getMessage() != null &&
+ (e.getMessage().contains("Transaction has been rolled back") ||
+ e.getMessage().contains("Cannot serialize transaction due to write conflict")));
+
+ // Wait MVCC updates become visible.
+ doSleep(50);
+ }
+ finally {
+ if (tx != null)
+ tx.close();
}
- }
- finally {
- if (tx != null)
- tx.commit();
}
}
}
@@ -302,7 +376,7 @@ public class CacheContinuousQueryOperationFromCallbackTest extends GridCommonAbs
@Override public boolean apply() {
return cbCntr.get() >= expCnt;
}
- }, TimeUnit.SECONDS.toMillis(60));
+ }, TimeUnit.SECONDS.toMillis(120));
assertTrue("Failed to wait events [exp=" + expCnt + ", act=" + cbCntr.get() + "]", res);
@@ -319,7 +393,7 @@ public class CacheContinuousQueryOperationFromCallbackTest extends GridCommonAbs
@Override public boolean apply() {
return filterCbCntr.get() >= expInvkCnt;
}
- }, TimeUnit.SECONDS.toMillis(60));
+ }, TimeUnit.SECONDS.toMillis(120));
assertEquals(expInvkCnt, filterCbCntr.get());
@@ -407,17 +481,45 @@ public class CacheContinuousQueryOperationFromCallbackTest extends GridCommonAbs
if (e.getKey().compareTo(new QueryTestKey(KEYS)) < 0) {
IgniteCache<QueryTestKey, QueryTestValue> cache = ignite.cache(cacheName);
- if (ThreadLocalRandom.current().nextBoolean()) {
- Set<QueryTestKey> keys = new LinkedHashSet<>();
+ boolean committed = false;
+ Transaction tx = null;
+ boolean startTx = cache.getConfiguration(CacheConfiguration.class).getAtomicityMode() == TRANSACTIONAL_SNAPSHOT;
+
+ while (!committed && !Thread.currentThread().isInterrupted()) {
+ try {
+ if (startTx)
+ tx = ignite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ);
- for (int key = KEYS; key < KEYS + KEYS_FROM_CALLBACK; key++)
- keys.add(new QueryTestKey(key));
+ if (ThreadLocalRandom.current().nextBoolean()) {
+ Set<QueryTestKey> keys = new LinkedHashSet<>();
- cache.invokeAll(keys, new IncrementTestEntryProcessor());
- }
- else {
- for (int key = KEYS; key < KEYS + KEYS_FROM_CALLBACK; key++)
- cache.invoke(new QueryTestKey(key), new IncrementTestEntryProcessor());
+ for (int key = KEYS; key < KEYS + KEYS_FROM_CALLBACK; key++)
+ keys.add(new QueryTestKey(key));
+
+ cache.invokeAll(keys, new IncrementTestEntryProcessor());
+ }
+ else {
+ for (int key = KEYS; key < KEYS + KEYS_FROM_CALLBACK; key++)
+ cache.invoke(new QueryTestKey(key), new IncrementTestEntryProcessor());
+ }
+
+ if (tx != null)
+ tx.commit();
+
+ committed = true;
+ }
+ catch (Exception ex) {
+ assertTrue(ex.getMessage(), ex.getMessage() != null &&
+ (ex.getMessage().contains("Transaction has been rolled back") ||
+ ex.getMessage().contains("Cannot serialize transaction due to write conflict")));
+
+ // Wait MVCC updates become visible.
+ doSleep(50);
+ }
+ finally {
+ if (tx != null)
+ tx.close();
+ }
}
filterCbCntr.incrementAndGet();
@@ -477,17 +579,42 @@ public class CacheContinuousQueryOperationFromCallbackTest extends GridCommonAbs
cntr.incrementAndGet();
if (cache != null) {
- if (ThreadLocalRandom.current().nextBoolean()) {
- Set<QueryTestKey> keys = new LinkedHashSet<>();
+ boolean committed = false;
+ Transaction tx = null;
+ boolean startTx = cache.getConfiguration(CacheConfiguration.class).getAtomicityMode() == TRANSACTIONAL_SNAPSHOT;
- for (int key = KEYS; key < KEYS + KEYS_FROM_CALLBACK; key++)
- keys.add(new QueryTestKey(key));
+ while (!committed && !Thread.currentThread().isInterrupted()) {
+ try {
+ if (startTx)
+ tx = cache.unwrap(Ignite.class).transactions().txStart(PESSIMISTIC, REPEATABLE_READ);
- cache.invokeAll(keys, new IncrementTestEntryProcessor());
- }
- else {
- for (int key = KEYS; key < KEYS + KEYS_FROM_CALLBACK; key++)
- cache.invoke(new QueryTestKey(key), new IncrementTestEntryProcessor());
+ if (ThreadLocalRandom.current().nextBoolean()) {
+ Set<QueryTestKey> keys = new LinkedHashSet<>();
+
+ for (int key = KEYS; key < KEYS + KEYS_FROM_CALLBACK; key++)
+ keys.add(new QueryTestKey(key));
+
+ cache.invokeAll(keys, new IncrementTestEntryProcessor());
+ }
+ else {
+ for (int key = KEYS; key < KEYS + KEYS_FROM_CALLBACK; key++)
+ cache.invoke(new QueryTestKey(key), new IncrementTestEntryProcessor());
+ }
+
+ if (tx != null)
+ tx.commit();
+
+ committed = true;
+ }
+ catch (Exception ex) {
+ assertTrue(ex.getMessage(), ex.getMessage() != null &&
+ (ex.getMessage().contains("Transaction has been rolled back") ||
+ ex.getMessage().contains("Cannot serialize transaction due to write conflict")));
+ }
+ finally {
+ if (tx != null)
+ tx.close();
+ }
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/51a202a4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryOperationP2PTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryOperationP2PTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryOperationP2PTest.java
index eb53fa3..f2889df 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryOperationP2PTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryOperationP2PTest.java
@@ -42,6 +42,7 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
import static org.apache.ignite.cache.CacheMode.REPLICATED;
import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
@@ -185,6 +186,53 @@ public class CacheContinuousQueryOperationP2PTest extends GridCommonAbstractTest
}
/**
+ * @throws Exception If failed.
+ */
+ public void testMvccTx() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
+ 1,
+ TRANSACTIONAL_SNAPSHOT
+ );
+
+ testContinuousQuery(ccfg, false);
+ }
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMvccTxClient() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
+ 1,
+ TRANSACTIONAL_SNAPSHOT
+ );
+
+ testContinuousQuery(ccfg, true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMvccTxReplicated() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(REPLICATED,
+ 0,
+ TRANSACTIONAL_SNAPSHOT
+ );
+
+ testContinuousQuery(ccfg, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMvccTxReplicatedClient() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(REPLICATED,
+ 0,
+ TRANSACTIONAL_SNAPSHOT
+ );
+
+ testContinuousQuery(ccfg, true);
+ }
+
+ /**
* @param ccfg Cache configuration.
* @param isClient Client.
* @throws Exception If failed.
http://git-wip-us.apache.org/repos/asf/ignite/blob/51a202a4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryOrderingEventTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryOrderingEventTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryOrderingEventTest.java
index 7442e24..1ad45dd 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryOrderingEventTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryOrderingEventTest.java
@@ -62,10 +62,13 @@ import org.apache.ignite.transactions.Transaction;
import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
import static org.apache.ignite.cache.CacheMode.REPLICATED;
import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
import static org.apache.ignite.cache.CacheWriteSynchronizationMode.PRIMARY_SYNC;
+import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
+import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
/**
*
@@ -163,6 +166,33 @@ public class CacheContinuousQueryOrderingEventTest extends GridCommonAbstractTes
doOrderingTest(ccfg, false);
}
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMvccTxOnheapTwoBackup() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED, 2, TRANSACTIONAL_SNAPSHOT, FULL_SYNC);
+
+ doOrderingTest(ccfg, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMvccTxOnheapWithoutBackup() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED, 0, TRANSACTIONAL_SNAPSHOT, PRIMARY_SYNC);
+
+ doOrderingTest(ccfg, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMvccTxOnheapWithoutBackupFullSync() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED, 0, TRANSACTIONAL_SNAPSHOT, FULL_SYNC);
+
+ doOrderingTest(ccfg, false);
+ }
+
// ASYNC
/**
@@ -238,6 +268,33 @@ public class CacheContinuousQueryOrderingEventTest extends GridCommonAbstractTes
}
/**
+ * @throws Exception If failed.
+ */
+ public void testMvccTxOnheapTwoBackupAsync() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED, 2, TRANSACTIONAL_SNAPSHOT, PRIMARY_SYNC);
+
+ doOrderingTest(ccfg, true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMvccTxOnheapAsync() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED, 0, TRANSACTIONAL_SNAPSHOT, PRIMARY_SYNC);
+
+ doOrderingTest(ccfg, true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMvccTxOnheapAsyncFullSync() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED, 0, TRANSACTIONAL_SNAPSHOT, FULL_SYNC);
+
+ doOrderingTest(ccfg, true);
+ }
+
+ /**
* @param ccfg Cache configuration.
* @param async Async filter.
* @throws Exception If failed.
@@ -298,46 +355,60 @@ public class CacheContinuousQueryOrderingEventTest extends GridCommonAbstractTes
QueryTestKey key = new QueryTestKey(rnd.nextInt(KEYS));
- boolean startTx = cache.getConfiguration(CacheConfiguration.class).getAtomicityMode() ==
- TRANSACTIONAL && rnd.nextBoolean();
+ boolean startTx = cache.getConfiguration(CacheConfiguration.class).getAtomicityMode() !=
+ ATOMIC && rnd.nextBoolean();
Transaction tx = null;
- if (startTx)
- tx = cache.unwrap(Ignite.class).transactions().txStart();
-
- try {
- if ((cache.get(key) == null) || rnd.nextBoolean()) {
- cache.invoke(key, new CacheEntryProcessor<QueryTestKey, QueryTestValue, Object>() {
- @Override public Object process(
- MutableEntry<QueryTestKey, QueryTestValue> entry,
- Object... arguments)
- throws EntryProcessorException {
- if (entry.exists())
- entry.setValue(new QueryTestValue(entry.getValue().val1 + 1));
- else
- entry.setValue(new QueryTestValue(0));
-
- return null;
- }
- });
- }
- else {
- QueryTestValue val;
- QueryTestValue newVal;
+ boolean committed = false;
+
+ while (!committed && !Thread.currentThread().isInterrupted()) {
+ try {
+ if (startTx)
+ tx = cache.unwrap(Ignite.class).transactions().txStart(PESSIMISTIC, REPEATABLE_READ);
+
+ if ((cache.get(key) == null) || rnd.nextBoolean()) {
+ cache.invoke(key, new CacheEntryProcessor<QueryTestKey, QueryTestValue, Object>() {
+ @Override public Object process(
+ MutableEntry<QueryTestKey, QueryTestValue> entry,
+ Object... arguments)
+ throws EntryProcessorException {
+ if (entry.exists())
+ entry.setValue(new QueryTestValue(entry.getValue().val1 + 1));
+ else
+ entry.setValue(new QueryTestValue(0));
+
+ return null;
+ }
+ });
+ }
+ else {
+ QueryTestValue val;
+ QueryTestValue newVal;
- do {
- val = cache.get(key);
+ do {
+ val = cache.get(key);
- newVal = val == null ?
- new QueryTestValue(0) : new QueryTestValue(val.val1 + 1);
+ newVal = val == null ?
+ new QueryTestValue(0) : new QueryTestValue(val.val1 + 1);
+ }
+ while (!cache.replace(key, val, newVal));
}
- while (!cache.replace(key, val, newVal));
+
+ if (tx != null)
+ tx.commit();
+
+ committed = true;
+ }
+ catch (Exception e) {
+ assertTrue(e.getMessage(), e.getMessage() != null &&
+ (e.getMessage().contains("Transaction has been rolled back") ||
+ e.getMessage().contains("Cannot serialize transaction due to write conflict")));
+ }
+ finally {
+ if (tx != null)
+ tx.close();
}
- }
- finally {
- if (tx != null)
- tx.commit();
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/51a202a4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryRandomOperationsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryRandomOperationsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryRandomOperationsTest.java
index 6d15df2..af92c31 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryRandomOperationsTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryRandomOperationsTest.java
@@ -84,12 +84,14 @@ import static javax.cache.event.EventType.REMOVED;
import static javax.cache.event.EventType.UPDATED;
import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
import static org.apache.ignite.cache.CacheMode.REPLICATED;
import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
import static org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryRandomOperationsTest.ContinuousDeploy.ALL;
import static org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryRandomOperationsTest.ContinuousDeploy.CLIENT;
import static org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryRandomOperationsTest.ContinuousDeploy.SERVER;
+import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED;
import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
import static org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE;
@@ -330,6 +332,42 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
/**
* @throws Exception If failed.
*/
+ public void testMvccTx() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
+ 1,
+ TRANSACTIONAL_SNAPSHOT,
+ false);
+
+ doTestContinuousQuery(ccfg, SERVER);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMvccTxAllNodes() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
+ 1,
+ TRANSACTIONAL_SNAPSHOT,
+ false);
+
+ doTestContinuousQuery(ccfg, ALL);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMvccTxExplicit() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
+ 1,
+ TRANSACTIONAL_SNAPSHOT,
+ false);
+
+ doTestContinuousQuery(ccfg, SERVER);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testDoubleRemoveAtomicWithoutBackup() throws Exception {
CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
0,
@@ -346,7 +384,7 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
0,
ATOMIC,
- false);
+ true);
doTestNotModifyOperation(ccfg);
}
@@ -394,7 +432,7 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
1,
TRANSACTIONAL,
- false);
+ true);
doTestNotModifyOperation(ccfg);
}
@@ -418,6 +456,18 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
CacheConfiguration<Object, Object> ccfg = cacheConfiguration(REPLICATED,
0,
TRANSACTIONAL,
+ true);
+
+ doTestNotModifyOperation(ccfg);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDoubleRemoveMvccTx() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
+ 1,
+ TRANSACTIONAL_SNAPSHOT,
false);
doTestNotModifyOperation(ccfg);
@@ -426,6 +476,46 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
/**
* @throws Exception If failed.
*/
+ public void testDoubleRemoveMvccTxWithStore() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-8582");
+
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
+ 1,
+ TRANSACTIONAL_SNAPSHOT,
+ true);
+
+ doTestNotModifyOperation(ccfg);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDoubleRemoveReplicatedMvccTx() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(REPLICATED,
+ 0,
+ TRANSACTIONAL_SNAPSHOT,
+ false);
+
+ doTestNotModifyOperation(ccfg);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDoubleRemoveReplicatedMvccTxWithStore() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-8582");
+
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(REPLICATED,
+ 0,
+ TRANSACTIONAL_SNAPSHOT,
+ true);
+
+ doTestNotModifyOperation(ccfg);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testDoubleRemoveReplicatedAtomic() throws Exception {
CacheConfiguration<Object, Object> ccfg = cacheConfiguration(REPLICATED,
0,
@@ -827,6 +917,102 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
}
/**
+ * @throws Exception If failed.
+ */
+ public void testMvccTxClient() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
+ 1,
+ TRANSACTIONAL_SNAPSHOT,
+ false);
+
+ doTestContinuousQuery(ccfg, CLIENT);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMvccTxClientExplicit() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
+ 1,
+ TRANSACTIONAL_SNAPSHOT,
+ false);
+
+ doTestContinuousQuery(ccfg, CLIENT);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMvccTxReplicated() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(REPLICATED,
+ 0,
+ TRANSACTIONAL_SNAPSHOT,
+ false);
+
+ doTestContinuousQuery(ccfg, SERVER);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMvccTxReplicatedClient() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(REPLICATED,
+ 0,
+ TRANSACTIONAL_SNAPSHOT,
+ false);
+
+ doTestContinuousQuery(ccfg, CLIENT);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMvccTxNoBackups() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
+ 0,
+ TRANSACTIONAL_SNAPSHOT,
+ false);
+
+ doTestContinuousQuery(ccfg, SERVER);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMvccTxNoBackupsAllNodes() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
+ 0,
+ TRANSACTIONAL_SNAPSHOT,
+ false);
+
+ doTestContinuousQuery(ccfg, ALL);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMvccTxNoBackupsExplicit() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
+ 0,
+ TRANSACTIONAL_SNAPSHOT,
+ false);
+
+ doTestContinuousQuery(ccfg, SERVER);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMvccTxNoBackupsClient() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
+ 0,
+ TRANSACTIONAL_SNAPSHOT,
+ false);
+
+ doTestContinuousQuery(ccfg, CLIENT);
+ }
+
+ /**
* @param ccfg Cache configuration.
* @param deploy The place where continuous query will be started.
* @throws Exception If failed.
@@ -988,11 +1174,19 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
Transaction tx = null;
- if (cache.getConfiguration(CacheConfiguration.class).getAtomicityMode() == TRANSACTIONAL && rnd.nextBoolean())
- tx = ignite.transactions().txStart(txRandomConcurrency(rnd), txRandomIsolation(rnd));
+ CacheAtomicityMode atomicityMode = cache.getConfiguration(CacheConfiguration.class).getAtomicityMode();
+
+ boolean mvccEnabled = atomicityMode == TRANSACTIONAL_SNAPSHOT;
+
+ if (atomicityMode != ATOMIC && rnd.nextBoolean()) {
+ TransactionConcurrency concurrency = mvccEnabled ? PESSIMISTIC : txRandomConcurrency(rnd);
+ TransactionIsolation isolation = mvccEnabled ? REPEATABLE_READ : txRandomIsolation(rnd);
+
+ tx = ignite.transactions().txStart(concurrency, isolation);
+ }
try {
- // log.info("Random operation [key=" + key + ", op=" + op + ']');
+ log.info("Random operation [key=" + key + ", op=" + op + ']');
switch (op) {
case 0: {
@@ -1001,7 +1195,7 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
if (tx != null)
tx.commit();
- updatePartitionCounter(cache, key, partCntr, expEvtCntrs);
+ updatePartitionCounter(cache, key, partCntr, expEvtCntrs, false);
waitAndCheckEvent(evtsQueues, partCntr, expEvtCntrs, affinity(cache), key, newVal, oldVal);
@@ -1016,7 +1210,7 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
if (tx != null)
tx.commit();
- updatePartitionCounter(cache, key, partCntr, expEvtCntrs);
+ updatePartitionCounter(cache, key, partCntr, expEvtCntrs, false);
waitAndCheckEvent(evtsQueues, partCntr, expEvtCntrs, affinity(cache), key, newVal, oldVal);
@@ -1026,12 +1220,13 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
}
case 2: {
- cache.remove(key);
+ boolean res = cache.remove(key);
if (tx != null)
tx.commit();
- updatePartitionCounter(cache, key, partCntr, expEvtCntrs);
+ // We don't update part counter if nothing was removed when MVCC enabled.
+ updatePartitionCounter(cache, key, partCntr, expEvtCntrs, mvccEnabled && !res);
waitAndCheckEvent(evtsQueues, partCntr, expEvtCntrs, affinity(cache), key, oldVal, oldVal);
@@ -1041,12 +1236,13 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
}
case 3: {
- cache.getAndRemove(key);
+ Object res = cache.getAndRemove(key);
if (tx != null)
tx.commit();
- updatePartitionCounter(cache, key, partCntr, expEvtCntrs);
+ // We don't update part counter if nothing was removed when MVCC enabled.
+ updatePartitionCounter(cache, key, partCntr, expEvtCntrs, mvccEnabled && res == null);
waitAndCheckEvent(evtsQueues, partCntr, expEvtCntrs, affinity(cache), key, oldVal, oldVal);
@@ -1061,7 +1257,7 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
if (tx != null)
tx.commit();
- updatePartitionCounter(cache, key, partCntr, expEvtCntrs);
+ updatePartitionCounter(cache, key, partCntr, expEvtCntrs, false);
waitAndCheckEvent(evtsQueues, partCntr, expEvtCntrs, affinity(cache), key, newVal, oldVal);
@@ -1071,12 +1267,15 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
}
case 5: {
- cache.invoke(key, new EntrySetValueProcessor(null, rnd.nextBoolean()));
+ EntrySetValueProcessor proc = new EntrySetValueProcessor(null, rnd.nextBoolean());
+
+ cache.invoke(key, proc);
if (tx != null)
tx.commit();
- updatePartitionCounter(cache, key, partCntr, expEvtCntrs);
+ // We don't update part counter if nothing was removed when MVCC enabled.
+ updatePartitionCounter(cache, key, partCntr, expEvtCntrs,mvccEnabled && proc.getOldVal() == null);
waitAndCheckEvent(evtsQueues, partCntr, expEvtCntrs, affinity(cache), key, oldVal, oldVal);
@@ -1092,7 +1291,7 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
tx.commit();
if (oldVal == null) {
- updatePartitionCounter(cache, key, partCntr, expEvtCntrs);
+ updatePartitionCounter(cache, key, partCntr, expEvtCntrs, false);
waitAndCheckEvent(evtsQueues, partCntr, expEvtCntrs, affinity(cache), key, newVal, null);
@@ -1111,7 +1310,7 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
tx.commit();
if (oldVal == null) {
- updatePartitionCounter(cache, key, partCntr, expEvtCntrs);
+ updatePartitionCounter(cache, key, partCntr, expEvtCntrs, false);
waitAndCheckEvent(evtsQueues, partCntr, expEvtCntrs, affinity(cache), key, newVal, null);
@@ -1130,7 +1329,7 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
tx.commit();
if (oldVal != null) {
- updatePartitionCounter(cache, key, partCntr, expEvtCntrs);
+ updatePartitionCounter(cache, key, partCntr, expEvtCntrs, false);
waitAndCheckEvent(evtsQueues, partCntr, expEvtCntrs, affinity(cache), key, newVal, oldVal);
@@ -1149,7 +1348,7 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
tx.commit();
if (oldVal != null) {
- updatePartitionCounter(cache, key, partCntr, expEvtCntrs);
+ updatePartitionCounter(cache, key, partCntr, expEvtCntrs, false);
waitAndCheckEvent(evtsQueues, partCntr, expEvtCntrs, affinity(cache), key, newVal, oldVal);
@@ -1173,7 +1372,7 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
if (tx != null)
tx.commit();
- updatePartitionCounter(cache, key, partCntr, expEvtCntrs);
+ updatePartitionCounter(cache, key, partCntr, expEvtCntrs, false);
waitAndCheckEvent(evtsQueues, partCntr, expEvtCntrs, affinity(cache), key, newVal, oldVal);
@@ -1212,7 +1411,7 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
tx.commit();
for (Map.Entry<Object, Object> e : vals.entrySet())
- updatePartitionCounter(cache, e.getKey(), partCntr, expEvtCntrs);
+ updatePartitionCounter(cache, e.getKey(), partCntr, expEvtCntrs, false);
waitAndCheckEvent(evtsQueues, partCntr, expEvtCntrs, affinity(cache), vals, expData);
@@ -1233,7 +1432,7 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
tx.commit();
for (Map.Entry<Object, Object> e : vals.entrySet())
- updatePartitionCounter(cache, e.getKey(), partCntr, expEvtCntrs);
+ updatePartitionCounter(cache, e.getKey(), partCntr, expEvtCntrs, false);
waitAndCheckEvent(evtsQueues, partCntr, expEvtCntrs, affinity(cache), vals, expData);
@@ -1330,16 +1529,18 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
* @return {@link TransactionConcurrency}.
*/
private TransactionConcurrency txRandomConcurrency(Random rnd) {
- return rnd.nextBoolean() ? TransactionConcurrency.OPTIMISTIC : TransactionConcurrency.PESSIMISTIC;
+ return rnd.nextBoolean() ? TransactionConcurrency.OPTIMISTIC : PESSIMISTIC;
}
/**
* @param cache Cache.
* @param key Key
* @param cntrs Partition counters.
+ * @param evtCntrs Event counters.
+ * @param skipUpdCntr Skip update counter flag.
*/
private void updatePartitionCounter(IgniteCache<Object, Object> cache, Object key, Map<Integer, Long> cntrs,
- Map<Object, Long> evtCntrs) {
+ Map<Object, Long> evtCntrs, boolean skipUpdCntr) {
Affinity<Object> aff = cache.unwrap(Ignite.class).affinity(cache.getName());
int part = aff.partition(key);
@@ -1349,7 +1550,10 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
if (partCntr == null)
partCntr = 0L;
- cntrs.put(part, ++partCntr);
+ if (!skipUpdCntr)
+ partCntr++;
+
+ cntrs.put(part, partCntr);
evtCntrs.put(key, partCntr);
}
@@ -1577,6 +1781,12 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
*
*/
protected static class EntrySetValueProcessor implements EntryProcessor<Object, Object, Object> {
+ /**
+ * Static variable: we need to obtain a previous value from another node.
+ * Assume this is a single threaded execution.
+ */
+ private static Object oldVal;
+
/** */
private Object val;
@@ -1607,6 +1817,8 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
if (skipModify)
return null;
+ oldVal = e.getValue();
+
Object old = retOld ? e.getValue() : null;
if (val != null)
@@ -1617,6 +1829,17 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
return old;
}
+ /**
+ * @return Old value.
+ */
+ Object getOldVal() {
+ Object oldVal0 = oldVal;
+
+ oldVal = null; // Clean value.
+
+ return oldVal0;
+ }
+
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(EntrySetValueProcessor.class, this);
http://git-wip-us.apache.org/repos/asf/ignite/blob/51a202a4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousWithTransformerReplicatedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousWithTransformerReplicatedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousWithTransformerReplicatedSelfTest.java
index 7aa91a2..60e2f80 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousWithTransformerReplicatedSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousWithTransformerReplicatedSelfTest.java
@@ -32,6 +32,7 @@ import javax.cache.expiry.Duration;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheEntryEventSerializableFilter;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.query.ContinuousQueryWithTransformer;
@@ -100,6 +101,7 @@ public class CacheContinuousWithTransformerReplicatedSelfTest extends GridCommon
CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg.setCacheMode(cacheMode());
+ ccfg.setAtomicityMode(atomicityMode());
cfg.setCacheConfiguration(ccfg);
}
@@ -107,6 +109,13 @@ public class CacheContinuousWithTransformerReplicatedSelfTest extends GridCommon
return cfg;
}
+ /**
+ * @return Cache atomicity mode.
+ */
+ protected CacheAtomicityMode atomicityMode() {
+ return CacheAtomicityMode.TRANSACTIONAL;
+ }
+
/** {@inheritDoc} */
@Override protected void afterTest() throws Exception {
gridToRunQuery().cache(DEFAULT_CACHE_NAME).removeAll();
http://git-wip-us.apache.org/repos/asf/ignite/blob/51a202a4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheKeepBinaryIterationNearEnabledTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheKeepBinaryIterationNearEnabledTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheKeepBinaryIterationNearEnabledTest.java
index 9eb56dc..0684d1f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheKeepBinaryIterationNearEnabledTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheKeepBinaryIterationNearEnabledTest.java
@@ -39,4 +39,13 @@ public class CacheKeepBinaryIterationNearEnabledTest extends CacheKeepBinaryIter
return ccfg;
}
+ /** {@inheritDoc} */
+ @Override public void testMvccTxOnHeap() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-7187");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void testMvccTxOnHeapLocalEntries() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-7187");
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/51a202a4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheKeepBinaryIterationStoreEnabledTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheKeepBinaryIterationStoreEnabledTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheKeepBinaryIterationStoreEnabledTest.java
index f98229d..910ce4a 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheKeepBinaryIterationStoreEnabledTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheKeepBinaryIterationStoreEnabledTest.java
@@ -50,6 +50,16 @@ public class CacheKeepBinaryIterationStoreEnabledTest extends CacheKeepBinaryIte
return ccfg;
}
+ /** {@inheritDoc} */
+ @Override public void testMvccTxOnHeap() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-8582");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void testMvccTxOnHeapLocalEntries() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-8582");
+ }
+
/**
*
*/