You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2016/05/18 10:58:31 UTC
[25/38] ignite git commit: IGNITE-2864 Need update local store from
primary and backups
http://git-wip-us.apache.org/repos/asf/ignite/blob/9f2bafbc/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractLocalStoreSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractLocalStoreSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractLocalStoreSelfTest.java
index 3e12ebf..7426f48 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractLocalStoreSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractLocalStoreSelfTest.java
@@ -22,6 +22,8 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
+import java.util.Random;
+import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
@@ -32,6 +34,7 @@ import javax.cache.integration.CacheLoaderException;
import javax.cache.integration.CacheWriterException;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.Ignition;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheMemoryMode;
@@ -46,6 +49,7 @@ import org.apache.ignite.events.Event;
import org.apache.ignite.events.EventType;
import org.apache.ignite.internal.processors.cache.store.CacheLocalStore;
import org.apache.ignite.internal.util.lang.GridAbsPredicate;
+import org.apache.ignite.internal.util.typedef.G;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiInClosure;
import org.apache.ignite.lang.IgniteBiTuple;
@@ -55,8 +59,11 @@ 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.jetbrains.annotations.Nullable;
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_LOCAL_STORE_KEEPS_PRIMARY_ONLY;
+import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.PRIMARY;
import static org.apache.ignite.cache.CacheMemoryMode.OFFHEAP_TIERED;
import static org.apache.ignite.cache.CacheMode.REPLICATED;
import static org.apache.ignite.cache.CacheRebalanceMode.SYNC;
@@ -79,10 +86,28 @@ public abstract class GridCacheAbstractLocalStoreSelfTest extends GridCommonAbst
public static final TestLocalStore<Integer, Integer> LOCAL_STORE_3 = new TestLocalStore<>();
/** */
- public static final int KEYS = 1000;
+ public static final TestLocalStore<Integer, Integer> LOCAL_STORE_4 = new TestLocalStore<>();
/** */
- public static final String BACKUP_CACHE = "backup";
+ public static final TestLocalStore<Integer, Integer> LOCAL_STORE_5 = new TestLocalStore<>();
+
+ /** */
+ public static final TestLocalStore<Integer, Integer> LOCAL_STORE_6 = new TestLocalStore<>();
+
+ /** */
+ public static final int KEYS = 1025;
+
+ /** */
+ public static final String BACKUP_CACHE_1 = "backup_1";
+
+ /** */
+ public static final String BACKUP_CACHE_2 = "backup_2";
+
+ /** */
+ public static volatile boolean primaryWriteOrderMode = false;
+
+ /** */
+ public static volatile boolean near = false;
/**
*
@@ -99,11 +124,15 @@ public abstract class GridCacheAbstractLocalStoreSelfTest extends GridCommonAbst
cacheCfg.setAffinity(new RendezvousAffinityFunction());
- CacheConfiguration cacheBackupCfg = cache(gridName, BACKUP_CACHE, 2);
+ CacheConfiguration cacheBackup1Cfg = cache(gridName, BACKUP_CACHE_1, 1);
+
+ cacheBackup1Cfg.setAffinity(new RendezvousAffinityFunction());
- cacheBackupCfg.setAffinity(new RendezvousAffinityFunction());
+ CacheConfiguration cacheBackup2Cfg = cache(gridName, BACKUP_CACHE_2, 2);
- cfg.setCacheConfiguration(cacheCfg, cacheBackupCfg);
+ cacheBackup2Cfg.setAffinity(new RendezvousAffinityFunction());
+
+ cfg.setCacheConfiguration(cacheCfg, cacheBackup1Cfg, cacheBackup2Cfg);
TcpDiscoverySpi spi = new TcpDiscoverySpi();
@@ -123,6 +152,9 @@ public abstract class GridCacheAbstractLocalStoreSelfTest extends GridCommonAbst
LOCAL_STORE_1.clear();
LOCAL_STORE_2.clear();
LOCAL_STORE_3.clear();
+ LOCAL_STORE_4.clear();
+ LOCAL_STORE_5.clear();
+ LOCAL_STORE_6.clear();
}
/**
@@ -140,14 +172,24 @@ public abstract class GridCacheAbstractLocalStoreSelfTest extends GridCommonAbst
cacheCfg.setAtomicityMode(getAtomicMode());
cacheCfg.setNearConfiguration(nearConfiguration());
cacheCfg.setWriteSynchronizationMode(FULL_SYNC);
+
+ if (primaryWriteOrderMode)
+ cacheCfg.setAtomicWriteOrderMode(PRIMARY);
+
cacheCfg.setRebalanceMode(SYNC);
if (gridName.endsWith("1"))
cacheCfg.setCacheStoreFactory(singletonFactory(LOCAL_STORE_1));
else if (gridName.endsWith("2"))
cacheCfg.setCacheStoreFactory(singletonFactory(LOCAL_STORE_2));
- else
+ else if (gridName.endsWith("3"))
cacheCfg.setCacheStoreFactory(singletonFactory(LOCAL_STORE_3));
+ else if (gridName.endsWith("4"))
+ cacheCfg.setCacheStoreFactory(singletonFactory(LOCAL_STORE_4));
+ else if (gridName.endsWith("5"))
+ cacheCfg.setCacheStoreFactory(singletonFactory(LOCAL_STORE_5));
+ else
+ cacheCfg.setCacheStoreFactory(singletonFactory(LOCAL_STORE_6));
cacheCfg.setWriteThrough(true);
cacheCfg.setReadThrough(true);
@@ -164,7 +206,9 @@ public abstract class GridCacheAbstractLocalStoreSelfTest extends GridCommonAbst
/**
* @return Distribution mode.
*/
- protected abstract NearCacheConfiguration nearConfiguration();
+ protected NearCacheConfiguration nearConfiguration() {
+ return near ? new NearCacheConfiguration() : null;
+ }
/**
* @return Cache atomicity mode.
@@ -228,7 +272,7 @@ public abstract class GridCacheAbstractLocalStoreSelfTest extends GridCommonAbst
for (int i = 0; i < KEYS; i++)
cache.put(i, i);
- checkLocalStore(ignite1, LOCAL_STORE_1);
+ checkLocalStore(ignite1, LOCAL_STORE_1, null);
final AtomicInteger evtCnt = new AtomicInteger(0);
@@ -259,8 +303,322 @@ public abstract class GridCacheAbstractLocalStoreSelfTest extends GridCommonAbst
assertEquals(Ignition.allGrids().size(), 2);
- checkLocalStore(ignite1, LOCAL_STORE_1);
- checkLocalStore(ignite2, LOCAL_STORE_2);
+ checkLocalStore(ignite1, LOCAL_STORE_1, null);
+ checkLocalStore(ignite2, LOCAL_STORE_2, null);
+ }
+
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testBackupRestorePrimary() throws Exception {
+ try {
+ primaryWriteOrderMode = true;
+
+ testBackupRestore();
+ }
+ finally {
+ primaryWriteOrderMode = false;
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testBackupRestore() throws Exception {
+ Ignite ignite1 = startGrid(1);
+ Ignite ignite2 = startGrid(2);
+
+ String name = BACKUP_CACHE_2;
+
+ int key1 = -1;
+ int key2 = -1;
+
+ for (int i = 0; i < KEYS; i++) {
+ if (ignite1.affinity(name).isPrimary(ignite1.cluster().localNode(), i)) {
+ key1 = i;
+
+ break;
+ }
+ }
+
+ for (int i = 0; i < KEYS; i++) {
+ if (!ignite1.affinity(name).isPrimary(ignite1.cluster().localNode(), i)) {
+ key2 = i;
+
+ break;
+ }
+ }
+
+ assertTrue(key1 >= 0);
+ assertTrue(key2 >= 0);
+ assertNotSame(key1, key2);
+
+ assertEquals(0, ignite1.cache(name).size());
+
+ assertEquals(0, LOCAL_STORE_1.map.size());
+ assertEquals(0, LOCAL_STORE_2.map.size());
+
+ try (Transaction tx = ignite1.transactions().txStart()) {
+ ignite1.cache(name).put(key1, key1);
+ ignite1.cache(name).put(key2, key2);
+
+ Map<Integer, Integer> m = new HashMap<>();
+
+ for (int i = KEYS; i < KEYS + 100; i++)
+ m.put(i, i);
+
+ ignite1.cache(name).putAll(m);
+
+ tx.commit();
+ }
+
+ assertEquals(102, LOCAL_STORE_1.map.size());
+ assertEquals(102, LOCAL_STORE_2.map.size());
+
+ stopGrid(1);
+
+ assertEquals(1, G.allGrids().size());
+
+ assertEquals(key1, ignite2.cache(name).get(key1));
+ assertEquals(key2, ignite2.cache(name).get(key2));
+
+ for (int i = KEYS; i < KEYS + 100; i++)
+ assertEquals(i, ignite2.cache(name).get(i));
+
+ assertEquals(102, ignite2.cache(name).size());
+
+ assertEquals(102, LOCAL_STORE_1.map.size());
+ assertEquals(102, LOCAL_STORE_2.map.size());
+
+ stopGrid(2);
+
+ assertEquals(0, G.allGrids().size());
+
+ assertEquals(102, LOCAL_STORE_1.map.size());
+ assertEquals(102, LOCAL_STORE_2.map.size());
+
+ // Node restart. One node should have everything at local store.
+ ignite2 = startGrid(2);
+
+ assertEquals(1, G.allGrids().size());
+
+ assertEquals(key1, ignite2.cache(name).get(key1));
+ assertEquals(key2, ignite2.cache(name).get(key2));
+
+ for (int i = KEYS; i < KEYS + 100; i++)
+ assertEquals(i, ignite2.cache(name).get(i));
+
+ assertEquals(102, ignite2.cache(name).size());
+
+ assertEquals(102, LOCAL_STORE_1.map.size());
+ assertEquals(102, LOCAL_STORE_2.map.size());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testLocalStoreCorrespondsAffinityWithBackups() throws Exception {
+ testLocalStoreCorrespondsAffinity(BACKUP_CACHE_2);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testLocalStoreCorrespondsAffinityWithBackup() throws Exception {
+ testLocalStoreCorrespondsAffinity(BACKUP_CACHE_1);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testLocalStoreCorrespondsAffinityNoBackups() throws Exception {
+ testLocalStoreCorrespondsAffinity(null);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ private void testLocalStoreCorrespondsAffinity(String name) throws Exception {
+ near = true;
+
+ try {
+
+ for (int i = 1; i <= 6; i++)
+ startGrid(i);
+
+ assertTrue(((IgniteCacheProxy)grid(1).cache(name)).context().isNear() ||
+ getCacheMode() == REPLICATED);
+
+ awaitPartitionMapExchange();
+
+ Random rn = new Random();
+
+ for (int i = 1; i <= 6; i++)
+ assertEquals(0, grid(i).cache(name).localSize(CachePeekMode.NEAR));
+
+ for (int i = 0; i < KEYS; i++) {
+ Ignite ignite = grid(rn.nextInt(6) + 1);
+
+ try (Transaction tx = ignite.transactions().txStart()) {
+ ignite.cache(name).put(i, i);
+
+ for (int j = 0; j < 5; j++)
+ ignite.cache(name).get(rn.nextInt(KEYS));
+
+ Map<Integer, Integer> m = new HashMap<>(5);
+
+ for (int j = 0; j < 5; j++) {
+ Integer key = rn.nextInt(KEYS);
+
+ m.put(key, key);
+ }
+
+ ignite.cache(name).putAll(m);
+
+ tx.commit();
+ }
+ }
+
+ for (int i = 1; i <= 6; i++) {
+ assertTrue(grid(i).cache(name).localSize(CachePeekMode.NEAR) > 0 ||
+ getCacheMode() == REPLICATED);
+ }
+
+ checkLocalStore(grid(1), LOCAL_STORE_1, name);
+ checkLocalStore(grid(2), LOCAL_STORE_2, name);
+ checkLocalStore(grid(3), LOCAL_STORE_3, name);
+ checkLocalStore(grid(4), LOCAL_STORE_4, name);
+ checkLocalStore(grid(5), LOCAL_STORE_5, name);
+ checkLocalStore(grid(6), LOCAL_STORE_6, name);
+
+ int fullStoreSize = LOCAL_STORE_1.map.size() +
+ LOCAL_STORE_2.map.size() +
+ LOCAL_STORE_3.map.size() +
+ LOCAL_STORE_4.map.size() +
+ LOCAL_STORE_5.map.size() +
+ LOCAL_STORE_6.map.size();
+
+ CacheConfiguration ccfg = grid(1).cache(name).getConfiguration(CacheConfiguration.class);
+
+ assertEquals(
+ getCacheMode() == REPLICATED ?
+ KEYS * 6 :
+ ccfg.getBackups() * KEYS + KEYS,
+ fullStoreSize);
+
+ }
+ finally {
+ near = false;
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testLocalStoreWithNearKeysPrimary() throws Exception {
+ try {
+ System.setProperty(IGNITE_LOCAL_STORE_KEEPS_PRIMARY_ONLY, "true");
+
+ testLocalStoreWithNearKeys();
+ }
+ finally {
+ System.setProperty(IGNITE_LOCAL_STORE_KEEPS_PRIMARY_ONLY, "false");
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testLocalStoreWithNearKeysPrimaryAndBackups() throws Exception {
+ testLocalStoreWithNearKeys();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testLocalStoreWithNearKeys() throws Exception {
+ if (getCacheMode() == REPLICATED)
+ return;
+
+ near = true;
+
+ try {
+ for (int i = 1; i <= 3; i++)
+ startGrid(i);
+
+ awaitPartitionMapExchange();
+
+ Ignite ignite = grid(1);
+
+ int k = 0;
+
+ for (int i = 1; i <= 3; i++) {
+ int kP = -1;
+ int kB = -1;
+ int kN = -1;
+
+ while (kP == -1 || kB == -1 || kN == -1) {
+ if (ignite.affinity(BACKUP_CACHE_1).isPrimary(grid(1).cluster().localNode(), k))
+ kP = k;
+
+ if (ignite.affinity(BACKUP_CACHE_1).isBackup(grid(1).cluster().localNode(), k) &&
+ ignite.affinity(BACKUP_CACHE_1).isPrimary(grid(2).cluster().localNode(), k))
+ kB = k;
+
+ if (!ignite.affinity(BACKUP_CACHE_1).isPrimaryOrBackup(grid(1).cluster().localNode(), k) &&
+ ignite.affinity(BACKUP_CACHE_1).isPrimary(grid(3).cluster().localNode(), k))
+ kN = k;
+
+ k++;
+ }
+
+ assertTrue(kP != kB && kB != kN && kN != kP);
+
+ Map<Integer, Integer> m = new HashMap<>(3);
+
+ m.put(kP, kP);
+ m.put(kB, kB);
+ m.put(kN, kN);
+
+ try (Transaction tx = grid(i).transactions().txStart()) {
+ grid(i).cache(BACKUP_CACHE_1).putAll(m);
+
+ tx.commit();
+ }
+
+ boolean locStoreBackups = !IgniteSystemProperties.getBoolean(IGNITE_LOCAL_STORE_KEEPS_PRIMARY_ONLY);
+
+ checkLocalStore(grid(1), LOCAL_STORE_1, BACKUP_CACHE_1, m.keySet(), locStoreBackups);
+ checkLocalStore(grid(2), LOCAL_STORE_2, BACKUP_CACHE_1, m.keySet(), locStoreBackups);
+ checkLocalStore(grid(3), LOCAL_STORE_3, BACKUP_CACHE_1, m.keySet(), locStoreBackups);
+ }
+
+ grid(1).cache(BACKUP_CACHE_1).removeAll();
+
+ Random rn = new Random();
+
+ for (int i = 1; i <= 3; i++) {
+ try (Transaction tx = grid(i).transactions().txStart()) {
+ Map<Integer, Integer> m = new HashMap<>(3);
+
+ for (int j = 0; j < 50; j++) {
+ m.put(rn.nextInt(1000), 1000);
+ }
+
+ grid(i).cache(BACKUP_CACHE_1).withSkipStore().putAll(m);
+
+ tx.commit();
+ }
+
+ assertTrue(LOCAL_STORE_1.map.isEmpty());
+ assertTrue(LOCAL_STORE_2.map.isEmpty());
+ assertTrue(LOCAL_STORE_3.map.isEmpty());
+ }
+ }
+ finally {
+ near = false;
+ }
}
/**
@@ -269,38 +627,63 @@ public abstract class GridCacheAbstractLocalStoreSelfTest extends GridCommonAbst
public void testBackupNode() throws Exception {
Ignite ignite1 = startGrid(1);
- IgniteCache<Object, Object> cache = ignite1.cache(BACKUP_CACHE);
+ IgniteCache<Object, Object> cache = ignite1.cache(BACKUP_CACHE_2);
for (int i = 0; i < KEYS; i++)
cache.put(i, i);
- for (int i = 0; i < KEYS; i++)
+ for (int i = 0; i < KEYS; i++) {
assertEquals(LOCAL_STORE_1.load(i).get1().intValue(), i);
+ assertNull(LOCAL_STORE_2.load(i));
+ assertNull(LOCAL_STORE_3.load(i));
+ }
- // Start 2'nd node.
- Ignite ignite2 = startGrid(2);
+ startGrid(2);
assertEquals(2, Ignition.allGrids().size());
- checkLocalStoreForBackup(ignite2, LOCAL_STORE_2);
+ for (int i = 0; i < KEYS; i++) {
+ assertEquals(LOCAL_STORE_1.load(i).get1().intValue(), i);
+ assertEquals(LOCAL_STORE_2.load(i).get1().intValue(), i);
+ assertNull(LOCAL_STORE_3.load(i));
+ }
- // Start 3'nd node.
- Ignite ignite3 = startGrid(3);
+ startGrid(3);
assertEquals(Ignition.allGrids().size(), 3);
for (int i = 0; i < KEYS; i++)
cache.put(i, i * 3);
- checkLocalStoreForBackup(ignite2, LOCAL_STORE_2);
- checkLocalStoreForBackup(ignite3, LOCAL_STORE_3);
+ for (int i = 0; i < KEYS; i++) {
+ assertEquals(LOCAL_STORE_1.load(i).get1().intValue(), i * 3);
+ assertEquals(LOCAL_STORE_2.load(i).get1().intValue(), i * 3);
+ assertEquals(LOCAL_STORE_3.load(i).get1().intValue(), i * 3);
+ }
// Stop 3'nd node.
stopGrid(3, true);
+ for (int i = 0; i < KEYS; i++)
+ cache.put(i, i * 7);
+
assertEquals(Ignition.allGrids().size(), 2);
- checkLocalStoreForBackup(ignite2, LOCAL_STORE_2);
+ for (int i = 0; i < KEYS; i++) {
+ assertEquals(LOCAL_STORE_1.load(i).get1().intValue(), i * 7);
+ assertEquals(LOCAL_STORE_2.load(i).get1().intValue(), i * 7);
+ assertEquals(LOCAL_STORE_3.load(i).get1().intValue(), i * 3);
+ }
+
+ startGrid(3);
+
+ assertEquals(Ignition.allGrids().size(), 3);
+
+ for (int i = 0; i < KEYS; i++) {
+ assertEquals(LOCAL_STORE_1.load(i).get1().intValue(), i * 7);
+ assertEquals(LOCAL_STORE_2.load(i).get1().intValue(), i * 7);
+ assertEquals(LOCAL_STORE_3.load(i).get1().intValue(), i * 7);
+ }
}
/**
@@ -315,7 +698,7 @@ public abstract class GridCacheAbstractLocalStoreSelfTest extends GridCommonAbst
for (int i = 0; i < KEYS; i++)
cache.put(i, i);
- checkLocalStore(ignite1, LOCAL_STORE_1);
+ checkLocalStore(ignite1, LOCAL_STORE_1, null);
// Push entry to swap.
for (int i = 0; i < KEYS; i++)
@@ -353,37 +736,60 @@ public abstract class GridCacheAbstractLocalStoreSelfTest extends GridCommonAbst
assertEquals(Ignition.allGrids().size(), 2);
- checkLocalStore(ignite1, LOCAL_STORE_1);
- checkLocalStore(ignite2, LOCAL_STORE_2);
+ checkLocalStore(ignite1, LOCAL_STORE_1, null);
+ checkLocalStore(ignite2, LOCAL_STORE_2, null);
}
/**
* Checks that local stores contains only primary entry.
- *
- * @param ignite Ignite.
+ * @param ignite Ignite.
* @param store Store.
+ * @param name Cache name.
*/
- private void checkLocalStore(Ignite ignite, CacheStore<Integer, IgniteBiTuple<Integer, ?>> store) {
+ private void checkLocalStore(Ignite ignite, CacheStore<Integer, IgniteBiTuple<Integer, ?>> store, String name) {
for (int i = 0; i < KEYS; i++) {
- if (ignite.affinity(null).isPrimary(ignite.cluster().localNode(), i))
+ if (ignite.affinity(name).isPrimaryOrBackup(ignite.cluster().localNode(), i))
assertEquals(store.load(i).get1().intValue(), i);
- else if (!ignite.affinity(null).isPrimaryOrBackup(ignite.cluster().localNode(), i))
+ else
assertNull(store.load(i));
}
}
/**
- * Checks that local stores contains only primary entry.
+ * Checks that local stores contains primary and backup entries.
+ * @param ignite Ignite.
+ * @param store Store.
+ * @param name Cache name.
+ * @param keys keys.
+ */
+ private void checkLocalStore(Ignite ignite, CacheStore<Integer, IgniteBiTuple<Integer, ?>> store, String name,
+ Set<Integer> keys) {
+ checkLocalStore(ignite, store, name, keys, true);
+ }
+
+ /**
+ * Checks that local stores contains primary and backup or only primary entries.
*
* @param ignite Ignite.
* @param store Store.
+ * @param name Cache name.
+ * @param keys keys.
*/
- private void checkLocalStoreForBackup(Ignite ignite, CacheStore<Integer, IgniteBiTuple<Integer, ?>> store) {
- for (int i = 0; i < KEYS; i++) {
- if (ignite.affinity(BACKUP_CACHE).isBackup(ignite.cluster().localNode(), i))
- assertEquals(store.load(i).get1().intValue(), i);
- else if (!ignite.affinity(BACKUP_CACHE).isPrimaryOrBackup(ignite.cluster().localNode(), i))
- assertNull(store.load(i).get1());
+ private void checkLocalStore(Ignite ignite, CacheStore<Integer, IgniteBiTuple<Integer, ?>> store, String name,
+ Set<Integer> keys, boolean withBackups) {
+ for (int key : keys) {
+ if (withBackups) {
+ if (ignite.affinity(name).isPrimaryOrBackup(ignite.cluster().localNode(), key))
+ assertEquals(store.load(key).get1().intValue(), key);
+ else
+ assertNull(store.load(key));
+ }
+ else {
+ if (ignite.affinity(name).isPrimary(ignite.cluster().localNode(), key))
+ assertEquals(store.load(key).get1().intValue(), key);
+ else
+ assertNull(store.load(key));
+ }
}
}
@@ -393,7 +799,7 @@ public abstract class GridCacheAbstractLocalStoreSelfTest extends GridCommonAbst
@CacheLocalStore
public static class TestLocalStore<K, V> implements CacheStore<K, IgniteBiTuple<V, ?>> {
/** */
- private Map<K, IgniteBiTuple<V, ?>> map = new ConcurrentHashMap<>();
+ private final Map<K, IgniteBiTuple<V, ?>> map = new ConcurrentHashMap<>();
/** {@inheritDoc} */
@Override public void loadCache(IgniteBiInClosure<K, IgniteBiTuple<V, ?>> clo, @Nullable Object... args)
http://git-wip-us.apache.org/repos/asf/ignite/blob/9f2bafbc/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePartitionedLocalStoreSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePartitionedLocalStoreSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePartitionedLocalStoreSelfTest.java
index 854626e..d3431f7 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePartitionedLocalStoreSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePartitionedLocalStoreSelfTest.java
@@ -19,7 +19,6 @@ package org.apache.ignite.internal.processors.cache;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.configuration.NearCacheConfiguration;
import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
@@ -29,11 +28,6 @@ import static org.apache.ignite.cache.CacheMode.PARTITIONED;
*/
public class GridCachePartitionedLocalStoreSelfTest extends GridCacheAbstractLocalStoreSelfTest {
/** {@inheritDoc} */
- @Override protected NearCacheConfiguration nearConfiguration() {
- return null;
- }
-
- /** {@inheritDoc} */
@Override protected CacheAtomicityMode getAtomicMode() {
return ATOMIC;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9f2bafbc/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePartitionedOffHeapLocalStoreSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePartitionedOffHeapLocalStoreSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePartitionedOffHeapLocalStoreSelfTest.java
index 433ca67..8f29158 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePartitionedOffHeapLocalStoreSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePartitionedOffHeapLocalStoreSelfTest.java
@@ -19,7 +19,6 @@ package org.apache.ignite.internal.processors.cache;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.configuration.NearCacheConfiguration;
import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
@@ -29,11 +28,6 @@ import static org.apache.ignite.cache.CacheMode.PARTITIONED;
*/
public class GridCachePartitionedOffHeapLocalStoreSelfTest extends GridCacheAbstractLocalStoreSelfTest {
/** {@inheritDoc} */
- @Override protected NearCacheConfiguration nearConfiguration() {
- return null;
- }
-
- /** {@inheritDoc} */
@Override protected CacheAtomicityMode getAtomicMode() {
return ATOMIC;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9f2bafbc/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReplicatedLocalStoreSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReplicatedLocalStoreSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReplicatedLocalStoreSelfTest.java
index 6465f89..2658e44 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReplicatedLocalStoreSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReplicatedLocalStoreSelfTest.java
@@ -19,7 +19,6 @@ package org.apache.ignite.internal.processors.cache;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.configuration.NearCacheConfiguration;
import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
import static org.apache.ignite.cache.CacheMode.REPLICATED;
@@ -29,11 +28,6 @@ import static org.apache.ignite.cache.CacheMode.REPLICATED;
*/
public class GridCacheReplicatedLocalStoreSelfTest extends GridCacheAbstractLocalStoreSelfTest {
/** {@inheritDoc} */
- @Override protected NearCacheConfiguration nearConfiguration() {
- return null;
- }
-
- /** {@inheritDoc} */
@Override protected CacheAtomicityMode getAtomicMode() {
return ATOMIC;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9f2bafbc/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTxPartitionedLocalStoreSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTxPartitionedLocalStoreSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTxPartitionedLocalStoreSelfTest.java
index 4810715..272665b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTxPartitionedLocalStoreSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTxPartitionedLocalStoreSelfTest.java
@@ -19,7 +19,6 @@ package org.apache.ignite.internal.processors.cache;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.configuration.NearCacheConfiguration;
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
@@ -29,11 +28,6 @@ import static org.apache.ignite.cache.CacheMode.PARTITIONED;
*/
public class GridCacheTxPartitionedLocalStoreSelfTest extends GridCacheAbstractLocalStoreSelfTest {
/** {@inheritDoc} */
- @Override protected NearCacheConfiguration nearConfiguration() {
- return null;
- }
-
- /** {@inheritDoc} */
@Override protected CacheAtomicityMode getAtomicMode() {
return TRANSACTIONAL;
}