ignite-1088 Implemented store for multi jvm tests
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f91b6996 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f91b6996 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f91b6996 Branch: refs/heads/master Commit: f91b6996774aa6b3b7cefe5b41e2acbe6e81b6f1 Parents: 27b032e Author: sboikov <[email protected]> Authored: Fri Jul 1 12:16:56 2016 +0300 Committer: sboikov <[email protected]> Committed: Fri Jul 1 12:16:56 2016 +0300 ---------------------------------------------------------------------- .../cache/GridCacheAbstractFullApiSelfTest.java | 162 +++---- .../cache/GridCacheAbstractMetricsSelfTest.java | 2 +- .../cache/GridCacheAbstractSelfTest.java | 103 +--- .../GridCacheInterceptorAbstractSelfTest.java | 2 +- .../processors/cache/H2CacheStoreStrategy.java | 468 +++++++++++++++++++ .../IgniteCacheConfigVariationsFullApiTest.java | 122 +++-- .../IgniteCacheReadThroughEvictionSelfTest.java | 2 +- .../processors/cache/MapCacheStoreStrategy.java | 145 ++++++ .../cache/TestCacheStoreStrategy.java | 96 ++++ ...idCacheNearOnlyMultiNodeFullApiSelfTest.java | 2 +- ...edOffHeapTieredMultiNodeFullApiSelfTest.java | 2 +- .../configvariations/ConfigVariations.java | 6 +- ...IgniteCacheConfigVariationsAbstractTest.java | 67 +-- .../cache/IgniteCacheQueryIndexSelfTest.java | 2 +- 14 files changed, 882 insertions(+), 299 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/f91b6996/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 59d3170..dff4d43 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 @@ -222,6 +222,8 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { + initStoreStrategy(); + if (cacheStartType() == CacheStartMode.STATIC) super.beforeTestsStarted(); else { @@ -267,17 +269,12 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract } /** - * Checks that skipStore flag gets overriden inside a transaction. - * - * @throws Exception if failed. + * Checks that skipStore flag gets overridden inside a transaction. */ public void testWriteThroughTx() { - if(isMultiJvm()) - fail("https://issues.apache.org/jira/browse/IGNITE-1088"); - String key = "writeThroughKey"; - map.remove(key); + storeStgy.removeFromStore(key); try (final Transaction transaction = grid(0).transactions().txStart()) { IgniteCache<String, Integer> cache = jcache(0); @@ -294,27 +291,22 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract transaction.commit(); } - assertEquals(2, map.get(key)); + assertEquals(2, storeStgy.getFromStore(key)); } /** - * Checks that skipStore flag gets overriden inside a transaction. - * - * @throws Exception if failed. + * Checks that skipStore flag gets overridden inside a transaction. */ public void testNoReadThroughTx() { - if(isMultiJvm()) - fail("https://issues.apache.org/jira/browse/IGNITE-1088"); - String key = "writeThroughKey"; IgniteCache<String, Integer> cache = jcache(0); - resetStore(); + storeStgy.resetStore(); cache.put(key, 1); - putToStore(key, 2); + storeStgy.putToStore(key, 2); try (final Transaction transaction = grid(0).transactions().txStart()) { Integer old = cache.get(key); @@ -328,7 +320,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract transaction.commit(); } - assertEquals(0, reads.get()); + assertEquals(0, storeStgy.getReads()); } /** {@inheritDoc} */ @@ -564,9 +556,6 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract * @throws Exception If failed. */ public void testRemoveAllSkipStore() throws Exception { - if (isMultiJvm()) - fail("https://issues.apache.org/jira/browse/IGNITE-1088"); - IgniteCache<String, Integer> jcache = jcache(); jcache.putAll(F.asMap("1", 1, "2", 2, "3", 3)); @@ -2068,7 +2057,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract // Check db. if (!isMultiJvm()) { - putToStore("key3", 3); + storeStgy.putToStore("key3", 3); assertEquals((Integer)3, cache.getAndPutIfAbsent("key3", 4)); @@ -2140,7 +2129,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract // Check db. if (!isMultiJvm()) { - putToStore("key3", 3); + storeStgy.putToStore("key3", 3); cacheAsync.getAndPutIfAbsent("key3", 4); @@ -2189,7 +2178,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract // Check db. if (!isMultiJvm()) { - putToStore("key3", 3); + storeStgy.putToStore("key3", 3); assertFalse(cache.putIfAbsent("key3", 4)); } @@ -2262,7 +2251,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract // Check db. if (!isMultiJvm()) { - putToStore("key3", 3); + storeStgy.putToStore("key3", 3); cacheAsync.putIfAbsent("key3", 4); @@ -2366,7 +2355,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract assert cache.get("key") == 4; if (!isMultiJvm()) { - putToStore("key2", 5); + storeStgy.putToStore("key2", 5); info("key2 5 -> 6"); @@ -2425,7 +2414,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract assert cache.get("key") == 4; if (!isMultiJvm()) { - putToStore("key2", 5); + storeStgy.putToStore("key2", 5); assert cache.replace("key2", 6); @@ -2501,7 +2490,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract assert cache.get("key") == 4; if (!isMultiJvm()) { - putToStore("key2", 5); + storeStgy.putToStore("key2", 5); cacheAsync.replace("key2", 5, 6); @@ -2563,7 +2552,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract assert cache.get("key") == 4; if (!isMultiJvm()) { - putToStore("key2", 5); + storeStgy.putToStore("key2", 5); cacheAsync.replace("key2", 6); @@ -2688,9 +2677,6 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract * @throws Exception If failed. */ public void testRemoveLoad() throws Exception { - if (isMultiJvm()) - fail("https://issues.apache.org/jira/browse/IGNITE-1088"); - int cnt = 10; Set<String> keys = new HashSet<>(); @@ -2701,7 +2687,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract jcache().removeAll(keys); for (String key : keys) - putToStore(key, Integer.parseInt(key)); + storeStgy.putToStore(key, Integer.parseInt(key)); for (int g = 0; g < gridCount(); g++) grid(g).cache(null).localLoadCache(null); @@ -3764,7 +3750,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract } // Avoid reloading from store. - map.remove(key); + storeStgy.removeFromStore(key); assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicateX() { @SuppressWarnings("unchecked") @@ -4803,9 +4789,6 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract * @throws Exception If failed. */ public void testWithSkipStore() throws Exception { - if(isMultiJvm()) - fail("https://issues.apache.org/jira/browse/IGNITE-1088"); - IgniteCache<String, Integer> cache = grid(0).cache(null); IgniteCache<String, Integer> cacheSkipStore = cache.withSkipStore(); @@ -4813,7 +4796,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract List<String> keys = primaryKeysForCache(cache, 10); for (int i = 0; i < keys.size(); ++i) - putToStore(keys.get(i), i); + storeStgy.putToStore(keys.get(i), i); assertFalse(cacheSkipStore.iterator().hasNext()); @@ -4851,7 +4834,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract assertNotNull(cacheSkipStore.get(key)); assertNotNull(cache.get(key)); - assertEquals(i, map.get(key)); + assertEquals(i, storeStgy.getFromStore(key)); } for (int i = 0; i < keys.size(); ++i) { @@ -4860,13 +4843,13 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract Integer val1 = -1; cacheSkipStore.put(key, val1); - assertEquals(i, map.get(key)); + assertEquals(i, storeStgy.getFromStore(key)); assertEquals(val1, cacheSkipStore.get(key)); Integer val2 = -2; assertEquals(val1, cacheSkipStore.invoke(key, new SetValueProcessor(val2))); - assertEquals(i, map.get(key)); + assertEquals(i, storeStgy.getFromStore(key)); assertEquals(val2, cacheSkipStore.get(key)); } @@ -4875,7 +4858,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract assertNull(cacheSkipStore.get(key)); assertNotNull(cache.get(key)); - assertTrue(map.containsKey(key)); + assertTrue(storeStgy.isInStore(key)); } for (String key : keys) { @@ -4883,37 +4866,37 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract assertNull(cacheSkipStore.get(key)); assertNull(cache.get(key)); - assertFalse(map.containsKey(key)); + assertFalse(storeStgy.isInStore(key)); - map.put(key, 0); + storeStgy.putToStore(key, 0); Integer val = -1; assertNull(cacheSkipStore.invoke(key, new SetValueProcessor(val))); - assertEquals(0, map.get(key)); + assertEquals(0, storeStgy.getFromStore(key)); assertEquals(val, cacheSkipStore.get(key)); cache.remove(key); - map.put(key, 0); + storeStgy.putToStore(key, 0); assertTrue(cacheSkipStore.putIfAbsent(key, val)); assertEquals(val, cacheSkipStore.get(key)); - assertEquals(0, map.get(key)); + assertEquals(0, storeStgy.getFromStore(key)); cache.remove(key); - map.put(key, 0); + storeStgy.putToStore(key, 0); assertNull(cacheSkipStore.getAndPut(key, val)); assertEquals(val, cacheSkipStore.get(key)); - assertEquals(0, map.get(key)); + assertEquals(0, storeStgy.getFromStore(key)); cache.remove(key); } assertFalse(cacheSkipStore.iterator().hasNext()); - assertTrue(map.size() == 0); + assertTrue(storeStgy.getStoreSize() == 0); assertTrue(cache.size(ALL) == 0); // putAll/removeAll from multiple nodes. @@ -4928,7 +4911,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract for (String key : keys) { assertNotNull(cacheSkipStore.get(key)); assertNotNull(cache.get(key)); - assertFalse(map.containsKey(key)); + assertFalse(storeStgy.isInStore(key)); } cache.putAll(data); @@ -4936,7 +4919,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract for (String key : keys) { assertNotNull(cacheSkipStore.get(key)); assertNotNull(cache.get(key)); - assertTrue(map.containsKey(key)); + assertTrue(storeStgy.isInStore(key)); } cacheSkipStore.removeAll(data.keySet()); @@ -4944,7 +4927,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract for (String key : keys) { assertNull(cacheSkipStore.get(key)); assertNotNull(cache.get(key)); - assertTrue(map.containsKey(key)); + assertTrue(storeStgy.isInStore(key)); } cacheSkipStore.putAll(data); @@ -4952,7 +4935,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract for (String key : keys) { assertNotNull(cacheSkipStore.get(key)); assertNotNull(cache.get(key)); - assertTrue(map.containsKey(key)); + assertTrue(storeStgy.isInStore(key)); } cacheSkipStore.removeAll(data.keySet()); @@ -4960,7 +4943,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract for (String key : keys) { assertNull(cacheSkipStore.get(key)); assertNotNull(cache.get(key)); - assertTrue(map.containsKey(key)); + assertTrue(storeStgy.isInStore(key)); } cache.removeAll(data.keySet()); @@ -4968,24 +4951,24 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract for (String key : keys) { assertNull(cacheSkipStore.get(key)); assertNull(cache.get(key)); - assertFalse(map.containsKey(key)); + assertFalse(storeStgy.isInStore(key)); } - assertTrue(map.size() == 0); + assertTrue(storeStgy.getStoreSize() == 0); // Miscellaneous checks. String newKey = "New key"; - assertFalse(map.containsKey(newKey)); + assertFalse(storeStgy.isInStore(newKey)); cacheSkipStore.put(newKey, 1); - assertFalse(map.containsKey(newKey)); + assertFalse(storeStgy.isInStore(newKey)); cache.put(newKey, 1); - assertTrue(map.containsKey(newKey)); + assertTrue(storeStgy.isInStore(newKey)); Iterator<Cache.Entry<String, Integer>> it = cacheSkipStore.iterator(); @@ -4995,29 +4978,26 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract String rmvKey = entry.getKey(); - assertTrue(map.containsKey(rmvKey)); + assertTrue(storeStgy.isInStore(rmvKey)); it.remove(); assertNull(cacheSkipStore.get(rmvKey)); - assertTrue(map.containsKey(rmvKey)); + assertTrue(storeStgy.isInStore(rmvKey)); assertTrue(cache.size(ALL) == 0); assertTrue(cacheSkipStore.size(ALL) == 0); cache.remove(rmvKey); - assertTrue(map.size() == 0); + assertTrue(storeStgy.getStoreSize() == 0); } /** * @throws Exception If failed. */ public void testWithSkipStoreRemoveAll() throws Exception { - if (isMultiJvm()) - fail("https://issues.apache.org/jira/browse/IGNITE-1088"); - if (atomicityMode() == TRANSACTIONAL || (atomicityMode() == ATOMIC && nearEnabled())) // TODO IGNITE-373. return; @@ -5035,7 +5015,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract for (String key : data.keySet()) { assertNotNull(cacheSkipStore.get(key)); assertNotNull(cache.get(key)); - assertTrue(map.containsKey(key)); + assertTrue(storeStgy.isInStore(key)); } cacheSkipStore.removeAll(); @@ -5043,7 +5023,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract for (String key : data.keySet()) { assertNull(cacheSkipStore.get(key)); assertNotNull(cache.get(key)); - assertTrue(map.containsKey(key)); + assertTrue(storeStgy.isInStore(key)); } cache.removeAll(); @@ -5051,7 +5031,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract for (String key : data.keySet()) { assertNull(cacheSkipStore.get(key)); assertNull(cache.get(key)); - assertFalse(map.containsKey(key)); + assertFalse(storeStgy.isInStore(key)); } } @@ -5127,7 +5107,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract for (String key: keys) { assertEquals(val, cacheSkipStore.get(key)); assertEquals(val, cache.get(key)); - assertFalse(map.containsKey(key)); + assertFalse(storeStgy.isInStore(key)); } tx.commit(); @@ -5136,10 +5116,10 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract for (String key: keys) { assertEquals(val, cacheSkipStore.get(key)); assertEquals(val, cache.get(key)); - assertFalse(map.containsKey(key)); + assertFalse(storeStgy.isInStore(key)); } - assertEquals(0, map.size()); + assertEquals(0, storeStgy.getStoreSize()); // cacheSkipStore putAll(..)/removeAll(..) check. try (Transaction tx = txs.txStart(txConcurrency, txIsolation)) { @@ -5153,10 +5133,10 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract assertEquals(val, cacheSkipStore.get(key)); assertEquals(val, cache.get(key)); - assertFalse(map.containsKey(key)); + assertFalse(storeStgy.isInStore(key)); } - map.putAll(data); + storeStgy.putAllToStore(data); try (Transaction tx = txs.txStart(txConcurrency, txIsolation)) { cacheSkipStore.removeAll(data.keySet()); @@ -5167,12 +5147,12 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract for (String key: keys) { assertNull(cacheSkipStore.get(key)); assertNotNull(cache.get(key)); - assertTrue(map.containsKey(key)); + assertTrue(storeStgy.isInStore(key)); cache.remove(key); } - assertTrue(map.size() == 0); + assertTrue(storeStgy.getStoreSize() == 0); // cache putAll(..)/removeAll(..) check. try (Transaction tx = txs.txStart(txConcurrency, txIsolation)) { @@ -5181,7 +5161,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract for (String key: keys) { assertNotNull(cacheSkipStore.get(key)); assertNotNull(cache.get(key)); - assertFalse(map.containsKey(key)); + assertFalse(storeStgy.isInStore(key)); } cache.removeAll(data.keySet()); @@ -5189,13 +5169,13 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract for (String key: keys) { assertNull(cacheSkipStore.get(key)); assertNull(cache.get(key)); - assertFalse(map.containsKey(key)); + assertFalse(storeStgy.isInStore(key)); } tx.commit(); } - assertTrue(map.size() == 0); + assertTrue(storeStgy.getStoreSize() == 0); // putAll(..) from both cacheSkipStore and cache. try (Transaction tx = txs.txStart(txConcurrency, txIsolation)) { @@ -5216,7 +5196,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract for (String key: keys) { assertNotNull(cacheSkipStore.get(key)); assertNotNull(cache.get(key)); - assertFalse(map.containsKey(key)); + assertFalse(storeStgy.isInStore(key)); } tx.commit(); @@ -5227,7 +5207,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract assertNotNull(cacheSkipStore.get(key)); assertNotNull(cache.get(key)); - assertFalse(map.containsKey(key)); + assertFalse(storeStgy.isInStore(key)); } for (int i = keys.size() / 2; i < keys.size(); i++) { @@ -5235,7 +5215,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract assertNotNull(cacheSkipStore.get(key)); assertNotNull(cache.get(key)); - assertTrue(map.containsKey(key)); + assertTrue(storeStgy.isInStore(key)); } cache.removeAll(data.keySet()); @@ -5243,16 +5223,16 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract for (String key: keys) { assertNull(cacheSkipStore.get(key)); assertNull(cache.get(key)); - assertFalse(map.containsKey(key)); + assertFalse(storeStgy.isInStore(key)); } // Check that read-through is disabled when cacheSkipStore is used. for (int i = 0; i < keys.size(); i++) - putToStore(keys.get(i), i); + storeStgy.putToStore(keys.get(i), i); assertTrue(cacheSkipStore.size(ALL) == 0); assertTrue(cache.size(ALL) == 0); - assertTrue(map.size() != 0); + assertTrue(storeStgy.getStoreSize() != 0); try (Transaction tx = txs.txStart(txConcurrency, txIsolation)) { assertTrue(cacheSkipStore.getAll(data.keySet()).size() == 0); @@ -5275,7 +5255,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract try (Transaction tx = txs.txStart(txConcurrency, txIsolation)) { for (String key : data.keySet()) { - map.put(key, 0); + storeStgy.putToStore(key, 0); assertNull(cacheSkipStore.invoke(key, new SetValueProcessor(val))); } @@ -5284,7 +5264,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract } for (String key : data.keySet()) { - assertEquals(0, map.get(key)); + assertEquals(0, storeStgy.getFromStore(key)); assertEquals(val, cacheSkipStore.get(key)); assertEquals(val, cache.get(key)); @@ -5294,7 +5274,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract try (Transaction tx = txs.txStart(txConcurrency, txIsolation)) { for (String key : data.keySet()) { - map.put(key, 0); + storeStgy.putToStore(key, 0); assertTrue(cacheSkipStore.putIfAbsent(key, val)); } @@ -5303,7 +5283,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract } for (String key : data.keySet()) { - assertEquals(0, map.get(key)); + assertEquals(0, storeStgy.getFromStore(key)); assertEquals(val, cacheSkipStore.get(key)); assertEquals(val, cache.get(key)); @@ -5313,7 +5293,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract try (Transaction tx = txs.txStart(txConcurrency, txIsolation)) { for (String key : data.keySet()) { - map.put(key, 0); + storeStgy.putToStore(key, 0); assertNull(cacheSkipStore.getAndPut(key, val)); } @@ -5322,7 +5302,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract } for (String key : data.keySet()) { - assertEquals(0, map.get(key)); + assertEquals(0, storeStgy.getFromStore(key)); assertEquals(val, cacheSkipStore.get(key)); assertEquals(val, cache.get(key)); @@ -5342,7 +5322,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract throws Exception { assertTrue(cache.size(ALL) == 0); assertTrue(cacheSkipStore.size(ALL) == 0); - assertTrue(map.size() == 0); + assertTrue(storeStgy.getStoreSize() == 0); } /** http://git-wip-us.apache.org/repos/asf/ignite/blob/f91b6996/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractMetricsSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractMetricsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractMetricsSelfTest.java index 13bd081..5ad7e5c 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractMetricsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractMetricsSelfTest.java @@ -906,7 +906,7 @@ public abstract class GridCacheAbstractMetricsSelfTest extends GridCacheAbstract } // Avoid reloading from store. - map.remove(key); + storeStgy.removeFromStore(key); assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicateX() { @SuppressWarnings("unchecked") http://git-wip-us.apache.org/repos/asf/ignite/blob/f91b6996/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java index b918f28..dcf5d98 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java @@ -17,7 +17,6 @@ package org.apache.ignite.internal.processors.cache; -import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; import javax.cache.Cache; import javax.cache.configuration.Factory; @@ -30,7 +29,6 @@ import org.apache.ignite.cache.CacheMode; import org.apache.ignite.cache.CachePeekMode; import org.apache.ignite.cache.CacheWriteSynchronizationMode; 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; @@ -43,7 +41,6 @@ import org.apache.ignite.internal.util.typedef.P1; import org.apache.ignite.internal.util.typedef.R1; 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.lang.IgnitePredicate; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; @@ -52,7 +49,6 @@ 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 org.jsr166.ConcurrentHashMap8; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMemoryMode.OFFHEAP_TIERED; @@ -66,21 +62,12 @@ public abstract class GridCacheAbstractSelfTest extends GridCommonAbstractTest { /** Test timeout */ private static final long TEST_TIMEOUT = 30 * 1000; - /** Store map. */ - protected static final Map<Object, Object> map = new ConcurrentHashMap8<>(); - - /** Reads counter. */ - protected static final AtomicInteger reads = new AtomicInteger(); - - /** Writes counter. */ - protected static final AtomicInteger writes = new AtomicInteger(); - - /** Removes counter. */ - protected static final AtomicInteger removes = new AtomicInteger(); - /** VM ip finder for TCP discovery. */ protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); + /** */ + protected static TestCacheStoreStrategy storeStgy; + /** * @return Grids count to start. */ @@ -97,6 +84,8 @@ public abstract class GridCacheAbstractSelfTest extends GridCommonAbstractTest { assert cnt >= 1 : "At least one grid must be started"; + initStoreStrategy(); + startGrids(cnt); awaitPartitionMapExchange(); @@ -106,7 +95,18 @@ public abstract class GridCacheAbstractSelfTest extends GridCommonAbstractTest { @Override protected void afterTestsStopped() throws Exception { stopAllGrids(); - map.clear(); + if (storeStgy != null) + storeStgy.resetStore(); + } + + /** + * Initializes {@link #storeStgy} with respect to the nature of the test. + * + * @throws IgniteCheckedException If failed. + */ + void initStoreStrategy() throws IgniteCheckedException { + if (storeStgy == null) + storeStgy = isMultiJvm() ? new H2CacheStoreStrategy() : new MapCacheStoreStrategy(); } /** {@inheritDoc} */ @@ -188,28 +188,7 @@ public abstract class GridCacheAbstractSelfTest extends GridCommonAbstractTest { assert jcache().unwrap(Ignite.class).transactions().tx() == null; assertEquals("Cache is not empty", 0, jcache().localSize(CachePeekMode.ALL)); - resetStore(); - } - - /** - * Cleans up cache store. - */ - protected void resetStore() { - map.clear(); - - reads.set(0); - writes.set(0); - removes.set(0); - } - - /** - * Put entry to cache store. - * - * @param key Key. - * @param val Value. - */ - protected void putToStore(Object key, Object val) { - map.put(key, val); + storeStgy.resetStore(); } /** {@inheritDoc} */ @@ -241,13 +220,16 @@ public abstract class GridCacheAbstractSelfTest extends GridCommonAbstractTest { protected CacheConfiguration cacheConfiguration(String gridName) throws Exception { CacheConfiguration cfg = defaultCacheConfiguration(); - CacheStore<?, ?> store = cacheStore(); + Factory<? extends CacheStore<Object, Object>> storeFactory = storeStgy.getStoreFactory(); + + CacheStore<?, ?> store = storeFactory.create(); if (store != null) { - cfg.setCacheStoreFactory(new TestStoreFactory()); + cfg.setCacheStoreFactory(storeFactory); cfg.setReadThrough(true); cfg.setWriteThrough(true); cfg.setLoadPreviousValue(true); + storeStgy.updateCacheConfiguration(cfg); } cfg.setSwapEnabled(swapEnabled()); @@ -303,37 +285,6 @@ public abstract class GridCacheAbstractSelfTest extends GridCommonAbstractTest { } /** - * @return Write through storage emulator. - */ - protected 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) { - reads.incrementAndGet(); - - return map.get(key); - } - - @Override public void write(javax.cache.Cache.Entry<? extends Object, ? extends Object> e) { - writes.incrementAndGet(); - - map.put(e.getKey(), e.getValue()); - } - - @Override public void delete(Object key) { - removes.incrementAndGet(); - - map.remove(key); - } - }; - } - - /** * @return {@code true} if swap should be enabled. */ protected boolean swapEnabled() { @@ -575,12 +526,4 @@ public abstract class GridCacheAbstractSelfTest extends GridCommonAbstractTest { } } - /** - * Serializable factory. - */ - protected static class TestStoreFactory implements Factory<CacheStore> { - @Override public CacheStore create() { - return cacheStore(); - } - } } http://git-wip-us.apache.org/repos/asf/ignite/blob/f91b6996/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheInterceptorAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheInterceptorAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheInterceptorAbstractSelfTest.java index f50a3e0..68bfb6f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheInterceptorAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheInterceptorAbstractSelfTest.java @@ -1444,7 +1444,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst interceptor.disabled = true; if (storeEnabled()) - assertEquals("Unexpected store value", expVal, map.get(key)); + assertEquals("Unexpected store value", expVal, storeStgy.getFromStore(key)); try { for (int i = 0; i < gridCount(); i++) http://git-wip-us.apache.org/repos/asf/ignite/blob/f91b6996/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/H2CacheStoreStrategy.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/H2CacheStoreStrategy.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/H2CacheStoreStrategy.java new file mode 100644 index 0000000..ccb2994 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/H2CacheStoreStrategy.java @@ -0,0 +1,468 @@ +/* + * 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.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.StringReader; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Map; +import javax.cache.Cache; +import javax.cache.configuration.Factory; +import javax.cache.integration.CacheLoaderException; +import javax.cache.integration.CacheWriterException; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.IgniteException; +import org.apache.ignite.cache.store.CacheStore; +import org.apache.ignite.cache.store.CacheStoreAdapter; +import org.apache.ignite.cache.store.CacheStoreSession; +import org.apache.ignite.cache.store.CacheStoreSessionListener; +import org.apache.ignite.cache.store.jdbc.CacheJdbcStoreSessionListener; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.lang.IgniteBiInClosure; +import org.apache.ignite.resources.CacheStoreSessionResource; +import org.h2.jdbcx.JdbcConnectionPool; +import org.h2.tools.RunScript; +import org.h2.tools.Server; + +/** + * {@link TestCacheStoreStrategy} backed by H2 in-memory database. + */ +public class H2CacheStoreStrategy implements TestCacheStoreStrategy { + /** Pool to get {@link Connection}s from. */ + private final JdbcConnectionPool dataSrc; + + /** Script that creates CACHE table. */ + private static final String CREATE_CACHE_TABLE = + "create table if not exists CACHE(k binary not null, v binary not null, PRIMARY KEY(k));"; + + /** Script that creates STATS table. */ + private static final String CREATE_STATS_TABLES = + "create table if not exists READS(id bigint auto_increment);\n" + + "create table if not exists WRITES(id bigint auto_increment);\n" + + "create table if not exists REMOVES(id bigint auto_increment);"; + + /** Script that populates STATS table */ + private static final String POPULATE_STATS_TABLE = + "delete from READS;\n" + + "delete from WRITES;\n" + + "delete from REMOVES;"; + + + /** + * @throws IgniteCheckedException If failed. + */ + public H2CacheStoreStrategy() throws IgniteCheckedException { + try { + Server.createTcpServer().start(); + dataSrc = H2CacheStoreSessionListenerFactory.createDataSource(); + + try (Connection conn = connection()) { + RunScript.execute(conn, new StringReader(CREATE_CACHE_TABLE)); + RunScript.execute(conn, new StringReader(CREATE_STATS_TABLES)); + RunScript.execute(conn, new StringReader(POPULATE_STATS_TABLE)); + } + } + catch (SQLException e) { + throw new IgniteCheckedException(e); + } + } + + /** {@inheritDoc} */ + @Override public int getReads() { + return queryStats("reads"); + } + + /** {@inheritDoc} */ + @Override public int getWrites() { + return queryStats("writes"); + } + + /** {@inheritDoc} */ + @Override public int getRemoves() { + return queryStats("removes"); + } + + /** + * @param tbl Table name. + * @return Update statistics. + */ + private int queryStats(String tbl) { + return querySingleInt("select count(*) from " + tbl, "Failed to query store stats [table=" + tbl + "]"); + } + + /** {@inheritDoc} */ + @Override public int getStoreSize() { + return querySingleInt("select count(*) from CACHE;", "Failed to query number of rows from CACHE table"); + } + + /** {@inheritDoc} */ + @Override public void resetStore() { + try (Connection conn = connection()) { + RunScript.execute(conn, new StringReader("delete from CACHE;")); + RunScript.execute(conn, new StringReader(POPULATE_STATS_TABLE)); + } + catch (SQLException e) { + throw new IgniteException(e); + } + } + + /** {@inheritDoc} */ + @Override public void putToStore(Object key, Object val) { + Connection conn = null; + try { + conn = connection(); + H2CacheStore.putToDb(conn, key, val); + } + catch (SQLException e) { + throw new IgniteException(e); + } + finally { + U.closeQuiet(conn); + } + } + + /** {@inheritDoc} */ + @Override public void putAllToStore(Map<?, ?> data) { + Connection conn = null; + PreparedStatement stmt = null; + try { + conn = connection(); + stmt = conn.prepareStatement(H2CacheStore.MERGE); + for (Map.Entry<?, ?> e : data.entrySet()) { + stmt.setBinaryStream(1, new ByteArrayInputStream(H2CacheStore.serialize(e.getKey()))); + stmt.setBinaryStream(2, new ByteArrayInputStream(H2CacheStore.serialize(e.getValue()))); + stmt.addBatch(); + } + stmt.executeBatch(); + } + catch (SQLException e) { + throw new IgniteException(e); + } + finally { + U.closeQuiet(stmt); + U.closeQuiet(conn); + } + } + + /** {@inheritDoc} */ + @Override public Object getFromStore(Object key) { + Connection conn = null; + try { + conn = connection(); + return H2CacheStore.getFromDb(conn, key); + } + catch (SQLException e) { + throw new IgniteException(e); + } + finally { + U.closeQuiet(conn); + } + } + + /** {@inheritDoc} */ + @Override public void removeFromStore(Object key) { + Connection conn = null; + try { + conn = connection(); + H2CacheStore.removeFromDb(conn, key); + } + catch (SQLException e) { + throw new IgniteException(e); + } + finally { + U.closeQuiet(conn); + } + } + + /** {@inheritDoc} */ + @Override public boolean isInStore(Object key) { + return getFromStore(key) != null; + } + + /** + * @return New {@link Connection} from {@link #dataSrc} + * @throws SQLException if failed + */ + private Connection connection() throws SQLException { + return dataSrc.getConnection(); + } + + /** + * Retrieves single int value from {@link ResultSet} returned by given query. + * + * @param qry Query string (fully populated, with params). + * @param errorMsg Message for {@link IgniteException} to bear in case of failure. + * @return Requested value + */ + private int querySingleInt(String qry, String errorMsg) { + Connection conn = null; + PreparedStatement stmt = null; + ResultSet rs = null; + try { + conn = connection(); + stmt = conn.prepareStatement(qry); + rs = stmt.executeQuery(); + if (rs.next()) + return rs.getInt(1); + else + throw new IgniteException(errorMsg); + } + catch (SQLException e) { + throw new IgniteException(e); + } + finally { + U.closeQuiet(rs); + U.closeQuiet(stmt); + U.closeQuiet(conn); + } + } + + /** {@inheritDoc} */ + @Override public void updateCacheConfiguration(CacheConfiguration<Object, Object> cfg) { + cfg.setCacheStoreSessionListenerFactories(new H2CacheStoreSessionListenerFactory()); + } + + /** {@inheritDoc} */ + @Override public Factory<? extends CacheStore<Object, Object>> getStoreFactory() { + return new H2StoreFactory(); + } + + /** Serializable H2 backed cache store factory. */ + public static class H2StoreFactory implements Factory<CacheStore<Object, Object>> { + /** {@inheritDoc} */ + @Override public CacheStore<Object, Object> create() { + return new H2CacheStore(); + } + } + + /** Serializable {@link Factory} producing H2 backed {@link CacheStoreSessionListener}s. */ + public static class H2CacheStoreSessionListenerFactory implements Factory<CacheStoreSessionListener> { + /** + * @return Connection pool + */ + static JdbcConnectionPool createDataSource() { + JdbcConnectionPool pool = JdbcConnectionPool.create("jdbc:h2:tcp://localhost/mem:TestDb;LOCK_MODE=0", "sa", ""); + pool.setMaxConnections(100); + return pool; + } + + /** {@inheritDoc} */ + @Override public CacheStoreSessionListener create() { + CacheJdbcStoreSessionListener lsnr = new CacheJdbcStoreSessionListener(); + lsnr.setDataSource(createDataSource()); + return lsnr; + } + } + + /** H2 backed {@link CacheStoreAdapter} implementations */ + public static class H2CacheStore extends CacheStoreAdapter<Object, Object> { + /** Store session */ + @CacheStoreSessionResource + private CacheStoreSession ses; + + /** Template for an insert statement */ + private static final String MERGE = "merge into CACHE(k, v) values(?, ?);"; + + /** {@inheritDoc} */ + @Override public void loadCache(IgniteBiInClosure<Object, Object> clo, Object... args) { + Connection conn = ses.attachment(); + assert conn != null; + + Statement stmt = null; + ResultSet rs = null; + try { + stmt = conn.createStatement(); + rs = stmt.executeQuery("select * from CACHE"); + while (rs.next()) + clo.apply(deserialize(rs.getBytes(1)), deserialize(rs.getBytes(2))); + } + catch (SQLException e) { + throw new IgniteException(e); + } + finally { + U.closeQuiet(rs); + U.closeQuiet(stmt); + } + } + + /** {@inheritDoc} */ + @Override public Object load(Object key) throws CacheLoaderException { + try { + Connection conn = ses.attachment(); + Object res = getFromDb(conn, key); + updateStats("reads"); + return res; + } + catch (SQLException e) { + throw new CacheLoaderException("Failed to load object [key=" + key + ']', e); + } + } + + /** {@inheritDoc} */ + @Override public void write(Cache.Entry<?, ?> entry) throws CacheWriterException { + try { + Connection conn = ses.attachment(); + putToDb(conn, entry.getKey(), entry.getValue()); + updateStats("writes"); + } + catch (SQLException e) { + throw new CacheWriterException("Failed to write object [key=" + entry.getKey() + ", " + + "val=" + entry.getValue() + ']', e); + } + } + + /** {@inheritDoc} */ + @Override public void delete(Object key) throws CacheWriterException { + try { + Connection conn = ses.attachment(); + removeFromDb(conn, key); + updateStats("removes"); + } + catch (SQLException e) { + throw new CacheWriterException("Failed to delete object [key=" + key + ']', e); + } + } + + /** + * Selects from H2 and deserialize from bytes the value pointed by key. + * + * @param conn {@link Connection} to use. + * @param key Key to look for. + * @return Stored object or null if the key is missing from DB. + * @throws SQLException If failed. + */ + static Object getFromDb(Connection conn, Object key) throws SQLException { + PreparedStatement stmt = null; + ResultSet rs = null; + try { + stmt = conn.prepareStatement("select v from CACHE where k = ?"); + stmt.setBinaryStream(1, new ByteArrayInputStream(H2CacheStore.serialize(key))); + rs = stmt.executeQuery(); + return rs.next() ? H2CacheStore.deserialize(rs.getBytes(1)) : null; + } + finally { + U.closeQuiet(rs); + U.closeQuiet(stmt); + } + } + + /** + * Puts key-value pair to H2. + * + * @param conn {@link Connection} to use. + * @param key Key. + * @param val Value. + * @throws SQLException If failed. + */ + static void putToDb(Connection conn, Object key, Object val) throws SQLException { + PreparedStatement stmt = null; + try { + stmt = conn.prepareStatement(H2CacheStore.MERGE); + stmt.setBinaryStream(1, new ByteArrayInputStream(H2CacheStore.serialize(key))); + stmt.setBinaryStream(2, new ByteArrayInputStream(H2CacheStore.serialize(val))); + stmt.executeUpdate(); + } + finally { + U.closeQuiet(stmt); + } + } + + /** + * Removes given key and its value from H2. + * + * @param conn {@link Connection} to invoke query upon. + * @param key Key to remove. + * @throws SQLException if failed. + */ + static void removeFromDb(Connection conn, Object key) throws SQLException { + PreparedStatement stmt = null; + try { + stmt = conn.prepareStatement("delete from CACHE where k = ?"); + stmt.setBinaryStream(1, new ByteArrayInputStream(H2CacheStore.serialize(key))); + stmt.executeUpdate(); + } + finally { + U.closeQuiet(stmt); + } + } + + /** + * Increments stored stats for given operation. + * + * @param tblName Table name + */ + private void updateStats(String tblName) { + Connection conn = ses.attachment(); + assert conn != null; + Statement stmt = null; + try { + stmt = conn.createStatement(); + stmt.executeUpdate("insert into " + tblName + " default values"); + } + catch (SQLException e) { + throw new IgniteException("Failed to update H2 store usage stats", e); + } + finally { + U.closeQuiet(stmt); + } + } + + /** + * Turns given arbitrary object to byte array. + * + * @param obj Object to serialize + * @return Bytes representation of given object. + */ + static byte[] serialize(Object obj) { + try (ByteArrayOutputStream b = new ByteArrayOutputStream()) { + try (ObjectOutputStream o = new ObjectOutputStream(b)) { + o.writeObject(obj); + } + return b.toByteArray(); + } + catch (Exception e) { + throw new IgniteException("Failed to serialize object to byte array [obj=" + obj, e); + } + } + + /** + * Deserializes an object from its byte array representation. + * + * @param bytes Byte array representation of the object. + * @return Deserialized object. + */ + public static Object deserialize(byte[] bytes) { + try (ByteArrayInputStream b = new ByteArrayInputStream(bytes)) { + try (ObjectInputStream o = new ObjectInputStream(b)) { + return o.readObject(); + } + } + catch (Exception e) { + throw new IgniteException("Failed to deserialize object from byte array", e); + } + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/f91b6996/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 index 5e8f162..7e6d015 100644 --- 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 @@ -351,9 +351,6 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar * @throws Exception If failed. */ public void testRemoveAllSkipStore() throws Exception { - if (isMultiJvm()) - fail("https://issues.apache.org/jira/browse/IGNITE-1088"); - if (!storeEnabled()) return; @@ -2571,9 +2568,6 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar * @throws Exception If failed. */ public void testRemoveLoad() throws Exception { - if (isMultiJvm()) - fail("https://issues.apache.org/jira/browse/IGNITE-1088"); - if (!storeEnabled()) return; @@ -3655,7 +3649,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar } // Avoid reloading from store. - map.remove(key); + storeStgy.removeFromStore(key); assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicateX() { @SuppressWarnings("unchecked") @@ -4169,12 +4163,12 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar for (int i = 0; i < gridCount(); i++) { for (Cache.Entry entry : jcache(i)) - map.put(entry.getKey(), entry.getValue()); + storeStgy.putToStore(entry.getKey(), entry.getValue()); } - assert map.size() == 2; - assert (Integer)map.get("key1") == 1; - assert (Integer)map.get("key2") == 2; + assert storeStgy.getStoreSize() == 2; + assert (Integer)storeStgy.getFromStore("key1") == 1; + assert (Integer)storeStgy.getFromStore("key2") == 2; } /** @@ -4726,9 +4720,6 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar * @throws Exception If failed. */ public void testWithSkipStore() throws Exception { - if (isMultiJvm()) - fail("https://issues.apache.org/jira/browse/IGNITE-1088"); - if (!storeEnabled()) return; @@ -4777,7 +4768,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar assertNotNull(cacheSkipStore.get(key)); assertNotNull(cache.get(key)); - assertEquals(i, map.get(key)); + assertEquals(i, storeStgy.getFromStore(key)); } for (int i = 0; i < keys.size(); ++i) { @@ -4786,13 +4777,13 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar Integer val1 = -1; cacheSkipStore.put(key, val1); - assertEquals(i, map.get(key)); + assertEquals(i, storeStgy.getFromStore(key)); assertEquals(val1, cacheSkipStore.get(key)); Integer val2 = -2; assertEquals(val1, cacheSkipStore.invoke(key, new SetValueProcessor(val2))); - assertEquals(i, map.get(key)); + assertEquals(i, storeStgy.getFromStore(key)); assertEquals(val2, cacheSkipStore.get(key)); } @@ -4801,7 +4792,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar assertNull(cacheSkipStore.get(key)); assertNotNull(cache.get(key)); - assertTrue(map.containsKey(key)); + assertTrue(storeStgy.isInStore(key)); } for (String key : keys) { @@ -4809,37 +4800,37 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar assertNull(cacheSkipStore.get(key)); assertNull(cache.get(key)); - assertFalse(map.containsKey(key)); + assertFalse(storeStgy.isInStore(key)); - map.put(key, 0); + storeStgy.putToStore(key, 0); Integer val = -1; assertNull(cacheSkipStore.invoke(key, new SetValueProcessor(val))); - assertEquals(0, map.get(key)); + assertEquals(0, storeStgy.getFromStore(key)); assertEquals(val, cacheSkipStore.get(key)); cache.remove(key); - map.put(key, 0); + storeStgy.putToStore(key, 0); assertTrue(cacheSkipStore.putIfAbsent(key, val)); assertEquals(val, cacheSkipStore.get(key)); - assertEquals(0, map.get(key)); + assertEquals(0, storeStgy.getFromStore(key)); cache.remove(key); - map.put(key, 0); + storeStgy.putToStore(key, 0); assertNull(cacheSkipStore.getAndPut(key, val)); assertEquals(val, cacheSkipStore.get(key)); - assertEquals(0, map.get(key)); + assertEquals(0, storeStgy.getFromStore(key)); cache.remove(key); } assertFalse(cacheSkipStore.iterator().hasNext()); - assertTrue(map.size() == 0); + assertTrue(storeStgy.getStoreSize() == 0); assertTrue(cache.size(ALL) == 0); // putAll/removeAll from multiple nodes. @@ -4854,7 +4845,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar for (String key : keys) { assertNotNull(cacheSkipStore.get(key)); assertNotNull(cache.get(key)); - assertFalse(map.containsKey(key)); + assertFalse(storeStgy.isInStore(key)); } cache.putAll(data); @@ -4862,7 +4853,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar for (String key : keys) { assertNotNull(cacheSkipStore.get(key)); assertNotNull(cache.get(key)); - assertTrue(map.containsKey(key)); + assertTrue(storeStgy.isInStore(key)); } cacheSkipStore.removeAll(data.keySet()); @@ -4870,7 +4861,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar for (String key : keys) { assertNull(cacheSkipStore.get(key)); assertNotNull(cache.get(key)); - assertTrue(map.containsKey(key)); + assertTrue(storeStgy.isInStore(key)); } cacheSkipStore.putAll(data); @@ -4878,7 +4869,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar for (String key : keys) { assertNotNull(cacheSkipStore.get(key)); assertNotNull(cache.get(key)); - assertTrue(map.containsKey(key)); + assertTrue(storeStgy.isInStore(key)); } cacheSkipStore.removeAll(data.keySet()); @@ -4886,7 +4877,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar for (String key : keys) { assertNull(cacheSkipStore.get(key)); assertNotNull(cache.get(key)); - assertTrue(map.containsKey(key)); + assertTrue(storeStgy.isInStore(key)); } cache.removeAll(data.keySet()); @@ -4894,24 +4885,24 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar for (String key : keys) { assertNull(cacheSkipStore.get(key)); assertNull(cache.get(key)); - assertFalse(map.containsKey(key)); + assertFalse(storeStgy.isInStore(key)); } - assertTrue(map.size() == 0); + assertTrue(storeStgy.getStoreSize() == 0); // Miscellaneous checks. String newKey = "New key"; - assertFalse(map.containsKey(newKey)); + assertFalse(storeStgy.isInStore(newKey)); cacheSkipStore.put(newKey, 1); - assertFalse(map.containsKey(newKey)); + assertFalse(storeStgy.isInStore(newKey)); cache.put(newKey, 1); - assertTrue(map.containsKey(newKey)); + assertTrue(storeStgy.isInStore(newKey)); Iterator<Cache.Entry<String, Integer>> it = cacheSkipStore.iterator(); @@ -4921,29 +4912,26 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar String rmvKey = entry.getKey(); - assertTrue(map.containsKey(rmvKey)); + assertTrue(storeStgy.isInStore(rmvKey)); it.remove(); assertNull(cacheSkipStore.get(rmvKey)); - assertTrue(map.containsKey(rmvKey)); + assertTrue(storeStgy.isInStore(rmvKey)); assertTrue(cache.size(ALL) == 0); assertTrue(cacheSkipStore.size(ALL) == 0); cache.remove(rmvKey); - assertTrue(map.size() == 0); + assertTrue(storeStgy.getStoreSize() == 0); } /** * @throws Exception If failed. */ public void testWithSkipStoreRemoveAll() throws Exception { - if (isMultiJvm()) - fail("https://issues.apache.org/jira/browse/IGNITE-1088"); - if (atomicityMode() == TRANSACTIONAL || (atomicityMode() == ATOMIC && nearEnabled())) // TODO IGNITE-373. return; @@ -4964,7 +4952,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar for (String key : data.keySet()) { assertNotNull(cacheSkipStore.get(key)); assertNotNull(cache.get(key)); - assertTrue(map.containsKey(key)); + assertTrue(storeStgy.isInStore(key)); } cacheSkipStore.removeAll(); @@ -4972,7 +4960,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar for (String key : data.keySet()) { assertNull(cacheSkipStore.get(key)); assertNotNull(cache.get(key)); - assertTrue(map.containsKey(key)); + assertTrue(storeStgy.isInStore(key)); } cache.removeAll(); @@ -4980,7 +4968,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar for (String key : data.keySet()) { assertNull(cacheSkipStore.get(key)); assertNull(cache.get(key)); - assertFalse(map.containsKey(key)); + assertFalse(storeStgy.isInStore(key)); } } @@ -5054,7 +5042,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar for (String key : keys) { assertEquals(val, cacheSkipStore.get(key)); assertEquals(val, cache.get(key)); - assertFalse(map.containsKey(key)); + assertFalse(storeStgy.isInStore(key)); } tx.commit(); @@ -5063,10 +5051,10 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar for (String key : keys) { assertEquals(val, cacheSkipStore.get(key)); assertEquals(val, cache.get(key)); - assertFalse(map.containsKey(key)); + assertFalse(storeStgy.isInStore(key)); } - assertEquals(0, map.size()); + assertEquals(0, storeStgy.getStoreSize()); // cacheSkipStore putAll(..)/removeAll(..) check. try (Transaction tx = txs.txStart(txConcurrency, txIsolation)) { @@ -5080,10 +5068,10 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar assertEquals(val, cacheSkipStore.get(key)); assertEquals(val, cache.get(key)); - assertFalse(map.containsKey(key)); + assertFalse(storeStgy.isInStore(key)); } - map.putAll(data); + storeStgy.putAllToStore(data); try (Transaction tx = txs.txStart(txConcurrency, txIsolation)) { cacheSkipStore.removeAll(data.keySet()); @@ -5094,12 +5082,12 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar for (String key : keys) { assertNull(cacheSkipStore.get(key)); assertNotNull(cache.get(key)); - assertTrue(map.containsKey(key)); + assertTrue(storeStgy.isInStore(key)); cache.remove(key); } - assertTrue(map.size() == 0); + assertTrue(storeStgy.getStoreSize() == 0); // cache putAll(..)/removeAll(..) check. try (Transaction tx = txs.txStart(txConcurrency, txIsolation)) { @@ -5108,7 +5096,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar for (String key : keys) { assertNotNull(cacheSkipStore.get(key)); assertNotNull(cache.get(key)); - assertFalse(map.containsKey(key)); + assertFalse(storeStgy.isInStore(key)); } cache.removeAll(data.keySet()); @@ -5116,13 +5104,13 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar for (String key : keys) { assertNull(cacheSkipStore.get(key)); assertNull(cache.get(key)); - assertFalse(map.containsKey(key)); + assertFalse(storeStgy.isInStore(key)); } tx.commit(); } - assertTrue(map.size() == 0); + assertTrue(storeStgy.getStoreSize() == 0); // putAll(..) from both cacheSkipStore and cache. try (Transaction tx = txs.txStart(txConcurrency, txIsolation)) { @@ -5143,7 +5131,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar for (String key : keys) { assertNotNull(cacheSkipStore.get(key)); assertNotNull(cache.get(key)); - assertFalse(map.containsKey(key)); + assertFalse(storeStgy.isInStore(key)); } tx.commit(); @@ -5154,7 +5142,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar assertNotNull(cacheSkipStore.get(key)); assertNotNull(cache.get(key)); - assertFalse(map.containsKey(key)); + assertFalse(storeStgy.isInStore(key)); } for (int i = keys.size() / 2; i < keys.size(); i++) { @@ -5162,7 +5150,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar assertNotNull(cacheSkipStore.get(key)); assertNotNull(cache.get(key)); - assertTrue(map.containsKey(key)); + assertTrue(storeStgy.isInStore(key)); } cache.removeAll(data.keySet()); @@ -5170,7 +5158,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar for (String key : keys) { assertNull(cacheSkipStore.get(key)); assertNull(cache.get(key)); - assertFalse(map.containsKey(key)); + assertFalse(storeStgy.isInStore(key)); } // Check that read-through is disabled when cacheSkipStore is used. @@ -5179,7 +5167,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar assertTrue(cacheSkipStore.size(ALL) == 0); assertTrue(cache.size(ALL) == 0); - assertTrue(map.size() != 0); + assertTrue(storeStgy.getStoreSize() != 0); try (Transaction tx = txs.txStart(txConcurrency, txIsolation)) { assertTrue(cacheSkipStore.getAll(data.keySet()).size() == 0); @@ -5202,7 +5190,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar try (Transaction tx = txs.txStart(txConcurrency, txIsolation)) { for (String key : data.keySet()) { - map.put(key, 0); + storeStgy.putToStore(key, 0); assertNull(cacheSkipStore.invoke(key, new SetValueProcessor(val))); } @@ -5211,7 +5199,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar } for (String key : data.keySet()) { - assertEquals(0, map.get(key)); + assertEquals(0, storeStgy.getFromStore(key)); assertEquals(val, cacheSkipStore.get(key)); assertEquals(val, cache.get(key)); @@ -5221,7 +5209,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar try (Transaction tx = txs.txStart(txConcurrency, txIsolation)) { for (String key : data.keySet()) { - map.put(key, 0); + storeStgy.putToStore(key, 0); assertTrue(cacheSkipStore.putIfAbsent(key, val)); } @@ -5230,7 +5218,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar } for (String key : data.keySet()) { - assertEquals(0, map.get(key)); + assertEquals(0, storeStgy.getFromStore(key)); assertEquals(val, cacheSkipStore.get(key)); assertEquals(val, cache.get(key)); @@ -5240,7 +5228,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar try (Transaction tx = txs.txStart(txConcurrency, txIsolation)) { for (String key : data.keySet()) { - map.put(key, 0); + storeStgy.putToStore(key, 0); assertNull(cacheSkipStore.getAndPut(key, val)); } @@ -5249,7 +5237,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar } for (String key : data.keySet()) { - assertEquals(0, map.get(key)); + assertEquals(0, storeStgy.getFromStore(key)); assertEquals(val, cacheSkipStore.get(key)); assertEquals(val, cache.get(key)); @@ -5268,7 +5256,7 @@ public class IgniteCacheConfigVariationsFullApiTest extends IgniteCacheConfigVar throws Exception { assertTrue(cache.size(ALL) == 0); assertTrue(cacheSkipStore.size(ALL) == 0); - assertTrue(map.size() == 0); + assertTrue(storeStgy.getStoreSize() == 0); } /** http://git-wip-us.apache.org/repos/asf/ignite/blob/f91b6996/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheReadThroughEvictionSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheReadThroughEvictionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheReadThroughEvictionSelfTest.java index 78afdc8..5da656d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheReadThroughEvictionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheReadThroughEvictionSelfTest.java @@ -51,7 +51,7 @@ public class IgniteCacheReadThroughEvictionSelfTest extends IgniteCacheConfigVar /** {@inheritDoc} */ @Override protected void afterTest() throws Exception { - resetStore(); + storeStgy.resetStore(); } /** http://git-wip-us.apache.org/repos/asf/ignite/blob/f91b6996/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MapCacheStoreStrategy.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MapCacheStoreStrategy.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MapCacheStoreStrategy.java new file mode 100644 index 0000000..800d781 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MapCacheStoreStrategy.java @@ -0,0 +1,145 @@ +/* + * 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.Map; +import java.util.concurrent.atomic.AtomicInteger; +import javax.cache.Cache; +import javax.cache.configuration.Factory; +import javax.cache.configuration.FactoryBuilder; +import org.apache.ignite.cache.store.CacheStore; +import org.apache.ignite.cache.store.CacheStoreAdapter; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.lang.IgniteBiInClosure; +import org.jsr166.ConcurrentHashMap8; + +/** + * {@link TestCacheStoreStrategy} implemented as a wrapper around {@link #map} + */ +public class MapCacheStoreStrategy implements TestCacheStoreStrategy { + /** Removes counter. */ + private final static AtomicInteger removes = new AtomicInteger(); + + /** Writes counter. */ + private final static AtomicInteger writes = new AtomicInteger(); + + /** Reads counter. */ + private final static AtomicInteger reads = new AtomicInteger(); + + /** Store map. */ + private final static Map<Object, Object> map = new ConcurrentHashMap8<>(); + + /** {@inheritDoc} */ + @Override public int getReads() { + return reads.get(); + } + + /** {@inheritDoc} */ + @Override public int getWrites() { + return writes.get(); + } + + /** {@inheritDoc} */ + @Override public int getRemoves() { + return removes.get(); + } + + /** {@inheritDoc} */ + @Override public int getStoreSize() { + return map.size(); + } + + /** {@inheritDoc} */ + @Override public void resetStore() { + map.clear(); + + reads.set(0); + writes.set(0); + removes.set(0); + } + + /** {@inheritDoc} */ + @Override public void putToStore(Object key, Object val) { + map.put(key, val); + } + + /** {@inheritDoc} */ + @Override public void putAllToStore(Map<?, ?> data) { + map.putAll(data); + } + + /** {@inheritDoc} */ + @Override public Object getFromStore(Object key) { + return map.get(key); + } + + /** {@inheritDoc} */ + @Override public void removeFromStore(Object key) { + map.remove(key); + } + + /** {@inheritDoc} */ + @Override public boolean isInStore(Object key) { + return map.containsKey(key); + } + + /** {@inheritDoc} */ + @Override public void updateCacheConfiguration(CacheConfiguration<Object, Object> cfg) { + // No-op. + } + + /** {@inheritDoc} */ + @Override public Factory<? extends CacheStore<Object, Object>> getStoreFactory() { + return FactoryBuilder.factoryOf(MapCacheStore.class); + } + + /** Serializable {@link #map} backed cache store factory */ + public static class MapStoreFactory implements Factory<CacheStore<Object, Object>> { + /** {@inheritDoc} */ + @Override public CacheStore<Object, Object> create() { + return new MapCacheStore(); + } + } + + /** {@link CacheStore} backed by {@link #map} */ + public static class MapCacheStore extends CacheStoreAdapter<Object, Object> { + /** {@inheritDoc} */ + @Override public void loadCache(IgniteBiInClosure<Object, Object> clo, Object... args) { + for (Map.Entry<Object, Object> e : map.entrySet()) + clo.apply(e.getKey(), e.getValue()); + } + + /** {@inheritDoc} */ + @Override public Object load(Object key) { + reads.incrementAndGet(); + return map.get(key); + } + + /** {@inheritDoc} */ + @Override public void write(Cache.Entry<?, ?> e) { + writes.incrementAndGet(); + map.put(e.getKey(), e.getValue()); + } + + /** {@inheritDoc} */ + @Override public void delete(Object key) { + removes.incrementAndGet(); + map.remove(key); + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/f91b6996/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/TestCacheStoreStrategy.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/TestCacheStoreStrategy.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/TestCacheStoreStrategy.java new file mode 100644 index 0000000..9ee174a --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/TestCacheStoreStrategy.java @@ -0,0 +1,96 @@ +/* + * 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.Map; +import javax.cache.configuration.Factory; +import org.apache.ignite.cache.store.CacheStore; +import org.apache.ignite.configuration.CacheConfiguration; + +/** + * Interface for cache store backend manipulation and stats routines. + */ +public interface TestCacheStoreStrategy { + /** + * @return Number of reads to store. + */ + public int getReads(); + + /** + * @return Number of writes to store. + */ + public int getWrites(); + + /** + * @return Number of removals from store. + */ + public int getRemoves(); + + /** + * @return Total number of items in the store. + */ + public int getStoreSize(); + + /** + * Clear store contents. + */ + public void resetStore(); + + /** + * Put entry to cache store. + * + * @param key Key. + * @param val Value. + */ + public void putToStore(Object key, Object val); + + /** + * @param data Items to put to store. + */ + public void putAllToStore(Map<?, ?> data); + + /** + * @param key Key to look for. + * @return {@link Object} pointed to by given key or {@code null} if no object is present. + */ + public Object getFromStore(Object key); + + /** + * @param key to look for + */ + public void removeFromStore(Object key); + + /** + * @param key to look for. + * @return {@code True} if object pointed to by key is in store, false otherwise. + */ + public boolean isInStore(Object key); + + /** + * Called from {@link GridCacheAbstractSelfTest#cacheConfiguration(String)}, + * this method allows implementations to tune cache config. + * + * @param cfg {@link CacheConfiguration} to tune. + */ + public void updateCacheConfiguration(CacheConfiguration<Object, Object> cfg); + + /** + * @return {@link Factory} for write-through storage emulator. + */ + public Factory<? extends CacheStore<Object, Object>> getStoreFactory(); +} http://git-wip-us.apache.org/repos/asf/ignite/blob/f91b6996/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java index eaab103..411e1bf 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java @@ -390,7 +390,7 @@ public class GridCacheNearOnlyMultiNodeFullApiSelfTest extends GridCachePartitio } // Avoid reloading from store. - map.remove(key); + storeStgy.removeFromStore(key); assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicateX() { @SuppressWarnings("unchecked") http://git-wip-us.apache.org/repos/asf/ignite/blob/f91b6996/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedOffHeapTieredMultiNodeFullApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedOffHeapTieredMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedOffHeapTieredMultiNodeFullApiSelfTest.java index cbcc739..0386510 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedOffHeapTieredMultiNodeFullApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedOffHeapTieredMultiNodeFullApiSelfTest.java @@ -68,6 +68,6 @@ public class GridCachePartitionedOffHeapTieredMultiNodeFullApiSelfTest extends G assertEquals(5, primaryCache.localPeek(key, CachePeekMode.ONHEAP).intValue()); assertNull(primaryCache.localPeek(key, CachePeekMode.OFFHEAP)); assertEquals(5, cache.get(key).intValue()); - assertEquals(5, map.get(key)); + assertEquals(5, storeStgy.getFromStore(key)); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/f91b6996/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 index 0be6d50..4666581 100644 --- 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 @@ -44,9 +44,9 @@ 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.internal.processors.cache.MapCacheStoreStrategy; 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; @@ -63,7 +63,7 @@ public class ConfigVariations { /** */ private static final ConfigParameter<Object> CACHE_STORE_PARAM = Parameters.complexParameter( - Parameters.parameter("setCacheStoreFactory", Parameters.factory(IgniteCacheConfigVariationsAbstractTest.TestStoreFactory.class)), + Parameters.parameter("setCacheStoreFactory", Parameters.factory(MapCacheStoreStrategy.MapStoreFactory.class)), Parameters.parameter("setReadThrough", true), Parameters.parameter("setWriteThrough", true), Parameters.parameter("setCacheStoreSessionListenerFactories", noopCacheStoreSessionListenerFactory()) @@ -71,7 +71,7 @@ public class ConfigVariations { /** */ private static final ConfigParameter<Object> SIMPLE_CACHE_STORE_PARAM = Parameters.complexParameter( - Parameters.parameter("setCacheStoreFactory", Parameters.factory(IgniteCacheConfigVariationsAbstractTest.TestStoreFactory.class)), + Parameters.parameter("setCacheStoreFactory", Parameters.factory(MapCacheStoreStrategy.MapStoreFactory.class)), Parameters.parameter("setReadThrough", true), Parameters.parameter("setWriteThrough", true) );
