You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by nt...@apache.org on 2016/03/01 12:09:27 UTC
[01/20] ignite git commit: IGNITE-2681: Binary serialization warning
is no longer printed to the log.
Repository: ignite
Updated Branches:
refs/heads/ignite-1186 e80e906fa -> 846e8e5d4
IGNITE-2681: Binary serialization warning is no longer printed to the log.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/5a663a97
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/5a663a97
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/5a663a97
Branch: refs/heads/ignite-1186
Commit: 5a663a97078803fc1618b371e11502db71f0f6a3
Parents: 7d65ec9
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Feb 26 14:19:44 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Feb 26 14:19:44 2016 +0300
----------------------------------------------------------------------
.../org/apache/ignite/internal/binary/BinaryClassDescriptor.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/5a663a97/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
index e831e96..d32b99a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
@@ -175,7 +175,7 @@ public class BinaryClassDescriptor {
}
if (useOptMarshaller && userType && !U.isIgnite(cls) && !U.isJdk(cls)) {
- U.quietAndWarn(ctx.log(), "Class \"" + cls.getName() + "\" cannot be serialized using " +
+ U.warn(ctx.log(), "Class \"" + cls.getName() + "\" cannot be serialized using " +
BinaryMarshaller.class.getSimpleName() + " because it either implements Externalizable interface " +
"or have writeObject/readObject methods. " + OptimizedMarshaller.class.getSimpleName() + " will be " +
"used instead and class instances will be deserialized on the server. Please ensure that all nodes " +
[03/20] ignite git commit: IGNITE-2715: No more spam from within
GridQueryProcessor about missing field for BinaryProperty. This closes #514.
Posted by nt...@apache.org.
IGNITE-2715: No more spam from within GridQueryProcessor about missing field for BinaryProperty. This closes #514.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/78728db6
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/78728db6
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/78728db6
Branch: refs/heads/ignite-1186
Commit: 78728db680a6d0bf444cb08c5f8cc8708c934a94
Parents: 42572ad
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Feb 26 14:45:30 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Feb 26 14:45:30 2016 +0300
----------------------------------------------------------------------
.../internal/processors/query/GridQueryProcessor.java | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/78728db6/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index b13c674..074e7e5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -1948,6 +1948,9 @@ public class GridQueryProcessor extends GridProcessorAdapter {
/** Flag indicating that we already tried to take a field. */
private volatile boolean fieldTaken;
+ /** Whether user was warned about missing property. */
+ private volatile boolean warned;
+
/**
* Constructor.
*
@@ -1987,8 +1990,12 @@ public class GridQueryProcessor extends GridProcessorAdapter {
else if (val instanceof BinaryObject && ((BinaryObject)val).hasField(propName))
isKeyProp = isKeyProp0 = -1;
else {
- U.warn(log, "Neither key nor value have property " +
- "[propName=" + propName + ", key=" + key + ", val=" + val + "]");
+ if (!warned) {
+ U.warn(log, "Neither key nor value have property \"" + propName + "\" " +
+ "(is cache indexing configured correctly?)");
+
+ warned = true;
+ }
return null;
}
[11/20] ignite git commit: ignite-2521: Configuration variations
tests framework + IgniteCacheBasicConfigVariationsFullApiTestSuite +
ignite-2554: Fixed Affinity.mapKeyToNode() for dynamically started LOCAL
cache
Posted by nt...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/953b575f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigVariationsFullApiTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigVariationsFullApiTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigVariationsFullApiTest.java
new file mode 100644
index 0000000..2ba7bb9
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigVariationsFullApiTest.java
@@ -0,0 +1,5851 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.locks.Lock;
+import javax.cache.Cache;
+import javax.cache.CacheException;
+import javax.cache.event.CacheEntryEvent;
+import javax.cache.event.CacheEntryListenerException;
+import javax.cache.event.CacheEntryUpdatedListener;
+import javax.cache.expiry.Duration;
+import javax.cache.expiry.ExpiryPolicy;
+import javax.cache.expiry.TouchedExpiryPolicy;
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.EntryProcessorResult;
+import javax.cache.processor.MutableEntry;
+import junit.framework.AssertionFailedError;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.IgniteTransactions;
+import org.apache.ignite.cache.CacheEntryEventSerializableFilter;
+import org.apache.ignite.cache.CacheEntryProcessor;
+import org.apache.ignite.cache.CachePeekMode;
+import org.apache.ignite.cache.affinity.Affinity;
+import org.apache.ignite.cache.query.ContinuousQuery;
+import org.apache.ignite.cache.query.QueryCursor;
+import org.apache.ignite.cache.query.ScanQuery;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.events.Event;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager;
+import org.apache.ignite.internal.util.lang.GridAbsPredicate;
+import org.apache.ignite.internal.util.lang.GridAbsPredicateX;
+import org.apache.ignite.internal.util.typedef.CIX1;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.PA;
+import org.apache.ignite.internal.util.typedef.internal.A;
+import org.apache.ignite.internal.util.typedef.internal.CU;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteBiPredicate;
+import org.apache.ignite.lang.IgniteClosure;
+import org.apache.ignite.lang.IgniteFuture;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.resources.LoggerResource;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.IgniteCacheConfigVariationsAbstractTest;
+import org.apache.ignite.transactions.Transaction;
+import org.apache.ignite.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+import org.jetbrains.annotations.Nullable;
+
+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.CacheMemoryMode.OFFHEAP_TIERED;
+import static org.apache.ignite.cache.CacheMode.LOCAL;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+import static org.apache.ignite.cache.CacheMode.REPLICATED;
+import static org.apache.ignite.cache.CachePeekMode.ALL;
+import static org.apache.ignite.cache.CachePeekMode.BACKUP;
+import static org.apache.ignite.cache.CachePeekMode.OFFHEAP;
+import static org.apache.ignite.cache.CachePeekMode.ONHEAP;
+import static org.apache.ignite.cache.CachePeekMode.PRIMARY;
+import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_LOCKED;
+import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_SWAPPED;
+import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_UNLOCKED;
+import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_UNSWAPPED;
+import static org.apache.ignite.testframework.GridTestUtils.assertThrows;
+import static org.apache.ignite.testframework.GridTestUtils.waitForCondition;
+import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC;
+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;
+import static org.apache.ignite.transactions.TransactionState.COMMITTED;
+
+/**
+ * Full API cache test.
+ */
+@SuppressWarnings({"TransientFieldInNonSerializableClass", "unchecked"})
+public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVariationsAbstractTest {
+ /** Test timeout */
+ private static final long TEST_TIMEOUT = 60 * 1000;
+
+ /** */
+ public static final CacheEntryProcessor<String, Integer, String> ERR_PROCESSOR =
+ new CacheEntryProcessor<String, Integer, String>() {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ @Override public String process(MutableEntry<String, Integer> e, Object... args) {
+ throw new RuntimeException("Failed!");
+ }
+ };
+
+ /** Increment processor for invoke operations. */
+ public static final EntryProcessor<Object, Object, Object> INCR_PROCESSOR = new IncrementEntryProcessor();
+
+ /** Increment processor for invoke operations with IgniteEntryProcessor. */
+ public static final CacheEntryProcessor<Object, Object, Object> INCR_IGNITE_PROCESSOR =
+ new CacheEntryProcessor<Object, Object, Object>() {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ @Override public Object process(MutableEntry<Object, Object> e, Object... args) {
+ return INCR_PROCESSOR.process(e, args);
+ }
+ };
+
+ /** Increment processor for invoke operations. */
+ public static final EntryProcessor<Object, Object, Object> RMV_PROCESSOR = new RemoveEntryProcessor();
+
+ /** Increment processor for invoke operations with IgniteEntryProcessor. */
+ public static final CacheEntryProcessor<Object, Object, Object> RMV_IGNITE_PROCESSOR =
+ new CacheEntryProcessor<Object, Object, Object>() {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ @Override public Object process(MutableEntry<Object, Object> e, Object... args) {
+ return RMV_PROCESSOR.process(e, args);
+ }
+ };
+
+ /** {@inheritDoc} */
+ @Override protected long getTestTimeout() {
+ return TEST_TIMEOUT;
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testSize() throws Exception {
+ assert jcache().localSize() == 0;
+
+ int size = 10;
+
+ final Map<String, Integer> map = new HashMap<>();
+
+ for (int i = 0; i < size; i++)
+ map.put("key" + i, i);
+
+ // Put in primary nodes to avoid near readers which will prevent entry from being cleared.
+ Map<ClusterNode, Collection<String>> mapped = grid(0).<String>affinity(cacheName()).mapKeysToNodes(map.keySet());
+
+ for (int i = 0; i < gridCount(); i++) {
+ Collection<String> keys = mapped.get(grid(i).localNode());
+
+ if (!F.isEmpty(keys)) {
+ for (String key : keys)
+ jcache(i).put(key, map.get(key));
+ }
+ }
+
+ map.remove("key0");
+
+ mapped = grid(0).<String>affinity(cacheName()).mapKeysToNodes(map.keySet());
+
+ for (int i = 0; i < gridCount(); i++) {
+ // Will actually delete entry from map.
+ CU.invalidate(jcache(i), "key0");
+
+ assertNull("Failed check for grid: " + i, jcache(i).localPeek("key0", ONHEAP));
+
+ Collection<String> keysCol = mapped.get(grid(i).localNode());
+
+ assert jcache(i).localSize() != 0 || F.isEmpty(keysCol);
+ }
+
+ for (int i = 0; i < gridCount(); i++)
+ executeOnLocalOrRemoteJvm(i, new CheckCacheSizeTask(map, cacheName()));
+
+ for (int i = 0; i < gridCount(); i++) {
+ Collection<String> keysCol = mapped.get(grid(i).localNode());
+
+ assertEquals("Failed check for grid: " + i, !F.isEmpty(keysCol) ? keysCol.size() : 0,
+ jcache(i).localSize(PRIMARY));
+ }
+
+ int globalPrimarySize = map.size();
+
+ for (int i = 0; i < gridCount(); i++)
+ assertEquals(globalPrimarySize, jcache(i).size(PRIMARY));
+
+ int times = 1;
+
+ if (cacheMode() == REPLICATED)
+ times = gridCount() - clientsCount();
+ else if (cacheMode() == PARTITIONED)
+ times = Math.min(gridCount(), jcache().getConfiguration(CacheConfiguration.class).getBackups() + 1);
+
+ int globalSize = globalPrimarySize * times;
+
+ for (int i = 0; i < gridCount(); i++)
+ assertEquals(globalSize, jcache(i).size(ALL));
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testContainsKey() throws Exception {
+ jcache().put("testContainsKey", 1);
+
+ checkContainsKey(true, "testContainsKey");
+ checkContainsKey(false, "testContainsKeyWrongKey");
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testContainsKeyTx() throws Exception {
+ if (!txEnabled())
+ return;
+
+ IgniteCache<String, Integer> cache = jcache();
+
+ IgniteTransactions txs = ignite(0).transactions();
+
+ for (int i = 0; i < 10; i++) {
+ String key = String.valueOf(i);
+
+ try (Transaction tx = txs.txStart()) {
+ assertNull(key, cache.get(key));
+
+ assertFalse(cache.containsKey(key));
+
+ tx.commit();
+ }
+
+ try (Transaction tx = txs.txStart()) {
+ assertNull(key, cache.get(key));
+
+ cache.put(key, i);
+
+ assertTrue(cache.containsKey(key));
+
+ tx.commit();
+ }
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testContainsKeysTx() throws Exception {
+ if (!txEnabled())
+ return;
+
+ IgniteCache<String, Integer> cache = jcache();
+
+ IgniteTransactions txs = ignite(0).transactions();
+
+ Set<String> keys = new HashSet<>();
+
+ for (int i = 0; i < 10; i++) {
+ String key = String.valueOf(i);
+
+ keys.add(key);
+ }
+
+ try (Transaction tx = txs.txStart()) {
+ for (String key : keys)
+ assertNull(key, cache.get(key));
+
+ assertFalse(cache.containsKeys(keys));
+
+ tx.commit();
+ }
+
+ try (Transaction tx = txs.txStart()) {
+ for (String key : keys)
+ assertNull(key, cache.get(key));
+
+ for (String key : keys)
+ cache.put(key, 0);
+
+ assertTrue(cache.containsKeys(keys));
+
+ tx.commit();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testRemoveInExplicitLocks() throws Exception {
+ if (lockingEnabled()) {
+ IgniteCache<String, Integer> cache = jcache();
+
+ cache.put("a", 1);
+
+ Lock lock = cache.lockAll(ImmutableSet.of("a", "b", "c", "d"));
+
+ lock.lock();
+
+ try {
+ cache.remove("a");
+
+ // Make sure single-key operation did not remove lock.
+ cache.putAll(F.asMap("b", 2, "c", 3, "d", 4));
+ }
+ finally {
+ lock.unlock();
+ }
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testRemoveAllSkipStore() throws Exception {
+ if (isMultiJvm())
+ fail("https://issues.apache.org/jira/browse/IGNITE-1088");
+
+ if (!storeEnabled())
+ return;
+
+ IgniteCache<String, Integer> jcache = jcache();
+
+ jcache.putAll(F.asMap("1", 1, "2", 2, "3", 3));
+
+ jcache.withSkipStore().removeAll();
+
+ assertEquals((Integer)1, jcache.get("1"));
+ assertEquals((Integer)2, jcache.get("2"));
+ assertEquals((Integer)3, jcache.get("3"));
+ }
+
+ /**
+ * @throws IgniteCheckedException If failed.
+ */
+ public void testAtomicOps() throws IgniteCheckedException {
+ IgniteCache<String, Integer> c = jcache();
+
+ final int cnt = 10;
+
+ for (int i = 0; i < cnt; i++)
+ assertNull(c.getAndPutIfAbsent("k" + i, i));
+
+ for (int i = 0; i < cnt; i++) {
+ boolean wrong = i % 2 == 0;
+
+ String key = "k" + i;
+
+ boolean res = c.replace(key, wrong ? i + 1 : i, -1);
+
+ assertEquals(wrong, !res);
+ }
+
+ for (int i = 0; i < cnt; i++) {
+ boolean success = i % 2 != 0;
+
+ String key = "k" + i;
+
+ boolean res = c.remove(key, -1);
+
+ assertTrue(success == res);
+ }
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testGet() throws Exception {
+ runInAllDataModes(new TestRunnable() {
+ @Override public void run() {
+ IgniteCache cache = jcache();
+
+ cache.put(key(1), value(1));
+ cache.put(key(2), value(2));
+
+ assertEquals(value(1), cache.get(key(1)));
+ assertEquals(value(2), cache.get(key(2)));
+ // Wrong key.
+ assertNull(cache.get(key(3)));
+ }
+ });
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testGetAsync() throws Exception {
+ IgniteCache<String, Integer> cache = jcache();
+
+ cache.put("key1", 1);
+ cache.put("key2", 2);
+
+ IgniteCache<String, Integer> cacheAsync = cache.withAsync();
+
+ cacheAsync.get("key1");
+
+ IgniteFuture<Integer> fut1 = cacheAsync.future();
+
+ cacheAsync.get("key2");
+
+ IgniteFuture<Integer> fut2 = cacheAsync.future();
+
+ cacheAsync.get("wrongKey");
+
+ IgniteFuture<Integer> fut3 = cacheAsync.future();
+
+ assert fut1.get() == 1;
+ assert fut2.get() == 2;
+ assert fut3.get() == null;
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testGetAll() throws Exception {
+ runInAllDataModes(new TestRunnable() {
+ @Override public void run() {
+ final Object key1 = key(1);
+ final Object key2 = key(2);
+ final Object key9999 = key(9999);
+
+ final Object val1 = value(1);
+ final Object val2 = value(2);
+
+ Transaction tx = txShouldBeUsed() ? transactions().txStart() : null;
+
+ final IgniteCache<Object, Object> cache = jcache();
+
+ try {
+ cache.put(key1, val1);
+ cache.put(key2, val2);
+
+ if (tx != null)
+ tx.commit();
+ }
+ finally {
+ if (tx != null)
+ tx.close();
+ }
+
+ GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ cache.getAll(null).isEmpty();
+
+ return null;
+ }
+ }, NullPointerException.class, null);
+
+ assert cache.getAll(Collections.<Object>emptySet()).isEmpty();
+
+ Map<Object, Object> map1 = cache.getAll(ImmutableSet.of(key1, key2, key9999));
+
+ info("Retrieved map1: " + map1);
+
+ assert 2 == map1.size() : "Invalid map: " + map1;
+
+ assertEquals(val1, map1.get(key1));
+ assertEquals(val2, map1.get(key2));
+ assertNull(map1.get(key9999));
+
+ Map<Object, Object> map2 = cache.getAll(ImmutableSet.of(key1, key2, key9999));
+
+ info("Retrieved map2: " + map2);
+
+ assert 2 == map2.size() : "Invalid map: " + map2;
+
+ assertEquals(val1, map2.get(key1));
+ assertEquals(val2, map2.get(key2));
+ assertNull(map2.get(key9999));
+
+ // Now do the same checks but within transaction.
+ if (txShouldBeUsed()) {
+ try (Transaction tx0 = transactions().txStart()) {
+ assert cache.getAll(Collections.<Object>emptySet()).isEmpty();
+
+ map1 = cache.getAll(ImmutableSet.of(key1, key2, key9999));
+
+ info("Retrieved map1: " + map1);
+
+ assert 2 == map1.size() : "Invalid map: " + map1;
+
+ assertEquals(val1, map2.get(key1));
+ assertEquals(val2, map2.get(key2));
+ assertNull(map2.get(key9999));
+
+ map2 = cache.getAll(ImmutableSet.of(key1, key2, key9999));
+
+ info("Retrieved map2: " + map2);
+
+ assert 2 == map2.size() : "Invalid map: " + map2;
+
+ assertEquals(val1, map2.get(key1));
+ assertEquals(val2, map2.get(key2));
+ assertNull(map2.get(key9999));
+
+ tx0.commit();
+ }
+ }
+ }
+ });
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testGetAllWithNulls() throws Exception {
+ final IgniteCache<String, Integer> cache = jcache();
+
+ final Set<String> c = new HashSet<>();
+
+ c.add("key1");
+ c.add(null);
+
+ GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ cache.getAll(c);
+
+ return null;
+ }
+ }, NullPointerException.class, null);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGetTxNonExistingKey() throws Exception {
+ if (txShouldBeUsed()) {
+ try (Transaction ignored = transactions().txStart()) {
+ assert jcache().get("key999123") == null;
+ }
+ }
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testGetAllAsync() throws Exception {
+ final IgniteCache<String, Integer> cache = jcache();
+
+ final IgniteCache<String, Integer> cacheAsync = cache.withAsync();
+
+ cache.put("key1", 1);
+ cache.put("key2", 2);
+
+ GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ cacheAsync.getAll(null);
+
+ return null;
+ }
+ }, NullPointerException.class, null);
+
+ cacheAsync.getAll(Collections.<String>emptySet());
+ IgniteFuture<Map<String, Integer>> fut2 = cacheAsync.future();
+
+ cacheAsync.getAll(ImmutableSet.of("key1", "key2"));
+ IgniteFuture<Map<String, Integer>> fut3 = cacheAsync.future();
+
+ assert fut2.get().isEmpty();
+ assert fut3.get().size() == 2 : "Invalid map: " + fut3.get();
+ assert fut3.get().get("key1") == 1;
+ assert fut3.get().get("key2") == 2;
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testPut() throws Exception {
+ runInAllDataModes(new TestRunnable() {
+ @Override public void run() throws Exception {
+ IgniteCache cache = jcache();
+
+ final Object key1 = key(1);
+ final Object val1 = value(1);
+ final Object key2 = key(2);
+ final Object val2 = value(2);
+
+ assert cache.getAndPut(key1, val1) == null;
+ assert cache.getAndPut(key2, val2) == null;
+
+ // Check inside transaction.
+ assertEquals(val1, cache.get(key1));
+ assertEquals(val2, cache.get(key2));
+
+ // Put again to check returned values.
+ assertEquals(val1, cache.getAndPut(key1, val1));
+ assertEquals(val2, cache.getAndPut(key2, val2));
+
+ checkContainsKey(true, key1);
+ checkContainsKey(true, key2);
+
+ assert cache.get(key1) != null;
+ assert cache.get(key2) != null;
+ assert cache.get(key(100500)) == null;
+
+ // Check outside transaction.
+ checkContainsKey(true, key1);
+ checkContainsKey(true, key2);
+
+ assertEquals(val1, cache.get(key1));
+ assertEquals(val2, cache.get(key2));
+ assert cache.get(key(100500)) == null;
+
+ assertEquals(val1, cache.getAndPut(key1, value(10)));
+ assertEquals(val2, cache.getAndPut(key2, value(11)));
+ }
+ });
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testPutTx() throws Exception {
+ if (txShouldBeUsed()) {
+ IgniteCache<String, Integer> cache = jcache();
+
+ try (Transaction tx = transactions().txStart()) {
+ assert cache.getAndPut("key1", 1) == null;
+ assert cache.getAndPut("key2", 2) == null;
+
+ // Check inside transaction.
+ assert cache.get("key1") == 1;
+ assert cache.get("key2") == 2;
+
+ // Put again to check returned values.
+ assert cache.getAndPut("key1", 1) == 1;
+ assert cache.getAndPut("key2", 2) == 2;
+
+ assert cache.get("key1") != null;
+ assert cache.get("key2") != null;
+ assert cache.get("wrong") == null;
+
+ tx.commit();
+ }
+
+ // Check outside transaction.
+ checkContainsKey(true, "key1");
+ checkContainsKey(true, "key2");
+
+ assert cache.get("key1") == 1;
+ assert cache.get("key2") == 2;
+ assert cache.get("wrong") == null;
+
+ assertEquals((Integer)1, cache.getAndPut("key1", 10));
+ assertEquals((Integer)2, cache.getAndPut("key2", 11));
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInvokeOptimisticReadCommitted() throws Exception {
+ runInAllDataModes(new TestRunnable() {
+ @Override public void run() throws Exception {
+ checkInvoke(OPTIMISTIC, READ_COMMITTED);
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInvokeOptimisticRepeatableRead() throws Exception {
+ runInAllDataModes(new TestRunnable() {
+ @Override public void run() throws Exception {
+ checkInvoke(OPTIMISTIC, REPEATABLE_READ);
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInvokePessimisticReadCommitted() throws Exception {
+ runInAllDataModes(new TestRunnable() {
+ @Override public void run() throws Exception {
+ checkInvoke(PESSIMISTIC, READ_COMMITTED);
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInvokePessimisticRepeatableRead() throws Exception {
+ runInAllDataModes(new TestRunnable() {
+ @Override public void run() throws Exception {
+ checkInvoke(PESSIMISTIC, REPEATABLE_READ);
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testIgniteInvokeOptimisticReadCommitted1() throws Exception {
+ runInAllDataModes(new TestRunnable() {
+ @Override public void run() throws Exception {
+ checkIgniteInvoke(OPTIMISTIC, READ_COMMITTED);
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testIgniteInvokeOptimisticRepeatableRead() throws Exception {
+ runInAllDataModes(new TestRunnable() {
+ @Override public void run() throws Exception {
+ checkIgniteInvoke(OPTIMISTIC, REPEATABLE_READ);
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testIgniteInvokePessimisticReadCommitted() throws Exception {
+ runInAllDataModes(new TestRunnable() {
+ @Override public void run() throws Exception {
+ checkIgniteInvoke(PESSIMISTIC, READ_COMMITTED);
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testIgniteInvokePessimisticRepeatableRead() throws Exception {
+ runInAllDataModes(new TestRunnable() {
+ @Override public void run() throws Exception {
+ checkIgniteInvoke(PESSIMISTIC, REPEATABLE_READ);
+ }
+ });
+ }
+
+ /**
+ * @param concurrency Concurrency.
+ * @param isolation Isolation.
+ * @throws Exception If failed.
+ */
+ private void checkIgniteInvoke(TransactionConcurrency concurrency, TransactionIsolation isolation)
+ throws Exception {
+ checkInvoke(concurrency, isolation, INCR_IGNITE_PROCESSOR, RMV_IGNITE_PROCESSOR);
+ }
+
+ /**
+ * @param concurrency Transaction concurrency.
+ * @param isolation Transaction isolation.
+ * @param incrProcessor Increment processor.
+ * @param rmvProseccor Remove processor.
+ */
+ private void checkInvoke(TransactionConcurrency concurrency, TransactionIsolation isolation,
+ EntryProcessor<Object, Object, Object> incrProcessor,
+ EntryProcessor<Object, Object, Object> rmvProseccor) {
+ IgniteCache cache = jcache();
+
+ final Object key1 = key(1);
+ final Object key2 = key(2);
+ final Object key3 = key(3);
+
+ final Object val1 = value(1);
+ final Object val2 = value(2);
+ final Object val3 = value(3);
+
+ cache.put(key2, val1);
+ cache.put(key3, val3);
+
+ Transaction tx = txShouldBeUsed() ? ignite(0).transactions().txStart(concurrency, isolation) : null;
+
+ try {
+ assertNull(cache.invoke(key1, incrProcessor, dataMode));
+ assertEquals(val1, cache.invoke(key2, incrProcessor, dataMode));
+ assertEquals(val3, cache.invoke(key3, rmvProseccor));
+
+ if (tx != null)
+ tx.commit();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+
+ throw e;
+ }
+ finally {
+ if (tx != null)
+ tx.close();
+ }
+
+ assertEquals(val1, cache.get(key1));
+ assertEquals(val2, cache.get(key2));
+ assertNull(cache.get(key3));
+
+ for (int i = 0; i < gridCount(); i++)
+ assertNull("Failed for cache: " + i, jcache(i).localPeek(key3, ONHEAP));
+
+ cache.remove(key1);
+ cache.put(key2, val1);
+ cache.put(key3, val3);
+
+ assertNull(cache.invoke(key1, incrProcessor, dataMode));
+ assertEquals(val1, cache.invoke(key2, incrProcessor, dataMode));
+ assertEquals(val3, cache.invoke(key3, rmvProseccor));
+
+ assertEquals(val1, cache.get(key1));
+ assertEquals(val2, cache.get(key2));
+ assertNull(cache.get(key3));
+
+ for (int i = 0; i < gridCount(); i++)
+ assertNull(jcache(i).localPeek(key3, ONHEAP));
+ }
+
+ /**
+ * @param concurrency Concurrency.
+ * @param isolation Isolation.
+ * @throws Exception If failed.
+ */
+ private void checkInvoke(TransactionConcurrency concurrency, TransactionIsolation isolation) throws Exception {
+ checkInvoke(concurrency, isolation, INCR_PROCESSOR, RMV_PROCESSOR);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInvokeAllOptimisticReadCommitted() throws Exception {
+ runInAllDataModes(new TestRunnable() {
+ @Override public void run() throws Exception {
+ checkInvokeAll(OPTIMISTIC, READ_COMMITTED);
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInvokeAllOptimisticRepeatableRead() throws Exception {
+ runInAllDataModes(new TestRunnable() {
+ @Override public void run() throws Exception {
+ checkInvokeAll(OPTIMISTIC, REPEATABLE_READ);
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInvokeAllPessimisticReadCommitted() throws Exception {
+ runInAllDataModes(new TestRunnable() {
+ @Override public void run() throws Exception {
+ checkInvokeAll(PESSIMISTIC, READ_COMMITTED);
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInvokeAllPessimisticRepeatableRead() throws Exception {
+ runInAllDataModes(new TestRunnable() {
+ @Override public void run() throws Exception {
+ checkInvokeAll(PESSIMISTIC, REPEATABLE_READ);
+ }
+ });
+ }
+
+ /**
+ * @param concurrency Transaction concurrency.
+ * @param isolation Transaction isolation.
+ * @throws Exception If failed.
+ */
+ private void checkInvokeAll(TransactionConcurrency concurrency, TransactionIsolation isolation) throws Exception {
+ // TODO IGNITE-2664: enable tests for all modes when IGNITE-2664 will be fixed.
+ if (dataMode != DataMode.EXTERNALIZABLE && gridCount() > 1)
+ return;
+
+ final Object key1 = key(1);
+ final Object key2 = key(2);
+ final Object key3 = key(3);
+
+ final Object val1 = value(1);
+ final Object val2 = value(2);
+ final Object val3 = value(3);
+ final Object val4 = value(4);
+
+ final IgniteCache<Object, Object> cache = jcache();
+
+ cache.put(key2, val1);
+ cache.put(key3, val3);
+
+ if (txShouldBeUsed()) {
+ Map<Object, EntryProcessorResult<Object>> res;
+
+ try (Transaction tx = ignite(0).transactions().txStart(concurrency, isolation)) {
+ res = cache.invokeAll(F.asSet(key1, key2, key3), INCR_PROCESSOR, dataMode);
+
+ tx.commit();
+ }
+
+ assertEquals(val1, cache.get(key1));
+ assertEquals(val2, cache.get(key2));
+ assertEquals(val4, cache.get(key3));
+
+ assertNull(res.get(key1));
+ assertEquals(val1, res.get(key2).get());
+ assertEquals(val3, res.get(key3).get());
+
+ assertEquals(2, res.size());
+
+ cache.remove(key1);
+ cache.put(key2, val1);
+ cache.put(key3, val3);
+ }
+
+ Map<Object, EntryProcessorResult<Object>> res = cache.invokeAll(F.asSet(key1, key2, key3), RMV_PROCESSOR);
+
+ for (int i = 0; i < gridCount(); i++) {
+ assertNull(jcache(i).localPeek(key1, ONHEAP));
+ assertNull(jcache(i).localPeek(key2, ONHEAP));
+ assertNull(jcache(i).localPeek(key3, ONHEAP));
+ }
+
+ assertNull(res.get(key1));
+ assertEquals(val1, res.get(key2).get());
+ assertEquals(val3, res.get(key3).get());
+
+ assertEquals(2, res.size());
+
+ cache.remove(key1);
+ cache.put(key2, val1);
+ cache.put(key3, val3);
+
+ res = cache.invokeAll(F.asSet(key1, key2, key3), INCR_PROCESSOR, dataMode);
+
+ assertEquals(val1, cache.get(key1));
+ assertEquals(val2, cache.get(key2));
+ assertEquals(val4, cache.get(key3));
+
+ assertNull(res.get(key1));
+ assertEquals(val1, res.get(key2).get());
+ assertEquals(val3, res.get(key3).get());
+
+ assertEquals(2, res.size());
+
+ cache.remove(key1);
+ cache.put(key2, val1);
+ cache.put(key3, val3);
+
+ res = cache.invokeAll(F.asMap(key1, INCR_PROCESSOR, key2, INCR_PROCESSOR, key3, INCR_PROCESSOR), dataMode);
+
+ assertEquals(val1, cache.get(key1));
+ assertEquals(val2, cache.get(key2));
+ assertEquals(val4, cache.get(key3));
+
+ assertNull(res.get(key1));
+ assertEquals(val1, res.get(key2).get());
+ assertEquals(val3, res.get(key3).get());
+
+ assertEquals(2, res.size());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInvokeAllWithNulls() throws Exception {
+ runInAllDataModes(new TestRunnable() {
+ @Override public void run() throws Exception {
+ final Object key1 = key(1);
+
+ final IgniteCache<Object, Object> cache = jcache();
+
+ GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ cache.invokeAll((Set<Object>)null, INCR_PROCESSOR, dataMode);
+
+ return null;
+ }
+ }, NullPointerException.class, null);
+
+ GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ cache.invokeAll(F.asSet(key1), null);
+
+ return null;
+ }
+ }, NullPointerException.class, null);
+
+ {
+ final Set<Object> keys = new LinkedHashSet<>(2);
+
+ keys.add(key1);
+ keys.add(null);
+
+ GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ cache.invokeAll(keys, INCR_PROCESSOR, dataMode);
+
+ return null;
+ }
+ }, NullPointerException.class, null);
+
+ GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ cache.invokeAll(F.asSet(key1), null);
+
+ return null;
+ }
+ }, NullPointerException.class, null);
+ }
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInvokeSequentialOptimisticNoStart() throws Exception {
+ runInAllDataModes(new TestRunnable() {
+ @Override public void run() throws Exception {
+ checkInvokeSequential0(false, OPTIMISTIC);
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInvokeSequentialPessimisticNoStart() throws Exception {
+ runInAllDataModes(new TestRunnable() {
+ @Override public void run() throws Exception {
+ checkInvokeSequential0(false, PESSIMISTIC);
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInvokeSequentialOptimisticWithStart() throws Exception {
+ runInAllDataModes(new TestRunnable() {
+ @Override public void run() throws Exception {
+ checkInvokeSequential0(true, OPTIMISTIC);
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInvokeSequentialPessimisticWithStart() throws Exception {
+ runInAllDataModes(new TestRunnable() {
+ @Override public void run() throws Exception {
+ checkInvokeSequential0(true, PESSIMISTIC);
+ }
+ });
+ }
+
+ /**
+ * @param startVal Whether to put value.
+ * @param concurrency Concurrency.
+ * @throws Exception If failed.
+ */
+ private void checkInvokeSequential0(boolean startVal, TransactionConcurrency concurrency)
+ throws Exception {
+ final Object val1 = value(1);
+ final Object val2 = value(2);
+ final Object val3 = value(3);
+
+ IgniteCache<Object, Object> cache = jcache();
+
+ final Object key = primaryTestObjectKeysForCache(cache, 1).get(0);
+
+ Transaction tx = txShouldBeUsed() ? ignite(0).transactions().txStart(concurrency, READ_COMMITTED) : null;
+
+ try {
+ if (startVal)
+ cache.put(key, val2);
+ else
+ assertEquals(null, cache.get(key));
+
+ Object expRes = startVal ? val2 : null;
+
+ assertEquals(expRes, cache.invoke(key, INCR_PROCESSOR, dataMode));
+
+ expRes = startVal ? val3 : val1;
+
+ assertEquals(expRes, cache.invoke(key, INCR_PROCESSOR, dataMode));
+
+ expRes = value(valueOf(expRes) + 1);
+
+ assertEquals(expRes, cache.invoke(key, INCR_PROCESSOR, dataMode));
+
+ if (tx != null)
+ tx.commit();
+ }
+ finally {
+ if (tx != null)
+ tx.close();
+ }
+
+ Object exp = value((startVal ? 2 : 0) + 3);
+
+ assertEquals(exp, cache.get(key));
+
+ for (int i = 0; i < gridCount(); i++) {
+ if (ignite(i).affinity(cacheName()).isPrimaryOrBackup(grid(i).localNode(), key))
+ assertEquals(exp, peek(jcache(i), key));
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInvokeAfterRemoveOptimistic() throws Exception {
+ runInAllDataModes(new TestRunnable() {
+ @Override public void run() throws Exception {
+ checkInvokeAfterRemove(OPTIMISTIC);
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInvokeAfterRemovePessimistic() throws Exception {
+ runInAllDataModes(new TestRunnable() {
+ @Override public void run() throws Exception {
+ checkInvokeAfterRemove(PESSIMISTIC);
+ }
+ });
+ }
+
+ /**
+ * @param concurrency Concurrency.
+ * @throws Exception If failed.
+ */
+ private void checkInvokeAfterRemove(TransactionConcurrency concurrency) throws Exception {
+ IgniteCache<Object, Object> cache = jcache();
+
+ Object key = key(1);
+
+ cache.put(key, value(4));
+
+ Transaction tx = txShouldBeUsed() ? ignite(0).transactions().txStart(concurrency, READ_COMMITTED) : null;
+
+ try {
+ cache.remove(key);
+
+ cache.invoke(key, INCR_PROCESSOR, dataMode);
+ cache.invoke(key, INCR_PROCESSOR, dataMode);
+ cache.invoke(key, INCR_PROCESSOR, dataMode);
+
+ if (tx != null)
+ tx.commit();
+ }
+ finally {
+ if (tx != null)
+ tx.close();
+ }
+
+ assertEquals(value(3), cache.get(key));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInvokeReturnValueGetOptimisticReadCommitted() throws Exception {
+ runInAllDataModes(new TestRunnable() {
+ @Override public void run() throws Exception {
+ checkInvokeReturnValue(false, OPTIMISTIC, READ_COMMITTED);
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInvokeReturnValueGetOptimisticRepeatableRead() throws Exception {
+ runInAllDataModes(new TestRunnable() {
+ @Override public void run() throws Exception {
+ checkInvokeReturnValue(false, OPTIMISTIC, REPEATABLE_READ);
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInvokeReturnValueGetPessimisticReadCommitted() throws Exception {
+ runInAllDataModes(new TestRunnable() {
+ @Override public void run() throws Exception {
+ checkInvokeReturnValue(false, PESSIMISTIC, READ_COMMITTED);
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInvokeReturnValueGetPessimisticRepeatableRead() throws Exception {
+ runInAllDataModes(new TestRunnable() {
+ @Override public void run() throws Exception {
+ checkInvokeReturnValue(false, PESSIMISTIC, REPEATABLE_READ);
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInvokeReturnValuePutInTx() throws Exception {
+ runInAllDataModes(new TestRunnable() {
+ @Override public void run() throws Exception {
+ checkInvokeReturnValue(true, OPTIMISTIC, READ_COMMITTED);
+ }
+ });
+ }
+
+ /**
+ * @param put Whether to put value.
+ * @param concurrency Concurrency.
+ * @param isolation Isolation.
+ * @throws Exception If failed.
+ */
+ private void checkInvokeReturnValue(boolean put,
+ TransactionConcurrency concurrency,
+ TransactionIsolation isolation)
+ throws Exception {
+ IgniteCache<Object, Object> cache = jcache();
+
+ Object key = key(1);
+ Object val1 = value(1);
+ Object val2 = value(2);
+
+ if (!put)
+ cache.put(key, val1);
+
+ Transaction tx = txShouldBeUsed() ? ignite(0).transactions().txStart(concurrency, isolation) : null;
+
+ try {
+ if (put)
+ cache.put(key, val1);
+
+ cache.invoke(key, INCR_PROCESSOR, dataMode);
+
+ assertEquals(val2, cache.get(key));
+
+ if (tx != null) {
+ // Second get inside tx. Make sure read value is not transformed twice.
+ assertEquals(val2, cache.get(key));
+
+ tx.commit();
+ }
+ }
+ finally {
+ if (tx != null)
+ tx.close();
+ }
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testGetAndPutAsync() throws Exception {
+ IgniteCache<String, Integer> cache = jcache();
+
+ IgniteCache<String, Integer> cacheAsync = cache.withAsync();
+
+ cache.put("key1", 1);
+ cache.put("key2", 2);
+
+ cacheAsync.getAndPut("key1", 10);
+
+ IgniteFuture<Integer> fut1 = cacheAsync.future();
+
+ cacheAsync.getAndPut("key2", 11);
+
+ IgniteFuture<Integer> fut2 = cacheAsync.future();
+
+ assertEquals((Integer)1, fut1.get(5000));
+ assertEquals((Integer)2, fut2.get(5000));
+
+ assertEquals((Integer)10, cache.get("key1"));
+ assertEquals((Integer)11, cache.get("key2"));
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testPutAsync0() throws Exception {
+ IgniteCache cacheAsync = jcache().withAsync();
+
+ cacheAsync.getAndPut("key1", 0);
+
+ IgniteFuture<Integer> fut1 = cacheAsync.future();
+
+ cacheAsync.getAndPut("key2", 1);
+
+ IgniteFuture<Integer> fut2 = cacheAsync.future();
+
+ assert fut1.get(5000) == null;
+ assert fut2.get(5000) == null;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInvokeAsync() throws Exception {
+ runInAllDataModes(new TestRunnable() {
+ @Override public void run() throws Exception {
+ final Object key1 = key(1);
+ final Object key2 = key(2);
+ final Object key3 = key(3);
+
+ final Object val1 = value(1);
+ final Object val2 = value(2);
+ final Object val3 = value(3);
+
+ IgniteCache<Object, Object> cache = jcache();
+
+ cache.put(key2, val1);
+ cache.put(key3, val3);
+
+ IgniteCache<Object, Object> cacheAsync = cache.withAsync();
+
+ assertNull(cacheAsync.invoke(key1, INCR_PROCESSOR, dataMode));
+
+ IgniteFuture<?> fut0 = cacheAsync.future();
+
+ assertNull(cacheAsync.invoke(key2, INCR_PROCESSOR, dataMode));
+
+ IgniteFuture<?> fut1 = cacheAsync.future();
+
+ assertNull(cacheAsync.invoke(key3, RMV_PROCESSOR));
+
+ IgniteFuture<?> fut2 = cacheAsync.future();
+
+ fut0.get();
+ fut1.get();
+ fut2.get();
+
+ assertEquals(val1, cache.get(key1));
+ assertEquals(val2, cache.get(key2));
+ assertNull(cache.get(key3));
+
+ for (int i = 0; i < gridCount(); i++)
+ assertNull(jcache(i).localPeek(key3, ONHEAP));
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInvoke() throws Exception {
+ runInAllDataModes(new TestRunnable() {
+ @Override public void run() throws Exception {
+ final Object k0 = key(0);
+ final Object k1 = key(1);
+
+ final Object val1 = value(1);
+ final Object val2 = value(2);
+ final Object val3 = value(3);
+
+ final IgniteCache<Object, Object> cache = jcache();
+
+ assertNull(cache.invoke(k0, INCR_PROCESSOR, dataMode));
+
+ assertEquals(k1, cache.get(k0));
+
+ assertEquals(val1, cache.invoke(k0, INCR_PROCESSOR, dataMode));
+
+ assertEquals(val2, cache.get(k0));
+
+ cache.put(k1, val1);
+
+ assertEquals(val1, cache.invoke(k1, INCR_PROCESSOR, dataMode));
+
+ assertEquals(val2, cache.get(k1));
+
+ assertEquals(val2, cache.invoke(k1, INCR_PROCESSOR, dataMode));
+
+ assertEquals(val3, cache.get(k1));
+
+ RemoveAndReturnNullEntryProcessor c = new RemoveAndReturnNullEntryProcessor();
+
+ assertNull(cache.invoke(k1, c));
+ assertNull(cache.get(k1));
+
+ for (int i = 0; i < gridCount(); i++)
+ assertNull(jcache(i).localPeek(k1, ONHEAP));
+
+ final EntryProcessor<Object, Object, Object> errProcessor = new FailedEntryProcessor();
+
+ GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ cache.invoke(k1, errProcessor);
+
+ return null;
+ }
+ }, EntryProcessorException.class, "Test entry processor exception.");
+ }
+ });
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testPutx() throws Exception {
+ if (txShouldBeUsed())
+ checkPut(true);
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testPutxNoTx() throws Exception {
+ checkPut(false);
+ }
+
+ /**
+ * @param inTx Whether to start transaction.
+ * @throws Exception If failed.
+ */
+ private void checkPut(boolean inTx) throws Exception {
+ Transaction tx = inTx ? transactions().txStart() : null;
+
+ IgniteCache<String, Integer> cache = jcache();
+
+ try {
+ cache.put("key1", 1);
+ cache.put("key2", 2);
+
+ // Check inside transaction.
+ assert cache.get("key1") == 1;
+ assert cache.get("key2") == 2;
+
+ if (tx != null)
+ tx.commit();
+ }
+ finally {
+ if (tx != null)
+ tx.close();
+ }
+
+ checkSize(F.asSet("key1", "key2"));
+
+ // Check outside transaction.
+ checkContainsKey(true, "key1");
+ checkContainsKey(true, "key2");
+ checkContainsKey(false, "wrong");
+
+ assert cache.get("key1") == 1;
+ assert cache.get("key2") == 2;
+ assert cache.get("wrong") == null;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPutAsync() throws Exception {
+ Transaction tx = txShouldBeUsed() ? transactions().txStart() : null;
+
+ IgniteCache cacheAsync = jcache().withAsync();
+
+ try {
+ jcache().put("key2", 1);
+
+ cacheAsync.put("key1", 10);
+
+ IgniteFuture<?> fut1 = cacheAsync.future();
+
+ cacheAsync.put("key2", 11);
+
+ IgniteFuture<?> fut2 = cacheAsync.future();
+
+ IgniteFuture<Transaction> f = null;
+
+ if (tx != null) {
+ tx = (Transaction)tx.withAsync();
+
+ tx.commit();
+
+ f = tx.future();
+ }
+
+ assertNull(fut1.get());
+ assertNull(fut2.get());
+
+ assert f == null || f.get().state() == COMMITTED;
+ }
+ finally {
+ if (tx != null)
+ tx.close();
+ }
+
+ checkSize(F.asSet("key1", "key2"));
+
+ assert jcache().get("key1") == 10;
+ assert jcache().get("key2") == 11;
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testPutAll() throws Exception {
+ Map<String, Integer> map = F.asMap("key1", 1, "key2", 2);
+
+ IgniteCache<String, Integer> cache = jcache();
+
+ cache.putAll(map);
+
+ checkSize(F.asSet("key1", "key2"));
+
+ assert cache.get("key1") == 1;
+ assert cache.get("key2") == 2;
+
+ map.put("key1", 10);
+ map.put("key2", 20);
+
+ cache.putAll(map);
+
+ checkSize(F.asSet("key1", "key2"));
+
+ assert cache.get("key1") == 10;
+ assert cache.get("key2") == 20;
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testNullInTx() throws Exception {
+ if (!txShouldBeUsed())
+ return;
+
+ final IgniteCache<String, Integer> cache = jcache();
+
+ for (int i = 0; i < 100; i++) {
+ final String key = "key-" + i;
+
+ assertNull(cache.get(key));
+
+ GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ IgniteTransactions txs = transactions();
+
+ try (Transaction tx = txs.txStart()) {
+ cache.put(key, 1);
+
+ cache.put(null, 2);
+
+ tx.commit();
+ }
+
+ return null;
+ }
+ }, NullPointerException.class, null);
+
+ assertNull(cache.get(key));
+
+ cache.put(key, 1);
+
+ assertEquals(1, (int)cache.get(key));
+
+ GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ IgniteTransactions txs = transactions();
+
+ try (Transaction tx = txs.txStart()) {
+ cache.put(key, 2);
+
+ cache.remove(null);
+
+ tx.commit();
+ }
+
+ return null;
+ }
+ }, NullPointerException.class, null);
+
+ assertEquals(1, (int)cache.get(key));
+
+ cache.put(key, 2);
+
+ assertEquals(2, (int)cache.get(key));
+
+ GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ IgniteTransactions txs = transactions();
+
+ Map<String, Integer> map = new LinkedHashMap<>();
+
+ map.put("k1", 1);
+ map.put("k2", 2);
+ map.put(null, 3);
+
+ try (Transaction tx = txs.txStart()) {
+ cache.put(key, 1);
+
+ cache.putAll(map);
+
+ tx.commit();
+ }
+
+ return null;
+ }
+ }, NullPointerException.class, null);
+
+ assertNull(cache.get("k1"));
+ assertNull(cache.get("k2"));
+
+ assertEquals(2, (int)cache.get(key));
+
+ cache.put(key, 3);
+
+ assertEquals(3, (int)cache.get(key));
+ }
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testPutAllWithNulls() throws Exception {
+ final IgniteCache<String, Integer> cache = jcache();
+
+ {
+ final Map<String, Integer> m = new LinkedHashMap<>(2);
+
+ m.put("key1", 1);
+ m.put(null, 2);
+
+ GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ cache.putAll(m);
+
+ return null;
+ }
+ }, NullPointerException.class, null);
+
+ cache.put("key1", 1);
+
+ assertEquals(1, (int)cache.get("key1"));
+ }
+
+ {
+ final Map<String, Integer> m = new LinkedHashMap<>(2);
+
+ m.put("key3", 3);
+ m.put("key4", null);
+
+ GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ cache.putAll(m);
+
+ return null;
+ }
+ }, NullPointerException.class, null);
+
+ m.put("key4", 4);
+
+ cache.putAll(m);
+
+ assertEquals(3, (int)cache.get("key3"));
+ assertEquals(4, (int)cache.get("key4"));
+ }
+
+ assertThrows(log, new Callable<Object>() {
+ @Nullable @Override public Object call() throws Exception {
+ cache.put("key1", null);
+
+ return null;
+ }
+ }, NullPointerException.class, A.NULL_MSG_PREFIX);
+
+ assertThrows(log, new Callable<Object>() {
+ @Nullable @Override public Object call() throws Exception {
+ cache.getAndPut("key1", null);
+
+ return null;
+ }
+ }, NullPointerException.class, A.NULL_MSG_PREFIX);
+
+ assertThrows(log, new Callable<Object>() {
+ @Nullable @Override public Object call() throws Exception {
+ cache.put(null, 1);
+
+ return null;
+ }
+ }, NullPointerException.class, A.NULL_MSG_PREFIX);
+
+ assertThrows(log, new Callable<Object>() {
+ @Nullable @Override public Object call() throws Exception {
+ cache.replace(null, 1);
+
+ return null;
+ }
+ }, NullPointerException.class, A.NULL_MSG_PREFIX);
+
+ assertThrows(log, new Callable<Object>() {
+ @Nullable @Override public Object call() throws Exception {
+ cache.getAndReplace(null, 1);
+
+ return null;
+ }
+ }, NullPointerException.class, A.NULL_MSG_PREFIX);
+
+ assertThrows(log, new Callable<Object>() {
+ @Nullable @Override public Object call() throws Exception {
+ cache.replace("key", null);
+
+ return null;
+ }
+ }, NullPointerException.class, A.NULL_MSG_PREFIX);
+
+ assertThrows(log, new Callable<Object>() {
+ @Nullable @Override public Object call() throws Exception {
+ cache.getAndReplace("key", null);
+
+ return null;
+ }
+ }, NullPointerException.class, A.NULL_MSG_PREFIX);
+
+ assertThrows(log, new Callable<Object>() {
+ @Nullable @Override public Object call() throws Exception {
+ cache.replace(null, 1, 2);
+
+ return null;
+ }
+ }, NullPointerException.class, A.NULL_MSG_PREFIX);
+
+ assertThrows(log, new Callable<Object>() {
+ @Nullable @Override public Object call() throws Exception {
+ cache.replace("key", null, 2);
+
+ return null;
+ }
+ }, NullPointerException.class, A.NULL_MSG_PREFIX);
+
+ assertThrows(log, new Callable<Object>() {
+ @Nullable @Override public Object call() throws Exception {
+ cache.replace("key", 1, null);
+
+ return null;
+ }
+ }, NullPointerException.class, A.NULL_MSG_PREFIX);
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testPutAllAsync() throws Exception {
+ Map<String, Integer> map = F.asMap("key1", 1, "key2", 2);
+
+ IgniteCache<String, Integer> cache = jcache();
+
+ IgniteCache<String, Integer> cacheAsync = cache.withAsync();
+
+ cacheAsync.putAll(map);
+
+ IgniteFuture<?> f1 = cacheAsync.future();
+
+ map.put("key1", 10);
+ map.put("key2", 20);
+
+ cacheAsync.putAll(map);
+
+ IgniteFuture<?> f2 = cacheAsync.future();
+
+ assertNull(f2.get());
+ assertNull(f1.get());
+
+ checkSize(F.asSet("key1", "key2"));
+
+ assert cache.get("key1") == 10;
+ assert cache.get("key2") == 20;
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testGetAndPutIfAbsent() throws Exception {
+ Transaction tx = txShouldBeUsed() ? transactions().txStart() : null;
+
+ IgniteCache<String, Integer> cache = jcache();
+
+ try {
+ assert cache.getAndPutIfAbsent("key", 1) == null;
+
+ assert cache.get("key") != null;
+ assert cache.get("key") == 1;
+
+ assert cache.getAndPutIfAbsent("key", 2) != null;
+ assert cache.getAndPutIfAbsent("key", 2) == 1;
+
+ assert cache.get("key") != null;
+ assert cache.get("key") == 1;
+
+ if (tx != null)
+ tx.commit();
+ }
+ finally {
+ if (tx != null)
+ tx.close();
+ }
+
+ assert cache.getAndPutIfAbsent("key", 2) != null;
+
+ for (int i = 0; i < gridCount(); i++) {
+ info("Peek on node [i=" + i + ", id=" + grid(i).localNode().id() + ", val=" +
+ grid(i).cache(cacheName()).localPeek("key", ONHEAP) + ']');
+ }
+
+ assertEquals((Integer)1, cache.getAndPutIfAbsent("key", 2));
+
+ assert cache.get("key") != null;
+ assert cache.get("key") == 1;
+
+ if (!storeEnabled())
+ return;
+
+ // Check swap.
+ cache.put("key2", 1);
+
+ cache.localEvict(Collections.singleton("key2"));
+
+ if (!isLoadPreviousValue())
+ cache.get("key2");
+
+ assertEquals((Integer)1, cache.getAndPutIfAbsent("key2", 3));
+
+ // Check db.
+ if (storeEnabled() && isLoadPreviousValue() && !isMultiJvm()) {
+ putToStore("key3", 3);
+
+ assertEquals((Integer)3, cache.getAndPutIfAbsent("key3", 4));
+
+ assertEquals((Integer)3, cache.get("key3"));
+ }
+
+ assertEquals((Integer)1, cache.get("key2"));
+
+ cache.localEvict(Collections.singleton("key2"));
+
+ if (!isLoadPreviousValue())
+ cache.get("key2");
+
+ // Same checks inside tx.
+ tx = txShouldBeUsed() ? transactions().txStart() : null;
+
+ try {
+ assertEquals((Integer)1, cache.getAndPutIfAbsent("key2", 3));
+
+ if (tx != null)
+ tx.commit();
+
+ assertEquals((Integer)1, cache.get("key2"));
+ }
+ finally {
+ if (tx != null)
+ tx.close();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGetAndPutIfAbsentAsync() throws Exception {
+ Transaction tx = txShouldBeUsed() ? transactions().txStart() : null;
+
+ IgniteCache<String, Integer> cache = jcache();
+
+ IgniteCache<String, Integer> cacheAsync = cache.withAsync();
+
+ try {
+ cacheAsync.getAndPutIfAbsent("key", 1);
+
+ IgniteFuture<Integer> fut1 = cacheAsync.future();
+
+ assertNull(fut1.get());
+ assertEquals((Integer)1, cache.get("key"));
+
+ cacheAsync.getAndPutIfAbsent("key", 2);
+
+ IgniteFuture<Integer> fut2 = cacheAsync.future();
+
+ assertEquals((Integer)1, fut2.get());
+ assertEquals((Integer)1, cache.get("key"));
+
+ if (tx != null)
+ tx.commit();
+ }
+ finally {
+ if (tx != null)
+ tx.close();
+ }
+
+ if (!storeEnabled())
+ return;
+
+ // Check swap.
+ cache.put("key2", 1);
+
+ cache.localEvict(Collections.singleton("key2"));
+
+ if (!isLoadPreviousValue())
+ cache.get("key2");
+
+ cacheAsync.getAndPutIfAbsent("key2", 3);
+
+ assertEquals((Integer)1, cacheAsync.<Integer>future().get());
+
+ // Check db.
+ if (storeEnabled() && isLoadPreviousValue() && !isMultiJvm()) {
+ putToStore("key3", 3);
+
+ cacheAsync.getAndPutIfAbsent("key3", 4);
+
+ assertEquals((Integer)3, cacheAsync.<Integer>future().get());
+ }
+
+ cache.localEvict(Collections.singleton("key2"));
+
+ if (!isLoadPreviousValue())
+ cache.get("key2");
+
+ // Same checks inside tx.
+ tx = txShouldBeUsed() ? transactions().txStart() : null;
+
+ try {
+ cacheAsync.getAndPutIfAbsent("key2", 3);
+
+ assertEquals(1, cacheAsync.future().get());
+
+ if (tx != null)
+ tx.commit();
+
+ assertEquals((Integer)1, cache.get("key2"));
+ }
+ finally {
+ if (tx != null)
+ tx.close();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPutIfAbsent() throws Exception {
+ IgniteCache<String, Integer> cache = jcache();
+
+ assertNull(cache.get("key"));
+ assert cache.putIfAbsent("key", 1);
+ assert cache.get("key") != null && cache.get("key") == 1;
+ assert !cache.putIfAbsent("key", 2);
+ assert cache.get("key") != null && cache.get("key") == 1;
+
+ if (!storeEnabled())
+ return;
+
+ // Check swap.
+ cache.put("key2", 1);
+
+ cache.localEvict(Collections.singleton("key2"));
+
+ if (!isLoadPreviousValue())
+ cache.get("key2");
+
+ assertFalse(cache.putIfAbsent("key2", 3));
+
+ // Check db.
+ if (storeEnabled() && isLoadPreviousValue() && !isMultiJvm()) {
+ putToStore("key3", 3);
+
+ assertFalse(cache.putIfAbsent("key3", 4));
+ }
+
+ cache.localEvict(Collections.singleton("key2"));
+
+ if (!isLoadPreviousValue())
+ cache.get("key2");
+
+ // Same checks inside tx.
+ Transaction tx = txShouldBeUsed() ? transactions().txStart() : null;
+
+ try {
+ assertFalse(cache.putIfAbsent("key2", 3));
+
+ if (tx != null)
+ tx.commit();
+
+ assertEquals((Integer)1, cache.get("key2"));
+ }
+ finally {
+ if (tx != null)
+ tx.close();
+ }
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testPutxIfAbsentAsync() throws Exception {
+ if (txShouldBeUsed())
+ checkPutxIfAbsentAsync(true);
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testPutxIfAbsentAsyncNoTx() throws Exception {
+ checkPutxIfAbsentAsync(false);
+ }
+
+ /**
+ * @param inTx In tx flag.
+ * @throws Exception If failed.
+ */
+ private void checkPutxIfAbsentAsync(boolean inTx) throws Exception {
+ IgniteCache<String, Integer> cache = jcache();
+
+ IgniteCache<String, Integer> cacheAsync = cache.withAsync();
+
+ cacheAsync.putIfAbsent("key", 1);
+
+ IgniteFuture<Boolean> fut1 = cacheAsync.future();
+
+ assert fut1.get();
+ assert cache.get("key") != null && cache.get("key") == 1;
+
+ cacheAsync.putIfAbsent("key", 2);
+
+ IgniteFuture<Boolean> fut2 = cacheAsync.future();
+
+ assert !fut2.get();
+ assert cache.get("key") != null && cache.get("key") == 1;
+
+ if (!storeEnabled())
+ return;
+
+ // Check swap.
+ cache.put("key2", 1);
+
+ cache.localEvict(Collections.singleton("key2"));
+
+ if (!isLoadPreviousValue())
+ cache.get("key2");
+
+ cacheAsync.putIfAbsent("key2", 3);
+
+ assertFalse(cacheAsync.<Boolean>future().get());
+
+ // Check db.
+ if (storeEnabled() && isLoadPreviousValue() && !isMultiJvm()) {
+ putToStore("key3", 3);
+
+ cacheAsync.putIfAbsent("key3", 4);
+
+ assertFalse(cacheAsync.<Boolean>future().get());
+ }
+
+ cache.localEvict(Collections.singletonList("key2"));
+
+ if (!isLoadPreviousValue())
+ cache.get("key2");
+
+ // Same checks inside tx.
+ Transaction tx = inTx ? transactions().txStart() : null;
+
+ try {
+ cacheAsync.putIfAbsent("key2", 3);
+
+ assertFalse(cacheAsync.<Boolean>future().get());
+
+ if (storeEnabled() && isLoadPreviousValue() && !isMultiJvm()) {
+ cacheAsync.putIfAbsent("key3", 4);
+
+ assertFalse(cacheAsync.<Boolean>future().get());
+ }
+
+ if (tx != null)
+ tx.commit();
+ }
+ finally {
+ if (tx != null)
+ tx.close();
+ }
+
+ assertEquals((Integer)1, cache.get("key2"));
+
+ if (storeEnabled() && isLoadPreviousValue() && !isMultiJvm())
+ assertEquals((Integer)3, cache.get("key3"));
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testPutIfAbsentAsyncConcurrent() throws Exception {
+ IgniteCache cacheAsync = jcache().withAsync();
+
+ cacheAsync.putIfAbsent("key1", 1);
+
+ IgniteFuture<Boolean> fut1 = cacheAsync.future();
+
+ cacheAsync.putIfAbsent("key2", 2);
+
+ IgniteFuture<Boolean> fut2 = cacheAsync.future();
+
+ assert fut1.get();
+ assert fut2.get();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGetAndReplace() throws Exception {
+ IgniteCache<String, Integer> cache = jcache();
+
+ cache.put("key", 1);
+
+ assert cache.get("key") == 1;
+
+ info("key 1 -> 2");
+
+ assert cache.getAndReplace("key", 2) == 1;
+
+ assert cache.get("key") == 2;
+
+ assert cache.getAndReplace("wrong", 0) == null;
+
+ assert cache.get("wrong") == null;
+
+ info("key 0 -> 3");
+
+ assert !cache.replace("key", 0, 3);
+
+ assert cache.get("key") == 2;
+
+ info("key 0 -> 3");
+
+ assert !cache.replace("key", 0, 3);
+
+ assert cache.get("key") == 2;
+
+ info("key 2 -> 3");
+
+ assert cache.replace("key", 2, 3);
+
+ assert cache.get("key") == 3;
+
+ if (!storeEnabled())
+ return;
+
+ info("evict key");
+
+ cache.localEvict(Collections.singleton("key"));
+
+ info("key 3 -> 4");
+
+ if (!isLoadPreviousValue())
+ cache.get("key");
+
+ assert cache.replace("key", 3, 4);
+
+ assert cache.get("key") == 4;
+
+ if (storeEnabled() && isLoadPreviousValue() && !isMultiJvm()) {
+ putToStore("key2", 5);
+
+ info("key2 5 -> 6");
+
+ assert cache.replace("key2", 5, 6);
+ }
+
+ for (int i = 0; i < gridCount(); i++) {
+ info("Peek key on grid [i=" + i + ", nodeId=" + grid(i).localNode().id() +
+ ", peekVal=" + grid(i).cache(cacheName()).localPeek("key", ONHEAP) + ']');
+
+ info("Peek key2 on grid [i=" + i + ", nodeId=" + grid(i).localNode().id() +
+ ", peekVal=" + grid(i).cache(cacheName()).localPeek("key2", ONHEAP) + ']');
+ }
+
+ if (storeEnabled() && isLoadPreviousValue() && !isMultiJvm())
+ assertEquals((Integer)6, cache.get("key2"));
+
+ cache.localEvict(Collections.singleton("key"));
+
+ if (!isLoadPreviousValue())
+ cache.get("key");
+
+ Transaction tx = txShouldBeUsed() ? transactions().txStart() : null;
+
+ try {
+ assert cache.replace("key", 4, 5);
+
+ if (tx != null)
+ tx.commit();
+
+ assert cache.get("key") == 5;
+ }
+ finally {
+ if (tx != null)
+ tx.close();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testReplace() throws Exception {
+ IgniteCache<String, Integer> cache = jcache();
+
+ cache.put("key", 1);
+
+ assert cache.get("key") == 1;
+
+ assert cache.replace("key", 2);
+
+ assert cache.get("key") == 2;
+
+ assert !cache.replace("wrong", 2);
+
+ if (!storeEnabled())
+ return;
+
+ cache.localEvict(Collections.singleton("key"));
+
+ if (!isLoadPreviousValue())
+ assert cache.get("key") == 2;
+
+ assert cache.replace("key", 4);
+
+ assert cache.get("key") == 4;
+
+ if (storeEnabled() && isLoadPreviousValue() && !isMultiJvm()) {
+ putToStore("key2", 5);
+
+ cache.replace("key2", 6);
+
+ assertEquals((Integer)6, cache.get("key2"));
+ }
+
+ cache.localEvict(Collections.singleton("key"));
+
+ if (!isLoadPreviousValue())
+ assert cache.get("key") == 4;
+
+ Transaction tx = txShouldBeUsed() ? transactions().txStart() : null;
+
+ try {
+ assert cache.replace("key", 5);
+
+ if (tx != null)
+ tx.commit();
+ }
+ finally {
+ if (tx != null)
+ tx.close();
+ }
+
+ assert cache.get("key") == 5;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGetAndReplaceAsync() throws Exception {
+ IgniteCache<String, Integer> cache = jcache();
+
+ IgniteCache<String, Integer> cacheAsync = cache.withAsync();
+
+ cache.put("key", 1);
+
+ assert cache.get("key") == 1;
+
+ cacheAsync.getAndReplace("key", 2);
+
+ assert cacheAsync.<Integer>future().get() == 1;
+
+ assert cache.get("key") == 2;
+
+ cacheAsync.getAndReplace("wrong", 0);
+
+ assert cacheAsync.future().get() == null;
+
+ assert cache.get("wrong") == null;
+
+ cacheAsync.replace("key", 0, 3);
+
+ assert !cacheAsync.<Boolean>future().get();
+
+ assert cache.get("key") == 2;
+
+ cacheAsync.replace("key", 0, 3);
+
+ assert !cacheAsync.<Boolean>future().get();
+
+ assert cache.get("key") == 2;
+
+ cacheAsync.replace("key", 2, 3);
+
+ assert cacheAsync.<Boolean>future().get();
+
+ assert cache.get("key") == 3;
+
+ if (!storeEnabled())
+ return;
+
+ cache.localEvict(Collections.singleton("key"));
+
+ if (!isLoadPreviousValue())
+ cache.get("key");
+
+ cacheAsync.replace("key", 3, 4);
+
+ assert cacheAsync.<Boolean>future().get();
+
+ assert cache.get("key") == 4;
+
+ if (storeEnabled() && isLoadPreviousValue() && !isMultiJvm()) {
+ putToStore("key2", 5);
+
+ cacheAsync.replace("key2", 5, 6);
+
+ assert cacheAsync.<Boolean>future().get();
+
+ assertEquals((Integer)6, cache.get("key2"));
+ }
+
+ cache.localEvict(Collections.singleton("key"));
+
+ if (!isLoadPreviousValue())
+ cache.get("key");
+
+ Transaction tx = txShouldBeUsed() ? transactions().txStart() : null;
+
+ try {
+ cacheAsync.replace("key", 4, 5);
+
+ assert cacheAsync.<Boolean>future().get();
+
+ if (tx != null)
+ tx.commit();
+ }
+ finally {
+ if (tx != null)
+ tx.close();
+ }
+
+ assert cache.get("key") == 5;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testReplacexAsync() throws Exception {
+ IgniteCache<String, Integer> cache = jcache();
+
+ IgniteCache<String, Integer> cacheAsync = cache.withAsync();
+
+ cache.put("key", 1);
+
+ assert cache.get("key") == 1;
+
+ cacheAsync.replace("key", 2);
+
+ assert cacheAsync.<Boolean>future().get();
+
+ info("Finished replace.");
+
+ assertEquals((Integer)2, cache.get("key"));
+
+ cacheAsync.replace("wrond", 2);
+
+ assert !cacheAsync.<Boolean>future().get();
+
+ if (!storeEnabled())
+ return;
+
+ cache.localEvict(Collections.singleton("key"));
+
+ if (!isLoadPreviousValue())
+ cache.get("key");
+
+ cacheAsync.replace("key", 4);
+
+ assert cacheAsync.<Boolean>future().get();
+
+ assert cache.get("key") == 4;
+
+ if (storeEnabled() && isLoadPreviousValue() && !isMultiJvm()) {
+ putToStore("key2", 5);
+
+ cacheAsync.replace("key2", 6);
+
+ assert cacheAsync.<Boolean>future().get();
+
+ assert cache.get("key2") == 6;
+ }
+
+ cache.localEvict(Collections.singleton("key"));
+
+ if (!isLoadPreviousValue())
+ cache.get("key");
+
+ Transaction tx = txShouldBeUsed() ? transactions().txStart() : null;
+
+ try {
+ cacheAsync.replace("key", 5);
+
+ assert cacheAsync.<Boolean>future().get();
+
+ if (tx != null)
+ tx.commit();
+ }
+ finally {
+ if (tx != null)
+ tx.close();
+ }
+
+ assert cache.get("key") == 5;
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testGetAndRemove() throws Exception {
+ IgniteCache<String, Integer> cache = jcache();
+
+ cache.put("key1", 1);
+ cache.put("key2", 2);
+
+ assert !cache.remove("key1", 0);
+ assert cache.get("key1") != null && cache.get("key1") == 1;
+ assert cache.remove("key1", 1);
+ assert cache.get("key1") == null;
+ assert cache.getAndRemove("key2") == 2;
+ assert cache.get("key2") == null;
+ assert cache.getAndRemove("key2") == null;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGetAndRemoveObject() throws Exception {
+ IgniteCache<String, SerializableObject> cache = ignite(0).cache(cacheName());
+
+ SerializableObject val1 = new SerializableObject(1);
+ SerializableObject val2 = new SerializableObject(2);
+
+ cache.put("key1", val1);
+ cache.put("key2", val2);
+
+ assert !cache.remove("key1", new SerializableObject(0));
+
+ SerializableObject oldVal = cache.get("key1");
+
+ assert oldVal != null && F.eq(val1, oldVal);
+
+ assert cache.remove("key1");
+
+ assert cache.get("key1") == null;
+
+ SerializableObject oldVal2 = cache.getAndRemove("key2");
+
+ assert F.eq(val2, oldVal2);
+
+ assert cache.get("key2") == null;
+ assert cache.getAndRemove("key2") == null;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGetAndPutSerializableObject() throws Exception {
+ IgniteCache<String, SerializableObject> cache = ignite(0).cache(cacheName());
+
+ SerializableObject val1 = new SerializableObject(1);
+ SerializableObject val2 = new SerializableObject(2);
+
+ cache.put("key1", val1);
+
+ SerializableObject oldVal = cache.get("key1");
+
+ assertEquals(val1, oldVal);
+
+ oldVal = cache.getAndPut("key1", val2);
+
+ assertEquals(val1, oldVal);
+
+ SerializableObject updVal = cache.get("key1");
+
+ assertEquals(val2, updVal);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDeletedEntriesFlag() throws Exception {
+ if (cacheMode() != LOCAL && cacheMode() != REPLICATED && memoryMode() != OFFHEAP_TIERED) {
+ final int cnt = 3;
+
+ IgniteCache<String, Integer> cache = jcache();
+
+ for (int i = 0; i < cnt; i++)
+ cache.put(String.valueOf(i), i);
+
+ for (int i = 0; i < cnt; i++)
+ cache.remove(String.valueOf(i));
+
+ for (int g = 0; g < gridCount(); g++)
+ executeOnLocalOrRemoteJvm(g, new CheckEntriesDeletedTask(cnt, cacheName()));
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testRemoveLoad() throws Exception {
+ if (isMultiJvm())
+ fail("https://issues.apache.org/jira/browse/IGNITE-1088");
+
+ if (!storeEnabled())
+ return;
+
+ int cnt = 10;
+
+ Set<String> keys = new HashSet<>();
+
+ for (int i = 0; i < cnt; i++)
+ keys.add(String.valueOf(i));
+
+ jcache().removeAll(keys);
+
+ for (String key : keys)
+ putToStore(key, Integer.parseInt(key));
+
+ for (int g = 0; g < gridCount(); g++)
+ grid(g).cache(cacheName()).localLoadCache(null);
+
+ for (int g = 0; g < gridCount(); g++) {
+ for (int i = 0; i < cnt; i++) {
+ String key = String.valueOf(i);
+
+ if (grid(0).affinity(cacheName()).mapKeyToPrimaryAndBackups(key).contains(grid(g).localNode()))
+ assertEquals((Integer)i, peek(jcache(g), key));
+ else
+ assertNull(peek(jcache(g), key));
+ }
+ }
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testRemoveAsync() throws Exception {
+ IgniteCache<String, Integer> cache = jcache();
+
+ IgniteCache<String, Integer> cacheAsync = cache.withAsync();
+
+ cache.put("key1", 1);
+ cache.put("key2", 2);
+
+ cacheAsync.remove("key1", 0);
+
+ assert !cacheAsync.<Boolean>future().get();
+
+ assert cache.get("key1") != null && cache.get("key1") == 1;
+
+ cacheAsync.remove("key1", 1);
+
+ assert cacheAsync.<Boolean>future().get();
+
+ assert cache.get("key1") == null;
+
+ cacheAsync.getAndRemove("key2");
+
+ assert cacheAsync.<Integer>future().get() == 2;
+
+ assert cache.get("key2") == null;
+
+ cacheAsync.getAndRemove("key2");
+
+ assert cacheAsync.future().get() == null;
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testRemove() throws Exception {
+ IgniteCache<String, Integer> cache = jcache();
+
+ cache.put("key1", 1);
+
+ assert cache.remove("key1");
+ assert cache.get("key1") == null;
+ assert !cache.remove("key1");
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testRemovexAsync() throws Exception {
+ IgniteCache<String, Integer> cache = jcache();
+
+ IgniteCache<String, Integer> cacheAsync = cache.withAsync();
+
+ cache.put("key1", 1);
+
+ cacheAsync.remove("key1");
+
+ assert cacheAsync.<Boolean>future().get();
+
+ assert cache.get("key1") == null;
+
+ cacheAsync.remove("key1");
+
+ assert !cacheAsync.<Boolean>future().get();
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testGlobalRemoveAll() throws Exception {
+ globalRemoveAll(false);
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testGlobalRemoveAllAsync() throws Exception {
+ globalRemoveAll(true);
+ }
+
+ /**
+ * @param async If {@code true} uses asynchronous operation.
+ * @throws Exception In case of error.
+ */
+ private void globalRemoveAll(boolean async) throws Exception {
+ IgniteCache<String, Integer> cache = jcache();
+
+ cache.put("key1", 1);
+ cache.put("key2", 2);
+ cache.put("key3", 3);
+
+ checkSize(F.asSet("key1", "key2", "key3"));
+
+ atomicClockModeDelay(cache);
+
+ IgniteCache<String, Integer> asyncCache = cache.withAsync();
+
+ if (async) {
+ asyncCache.removeAll(F.asSet("key1", "key2"));
+
+ asyncCache.future().get();
+ }
+ else
+ cache.removeAll(F.asSet("key1", "key2"));
+
+ checkSize(F.asSet("key3"));
+
+ checkContainsKey(false, "key1");
+ checkContainsKey(false, "key2");
+ checkContainsKey(true, "key3");
+
+ // Put values again.
+ cache.put("key1", 1);
+ cache.put("key2", 2);
+ cache.put("key3", 3);
+
+ atomicClockModeDelay(cache);
+
+ if (async) {
+ IgniteCache asyncCache0 = jcache(gridCount() > 1 ? 1 : 0).withAsync();
+
+ asyncCache0.removeAll();
+
+ asyncCache0.future().get();
+ }
+ else
+ jcache(gridCount() > 1 ? 1 : 0).removeAll();
+
+ assertEquals(0, cache.localSize());
+ long entryCnt = hugeRemoveAllEntryCount();
+
+ for (int i = 0; i < entryCnt; i++)
+ cache.put(String.valueOf(i), i);
+
+ for (int i = 0; i < entryCnt; i++)
+ assertEquals(Integer.valueOf(i), cache.get(String.valueOf(i)));
+
+ atomicClockModeDelay(cache);
+
+ if (async) {
+ asyncCache.removeAll();
+
+ asyncCache.future().get();
+ }
+ else
+ cache.removeAll();
+
+ for (int i = 0; i < entryCnt; i++)
+ assertNull(cache.get(String.valueOf(i)));
+ }
+
+ /**
+ * @return Count of entries to be removed in removeAll() test.
+ */
+ protected long hugeRemoveAllEntryCount() {
+ return 1000L;
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testRemoveAllWithNulls() throws Exception {
+ final IgniteCache<String, Integer> cache = jcache();
+
+ final Set<String> c = new LinkedHashSet<>();
+
+ c.add("key1");
+ c.add(null);
+
+ GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ cache.removeAll(c);
+
+ return null;
+ }
+ }, NullPointerException.class, null);
+
+ assertEquals(0, jcache().localSize());
+
+ GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ cache.removeAll(null);
+
+ return null;
+ }
+ }, NullPointerException.class, null);
+
+ GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ cache.remove(null);
+
+ return null;
+ }
+ }, NullPointerException.class, null);
+
+ GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ cache.getAndRemove(null);
+
+ return null;
+ }
+ }, NullPointerException.class, null);
+
+ GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ cache.remove("key1", null);
+
+ return null;
+ }
+ }, NullPointerException.class, null);
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testRemoveAllDuplicates() throws Exception {
+ jcache().removeAll(ImmutableSet.of("key1", "key1", "key1"));
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testRemoveAllDuplicatesTx() throws Exception {
+ if (txShouldBeUsed()) {
+ try (Transaction tx = transactions().txStart()) {
+ jcache().removeAll(ImmutableSet.of("key1", "key1", "key1"));
+
+ tx.commit();
+ }
+ }
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testRemoveAllEmpty() throws Exception {
+ jcache().removeAll();
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testRemoveAllAsync() throws Exception {
+ IgniteCache<String, Integer> cache = jcache();
+
+ IgniteCache<String, Integer> cacheAsync = cache.withAsync();
+
+ cache.put("key1", 1);
+ cache.put("key2", 2);
+ cache.put("key3", 3);
+
+ checkSize(F.asSet("key1", "key2", "key3"));
+
+ cacheAsync.removeAll(F.asSet("key1", "key2"));
+
+ assertNull(cacheAsync.future().get());
+
+ checkSize(F.asSet("key3"));
+
+ checkContainsKey(false, "key1");
+ checkContainsKey(false, "key2");
+ checkContainsKey(true, "key3");
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
+ public void testLoadAll() throws Exception {
+ if (!storeEnabled())
+ return;
+
+ IgniteCache<String, Integer> cache = jcache();
+
+ Set<String> keys = new HashSet<>(primaryKeysForCache(2));
+
+ for (String key : keys)
+ assertNull(cache.localPeek(key, ONHEAP));
+
+ Map<String, Integer> vals = new HashMap<>();
+
+ int i = 0;
+
+ for (String key : keys) {
+ cache.put(key, i);
+
+ vals.put(key, i);
+
+ i++;
+ }
+
+ for (String key : keys)
+ assertEquals(vals.get(key), peek(cache, key));
+
+ cache.clear();
+
+ for (String key : keys)
+ assertNull(peek(cache, key));
+
+ loadAll(cache, keys, true);
+
+ for (String key : keys)
+ assertEquals(vals.get(key), peek(cache, key));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testRemoveAfterClear() throws Exception {
+ IgniteEx ignite = grid(0);
+
+ boolean affNode = ignite.context().cache().internalCache(cacheName()).context().affinityNode();
+
+ if (!affNode) {
+ if (gridCount() < 2)
+ return;
+
+ ignite = grid(1);
+ }
+
+ IgniteCache<Integer, Integer> cache = ignite.cache(cacheName());
+
+ int key = 0;
+
+ Collection<Integer> keys = new ArrayList<>();
+
+ for (int k = 0; k < 2; k++) {
+ while (!ignite.affinity(cacheName()).isPrimary(ignite.localNode(), key))
+ key++;
+
+ keys.add(key);
+
+ key++;
+ }
+
+ info("Keys: " + keys);
+
+ for (Integer k : keys)
+ cache.put(k, k);
+
+ cache.clear();
+
+ for (int g = 0; g < gridCount(); g++) {
+ Ignite
<TRUNCATED>
[05/20] ignite git commit: IGNITE-2455 - Create missing caches in
cache 'schema not found' exception is thrown
Posted by nt...@apache.org.
IGNITE-2455 - Create missing caches in cache 'schema not found' exception is thrown
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/affe6e74
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/affe6e74
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/affe6e74
Branch: refs/heads/ignite-1186
Commit: affe6e746652e9c76e527a279b7db51f0d55a70c
Parents: e970d56
Author: Valentin Kulichenko <va...@gmail.com>
Authored: Fri Feb 26 20:28:42 2016 -0800
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Fri Feb 26 20:28:42 2016 -0800
----------------------------------------------------------------------
.../processors/cache/GridCacheProcessor.java | 12 +++
.../processors/query/h2/IgniteH2Indexing.java | 104 +++++++++++--------
.../cache/CacheQueryNewClientSelfTest.java | 80 ++++++++++++++
.../IgniteCacheQuerySelfTestSuite.java | 6 +-
4 files changed, 158 insertions(+), 44 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/affe6e74/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index de85d03..a8f205b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -3309,6 +3309,18 @@ public class GridCacheProcessor extends GridProcessorAdapter {
}
/**
+ * Starts client caches that do not exist yet.
+ *
+ * @throws IgniteCheckedException In case of error.
+ */
+ public void createMissingCaches() throws IgniteCheckedException {
+ for (String cacheName : registeredCaches.keySet()) {
+ if (!CU.isSystemCache(cacheName) && !caches.containsKey(cacheName))
+ dynamicStartCache(null, cacheName, null, false, true, true).get();
+ }
+ }
+
+ /**
* Registers MBean for cache components.
*
* @param o Cache component.
http://git-wip-us.apache.org/repos/asf/ignite/blob/affe6e74/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index cae1a9f..a0e9c58 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -17,6 +17,42 @@
package org.apache.ignite.internal.processors.query.h2;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.math.BigDecimal;
+import java.sql.Connection;
+import java.sql.Date;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.sql.Types;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import javax.cache.Cache;
+import javax.cache.CacheException;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
@@ -81,6 +117,7 @@ import org.apache.ignite.spi.IgniteSpiCloseableIterator;
import org.apache.ignite.spi.indexing.IndexingQueryFilter;
import org.h2.api.JavaObjectSerializer;
import org.h2.command.CommandInterface;
+import org.h2.constant.ErrorCode;
import org.h2.constant.SysProperties;
import org.h2.index.Index;
import org.h2.index.SpatialIndex;
@@ -115,43 +152,6 @@ import org.h2.value.ValueUuid;
import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentHashMap8;
-import javax.cache.Cache;
-import javax.cache.CacheException;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.math.BigDecimal;
-import java.sql.Connection;
-import java.sql.Date;
-import java.sql.DriverManager;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.sql.Types;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
import static org.apache.ignite.IgniteSystemProperties.IGNITE_H2_DEBUG_CONSOLE;
import static org.apache.ignite.IgniteSystemProperties.getString;
import static org.apache.ignite.internal.processors.query.GridQueryIndexType.FULLTEXT;
@@ -1035,13 +1035,31 @@ public class IgniteH2Indexing implements GridQueryIndexing {
else {
PreparedStatement stmt;
- try {
- // Do not cache this statement because the whole two step query object will be cached later on.
- stmt = prepareStatement(c, sqlQry, false);
- }
- catch (SQLException e) {
- throw new CacheException("Failed to parse query: " + sqlQry, e);
+ boolean cachesCreated = false;
+
+ while (true) {
+ try {
+ // Do not cache this statement because the whole two step query object will be cached later on.
+ stmt = prepareStatement(c, sqlQry, false);
+
+ break;
+ }
+ catch (SQLException e) {
+ if (!cachesCreated && e.getErrorCode() == ErrorCode.SCHEMA_NOT_FOUND_1) {
+ try {
+ ctx.cache().createMissingCaches();
+ }
+ catch (IgniteCheckedException e1) {
+ throw new CacheException("Failed to create missing caches.", e);
+ }
+
+ cachesCreated = true;
+ }
+ else
+ throw new CacheException("Failed to parse query: " + sqlQry, e);
+ }
}
+
try {
try {
bindParameters(stmt, F.asList(qry.getArgs()));
http://git-wip-us.apache.org/repos/asf/ignite/blob/affe6e74/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheQueryNewClientSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheQueryNewClientSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheQueryNewClientSelfTest.java
new file mode 100644
index 0000000..020dddd
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheQueryNewClientSelfTest.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import java.util.List;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ * Test for the case when client is started after the cache is already created.
+ */
+public class CacheQueryNewClientSelfTest extends GridCommonAbstractTest {
+ /** */
+ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER));
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ stopAllGrids();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testQueryFromNewClient() throws Exception {
+ Ignite server = startGrid("server");
+
+ IgniteCache<Integer, Integer> cache1 = server.createCache(new CacheConfiguration<Integer, Integer>().
+ setName("cache1").setIndexedTypes(Integer.class, Integer.class));
+ IgniteCache<Integer, Integer> cache2 = server.createCache(new CacheConfiguration<Integer, Integer>().
+ setName("cache2").setIndexedTypes(Integer.class, Integer.class));
+
+ for (int i = 0; i < 10; i++) {
+ cache1.put(i, i);
+ cache2.put(i, i);
+ }
+
+ Ignition.setClientMode(true);
+
+ Ignite client = startGrid("client");
+
+ IgniteCache<Integer, Integer> cache = client.cache("cache1");
+
+ List<List<?>> res = cache.query(new SqlFieldsQuery(
+ "select i1._val, i2._val from Integer i1 cross join \"cache2\".Integer i2")).getAll();
+
+ assertEquals(100, res.size());
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/affe6e74/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
index 457ab9b..968dbf6 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
@@ -21,6 +21,7 @@ import junit.framework.TestSuite;
import org.apache.ignite.internal.processors.cache.CacheLocalQueryMetricsSelfTest;
import org.apache.ignite.internal.processors.cache.CachePartitionedQueryMetricsDistributedSelfTest;
import org.apache.ignite.internal.processors.cache.CachePartitionedQueryMetricsLocalSelfTest;
+import org.apache.ignite.internal.processors.cache.CacheQueryNewClientSelfTest;
import org.apache.ignite.internal.processors.cache.CacheQueryOffheapEvictDataLostTest;
import org.apache.ignite.internal.processors.cache.CacheReplicatedQueryMetricsDistributedSelfTest;
import org.apache.ignite.internal.processors.cache.CacheReplicatedQueryMetricsLocalSelfTest;
@@ -252,10 +253,13 @@ public class IgniteCacheQuerySelfTestSuite extends TestSuite {
suite.addTestSuite(CacheReplicatedQueryMetricsDistributedSelfTest.class);
suite.addTestSuite(CacheReplicatedQueryMetricsLocalSelfTest.class);
- //Unmarshallig query test.
+ // Unmarshalling query test.
suite.addTestSuite(IgniteCacheP2pUnmarshallingQueryErrorTest.class);
suite.addTestSuite(IgniteCacheNoClassQuerySelfTest.class);
+ // Other.
+ suite.addTestSuite(CacheQueryNewClientSelfTest.class);
+
return suite;
}
}
[16/20] ignite git commit: Added print partition stats.
Posted by nt...@apache.org.
Added print partition stats.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/071498f1
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/071498f1
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/071498f1
Branch: refs/heads/ignite-1186
Commit: 071498f10ab1857759bc3c180199b6c7efbce81a
Parents: 62c26d5
Author: nikolay_tikhonov <nt...@gridgain.com>
Authored: Mon Feb 29 22:20:15 2016 +0300
Committer: nikolay_tikhonov <nt...@gridgain.com>
Committed: Mon Feb 29 22:20:15 2016 +0300
----------------------------------------------------------------------
.../yardstick/IgniteBenchmarkArguments.java | 11 +++++
.../cache/IgniteCacheAbstractBenchmark.java | 52 ++++++++++++++++++++
2 files changed, 63 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/071498f1/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java
index 1ecfa0f..36551cc 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java
@@ -136,6 +136,17 @@ public class IgniteBenchmarkArguments {
@Parameter(names = {"-kpt", "--keysPerThread"}, description = "Use not intersecting keys in putAll benchmark")
private boolean keysPerThread;
+ /** */
+ @Parameter(names = {"-pp", "--printPartitionStats"}, description = "Print partition statistics")
+ private boolean printPartStats;
+
+ /**
+ * @return If {@code true} when need to print partition statistics.
+ */
+ public boolean printPartitionStatistics() {
+ return printPartStats;
+ }
+
/**
* @return JDBC url.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/071498f1/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java
index 3efa4a5..c9a4b9c 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java
@@ -17,9 +17,18 @@
package org.apache.ignite.yardstick.cache;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.affinity.Affinity;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.internal.util.typedef.T2;
+import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
import org.yardstickframework.BenchmarkConfiguration;
import org.yardstickframework.BenchmarkUtils;
@@ -42,6 +51,49 @@ public abstract class IgniteCacheAbstractBenchmark<K, V> extends IgniteAbstractB
super.setUp(cfg);
cache = cache();
+
+ if (args.printPartitionStatistics()) {
+ Map<ClusterNode, T2<List<Integer>, List<Integer>>> parts = new HashMap<>();
+
+ for (ClusterNode node : ignite().cluster().nodes())
+ parts.put(node,
+ new T2<List<Integer>, List<Integer>>(new ArrayList<Integer>(), new ArrayList<Integer>()));
+
+ U.sleep(5000);
+
+ Affinity<Object> aff = ignite().affinity(cache.getName());
+
+ for (int p = 0; p < aff.partitions(); p++) {
+ Collection<ClusterNode> nodes = aff.mapPartitionToPrimaryAndBackups(p);
+
+ boolean primary = true;
+
+ for (ClusterNode node : nodes) {
+ if (primary) {
+ parts.get(node).get1().add(p);
+
+ primary = false;
+ }
+ else
+ parts.get(node).get2().add(p);
+ }
+ }
+
+ BenchmarkUtils.println(cfg, "Partition stats. [cacheName: "+ cache.getName() +", topVer: "
+ + ignite().cluster().topologyVersion() + "]");
+ BenchmarkUtils.println(cfg, "(Node id, Number of Primary, Percent, Number of Backup, Percent, Total, Percent)");
+
+ for (Map.Entry<ClusterNode, T2<List<Integer>, List<Integer>>> e : parts.entrySet()) {
+ List<Integer> primary = e.getValue().get1();
+ List<Integer> backup = e.getValue().get2();
+
+ BenchmarkUtils.println(cfg, e.getKey().id() + " " + primary.size() + " " + primary.size() * 1. /
+ aff.partitions() + " " + backup.size() + " "
+ + backup.size() * 1. / (aff.partitions() * args.backups() == 0 ? 1 : args.backups())
+ + (primary.size() + backup.size() * 1.) / (aff.partitions() * args.backups() + aff.partitions())
+ );
+ }
+ }
}
/**
[19/20] ignite git commit: IGNITE-1186 Added P2P tests.
Posted by nt...@apache.org.
IGNITE-1186 Added P2P tests.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/5455a9fe
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/5455a9fe
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/5455a9fe
Branch: refs/heads/ignite-1186
Commit: 5455a9feeeb95841bb4a1a8a0ca70972586c2711
Parents: 9ad476b
Author: nikolay_tikhonov <nt...@gridgain.com>
Authored: Tue Mar 1 13:38:11 2016 +0300
Committer: nikolay_tikhonov <nt...@gridgain.com>
Committed: Tue Mar 1 13:41:33 2016 +0300
----------------------------------------------------------------------
.../CacheContinuousQueryHandlerV2.java | 50 ++++++-
.../continuous/CacheContinuousQueryManager.java | 63 ++++-----
.../IgniteCacheEntryListenerAbstractTest.java | 6 +-
.../CacheContinuousQueryOperationP2PTest.java | 130 +++++--------------
.../IgniteCacheQuerySelfTestSuite.java | 4 +
5 files changed, 107 insertions(+), 146 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/5455a9fe/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandlerV2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandlerV2.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandlerV2.java
index 628e1c3..6fc2041 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandlerV2.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandlerV2.java
@@ -27,12 +27,11 @@ import javax.cache.event.CacheEntryEventFilter;
import javax.cache.event.CacheEntryUpdatedListener;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.GridKernalContext;
-import org.apache.ignite.internal.IgniteDeploymentCheckedException;
-import org.apache.ignite.internal.managers.deployment.GridDeployment;
-import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryManager.JCacheRemoteQueryFactory;
+import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryManager.JCacheQueryRemoteFilter;
import org.apache.ignite.internal.processors.continuous.GridContinuousHandler;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.jetbrains.annotations.Nullable;
/**
* Continuous query handler V2 version. Contains {@link Factory} for remote listener.
@@ -47,6 +46,9 @@ public class CacheContinuousQueryHandlerV2<K, V> extends CacheContinuousQueryHan
/** Deployable object for filter factory. */
private DeployableObject rmtFilterFactoryDep;
+ /** Event types for JCache API. */
+ private byte types = 0;
+
/** */
protected transient CacheEntryEventFilter filter;
@@ -73,6 +75,7 @@ public class CacheContinuousQueryHandlerV2<K, V> extends CacheContinuousQueryHan
* @param taskHash Task name hash code.
* @param locCache {@code True} if local cache.
* @param keepBinary Keep binary flag.
+ * @param types Event types.
*/
public CacheContinuousQueryHandlerV2(
String cacheName,
@@ -88,7 +91,8 @@ public class CacheContinuousQueryHandlerV2<K, V> extends CacheContinuousQueryHan
boolean skipPrimaryCheck,
boolean locCache,
boolean keepBinary,
- boolean ignoreClsNotFound) {
+ boolean ignoreClsNotFound,
+ @Nullable Byte types) {
super(cacheName,
topic,
locLsnr,
@@ -107,6 +111,9 @@ public class CacheContinuousQueryHandlerV2<K, V> extends CacheContinuousQueryHan
assert rmtFilterFactory != null;
this.rmtFilterFactory = rmtFilterFactory;
+
+ if (types != null)
+ this.types = types;
}
/** {@inheritDoc} */
@@ -114,6 +121,9 @@ public class CacheContinuousQueryHandlerV2<K, V> extends CacheContinuousQueryHan
if (filter == null) {
assert rmtFilterFactory != null;
+ if (types != 0)
+ rmtFilterFactory = new JCacheRemoteQueryFactory(rmtFilterFactory, types);
+
filter = rmtFilterFactory.create();
}
@@ -158,6 +168,8 @@ public class CacheContinuousQueryHandlerV2<K, V> extends CacheContinuousQueryHan
out.writeObject(rmtFilterFactoryDep);
else
out.writeObject(rmtFilterFactory);
+
+ out.writeByte(types);
}
/** {@inheritDoc} */
@@ -171,5 +183,35 @@ public class CacheContinuousQueryHandlerV2<K, V> extends CacheContinuousQueryHan
rmtFilterFactoryDep = (DeployableObject)in.readObject();
else
rmtFilterFactory = (Factory)in.readObject();
+
+ types = in.readByte();
+ }
+
+ /**
+ *
+ */
+ private static class JCacheRemoteQueryFactory implements Factory<CacheEntryEventFilter> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Factory. */
+ protected Factory<? extends CacheEntryEventFilter> impl;
+
+ /** */
+ private byte types;
+
+ /**
+ * @param impl Factory.
+ * @param types Types.
+ */
+ public JCacheRemoteQueryFactory(@Nullable Factory<? extends CacheEntryEventFilter> impl, byte types) {
+ this.impl = impl;
+ this.types = types;
+ }
+
+ /** {@inheritDoc} */
+ @Override public JCacheQueryRemoteFilter create() {
+ return new JCacheQueryRemoteFilter(impl != null ? impl.create() : null, types);
+ }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5455a9fe/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
index 33d6d59..2a05865 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
@@ -621,6 +621,7 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
/**
* @param locLsnr Local listener.
+ * @param types JCache event types.
* @param bufSize Buffer size.
* @param timeInterval Time interval.
* @param autoUnsubscribe Auto unsubscribe flag.
@@ -634,7 +635,8 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
* @throws IgniteCheckedException In case of error.
*/
private UUID executeJCacheQueryFactory(CacheEntryUpdatedListener locLsnr,
- final JCacheRemoteQueryFactory rmtFilterFactory,
+ final Factory<CacheEntryEventFilter> rmtFilterFactory,
+ byte types,
int bufSize,
long timeInterval,
boolean autoUnsubscribe,
@@ -647,6 +649,8 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
final boolean keepBinary,
boolean ignoreClassNotFound) throws IgniteCheckedException
{
+ assert types != 0 : types;
+
cctx.checkSecurity(SecurityPermission.CACHE_READ);
int taskNameHash = !internal && cctx.kernalContext().security().enabled() ?
@@ -654,7 +658,7 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
boolean skipPrimaryCheck = loc && cctx.config().getCacheMode() == CacheMode.REPLICATED && cctx.affinityNode();
- boolean v2 = useV2Protocol(cctx.discovery().allNodes());
+ boolean v2 = rmtFilterFactory != null && useV2Protocol(cctx.discovery().allNodes());
GridContinuousHandler hnd;
@@ -673,23 +677,28 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
skipPrimaryCheck,
cctx.isLocal(),
keepBinary,
- ignoreClassNotFound);
+ ignoreClassNotFound,
+ types);
else {
- JCacheQueryRemoteFilter fltr = null;
+ JCacheQueryRemoteFilter jCacheFilter;
+
+ CacheEntryEventFilter filter = null;
if (rmtFilterFactory != null) {
- fltr = rmtFilterFactory.create();
+ filter = rmtFilterFactory.create();
- if (!(fltr.impl instanceof Serializable))
+ if (!(filter instanceof Serializable))
throw new IgniteCheckedException("Topology has nodes of the old versions. In this case " +
- "EntryEventFilter must implement java.io.Serializable interface. Filter: " + fltr.impl);
+ "EntryEventFilter must implement java.io.Serializable interface. Filter: " + filter);
}
+ jCacheFilter = new JCacheQueryRemoteFilter(filter, types);
+
hnd = new CacheContinuousQueryHandler(
cctx.name(),
TOPIC_CACHE.topic(topicPrefix, cctx.localNodeId(), seq.getAndIncrement()),
locLsnr,
- fltr,
+ jCacheFilter,
internal,
notifyExisting,
oldValRequired,
@@ -766,7 +775,8 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
skipPrimaryCheck,
cctx.isLocal(),
keepBinary,
- ignoreClassNotFound);
+ ignoreClassNotFound,
+ (byte)0);
else {
CacheEntryEventFilter fltr = null;
@@ -1025,7 +1035,8 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
routineId = executeJCacheQueryFactory(
locLsnr,
- new JCacheRemoteQueryFactory(cfg.getCacheEntryEventFilterFactory(), types),
+ cfg.getCacheEntryEventFilterFactory(),
+ types,
ContinuousQuery.DFLT_PAGE_SIZE,
ContinuousQuery.DFLT_TIME_INTERVAL,
ContinuousQuery.DFLT_AUTO_UNSUBSCRIBE,
@@ -1139,7 +1150,7 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
/**
* For handler version 2.0 this filter should not be serialized.
*/
- private static class JCacheQueryRemoteFilter implements CacheEntryEventSerializableFilter, Externalizable {
+ protected static class JCacheQueryRemoteFilter implements CacheEntryEventSerializableFilter, Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -1164,7 +1175,7 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
* @param impl Filter.
* @param types Types.
*/
- JCacheQueryRemoteFilter(CacheEntryEventFilter impl, byte types) {
+ JCacheQueryRemoteFilter(@Nullable CacheEntryEventFilter impl, byte types) {
assert types != 0;
this.impl = impl;
@@ -1221,34 +1232,6 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
}
/**
- *
- */
- protected static class JCacheRemoteQueryFactory implements Factory<CacheEntryEventFilter> {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Factory. */
- protected Factory<CacheEntryEventFilter> impl;
-
- /** */
- private byte types;
-
- /**
- * @param impl Factory.
- * @param types Types.
- */
- public JCacheRemoteQueryFactory(@Nullable Factory<CacheEntryEventFilter> impl, byte types) {
- this.impl = impl;
- this.types = types;
- }
-
- /** {@inheritDoc} */
- @Override public JCacheQueryRemoteFilter create() {
- return new JCacheQueryRemoteFilter(impl != null ? impl.create() : null, types);
- }
- }
-
- /**
* Task flash backup queue.
*/
private static final class BackupCleaner implements Runnable {
http://git-wip-us.apache.org/repos/asf/ignite/blob/5455a9fe/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java
index e61127d..43ca283 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java
@@ -539,16 +539,16 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
/**
* @throws Exception If failed.
*/
- public void _testEventsObjectKeyValue() throws Exception {
+ public void testEventsObjectKeyValue() throws Exception {
useObjects = true;
- _testEvents();
+ testEvents();
}
/**
* @throws Exception If failed.
*/
- public void _testEvents() throws Exception {
+ public void testEvents() throws Exception {
IgniteCache<Object, Object> cache = jcache();
Map<Object, Object> vals = new HashMap<>();
http://git-wip-us.apache.org/repos/asf/ignite/blob/5455a9fe/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 ff8d0a7..97f9e0e 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
@@ -17,28 +17,25 @@
package org.apache.ignite.internal.processors.cache.query.continuous;
-import java.io.Serializable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;
import javax.cache.configuration.Factory;
import javax.cache.configuration.FactoryBuilder;
import javax.cache.configuration.MutableCacheEntryListenerConfiguration;
+import javax.cache.event.CacheEntryCreatedListener;
import javax.cache.event.CacheEntryEvent;
import javax.cache.event.CacheEntryEventFilter;
-import javax.cache.event.CacheEntryListener;
import javax.cache.event.CacheEntryListenerException;
import javax.cache.event.CacheEntryUpdatedListener;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.cache.CacheAtomicityMode;
-import org.apache.ignite.cache.CacheEntryEventSerializableFilter;
import org.apache.ignite.cache.CacheMemoryMode;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.query.ContinuousQuery;
import org.apache.ignite.cache.query.QueryCursor;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
@@ -63,15 +60,6 @@ public class CacheContinuousQueryOperationP2PTest extends GridCommonAbstractTest
private static final int NODES = 5;
/** */
- private static final int KEYS = 50;
-
- /** */
- private static final int VALS = 10;
-
- /** */
- public static final int ITERATION_CNT = 100;
-
- /** */
private boolean client;
/** {@inheritDoc} */
@@ -87,8 +75,15 @@ public class CacheContinuousQueryOperationP2PTest extends GridCommonAbstractTest
}
/** {@inheritDoc} */
- @Override protected void beforeTestsStarted() throws Exception {
- super.beforeTestsStarted();
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+
+ super.afterTestsStopped();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ super.beforeTest();
startGridsMultiThreaded(NODES - 1);
@@ -98,10 +93,10 @@ public class CacheContinuousQueryOperationP2PTest extends GridCommonAbstractTest
}
/** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
- stopAllGrids();
+ @Override protected void afterTest() throws Exception {
+ super.afterTest();
- super.afterTestsStopped();
+ stopAllGrids();
}
/**
@@ -228,11 +223,14 @@ public class CacheContinuousQueryOperationP2PTest extends GridCommonAbstractTest
ContinuousQuery<Integer, Integer> qry = new ContinuousQuery<>();
- CacheEntryUpdatedListener<Integer, Integer> localLsnr = new CacheEntryUpdatedListener<Integer, Integer>() {
- @Override public void onUpdated(Iterable<CacheEntryEvent<? extends Integer,
- ? extends Integer>> evts) throws CacheEntryListenerException {
- for (CacheEntryEvent<? extends Integer, ? extends Integer> evt : evts)
+ TestLocalListener localLsnr = new TestLocalListener() {
+ @Override public void onEvent(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>> evts)
+ throws CacheEntryListenerException {
+ for (CacheEntryEvent<? extends Integer, ? extends Integer> evt : evts) {
latch.countDown();
+
+ log.info("Received event: " + evt);
+ }
}
};
@@ -258,7 +256,7 @@ public class CacheContinuousQueryOperationP2PTest extends GridCommonAbstractTest
else
cache = grid(rnd.nextInt(NODES - 1)).cache(ccfg.getName());
- //cur = cache.query(qry);
+ cur = cache.query(qry);
cache.registerCacheEntryListener(lsnrCfg);
@@ -306,89 +304,23 @@ public class CacheContinuousQueryOperationP2PTest extends GridCommonAbstractTest
/**
*
*/
- public static class QueryTestKey implements Serializable, Comparable {
- /** */
- private final Integer key;
-
- /**
- * @param key Key.
- */
- public QueryTestKey(Integer key) {
- this.key = key;
- }
-
+ private static abstract class TestLocalListener implements CacheEntryUpdatedListener<Integer, Integer>,
+ CacheEntryCreatedListener<Integer, Integer> {
/** {@inheritDoc} */
- @Override public boolean equals(Object o) {
- if (this == o)
- return true;
-
- if (o == null || getClass() != o.getClass())
- return false;
-
- QueryTestKey that = (QueryTestKey)o;
-
- return key.equals(that.key);
+ @Override public void onCreated(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>> evts)
+ throws CacheEntryListenerException {
+ onEvent(evts);
}
/** {@inheritDoc} */
- @Override public int hashCode() {
- return key.hashCode();
+ @Override public void onUpdated(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>> evts)
+ throws CacheEntryListenerException {
+ onEvent(evts);
}
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(QueryTestKey.class, this);
- }
-
- /** {@inheritDoc} */
- @Override public int compareTo(Object o) {
- return key - ((QueryTestKey)o).key;
- }
- }
-
- /**
- *
- */
- public static class QueryTestValue implements Serializable {
- /** */
- protected final Integer val1;
-
- /** */
- protected final String val2;
-
/**
- * @param val Value.
+ * @param evts Events.
*/
- public QueryTestValue(Integer val) {
- this.val1 = val;
- this.val2 = String.valueOf(val);
- }
-
- /** {@inheritDoc} */
- @Override public boolean equals(Object o) {
- if (this == o)
- return true;
-
- if (o == null || getClass() != o.getClass())
- return false;
-
- QueryTestValue that = (QueryTestValue) o;
-
- return val1.equals(that.val1) && val2.equals(that.val2);
- }
-
- /** {@inheritDoc} */
- @Override public int hashCode() {
- int res = val1.hashCode();
-
- res = 31 * res + val2.hashCode();
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(QueryTestValue.class, this);
- }
+ protected abstract void onEvent(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>> evts);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5455a9fe/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
index 457ab9b..5df10a7 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
@@ -78,12 +78,14 @@ import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinu
import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryCounterReplicatedTxTest;
import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousBatchAckTest;
import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousBatchForceServerModeAckTest;
+import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFactoryFilterTest;
import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFailoverAtomicPrimaryWriteOrderOffheapTieredTest;
import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFailoverAtomicPrimaryWriteOrderSelfTest;
import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFailoverAtomicReplicatedSelfTest;
import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFailoverTxOffheapTieredTest;
import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFailoverTxReplicatedSelfTest;
import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFailoverTxSelfTest;
+import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryOperationP2PTest;
import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryRandomOperationsTest;
import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryAtomicNearEnabledSelfTest;
import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryAtomicOffheapTieredTest;
@@ -224,6 +226,8 @@ public class IgniteCacheQuerySelfTestSuite extends TestSuite {
suite.addTestSuite(CacheContinuousQueryFailoverAtomicPrimaryWriteOrderOffheapTieredTest.class);
suite.addTestSuite(CacheContinuousQueryFailoverTxOffheapTieredTest.class);
suite.addTestSuite(CacheContinuousQueryRandomOperationsTest.class);
+ suite.addTestSuite(CacheContinuousQueryFactoryFilterTest.class);
+ suite.addTestSuite(CacheContinuousQueryOperationP2PTest.class);
suite.addTestSuite(CacheContinuousBatchAckTest.class);
suite.addTestSuite(CacheContinuousBatchForceServerModeAckTest.class);
[09/20] ignite git commit: ignite-2521: Configuration variations
tests framework + IgniteCacheBasicConfigVariationsFullApiTestSuite +
ignite-2554: Fixed Affinity.mapKeyToNode() for dynamically started LOCAL
cache
Posted by nt...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/953b575f/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteCacheConfigVariationsAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteCacheConfigVariationsAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteCacheConfigVariationsAbstractTest.java
new file mode 100644
index 0000000..28c6f55
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteCacheConfigVariationsAbstractTest.java
@@ -0,0 +1,583 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.testframework.junits;
+
+import java.util.Map;
+import javax.cache.Cache;
+import javax.cache.configuration.Factory;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteTransactions;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMemoryMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.CachePeekMode;
+import org.apache.ignite.cache.store.CacheStore;
+import org.apache.ignite.cache.store.CacheStoreAdapter;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.NearCacheConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
+import org.apache.ignite.internal.processors.cache.GridCacheContext;
+import org.apache.ignite.internal.util.lang.GridAbsPredicateX;
+import org.apache.ignite.internal.util.typedef.X;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteBiInClosure;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.configvariations.CacheStartMode;
+import org.apache.ignite.transactions.Transaction;
+import org.jetbrains.annotations.Nullable;
+import org.jsr166.ConcurrentHashMap8;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheMemoryMode.OFFHEAP_TIERED;
+import static org.apache.ignite.cache.CacheMemoryMode.ONHEAP_TIERED;
+
+/**
+ * Abstract class for cache configuration variations tests.
+ */
+public abstract class IgniteCacheConfigVariationsAbstractTest extends IgniteConfigVariationsAbstractTest {
+ /** */
+ protected static final int CLIENT_NEAR_ONLY_IDX = 2;
+
+ /** Test timeout. */
+ private static final long TEST_TIMEOUT = 30 * 1000;
+
+ /** Store map. */
+ protected static final Map<Object, Object> map = new ConcurrentHashMap8<>();
+
+ /** {@inheritDoc} */
+ @Override protected long getTestTimeout() {
+ return TEST_TIMEOUT;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected final void beforeTestsStarted() throws Exception {
+ assert testsCfg != null;
+ assert !testsCfg.withClients() || testsCfg.gridCount() >= 3;
+
+ assert testsCfg.testedNodeIndex() >= 0 : "testedNodeIdx: " + testedNodeIdx;
+
+ testedNodeIdx = testsCfg.testedNodeIndex();
+
+ if (testsCfg.isStartCache()) {
+ final CacheStartMode cacheStartMode = testsCfg.cacheStartMode();
+ final int cnt = testsCfg.gridCount();
+
+ if (cacheStartMode == CacheStartMode.STATIC) {
+ info("All nodes will be stopped, new " + cnt + " nodes will be started.");
+
+ Ignition.stopAll(true);
+
+ for (int i = 0; i < cnt; i++) {
+ String gridName = getTestGridName(i);
+
+ IgniteConfiguration cfg = optimize(getConfiguration(gridName));
+
+ if (i != CLIENT_NODE_IDX && i != CLIENT_NEAR_ONLY_IDX) {
+ CacheConfiguration cc = testsCfg.configurationFactory().cacheConfiguration(gridName);
+
+ cc.setName(cacheName());
+
+ cfg.setCacheConfiguration(cc);
+ }
+
+ startGrid(gridName, cfg, null);
+ }
+
+ if (testsCfg.withClients() && testsCfg.gridCount() > CLIENT_NEAR_ONLY_IDX)
+ grid(CLIENT_NEAR_ONLY_IDX).createNearCache(cacheName(), new NearCacheConfiguration());
+ }
+ else if (cacheStartMode == null || cacheStartMode == CacheStartMode.DYNAMIC) {
+ super.beforeTestsStarted();
+
+ startCachesDinamically();
+ }
+ else
+ throw new IllegalArgumentException("Unknown cache start mode: " + cacheStartMode);
+ }
+
+ if (testsCfg.gridCount() > 1)
+ checkTopology(testsCfg.gridCount());
+
+ awaitPartitionMapExchange();
+
+ for (int i = 0; i < gridCount(); i++)
+ info("Grid " + i + ": " + grid(i).localNode().id());
+
+ if (testsCfg.withClients()) {
+ boolean testedNodeNearEnabled = grid(testedNodeIdx).cachex(cacheName()).context().isNear();
+
+ if (testedNodeIdx != SERVER_NODE_IDX)
+ assertEquals(testedNodeIdx == CLIENT_NEAR_ONLY_IDX, testedNodeNearEnabled);
+
+ info(">>> Starting set of tests [testedNodeIdx=" + testedNodeIdx
+ + ", id=" + grid(testedNodeIdx).localNode().id()
+ + ", isClient=" + grid(testedNodeIdx).configuration().isClientMode()
+ + ", nearEnabled=" + testedNodeNearEnabled + "]");
+ }
+ }
+
+ /**
+ * Starts caches dinamically.
+ */
+ private void startCachesDinamically() throws Exception {
+ for (int i = 0; i < gridCount(); i++) {
+ info("Starting cache dinamically on grid: " + i);
+
+ IgniteEx grid = grid(i);
+
+ if (i != CLIENT_NODE_IDX && i != CLIENT_NEAR_ONLY_IDX) {
+ CacheConfiguration cc = testsCfg.configurationFactory().cacheConfiguration(grid.name());
+
+ cc.setName(cacheName());
+
+ grid.getOrCreateCache(cc);
+ }
+
+ if (testsCfg.withClients() && i == CLIENT_NEAR_ONLY_IDX)
+ grid(CLIENT_NEAR_ONLY_IDX).createNearCache(cacheName(), new NearCacheConfiguration());
+ }
+
+ awaitPartitionMapExchange();
+
+ for (int i = 0; i < gridCount(); i++)
+ assertNotNull(jcache(i));
+
+ for (int i = 0; i < gridCount(); i++)
+ assertEquals("Cache is not empty [idx=" + i + ", entrySet=" + jcache(i).localEntries() + ']',
+ 0, jcache(i).localSize(CachePeekMode.ALL));
+ }
+
+ /** {@inheritDoc} */
+ @Override protected boolean expectedClient(String testGridName) {
+ return getTestGridName(CLIENT_NODE_IDX).equals(testGridName)
+ || getTestGridName(CLIENT_NEAR_ONLY_IDX).equals(testGridName);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ if (testsCfg.isStopCache()) {
+ for (int i = 0; i < gridCount(); i++) {
+ info("Destroing cache on grid: " + i);
+
+ IgniteCache<String, Integer> cache = jcache(i);
+
+ assert i != 0 || cache != null;
+
+ if (cache != null)
+ cache.destroy();
+ }
+ }
+
+ map.clear();
+
+ super.afterTestsStopped();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ super.beforeTest();
+
+ awaitPartitionMapExchange();
+
+ assert jcache().unwrap(Ignite.class).transactions().tx() == null;
+
+ assertEquals(0, jcache().localSize());
+ assertEquals(0, jcache().size());
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ Transaction tx = jcache().unwrap(Ignite.class).transactions().tx();
+
+ if (tx != null) {
+ tx.close();
+
+ fail("Cache transaction remained after test completion: " + tx);
+ }
+
+ String cacheIsNotEmptyMsg = null;
+
+ for (int i = 0; i < gridCount(); i++) {
+ info("Checking grid: " + i);
+
+ while (true) {
+ try {
+ final int fi = i;
+
+ boolean cacheIsEmpty = GridTestUtils.waitForCondition(
+ // Preloading may happen as nodes leave, so we need to wait.
+ new GridAbsPredicateX() {
+ @Override public boolean applyx() throws IgniteCheckedException {
+ jcache(fi).removeAll();
+
+ if (jcache(fi).size(CachePeekMode.ALL) > 0) {
+ for (Cache.Entry<?, ?> k : jcache(fi).localEntries())
+ jcache(fi).remove(k.getKey());
+ }
+
+ int locSize = jcache(fi).localSize(CachePeekMode.ALL);
+
+ if (locSize != 0) {
+ info(">>>>> Debug localSize for grid: " + fi + " is " + locSize);
+ info(">>>>> Debug ONHEAP localSize for grid: " + fi + " is "
+ + jcache(fi).localSize(CachePeekMode.ONHEAP));
+ info(">>>>> Debug OFFHEAP localSize for grid: " + fi + " is "
+ + jcache(fi).localSize(CachePeekMode.OFFHEAP));
+ info(">>>>> Debug PRIMARY localSize for grid: " + fi + " is "
+ + jcache(fi).localSize(CachePeekMode.PRIMARY));
+ info(">>>>> Debug BACKUP localSize for grid: " + fi + " is "
+ + jcache(fi).localSize(CachePeekMode.BACKUP));
+ info(">>>>> Debug NEAR localSize for grid: " + fi + " is "
+ + jcache(fi).localSize(CachePeekMode.NEAR));
+ info(">>>>> Debug SWAP localSize for grid: " + fi + " is "
+ + jcache(fi).localSize(CachePeekMode.SWAP));
+ }
+
+ return locSize == 0;
+ }
+ }, 10_000);
+
+ if (cacheIsEmpty)
+ assertTrue("Cache is not empty: " + " localSize = " + jcache(fi).localSize(CachePeekMode.ALL)
+ + ", local entries " + entrySet(jcache(fi).localEntries()), cacheIsEmpty);
+
+ int primaryKeySize = jcache(i).localSize(CachePeekMode.PRIMARY);
+ int keySize = jcache(i).localSize();
+ int size = jcache(i).localSize();
+ int globalSize = jcache(i).size();
+ int globalPrimarySize = jcache(i).size(CachePeekMode.PRIMARY);
+
+ info("Size after [idx=" + i +
+ ", size=" + size +
+ ", keySize=" + keySize +
+ ", primarySize=" + primaryKeySize +
+ ", globalSize=" + globalSize +
+ ", globalPrimarySize=" + globalPrimarySize +
+ ", entrySet=" + jcache(i).localEntries() + ']');
+
+ if (!cacheIsEmpty) {
+ cacheIsNotEmptyMsg = "Cache is not empty: localSize = "
+ + jcache(fi).localSize(CachePeekMode.ALL) + ", local entries "
+ + entrySet(jcache(fi).localEntries());
+
+ break;
+ }
+
+ assertEquals("Cache is not empty [idx=" + i + ", entrySet=" + jcache(i).localEntries() + ']',
+ 0, jcache(i).localSize(CachePeekMode.ALL));
+
+ break;
+ }
+ catch (Exception e) {
+ if (X.hasCause(e, ClusterTopologyCheckedException.class)) {
+ info("Got topology exception while tear down (will retry in 1000ms).");
+
+ U.sleep(1000);
+ }
+ else
+ throw e;
+ }
+ }
+
+ if (cacheIsNotEmptyMsg != null)
+ break;
+
+ for (Cache.Entry entry : jcache(i).localEntries(CachePeekMode.SWAP))
+ jcache(i).remove(entry.getKey());
+ }
+
+ assert jcache().unwrap(Ignite.class).transactions().tx() == null;
+
+ if (cacheIsNotEmptyMsg == null)
+ assertEquals("Cache is not empty", 0, jcache().localSize(CachePeekMode.ALL));
+
+ resetStore();
+
+ // Restore cache if current cache has garbage.
+ if (cacheIsNotEmptyMsg != null) {
+ for (int i = 0; i < gridCount(); i++) {
+ info("Destroing cache on grid: " + i);
+
+ IgniteCache<String, Integer> cache = jcache(i);
+
+ assert i != 0 || cache != null;
+
+ if (cache != null)
+ cache.destroy();
+ }
+
+ assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicateX() {
+ @Override public boolean applyx() {
+ for (int i = 0; i < gridCount(); i++) {
+ if (jcache(i) != null)
+ return false;
+ }
+
+ return true;
+ }
+ }, 10_000));
+
+ startCachesDinamically();
+
+ log.warning(cacheIsNotEmptyMsg);
+
+ throw new IllegalStateException(cacheIsNotEmptyMsg);
+ }
+
+ assertEquals(0, jcache().localSize());
+ assertEquals(0, jcache().size());
+ }
+
+ /**
+ * Cleans up cache store.
+ */
+ protected void resetStore() {
+ map.clear();
+ }
+
+ /**
+ * Put entry to cache store.
+ *
+ * @param key Key.
+ * @param val Value.
+ */
+ protected void putToStore(Object key, Object val) {
+ if (!storeEnabled())
+ throw new IllegalStateException("Failed to put to store because store is disabled.");
+
+ map.put(key, val);
+ }
+
+ /**
+ * @return Default cache mode.
+ */
+ protected CacheMode cacheMode() {
+ CacheMode mode = cacheConfiguration().getCacheMode();
+
+ return mode == null ? CacheConfiguration.DFLT_CACHE_MODE : mode;
+ }
+
+ /**
+ * @return Load previous value flag.
+ */
+ protected boolean isLoadPreviousValue() {
+ return cacheConfiguration().isLoadPreviousValue();
+ }
+
+ /**
+ * @return Cache atomicity mode.
+ */
+ protected CacheAtomicityMode atomicityMode() {
+ return cacheConfiguration().getAtomicityMode();
+ }
+
+ /**
+ * @return {@code True} if values should be stored off-heap.
+ */
+ protected CacheMemoryMode memoryMode() {
+ return cacheConfiguration().getMemoryMode();
+ }
+
+ /**
+ * @return {@code True} if swap should happend after localEvict() call.
+ */
+ protected boolean swapAfterLocalEvict() {
+ if (memoryMode() == OFFHEAP_TIERED)
+ return false;
+
+ return memoryMode() == ONHEAP_TIERED ? (!offheapEnabled() && swapEnabled()) : swapEnabled();
+ }
+
+ /**
+ * @return {@code True} if store is enabled.
+ */
+ protected boolean storeEnabled() {
+ return cacheConfiguration().getCacheStoreFactory() != null;
+ }
+
+ /**
+ * @return {@code True} if offheap memory is enabled.
+ */
+ protected boolean offheapEnabled() {
+ return cacheConfiguration().getOffHeapMaxMemory() >= 0;
+ }
+
+ /**
+ * @return {@code True} if swap is enabled.
+ */
+ protected boolean swapEnabled() {
+ return cacheConfiguration().isSwapEnabled();
+ }
+
+ /**
+ * @return Write through storage emulator.
+ */
+ public static CacheStore<?, ?> cacheStore() {
+ return new CacheStoreAdapter<Object, Object>() {
+ @Override public void loadCache(IgniteBiInClosure<Object, Object> clo,
+ Object... args) {
+ for (Map.Entry<Object, Object> e : map.entrySet())
+ clo.apply(e.getKey(), e.getValue());
+ }
+
+ @Override public Object load(Object key) {
+ return map.get(key);
+ }
+
+ @Override public void write(Cache.Entry<? extends Object, ? extends Object> e) {
+ map.put(e.getKey(), e.getValue());
+ }
+
+ @Override public void delete(Object key) {
+ map.remove(key);
+ }
+ };
+ }
+
+ /**
+ * @return {@code true} if near cache should be enabled.
+ */
+ protected boolean nearEnabled() {
+ return grid(testedNodeIdx).cachex(cacheName()).context().isNear();
+ }
+
+ /**
+ * @return {@code True} if transactions are enabled.
+ * @see #txShouldBeUsed()
+ */
+ protected boolean txEnabled() {
+ return atomicityMode() == TRANSACTIONAL;
+ }
+
+ /**
+ * @return Cache configuration.
+ */
+ protected CacheConfiguration cacheConfiguration() {
+ return testsCfg.configurationFactory().cacheConfiguration(getTestGridName(testedNodeIdx));
+ }
+
+ /**
+ * @return {@code True} if transactions should be used.
+ */
+ protected boolean txShouldBeUsed() {
+ return txEnabled() && !isMultiJvm();
+ }
+
+ /**
+ * @return {@code True} if locking is enabled.
+ */
+ protected boolean lockingEnabled() {
+ return txEnabled();
+ }
+
+ /**
+ * @return Default cache instance.
+ */
+ @SuppressWarnings({"unchecked"})
+ @Override protected <K, V> IgniteCache<K, V> jcache() {
+ return jcache(testedNodeIdx);
+ }
+
+ /**
+ * @return A not near-only cache.
+ */
+ protected IgniteCache<String, Integer> serverNodeCache() {
+ return jcache(SERVER_NODE_IDX);
+ }
+
+ /**
+ * @return Cache name.
+ */
+ protected String cacheName() {
+ return "testcache-" + testsCfg.description().hashCode();
+ }
+
+ /**
+ * @return Transactions instance.
+ */
+ protected IgniteTransactions transactions() {
+ return grid(0).transactions();
+ }
+
+ /**
+ * @param idx Index of grid.
+ * @return Default cache.
+ */
+ @SuppressWarnings({"unchecked"})
+ @Override protected <K, V> IgniteCache<K, V> jcache(int idx) {
+ return ignite(idx).cache(cacheName());
+ }
+
+ /**
+ * @param idx Index of grid.
+ * @return Cache context.
+ */
+ protected GridCacheContext<String, Integer> context(final int idx) {
+ if (isRemoteJvm(idx) && !isRemoteJvm())
+ throw new UnsupportedOperationException("Operation can't be done automatically via proxy. " +
+ "Send task with this logic on remote jvm instead.");
+
+ return ((IgniteKernal)grid(idx)).<String, Integer>internalCache(cacheName()).context();
+ }
+
+ /**
+ * @param cache Cache.
+ * @return {@code True} if cache has OFFHEAP_TIERED memory mode.
+ */
+ protected static <K, V> boolean offheapTiered(IgniteCache<K, V> cache) {
+ return cache.getConfiguration(CacheConfiguration.class).getMemoryMode() == OFFHEAP_TIERED;
+ }
+
+ /**
+ * Executes regular peek or peek from swap.
+ *
+ * @param cache Cache projection.
+ * @param key Key.
+ * @return Value.
+ */
+ @Nullable protected static <K, V> V peek(IgniteCache<K, V> cache, K key) {
+ return offheapTiered(cache) ? cache.localPeek(key, CachePeekMode.SWAP, CachePeekMode.OFFHEAP) :
+ cache.localPeek(key, CachePeekMode.ONHEAP);
+ }
+
+ /**
+ * @param cache Cache.
+ * @param key Key.
+ * @return {@code True} if cache contains given key.
+ * @throws Exception If failed.
+ */
+ @SuppressWarnings("unchecked")
+ protected static boolean containsKey(IgniteCache cache, Object key) throws Exception {
+ return offheapTiered(cache) ? cache.localPeek(key, CachePeekMode.OFFHEAP) != null : cache.containsKey(key);
+ }
+
+ /**
+ * Serializable factory.
+ */
+ public static class TestStoreFactory implements Factory<CacheStore> {
+ @Override public CacheStore create() {
+ return cacheStore();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/953b575f/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteConfigVariationsAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteConfigVariationsAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteConfigVariationsAbstractTest.java
new file mode 100644
index 0000000..b22f289
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteConfigVariationsAbstractTest.java
@@ -0,0 +1,420 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.testframework.junits;
+
+import java.io.Externalizable;
+import java.io.File;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.Serializable;
+import org.apache.commons.io.FileUtils;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.testframework.configvariations.VariationsTestsConfig;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ * Common abstract test for Ignite tests based on configurations variations.
+ */
+public abstract class IgniteConfigVariationsAbstractTest extends GridCommonAbstractTest {
+ /** */
+ protected static final int SERVER_NODE_IDX = 0;
+
+ /** */
+ protected static final int CLIENT_NODE_IDX = 1;
+
+ /** */
+ protected int testedNodeIdx;
+
+ /** */
+ private static final File workDir = new File(U.getIgniteHome() + File.separator + "workOfConfigVariationsTests");
+
+ /** */
+ protected VariationsTestsConfig testsCfg;
+
+ /** */
+ protected volatile DataMode dataMode;
+
+ /**
+ * @param testsCfg Tests configuration.
+ */
+ public void setTestsConfiguration(VariationsTestsConfig testsCfg) {
+ assert this.testsCfg == null : "Test config must be set only once [oldTestCfg=" + this.testsCfg
+ + ", newTestCfg=" + testsCfg + "]";
+
+ this.testsCfg = testsCfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ assert testsCfg != null;
+
+ FileUtils.deleteDirectory(workDir);
+
+ info("Ignite's 'work' directory has been cleaned.");
+
+ if (Ignition.allGrids().size() != testsCfg.gridCount()) {
+ info("All nodes will be stopped, new " + testsCfg.gridCount() + " nodes will be started.");
+
+ Ignition.stopAll(true);
+
+ startGrids(testsCfg.gridCount());
+
+ for (int i = 0; i < testsCfg.gridCount(); i++)
+ info("Grid " + i + ": " + grid(i).localNode().id());
+ }
+
+ assert testsCfg.testedNodeIndex() >= 0 : "testedNodeIdx: " + testedNodeIdx;
+
+ testedNodeIdx = testsCfg.testedNodeIndex();
+
+ if (testsCfg.withClients()) {
+ for (int i = 0; i < gridCount(); i++)
+ assertEquals("i: " + i, expectedClient(getTestGridName(i)),
+ (boolean)grid(i).configuration().isClientMode());
+ }
+ }
+
+ /**
+ * @param testGridName Name.
+ * @return {@code True} if node is client should be client.
+ */
+ protected boolean expectedClient(String testGridName) {
+ return getTestGridName(CLIENT_NODE_IDX).equals(testGridName);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ if (testsCfg.isStopNodes()) {
+ info("Stopping all grids...");
+
+ stopAllGrids();
+
+ FileUtils.deleteDirectory(workDir);
+
+ info("Ignite's 'work' directory has been cleaned.");
+
+ memoryUsage();
+
+ System.gc();
+
+ memoryUsage();
+ }
+ }
+
+ /**
+ * Prints memory usage.
+ */
+ private void memoryUsage() {
+ int mb = 1024 * 1024;
+
+ Runtime runtime = Runtime.getRuntime();
+
+ info("##### Heap utilization statistics [MB] #####");
+ info("Used Memory (mb): " + (runtime.totalMemory() - runtime.freeMemory()) / mb);
+ info("Free Memory (mb): " + runtime.freeMemory() / mb);
+ info("Total Memory (mb): " + runtime.totalMemory() / mb);
+ info("Max Memory (mb): " + runtime.maxMemory() / mb);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected String testClassDescription() {
+ return super.testClassDescription() + '-' + testsCfg.description() + '-' + testsCfg.gridCount() + "-node(s)";
+ }
+
+ /** {@inheritDoc} */
+ @Override protected String testDescription() {
+ return super.testDescription() + '-' + testsCfg.description() + '-' + testsCfg.gridCount() + "-node(s)";
+ }
+
+ /** {@inheritDoc} */
+ @Override protected final IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ IgniteConfiguration resCfg = testsCfg.configurationFactory().getConfiguration(gridName, cfg);
+
+ resCfg.setWorkDirectory(workDir.getAbsolutePath());
+
+ if (testsCfg.withClients())
+ resCfg.setClientMode(expectedClient(gridName));
+
+ return resCfg;
+ }
+
+ /** {@inheritDoc} */
+ protected final int gridCount() {
+ return testsCfg.gridCount();
+ }
+
+ /**
+ * @return Count of clients.
+ */
+ protected int clientsCount() {
+ int cnt = 0;
+
+ for (int i = 0; i < gridCount(); i++) {
+ if (grid(i).configuration().isClientMode())
+ cnt++;
+ }
+
+ return cnt;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteEx grid() {
+ throw new UnsupportedOperationException("Not supported, grid(int idx) or testedGrid() should be used instead.");
+ }
+
+ /**
+ * @return Grid which should be tested.
+ */
+ protected IgniteEx testedGrid() {
+ return grid(testedNodeIdx);
+ }
+
+ /**
+ * Runs in all data modes.
+ */
+ protected void runInAllDataModes(TestRunnable call) throws Exception {
+ for (int i = 0; i < DataMode.values().length; i++) {
+ dataMode = DataMode.values()[i];
+
+ info("Running test in data mode: " + dataMode);
+
+ if (i != 0)
+ beforeTest();
+
+ try {
+ call.run();
+ }
+ finally {
+ if (i + 1 != DataMode.values().length)
+ afterTest();
+ }
+ }
+ }
+
+ /**
+ * @param keyId Key Id.
+ * @return Key.
+ */
+ public Object key(int keyId) {
+ return key(keyId, dataMode);
+ }
+
+ /**
+ * @param valId Key Id.
+ * @return Value.
+ */
+ public Object value(int valId) {
+ return value(valId, dataMode);
+ }
+
+ /**
+ * @param keyId Key Id.
+ * @param mode Mode.
+ * @return Key.
+ */
+ public static Object key(int keyId, DataMode mode) {
+ switch (mode) {
+ case SERIALIZABLE:
+ return new SerializableObject(keyId);
+ case EXTERNALIZABLE:
+ return new ExternalizableObject(keyId);
+ case PLANE_OBJECT:
+ return new TestObject(keyId);
+ default:
+ throw new IllegalArgumentException("mode: " + mode);
+ }
+ }
+
+ /**
+ * @param obj Key or value object
+ * @return Value.
+ */
+ public static int valueOf(Object obj) {
+ if (obj instanceof TestObject)
+ return ((TestObject)obj).value();
+ else
+ throw new IllegalStateException();
+ }
+
+ /**
+ * @param idx Index.
+ * @param mode Mode.
+ * @return Value.
+ */
+ public static Object value(int idx, DataMode mode) {
+ switch (mode) {
+ case SERIALIZABLE:
+ return new SerializableObject(idx);
+ case EXTERNALIZABLE:
+ return new ExternalizableObject(idx);
+ case PLANE_OBJECT:
+ return new TestObject(idx);
+ default:
+ throw new IllegalArgumentException("mode: " + mode);
+ }
+ }
+
+ /**
+ *
+ */
+ public static class TestObject {
+ /** */
+ protected int val;
+
+ /** */
+ protected String strVal;
+
+ /** */
+ protected TestEnum enumVal;
+
+ /**
+ * @param val Value.
+ */
+ TestObject(int val) {
+ this.val = val;
+ strVal = "val" + val;
+
+ TestEnum[] values = TestEnum.values();
+ enumVal = values[Math.abs(val) % values.length];
+ }
+
+ /**
+ * @return Value.
+ */
+ public int value() {
+ return val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+
+ if (!(o instanceof TestObject))
+ return false;
+
+ TestObject val = (TestObject)o;
+
+ return getClass().equals(o.getClass()) && this.val == val.val && enumVal == val.enumVal
+ && strVal.equals(val.strVal);
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return getClass().getSimpleName() + "[" +
+ "val=" + val +
+ ", strVal='" + strVal + '\'' +
+ ", enumVal=" + enumVal +
+ ']';
+ }
+ }
+
+ /**
+ *
+ */
+ protected static class SerializableObject extends TestObject implements Serializable {
+ /**
+ * @param val Value.
+ */
+ public SerializableObject(int val) {
+ super(val);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ExternalizableObject extends TestObject implements Externalizable {
+ /**
+ * Default constructor.
+ */
+ ExternalizableObject() {
+ super(-1);
+ }
+
+ /**
+ * @param val Value.
+ */
+ ExternalizableObject(int val) {
+ super(val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(val);
+ out.writeObject(strVal);
+ out.writeObject(enumVal);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ val = in.readInt();
+ strVal = (String)in.readObject();
+ enumVal = (TestEnum)in.readObject();
+ }
+ }
+
+ /**
+ * Data mode.
+ */
+ public enum DataMode {
+ /** Serializable objects. */
+ SERIALIZABLE,
+
+ /** Externalizable objects. */
+ EXTERNALIZABLE,
+
+ /** Objects without Serializable and Externalizable. */
+ PLANE_OBJECT
+ }
+
+ /**
+ *
+ */
+ private enum TestEnum {
+ /** */
+ TEST_VALUE_1,
+
+ /** */
+ TEST_VALUE_2,
+
+ /** */
+ TEST_VALUE_3
+ }
+
+ /**
+ *
+ */
+ public static interface TestRunnable {
+ /**
+ * @throws Exception If failed.
+ */
+ public void run() throws Exception;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/953b575f/modules/core/src/test/java/org/apache/ignite/testframework/test/ConfigVariationsTestSuiteBuilderTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/test/ConfigVariationsTestSuiteBuilderTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/test/ConfigVariationsTestSuiteBuilderTest.java
new file mode 100644
index 0000000..75e3010
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/test/ConfigVariationsTestSuiteBuilderTest.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.testframework.test;
+
+import java.util.concurrent.atomic.AtomicInteger;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.testframework.configvariations.ConfigVariationsTestSuiteBuilder;
+import org.apache.ignite.testframework.junits.IgniteConfigVariationsAbstractTest;
+
+/**
+ *
+ */
+public class ConfigVariationsTestSuiteBuilderTest extends TestCase {
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDefaults() throws Exception {
+ TestSuite dfltSuite = new ConfigVariationsTestSuiteBuilder("testSuite", OneTestCase.class).build();
+
+ assertEquals(4, dfltSuite.countTestCases());
+
+ TestSuite dfltCacheSuite = new ConfigVariationsTestSuiteBuilder("testSuite", OneTestCase.class)
+ .withBasicCacheParams().build();
+
+ assertEquals(4 * 12, dfltCacheSuite.countTestCases());
+
+ // With clients.
+ dfltSuite = new ConfigVariationsTestSuiteBuilder("testSuite", OneTestCase.class)
+ .testedNodesCount(2).withClients().build();
+
+ assertEquals(4 * 2, dfltSuite.countTestCases());
+
+ dfltCacheSuite = new ConfigVariationsTestSuiteBuilder("testSuite", OneTestCase.class)
+ .withBasicCacheParams().testedNodesCount(3).withClients().build();
+
+ assertEquals(4 * 12 * 3, dfltCacheSuite.countTestCases());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ @SuppressWarnings("serial")
+ public void testIgniteConfigFilter() throws Exception {
+ TestSuite dfltSuite = new ConfigVariationsTestSuiteBuilder("testSuite", OneTestCase.class).build();
+
+ final AtomicInteger cnt = new AtomicInteger();
+
+ TestSuite filteredSuite = new ConfigVariationsTestSuiteBuilder("testSuite", OneTestCase.class)
+ .withIgniteConfigFilters(new IgnitePredicate<IgniteConfiguration>() {
+ @Override public boolean apply(IgniteConfiguration configuration) {
+ return cnt.getAndIncrement() % 2 == 0;
+ }
+ })
+ .build();
+
+ assertEquals(dfltSuite.countTestCases() / 2, filteredSuite.countTestCases());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ @SuppressWarnings("serial")
+ public void testCacheConfigFilter() throws Exception {
+ TestSuite dfltSuite = new ConfigVariationsTestSuiteBuilder("testSuite", OneTestCase.class)
+ .withBasicCacheParams()
+ .build();
+
+ final AtomicInteger cnt = new AtomicInteger();
+
+ TestSuite filteredSuite = new ConfigVariationsTestSuiteBuilder("testSuite", OneTestCase.class)
+ .withBasicCacheParams()
+ .withCacheConfigFilters(new IgnitePredicate<CacheConfiguration>() {
+ @Override public boolean apply(CacheConfiguration configuration) {
+ return cnt.getAndIncrement() % 2 == 0;
+ }
+ })
+ .build();
+
+ assertEquals(dfltSuite.countTestCases() / 2, filteredSuite.countTestCases());
+ }
+
+ /**
+ *
+ */
+ private static class OneTestCase extends IgniteConfigVariationsAbstractTest {
+ /**
+ * @throws Exception If failed.
+ */
+ public void test1() throws Exception {
+ // No-op.
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/953b575f/modules/core/src/test/java/org/apache/ignite/testframework/test/ParametersTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/test/ParametersTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/test/ParametersTest.java
new file mode 100644
index 0000000..2870b06
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/test/ParametersTest.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.testframework.test;
+
+import java.util.HashSet;
+import java.util.Set;
+import junit.framework.TestCase;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.testframework.configvariations.ConfigParameter;
+import org.apache.ignite.testframework.configvariations.Parameters;
+
+/**
+ * Test.
+ */
+public class ParametersTest extends TestCase {
+ /**
+ * @throws Exception If failed.
+ */
+ public void testEnumVariations() throws Exception {
+ ConfigParameter<CacheConfiguration>[] modes = Parameters.enumParameters("setCacheMode", CacheMode.class);
+
+ assertEquals(CacheMode.values().length, modes.length);
+
+ Set<CacheMode> res = new HashSet<>();
+
+ for (ConfigParameter<CacheConfiguration> modeApplier : modes) {
+ CacheConfiguration cfg = new CacheConfiguration();
+
+ modeApplier.apply(cfg);
+
+ CacheMode mode = cfg.getCacheMode();
+
+ res.add(mode);
+
+ System.out.println(">>> " + mode);
+ }
+
+ assertEquals(modes.length, res.size());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ @SuppressWarnings("unchecked")
+ public void testEnumVariationsWithNull() throws Exception {
+ ConfigParameter<CacheConfiguration>[] cfgParam =
+ Parameters.enumParameters(true, "setCacheMode", CacheMode.class);
+
+ assertEquals(CacheMode.values().length + 1, cfgParam.length);
+
+ cfgParam[0] = null;
+
+ Set<CacheMode> set = new HashSet<>();
+
+ for (int i = 1; i < cfgParam.length; i++) {
+ ConfigParameter<CacheConfiguration> modeApplier = cfgParam[i];
+
+ CacheConfiguration cfg = new CacheConfiguration();
+
+ modeApplier.apply(cfg);
+
+ CacheMode mode = cfg.getCacheMode();
+
+ set.add(mode);
+
+ System.out.println(">>> " + mode);
+ }
+
+ assertEquals(CacheMode.values().length, set.size());
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/953b575f/modules/core/src/test/java/org/apache/ignite/testframework/test/VariationsIteratorTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/test/VariationsIteratorTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/test/VariationsIteratorTest.java
new file mode 100644
index 0000000..d8ac2b3
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/test/VariationsIteratorTest.java
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.testframework.test;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+import junit.framework.TestCase;
+import org.apache.ignite.testframework.configvariations.VariationsIterator;
+
+/**
+ * Test start iterator.
+ */
+public class VariationsIteratorTest extends TestCase {
+ /**
+ * @throws Exception If failed.
+ */
+ public void test1() throws Exception {
+ Object[][] arr = new Object[][] {
+ {0, 1},
+ {0, 1},
+ {0, 1},
+ };
+
+ checkIterator(arr);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ @SuppressWarnings("PointlessArithmeticExpression")
+ public void test2() throws Exception {
+ Object[][] arr = new Object[][] {
+ {0},
+ {0, 1, 2},
+ {0, 1},
+ {0, 1, 2, 3, 4, 5},
+ };
+
+ checkIterator(arr);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ @SuppressWarnings("PointlessArithmeticExpression")
+ public void test3() throws Exception {
+ Object[][] arr = new Object[][] {
+ {0, 1, 2, 3, 4, 5},
+ {0, 1, 2},
+ {0, 1},
+ {0},
+ };
+
+ checkIterator(arr);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ @SuppressWarnings("PointlessArithmeticExpression")
+ public void test4() throws Exception {
+ Object[][] arr = new Object[][]{
+ {0,1,2},
+ {0,1},
+ {0,1,2,4},
+ {0,1},
+ {0},
+ {0},
+ {0,1,2,4},
+ };
+
+ checkIterator(arr);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testSimple() throws Exception {
+ Object[][] arr = new Object[][] {
+ {0},
+ };
+
+ checkIterator(arr);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testSimple2() throws Exception {
+ Object[][] arr = new Object[][] {
+ {0},
+ {0},
+ };
+
+ checkIterator(arr);
+ }
+
+ /**
+ * @param arr Array.
+ */
+ private void checkIterator(Object[][] arr) {
+ int expSize = 1;
+ int significantParamsCnt = 1;
+
+ for (int i = 0; i < arr.length; i++) {
+ Object[] objects = arr[i];
+
+ System.out.println(">>> " + i + ": " + objects.length);
+
+ expSize *= objects.length;
+
+ if (objects.length > 1)
+ significantParamsCnt++;
+ }
+
+ System.out.println("Iteration info [expSize=" + expSize + ", significantParamsCnt=" + significantParamsCnt + "]");
+
+ Set<int[]> states = new HashSet<>();
+
+ int step = 0;
+
+ for (VariationsIterator it = new VariationsIterator(arr); it.hasNext(); ) {
+ int[] state = it.next();
+
+ System.out.println(Arrays.toString(state));
+
+ for (int[] state2 : states) {
+ if (Arrays.equals(state, state2))
+ fail("Got equal states on step " + step + " [state=" + Arrays.toString(state)
+ + ", state2=" + Arrays.toString(state2));
+ }
+
+ states.add(state);
+
+ step++;
+ }
+
+ assertEquals(expSize, states.size());
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/953b575f/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
index 3903910..9e2324c 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
@@ -51,6 +51,9 @@ import org.apache.ignite.messaging.GridMessagingSelfTest;
import org.apache.ignite.messaging.IgniteMessagingWithClientTest;
import org.apache.ignite.spi.GridSpiLocalHostInjectionTest;
import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.test.ConfigVariationsTestSuiteBuilderTest;
+import org.apache.ignite.testframework.test.ParametersTest;
+import org.apache.ignite.testframework.test.VariationsIteratorTest;
/**
* Basic test suite.
@@ -121,6 +124,11 @@ public class IgniteBasicTestSuite extends TestSuite {
GridTestUtils.addTestIfNeeded(suite, DynamicProxySerializationMultiJvmSelfTest.class, ignoredTests);
+ // Tests against configuration variations framework.
+ suite.addTestSuite(ParametersTest.class);
+ suite.addTestSuite(VariationsIteratorTest.class);
+ suite.addTestSuite(ConfigVariationsTestSuiteBuilderTest.class);
+
return suite;
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/953b575f/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheBasicConfigVariationsFullApiTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheBasicConfigVariationsFullApiTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheBasicConfigVariationsFullApiTestSuite.java
new file mode 100644
index 0000000..85a8f59
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheBasicConfigVariationsFullApiTestSuite.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.testsuites;
+
+import junit.framework.TestSuite;
+import org.apache.ignite.internal.processors.cache.IgniteCacheConfigVariationsFullApiTest;
+import org.apache.ignite.testframework.configvariations.ConfigVariationsTestSuiteBuilder;
+
+/**
+ * Test suite for cache API.
+ */
+public class IgniteCacheBasicConfigVariationsFullApiTestSuite extends TestSuite {
+ /**
+ * @return Cache API test suite.
+ * @throws Exception If failed.
+ */
+ public static TestSuite suite() throws Exception {
+ return new ConfigVariationsTestSuiteBuilder(
+ "Cache New Full API Test Suite",
+ IgniteCacheConfigVariationsFullApiTest.class)
+ .withBasicCacheParams()
+ .gridsCount(5).backups(1)
+ .testedNodesCount(3).withClients()
+ .build();
+ }
+}
[02/20] ignite git commit: IGNITE-2681: Binary serialization warning
is no longer printed to the log (part 2).
Posted by nt...@apache.org.
IGNITE-2681: Binary serialization warning is no longer printed to the log (part 2).
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/42572ad8
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/42572ad8
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/42572ad8
Branch: refs/heads/ignite-1186
Commit: 42572ad88f27aaa0e27582681050f4dc3bed51e6
Parents: 5a663a9
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Feb 26 14:28:02 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Feb 26 14:28:02 2016 +0300
----------------------------------------------------------------------
.../ignite/internal/processors/query/GridQueryProcessor.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/42572ad8/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index 64bbc8f..b13c674 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -384,7 +384,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
// Indexed types must be translated to CacheTypeMetadata in CacheConfiguration.
if (mustDeserializeClss != null) {
- U.quietAndWarn(log, "Some classes in query configuration cannot be written in binary format " +
+ U.warn(log, "Some classes in query configuration cannot be written in binary format " +
"because they either implement Externalizable interface or have writeObject/readObject methods. " +
"Instances of these classes will be deserialized in order to build indexes. Please ensure that " +
"all nodes have these classes in classpath. To enable binary serialization either implement " +
[07/20] ignite git commit: IGNITE-2726 Added missing off heap metrics
for Visor Console.
Posted by nt...@apache.org.
IGNITE-2726 Added missing off heap metrics for Visor Console.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c3f51685
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c3f51685
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c3f51685
Branch: refs/heads/ignite-1186
Commit: c3f5168555d94d1fe7bbc9cf32685ede48941638
Parents: 436c17e
Author: AKuznetsov <ak...@gridgain.com>
Authored: Mon Feb 29 11:31:58 2016 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Mon Feb 29 11:31:58 2016 +0700
----------------------------------------------------------------------
.../ignite/internal/visor/cache/VisorCache.java | 2 +-
.../cache/VisorCacheAggregatedMetrics.java | 113 ++++++++++++++-----
.../internal/visor/cache/VisorCacheMetrics.java | 88 +++++++--------
.../cache/VisorCacheMetricsCollectorTask.java | 21 +++-
.../visor/cache/VisorCacheMetricsV2.java | 66 +++++++++++
.../internal/visor/cache/VisorCacheV2.java | 2 +-
.../commands/cache/VisorCacheCommand.scala | 30 +++--
7 files changed, 238 insertions(+), 84 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/c3f51685/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java
index 9115c0c..7cd0669 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java
@@ -215,7 +215,7 @@ public class VisorCache implements Serializable {
offHeapAllocatedSize = ca.offHeapAllocatedSize();
offHeapEntriesCnt = ca.offHeapEntriesCount();
partitions = ca.affinity().partitions();
- metrics = VisorCacheMetrics.from(ignite, cacheName);
+ metrics = new VisorCacheMetrics().from(ignite, cacheName);
estimateMemorySize(ignite, ca, sample);
http://git-wip-us.apache.org/repos/asf/ignite/blob/c3f51685/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheAggregatedMetrics.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheAggregatedMetrics.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheAggregatedMetrics.java
index fba8a0d..0cba24b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheAggregatedMetrics.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheAggregatedMetrics.java
@@ -44,14 +44,23 @@ public class VisorCacheAggregatedMetrics implements Serializable {
/** Node IDs with cache metrics. */
private final Map<UUID, VisorCacheMetrics> metrics = new HashMap<>();
- /** Minimum number of elements in the cache. */
- private transient Integer minSize;
+ /** Minimum number of elements in heap. */
+ private transient Long minHeapSize;
- /** Average number of elements in the cache. */
- private transient Double avgSize;
+ /** Average number of elements in heap. */
+ private transient Double avgHeapSize;
- /** Maximum number of elements in the cache. */
- private transient Integer maxSize;
+ /** Maximum number of elements in heap. */
+ private transient Long maxHeapSize;
+
+ /** Minimum number of elements in off heap. */
+ private transient Long minOffHeapSize;
+
+ /** Average number of elements in off heap. */
+ private transient Double avgOffHeapSize;
+
+ /** Maximum number of elements in off heap. */
+ private transient Long maxOffHeapSize;
/** Minimum hits of the owning cache. */
private transient Long minHits;
@@ -148,47 +157,99 @@ public class VisorCacheAggregatedMetrics implements Serializable {
}
/**
- * @return Minimum number of elements in the cache.
+ * @return Minimum number of elements in heap.
+ */
+ public long minimumHeapSize() {
+ if (minHeapSize == null) {
+ minHeapSize = Long.MAX_VALUE;
+
+ for (VisorCacheMetrics metric : metrics.values())
+ minHeapSize = Math.min(minHeapSize, metric.keySize());
+ }
+
+ return minHeapSize;
+ }
+
+ /**
+ * @return Average number of elements in heap.
+ */
+ public double averageHeapSize() {
+ if (avgHeapSize == null) {
+ avgHeapSize = 0.0d;
+
+ for (VisorCacheMetrics metric : metrics.values())
+ avgHeapSize += metric.keySize();
+
+ avgHeapSize /= metrics.size();
+ }
+
+ return avgHeapSize;
+ }
+
+ /**
+ * @return Maximum number of elements in heap.
+ */
+ public long maximumHeapSize() {
+ if (maxHeapSize == null) {
+ maxHeapSize = Long.MIN_VALUE;
+
+ for (VisorCacheMetrics metric : metrics.values())
+ maxHeapSize = Math.max(maxHeapSize, metric.keySize());
+ }
+
+ return maxHeapSize;
+ }
+
+ /**
+ * @param metric Metrics to process.
+ * @return Off heap entries count.
+ */
+ private long offHeapEntriesCount(VisorCacheMetrics metric) {
+ return metric instanceof VisorCacheMetricsV2 ? ((VisorCacheMetricsV2) metric).offHeapEntriesCount() : 0;
+ }
+
+ /**
+ * @return Minimum number of elements in off heap.
*/
- public int minimumSize() {
- if (minSize == null) {
- minSize = Integer.MAX_VALUE;
+ public long minimumOffHeapSize() {
+ if (minOffHeapSize == null) {
+ minOffHeapSize = Long.MAX_VALUE;
for (VisorCacheMetrics metric : metrics.values())
- minSize = Math.min(minSize, metric.keySize());
+ minOffHeapSize = Math.min(minOffHeapSize, offHeapEntriesCount(metric));
}
- return minSize;
+ return minOffHeapSize;
}
/**
- * @return Average number of elements in the cache.
+ * @return Average number of elements in off heap.
*/
- public double averageSize() {
- if (avgSize == null) {
- avgSize = 0.0d;
+ public double averageOffHeapSize() {
+ if (avgOffHeapSize == null) {
+ avgOffHeapSize = 0.0d;
for (VisorCacheMetrics metric : metrics.values())
- avgSize += metric.keySize();
+ avgOffHeapSize += offHeapEntriesCount(metric);
- avgSize /= metrics.size();
+ avgOffHeapSize /= metrics.size();
}
- return avgSize;
+ return avgOffHeapSize;
}
/**
- * @return Maximum number of elements in the cache.
+ * @return Maximum number of elements in off heap in the cache.
*/
- public int maximumSize() {
- if (maxSize == null) {
- maxSize = Integer.MIN_VALUE;
+ public long maximumOffHeapSize() {
+ if (maxOffHeapSize == null) {
+ maxOffHeapSize = Long.MIN_VALUE;
for (VisorCacheMetrics metric : metrics.values())
- maxSize = Math.max(maxSize, metric.keySize());
+ maxOffHeapSize = Math.max(maxOffHeapSize, offHeapEntriesCount(metric));
}
- return maxSize;
+ return maxOffHeapSize;
}
/**
@@ -460,4 +521,4 @@ public class VisorCacheAggregatedMetrics implements Serializable {
@Override public String toString() {
return S.toString(VisorCacheAggregatedMetrics.class, this);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c3f51685/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetrics.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetrics.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetrics.java
index 2844c12..1a88813 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetrics.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetrics.java
@@ -170,66 +170,64 @@ public class VisorCacheMetrics implements Serializable {
* @param cacheName Cache name.
* @return Data transfer object for given cache metrics.
*/
- public static VisorCacheMetrics from(IgniteEx ignite, String cacheName) {
- VisorCacheMetrics cm = new VisorCacheMetrics();
-
+ public VisorCacheMetrics from(IgniteEx ignite, String cacheName) {
GridCacheProcessor cacheProcessor = ignite.context().cache();
IgniteCache<Object, Object> c = cacheProcessor.jcache(cacheName);
- cm.name = cacheName;
- cm.mode = cacheProcessor.cacheMode(cacheName);
- cm.sys = cacheProcessor.systemCache(cacheName);
+ name = cacheName;
+ mode = cacheProcessor.cacheMode(cacheName);
+ sys = cacheProcessor.systemCache(cacheName);
CacheMetrics m = c.metrics();
- cm.size = m.getSize();
- cm.keySize = m.getKeySize();
+ size = m.getSize();
+ keySize = m.getKeySize();
- cm.reads = m.getCacheGets();
- cm.writes = m.getCachePuts() + m.getCacheRemovals();
- cm.hits = m.getCacheHits();
- cm.misses = m.getCacheMisses();
+ reads = m.getCacheGets();
+ writes = m.getCachePuts() + m.getCacheRemovals();
+ hits = m.getCacheHits();
+ misses = m.getCacheMisses();
- cm.txCommits = m.getCacheTxCommits();
- cm.txRollbacks = m.getCacheTxRollbacks();
+ txCommits = m.getCacheTxCommits();
+ txRollbacks = m.getCacheTxRollbacks();
- cm.avgTxCommitTime = m.getAverageTxCommitTime();
- cm.avgTxRollbackTime = m.getAverageTxRollbackTime();
+ avgTxCommitTime = m.getAverageTxCommitTime();
+ avgTxRollbackTime = m.getAverageTxRollbackTime();
- cm.puts = m.getCachePuts();
- cm.removals = m.getCacheRemovals();
- cm.evictions = m.getCacheEvictions();
+ puts = m.getCachePuts();
+ removals = m.getCacheRemovals();
+ evictions = m.getCacheEvictions();
- cm.avgReadTime = m.getAverageGetTime();
- cm.avgPutTime = m.getAveragePutTime();
- cm.avgRemovalTime = m.getAverageRemoveTime();
+ avgReadTime = m.getAverageGetTime();
+ avgPutTime = m.getAveragePutTime();
+ avgRemovalTime = m.getAverageRemoveTime();
- cm.readsPerSec = perSecond(m.getAverageGetTime());
- cm.putsPerSec = perSecond(m.getAveragePutTime());
- cm.removalsPerSec = perSecond(m.getAverageRemoveTime());
- cm.commitsPerSec = perSecond(m.getAverageTxCommitTime());
- cm.rollbacksPerSec = perSecond(m.getAverageTxRollbackTime());
+ readsPerSec = perSecond(m.getAverageGetTime());
+ putsPerSec = perSecond(m.getAveragePutTime());
+ removalsPerSec = perSecond(m.getAverageRemoveTime());
+ commitsPerSec = perSecond(m.getAverageTxCommitTime());
+ rollbacksPerSec = perSecond(m.getAverageTxRollbackTime());
- cm.qryMetrics = VisorCacheQueryMetrics.from(c.queryMetrics());
+ qryMetrics = VisorCacheQueryMetrics.from(c.queryMetrics());
- cm.dhtEvictQueueCurrSize = m.getDhtEvictQueueCurrentSize();
- cm.txThreadMapSize = m.getTxThreadMapSize();
- cm.txXidMapSize = m.getTxXidMapSize();
- cm.txCommitQueueSize = m.getTxCommitQueueSize();
- cm.txPrepareQueueSize = m.getTxPrepareQueueSize();
- cm.txStartVerCountsSize = m.getTxStartVersionCountsSize();
- cm.txCommittedVersionsSize = m.getTxCommittedVersionsSize();
- cm.txRolledbackVersionsSize = m.getTxRolledbackVersionsSize();
- cm.txDhtThreadMapSize = m.getTxDhtThreadMapSize();
- cm.txDhtXidMapSize = m.getTxDhtXidMapSize();
- cm.txDhtCommitQueueSize = m.getTxDhtCommitQueueSize();
- cm.txDhtPrepareQueueSize = m.getTxDhtPrepareQueueSize();
- cm.txDhtStartVerCountsSize = m.getTxDhtStartVersionCountsSize();
- cm.txDhtCommittedVersionsSize = m.getTxDhtCommittedVersionsSize();
- cm.txDhtRolledbackVersionsSize = m.getTxDhtRolledbackVersionsSize();
+ dhtEvictQueueCurrSize = m.getDhtEvictQueueCurrentSize();
+ txThreadMapSize = m.getTxThreadMapSize();
+ txXidMapSize = m.getTxXidMapSize();
+ txCommitQueueSize = m.getTxCommitQueueSize();
+ txPrepareQueueSize = m.getTxPrepareQueueSize();
+ txStartVerCountsSize = m.getTxStartVersionCountsSize();
+ txCommittedVersionsSize = m.getTxCommittedVersionsSize();
+ txRolledbackVersionsSize = m.getTxRolledbackVersionsSize();
+ txDhtThreadMapSize = m.getTxDhtThreadMapSize();
+ txDhtXidMapSize = m.getTxDhtXidMapSize();
+ txDhtCommitQueueSize = m.getTxDhtCommitQueueSize();
+ txDhtPrepareQueueSize = m.getTxDhtPrepareQueueSize();
+ txDhtStartVerCountsSize = m.getTxDhtStartVersionCountsSize();
+ txDhtCommittedVersionsSize = m.getTxDhtCommittedVersionsSize();
+ txDhtRolledbackVersionsSize = m.getTxDhtRolledbackVersionsSize();
- return cm;
+ return this;
}
/**
@@ -516,4 +514,4 @@ public class VisorCacheMetrics implements Serializable {
@Override public String toString() {
return S.toString(VisorCacheMetrics.class, this);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c3f51685/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetricsCollectorTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetricsCollectorTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetricsCollectorTask.java
index abed7db..4dd1e28 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetricsCollectorTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetricsCollectorTask.java
@@ -21,6 +21,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
+import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.compute.ComputeJobResult;
import org.apache.ignite.internal.processors.cache.GridCacheProcessor;
import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
@@ -30,6 +31,7 @@ import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.internal.visor.VisorJob;
import org.apache.ignite.internal.visor.VisorMultiNodeTask;
import org.apache.ignite.lang.IgniteBiTuple;
+import org.apache.ignite.lang.IgniteProductVersion;
import org.jetbrains.annotations.Nullable;
/**
@@ -77,9 +79,13 @@ public class VisorCacheMetricsCollectorTask extends VisorMultiNodeTask<IgniteBiT
*/
private static class VisorCacheMetricsCollectorJob
extends VisorJob<IgniteBiTuple<Boolean, Collection<String>>, Collection<VisorCacheMetrics>> {
+
/** */
private static final long serialVersionUID = 0L;
+ /** */
+ private static final IgniteProductVersion V2_SINCE = IgniteProductVersion.fromString("1.5.8");
+
/**
* Create job with given argument.
*
@@ -114,7 +120,18 @@ public class VisorCacheMetricsCollectorTask extends VisorMultiNodeTask<IgniteBiT
if (ca.context().started()) {
String cacheName = ca.getName();
- VisorCacheMetrics cm = VisorCacheMetrics.from(ignite, cacheName);
+ boolean compatibilityMode = false;
+
+ for (ClusterNode node : ignite.cluster().nodes()) {
+ if (node.version().compareToIgnoreTimestamp(V2_SINCE) < 0) {
+ compatibilityMode = true;
+
+ break;
+ }
+ }
+
+ VisorCacheMetrics cm = (compatibilityMode ? new VisorCacheMetrics() : new VisorCacheMetricsV2())
+ .from(ignite, cacheName);
if ((allCaches || cacheNames.contains(cacheName)) && (showSysCaches || !cm.system()))
res.add(cm);
@@ -129,4 +146,4 @@ public class VisorCacheMetricsCollectorTask extends VisorMultiNodeTask<IgniteBiT
return S.toString(VisorCacheMetricsCollectorJob.class, this);
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c3f51685/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetricsV2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetricsV2.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetricsV2.java
new file mode 100644
index 0000000..2376db0
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetricsV2.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.visor.cache;
+
+import org.apache.ignite.cache.CacheMetrics;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
+import org.apache.ignite.internal.processors.cache.GridCacheProcessor;
+
+/**
+ * Data transfer object for {@link CacheMetrics}.
+ */
+public class VisorCacheMetricsV2 extends VisorCacheMetrics {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Memory size allocated in off-heap. */
+ private long offHeapAllocatedSize;
+
+ /** Number of cache entries stored in off-heap memory. */
+ private long offHeapEntriesCount;
+
+ /** {@inheritDoc} */
+ @Override
+ public VisorCacheMetrics from(IgniteEx ignite, String cacheName) {
+ super.from(ignite, cacheName);
+
+ GridCacheProcessor cacheProcessor = ignite.context().cache();
+
+ GridCacheAdapter<Object, Object> c = cacheProcessor.internalCache(cacheName);
+
+ offHeapAllocatedSize = c.offHeapAllocatedSize();
+ offHeapEntriesCount = c.offHeapEntriesCount();
+
+ return this;
+ }
+
+ /**
+ * @return Memory size allocated in off-heap.
+ */
+ public long offHeapAllocatedSize() {
+ return offHeapAllocatedSize;
+ }
+
+ /**
+ * @return Number of cache entries stored in off-heap memory.
+ */
+ public long offHeapEntriesCount() {
+ return offHeapEntriesCount;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c3f51685/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheV2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheV2.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheV2.java
index 6b6aba2..61551cc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheV2.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheV2.java
@@ -41,7 +41,7 @@ public class VisorCacheV2 extends VisorCache {
if (c != null && c instanceof VisorCacheV2) {
GridCacheAdapter ca = ignite.context().cache().internalCache(cacheName);
- // Cache was not started.
+ // Process only started caches.
if (ca != null && ca.context().started())
((VisorCacheV2)c).near = ca.context().isNear();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c3f51685/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala
index 13b4e32..b6812c3 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala
@@ -316,7 +316,7 @@ class VisorCacheCommand {
val sumT = VisorTextTable()
- sumT #= ("Name(@)", "Mode", "Nodes", "Entries", "Hits", "Misses", "Reads", "Writes")
+ sumT #= ("Name(@)", "Mode", "Nodes", "Entries (Heap / Off heap)", "Hits", "Misses", "Reads", "Writes")
sortAggregatedData(aggrData, sortType.getOrElse("cn"), reversed).foreach(
ad => {
@@ -328,9 +328,12 @@ class VisorCacheCommand {
ad.mode(),
ad.nodes.size(),
(
- "min: " + ad.minimumSize,
- "avg: " + formatDouble(ad.averageSize),
- "max: " + ad.maximumSize
+ "min: " + (ad.minimumHeapSize() + ad.minimumOffHeapSize()) +
+ " (" + ad.minimumHeapSize() + " / " + ad.minimumOffHeapSize() + ")",
+ "avg: " + formatDouble(ad.averageHeapSize() + ad.averageOffHeapSize()) +
+ " (" + formatDouble(ad.averageHeapSize()) + " / " + formatDouble(ad.averageOffHeapSize()) + ")",
+ "max: " + (ad.maximumHeapSize() + ad.maximumOffHeapSize()) +
+ " (" + ad.maximumHeapSize() + " / " + ad.maximumOffHeapSize() + ")"
),
(
"min: " + ad.minimumHits,
@@ -382,7 +385,13 @@ class VisorCacheCommand {
csT += ("Name(@)", cacheNameVar)
csT += ("Nodes", m.size())
- csT += ("Size Min/Avg/Max", ad.minimumSize + " / " + formatDouble(ad.averageSize) + " / " + ad.maximumSize)
+ csT += ("Total size Min/Avg/Max", (ad.minimumHeapSize() + ad.minimumOffHeapSize()) + " / " +
+ formatDouble(ad.averageHeapSize() + ad.averageOffHeapSize()) + " / " +
+ (ad.maximumHeapSize() + ad.maximumOffHeapSize()))
+ csT += (" Heap size Min/Avg/Max", ad.minimumHeapSize() + " / " +
+ formatDouble(ad.averageHeapSize()) + " / " + ad.maximumHeapSize())
+ csT += (" Off heap size Min/Avg/Max", ad.minimumOffHeapSize() + " / " +
+ formatDouble(ad.averageOffHeapSize()) + " / " + ad.maximumOffHeapSize())
val ciT = VisorTextTable()
@@ -617,7 +626,7 @@ class VisorCacheCommand {
val sumT = VisorTextTable()
- sumT #= ("#", "Name(@)", "Mode", "Size")
+ sumT #= ("#", "Name(@)", "Mode", "Size (Heap / Off heap)")
sortedAggrData.indices.foreach(i => {
val ad = sortedAggrData(i)
@@ -630,9 +639,12 @@ class VisorCacheCommand {
mkCacheName(ad.name()),
ad.mode(),
(
- "min: " + ad.minimumSize,
- "avg: " + formatDouble(ad.averageSize),
- "max: " + ad.maximumSize
+ "min: " + (ad.minimumHeapSize() + ad.minimumOffHeapSize()) +
+ " (" + ad.minimumHeapSize() + " / " + ad.minimumOffHeapSize() + ")",
+ "avg: " + formatDouble(ad.averageHeapSize() + ad.averageOffHeapSize()) +
+ " (" + formatDouble(ad.averageHeapSize()) + " / " + formatDouble(ad.averageOffHeapSize()) + ")",
+ "max: " + (ad.maximumHeapSize() + ad.maximumOffHeapSize()) +
+ " (" + ad.maximumHeapSize() + " / " + ad.maximumOffHeapSize() + ")"
))
})
[20/20] ignite git commit: Merge branch 'master' into ignite-1186
Posted by nt...@apache.org.
Merge branch 'master' into ignite-1186
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/846e8e5d
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/846e8e5d
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/846e8e5d
Branch: refs/heads/ignite-1186
Commit: 846e8e5d46fcf206369a6dacd2b56a45ac33b1cd
Parents: 5455a9f 8917269
Author: nikolay_tikhonov <nt...@gridgain.com>
Authored: Tue Mar 1 13:41:48 2016 +0300
Committer: nikolay_tikhonov <nt...@gridgain.com>
Committed: Tue Mar 1 14:09:35 2016 +0300
----------------------------------------------------------------------
.../internal/binary/BinaryClassDescriptor.java | 2 +-
.../processors/cache/GridCacheProcessor.java | 20 +
.../processors/cache/GridCacheUtils.java | 15 +
.../cache/affinity/GridCacheAffinityImpl.java | 7 +-
.../CacheContinuousQueryHandlerV2.java | 11 +-
.../continuous/CacheContinuousQueryManager.java | 2 +-
.../processors/query/GridQueryProcessor.java | 13 +-
.../ignite/internal/visor/cache/VisorCache.java | 2 +-
.../cache/VisorCacheAggregatedMetrics.java | 113 +-
.../internal/visor/cache/VisorCacheMetrics.java | 88 +-
.../cache/VisorCacheMetricsCollectorTask.java | 21 +-
.../visor/cache/VisorCacheMetricsV2.java | 66 +
.../internal/visor/cache/VisorCacheV2.java | 2 +-
.../ignite/resources/JobContextResource.java | 4 +-
.../org/apache/ignite/spi/IgniteSpiAdapter.java | 15 +
.../ignite/spi/IgniteSpiConsistencyChecked.java | 8 +
.../ignite/spi/discovery/tcp/ClientImpl.java | 6 +-
.../ignite/spi/discovery/tcp/ServerImpl.java | 2 +-
.../TcpDiscoveryMulticastIpFinder.java | 1 +
.../spi/swapspace/file/FileSwapSpaceSpi.java | 2 +
.../spi/swapspace/noop/NoopSwapSpaceSpi.java | 2 +
.../cache/GridCacheAbstractFullApiSelfTest.java | 10 +-
...ridCacheSwapSpaceSpiConsistencySelfTest.java | 146 +
.../IgniteCacheConfigVariationsFullApiTest.java | 5851 ++++++++++++++++++
...acheContinuousQueryRandomOperationsTest.java | 51 +
.../GridSwapSpaceSpiConsistencySelfTest.java | 131 +
.../configvariations/CacheStartMode.java | 29 +
.../configvariations/ConfigFactory.java | 39 +
.../configvariations/ConfigParameter.java | 34 +
.../configvariations/ConfigVariations.java | 346 ++
.../ConfigVariationsFactory.java | 197 +
.../ConfigVariationsTestSuiteBuilder.java | 382 ++
.../IgniteConfigVariationsTestSuite.java | 50 +
.../configvariations/Parameters.java | 377 ++
.../configvariations/VariationsIterator.java | 174 +
.../configvariations/VariationsTestsConfig.java | 161 +
.../testframework/junits/GridAbstractTest.java | 43 +-
...IgniteCacheConfigVariationsAbstractTest.java | 583 ++
.../IgniteConfigVariationsAbstractTest.java | 420 ++
.../ConfigVariationsTestSuiteBuilderTest.java | 112 +
.../testframework/test/ParametersTest.java | 87 +
.../test/VariationsIteratorTest.java | 156 +
.../ignite/testsuites/IgniteBasicTestSuite.java | 8 +
...heBasicConfigVariationsFullApiTestSuite.java | 41 +
.../testsuites/IgniteCacheTestSuite5.java | 2 +
.../IgniteSpiSwapSpaceSelfTestSuite.java | 2 +
.../processors/query/h2/IgniteH2Indexing.java | 104 +-
.../cache/CacheQueryNewClientSelfTest.java | 108 +
.../IgniteCacheQuerySelfTestSuite.java | 6 +-
.../commands/cache/VisorCacheCommand.scala | 30 +-
.../yardstick/IgniteBenchmarkArguments.java | 11 +
.../org/apache/ignite/yardstick/IgniteNode.java | 2 +
.../cache/IgniteCacheAbstractBenchmark.java | 54 +
53 files changed, 9994 insertions(+), 155 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/846e8e5d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandlerV2.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandlerV2.java
index 6fc2041,0000000..dbe2a46
mode 100644,000000..100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandlerV2.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandlerV2.java
@@@ -1,217 -1,0 +1,222 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.query.continuous;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.UUID;
+import javax.cache.configuration.Factory;
+import javax.cache.event.CacheEntryEventFilter;
+import javax.cache.event.CacheEntryUpdatedListener;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryManager.JCacheQueryRemoteFilter;
+import org.apache.ignite.internal.processors.continuous.GridContinuousHandler;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Continuous query handler V2 version. Contains {@link Factory} for remote listener.
+ */
+public class CacheContinuousQueryHandlerV2<K, V> extends CacheContinuousQueryHandler<K, V> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Remote filter factory. */
+ private Factory<? extends CacheEntryEventFilter> rmtFilterFactory;
+
+ /** Deployable object for filter factory. */
+ private DeployableObject rmtFilterFactoryDep;
+
+ /** Event types for JCache API. */
+ private byte types = 0;
+
+ /** */
+ protected transient CacheEntryEventFilter filter;
+
+ /**
+ * Required by {@link Externalizable}.
+ */
+ public CacheContinuousQueryHandlerV2() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param cacheName Cache name.
+ * @param topic Topic for ordered messages.
+ * @param locLsnr Local listener.
+ * @param rmtFilterFactory Remote filter factory.
+ * @param internal Internal flag.
+ * @param notifyExisting Notify existing flag.
+ * @param oldValRequired Old value required flag.
+ * @param sync Synchronous flag.
+ * @param ignoreExpired Ignore expired events flag.
+ * @param skipPrimaryCheck Whether to skip primary check for REPLICATED cache.
+ * @param taskHash Task name hash code.
+ * @param locCache {@code True} if local cache.
+ * @param keepBinary Keep binary flag.
+ * @param types Event types.
+ */
+ public CacheContinuousQueryHandlerV2(
+ String cacheName,
+ Object topic,
+ CacheEntryUpdatedListener<K, V> locLsnr,
+ Factory<? extends CacheEntryEventFilter<K, V>> rmtFilterFactory,
+ boolean internal,
+ boolean notifyExisting,
+ boolean oldValRequired,
+ boolean sync,
+ boolean ignoreExpired,
+ int taskHash,
+ boolean skipPrimaryCheck,
+ boolean locCache,
+ boolean keepBinary,
+ boolean ignoreClsNotFound,
+ @Nullable Byte types) {
+ super(cacheName,
+ topic,
+ locLsnr,
+ null,
+ internal,
+ notifyExisting,
+ oldValRequired,
+ sync,
+ ignoreExpired,
+ taskHash,
+ skipPrimaryCheck,
+ locCache,
+ keepBinary,
+ ignoreClsNotFound);
+
+ assert rmtFilterFactory != null;
+
+ this.rmtFilterFactory = rmtFilterFactory;
+
- if (types != null)
++ if (types != null) {
++ assert types != 0;
++
+ this.types = types;
++ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public CacheEntryEventFilter getEventFilter() {
+ if (filter == null) {
+ assert rmtFilterFactory != null;
+
++ Factory<? extends CacheEntryEventFilter> factory = rmtFilterFactory;
++
+ if (types != 0)
- rmtFilterFactory = new JCacheRemoteQueryFactory(rmtFilterFactory, types);
++ factory = new JCacheRemoteQueryFactory(rmtFilterFactory, types);
+
- filter = rmtFilterFactory.create();
++ filter = factory.create();
+ }
+
+ return filter;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void p2pMarshal(GridKernalContext ctx) throws IgniteCheckedException {
+ super.p2pMarshal(ctx);
+
+ if (rmtFilterFactory != null && !U.isGrid(rmtFilterFactory.getClass()))
+ rmtFilterFactoryDep = new DeployableObject(rmtFilterFactory, ctx);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void p2pUnmarshal(UUID nodeId, GridKernalContext ctx) throws IgniteCheckedException {
+ super.p2pUnmarshal(nodeId, ctx);
+
+ if (rmtFilterFactoryDep != null)
+ rmtFilterFactory = rmtFilterFactoryDep.unmarshal(nodeId, ctx);
+ }
+
+ /** {@inheritDoc} */
+ @Override public GridContinuousHandler clone() {
+ return super.clone();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(CacheContinuousQueryHandlerV2.class, this);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+
+ boolean b = rmtFilterFactoryDep != null;
+
+ out.writeBoolean(b);
+
+ if (b)
+ out.writeObject(rmtFilterFactoryDep);
+ else
+ out.writeObject(rmtFilterFactory);
+
+ out.writeByte(types);
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+
+ boolean b = in.readBoolean();
+
+ if (b)
+ rmtFilterFactoryDep = (DeployableObject)in.readObject();
+ else
+ rmtFilterFactory = (Factory)in.readObject();
+
+ types = in.readByte();
+ }
+
+ /**
+ *
+ */
+ private static class JCacheRemoteQueryFactory implements Factory<CacheEntryEventFilter> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Factory. */
+ protected Factory<? extends CacheEntryEventFilter> impl;
+
+ /** */
+ private byte types;
+
+ /**
+ * @param impl Factory.
+ * @param types Types.
+ */
+ public JCacheRemoteQueryFactory(@Nullable Factory<? extends CacheEntryEventFilter> impl, byte types) {
+ this.impl = impl;
+ this.types = types;
+ }
+
+ /** {@inheritDoc} */
+ @Override public JCacheQueryRemoteFilter create() {
+ return new JCacheQueryRemoteFilter(impl != null ? impl.create() : null, types);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/846e8e5d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
index 2a05865,409c1da..bfe70f1
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
@@@ -608,235 -589,6 +608,235 @@@ public class CacheContinuousQueryManage
keepBinary,
ignoreClassNotFound);
+ return executeQuery0(locLsnr,
+ bufSize,
+ timeInterval,
+ autoUnsubscribe,
+ notifyExisting,
+ loc,
+ keepBinary,
+ hnd);
+ }
+
+
+ /**
+ * @param locLsnr Local listener.
+ * @param types JCache event types.
+ * @param bufSize Buffer size.
+ * @param timeInterval Time interval.
+ * @param autoUnsubscribe Auto unsubscribe flag.
+ * @param internal Internal flag.
+ * @param notifyExisting Notify existing flag.
+ * @param oldValRequired Old value required flag.
+ * @param sync Synchronous flag.
+ * @param ignoreExpired Ignore expired event flag.
+ * @param loc Local flag.
+ * @return Continuous routine ID.
+ * @throws IgniteCheckedException In case of error.
+ */
+ private UUID executeJCacheQueryFactory(CacheEntryUpdatedListener locLsnr,
+ final Factory<CacheEntryEventFilter> rmtFilterFactory,
+ byte types,
+ int bufSize,
+ long timeInterval,
+ boolean autoUnsubscribe,
+ boolean internal,
+ boolean notifyExisting,
+ boolean oldValRequired,
+ boolean sync,
+ boolean ignoreExpired,
+ boolean loc,
+ final boolean keepBinary,
+ boolean ignoreClassNotFound) throws IgniteCheckedException
+ {
+ assert types != 0 : types;
+
+ cctx.checkSecurity(SecurityPermission.CACHE_READ);
+
+ int taskNameHash = !internal && cctx.kernalContext().security().enabled() ?
+ cctx.kernalContext().job().currentTaskNameHash() : 0;
+
+ boolean skipPrimaryCheck = loc && cctx.config().getCacheMode() == CacheMode.REPLICATED && cctx.affinityNode();
+
+ boolean v2 = rmtFilterFactory != null && useV2Protocol(cctx.discovery().allNodes());
+
+ GridContinuousHandler hnd;
+
+ if (v2)
+ hnd = new CacheContinuousQueryHandlerV2(
+ cctx.name(),
+ TOPIC_CACHE.topic(topicPrefix, cctx.localNodeId(), seq.getAndIncrement()),
+ locLsnr,
+ rmtFilterFactory,
+ internal,
+ notifyExisting,
+ oldValRequired,
+ sync,
+ ignoreExpired,
+ taskNameHash,
+ skipPrimaryCheck,
+ cctx.isLocal(),
+ keepBinary,
+ ignoreClassNotFound,
+ types);
+ else {
+ JCacheQueryRemoteFilter jCacheFilter;
+
+ CacheEntryEventFilter filter = null;
+
+ if (rmtFilterFactory != null) {
+ filter = rmtFilterFactory.create();
+
+ if (!(filter instanceof Serializable))
+ throw new IgniteCheckedException("Topology has nodes of the old versions. In this case " +
+ "EntryEventFilter must implement java.io.Serializable interface. Filter: " + filter);
+ }
+
+ jCacheFilter = new JCacheQueryRemoteFilter(filter, types);
+
+ hnd = new CacheContinuousQueryHandler(
+ cctx.name(),
+ TOPIC_CACHE.topic(topicPrefix, cctx.localNodeId(), seq.getAndIncrement()),
+ locLsnr,
+ jCacheFilter,
+ internal,
+ notifyExisting,
+ oldValRequired,
+ sync,
+ ignoreExpired,
+ taskNameHash,
+ skipPrimaryCheck,
+ cctx.isLocal(),
+ keepBinary,
+ ignoreClassNotFound);
+ }
+
+ return executeQuery0(locLsnr,
+ bufSize,
+ timeInterval,
+ autoUnsubscribe,
+ notifyExisting,
+ loc,
+ keepBinary,
+ hnd);
+ }
+
+ /**
+ * @param locLsnr Local listener.
+ * @param bufSize Buffer size.
+ * @param timeInterval Time interval.
+ * @param autoUnsubscribe Auto unsubscribe flag.
+ * @param internal Internal flag.
+ * @param notifyExisting Notify existing flag.
+ * @param oldValRequired Old value required flag.
+ * @param sync Synchronous flag.
+ * @param ignoreExpired Ignore expired event flag.
+ * @param loc Local flag.
+ * @return Continuous routine ID.
+ * @throws IgniteCheckedException In case of error.
+ */
+ private UUID executeQueryWithFilterFactory(CacheEntryUpdatedListener locLsnr,
+ final Factory<? extends CacheEntryEventFilter> rmtFilterFactory,
+ int bufSize,
+ long timeInterval,
+ boolean autoUnsubscribe,
+ boolean internal,
+ boolean notifyExisting,
+ boolean oldValRequired,
+ boolean sync,
+ boolean ignoreExpired,
+ boolean loc,
+ final boolean keepBinary,
+ boolean ignoreClassNotFound) throws IgniteCheckedException
+ {
+ cctx.checkSecurity(SecurityPermission.CACHE_READ);
+
+ int taskNameHash = !internal && cctx.kernalContext().security().enabled() ?
+ cctx.kernalContext().job().currentTaskNameHash() : 0;
+
+ boolean skipPrimaryCheck = loc && cctx.config().getCacheMode() == CacheMode.REPLICATED && cctx.affinityNode();
+
+ boolean v2 = rmtFilterFactory != null && useV2Protocol(cctx.discovery().allNodes());
+
+ GridContinuousHandler hnd;
+
+ if (v2)
+ hnd = new CacheContinuousQueryHandlerV2(
+ cctx.name(),
+ TOPIC_CACHE.topic(topicPrefix, cctx.localNodeId(), seq.getAndIncrement()),
+ locLsnr,
+ rmtFilterFactory,
+ internal,
+ notifyExisting,
+ oldValRequired,
+ sync,
+ ignoreExpired,
+ taskNameHash,
+ skipPrimaryCheck,
+ cctx.isLocal(),
+ keepBinary,
+ ignoreClassNotFound,
- (byte)0);
++ null);
+ else {
+ CacheEntryEventFilter fltr = null;
+
+ if (rmtFilterFactory != null) {
+ fltr = rmtFilterFactory.create();
+
+ if (!(fltr instanceof CacheEntryEventSerializableFilter))
+ throw new IgniteCheckedException("Topology has nodes of the old versions. In this case " +
+ "EntryEventFilter should implement org.apache.ignite.cache.CacheEntryEventSerializableFilter " +
+ "interface. Filter: " + fltr);
+ }
+
+ hnd = new CacheContinuousQueryHandler(
+ cctx.name(),
+ TOPIC_CACHE.topic(topicPrefix, cctx.localNodeId(), seq.getAndIncrement()),
+ locLsnr,
+ (CacheEntryEventSerializableFilter)fltr,
+ internal,
+ notifyExisting,
+ oldValRequired,
+ sync,
+ ignoreExpired,
+ taskNameHash,
+ skipPrimaryCheck,
+ cctx.isLocal(),
+ keepBinary,
+ ignoreClassNotFound);
+ }
+
+ return executeQuery0(locLsnr,
+ bufSize,
+ timeInterval,
+ autoUnsubscribe,
+ notifyExisting,
+ loc,
+ keepBinary,
+ hnd);
+ }
+
+ /**
+ * @param locLsnr Local listener.
+ * @param bufSize Buffer size.
+ * @param timeInterval Time interval.
+ * @param autoUnsubscribe Auto unsubscribe flag.
+ * @param notifyExisting Notify existing flag.
+ * @param loc Local flag.
+ * @param keepBinary Keep binary.
+ * @param hnd Handler.
+ * @return Continuous routine ID.
+ * @throws IgniteCheckedException In case of error.
+ */
+ private UUID executeQuery0(CacheEntryUpdatedListener locLsnr,
+ int bufSize,
+ long timeInterval,
+ boolean autoUnsubscribe,
+ boolean notifyExisting,
+ boolean loc,
+ final boolean keepBinary,
+ final GridContinuousHandler hnd)
+ throws IgniteCheckedException {
IgnitePredicate<ClusterNode> pred = (loc || cctx.config().getCacheMode() == CacheMode.LOCAL) ?
F.nodeForNodeId(cctx.localNodeId()) : F.<ClusterNode>alwaysTrue();
http://git-wip-us.apache.org/repos/asf/ignite/blob/846e8e5d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryRandomOperationsTest.java
----------------------------------------------------------------------
diff --cc modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryRandomOperationsTest.java
index 23b9d85,62ed66f..c18cf35
--- 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
@@@ -28,11 -28,11 +28,14 @@@ import java.util.SortedMap
import java.util.TreeMap;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
++import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import javax.cache.Cache;
import javax.cache.configuration.Factory;
import javax.cache.event.CacheEntryEvent;
++import javax.cache.event.CacheEntryEventFilter;
++import javax.cache.event.CacheEntryListenerException;
import javax.cache.event.CacheEntryUpdatedListener;
import javax.cache.integration.CacheLoaderException;
import javax.cache.integration.CacheWriterException;
@@@ -40,7 -40,7 +43,9 @@@ import javax.cache.processor.EntryProce
import javax.cache.processor.MutableEntry;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
++import org.apache.ignite.IgniteException;
import org.apache.ignite.cache.CacheAtomicityMode;
++import org.apache.ignite.cache.CacheEntryEventSerializableFilter;
import org.apache.ignite.cache.CacheMemoryMode;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.affinity.Affinity;
@@@ -55,6 -55,6 +60,7 @@@ import org.apache.ignite.internal.util.
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
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 org.apache.ignite.transactions.TransactionConcurrency;
@@@ -132,6 -132,6 +138,51 @@@ public class CacheContinuousQueryRandom
/**
* @throws Exception If failed.
*/
++ public void testFilterAndFactoryProvided() throws Exception {
++ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
++ 1,
++ ATOMIC,
++ ONHEAP_TIERED,
++ false);
++
++ final IgniteCache<Object, Object> cache = grid(0).getOrCreateCache(ccfg);
++
++ try {
++ final ContinuousQuery qry = new ContinuousQuery();
++
++ qry.setRemoteFilterFactory(new Factory<CacheEntryEventFilter>() {
++ @Override public CacheEntryEventFilter create() {
++ return null;
++ }
++ });
++
++ qry.setRemoteFilter(new CacheEntryEventSerializableFilter() {
++ @Override public boolean evaluate(CacheEntryEvent event) throws CacheEntryListenerException {
++ return false;
++ }
++ });
++
++ qry.setLocalListener(new CacheEntryUpdatedListener() {
++ @Override public void onUpdated(Iterable iterable) throws CacheEntryListenerException {
++ // No-op.
++ }
++ });
++
++ GridTestUtils.assertThrows(log, new Callable<Object>() {
++ @Override public Object call() throws Exception {
++ return cache.query(qry);
++ }
++ }, IgniteException.class, null);
++
++ }
++ finally {
++ cache.destroy();
++ }
++ }
++
++ /**
++ * @throws Exception If failed.
++ */
public void testAtomicClient() throws Exception {
CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
1,
http://git-wip-us.apache.org/repos/asf/ignite/blob/846e8e5d/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
----------------------------------------------------------------------
[15/20] ignite git commit: IGNITE-1186 WIP
Posted by nt...@apache.org.
IGNITE-1186 WIP
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/9ad476b2
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/9ad476b2
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/9ad476b2
Branch: refs/heads/ignite-1186
Commit: 9ad476b21a1f6f9d52d8efcaad346a4ac85ea73b
Parents: e80e906
Author: nikolay_tikhonov <nt...@gridgain.com>
Authored: Mon Feb 29 20:56:35 2016 +0300
Committer: nikolay_tikhonov <nt...@gridgain.com>
Committed: Mon Feb 29 20:56:35 2016 +0300
----------------------------------------------------------------------
.../ignite/cache/query/ContinuousQuery.java | 10 +-
.../internal/GridEventConsumeHandler.java | 6 +
.../internal/GridMessageListenHandler.java | 6 +
.../processors/cache/IgniteCacheProxy.java | 13 +-
.../continuous/CacheContinuousQueryHandler.java | 9 +-
.../CacheContinuousQueryHandlerV2.java | 20 +-
.../continuous/CacheContinuousQueryManager.java | 263 ++++-
.../continuous/GridContinuousHandler.java | 6 +
.../IgniteCacheEntryListenerAbstractTest.java | 66 +-
.../CacheContinuousQueryFactoryFilterTest.java | 1002 +++---------------
.../CacheContinuousQueryOperationP2PTest.java | 394 +++++++
...acheContinuousQueryRandomOperationsTest.java | 10 +-
.../p2p/CacheDeploymentEntryEventFilter.java | 33 +
.../CacheDeploymentEntryEventFilterFactory.java | 31 +
14 files changed, 924 insertions(+), 945 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/9ad476b2/modules/core/src/main/java/org/apache/ignite/cache/query/ContinuousQuery.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/ContinuousQuery.java b/modules/core/src/main/java/org/apache/ignite/cache/query/ContinuousQuery.java
index 452735e..3ea8f93 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/ContinuousQuery.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/ContinuousQuery.java
@@ -19,6 +19,7 @@ package org.apache.ignite.cache.query;
import javax.cache.Cache;
import javax.cache.configuration.Factory;
+import javax.cache.event.CacheEntryEventFilter;
import javax.cache.event.CacheEntryUpdatedListener;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.cache.CacheEntryEventSerializableFilter;
@@ -121,7 +122,7 @@ public final class ContinuousQuery<K, V> extends Query<Cache.Entry<K, V>> {
private CacheEntryEventSerializableFilter<K, V> rmtFilter;
/** Remote filter factory. */
- private Factory<? extends CacheEntryEventSerializableFilter<K, V>> rmtFilterFactory;
+ private Factory<? extends CacheEntryEventFilter<K, V>> rmtFilterFactory;
/** Time interval. */
private long timeInterval = DFLT_TIME_INTERVAL;
@@ -200,7 +201,10 @@ public final class ContinuousQuery<K, V> extends Query<Cache.Entry<K, V>> {
*
* @param rmtFilter Key-value filter.
* @return {@code this} for chaining.
+ *
+ * @deprecated Use {@link #setRemoteFilterFactory(Factory)} instead.
*/
+ @Deprecated
public ContinuousQuery<K, V> setRemoteFilter(CacheEntryEventSerializableFilter<K, V> rmtFilter) {
this.rmtFilter = rmtFilter;
@@ -228,7 +232,7 @@ public final class ContinuousQuery<K, V> extends Query<Cache.Entry<K, V>> {
* @return {@code this} for chaining.
*/
public ContinuousQuery<K, V> setRemoteFilterFactory(
- Factory<? extends CacheEntryEventSerializableFilter<K, V>> rmtFilterFactory) {
+ Factory<? extends CacheEntryEventFilter<K, V>> rmtFilterFactory) {
this.rmtFilterFactory = rmtFilterFactory;
return this;
@@ -239,7 +243,7 @@ public final class ContinuousQuery<K, V> extends Query<Cache.Entry<K, V>> {
*
* @return Remote filter.
*/
- public Factory<? extends CacheEntryEventSerializableFilter<K, V>> getRemoteFilterFactory() {
+ public Factory<? extends CacheEntryEventFilter<K, V>> getRemoteFilterFactory() {
return rmtFilterFactory;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9ad476b2/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java
index e2b1184..924a8ea 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java
@@ -26,6 +26,7 @@ import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import java.util.UUID;
+import javax.cache.event.CacheEntryEventFilter;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.events.CacheEvent;
@@ -141,6 +142,11 @@ class GridEventConsumeHandler implements GridContinuousHandler {
}
/** {@inheritDoc} */
+ @Override public CacheEntryEventFilter getEventFilter() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
@Override public RegisterStatus register(final UUID nodeId, final UUID routineId, final GridKernalContext ctx)
throws IgniteCheckedException {
assert nodeId != null;
http://git-wip-us.apache.org/repos/asf/ignite/blob/9ad476b2/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java
index 402365c..e157c98 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java
@@ -24,6 +24,7 @@ import java.io.ObjectOutput;
import java.util.Collection;
import java.util.Map;
import java.util.UUID;
+import javax.cache.event.CacheEntryEventFilter;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.managers.deployment.GridDeployment;
import org.apache.ignite.internal.managers.deployment.GridDeploymentInfoBean;
@@ -130,6 +131,11 @@ public class GridMessageListenHandler implements GridContinuousHandler {
}
/** {@inheritDoc} */
+ @Override public CacheEntryEventFilter getEventFilter() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
@Override public RegisterStatus register(UUID nodeId, UUID routineId, final GridKernalContext ctx)
throws IgniteCheckedException {
ctx.io().addUserMessageListener(topic, pred);
http://git-wip-us.apache.org/repos/asf/ignite/blob/9ad476b2/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
index 9e9b985..690e0b4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
@@ -97,16 +97,6 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
/** */
private static final long serialVersionUID = 0L;
- /** */
- private static final IgniteBiPredicate ACCEPT_ALL = new IgniteBiPredicate() {
- /** */
- private static final long serialVersionUID = -1640538788290240617L;
-
- @Override public boolean apply(Object k, Object v) {
- return true;
- }
- };
-
/** Context. */
private GridCacheContext<K, V> ctx;
@@ -565,6 +555,9 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
if (qry.getLocalListener() == null)
throw new IgniteException("Mandatory local listener is not set for the query: " + qry);
+ if (qry.getRemoteFilter() != null && qry.getRemoteFilterFactory() != null)
+ throw new IgniteException("Should be used either RemoterFilter or RemoteFilterFactory.");
+
try {
final UUID routineId = ctx.continuousQueries().executeQuery(
qry.getLocalListener(),
http://git-wip-us.apache.org/repos/asf/ignite/blob/9ad476b2/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
index 47f5c52..393f7fb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
@@ -25,7 +25,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -263,7 +262,7 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
if (locLsnr != null)
ctx.resource().injectGeneric(locLsnr);
- final CacheEntryEventFilter filter = getRemoteFilter();
+ final CacheEntryEventFilter filter = getEventFilter();
if (filter != null)
ctx.resource().injectGeneric(filter);
@@ -521,10 +520,8 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
return mgr.registerListener(routineId, lsnr, internal);
}
- /**
- * @return Remote filter.
- */
- protected CacheEntryEventFilter<K, V> getRemoteFilter() {
+ /** {@inheritDoc} */
+ public CacheEntryEventFilter getEventFilter() {
return rmtFilter;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9ad476b2/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandlerV2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandlerV2.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandlerV2.java
index 4573e6c..628e1c3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandlerV2.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandlerV2.java
@@ -26,8 +26,10 @@ import javax.cache.configuration.Factory;
import javax.cache.event.CacheEntryEventFilter;
import javax.cache.event.CacheEntryUpdatedListener;
import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.cache.CacheEntryEventSerializableFilter;
import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.IgniteDeploymentCheckedException;
+import org.apache.ignite.internal.managers.deployment.GridDeployment;
+import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryManager.JCacheRemoteQueryFactory;
import org.apache.ignite.internal.processors.continuous.GridContinuousHandler;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
@@ -40,13 +42,13 @@ public class CacheContinuousQueryHandlerV2<K, V> extends CacheContinuousQueryHan
private static final long serialVersionUID = 0L;
/** Remote filter factory. */
- private Factory<? extends CacheEntryEventSerializableFilter<K, V>> rmtFilterFactory;
+ private Factory<? extends CacheEntryEventFilter> rmtFilterFactory;
/** Deployable object for filter factory. */
private DeployableObject rmtFilterFactoryDep;
/** */
- protected transient CacheEntryEventFilter<K, V> rmtNonSerFilter;
+ protected transient CacheEntryEventFilter filter;
/**
* Required by {@link Externalizable}.
@@ -76,7 +78,7 @@ public class CacheContinuousQueryHandlerV2<K, V> extends CacheContinuousQueryHan
String cacheName,
Object topic,
CacheEntryUpdatedListener<K, V> locLsnr,
- Factory<? extends CacheEntryEventSerializableFilter<K, V>> rmtFilterFactory,
+ Factory<? extends CacheEntryEventFilter<K, V>> rmtFilterFactory,
boolean internal,
boolean notifyExisting,
boolean oldValRequired,
@@ -108,14 +110,14 @@ public class CacheContinuousQueryHandlerV2<K, V> extends CacheContinuousQueryHan
}
/** {@inheritDoc} */
- @Override protected CacheEntryEventFilter<K, V> getRemoteFilter() {
- if (rmtNonSerFilter == null) {
+ @Override public CacheEntryEventFilter getEventFilter() {
+ if (filter == null) {
assert rmtFilterFactory != null;
- rmtNonSerFilter = rmtFilterFactory.create();
+ filter = rmtFilterFactory.create();
}
- return rmtNonSerFilter;
+ return filter;
}
/** {@inheritDoc} */
@@ -168,6 +170,6 @@ public class CacheContinuousQueryHandlerV2<K, V> extends CacheContinuousQueryHan
if (b)
rmtFilterFactoryDep = (DeployableObject)in.readObject();
else
- rmtFilterFactory = (Factory<CacheEntryEventSerializableFilter<K, V>>)in.readObject();
+ rmtFilterFactory = (Factory)in.readObject();
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9ad476b2/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
index fd4d71e..33d6d59 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
@@ -21,10 +21,11 @@ import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+import java.io.Serializable;
import java.util.ArrayList;
-import java.util.Map;
import java.util.Collection;
import java.util.Iterator;
+import java.util.Map;
import java.util.NoSuchElementException;
import java.util.UUID;
import java.util.concurrent.ConcurrentMap;
@@ -415,29 +416,44 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
* @throws IgniteCheckedException In case of error.
*/
public UUID executeQuery(CacheEntryUpdatedListener locLsnr,
- CacheEntryEventSerializableFilter rmtFilter,
- Factory<? extends CacheEntryEventSerializableFilter> rmtFilterFactory,
+ @Nullable CacheEntryEventSerializableFilter rmtFilter,
+ @Nullable Factory<? extends CacheEntryEventSerializableFilter> rmtFilterFactory,
int bufSize,
long timeInterval,
boolean autoUnsubscribe,
boolean loc,
boolean keepBinary) throws IgniteCheckedException
{
- return executeQuery0(
- locLsnr,
- rmtFilter,
- rmtFilterFactory,
- bufSize,
- timeInterval,
- autoUnsubscribe,
- false,
- false,
- true,
- false,
- true,
- loc,
- keepBinary,
- false);
+ if (rmtFilterFactory != null)
+ return executeQueryWithFilterFactory(
+ locLsnr,
+ rmtFilterFactory,
+ bufSize,
+ timeInterval,
+ autoUnsubscribe,
+ false,
+ false,
+ true,
+ false,
+ true,
+ loc,
+ keepBinary,
+ false);
+ else
+ return executeQueryWithFilter(
+ locLsnr,
+ rmtFilter,
+ bufSize,
+ timeInterval,
+ autoUnsubscribe,
+ false,
+ false,
+ true,
+ false,
+ true,
+ loc,
+ keepBinary,
+ false);
}
/**
@@ -455,10 +471,9 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
boolean ignoreClassNotFound)
throws IgniteCheckedException
{
- return executeQuery0(
+ return executeQueryWithFilter(
locLsnr,
rmtFilter,
- null,
ContinuousQuery.DFLT_PAGE_SIZE,
ContinuousQuery.DFLT_TIME_INTERVAL,
ContinuousQuery.DFLT_AUTO_UNSUBSCRIBE,
@@ -556,8 +571,162 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
* @return Continuous routine ID.
* @throws IgniteCheckedException In case of error.
*/
- private UUID executeQuery0(CacheEntryUpdatedListener locLsnr,
+ private UUID executeQueryWithFilter(CacheEntryUpdatedListener locLsnr,
final CacheEntryEventSerializableFilter rmtFilter,
+ int bufSize,
+ long timeInterval,
+ boolean autoUnsubscribe,
+ boolean internal,
+ boolean notifyExisting,
+ boolean oldValRequired,
+ boolean sync,
+ boolean ignoreExpired,
+ boolean loc,
+ final boolean keepBinary,
+ boolean ignoreClassNotFound) throws IgniteCheckedException
+ {
+ cctx.checkSecurity(SecurityPermission.CACHE_READ);
+
+ int taskNameHash = !internal && cctx.kernalContext().security().enabled() ?
+ cctx.kernalContext().job().currentTaskNameHash() : 0;
+
+ boolean skipPrimaryCheck = loc && cctx.config().getCacheMode() == CacheMode.REPLICATED && cctx.affinityNode();
+
+ GridContinuousHandler hnd = new CacheContinuousQueryHandler(
+ cctx.name(),
+ TOPIC_CACHE.topic(topicPrefix, cctx.localNodeId(), seq.getAndIncrement()),
+ locLsnr,
+ rmtFilter,
+ internal,
+ notifyExisting,
+ oldValRequired,
+ sync,
+ ignoreExpired,
+ taskNameHash,
+ skipPrimaryCheck,
+ cctx.isLocal(),
+ keepBinary,
+ ignoreClassNotFound);
+
+ return executeQuery0(locLsnr,
+ bufSize,
+ timeInterval,
+ autoUnsubscribe,
+ notifyExisting,
+ loc,
+ keepBinary,
+ hnd);
+ }
+
+
+ /**
+ * @param locLsnr Local listener.
+ * @param bufSize Buffer size.
+ * @param timeInterval Time interval.
+ * @param autoUnsubscribe Auto unsubscribe flag.
+ * @param internal Internal flag.
+ * @param notifyExisting Notify existing flag.
+ * @param oldValRequired Old value required flag.
+ * @param sync Synchronous flag.
+ * @param ignoreExpired Ignore expired event flag.
+ * @param loc Local flag.
+ * @return Continuous routine ID.
+ * @throws IgniteCheckedException In case of error.
+ */
+ private UUID executeJCacheQueryFactory(CacheEntryUpdatedListener locLsnr,
+ final JCacheRemoteQueryFactory rmtFilterFactory,
+ int bufSize,
+ long timeInterval,
+ boolean autoUnsubscribe,
+ boolean internal,
+ boolean notifyExisting,
+ boolean oldValRequired,
+ boolean sync,
+ boolean ignoreExpired,
+ boolean loc,
+ final boolean keepBinary,
+ boolean ignoreClassNotFound) throws IgniteCheckedException
+ {
+ cctx.checkSecurity(SecurityPermission.CACHE_READ);
+
+ int taskNameHash = !internal && cctx.kernalContext().security().enabled() ?
+ cctx.kernalContext().job().currentTaskNameHash() : 0;
+
+ boolean skipPrimaryCheck = loc && cctx.config().getCacheMode() == CacheMode.REPLICATED && cctx.affinityNode();
+
+ boolean v2 = useV2Protocol(cctx.discovery().allNodes());
+
+ GridContinuousHandler hnd;
+
+ if (v2)
+ hnd = new CacheContinuousQueryHandlerV2(
+ cctx.name(),
+ TOPIC_CACHE.topic(topicPrefix, cctx.localNodeId(), seq.getAndIncrement()),
+ locLsnr,
+ rmtFilterFactory,
+ internal,
+ notifyExisting,
+ oldValRequired,
+ sync,
+ ignoreExpired,
+ taskNameHash,
+ skipPrimaryCheck,
+ cctx.isLocal(),
+ keepBinary,
+ ignoreClassNotFound);
+ else {
+ JCacheQueryRemoteFilter fltr = null;
+
+ if (rmtFilterFactory != null) {
+ fltr = rmtFilterFactory.create();
+
+ if (!(fltr.impl instanceof Serializable))
+ throw new IgniteCheckedException("Topology has nodes of the old versions. In this case " +
+ "EntryEventFilter must implement java.io.Serializable interface. Filter: " + fltr.impl);
+ }
+
+ hnd = new CacheContinuousQueryHandler(
+ cctx.name(),
+ TOPIC_CACHE.topic(topicPrefix, cctx.localNodeId(), seq.getAndIncrement()),
+ locLsnr,
+ fltr,
+ internal,
+ notifyExisting,
+ oldValRequired,
+ sync,
+ ignoreExpired,
+ taskNameHash,
+ skipPrimaryCheck,
+ cctx.isLocal(),
+ keepBinary,
+ ignoreClassNotFound);
+ }
+
+ return executeQuery0(locLsnr,
+ bufSize,
+ timeInterval,
+ autoUnsubscribe,
+ notifyExisting,
+ loc,
+ keepBinary,
+ hnd);
+ }
+
+ /**
+ * @param locLsnr Local listener.
+ * @param bufSize Buffer size.
+ * @param timeInterval Time interval.
+ * @param autoUnsubscribe Auto unsubscribe flag.
+ * @param internal Internal flag.
+ * @param notifyExisting Notify existing flag.
+ * @param oldValRequired Old value required flag.
+ * @param sync Synchronous flag.
+ * @param ignoreExpired Ignore expired event flag.
+ * @param loc Local flag.
+ * @return Continuous routine ID.
+ * @throws IgniteCheckedException In case of error.
+ */
+ private UUID executeQueryWithFilterFactory(CacheEntryUpdatedListener locLsnr,
final Factory<? extends CacheEntryEventFilter> rmtFilterFactory,
int bufSize,
long timeInterval,
@@ -582,9 +751,7 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
GridContinuousHandler hnd;
- if (v2) {
- assert rmtFilter == null : rmtFilter;
-
+ if (v2)
hnd = new CacheContinuousQueryHandlerV2(
cctx.name(),
TOPIC_CACHE.topic(topicPrefix, cctx.localNodeId(), seq.getAndIncrement()),
@@ -600,7 +767,6 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
cctx.isLocal(),
keepBinary,
ignoreClassNotFound);
- }
else {
CacheEntryEventFilter fltr = null;
@@ -608,8 +774,9 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
fltr = rmtFilterFactory.create();
if (!(fltr instanceof CacheEntryEventSerializableFilter))
- throw new IgniteCheckedException("Cache entry event filter must implement " +
- "org.apache.ignite.cache.CacheEntryEventSerializableFilter: " + fltr);
+ throw new IgniteCheckedException("Topology has nodes of the old versions. In this case " +
+ "EntryEventFilter should implement org.apache.ignite.cache.CacheEntryEventSerializableFilter " +
+ "interface. Filter: " + fltr);
}
hnd = new CacheContinuousQueryHandler(
@@ -629,6 +796,37 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
ignoreClassNotFound);
}
+ return executeQuery0(locLsnr,
+ bufSize,
+ timeInterval,
+ autoUnsubscribe,
+ notifyExisting,
+ loc,
+ keepBinary,
+ hnd);
+ }
+
+ /**
+ * @param locLsnr Local listener.
+ * @param bufSize Buffer size.
+ * @param timeInterval Time interval.
+ * @param autoUnsubscribe Auto unsubscribe flag.
+ * @param notifyExisting Notify existing flag.
+ * @param loc Local flag.
+ * @param keepBinary Keep binary.
+ * @param hnd Handler.
+ * @return Continuous routine ID.
+ * @throws IgniteCheckedException In case of error.
+ */
+ private UUID executeQuery0(CacheEntryUpdatedListener locLsnr,
+ int bufSize,
+ long timeInterval,
+ boolean autoUnsubscribe,
+ boolean notifyExisting,
+ boolean loc,
+ final boolean keepBinary,
+ final GridContinuousHandler hnd)
+ throws IgniteCheckedException {
IgnitePredicate<ClusterNode> pred = (loc || cctx.config().getCacheMode() == CacheMode.LOCAL) ?
F.nodeForNodeId(cctx.localNodeId()) : F.<ClusterNode>alwaysTrue();
@@ -694,7 +892,7 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
cctx.kernalContext().cache().jcache(cctx.name()),
cctx, entry);
- if (rmtFilter != null && !rmtFilter.evaluate(next))
+ if (hnd.getEventFilter() != null && !hnd.getEventFilter().evaluate(next))
next = null;
}
}
@@ -825,9 +1023,8 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
locLsnrImpl,
log);
- routineId = executeQuery0(
+ routineId = executeJCacheQueryFactory(
locLsnr,
- null,
new JCacheRemoteQueryFactory(cfg.getCacheEntryEventFilterFactory(), types),
ContinuousQuery.DFLT_PAGE_SIZE,
ContinuousQuery.DFLT_TIME_INTERVAL,
@@ -1026,12 +1223,12 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
/**
*
*/
- private static class JCacheRemoteQueryFactory implements Factory<CacheEntryEventFilter> {
+ protected static class JCacheRemoteQueryFactory implements Factory<CacheEntryEventFilter> {
/** */
private static final long serialVersionUID = 0L;
/** Factory. */
- private Factory<CacheEntryEventFilter> impl;
+ protected Factory<CacheEntryEventFilter> impl;
/** */
private byte types;
@@ -1046,7 +1243,7 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
}
/** {@inheritDoc} */
- @Override public CacheEntryEventFilter create() {
+ @Override public JCacheQueryRemoteFilter create() {
return new JCacheQueryRemoteFilter(impl != null ? impl.create() : null, types);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9ad476b2/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousHandler.java
index 8cd30a8..232e1ff 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousHandler.java
@@ -21,6 +21,7 @@ import java.io.Externalizable;
import java.util.Collection;
import java.util.Map;
import java.util.UUID;
+import javax.cache.event.CacheEntryEventFilter;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
@@ -158,4 +159,9 @@ public interface GridContinuousHandler extends Externalizable, Cloneable {
* @param topVer Topology version.
*/
public void updateCounters(AffinityTopologyVersion topVer, Map<Integer, Long> cntrs);
+
+ /**
+ * @return Cache entry filter.
+ */
+ public CacheEntryEventFilter getEventFilter();
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/9ad476b2/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java
index 62a4153..e61127d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java
@@ -42,6 +42,7 @@ import javax.cache.configuration.FactoryBuilder;
import javax.cache.configuration.MutableCacheEntryListenerConfiguration;
import javax.cache.event.CacheEntryCreatedListener;
import javax.cache.event.CacheEntryEvent;
+import javax.cache.event.CacheEntryEventFilter;
import javax.cache.event.CacheEntryExpiredListener;
import javax.cache.event.CacheEntryListener;
import javax.cache.event.CacheEntryListenerException;
@@ -62,6 +63,7 @@ import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.processors.continuous.GridContinuousProcessor;
import org.apache.ignite.internal.util.lang.GridAbsPredicate;
+import org.apache.ignite.internal.util.typedef.PA;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.testframework.GridTestUtils;
@@ -99,6 +101,9 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
/** */
private boolean useObjects;
+ /** */
+ private static AtomicBoolean serialized = new AtomicBoolean(false);
+
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception {
@@ -138,6 +143,8 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
assertEquals(0, syncMsgFuts.size());
}
+
+ serialized.set(false);
}
/**
@@ -439,18 +446,23 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
jcache(0).registerCacheEntryListener(new MutableCacheEntryListenerConfiguration<>(
FactoryBuilder.factoryOf(lsnr),
- null,
+ new SerializableFactory(),
true,
false
));
try {
startGrid(gridCount());
+
+ jcache(0).put(1, 1);
}
finally {
stopGrid(gridCount());
}
+ jcache(0).put(2, 2);
+
+ assertFalse(IgniteCacheEntryListenerAbstractTest.serialized.get());
assertFalse(serialized.get());
}
@@ -527,16 +539,16 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
/**
* @throws Exception If failed.
*/
- public void testEventsObjectKeyValue() throws Exception {
+ public void _testEventsObjectKeyValue() throws Exception {
useObjects = true;
- testEvents();
+ _testEvents();
}
/**
* @throws Exception If failed.
*/
- public void testEvents() throws Exception {
+ public void _testEvents() throws Exception {
IgniteCache<Object, Object> cache = jcache();
Map<Object, Object> vals = new HashMap<>();
@@ -1126,9 +1138,9 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
/**
*
*/
- private static class TestFilterFactory implements Factory<CacheEntryEventSerializableFilter<Object, Object>> {
+ private static class TestFilterFactory implements Factory<CacheEntryEventFilter<Object, Object>> {
/** {@inheritDoc} */
- @Override public CacheEntryEventSerializableFilter<Object, Object> create() {
+ @Override public CacheEntryEventFilter<Object, Object> create() {
return new TestFilter();
}
}
@@ -1180,7 +1192,7 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
/**
*
*/
- private static class TestFilter implements CacheEntryEventSerializableFilter<Object, Object> {
+ private static class TestFilter implements CacheEntryEventFilter<Object, Object>, Externalizable {
/** {@inheritDoc} */
@Override public boolean evaluate(CacheEntryEvent<?, ?> evt) {
assert evt != null;
@@ -1197,6 +1209,16 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
return key % 2 == 0;
}
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ throw new UnsupportedOperationException("Filter muns't be marshaled.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ throw new UnsupportedOperationException("Filter muns't be unmarshaled.");
+ }
}
/**
@@ -1351,6 +1373,36 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
}
/**
+ *
+ */
+ public static class SerializableFactory implements Factory<NonSerializableFilter> {
+ /** {@inheritDoc} */
+ @Override public NonSerializableFilter create() {
+ return new NonSerializableFilter();
+ }
+ }
+
+ /**
+ *
+ */
+ public static class NonSerializableFilter implements CacheEntryEventFilter<Object, Object>, Externalizable {
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ serialized.set(true);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ serialized.set(true);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean evaluate(CacheEntryEvent<?, ?> event) throws CacheEntryListenerException {
+ return true;
+ }
+ }
+
+ /**
*/
public static class NonSerializableListener implements CacheEntryCreatedListener<Object, Object>, Externalizable {
/** */
http://git-wip-us.apache.org/repos/asf/ignite/blob/9ad476b2/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFactoryFilterTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFactoryFilterTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFactoryFilterTest.java
index 2ff2b79..d6d30ae 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFactoryFilterTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFactoryFilterTest.java
@@ -21,69 +21,47 @@ import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
-import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
-import java.util.SortedMap;
-import java.util.TreeMap;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-import javax.cache.Cache;
+import java.util.concurrent.ThreadLocalRandom;
+import javax.cache.configuration.CacheEntryListenerConfiguration;
import javax.cache.configuration.Factory;
import javax.cache.configuration.FactoryBuilder;
-import javax.cache.configuration.FactoryBuilder.SingletonFactory;
+import javax.cache.configuration.MutableCacheEntryListenerConfiguration;
+import javax.cache.event.CacheEntryCreatedListener;
import javax.cache.event.CacheEntryEvent;
-import javax.cache.event.CacheEntryEventFilter;
+import javax.cache.event.CacheEntryExpiredListener;
import javax.cache.event.CacheEntryListenerException;
+import javax.cache.event.CacheEntryRemovedListener;
import javax.cache.event.CacheEntryUpdatedListener;
-import javax.cache.integration.CacheLoaderException;
-import javax.cache.integration.CacheWriterException;
-import javax.cache.processor.EntryProcessor;
-import javax.cache.processor.MutableEntry;
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.CacheMemoryMode;
-import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.affinity.Affinity;
import org.apache.ignite.cache.query.CacheQueryEntryEvent;
import org.apache.ignite.cache.query.ContinuousQuery;
import org.apache.ignite.cache.query.QueryCursor;
-import org.apache.ignite.cache.store.CacheStore;
-import org.apache.ignite.cache.store.CacheStoreAdapter;
import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryRandomOperationsTest.QueryTestKey;
+import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryRandomOperationsTest.QueryTestValue;
+import org.apache.ignite.internal.util.typedef.T2;
import org.apache.ignite.transactions.Transaction;
import org.apache.ignite.transactions.TransactionConcurrency;
import org.apache.ignite.transactions.TransactionIsolation;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
-import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.PRIMARY;
-import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
-import static org.apache.ignite.cache.CacheMemoryMode.OFFHEAP_TIERED;
-import static org.apache.ignite.cache.CacheMemoryMode.OFFHEAP_VALUES;
-import static org.apache.ignite.cache.CacheMemoryMode.ONHEAP_TIERED;
-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.CacheContinuousQueryFactoryFilterTest.ContinuousDeploy.ALL;
-import static org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFactoryFilterTest.ContinuousDeploy.CLIENT;
-import static org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFactoryFilterTest.ContinuousDeploy.SERVER;
import static org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFactoryFilterTest.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.TransactionIsolation.READ_COMMITTED;
import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
import static org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE;
@@ -91,10 +69,7 @@ import static org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE;
/**
*
*/
-public class CacheContinuousQueryFactoryFilterTest extends GridCommonAbstractTest {
- /** */
- private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
-
+public class CacheContinuousQueryFactoryFilterTest extends CacheContinuousQueryRandomOperationsTest {
/** */
private static final int NODES = 5;
@@ -105,488 +80,10 @@ public class CacheContinuousQueryFactoryFilterTest extends GridCommonAbstractTes
private static final int VALS = 10;
/** */
- public static final int ITERATION_CNT = 100;
-
- /** */
- private boolean client;
+ public static final int ITERATION_CNT = 40;
/** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
- IgniteConfiguration cfg = super.getConfiguration(gridName);
-
- ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
-
- cfg.setClientMode(client);
-
- return cfg;
- }
-
- /** {@inheritDoc} */
- @Override protected void beforeTestsStarted() throws Exception {
- super.beforeTestsStarted();
-
- startGridsMultiThreaded(NODES - 1);
-
- client = true;
-
- startGrid(NODES - 1);
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
- stopAllGrids();
-
- super.afterTestsStopped();
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testAtomicClient() throws Exception {
- CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
- 1,
- ATOMIC,
- ONHEAP_TIERED,
- false);
-
- testContinuousQuery(ccfg, CLIENT);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testAtomic() throws Exception {
- CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
- 1,
- ATOMIC,
- ONHEAP_TIERED,
- false);
-
- testContinuousQuery(ccfg, SERVER);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testAtomicAllNodes() throws Exception {
- CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
- 1,
- ATOMIC,
- ONHEAP_TIERED,
- false);
-
- testContinuousQuery(ccfg, ALL);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testAtomicReplicated() throws Exception {
- CacheConfiguration<Object, Object> ccfg = cacheConfiguration(REPLICATED,
- 0,
- ATOMIC,
- ONHEAP_TIERED,
- false);
-
- testContinuousQuery(ccfg, SERVER);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testAtomicReplicatedAllNodes() throws Exception {
- CacheConfiguration<Object, Object> ccfg = cacheConfiguration(REPLICATED,
- 0,
- ATOMIC,
- ONHEAP_TIERED,
- false);
-
- testContinuousQuery(ccfg, ALL);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testAtomicReplicatedClient() throws Exception {
- CacheConfiguration<Object, Object> ccfg = cacheConfiguration(REPLICATED,
- 0,
- ATOMIC,
- ONHEAP_TIERED,
- false);
-
- testContinuousQuery(ccfg, CLIENT);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testAtomicOffheapValues() throws Exception {
- CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
- 1,
- ATOMIC,
- OFFHEAP_VALUES,
- false);
-
- testContinuousQuery(ccfg, SERVER);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testAtomicOffheapValuesAllNodes() throws Exception {
- CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
- 1,
- ATOMIC,
- OFFHEAP_VALUES,
- false);
-
- testContinuousQuery(ccfg, ALL);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testAtomicOffheapValuesClient() throws Exception {
- CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
- 1,
- ATOMIC,
- OFFHEAP_VALUES,
- false);
-
- testContinuousQuery(ccfg, CLIENT);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testAtomicOffheapTiered() throws Exception {
- CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
- 1,
- ATOMIC,
- OFFHEAP_TIERED,
- false);
-
- testContinuousQuery(ccfg, SERVER);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testAtomicOffheapTieredAllNodes() throws Exception {
- CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
- 1,
- ATOMIC,
- OFFHEAP_TIERED,
- false);
-
- testContinuousQuery(ccfg, ALL);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testAtomicOffheapTieredClient() throws Exception {
- CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
- 1,
- ATOMIC,
- OFFHEAP_TIERED,
- false);
-
- testContinuousQuery(ccfg, CLIENT);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testAtomicNoBackups() throws Exception {
- CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
- 0,
- ATOMIC,
- ONHEAP_TIERED,
- false);
-
- testContinuousQuery(ccfg, SERVER);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testAtomicNoBackupsAllNodes() throws Exception {
- CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
- 0,
- ATOMIC,
- ONHEAP_TIERED,
- false);
-
- testContinuousQuery(ccfg, ALL);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testAtomicNoBackupsClient() throws Exception {
- CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
- 0,
- ATOMIC,
- ONHEAP_TIERED,
- false);
-
- testContinuousQuery(ccfg, CLIENT);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testTx() throws Exception {
- CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
- 1,
- TRANSACTIONAL,
- ONHEAP_TIERED,
- false);
-
- testContinuousQuery(ccfg, SERVER);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testTxAllNodes() throws Exception {
- CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
- 1,
- TRANSACTIONAL,
- ONHEAP_TIERED,
- false);
-
- testContinuousQuery(ccfg, ALL);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testTxExplicit() throws Exception {
- CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
- 1,
- TRANSACTIONAL,
- ONHEAP_TIERED,
- false);
-
- testContinuousQuery(ccfg, SERVER);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testTxClient() throws Exception {
- CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
- 1,
- TRANSACTIONAL,
- ONHEAP_TIERED,
- false);
-
- testContinuousQuery(ccfg, CLIENT);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testTxClientExplicit() throws Exception {
- CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
- 1,
- TRANSACTIONAL,
- ONHEAP_TIERED,
- false);
-
- testContinuousQuery(ccfg, CLIENT);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testTxReplicated() throws Exception {
- CacheConfiguration<Object, Object> ccfg = cacheConfiguration(REPLICATED,
- 0,
- TRANSACTIONAL,
- ONHEAP_TIERED,
- false);
-
- testContinuousQuery(ccfg, SERVER);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testTxReplicatedClient() throws Exception {
- CacheConfiguration<Object, Object> ccfg = cacheConfiguration(REPLICATED,
- 0,
- TRANSACTIONAL,
- ONHEAP_TIERED,
- false);
-
- testContinuousQuery(ccfg, CLIENT);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testTxOffheapValues() throws Exception {
- CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
- 1,
- TRANSACTIONAL,
- OFFHEAP_VALUES,
- false);
-
- testContinuousQuery(ccfg, SERVER);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testTxOffheapValuesAllNodes() throws Exception {
- CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
- 1,
- TRANSACTIONAL,
- OFFHEAP_VALUES,
- false);
-
- testContinuousQuery(ccfg, ALL);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testTxOffheapValuesExplicit() throws Exception {
- CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
- 1,
- TRANSACTIONAL,
- OFFHEAP_VALUES,
- false);
-
- testContinuousQuery(ccfg, SERVER);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testTxOffheapValuesClient() throws Exception {
- CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
- 1,
- TRANSACTIONAL,
- OFFHEAP_VALUES,
- false);
-
- testContinuousQuery(ccfg, CLIENT);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testTxOffheapTiered() throws Exception {
- CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
- 1,
- TRANSACTIONAL,
- OFFHEAP_TIERED,
- false);
-
- testContinuousQuery(ccfg, SERVER);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testTxOffheapTieredAllNodes() throws Exception {
- CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
- 1,
- TRANSACTIONAL,
- OFFHEAP_TIERED,
- false);
-
- testContinuousQuery(ccfg, ALL);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testTxOffheapTieredClient() throws Exception {
- CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
- 1,
- TRANSACTIONAL,
- OFFHEAP_TIERED,
- false);
-
- testContinuousQuery(ccfg, CLIENT);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testTxOffheapTieredClientExplicit() throws Exception {
- CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
- 1,
- TRANSACTIONAL,
- OFFHEAP_TIERED,
- false);
-
- testContinuousQuery(ccfg, CLIENT);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testTxNoBackups() throws Exception {
- CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
- 0,
- TRANSACTIONAL,
- ONHEAP_TIERED,
- false);
-
- testContinuousQuery(ccfg, SERVER);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testTxNoBackupsAllNodes() throws Exception {
- CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
- 0,
- TRANSACTIONAL,
- ONHEAP_TIERED,
- false);
-
- testContinuousQuery(ccfg, ALL);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testTxNoBackupsExplicit() throws Exception {
- CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
- 0,
- TRANSACTIONAL,
- ONHEAP_TIERED,
- false);
-
- testContinuousQuery(ccfg, SERVER);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testTxNoBackupsClient() throws Exception {
- CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
- 0,
- TRANSACTIONAL,
- ONHEAP_TIERED,
- false);
-
- testContinuousQuery(ccfg, CLIENT);
- }
-
- /**
- * @param ccfg Cache configuration.
- * @param deploy The place where continuous query will be started.
- * @throws Exception If failed.
- */
- private void testContinuousQuery(CacheConfiguration<Object, Object> ccfg, ContinuousDeploy deploy)
+ @Override protected void testContinuousQuery(CacheConfiguration<Object, Object> ccfg, ContinuousDeploy deploy)
throws Exception {
ignite(0).createCache(ccfg);
@@ -601,70 +98,18 @@ public class CacheContinuousQueryFactoryFilterTest extends GridCommonAbstractTes
Collection<QueryCursor<?>> curs = new ArrayList<>();
- if (deploy == CLIENT) {
- ContinuousQuery<QueryTestKey, QueryTestValue> qry = new ContinuousQuery<>();
-
- final BlockingQueue<CacheEntryEvent<?, ?>> evtsQueue = new ArrayBlockingQueue<>(50_000);
-
- qry.setLocalListener(new CacheEntryUpdatedListener<QueryTestKey, QueryTestValue>() {
- @Override public void onUpdated(Iterable<CacheEntryEvent<? extends QueryTestKey,
- ? extends QueryTestValue>> evts) throws CacheEntryListenerException {
- for (CacheEntryEvent<?, ?> evt : evts)
- evtsQueue.add(evt);
- }
- });
-
- qry.setRemoteFilterFactory(new FilterFactory());
-
- evtsQueues.add(evtsQueue);
+ Collection<T2<Integer, MutableCacheEntryListenerConfiguration>> lsnrCfgs = new ArrayList<>();
- QueryCursor<?> cur = grid(NODES - 1).cache(ccfg.getName()).query(qry);
-
- curs.add(cur);
- }
- else if (deploy == SERVER) {
- ContinuousQuery<QueryTestKey, QueryTestValue> qry = new ContinuousQuery<>();
-
- final BlockingQueue<CacheEntryEvent<?, ?>> evtsQueue = new ArrayBlockingQueue<>(50_000);
-
- qry.setLocalListener(new CacheEntryUpdatedListener<QueryTestKey, QueryTestValue>() {
- @Override public void onUpdated(Iterable<CacheEntryEvent<? extends QueryTestKey,
- ? extends QueryTestValue>> evts) throws CacheEntryListenerException {
- for (CacheEntryEvent<?, ?> evt : evts)
- evtsQueue.add(evt);
- }
- });
-
- qry.setRemoteFilterFactory(new FilterFactory());
-
- evtsQueues.add(evtsQueue);
-
- QueryCursor<?> cur = grid(rnd.nextInt(NODES - 1)).cache(ccfg.getName()).query(qry);
-
- curs.add(cur);
- }
+ if (deploy == CLIENT)
+ evtsQueues.add(registerListener(ccfg.getName(), NODES - 1, curs, lsnrCfgs, rnd.nextBoolean()));
+ else if (deploy == SERVER)
+ evtsQueues.add(registerListener(ccfg.getName(), rnd.nextInt(NODES - 1), curs, lsnrCfgs,
+ rnd.nextBoolean()));
else {
- for (int i = 0; i < NODES - 1; i++) {
- ContinuousQuery<QueryTestKey, QueryTestValue> qry = new ContinuousQuery<>();
+ boolean isSync = rnd.nextBoolean();
- final BlockingQueue<CacheEntryEvent<?, ?>> evtsQueue = new ArrayBlockingQueue<>(50_000);
-
- qry.setLocalListener(new CacheEntryUpdatedListener<QueryTestKey, QueryTestValue>() {
- @Override public void onUpdated(Iterable<CacheEntryEvent<? extends QueryTestKey,
- ? extends QueryTestValue>> evts) throws CacheEntryListenerException {
- for (CacheEntryEvent<?, ?> evt : evts)
- evtsQueue.add(evt);
- }
- });
-
- qry.setRemoteFilterFactory(new FilterFactory());
-
- evtsQueues.add(evtsQueue);
-
- QueryCursor<?> cur = ignite(i).cache(ccfg.getName()).query(qry);
-
- curs.add(cur);
- }
+ for (int i = 0; i < NODES - 1; i++)
+ evtsQueues.add(registerListener(ccfg.getName(), i, curs, lsnrCfgs, isSync));
}
ConcurrentMap<Object, Object> expData = new ConcurrentHashMap<>();
@@ -673,7 +118,7 @@ public class CacheContinuousQueryFactoryFilterTest extends GridCommonAbstractTes
try {
for (int i = 0; i < ITERATION_CNT; i++) {
- if (i % 20 == 0)
+ if (i % 10 == 0)
log.info("Iteration: " + i);
for (int idx = 0; idx < NODES; idx++)
@@ -683,6 +128,9 @@ public class CacheContinuousQueryFactoryFilterTest extends GridCommonAbstractTes
finally {
for (QueryCursor<?> cur : curs)
cur.close();
+
+ for (T2<Integer, MutableCacheEntryListenerConfiguration> e : lsnrCfgs)
+ grid(e.get1()).cache(ccfg.getName()).deregisterCacheEntryListener(e.get2());
}
}
finally {
@@ -691,6 +139,60 @@ public class CacheContinuousQueryFactoryFilterTest extends GridCommonAbstractTes
}
/**
+ * @param cacheName Cache name.
+ * @param nodeIdx Node index.
+ * @param curs Cursors.
+ * @param lsnrCfgs Listener configurations.
+ * @return Event queue
+ */
+ private BlockingQueue<CacheEntryEvent<?, ?>> registerListener(String cacheName,
+ int nodeIdx,
+ Collection<QueryCursor<?>> curs,
+ Collection<T2<Integer, MutableCacheEntryListenerConfiguration>> lsnrCfgs,
+ boolean sync) {
+ final BlockingQueue<CacheEntryEvent<?, ?>> evtsQueue = new ArrayBlockingQueue<>(50_000);
+
+ if (ThreadLocalRandom.current().nextBoolean()) {
+ MutableCacheEntryListenerConfiguration<QueryTestKey, QueryTestValue> lsnrCfg =
+ new MutableCacheEntryListenerConfiguration<>(
+ FactoryBuilder.factoryOf(new LocalNonSerialiseListener() {
+ @Override protected void onEvents(Iterable<CacheEntryEvent<? extends QueryTestKey,
+ ? extends QueryTestValue>> evts) {
+ for (CacheEntryEvent<?, ?> evt : evts)
+ evtsQueue.add(evt);
+ }
+ }),
+ new FilterFactory(),
+ true,
+ sync
+ );
+
+ grid(nodeIdx).cache(cacheName).registerCacheEntryListener((CacheEntryListenerConfiguration)lsnrCfg);
+
+ lsnrCfgs.add(new T2<Integer, MutableCacheEntryListenerConfiguration>(nodeIdx, lsnrCfg));
+ }
+ else {
+ ContinuousQuery<QueryTestKey, QueryTestValue> qry = new ContinuousQuery<>();
+
+ qry.setLocalListener(new CacheEntryUpdatedListener<QueryTestKey, QueryTestValue>() {
+ @Override public void onUpdated(Iterable<CacheEntryEvent<? extends QueryTestKey,
+ ? extends QueryTestValue>> evts) throws CacheEntryListenerException {
+ for (CacheEntryEvent<?, ?> evt : evts)
+ evtsQueue.add(evt);
+ }
+ });
+
+ qry.setRemoteFilterFactory(new FilterFactory());
+
+ QueryCursor<?> cur = grid(nodeIdx).cache(cacheName).query(qry);
+
+ curs.add(cur);
+ }
+
+ return evtsQueue;
+ }
+
+ /**
* @param rnd Random generator.
* @param evtsQueues Events queue.
* @param expData Expected cache data.
@@ -927,49 +429,6 @@ public class CacheContinuousQueryFactoryFilterTest extends GridCommonAbstractTes
break;
}
- case 11: {
- SortedMap<Object, Object> vals = new TreeMap<>();
-
- while (vals.size() < KEYS / 5)
- vals.put(new QueryTestKey(rnd.nextInt(KEYS)), value(rnd));
-
- cache.putAll(vals);
-
- if (tx != null)
- tx.commit();
-
- for (Map.Entry<Object, Object> e : vals.entrySet())
- updatePartitionCounter(cache, e.getKey(), partCntr);
-
- waitAndCheckEvent(evtsQueues, partCntr, affinity(cache), vals, expData);
-
- expData.putAll(vals);
-
- break;
- }
-
- case 12: {
- SortedMap<Object, Object> vals = new TreeMap<>();
-
- while (vals.size() < KEYS / 5)
- vals.put(new QueryTestKey(rnd.nextInt(KEYS)), newVal);
-
- cache.invokeAll(vals.keySet(), new EntrySetValueProcessor(newVal, rnd.nextBoolean()));
-
- if (tx != null)
- tx.commit();
-
- for (Map.Entry<Object, Object> e : vals.entrySet())
- updatePartitionCounter(cache, e.getKey(), partCntr);
-
- waitAndCheckEvent(evtsQueues, partCntr, affinity(cache), vals, expData);
-
- for (Object o : vals.keySet())
- expData.put(o, newVal);
-
- break;
- }
-
default:
fail("Op:" + op);
}
@@ -980,76 +439,6 @@ public class CacheContinuousQueryFactoryFilterTest extends GridCommonAbstractTes
}
/**
- * @param evtsQueues Queue.
- * @param partCntrs Counters.
- * @param aff Affinity.
- * @param vals Values.
- * @param expData Expected data.
- */
- private void waitAndCheckEvent(List<BlockingQueue<CacheEntryEvent<?, ?>>> evtsQueues,
- Map<Integer, Long> partCntrs,
- Affinity<Object> aff,
- SortedMap<Object, Object> vals,
- Map<Object, Object> expData)
- throws Exception {
- Map<Object, Object> vals0 = new HashMap<>(vals);
-
- for (Map.Entry<Object, Object> e : vals0.entrySet()) {
- if (!isAccepted((QueryTestValue)e.getValue()))
- vals.remove(e.getKey());
- }
-
- for (BlockingQueue<CacheEntryEvent<?, ?>> evtsQueue : evtsQueues) {
- Map<Object, CacheEntryEvent> rcvEvts = new HashMap<>();
-
- for (int i = 0; i < vals.size(); i++) {
- CacheEntryEvent<?, ?> evt = evtsQueue.poll(5, SECONDS);
-
- try {
- assertNotNull(evt);
- }
- catch (Throwable e) {
- int z = 0;
-
- ++z;
- }
-
- rcvEvts.put(evt.getKey(), evt);
- }
-
- assertEquals(vals.size(), rcvEvts.size());
-
- for (Map.Entry<Object, Object> e : vals.entrySet()) {
- Object key = e.getKey();
- Object val = e.getValue();
- Object oldVal = expData.get(key);
-
- if (val == null && oldVal == null) {
- checkNoEvent(evtsQueues);
-
- continue;
- }
-
- CacheEntryEvent evt = rcvEvts.get(key);
-
- assertNotNull("Failed to wait for event [key=" + key + ", val=" + val + ", oldVal=" + oldVal + ']',
- evt);
- assertEquals(key, evt.getKey());
- assertEquals(val, evt.getValue());
- assertEquals(oldVal, evt.getOldValue());
-
- long cntr = partCntrs.get(aff.partition(key));
- CacheQueryEntryEvent qryEntryEvt = (CacheQueryEntryEvent)evt.unwrap(CacheQueryEntryEvent.class);
-
- assertNotNull(cntr);
- assertNotNull(qryEntryEvt);
-
- assertEquals(cntr, qryEntryEvt.getPartitionUpdateCounter());
- }
- }
- }
-
- /**
* @param rnd {@link Random}.
* @return {@link TransactionIsolation}.
*/
@@ -1153,230 +542,99 @@ public class CacheContinuousQueryFactoryFilterTest extends GridCommonAbstractTes
/**
*
- * @param cacheMode Cache mode.
- * @param backups Number of backups.
- * @param atomicityMode Cache atomicity mode.
- * @param memoryMode Cache memory mode.
- * @param store If {@code true} configures dummy cache store.
- * @return Cache configuration.
- */
- private CacheConfiguration<Object, Object> cacheConfiguration(
- CacheMode cacheMode,
- int backups,
- CacheAtomicityMode atomicityMode,
- CacheMemoryMode memoryMode,
- boolean store) {
- CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>();
-
- ccfg.setAtomicityMode(atomicityMode);
- ccfg.setCacheMode(cacheMode);
- ccfg.setMemoryMode(memoryMode);
- ccfg.setWriteSynchronizationMode(FULL_SYNC);
- ccfg.setAtomicWriteOrderMode(PRIMARY);
-
- if (cacheMode == PARTITIONED)
- ccfg.setBackups(backups);
-
- if (store) {
- ccfg.setCacheStoreFactory(new TestStoreFactory());
- ccfg.setReadThrough(true);
- ccfg.setWriteThrough(true);
- }
-
- return ccfg;
- }
-
- /**
- *
- */
- private static class TestStoreFactory implements Factory<CacheStore<Object, Object>> {
- /** {@inheritDoc} */
- @SuppressWarnings("unchecked")
- @Override public CacheStore<Object, Object> create() {
- return new CacheStoreAdapter() {
- @Override public Object load(Object key) throws CacheLoaderException {
- return null;
- }
-
- @Override public void write(Cache.Entry entry) throws CacheWriterException {
- // No-op.
- }
-
- @Override public void delete(Object key) throws CacheWriterException {
- // No-op.
- }
- };
- }
- }
-
- /**
- *
*/
- static class QueryTestKey implements Serializable, Comparable {
+ protected static class NonSerializableFilter
+ implements CacheEntryEventSerializableFilter<QueryTestKey, QueryTestValue>, Externalizable {
/** */
- private final Integer key;
-
- /**
- * @param key Key.
- */
- public QueryTestKey(Integer key) {
- this.key = key;
+ public NonSerializableFilter() {
+ // No-op.
}
/** {@inheritDoc} */
- @Override public boolean equals(Object o) {
- if (this == o)
- return true;
-
- if (o == null || getClass() != o.getClass())
- return false;
-
- QueryTestKey that = (QueryTestKey)o;
-
- return key.equals(that.key);
+ @Override public boolean evaluate(CacheEntryEvent<? extends QueryTestKey, ? extends QueryTestValue> event)
+ throws CacheEntryListenerException {
+ return isAccepted(event.getValue());
}
/** {@inheritDoc} */
- @Override public int hashCode() {
- return key.hashCode();
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ fail("Entry filter should not be marshaled.");
}
/** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(QueryTestKey.class, this);
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ fail("Entry filter should not be marshaled.");
}
- /** {@inheritDoc} */
- @Override public int compareTo(Object o) {
- return key - ((QueryTestKey)o).key;
+ /**
+ * @return {@code True} if value is even.
+ */
+ public static boolean isAccepted(QueryTestValue val) {
+ return val == null || val.val1 % 2 == 0;
}
}
/**
*
*/
- static class QueryTestValue implements Serializable {
- /** */
- private final Integer val1;
-
- /** */
- private final String val2;
-
- /**
- * @param val Value.
- */
- public QueryTestValue(Integer val) {
- this.val1 = val;
- this.val2 = String.valueOf(val);
- }
-
- /** {@inheritDoc} */
- @Override public boolean equals(Object o) {
- if (this == o)
- return true;
-
- if (o == null || getClass() != o.getClass())
- return false;
-
- QueryTestValue that = (QueryTestValue) o;
-
- return val1.equals(that.val1) && val2.equals(that.val2);
- }
-
- /** {@inheritDoc} */
- @Override public int hashCode() {
- int res = val1.hashCode();
-
- res = 31 * res + val2.hashCode();
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(QueryTestValue.class, this);
+ protected static class FilterFactory implements Factory<NonSerializableFilter> {
+ @Override public NonSerializableFilter create() {
+ return new NonSerializableFilter();
}
}
/**
*
*/
- protected static class EntrySetValueProcessor implements EntryProcessor<Object, Object, Object> {
+ public abstract class LocalNonSerialiseListener implements
+ CacheEntryUpdatedListener<QueryTestKey, QueryTestValue>,
+ CacheEntryCreatedListener<QueryTestKey, QueryTestValue>,
+ CacheEntryExpiredListener<QueryTestKey, QueryTestValue>,
+ CacheEntryRemovedListener<QueryTestKey, QueryTestValue>,
+ Externalizable {
/** */
- private Object val;
-
- /** */
- private boolean retOld;
-
- /**
- * @param val Value to set.
- * @param retOld Return old value flag.
- */
- public EntrySetValueProcessor(Object val, boolean retOld) {
- this.val = val;
- this.retOld = retOld;
+ public LocalNonSerialiseListener() {
+ // No-op.
}
/** {@inheritDoc} */
- @Override public Object process(MutableEntry<Object, Object> e, Object... args) {
- Object old = retOld ? e.getValue() : null;
-
- if (val != null)
- e.setValue(val);
- else
- e.remove();
-
- return old;
+ @Override public void onCreated(Iterable<CacheEntryEvent<? extends QueryTestKey,
+ ? extends QueryTestValue>> evts) throws CacheEntryListenerException {
+ onEvents(evts);
}
/** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(EntrySetValueProcessor.class, this);
+ @Override public void onExpired(Iterable<CacheEntryEvent<? extends QueryTestKey,
+ ? extends QueryTestValue>> evts) throws CacheEntryListenerException {
+ onEvents(evts);
}
- }
-
- /**
- *
- */
- protected enum ContinuousDeploy {
- CLIENT, SERVER, ALL
- }
- /**
- *
- */
- protected static class NonSerializableFilter
- implements CacheEntryEventSerializableFilter<QueryTestKey, QueryTestValue>, Externalizable {
/** {@inheritDoc} */
- @Override public boolean evaluate(CacheEntryEvent<? extends QueryTestKey, ? extends QueryTestValue> event)
- throws CacheEntryListenerException {
- return isAccepted(event.getValue());
- }
-
- /** {@inheritDoc} */
- @Override public void writeExternal(ObjectOutput out) throws IOException {
- fail("Entry filter should not be marshaled.");
+ @Override public void onRemoved(Iterable<CacheEntryEvent<? extends QueryTestKey,
+ ? extends QueryTestValue>> evts) throws CacheEntryListenerException {
+ onEvents(evts);
}
/** {@inheritDoc} */
- @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- fail("Entry filter should not be marshaled.");
+ @Override public void onUpdated(Iterable<CacheEntryEvent<? extends QueryTestKey,
+ ? extends QueryTestValue>> evts) throws CacheEntryListenerException {
+ onEvents(evts);
}
/**
- * @return {@code True} if value is even.
+ * @param evts Events.
*/
- public static boolean isAccepted(QueryTestValue val) {
- return val == null ? true : val.val1 % 2 == 0;
+ protected abstract void onEvents(Iterable<CacheEntryEvent<? extends QueryTestKey,
+ ? extends QueryTestValue>> evts);
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ throw new UnsupportedOperationException("Failed. Listener should not be marshaled.");
}
- }
- /**
- *
- */
- protected static class FilterFactory implements Factory<NonSerializableFilter> {
- @Override public NonSerializableFilter create() {
- return new NonSerializableFilter();
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ throw new UnsupportedOperationException("Failed. Listener should not be unmarshaled.");
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9ad476b2/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
new file mode 100644
index 0000000..ff8d0a7
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryOperationP2PTest.java
@@ -0,0 +1,394 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.query.continuous;
+
+import java.io.Serializable;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.TimeUnit;
+import javax.cache.configuration.Factory;
+import javax.cache.configuration.FactoryBuilder;
+import javax.cache.configuration.MutableCacheEntryListenerConfiguration;
+import javax.cache.event.CacheEntryEvent;
+import javax.cache.event.CacheEntryEventFilter;
+import javax.cache.event.CacheEntryListener;
+import javax.cache.event.CacheEntryListenerException;
+import javax.cache.event.CacheEntryUpdatedListener;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheEntryEventSerializableFilter;
+import org.apache.ignite.cache.CacheMemoryMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.query.ContinuousQuery;
+import org.apache.ignite.cache.query.QueryCursor;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.PRIMARY;
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheMemoryMode.ONHEAP_TIERED;
+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;
+
+/**
+ *
+ */
+public class CacheContinuousQueryOperationP2PTest extends GridCommonAbstractTest {
+ /** */
+ private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+ /** */
+ private static final int NODES = 5;
+
+ /** */
+ private static final int KEYS = 50;
+
+ /** */
+ private static final int VALS = 10;
+
+ /** */
+ public static final int ITERATION_CNT = 100;
+
+ /** */
+ private boolean client;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
+
+ cfg.setClientMode(client);
+ cfg.setPeerClassLoadingEnabled(true);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ super.beforeTestsStarted();
+
+ startGridsMultiThreaded(NODES - 1);
+
+ client = true;
+
+ startGrid(NODES - 1);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+
+ super.afterTestsStopped();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testAtomicClient() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
+ 1,
+ ATOMIC,
+ ONHEAP_TIERED
+ );
+
+ testContinuousQuery(ccfg, true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testAtomic() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
+ 1,
+ ATOMIC,
+ ONHEAP_TIERED
+ );
+
+ testContinuousQuery(ccfg, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testAtomicReplicated() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(REPLICATED,
+ 0,
+ ATOMIC,
+ ONHEAP_TIERED
+ );
+
+ testContinuousQuery(ccfg, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testAtomicReplicatedClient() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(REPLICATED,
+ 0,
+ ATOMIC,
+ ONHEAP_TIERED
+ );
+
+ testContinuousQuery(ccfg, true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTx() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
+ 1,
+ TRANSACTIONAL,
+ ONHEAP_TIERED
+ );
+
+ testContinuousQuery(ccfg, false);
+ }
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTxClient() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
+ 1,
+ TRANSACTIONAL,
+ ONHEAP_TIERED
+ );
+
+ testContinuousQuery(ccfg, true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTxReplicated() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(REPLICATED,
+ 0,
+ TRANSACTIONAL,
+ ONHEAP_TIERED
+ );
+
+ testContinuousQuery(ccfg, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTxReplicatedClient() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(REPLICATED,
+ 0,
+ TRANSACTIONAL,
+ ONHEAP_TIERED
+ );
+
+ testContinuousQuery(ccfg, true);
+ }
+
+ /**
+ * @param ccfg Cache configuration.
+ * @param isClient Client.
+ * @throws Exception If failed.
+ */
+ protected void testContinuousQuery(CacheConfiguration<Object, Object> ccfg, boolean isClient)
+ throws Exception {
+ ignite(0).createCache(ccfg);
+
+ ThreadLocalRandom rnd = ThreadLocalRandom.current();
+
+ QueryCursor<?> cur = null;
+
+ final Class<Factory<CacheEntryEventFilter>> evtFilterFactory =
+ (Class<Factory<CacheEntryEventFilter>>)getExternalClassLoader().
+ loadClass("org.apache.ignite.tests.p2p.CacheDeploymentEntryEventFilterFactory");
+
+ final CountDownLatch latch = new CountDownLatch(10);
+
+ ContinuousQuery<Integer, Integer> qry = new ContinuousQuery<>();
+
+ CacheEntryUpdatedListener<Integer, Integer> localLsnr = new CacheEntryUpdatedListener<Integer, Integer>() {
+ @Override public void onUpdated(Iterable<CacheEntryEvent<? extends Integer,
+ ? extends Integer>> evts) throws CacheEntryListenerException {
+ for (CacheEntryEvent<? extends Integer, ? extends Integer> evt : evts)
+ latch.countDown();
+ }
+ };
+
+ MutableCacheEntryListenerConfiguration<Integer, Integer> lsnrCfg =
+ new MutableCacheEntryListenerConfiguration<>(
+ new FactoryBuilder.SingletonFactory<>(localLsnr),
+ (Factory<? extends CacheEntryEventFilter<? super Integer, ? super Integer>>)
+ (Object)evtFilterFactory.newInstance(),
+ true,
+ true
+ );
+
+ qry.setLocalListener(localLsnr);
+
+ qry.setRemoteFilterFactory(
+ (Factory<? extends CacheEntryEventFilter<Integer, Integer>>)(Object)evtFilterFactory.newInstance());
+
+ IgniteCache<Integer, Integer> cache = null;
+
+ try {
+ if (isClient)
+ cache = grid(NODES - 1).cache(ccfg.getName());
+ else
+ cache = grid(rnd.nextInt(NODES - 1)).cache(ccfg.getName());
+
+ //cur = cache.query(qry);
+
+ cache.registerCacheEntryListener(lsnrCfg);
+
+ for (int i = 0; i < 10; i++)
+ cache.put(i, i);
+
+ assertTrue(latch.await(3, TimeUnit.SECONDS));
+ }
+ finally {
+ if (cur != null)
+ cur.close();
+
+ if (cache != null)
+ cache.deregisterCacheEntryListener(lsnrCfg);
+ }
+ }
+
+ /**
+ *
+ * @param cacheMode Cache mode.
+ * @param backups Number of backups.
+ * @param atomicityMode Cache atomicity mode.
+ * @param memoryMode Cache memory mode.
+ * @return Cache configuration.
+ */
+ private CacheConfiguration<Object, Object> cacheConfiguration(
+ CacheMode cacheMode,
+ int backups,
+ CacheAtomicityMode atomicityMode,
+ CacheMemoryMode memoryMode) {
+ CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>();
+
+ ccfg.setAtomicityMode(atomicityMode);
+ ccfg.setCacheMode(cacheMode);
+ ccfg.setMemoryMode(memoryMode);
+ ccfg.setWriteSynchronizationMode(FULL_SYNC);
+ ccfg.setAtomicWriteOrderMode(PRIMARY);
+
+ if (cacheMode == PARTITIONED)
+ ccfg.setBackups(backups);
+
+ return ccfg;
+ }
+
+ /**
+ *
+ */
+ public static class QueryTestKey implements Serializable, Comparable {
+ /** */
+ private final Integer key;
+
+ /**
+ * @param key Key.
+ */
+ public QueryTestKey(Integer key) {
+ this.key = key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ QueryTestKey that = (QueryTestKey)o;
+
+ return key.equals(that.key);
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return key.hashCode();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(QueryTestKey.class, this);
+ }
+
+ /** {@inheritDoc} */
+ @Override public int compareTo(Object o) {
+ return key - ((QueryTestKey)o).key;
+ }
+ }
+
+ /**
+ *
+ */
+ public static class QueryTestValue implements Serializable {
+ /** */
+ protected final Integer val1;
+
+ /** */
+ protected final String val2;
+
+ /**
+ * @param val Value.
+ */
+ public QueryTestValue(Integer val) {
+ this.val1 = val;
+ this.val2 = String.valueOf(val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ QueryTestValue that = (QueryTestValue) o;
+
+ return val1.equals(that.val1) && val2.equals(that.val2);
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ int res = val1.hashCode();
+
+ res = 31 * res + val2.hashCode();
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(QueryTestValue.class, this);
+ }
+ }
+}
[10/20] ignite git commit: ignite-2521: Configuration variations
tests framework + IgniteCacheBasicConfigVariationsFullApiTestSuite +
ignite-2554: Fixed Affinity.mapKeyToNode() for dynamically started LOCAL
cache
Posted by nt...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/953b575f/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/CacheStartMode.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/CacheStartMode.java b/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/CacheStartMode.java
new file mode 100644
index 0000000..ef8bdf0
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/CacheStartMode.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.testframework.configvariations;
+
+/**
+ * Cache start mode.
+ */
+public enum CacheStartMode {
+ /** Start caches together with nodes (not dynamically). */
+ STATIC,
+
+ /** Starts nodes first and then starts caches dynamically. */
+ DYNAMIC
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/953b575f/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/ConfigFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/ConfigFactory.java b/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/ConfigFactory.java
new file mode 100644
index 0000000..9541c1a
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/ConfigFactory.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.testframework.configvariations;
+
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+
+/**
+ * Configuration factory.
+ */
+public interface ConfigFactory {
+ /**
+ * @param gridName Grid name.
+ * @param srcCfg Source config.
+ * @return IgniteConfiguration.
+ */
+ public IgniteConfiguration getConfiguration(String gridName, IgniteConfiguration srcCfg);
+
+ /**
+ * @param gridName Name.
+ * @return CacheConfiguration.
+ */
+ public CacheConfiguration cacheConfiguration(String gridName);
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/953b575f/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/ConfigParameter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/ConfigParameter.java b/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/ConfigParameter.java
new file mode 100644
index 0000000..5a29d25
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/ConfigParameter.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.testframework.configvariations;
+
+/**
+ * Configuration parameter.
+ */
+public interface ConfigParameter<T> {
+ /**
+ * @return Name
+ */
+ public String name();
+
+ /**
+ * @param cfg Configuration.
+ * @return Configuration.
+ */
+ public T apply(T cfg);
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/953b575f/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/ConfigVariations.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/ConfigVariations.java b/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/ConfigVariations.java
new file mode 100644
index 0000000..e5856f0
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/ConfigVariations.java
@@ -0,0 +1,346 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.testframework.configvariations;
+
+import java.util.Collection;
+import javax.cache.Cache;
+import javax.cache.configuration.CacheEntryListenerConfiguration;
+import javax.cache.configuration.Factory;
+import javax.cache.configuration.MutableCacheEntryListenerConfiguration;
+import javax.cache.event.CacheEntryCreatedListener;
+import javax.cache.event.CacheEntryEventFilter;
+import javax.cache.event.CacheEntryListener;
+import javax.cache.event.CacheEntryListenerException;
+import org.apache.ignite.cache.CacheAtomicWriteOrderMode;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheInterceptorAdapter;
+import org.apache.ignite.cache.CacheMemoryMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.CacheRebalanceMode;
+import org.apache.ignite.cache.CacheWriteSynchronizationMode;
+import org.apache.ignite.cache.affinity.fair.FairAffinityFunction;
+import org.apache.ignite.cache.eviction.EvictionFilter;
+import org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy;
+import org.apache.ignite.cache.store.CacheStoreSession;
+import org.apache.ignite.cache.store.CacheStoreSessionListener;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.NearCacheConfiguration;
+import org.apache.ignite.configuration.TopologyValidator;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
+import org.apache.ignite.spi.swapspace.inmemory.GridTestSwapSpaceSpi;
+import org.apache.ignite.testframework.junits.IgniteCacheConfigVariationsAbstractTest;
+
+import static org.apache.ignite.internal.util.lang.GridFunc.asArray;
+
+/**
+ * Cache configuration variations.
+ */
+@SuppressWarnings("serial")
+public class ConfigVariations {
+ /** */
+ private static final ConfigParameter<Object> EVICTION_PARAM = Parameters.complexParameter(
+ Parameters.parameter("setEvictionPolicy", Parameters.factory(FifoEvictionPolicy.class)),
+ Parameters.parameter("setEvictionFilter", Parameters.factory(NoopEvictionFilter.class))
+ );
+
+ /** */
+ private static final ConfigParameter<Object> CACHE_STORE_PARAM = Parameters.complexParameter(
+ Parameters.parameter("setCacheStoreFactory", Parameters.factory(IgniteCacheConfigVariationsAbstractTest.TestStoreFactory.class)),
+ Parameters.parameter("setReadThrough", true),
+ Parameters.parameter("setWriteThrough", true),
+ Parameters.parameter("setCacheStoreSessionListenerFactories", noopCacheStoreSessionListenerFactory())
+ );
+
+ /** */
+ private static final ConfigParameter<Object> SIMPLE_CACHE_STORE_PARAM = Parameters.complexParameter(
+ Parameters.parameter("setCacheStoreFactory", Parameters.factory(IgniteCacheConfigVariationsAbstractTest.TestStoreFactory.class)),
+ Parameters.parameter("setReadThrough", true),
+ Parameters.parameter("setWriteThrough", true)
+ );
+
+ /** */
+ private static final ConfigParameter<Object> REBALANCING_PARAM = Parameters.complexParameter(
+ Parameters.parameter("setRebalanceBatchSize", 2028 * 1024),
+ Parameters.parameter("setRebalanceBatchesPrefetchCount", 5L),
+ Parameters.parameter("setRebalanceThreadPoolSize", 5),
+ Parameters.parameter("setRebalanceTimeout", CacheConfiguration.DFLT_REBALANCE_TIMEOUT * 2),
+ Parameters.parameter("setRebalanceDelay", 1000L)
+ );
+
+ /** */
+ private static final ConfigParameter<Object> ONHEAP_TIERED_MEMORY_PARAM =
+ Parameters.parameter("setMemoryMode", CacheMemoryMode.ONHEAP_TIERED);
+
+ /** */
+ private static final ConfigParameter<Object> OFFHEAP_TIERED_MEMORY_PARAM =
+ Parameters.parameter("setMemoryMode", CacheMemoryMode.OFFHEAP_TIERED);
+
+ /** */
+ private static final ConfigParameter<Object> OFFHEAP_VALUES_MEMORY_PARAM =
+ Parameters.parameter("setMemoryMode", CacheMemoryMode.OFFHEAP_VALUES);
+
+ /** */
+ private static final ConfigParameter<Object> OFFHEAP_ENABLED =
+ Parameters.parameter("setOffHeapMaxMemory", 10 * 1024 * 1024L);
+
+ /** */
+ @SuppressWarnings("unchecked")
+ private static final ConfigParameter<IgniteConfiguration>[][] BASIC_IGNITE_SET = new ConfigParameter[][] {
+ Parameters.objectParameters("setMarshaller", Parameters.factory(BinaryMarshaller.class), optimizedMarshallerFactory()),
+ Parameters.booleanParameters("setPeerClassLoadingEnabled"),
+ Parameters.objectParameters("setSwapSpaceSpi", Parameters.factory(GridTestSwapSpaceSpi.class)),
+ };
+
+ /** */
+ @SuppressWarnings("unchecked")
+ private static final ConfigParameter<CacheConfiguration>[][] BASIC_CACHE_SET = new ConfigParameter[][] {
+ Parameters.objectParameters("setCacheMode", CacheMode.REPLICATED, CacheMode.PARTITIONED),
+ Parameters.enumParameters("setAtomicityMode", CacheAtomicityMode.class),
+ Parameters.enumParameters("setMemoryMode", CacheMemoryMode.class),
+ // Set default parameters.
+ Parameters.objectParameters("setLoadPreviousValue", true),
+ Parameters.objectParameters("setSwapEnabled", true),
+ asArray(SIMPLE_CACHE_STORE_PARAM),
+ Parameters.objectParameters("setWriteSynchronizationMode", CacheWriteSynchronizationMode.FULL_SYNC),
+ Parameters.objectParameters("setAtomicWriteOrderMode", CacheAtomicWriteOrderMode.PRIMARY),
+ Parameters.objectParameters("setStartSize", 1024),
+ };
+
+ /** */
+ @SuppressWarnings("unchecked")
+ private static final ConfigParameter<CacheConfiguration>[][] FULL_CACHE_SET = new ConfigParameter[][] {
+ Parameters.enumParameters("setCacheMode", CacheMode.class),
+ Parameters.enumParameters("setAtomicityMode", CacheAtomicityMode.class),
+ asArray(ONHEAP_TIERED_MEMORY_PARAM,
+ Parameters.complexParameter(ONHEAP_TIERED_MEMORY_PARAM, OFFHEAP_ENABLED),
+ Parameters.complexParameter(OFFHEAP_TIERED_MEMORY_PARAM, OFFHEAP_ENABLED),
+ Parameters.complexParameter(OFFHEAP_VALUES_MEMORY_PARAM, OFFHEAP_ENABLED)
+ ),
+ Parameters.booleanParameters("setLoadPreviousValue"),
+ Parameters.booleanParameters("setReadFromBackup"),
+ Parameters.booleanParameters("setStoreKeepBinary"),
+ Parameters.objectParameters("setRebalanceMode", CacheRebalanceMode.SYNC, CacheRebalanceMode.ASYNC),
+ Parameters.booleanParameters("setSwapEnabled"),
+ Parameters.booleanParameters("setCopyOnRead"),
+ Parameters.objectParameters(true, "setNearConfiguration", nearCacheConfigurationFactory()),
+ asArray(null,
+ Parameters.complexParameter(
+ EVICTION_PARAM,
+ CACHE_STORE_PARAM,
+ REBALANCING_PARAM,
+ Parameters.parameter("setAffinity", Parameters.factory(FairAffinityFunction.class)),
+ Parameters.parameter("setInterceptor", Parameters.factory(NoopInterceptor.class)),
+ Parameters.parameter("setTopologyValidator", Parameters.factory(NoopTopologyValidator.class)),
+ Parameters.parameter("addCacheEntryListenerConfiguration", Parameters.factory(EmptyCacheEntryListenerConfiguration.class))
+ )
+ ),
+ // Set default parameters.
+ Parameters.objectParameters("setWriteSynchronizationMode", CacheWriteSynchronizationMode.FULL_SYNC),
+ Parameters.objectParameters("setAtomicWriteOrderMode", CacheAtomicWriteOrderMode.PRIMARY),
+ Parameters.objectParameters("setStartSize", 1024),
+ };
+
+ /**
+ * Private constructor.
+ */
+ private ConfigVariations() {
+ // No-op.
+ }
+
+ /**
+ * @return Custom near cache config.
+ */
+ private static Factory nearCacheConfigurationFactory() {
+ return new Factory() {
+ @Override public Object create() {
+ NearCacheConfiguration cfg = new NearCacheConfiguration<>();
+
+ cfg.setNearEvictionPolicy(new FifoEvictionPolicy());
+
+ return cfg;
+ }
+ };
+ }
+
+ /**
+ * @return Noop cache store session listener factory.
+ */
+ private static Factory noopCacheStoreSessionListenerFactory() {
+ return new Factory() {
+ @Override public Object create() {
+ return new Factory[] {new NoopCacheStoreSessionListenerFactory()};
+ }
+ };
+ }
+
+ /**
+ * @return Default matrix of availiable variations.
+ */
+ public static ConfigParameter<CacheConfiguration>[][] cacheBasicSet() {
+ return BASIC_CACHE_SET;
+ }
+
+ /**
+ * @return Full matrix of availiable variations.
+ */
+ public static ConfigParameter<CacheConfiguration>[][] cacheFullSet() {
+ return FULL_CACHE_SET;
+ }
+
+ /**
+ * @return Default matrix of availiable variations.
+ */
+ public static ConfigParameter<IgniteConfiguration>[][] igniteBasicSet() {
+ return BASIC_IGNITE_SET;
+ }
+
+ /**
+ * @return Marshaller.
+ */
+ private static Factory<OptimizedMarshaller> optimizedMarshallerFactory() {
+ return new Factory<OptimizedMarshaller>() {
+ @Override public OptimizedMarshaller create() {
+ OptimizedMarshaller marsh = new OptimizedMarshaller(true);
+
+ marsh.setRequireSerializable(false);
+
+ return marsh;
+ }
+ };
+ }
+
+ /**
+ *
+ */
+ public static class NoopEvictionFilter implements EvictionFilter {
+ /** */
+ private static final long serialVersionUID = 0;
+
+ /** {@inheritDoc} */
+ @Override public boolean evictAllowed(Cache.Entry entry) {
+ return true;
+ }
+ }
+
+ /**
+ *
+ */
+ public static class NoopInterceptor extends CacheInterceptorAdapter {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ // No-op.
+ }
+
+ /**
+ *
+ */
+ public static class NoopCacheStoreSessionListenerFactory implements Factory<NoopCacheStoreSessionListener> {
+ /** Serial version uid. */
+ private static final long serialVersionUID = 0L;
+
+ /** {@inheritDoc} */
+ @Override public NoopCacheStoreSessionListener create() {
+ return new NoopCacheStoreSessionListener();
+ }
+ }
+
+ /**
+ *
+ */
+ public static class NoopCacheStoreSessionListener implements CacheStoreSessionListener {
+ /** {@inheritDoc} */
+ @Override public void onSessionStart(CacheStoreSession ses) {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void onSessionEnd(CacheStoreSession ses, boolean commit) {
+ // No-op.
+ }
+ }
+
+ /**
+ *
+ */
+ public static class NoopTopologyValidator implements TopologyValidator {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** {@inheritDoc} */
+ @Override public boolean validate(Collection<ClusterNode> nodes) {
+ return true;
+ }
+ }
+
+ /**
+ *
+ */
+ @SuppressWarnings({"serial", "unchecked"})
+ public static class EmptyCacheEntryListenerConfiguration extends MutableCacheEntryListenerConfiguration {
+ /**
+ *
+ */
+ public EmptyCacheEntryListenerConfiguration() {
+ super(new NoopCacheEntryListenerConfiguration());
+ }
+ }
+
+ /**
+ *
+ */
+ @SuppressWarnings("serial")
+ public static class NoopCacheEntryListenerConfiguration implements CacheEntryListenerConfiguration {
+ /** {@inheritDoc} */
+ @Override public Factory<CacheEntryListener> getCacheEntryListenerFactory() {
+ return new Factory<CacheEntryListener>() {
+ @Override public CacheEntryListener create() {
+ return new NoopCacheEntryListener();
+ }
+ };
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isOldValueRequired() {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Factory<CacheEntryEventFilter> getCacheEntryEventFilterFactory() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isSynchronous() {
+ return false;
+ }
+ }
+
+ /**
+ *
+ */
+ public static class NoopCacheEntryListener implements CacheEntryCreatedListener {
+ /** {@inheritDoc} */
+ @Override public void onCreated(Iterable iterable) throws CacheEntryListenerException {
+ // No-op.
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/953b575f/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/ConfigVariationsFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/ConfigVariationsFactory.java b/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/ConfigVariationsFactory.java
new file mode 100644
index 0000000..f5e7d57
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/ConfigVariationsFactory.java
@@ -0,0 +1,197 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.testframework.configvariations;
+
+import java.util.Arrays;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.util.typedef.internal.SB;
+import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Configurations variations factory.
+ */
+public class ConfigVariationsFactory implements ConfigFactory {
+ /** */
+ private final ConfigParameter<IgniteConfiguration>[][] igniteParams;
+
+ /** */
+ private final int[] igniteCfgVariation;
+
+ /** */
+ private final ConfigParameter<CacheConfiguration>[][] cacheParams;
+
+ /** */
+ private final int[] cacheCfgVariation;
+
+ /** */
+ private int backups = -1;
+
+ /**
+ * @param igniteParams Ignite Params.
+ * @param igniteCfgVariation Ignite configuration variation.
+ * @param cacheParams Cache Params.
+ * @param cacheCfgVariation Cache config variation.
+ */
+ public ConfigVariationsFactory(ConfigParameter<IgniteConfiguration>[][] igniteParams,
+ int[] igniteCfgVariation,
+ @Nullable ConfigParameter<CacheConfiguration>[][] cacheParams,
+ @Nullable int[] cacheCfgVariation) {
+ this.igniteParams = igniteParams;
+ this.igniteCfgVariation = igniteCfgVariation;
+ this.cacheParams = cacheParams;
+ this.cacheCfgVariation = cacheCfgVariation;
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override public IgniteConfiguration getConfiguration(String gridName, IgniteConfiguration srcCfg) {
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ if (srcCfg != null)
+ copyDefaultsFromSource(cfg, srcCfg);
+
+ if (igniteParams == null)
+ return cfg;
+
+ for (int i = 0; i < igniteCfgVariation.length; i++) {
+ int var = igniteCfgVariation[i];
+
+ ConfigParameter<IgniteConfiguration> cfgC = igniteParams[i][var];
+
+ if (cfgC != null)
+ cfgC.apply(cfg);
+ }
+
+ return cfg;
+ }
+
+ /**
+ * @param cfg Config.
+ * @param srcCfg Source config.
+ */
+ private static void copyDefaultsFromSource(IgniteConfiguration cfg, IgniteConfiguration srcCfg) {
+ cfg.setGridName(srcCfg.getGridName());
+ cfg.setGridLogger(srcCfg.getGridLogger());
+ cfg.setNodeId(srcCfg.getNodeId());
+ cfg.setIgniteHome(srcCfg.getIgniteHome());
+ cfg.setMBeanServer(srcCfg.getMBeanServer());
+ cfg.setMetricsLogFrequency(srcCfg.getMetricsLogFrequency());
+ cfg.setConnectorConfiguration(srcCfg.getConnectorConfiguration());
+ cfg.setCommunicationSpi(srcCfg.getCommunicationSpi());
+ cfg.setNetworkTimeout(srcCfg.getNetworkTimeout());
+ cfg.setDiscoverySpi(srcCfg.getDiscoverySpi());
+ cfg.setCheckpointSpi(srcCfg.getCheckpointSpi());
+ cfg.setIncludeEventTypes(srcCfg.getIncludeEventTypes());
+
+ // Specials.
+ ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
+ ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true);
+ cfg.getTransactionConfiguration().setTxSerializableEnabled(true);
+ }
+
+ /**
+ * @return Description.
+ */
+ public String getIgniteConfigurationDescription() {
+ if (igniteParams == null)
+ return "";
+
+ SB sb = new SB("[");
+
+ for (int i = 0; i < igniteCfgVariation.length; i++) {
+ int var = igniteCfgVariation[i];
+
+ ConfigParameter<IgniteConfiguration> cfgC = igniteParams[i][var];
+
+ if (cfgC != null) {
+ sb.a(cfgC.name());
+
+ if (i + 1 < igniteCfgVariation.length)
+ sb.a(", ");
+ }
+ }
+
+ sb.a("]");
+
+ return sb.toString();
+
+ }
+
+ /** {@inheritDoc} */
+ @Override public CacheConfiguration cacheConfiguration(String gridName) {
+ if (cacheParams == null || cacheCfgVariation == null)
+ throw new IllegalStateException("Failed to configure cache [cacheParams=" + Arrays.deepToString(cacheParams)
+ + ", cacheCfgVariation=" + Arrays.toString(cacheCfgVariation) + "]");
+
+ CacheConfiguration cfg = new CacheConfiguration();
+
+ for (int i = 0; i < cacheCfgVariation.length; i++) {
+ int var = cacheCfgVariation[i];
+
+ ConfigParameter<CacheConfiguration> cfgC = cacheParams[i][var];
+
+ if (cfgC != null)
+ cfgC.apply(cfg);
+ }
+
+ if (backups > 0)
+ cfg.setBackups(backups);
+
+ return cfg;
+ }
+
+ /**
+ * @return Description.
+ */
+ public String getCacheConfigurationDescription() {
+ if (cacheCfgVariation == null)
+ return "";
+
+ SB sb = new SB("[");
+
+ for (int i = 0; i < cacheCfgVariation.length; i++) {
+ int var = cacheCfgVariation[i];
+
+ ConfigParameter cfgC = cacheParams[i][var];
+
+ if (cfgC != null) {
+ sb.a(cfgC.name());
+
+ if (i + 1 < cacheCfgVariation.length)
+ sb.a(", ");
+ }
+ }
+
+ if (backups > 0)
+ sb.a(", backups=").a(backups);
+
+ sb.a("]");
+
+ return sb.toString();
+ }
+
+ /**
+ * @param backups New backups.
+ */
+ public void backups(int backups) {
+ this.backups = backups;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/953b575f/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/ConfigVariationsTestSuiteBuilder.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/ConfigVariationsTestSuiteBuilder.java b/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/ConfigVariationsTestSuiteBuilder.java
new file mode 100644
index 0000000..71d7987
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/ConfigVariationsTestSuiteBuilder.java
@@ -0,0 +1,382 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.testframework.configvariations;
+
+import java.util.Arrays;
+import junit.framework.TestSuite;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.testframework.junits.IgniteCacheConfigVariationsAbstractTest;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.testframework.junits.IgniteConfigVariationsAbstractTest;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Configuration variations test suite builder.
+ */
+public class ConfigVariationsTestSuiteBuilder {
+ /** */
+ private final TestSuite suite;
+
+ /** */
+ @SuppressWarnings("unchecked")
+ private ConfigParameter<IgniteConfiguration>[][] igniteParams =
+ ConfigVariations.igniteBasicSet();
+
+ /** */
+ @SuppressWarnings("unchecked")
+ private ConfigParameter<CacheConfiguration>[][] cacheParams;
+
+ /** */
+ private CacheStartMode cacheStartMode = CacheStartMode.DYNAMIC;
+
+ /** */
+ private boolean withClients;
+
+ /** */
+ private int gridsCnt = 3;
+
+ /** */
+ private int testedNodeCnt = 1;
+
+ /** */
+ private Class<? extends IgniteConfigVariationsAbstractTest> cls;
+
+ /** */
+ private int[] specificIgniteParam;
+
+ /** */
+ private int[] specificCacheParam;
+
+ /** */
+ private int backups = -1;
+
+ /** */
+ private IgnitePredicate<IgniteConfiguration>[] igniteCfgFilters;
+
+ /** */
+ private IgnitePredicate<CacheConfiguration>[] cacheCfgFilters;
+
+ /**
+ * @param name Name.
+ * @param cls Test class.
+ */
+ public ConfigVariationsTestSuiteBuilder(String name, Class<? extends IgniteConfigVariationsAbstractTest> cls) {
+ suite = new TestSuite(name);
+ this.cls = cls;
+ }
+
+ /**
+ * @return Test suite.
+ */
+ public TestSuite build() {
+ assert testedNodeCnt > 0;
+ assert gridsCnt > 0;
+
+ VariationsIterator igniteCfgIter;
+
+ if (specificIgniteParam == null)
+ igniteCfgIter = new VariationsIterator(igniteParams);
+ else
+ igniteCfgIter = new OneElementVariationsIterator(specificIgniteParam, igniteParams);
+
+ for (; igniteCfgIter.hasNext(); ) {
+ final int[] igniteCfgVariation = igniteCfgIter.next();
+
+ if (!passIgniteConfigFilter(igniteCfgVariation))
+ continue;
+
+ if (cacheParams == null) {
+ TestSuite addedSuite = build(igniteCfgVariation, null, true);
+
+ suite.addTest(addedSuite);
+ }
+ else {
+ VariationsIterator cacheCfgIter;
+
+ if (specificCacheParam == null)
+ cacheCfgIter = new VariationsIterator(cacheParams);
+ else
+ cacheCfgIter = new OneElementVariationsIterator(specificCacheParam, cacheParams);
+
+ for (; cacheCfgIter.hasNext(); ) {
+ int[] cacheCfgVariation = cacheCfgIter.next();
+
+ if (!passCacheConfigFilter(cacheCfgVariation))
+ continue;
+
+ // Stop all grids before starting new ignite configuration.
+ boolean stopNodes = !cacheCfgIter.hasNext();
+
+ TestSuite addedSuite = build(igniteCfgVariation, cacheCfgVariation, stopNodes);
+
+ suite.addTest(addedSuite);
+ }
+ }
+ }
+
+ return suite;
+ }
+
+ /**
+ * @param variation Variation.
+ * @return {@code True} if variation pass filters.
+ */
+ private boolean passIgniteConfigFilter(int[] variation) {
+ ConfigVariationsFactory factory = new ConfigVariationsFactory(igniteParams, variation, null, null);
+
+ IgniteConfiguration cfg = factory.getConfiguration(null, null);
+
+ if (igniteCfgFilters != null) {
+ for (IgnitePredicate<IgniteConfiguration> filter : igniteCfgFilters) {
+ if (!filter.apply(cfg))
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * @param variation Variation.
+ * @return {@code True} if variation pass filters.
+ */
+ private boolean passCacheConfigFilter(int[] variation) {
+ ConfigVariationsFactory factory = new ConfigVariationsFactory(null, null, cacheParams, variation);
+
+ CacheConfiguration cfg = factory.cacheConfiguration(null);
+
+ if (cacheCfgFilters != null) {
+ for (IgnitePredicate<CacheConfiguration> filter : cacheCfgFilters) {
+ if (!filter.apply(cfg))
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * @param igniteCfgVariation Ignite Variation.
+ * @param cacheCfgVariation Cache Variation.
+ * @param stopNodes Stop nodes.
+ * @return Test suite.
+ */
+ private TestSuite build(int[] igniteCfgVariation, @Nullable int[] cacheCfgVariation, boolean stopNodes) {
+ ConfigVariationsFactory factory = new ConfigVariationsFactory(igniteParams,
+ igniteCfgVariation, cacheParams, cacheCfgVariation);
+
+ factory.backups(backups);
+
+ String clsNameSuffix = "[igniteCfgVariation=" + Arrays.toString(igniteCfgVariation)
+ + ", cacheCfgVariation=" + Arrays.toString(cacheCfgVariation)
+ + ", igniteCfg=" + factory.getIgniteConfigurationDescription()
+ + ", cacheCfg=" + factory.getCacheConfigurationDescription() + "]";
+
+ VariationsTestsConfig testCfg = new VariationsTestsConfig(factory, clsNameSuffix, stopNodes, cacheStartMode,
+ gridsCnt);
+
+ TestSuite addedSuite;
+
+ if (testedNodeCnt > 1)
+ addedSuite = createMultiNodeTestSuite((Class<? extends IgniteCacheConfigVariationsAbstractTest>)cls,
+ testCfg, testedNodeCnt, withClients);
+ else
+ addedSuite = new IgniteConfigVariationsTestSuite(cls, testCfg);
+
+ return addedSuite;
+ }
+
+ /**
+ * @param cls Test class.
+ * @param cfg Configuration.
+ * @param testedNodeCnt Count of tested nodes.
+ */
+ private static TestSuite createMultiNodeTestSuite(Class<? extends IgniteCacheConfigVariationsAbstractTest> cls,
+ VariationsTestsConfig cfg, int testedNodeCnt, boolean withClients) {
+ TestSuite suite = new TestSuite();
+
+ if (cfg.gridCount() < testedNodeCnt)
+ throw new IllegalArgumentException("Failed to initialize test suite [nodeCnt=" + testedNodeCnt
+ + ", cfgGridCnt=" + cfg.gridCount() + "]");
+
+ for (int i = 0; i < testedNodeCnt; i++) {
+ boolean stopNodes = cfg.isStopNodes() && i + 1 == testedNodeCnt;
+ boolean startCache = i == 0;
+ boolean stopCache = i + 1 == testedNodeCnt;
+
+ VariationsTestsConfig cfg0 = new VariationsTestsConfig(cfg.configurationFactory(), cfg.description(),
+ stopNodes, startCache, stopCache, cfg.cacheStartMode(), cfg.gridCount(), i, withClients);
+
+ suite.addTest(new IgniteConfigVariationsTestSuite(cls, cfg0));
+ }
+
+ return suite;
+ }
+
+ /**
+ * @return {@code this} for chaining.
+ */
+ public ConfigVariationsTestSuiteBuilder withClients() {
+ if (testedNodeCnt < 2)
+ throw new IllegalStateException("Tested node count should be more than 1: " + testedNodeCnt);
+
+ withClients = true;
+
+ return this;
+ }
+
+ /**
+ * @param testedNodeCnt Tested node count.
+ * @return {@code this} for chaining.
+ */
+ public ConfigVariationsTestSuiteBuilder testedNodesCount(int testedNodeCnt) {
+ this.testedNodeCnt = testedNodeCnt;
+
+ return this;
+ }
+
+ /**
+ * @param cnt Count.
+ * @return {@code this} for chaining.
+ */
+ public ConfigVariationsTestSuiteBuilder gridsCount(int cnt) {
+ assert cnt > 0;
+
+ gridsCnt = cnt;
+
+ return this;
+ }
+
+ /**
+ * @param igniteParams New ignite params.
+ * @return {@code this} for chaining.
+ */
+ public ConfigVariationsTestSuiteBuilder igniteParams(
+ ConfigParameter<IgniteConfiguration>[][] igniteParams) {
+ this.igniteParams = igniteParams;
+
+ return this;
+ }
+
+ /**
+ * @param cacheParams New cache params.
+ * @return {@code this} for chaining.
+ */
+ public ConfigVariationsTestSuiteBuilder cacheParams(ConfigParameter<CacheConfiguration>[][] cacheParams) {
+ this.cacheParams = cacheParams;
+
+ return this;
+ }
+
+ /**
+ * Sets basic cache params and basic count of backups.
+ *
+ * @return {@code this} for chaining.
+ */
+ public ConfigVariationsTestSuiteBuilder withBasicCacheParams() {
+ cacheParams = ConfigVariations.cacheBasicSet();
+ backups = 1;
+
+ return this;
+ }
+
+ /**
+ * @param backups Backups.
+ * @return {@code this} for chaining.
+ */
+ public ConfigVariationsTestSuiteBuilder backups(int backups) {
+ assert backups > 0 : backups;
+
+ this.backups = backups;
+
+ return this;
+ }
+
+ /**
+ * @param singleIgniteParam Param.
+ * @return {@code this} for chaining.
+ */
+ public ConfigVariationsTestSuiteBuilder specifyIgniteParam(int... singleIgniteParam) {
+ specificIgniteParam = singleIgniteParam;
+
+ return this;
+ }
+
+ /**
+ * @param singleParam Param.
+ * @return {@code this} for chaining.
+ */
+ public ConfigVariationsTestSuiteBuilder specifyCacheParam(int... singleParam) {
+ specificCacheParam = singleParam;
+
+ return this;
+ }
+
+ /**
+ * @param filters Ignite configuration filters.
+ * @return {@code this} for chaining.
+ */
+ public ConfigVariationsTestSuiteBuilder withIgniteConfigFilters(IgnitePredicate<IgniteConfiguration>... filters) {
+ igniteCfgFilters = filters;
+
+ return this;
+ }
+
+ /**
+ * @param filters Ignite configuration filters.
+ * @return {@code this} for chaining.
+ */
+ public ConfigVariationsTestSuiteBuilder withCacheConfigFilters(IgnitePredicate<CacheConfiguration>... filters) {
+ cacheCfgFilters = filters;
+
+ return this;
+ }
+
+ /**
+ *
+ */
+ private static class OneElementVariationsIterator extends VariationsIterator {
+ /** */
+ private int[] elem;
+
+ /** */
+ private boolean hasNext = true;
+
+ /**
+ * @param elem Element.
+ */
+ OneElementVariationsIterator(int[] elem, Object[][] params) {
+ super(params);
+
+ this.elem = elem;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean hasNext() {
+ return hasNext;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int[] next() {
+ hasNext = false;
+
+ return elem;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/953b575f/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/IgniteConfigVariationsTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/IgniteConfigVariationsTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/IgniteConfigVariationsTestSuite.java
new file mode 100644
index 0000000..d953c27
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/IgniteConfigVariationsTestSuite.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.testframework.configvariations;
+
+import junit.framework.Test;
+import junit.framework.TestResult;
+import junit.framework.TestSuite;
+import org.apache.ignite.testframework.junits.IgniteConfigVariationsAbstractTest;
+
+/**
+ * Configuration variations test suite.
+ */
+public class IgniteConfigVariationsTestSuite extends TestSuite {
+ /** */
+ protected final VariationsTestsConfig cfg;
+
+ /**
+ * @param cls Test class.
+ * @param cfg Configuration.
+ */
+ public IgniteConfigVariationsTestSuite(Class<? extends IgniteConfigVariationsAbstractTest> cls,
+ VariationsTestsConfig cfg) {
+ super(cls);
+
+ this.cfg = cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void runTest(Test test, TestResult res) {
+ if (test instanceof IgniteConfigVariationsAbstractTest)
+ ((IgniteConfigVariationsAbstractTest)test).setTestsConfiguration(cfg);
+
+ super.runTest(test, res);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/953b575f/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/Parameters.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/Parameters.java b/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/Parameters.java
new file mode 100644
index 0000000..27c0a48
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/Parameters.java
@@ -0,0 +1,377 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.testframework.configvariations;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayDeque;
+import java.util.Arrays;
+import java.util.Queue;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import javax.cache.configuration.Factory;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.T2;
+import org.apache.ignite.internal.util.typedef.internal.A;
+import org.apache.ignite.internal.util.typedef.internal.SB;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Parameters utils.
+ */
+public class Parameters {
+ /**
+ * Private constructor.
+ */
+ private Parameters() {
+ // No-op.
+ }
+
+ /**
+ * @return Array of configuration processors for given enum.
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> ConfigParameter<T>[] enumParameters(String mtdName, Class<?> enumCls) {
+ return enumParameters(false, mtdName, enumCls);
+ }
+
+ /**
+ * @return Array of configuration processors for given enum.
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> ConfigParameter<T>[] enumParameters(boolean withNull, String mtdName, Class<?> enumCls) {
+ return parameters0(mtdName, withNull, enumCls.getEnumConstants());
+ }
+
+ /**
+ * @param mtdName Method name.
+ * @param values Values.
+ * @return Array of configuration paramethers.
+ */
+ @SuppressWarnings("unchecked")
+ private static <T> ConfigParameter<T>[] parameters0(String mtdName, boolean withNull, Object[] values) {
+ for (Object val : values) {
+ if (!isPrimitiveOrEnum(val) && !(val instanceof Factory))
+ throw new IllegalArgumentException("Value have to be primite, enum or factory: " + val);
+ }
+
+ if (withNull) {
+ Object[] valuesWithNull = new Object[values.length + 1];
+
+ valuesWithNull[0] = null;
+
+ System.arraycopy(values, 0, valuesWithNull, 1, valuesWithNull.length - 1);
+
+ values = valuesWithNull;
+ }
+
+ assert values != null && values.length > 0 : "MtdName:" + mtdName;
+
+ ConfigParameter<T>[] resArr = new ConfigParameter[values.length];
+
+ for (int i = 0; i < resArr.length; i++)
+ resArr[i] = new ReflectionParameter<>(mtdName, values[i]);
+
+ return resArr;
+ }
+
+ /**
+ * @param val Value.
+ * @return Primitive or enum or not.
+ */
+ private static boolean isPrimitiveOrEnum(Object val) {
+ return val.getClass().isPrimitive()
+ || val.getClass().equals(Boolean.class)
+ || val.getClass().equals(Byte.class)
+ || val.getClass().equals(Short.class)
+ || val.getClass().equals(Character.class)
+ || val.getClass().equals(Integer.class)
+ || val.getClass().equals(Long.class)
+ || val.getClass().equals(Float.class)
+ || val.getClass().equals(Double.class)
+ || val.getClass().isEnum();
+ }
+
+ /**
+ * @return Array of configuration processors for given enum.
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> ConfigParameter<T>[] booleanParameters(String mtdName) {
+ return parameters0(mtdName, false, new Boolean[] {true, false});
+ }
+
+ /**
+ * @return Array of configuration processors for given enum.
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> ConfigParameter<T>[] booleanParameters(boolean withNull, String mtdName) {
+ return parameters0(mtdName, withNull, new Boolean[] {true, false});
+ }
+
+ /**
+ * @param mtdName Method name.
+ * @param values Values.
+ * @return Array of configuration processors for given classes.
+ */
+ public static ConfigParameter[] objectParameters(String mtdName, Object... values) {
+ return objectParameters(false, mtdName, values);
+ }
+
+ /**
+ * @param mtdName Method name.
+ * @param values Values.
+ * @return Array of configuration processors for given classes.
+ */
+ public static ConfigParameter[] objectParameters(boolean withNull, String mtdName, Object... values) {
+ return parameters0(mtdName, withNull, values);
+ }
+
+ /**
+ * @param mtdName Method name.
+ * @param val Value.
+ * @return Configuration parameter.
+ */
+ public static <T> ConfigParameter<T> parameter(String mtdName, Object val) {
+ return new ReflectionParameter<>(mtdName, val);
+ }
+
+ /**
+ * @return Complex parameter.
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> ConfigParameter<T> complexParameter(ConfigParameter<T>... params) {
+ return new ComplexParameter<T>(params);
+ }
+
+ /**
+ * @param cls Class.
+ * @return Factory that uses default constructor to initiate object by given class.
+ */
+ public static <T> Factory<T> factory(Class<?> cls) {
+ return new ReflectionFactory<>(cls);
+ }
+
+ /**
+ * Reflection configuration applier.
+ */
+ @SuppressWarnings("serial")
+ private static class ReflectionParameter<T> implements ConfigParameter<T> {
+ /** Classes of marameters cache. */
+ private static final ConcurrentMap<T2<Class, String>, Class> paramClassesCache = new ConcurrentHashMap();
+
+ /** */
+ private final String mtdName;
+
+ /** Primitive, enum or factory. */
+ private final Object val;
+
+ /**
+ * @param mtdName Method name.
+ */
+ ReflectionParameter(String mtdName, @Nullable Object val) {
+ if (val != null && !isPrimitiveOrEnum(val) && !(val instanceof Factory))
+ throw new IllegalArgumentException("Value have to be primite, enum or factory: " + val);
+
+ this.mtdName = mtdName;
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String name() {
+ String mtdName0 = mtdName;
+
+ if (mtdName0.startsWith("set") && mtdName0.length() > 3)
+ mtdName0 = mtdName0.substring(3, mtdName0.length());
+
+ String val0;
+
+ if (val == null)
+ val0 = "null";
+ else if (val instanceof Factory)
+ val0 = ((Factory)val).create().toString();
+ else
+ val0 = val.toString();
+
+ return mtdName0 + "=" + val0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public T apply(T cfg) {
+ if (val == null)
+ return null;
+
+ try {
+ Object val0 = val;
+
+ if (!isPrimitiveOrEnum(val))
+ val0 = ((Factory)val0).create();
+
+ Class<?> paramCls = paramClassesCache.get(new T2<Class, String>(cfg.getClass(), mtdName));
+
+ if (paramCls == null)
+ paramCls = val0.getClass();
+ else if (!paramCls.isInstance(val0))
+ throw new IgniteException("Class parameter from cache does not match value argument class " +
+ "[paramCls=" + paramCls + ", val=" + val0 + "]");
+
+ if (val0.getClass().equals(Boolean.class))
+ paramCls = Boolean.TYPE;
+ else if (val0.getClass().equals(Byte.class))
+ paramCls = Byte.TYPE;
+ else if (val0.getClass().equals(Short.class))
+ paramCls = Short.TYPE;
+ else if (val0.getClass().equals(Character.class))
+ paramCls = Character.TYPE;
+ else if (val0.getClass().equals(Integer.class))
+ paramCls = Integer.TYPE;
+ else if (val0.getClass().equals(Long.class))
+ paramCls = Long.TYPE;
+ else if (val0.getClass().equals(Float.class))
+ paramCls = Float.TYPE;
+ else if (val0.getClass().equals(Double.class))
+ paramCls = Double.TYPE;
+
+ Method mtd;
+
+ Queue<Class> queue = new ArrayDeque<>();
+
+ boolean failed = false;
+
+ while (true) {
+ try {
+ mtd = cfg.getClass().getMethod(mtdName, paramCls);
+
+ if (failed)
+ paramClassesCache.put(new T2<Class, String>(cfg.getClass(), mtdName), paramCls);
+
+ break;
+ }
+ catch (NoSuchMethodException e) {
+ failed = true;
+
+ U.warn(null, "Method not found [cfgCls=" + cfg.getClass() + ", mtdName=" + mtdName
+ + ", paramCls=" + paramCls + "]");
+
+ Class<?>[] interfaces = paramCls.getInterfaces();
+
+ Class<?> superclass = paramCls.getSuperclass();
+
+ if (superclass != null)
+ queue.add(superclass);
+
+ if (!F.isEmpty(interfaces))
+ queue.addAll(Arrays.asList(interfaces));
+
+ if (queue.isEmpty())
+ throw new IgniteException("Method not found [cfgCls=" + cfg.getClass() + ", mtdName="
+ + mtdName + ", paramCls=" + val0.getClass() + "]", e);
+
+ paramCls = queue.remove();
+ }
+ }
+
+ mtd.invoke(cfg, val0);
+ }
+ catch (InvocationTargetException | IllegalAccessException e) {
+ throw new IgniteException(e);
+ }
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ReflectionFactory<T> implements Factory<T> {
+ /** */
+ private static final long serialVersionUID = 0;
+
+ /** */
+ private Class<?> cls;
+
+ /**
+ * @param cls Class.
+ */
+ ReflectionFactory(Class<?> cls) {
+ this.cls = cls;
+ }
+
+ /** {@inheritDoc} */
+ @Override public T create() {
+ try {
+ Constructor<?> constructor = cls.getConstructor();
+
+ return (T)constructor.newInstance();
+ }
+ catch (NoSuchMethodException | InstantiationException | InvocationTargetException |
+ IllegalAccessException e) {
+ throw new IgniteException("Failed to create object using default constructor: " + cls, e);
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ComplexParameter<T> implements ConfigParameter<T> {
+ /** */
+ private final String name;
+
+ /** */
+ private ConfigParameter<T>[] params;
+
+ /**
+ * @param params Params
+ */
+ @SafeVarargs
+ ComplexParameter(ConfigParameter<T>... params) {
+ A.notEmpty(params, "params");
+
+ this.params = params;
+
+ if (params.length == 1)
+ name = params[0].name();
+ else {
+ SB sb = new SB(params[0].name());
+
+ for (int i = 1; i < params.length; i++)
+ sb.a('-').a(params[i]);
+
+ name = sb.toString();
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public String name() {
+ return name;
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override public T apply(T cfg) {
+ for (ConfigParameter param : params)
+ param.apply(cfg);
+
+ return cfg;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/953b575f/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/VariationsIterator.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/VariationsIterator.java b/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/VariationsIterator.java
new file mode 100644
index 0000000..fa1c216
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/VariationsIterator.java
@@ -0,0 +1,174 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.testframework.configvariations;
+
+import java.util.Arrays;
+import java.util.Iterator;
+
+/**
+ * Variations iterator.
+ */
+public class VariationsIterator implements Iterator<int[]> {
+ /** */
+ private final Object[][] params;
+
+ /** */
+ private final int[] vector;
+
+ /** */
+ private int position;
+
+ /** */
+ private final int expCntOfVectors;
+
+ /** */
+ private int cntOfVectors;
+
+ /**
+ * @param params Paramethers.
+ */
+ public VariationsIterator(Object[][] params) {
+ assert params != null;
+ assert params.length > 0;
+
+ for (int i = 0; i < params.length; i++) {
+ assert params[i] != null : i;
+ assert params[i].length > 0 : i;
+ }
+
+ this.params = params;
+
+ vector = new int[params.length];
+
+ for (int i = 0; i < vector.length; i++)
+ vector[i] = 0;
+
+ position = -1;
+
+ int cntOfVectors0 = 1;
+
+ for (int i = 0; i < params.length; i++)
+ cntOfVectors0 *= params[i].length;
+
+ expCntOfVectors = cntOfVectors0;
+
+ cntOfVectors = 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean hasNext() {
+ return cntOfVectors < expCntOfVectors;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int[] next() {
+ // Only first call.
+ if (position == -1) {
+ position = 0;
+
+ cntOfVectors++;
+
+ return arraycopy(vector);
+ }
+
+ if (!updateVector(vector, position)) {
+ if (position + 1 == params.length)
+ throw new IllegalStateException("[position=" + position + ", vector=" +
+ Arrays.toString(vector) + ", params=" + Arrays.deepToString(params));
+
+ position++;
+
+ // Skip params with length 1. We cannot set 1 at this position.
+ while (position < params.length && params[position].length < 2)
+ position++;
+
+ if (position == params.length)
+ throw new IllegalStateException("[position=" + position + ", vector=" +
+ Arrays.toString(vector) + ", params=" + Arrays.deepToString(params));
+
+ vector[position] = 1;
+
+ cntOfVectors++;
+
+ return arraycopy(vector);
+ }
+
+ cntOfVectors++;
+
+ return arraycopy(vector);
+ }
+
+ /**
+ * Updates vector starting from position.
+ *
+ * @param vector Vector.
+ * @param position Position.
+ * @return {@code True} if vector has been updated. When {@code false} is returned it means that all positions
+ * before has been set to {@code 0}.
+ */
+ private boolean updateVector(int[] vector, int position) {
+ if (position == 0) {
+ int val = vector[0];
+
+ if (val + 1 < params[0].length) {
+ vector[0] = val + 1;
+
+ return true;
+ }
+ else {
+ vector[0] = 0;
+
+ return false;
+ }
+ }
+
+ if (updateVector(vector, position - 1))
+ return true;
+
+ int val = vector[position];
+
+ if (val + 1 < params[position].length) {
+ vector[position] = val + 1;
+
+ return true;
+ }
+ else {
+ vector[position] = 0;
+
+ return false;
+ }
+
+ }
+
+ /**
+ * @param arr Array.
+ * @return Array copy.
+ */
+ private static int[] arraycopy(int[] arr) {
+ int[] dest = new int[arr.length];
+
+ System.arraycopy(arr, 0, dest, 0, arr.length);
+
+ return dest;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void remove() {
+ throw new UnsupportedOperationException();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/953b575f/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/VariationsTestsConfig.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/VariationsTestsConfig.java b/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/VariationsTestsConfig.java
new file mode 100644
index 0000000..7bcfc7f
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/configvariations/VariationsTestsConfig.java
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.testframework.configvariations;
+
+import org.apache.ignite.internal.util.typedef.internal.A;
+
+/**
+ * Immutable tests configuration.
+ */
+public class VariationsTestsConfig {
+ /** */
+ private final ConfigFactory factory;
+
+ /** */
+ private final String desc;
+
+ /** */
+ private final boolean stopNodes;
+
+ /** */
+ private final int gridCnt;
+
+ /** */
+ private final CacheStartMode cacheStartMode;
+
+ /** */
+ private final int testedNodeIdx;
+
+ /** */
+ private boolean startCache;
+
+ /** */
+ private boolean stopCache;
+
+ /** */
+ private boolean withClients;
+
+ /**
+ * @param factory Factory.
+ * @param desc Class suffix.
+ * @param stopNodes Stope nodes.
+ * @param gridCnt Grdi count.
+ */
+ public VariationsTestsConfig(
+ ConfigFactory factory,
+ String desc,
+ boolean stopNodes,
+ CacheStartMode cacheStartMode,
+ int gridCnt
+ ) {
+ this(factory, desc, stopNodes, true, true, cacheStartMode, gridCnt, 0, false);
+ }
+
+ /**
+ * @param factory Factory.
+ * @param desc Config description.
+ * @param stopNodes Stope nodes.
+ * @param gridCnt Grdi count.
+ */
+ public VariationsTestsConfig(
+ ConfigFactory factory,
+ String desc,
+ boolean stopNodes,
+ boolean startCache,
+ boolean stopCache,
+ CacheStartMode cacheStartMode,
+ int gridCnt,
+ int testedNodeIdx,
+ boolean withClients
+ ) {
+ A.ensure(gridCnt >= 1, "Grids count cannot be less then 1.");
+
+ this.factory = factory;
+ this.desc = desc;
+ this.gridCnt = gridCnt;
+ this.cacheStartMode = cacheStartMode;
+ this.testedNodeIdx = testedNodeIdx;
+ this.stopNodes = stopNodes;
+ this.startCache = startCache;
+ this.stopCache = stopCache;
+ this.withClients = withClients;
+ }
+
+ /**
+ * @return Configuration factory.
+ */
+ public ConfigFactory configurationFactory() {
+ return factory;
+ }
+
+ /**
+ * @return Configuration description..
+ */
+ public String description() {
+ return desc;
+ }
+
+ /**
+ * @return Grids count.
+ */
+ public int gridCount() {
+ return gridCnt;
+ }
+
+ /**
+ * @return Whether nodes should be stopped after tests execution or not.
+ */
+ public boolean isStopNodes() {
+ return stopNodes;
+ }
+
+ /**
+ * @return Cache start type.
+ */
+ public CacheStartMode cacheStartMode() {
+ return cacheStartMode;
+ }
+
+ /**
+ * @return Index of node which should be tested or {@code null}.
+ */
+ public int testedNodeIndex() {
+ return testedNodeIdx;
+ }
+
+ /**
+ * @return Whether cache should be started before tests execution or not.
+ */
+ public boolean isStartCache() {
+ return startCache;
+ }
+
+ /**
+ * @return Whether cache should be destroyed after tests execution or not.
+ */
+ public boolean isStopCache() {
+ return stopCache;
+ }
+
+ /**
+ * @return With clients.
+ */
+ public boolean withClients() {
+ return withClients;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/953b575f/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
index 614e634..2f8155c 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
@@ -153,7 +153,7 @@ public abstract class GridAbstractTest extends TestCase {
private static long ts = System.currentTimeMillis();
/** Starting grid name. */
- protected final static ThreadLocal<String> startingGrid = new ThreadLocal<>();
+ protected static final ThreadLocal<String> startingGrid = new ThreadLocal<>();
/**
*
@@ -528,7 +528,7 @@ public abstract class GridAbstractTest extends TestCase {
}
if (isFirstTest()) {
- info(">>> Starting test class: " + GridTestUtils.fullSimpleName(getClass()) + " <<<");
+ info(">>> Starting test class: " + testClassDescription() + " <<<");
if (startGrid) {
IgniteConfiguration cfg = optimize(getConfiguration());
@@ -561,7 +561,7 @@ public abstract class GridAbstractTest extends TestCase {
}
}
- info(">>> Starting test: " + getName() + " <<<");
+ info(">>> Starting test: " + testDescription() + " <<<");
try {
beforeTest();
@@ -581,6 +581,20 @@ public abstract class GridAbstractTest extends TestCase {
}
/**
+ * @return Test description.
+ */
+ protected String testDescription() {
+ return GridTestUtils.fullSimpleName(getClass()) + "#" + getName();
+ }
+
+ /**
+ * @return Test class description.
+ */
+ protected String testClassDescription() {
+ return GridTestUtils.fullSimpleName(getClass());
+ }
+
+ /**
* @return Started grid.
* @throws Exception If anything failed.
*/
@@ -738,16 +752,29 @@ public abstract class GridAbstractTest extends TestCase {
* @throws Exception If failed.
*/
protected Ignite startGrid(String gridName, GridSpringResourceContext ctx) throws Exception {
+ return startGrid(gridName, optimize(getConfiguration(gridName)), ctx);
+ }
+ /**
+ * Starts new grid with given name.
+ *
+ * @param gridName Grid name.
+ * @param ctx Spring context.
+ * @return Started grid.
+ * @throws Exception If failed.
+ */
+ protected Ignite startGrid(String gridName, IgniteConfiguration cfg, GridSpringResourceContext ctx)
+ throws Exception {
if (!isRemoteJvm(gridName)) {
startingGrid.set(gridName);
try {
- Ignite node = IgnitionEx.start(optimize(getConfiguration(gridName)), ctx);
+ Ignite node = IgnitionEx.start(cfg, ctx);
- IgniteConfiguration cfg = node.configuration();
+ IgniteConfiguration nodeCfg = node.configuration();
log.info("Node started with the following configuration [id=" + node.cluster().localNode().id()
- + ", marshaller=" + cfg.getMarshaller() + ", binaryCfg=" + cfg.getBinaryConfiguration() + "]");
+ + ", marshaller=" + nodeCfg.getMarshaller()
+ + ", binaryCfg=" + nodeCfg.getBinaryConfiguration() + "]");
return node;
}
@@ -1382,7 +1409,7 @@ public abstract class GridAbstractTest extends TestCase {
@Override protected void tearDown() throws Exception {
long dur = System.currentTimeMillis() - ts;
- info(">>> Stopping test: " + getName() + " in " + dur + " ms <<<");
+ info(">>> Stopping test: " + testDescription() + " in " + dur + " ms <<<");
TestCounters cntrs = getTestCounters();
@@ -1397,7 +1424,7 @@ public abstract class GridAbstractTest extends TestCase {
serializedObj.clear();
if (isLastTest()) {
- info(">>> Stopping test class: " + GridTestUtils.fullSimpleName(getClass()) + " <<<");
+ info(">>> Stopping test class: " + testClassDescription() + " <<<");
TestCounters counters = getTestCounters();
[14/20] ignite git commit: IGNITE-1186 WIP
Posted by nt...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/9ad476b2/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 62ed66f..23b9d85 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
@@ -576,7 +576,7 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
* @param deploy The place where continuous query will be started.
* @throws Exception If failed.
*/
- private void testContinuousQuery(CacheConfiguration<Object, Object> ccfg, ContinuousDeploy deploy)
+ protected void testContinuousQuery(CacheConfiguration<Object, Object> ccfg, ContinuousDeploy deploy)
throws Exception {
ignite(0).createCache(ccfg);
@@ -1176,7 +1176,7 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
/**
*
*/
- static class QueryTestKey implements Serializable, Comparable {
+ public static class QueryTestKey implements Serializable, Comparable {
/** */
private final Integer key;
@@ -1219,12 +1219,12 @@ public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstract
/**
*
*/
- static class QueryTestValue implements Serializable {
+ public static class QueryTestValue implements Serializable {
/** */
- private final Integer val1;
+ protected final Integer val1;
/** */
- private final String val2;
+ protected final String val2;
/**
* @param val Value.
http://git-wip-us.apache.org/repos/asf/ignite/blob/9ad476b2/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentEntryEventFilter.java
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentEntryEventFilter.java b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentEntryEventFilter.java
new file mode 100644
index 0000000..359dd58
--- /dev/null
+++ b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentEntryEventFilter.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.tests.p2p;
+
+import javax.cache.event.CacheEntryEvent;
+import javax.cache.event.CacheEntryEventFilter;
+import javax.cache.event.CacheEntryListenerException;
+
+/**
+ * Event filter for deployment.
+ */
+public class CacheDeploymentEntryEventFilter implements CacheEntryEventFilter<Integer, Integer> {
+ /** {@inheritDoc} */
+ @Override public boolean evaluate(CacheEntryEvent<? extends Integer, ? extends Integer> evt)
+ throws CacheEntryListenerException {
+ return evt.getValue() == null || evt.getValue() % 2 != 0;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9ad476b2/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentEntryEventFilterFactory.java
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentEntryEventFilterFactory.java b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentEntryEventFilterFactory.java
new file mode 100644
index 0000000..0d6eceb
--- /dev/null
+++ b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentEntryEventFilterFactory.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.tests.p2p;
+
+import javax.cache.configuration.Factory;
+import javax.cache.event.CacheEntryEventFilter;
+
+/**
+ * Event filter factory for deployment.
+ */
+public class CacheDeploymentEntryEventFilterFactory implements Factory<CacheEntryEventFilter<Integer, Integer>> {
+ /** {@inheritDoc} */
+ @Override public CacheEntryEventFilter<Integer, Integer> create() {
+ return new CacheDeploymentEntryEventFilter();
+ }
+}
[17/20] ignite git commit: Added print partition stats.
Posted by nt...@apache.org.
Added print partition stats.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c4d6f3cd
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c4d6f3cd
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c4d6f3cd
Branch: refs/heads/ignite-1186
Commit: c4d6f3cddf0a7ef89d6126eff432775e713e797a
Parents: 071498f
Author: nikolay_tikhonov <nt...@gridgain.com>
Authored: Mon Feb 29 22:37:38 2016 +0300
Committer: nikolay_tikhonov <nt...@gridgain.com>
Committed: Mon Feb 29 22:37:38 2016 +0300
----------------------------------------------------------------------
.../ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4d6f3cd/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java
index c9a4b9c..6c25ec0 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java
@@ -87,9 +87,11 @@ public abstract class IgniteCacheAbstractBenchmark<K, V> extends IgniteAbstractB
List<Integer> primary = e.getValue().get1();
List<Integer> backup = e.getValue().get2();
- BenchmarkUtils.println(cfg, e.getKey().id() + " " + primary.size() + " " + primary.size() * 1. /
- aff.partitions() + " " + backup.size() + " "
- + backup.size() * 1. / (aff.partitions() * args.backups() == 0 ? 1 : args.backups())
+ BenchmarkUtils.println(cfg, e.getKey().id() + " "
+ + primary.size() + " " + primary.size() * 1. /aff.partitions() + " "
+ + backup.size() + " "
+ + backup.size() * 1. / (aff.partitions() * (args.backups() == 0 ? 1 : args.backups())) + " "
+ + (primary.size() + backup.size()) + " "
+ (primary.size() + backup.size() * 1.) / (aff.partitions() * args.backups() + aff.partitions())
);
}
[18/20] ignite git commit: IGNITE-2650
Posted by nt...@apache.org.
IGNITE-2650
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/89172691
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/89172691
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/89172691
Branch: refs/heads/ignite-1186
Commit: 891726916390c2de5c4c28cc308b0fac0a3c9974
Parents: c4d6f3c
Author: ruskim <ru...@gmail.com>
Authored: Tue Mar 1 12:13:14 2016 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Tue Mar 1 12:13:14 2016 +0300
----------------------------------------------------------------------
.../processors/cache/GridCacheProcessor.java | 8 +
.../processors/cache/GridCacheUtils.java | 15 ++
.../org/apache/ignite/spi/IgniteSpiAdapter.java | 15 ++
.../ignite/spi/IgniteSpiConsistencyChecked.java | 8 +
.../spi/swapspace/file/FileSwapSpaceSpi.java | 2 +
.../spi/swapspace/noop/NoopSwapSpaceSpi.java | 2 +
...ridCacheSwapSpaceSpiConsistencySelfTest.java | 146 +++++++++++++++++++
.../GridSwapSpaceSpiConsistencySelfTest.java | 131 +++++++++++++++++
.../testsuites/IgniteCacheTestSuite5.java | 2 +
.../IgniteSpiSwapSpaceSelfTestSuite.java | 2 +
10 files changed, 331 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/89172691/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index a8f205b..c0fc32a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -2271,6 +2271,14 @@ public class GridCacheProcessor extends GridProcessorAdapter {
req.startCacheConfiguration(ccfg);
}
+ // Fail cache with swap enabled creation on grid without swap space SPI.
+ if (ccfg.isSwapEnabled())
+ for (ClusterNode n : ctx.discovery().allNodes())
+ if (!GridCacheUtils.clientNode(n) && !GridCacheUtils.isSwapEnabled(n))
+ return new GridFinishedFuture<>(new IgniteCheckedException("Failed to start cache " +
+ cacheName + " with swap enabled: Remote Node with ID " + n.id().toString().toUpperCase() +
+ " has not swap SPI configured"));
+
if (nearCfg != null)
req.nearCacheConfiguration(nearCfg);
http://git-wip-us.apache.org/repos/asf/ignite/blob/89172691/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
index cd21794..dce5357 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
@@ -90,6 +90,7 @@ import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.lang.IgniteReducer;
import org.apache.ignite.lifecycle.LifecycleAware;
import org.apache.ignite.plugin.CachePluginConfiguration;
+import org.apache.ignite.spi.swapspace.noop.NoopSwapSpaceSpi;
import org.apache.ignite.transactions.Transaction;
import org.apache.ignite.transactions.TransactionConcurrency;
import org.apache.ignite.transactions.TransactionIsolation;
@@ -283,6 +284,10 @@ public class GridCacheUtils {
}
};
+ /** NoopSwapSpaceSpi used attribute. */
+ private static final String NOOP_SWAP_SPACE_SPI_ATTR_NAME = U.spiAttribute(new NoopSwapSpaceSpi(),
+ IgniteNodeAttributes.ATTR_SPI_CLASS);
+
/**
* Ensure singleton.
*/
@@ -1836,4 +1841,14 @@ public class GridCacheUtils {
return res;
}
+
+ /**
+ * Checks if swap is enabled on node.
+ *
+ * @param node Node
+ * @return {@code true} if swap is enabled, {@code false} otherwise.
+ */
+ public static boolean isSwapEnabled(ClusterNode node) {
+ return !node.attributes().containsKey(NOOP_SWAP_SPACE_SPI_ATTR_NAME);
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/89172691/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java
index 1cb202c..f31aae7 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java
@@ -39,10 +39,12 @@ import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.IgniteNodeAttributes;
import org.apache.ignite.internal.managers.communication.GridMessageListener;
import org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener;
+import org.apache.ignite.internal.processors.cache.GridCacheUtils;
import org.apache.ignite.internal.processors.timeout.GridSpiTimeoutObject;
import org.apache.ignite.internal.util.IgniteExceptionRegistry;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.X;
+import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.SB;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteFuture;
@@ -448,6 +450,15 @@ public abstract class IgniteSpiAdapter implements IgniteSpi, IgniteSpiManagement
}
/**
+ * @return {@code true} if client cluster nodes should be checked.
+ */
+ private boolean checkClient() {
+ IgniteSpiConsistencyChecked ann = U.getAnnotation(getClass(), IgniteSpiConsistencyChecked.class);
+
+ return ann != null && ann.checkClient();
+ }
+
+ /**
* Method which is called in the end of checkConfigurationConsistency() method. May be overriden in SPIs.
*
* @param spiCtx SPI context.
@@ -480,10 +491,14 @@ public abstract class IgniteSpiAdapter implements IgniteSpi, IgniteSpiManagement
*/
boolean optional = checkOptional();
boolean enabled = checkEnabled();
+ boolean checkClient = checkClient();
if (!enabled)
return;
+ if (!checkClient && (CU.clientNode(getLocalNode()) || CU.clientNode(node)))
+ return;
+
String clsAttr = createSpiAttributeName(IgniteNodeAttributes.ATTR_SPI_CLASS);
String name = getName();
http://git-wip-us.apache.org/repos/asf/ignite/blob/89172691/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiConsistencyChecked.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiConsistencyChecked.java b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiConsistencyChecked.java
index 157d9ce..81ab21e 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiConsistencyChecked.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiConsistencyChecked.java
@@ -40,4 +40,12 @@ public @interface IgniteSpiConsistencyChecked {
*/
@SuppressWarnings("JavaDoc")
public boolean optional();
+
+ /**
+ * If false, skip consistency checks for client cluster nodes. Could be useful
+ * for SwapSpaceSpi for example, since client nodes has no data at all, so they
+ * don't need to be consistent with server nodes.
+ */
+ @SuppressWarnings("JavaDoc")
+ public boolean checkClient() default true;
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/89172691/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java
index df35ed3..8809f08 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java
@@ -61,6 +61,7 @@ import org.apache.ignite.resources.LoggerResource;
import org.apache.ignite.spi.IgniteSpiAdapter;
import org.apache.ignite.spi.IgniteSpiCloseableIterator;
import org.apache.ignite.spi.IgniteSpiConfiguration;
+import org.apache.ignite.spi.IgniteSpiConsistencyChecked;
import org.apache.ignite.spi.IgniteSpiException;
import org.apache.ignite.spi.IgniteSpiMultipleInstancesSupport;
import org.apache.ignite.spi.IgniteSpiThread;
@@ -137,6 +138,7 @@ import static org.apache.ignite.events.EventType.EVT_SWAP_SPACE_DATA_STORED;
* @see org.apache.ignite.spi.swapspace.SwapSpaceSpi
*/
@IgniteSpiMultipleInstancesSupport(true)
+@IgniteSpiConsistencyChecked(optional = false, checkClient = false)
@SuppressWarnings({"PackageVisibleInnerClass", "PackageVisibleField"})
public class FileSwapSpaceSpi extends IgniteSpiAdapter implements SwapSpaceSpi, FileSwapSpaceSpiMBean {
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/89172691/modules/core/src/main/java/org/apache/ignite/spi/swapspace/noop/NoopSwapSpaceSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/swapspace/noop/NoopSwapSpaceSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/swapspace/noop/NoopSwapSpaceSpi.java
index 13622d9..df73eb0 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/swapspace/noop/NoopSwapSpaceSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/swapspace/noop/NoopSwapSpaceSpi.java
@@ -30,6 +30,7 @@ import org.apache.ignite.lang.IgniteInClosure;
import org.apache.ignite.resources.LoggerResource;
import org.apache.ignite.spi.IgniteSpiAdapter;
import org.apache.ignite.spi.IgniteSpiCloseableIterator;
+import org.apache.ignite.spi.IgniteSpiConsistencyChecked;
import org.apache.ignite.spi.IgniteSpiException;
import org.apache.ignite.spi.IgniteSpiMultipleInstancesSupport;
import org.apache.ignite.spi.IgniteSpiNoop;
@@ -44,6 +45,7 @@ import org.jetbrains.annotations.Nullable;
*/
@IgniteSpiNoop
@IgniteSpiMultipleInstancesSupport(true)
+@IgniteSpiConsistencyChecked(optional = false, checkClient = false)
public class NoopSwapSpaceSpi extends IgniteSpiAdapter implements SwapSpaceSpi {
/** Logger. */
@LoggerResource
http://git-wip-us.apache.org/repos/asf/ignite/blob/89172691/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheSwapSpaceSpiConsistencySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheSwapSpaceSpiConsistencySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheSwapSpaceSpiConsistencySelfTest.java
new file mode 100644
index 0000000..74ac2fc
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheSwapSpaceSpiConsistencySelfTest.java
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import java.util.concurrent.Callable;
+import javax.cache.CacheException;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.spi.swapspace.file.FileSwapSpaceSpi;
+import org.apache.ignite.spi.swapspace.noop.NoopSwapSpaceSpi;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.testframework.junits.common.GridCommonTest;
+
+/**
+ * Check creation of cache with swap space enabled on grids with and without swap space spi
+ */
+@SuppressWarnings({"ProhibitedExceptionDeclared"})
+@GridCommonTest(group = "Kernal")
+public class GridCacheSwapSpaceSpiConsistencySelfTest extends GridCommonAbstractTest {
+ /** */
+ protected static final String GRID_WITHOUT_SWAP_SPACE = "grid-without-swap-space";
+
+ /** */
+ protected static final String GRID_WITH_SWAP_SPACE = "grid-with-swap-space";
+
+ /** */
+ protected static final String GRID_CLIENT = "grid-client";
+
+ /** */
+ protected static final String CACHE_NAME = "TestCache";
+
+ /**
+ *
+ */
+ public GridCacheSwapSpaceSpiConsistencySelfTest() {
+ super(false);
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings({"unchecked"})
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ if (gridName.startsWith(GRID_WITHOUT_SWAP_SPACE))
+ cfg.setSwapSpaceSpi(new NoopSwapSpaceSpi());
+
+ if (gridName.startsWith(GRID_WITH_SWAP_SPACE))
+ cfg.setSwapSpaceSpi(new FileSwapSpaceSpi());
+
+ if (GRID_CLIENT.equals(gridName))
+ cfg.setClientMode(true);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ stopAllGrids();
+ }
+
+ /**
+ *
+ */
+ public void testInconsistentCacheCreationFromClient() throws Exception {
+ testInconsistentCacheCreation(true);
+ }
+
+ /**
+ *
+ */
+ public void testInconsistentCacheCreationFromServer() throws Exception {
+ testInconsistentCacheCreation(false);
+ }
+
+ /**
+ * It should be impossible to create cache with swap enabled on grid without swap.
+ */
+ public void testInconsistentCacheCreation(boolean fromClient) throws Exception {
+ startGrid(GRID_WITHOUT_SWAP_SPACE);
+
+ final Ignite ignite = startGrid(fromClient ? GRID_CLIENT : GRID_WITHOUT_SWAP_SPACE + "2");
+
+ final CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>();
+
+ cfg.setSwapEnabled(true);
+ cfg.setName(CACHE_NAME);
+
+ GridTestUtils.assertThrows(log, new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ return ignite.createCache(cfg);
+ }
+ }, CacheException.class, "Failed to start cache " + CACHE_NAME + " with swap enabled:");
+ }
+
+ /**
+ *
+ */
+ public void testConsistentCacheCreationFromClient() throws Exception {
+ testConsistentCacheCreation(true);
+ }
+
+ /**
+ *
+ */
+ public void testConsistentCacheCreationFromServer() throws Exception {
+ testConsistentCacheCreation(false);
+ }
+
+ /**
+ * It should ok to create cache with swap enabled on grid with swap.
+ */
+ public void testConsistentCacheCreation(boolean fromClient) throws Exception {
+ startGrid(GRID_WITH_SWAP_SPACE);
+
+ final Ignite ignite = startGrid(fromClient ? GRID_CLIENT : GRID_WITH_SWAP_SPACE + "2");
+
+ final CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>();
+
+ cfg.setSwapEnabled(true);
+ cfg.setName(CACHE_NAME);
+
+ IgniteCache<Integer, String> cache = ignite.createCache(cfg);
+
+ cache.put(1, "one");
+
+ assert cache.get(1).equals("one");
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/89172691/modules/core/src/test/java/org/apache/ignite/spi/swapspace/GridSwapSpaceSpiConsistencySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/swapspace/GridSwapSpaceSpiConsistencySelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/swapspace/GridSwapSpaceSpiConsistencySelfTest.java
new file mode 100644
index 0000000..8efafdf
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/spi/swapspace/GridSwapSpaceSpiConsistencySelfTest.java
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.spi.swapspace;
+
+import java.util.concurrent.Callable;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.spi.swapspace.file.FileSwapSpaceSpi;
+import org.apache.ignite.spi.swapspace.noop.NoopSwapSpaceSpi;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ * Check that all server nodes in grid have configured the same swap space spi. Check that client nodes could have any
+ * swap space spi.
+ */
+@SuppressWarnings({"ProhibitedExceptionDeclared"})
+public class GridSwapSpaceSpiConsistencySelfTest extends GridCommonAbstractTest {
+ /** */
+ protected static final String GRID_WITHOUT_SWAP_SPACE = "grid-without-swap-space";
+
+ /** */
+ protected static final String GRID_WITH_SWAP_SPACE = "grid-with-swap-space";
+
+ /** */
+ protected static final String GRID_CLIENT_WITHOUT_SWAP_SPACE = "grid-client-without-swap-space";
+
+ /** */
+ protected static final String GRID_CLIENT_WITH_SWAP_SPACE = "grid-client-with-swap-space";
+
+ /** */
+ protected static final String CACHE_NAME = "TestCache";
+
+ /**
+ *
+ */
+ public GridSwapSpaceSpiConsistencySelfTest() {
+ super(false);
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings({"unchecked"})
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ if (GRID_WITHOUT_SWAP_SPACE.equals(gridName))
+ cfg.setSwapSpaceSpi(new NoopSwapSpaceSpi());
+
+ if (GRID_WITH_SWAP_SPACE.equals(gridName))
+ cfg.setSwapSpaceSpi(new FileSwapSpaceSpi());
+
+ if (GRID_CLIENT_WITHOUT_SWAP_SPACE.equals(gridName)) {
+ cfg.setClientMode(true);
+ cfg.setSwapSpaceSpi(new NoopSwapSpaceSpi());
+ }
+
+ if (GRID_CLIENT_WITH_SWAP_SPACE.equals(gridName)) {
+ cfg.setClientMode(true);
+ cfg.setSwapSpaceSpi(new FileSwapSpaceSpi());
+ }
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ stopAllGrids();
+ }
+
+ /**
+ * Node with swap enabled should not start after node without swap
+ */
+ public void testServerNodeIncompatibleSwapSpaceSpi1() throws Exception {
+ startGrid(GRID_WITHOUT_SWAP_SPACE);
+
+ GridTestUtils.assertThrows(log, new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ return startGrid(GRID_WITH_SWAP_SPACE);
+ }
+ }, IgniteCheckedException.class, "Failed to initialize SPI context");
+ }
+
+ /**
+ * Node without swap should not start after node with swap enabled
+ */
+ public void testServerNodeIncompatibleSwapSpaceSpi2() throws Exception {
+ startGrid(GRID_WITH_SWAP_SPACE);
+
+ GridTestUtils.assertThrows(log, new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ return startGrid(GRID_WITHOUT_SWAP_SPACE);
+ }
+ }, IgniteCheckedException.class, "Failed to initialize SPI context");
+ }
+
+ /**
+ * Client nodes should join to grid with any swap policy
+ */
+ public void testClientNodeAnySwapSpaceSpi() throws Exception {
+ startGrid(GRID_WITHOUT_SWAP_SPACE);
+
+ Ignite client1 = startGrid(GRID_CLIENT_WITH_SWAP_SPACE);
+
+ Ignite client2 = startGrid(GRID_CLIENT_WITHOUT_SWAP_SPACE);
+
+ IgniteCache<Integer, String> cache1 = client1.createCache("TestCache");
+
+ cache1.put(1, "one");
+
+ IgniteCache<Integer, String> cache2 = client2.getOrCreateCache("TestCache");
+
+ assert cache2.get(1).equals("one");
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/89172691/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
index 3eb0b13..305f5cd 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
@@ -20,6 +20,7 @@ package org.apache.ignite.testsuites;
import junit.framework.TestSuite;
import org.apache.ignite.internal.processors.cache.CacheNearReaderUpdateTest;
import org.apache.ignite.internal.processors.cache.CacheSerializableTransactionsTest;
+import org.apache.ignite.internal.processors.cache.GridCacheSwapSpaceSpiConsistencySelfTest;
import org.apache.ignite.internal.processors.cache.IgniteCachePutStackOverflowSelfTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheStoreCollectionTest;
import org.apache.ignite.internal.processors.cache.store.IgniteCacheWriteBehindNoUpdateSelfTest;
@@ -40,6 +41,7 @@ public class IgniteCacheTestSuite5 extends TestSuite {
suite.addTestSuite(IgniteCacheStoreCollectionTest.class);
suite.addTestSuite(IgniteCacheWriteBehindNoUpdateSelfTest.class);
suite.addTestSuite(IgniteCachePutStackOverflowSelfTest.class);
+ suite.addTestSuite(GridCacheSwapSpaceSpiConsistencySelfTest.class);
return suite;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/89172691/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiSwapSpaceSelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiSwapSpaceSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiSwapSpaceSelfTestSuite.java
index 6d44934..3bf1b1b 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiSwapSpaceSelfTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiSwapSpaceSelfTestSuite.java
@@ -21,6 +21,7 @@ import junit.framework.TestSuite;
import org.apache.ignite.spi.swapspace.file.GridFileSwapCompactionSelfTest;
import org.apache.ignite.spi.swapspace.file.GridFileSwapSpaceSpiSelfTest;
import org.apache.ignite.spi.swapspace.noop.GridNoopSwapSpaceSpiSelfTest;
+import org.apache.ignite.spi.swapspace.GridSwapSpaceSpiConsistencySelfTest;
/**
*
@@ -36,6 +37,7 @@ public class IgniteSpiSwapSpaceSelfTestSuite {
suite.addTest(new TestSuite(GridFileSwapCompactionSelfTest.class));
suite.addTest(new TestSuite(GridFileSwapSpaceSpiSelfTest.class));
suite.addTest(new TestSuite(GridNoopSwapSpaceSpiSelfTest.class));
+ suite.addTest(new TestSuite(GridSwapSpaceSpiConsistencySelfTest.class));
return suite;
}
[13/20] ignite git commit: Added output cache configuration in
yardstick.
Posted by nt...@apache.org.
Added output cache configuration in yardstick.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/62c26d5a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/62c26d5a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/62c26d5a
Branch: refs/heads/ignite-1186
Commit: 62c26d5a1257eb581b35d766098bf75fd8515d68
Parents: 953b575
Author: nikolay_tikhonov <nt...@gridgain.com>
Authored: Mon Feb 29 16:27:09 2016 +0300
Committer: nikolay_tikhonov <nt...@gridgain.com>
Committed: Mon Feb 29 16:27:09 2016 +0300
----------------------------------------------------------------------
.../src/main/java/org/apache/ignite/yardstick/IgniteNode.java | 2 ++
1 file changed, 2 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/62c26d5a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteNode.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteNode.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteNode.java
index 33656fb..eed4450 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteNode.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteNode.java
@@ -136,6 +136,8 @@ public class IgniteNode implements BenchmarkServer {
cc.setWriteThrough(args.isStoreEnabled());
cc.setWriteBehindEnabled(args.isWriteBehind());
+
+ BenchmarkUtils.println(cfg, "Cache configured with the following parameters: " + cc);
}
TransactionConfiguration tc = c.getTransactionConfiguration();
[12/20] ignite git commit: ignite-2521: Configuration variations
tests framework + IgniteCacheBasicConfigVariationsFullApiTestSuite +
ignite-2554: Fixed Affinity.mapKeyToNode() for dynamically started LOCAL
cache
Posted by nt...@apache.org.
ignite-2521: Configuration variations tests framework + IgniteCacheBasicConfigVariationsFullApiTestSuite + ignite-2554: Fixed Affinity.mapKeyToNode() for dynamically started LOCAL cache
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/953b575f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/953b575f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/953b575f
Branch: refs/heads/ignite-1186
Commit: 953b575f0321acd90374c2dd92b32825842999ab
Parents: 49dcd6b
Author: ashutak <as...@gridgain.com>
Authored: Mon Feb 29 14:00:45 2016 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Mon Feb 29 14:00:45 2016 +0300
----------------------------------------------------------------------
.../cache/affinity/GridCacheAffinityImpl.java | 7 +-
.../cache/GridCacheAbstractFullApiSelfTest.java | 10 +-
.../IgniteCacheConfigVariationsFullApiTest.java | 5851 ++++++++++++++++++
.../configvariations/CacheStartMode.java | 29 +
.../configvariations/ConfigFactory.java | 39 +
.../configvariations/ConfigParameter.java | 34 +
.../configvariations/ConfigVariations.java | 346 ++
.../ConfigVariationsFactory.java | 197 +
.../ConfigVariationsTestSuiteBuilder.java | 382 ++
.../IgniteConfigVariationsTestSuite.java | 50 +
.../configvariations/Parameters.java | 377 ++
.../configvariations/VariationsIterator.java | 174 +
.../configvariations/VariationsTestsConfig.java | 161 +
.../testframework/junits/GridAbstractTest.java | 43 +-
...IgniteCacheConfigVariationsAbstractTest.java | 583 ++
.../IgniteConfigVariationsAbstractTest.java | 420 ++
.../ConfigVariationsTestSuiteBuilderTest.java | 112 +
.../testframework/test/ParametersTest.java | 87 +
.../test/VariationsIteratorTest.java | 156 +
.../ignite/testsuites/IgniteBasicTestSuite.java | 8 +
...heBasicConfigVariationsFullApiTestSuite.java | 41 +
21 files changed, 9094 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/953b575f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/affinity/GridCacheAffinityImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/affinity/GridCacheAffinityImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/affinity/GridCacheAffinityImpl.java
index 3bc71fe..6567141 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/affinity/GridCacheAffinityImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/affinity/GridCacheAffinityImpl.java
@@ -193,7 +193,12 @@ public class GridCacheAffinityImpl<K, V> implements Affinity<K> {
AffinityTopologyVersion topVer = topologyVersion();
- int nodesCnt = cctx.discovery().cacheAffinityNodes(cctx.name(), topVer).size();
+ int nodesCnt;
+
+ if (!cctx.isLocal())
+ nodesCnt = cctx.discovery().cacheAffinityNodes(cctx.name(), topVer).size();
+ else
+ nodesCnt = 1;
// Must return empty map if no alive nodes present or keys is empty.
Map<ClusterNode, Collection<K>> res = new HashMap<>(nodesCnt, 1.0f);
http://git-wip-us.apache.org/repos/asf/ignite/blob/953b575f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
index 222a96b..401afbf 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
@@ -65,7 +65,6 @@ import org.apache.ignite.events.Event;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.IgnitionEx;
-import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager;
import org.apache.ignite.internal.processors.resource.GridSpringResourceContext;
import org.apache.ignite.internal.util.lang.GridAbsPredicate;
@@ -231,8 +230,10 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
Ignite ignite = grid(entry.getKey());
for (CacheConfiguration cfg : entry.getValue())
- ignite.createCache(cfg);
+ ignite.getOrCreateCache(cfg);
}
+
+ awaitPartitionMapExchange();
}
else {
int cnt = gridCount();
@@ -5565,12 +5566,13 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
*
*/
private static class CheckCacheSizeTask extends TestIgniteIdxRunnable {
+ /** */
private final Map<String, Integer> map;
/**
* @param map Map.
*/
- public CheckCacheSizeTask(Map<String, Integer> map) {
+ CheckCacheSizeTask(Map<String, Integer> map) {
this.map = map;
}
@@ -5581,7 +5583,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
int size = 0;
for (String key : map.keySet())
- if (ctx.affinity().localNode(key, new AffinityTopologyVersion(ctx.discovery().topologyVersion())))
+ if (ctx.affinity().localNode(key, ctx.discovery().topologyVersionEx()))
size++;
assertEquals("Incorrect key size on cache #" + idx, size, ignite.cache(ctx.name()).localSize(ALL));
[04/20] ignite git commit: JavaDoc typo
Posted by nt...@apache.org.
JavaDoc typo
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e970d56e
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e970d56e
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e970d56e
Branch: refs/heads/ignite-1186
Commit: e970d56ed84aa2060d6a7689f2b68c852040fb67
Parents: 78728db
Author: Valentin Kulichenko <va...@gmail.com>
Authored: Fri Feb 26 20:26:23 2016 -0800
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Fri Feb 26 20:26:23 2016 -0800
----------------------------------------------------------------------
.../java/org/apache/ignite/resources/JobContextResource.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/e970d56e/modules/core/src/main/java/org/apache/ignite/resources/JobContextResource.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/resources/JobContextResource.java b/modules/core/src/main/java/org/apache/ignite/resources/JobContextResource.java
index 9e1a5e7..06e63a2 100644
--- a/modules/core/src/main/java/org/apache/ignite/resources/JobContextResource.java
+++ b/modules/core/src/main/java/org/apache/ignite/resources/JobContextResource.java
@@ -47,7 +47,7 @@ import java.lang.annotation.Target;
* ...
* private ComputeJobContext jobCtx;
* ...
- * @IgniteJobContextResource
+ * @JobContextResource
* public void setJobContext(ComputeJobContext jobCtx) {
* this.jobCtx = jobCtx;
* }
@@ -60,4 +60,4 @@ import java.lang.annotation.Target;
@Target({ElementType.METHOD, ElementType.FIELD})
public @interface JobContextResource {
// No-op.
-}
\ No newline at end of file
+}
[08/20] ignite git commit: ignite-2720 Need call
'initializeLocalAddresses' before starting client message worker.
Posted by nt...@apache.org.
ignite-2720 Need call 'initializeLocalAddresses' before starting client message worker.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/49dcd6b9
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/49dcd6b9
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/49dcd6b9
Branch: refs/heads/ignite-1186
Commit: 49dcd6b96fef901cdd8b20da1e9136688e59a7f4
Parents: c3f5168
Author: sboikov <sb...@gridgain.com>
Authored: Fri Feb 26 16:49:37 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon Feb 29 09:40:08 2016 +0300
----------------------------------------------------------------------
.../java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java | 6 +++---
.../java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java | 2 +-
.../tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java | 1 +
3 files changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/49dcd6b9/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
index 9b2bf46..65b94ca 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
@@ -242,12 +242,12 @@ class ClientImpl extends TcpDiscoveryImpl {
sockReader = new SocketReader();
sockReader.start();
- msgWorker = new MessageWorker();
- msgWorker.start();
-
if (spi.ipFinder.isShared())
registerLocalNodeAddress();
+ msgWorker = new MessageWorker();
+ msgWorker.start();
+
try {
joinLatch.await();
http://git-wip-us.apache.org/repos/asf/ignite/blob/49dcd6b9/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index 3ce983e..d6db66f 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -313,7 +313,7 @@ class ServerImpl extends TcpDiscoveryImpl {
else {
if (F.isEmpty(spi.ipFinder.getRegisteredAddresses()))
throw new IgniteSpiException("Non-shared IP finder must have IP addresses specified in " +
- "GridTcpDiscoveryIpFinder.getRegisteredAddresses() configuration property " +
+ "TcpDiscoveryIpFinder.getRegisteredAddresses() configuration property " +
"(specify list of IP addresses in configuration).");
ipFinderHasLocAddr = spi.ipFinderHasLocalAddress();
http://git-wip-us.apache.org/repos/asf/ignite/blob/49dcd6b9/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
index 75b5f91..d5b3dae 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
@@ -136,6 +136,7 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
/** */
private boolean mcastErr;
+ /** */
@GridToStringExclude
private Set<InetSocketAddress> locNodeAddrs;
[06/20] ignite git commit: IGNITE-2455 - Test for custom schema name
Posted by nt...@apache.org.
IGNITE-2455 - Test for custom schema name
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/436c17eb
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/436c17eb
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/436c17eb
Branch: refs/heads/ignite-1186
Commit: 436c17eb740ede2e6a86bdc8c0cda0cadb6975e7
Parents: affe6e7
Author: Valentin Kulichenko <va...@gmail.com>
Authored: Sun Feb 28 12:21:57 2016 -0800
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Sun Feb 28 12:21:57 2016 -0800
----------------------------------------------------------------------
.../cache/CacheQueryNewClientSelfTest.java | 28 ++++++++++++++++++++
1 file changed, 28 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/436c17eb/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheQueryNewClientSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheQueryNewClientSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheQueryNewClientSelfTest.java
index 020dddd..6e7a038 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheQueryNewClientSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheQueryNewClientSelfTest.java
@@ -77,4 +77,32 @@ public class CacheQueryNewClientSelfTest extends GridCommonAbstractTest {
assertEquals(100, res.size());
}
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testQueryFromNewClientCustomSchemaName() throws Exception {
+ Ignite server = startGrid("server");
+
+ IgniteCache<Integer, Integer> cache1 = server.createCache(new CacheConfiguration<Integer, Integer>().
+ setName("cache1").setSqlSchema("cache1_sql").setIndexedTypes(Integer.class, Integer.class));
+ IgniteCache<Integer, Integer> cache2 = server.createCache(new CacheConfiguration<Integer, Integer>().
+ setName("cache2").setSqlSchema("cache2_sql").setIndexedTypes(Integer.class, Integer.class));
+
+ for (int i = 0; i < 10; i++) {
+ cache1.put(i, i);
+ cache2.put(i, i);
+ }
+
+ Ignition.setClientMode(true);
+
+ Ignite client = startGrid("client");
+
+ IgniteCache<Integer, Integer> cache = client.cache("cache1");
+
+ List<List<?>> res = cache.query(new SqlFieldsQuery(
+ "select i1._val, i2._val from Integer i1 cross join cache2_sql.Integer i2")).getAll();
+
+ assertEquals(100, res.size());
+ }
}