Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id C1748200B61 for ; Mon, 4 Jul 2016 21:02:42 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id C0715160A65; Mon, 4 Jul 2016 19:02:42 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id DA349160A7A for ; Mon, 4 Jul 2016 21:02:40 +0200 (CEST) Received: (qmail 28177 invoked by uid 500); 4 Jul 2016 19:02:40 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 26412 invoked by uid 99); 4 Jul 2016 19:02:38 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Jul 2016 19:02:38 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 57F5BE9646; Mon, 4 Jul 2016 19:02:38 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: vkulichenko@apache.org To: commits@ignite.apache.org Date: Mon, 04 Jul 2016 19:03:18 -0000 Message-Id: <5c0f04b296e64eec97643bb693f3c76f@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [42/50] [abbrv] ignite git commit: ignite-1088 Implemented store for multi jvm tests archived-at: Mon, 04 Jul 2016 19:02:42 -0000 http://git-wip-us.apache.org/repos/asf/ignite/blob/f91b6996/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteCacheConfigVariationsAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteCacheConfigVariationsAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteCacheConfigVariationsAbstractTest.java index bcea603..403835a 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteCacheConfigVariationsAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteCacheConfigVariationsAbstractTest.java @@ -17,9 +17,7 @@ package org.apache.ignite.testframework.junits; -import java.util.Map; import javax.cache.Cache; -import javax.cache.configuration.Factory; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; import org.apache.ignite.IgniteCheckedException; @@ -29,8 +27,6 @@ import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cache.CacheMemoryMode; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.cache.CachePeekMode; -import org.apache.ignite.cache.store.CacheStore; -import org.apache.ignite.cache.store.CacheStoreAdapter; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; @@ -38,15 +34,16 @@ import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException; import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.H2CacheStoreStrategy; +import org.apache.ignite.internal.processors.cache.MapCacheStoreStrategy; +import org.apache.ignite.internal.processors.cache.TestCacheStoreStrategy; import org.apache.ignite.internal.util.lang.GridAbsPredicateX; import org.apache.ignite.internal.util.typedef.X; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.lang.IgniteBiInClosure; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.configvariations.CacheStartMode; import org.apache.ignite.transactions.Transaction; import org.jetbrains.annotations.Nullable; -import org.jsr166.ConcurrentHashMap8; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMemoryMode.OFFHEAP_TIERED; @@ -62,8 +59,8 @@ public abstract class IgniteCacheConfigVariationsAbstractTest extends IgniteConf /** Test timeout. */ private static final long TEST_TIMEOUT = 30 * 1000; - /** Store map. */ - protected static final Map map = new ConcurrentHashMap8<>(); + /** */ + protected static TestCacheStoreStrategy storeStgy; /** {@inheritDoc} */ @Override protected long getTestTimeout() { @@ -72,6 +69,7 @@ public abstract class IgniteCacheConfigVariationsAbstractTest extends IgniteConf /** {@inheritDoc} */ @Override protected final void beforeTestsStarted() throws Exception { + initStoreStrategy(); assert testsCfg != null; assert !testsCfg.withClients() || testsCfg.gridCount() >= 3; @@ -135,6 +133,12 @@ public abstract class IgniteCacheConfigVariationsAbstractTest extends IgniteConf } } + /** Initialize {@link #storeStgy} with respect to the nature of the test */ + void initStoreStrategy() throws IgniteCheckedException { + if (storeStgy == null) + storeStgy = isMultiJvm() ? new H2CacheStoreStrategy() : new MapCacheStoreStrategy(); + } + /** * Starts caches dynamically. * @@ -189,7 +193,7 @@ public abstract class IgniteCacheConfigVariationsAbstractTest extends IgniteConf } } - map.clear(); + storeStgy.resetStore(); super.afterTestsStopped(); } @@ -313,7 +317,7 @@ public abstract class IgniteCacheConfigVariationsAbstractTest extends IgniteConf if (cacheIsNotEmptyMsg == null) assertEquals("Cache is not empty", 0, jcache().localSize(CachePeekMode.ALL)); - resetStore(); + storeStgy.resetStore(); // Restore cache if current cache has garbage. if (cacheIsNotEmptyMsg != null) { @@ -351,13 +355,6 @@ public abstract class IgniteCacheConfigVariationsAbstractTest extends IgniteConf } /** - * Cleans up cache store. - */ - protected void resetStore() { - map.clear(); - } - - /** * Put entry to cache store. * * @param key Key. @@ -367,7 +364,7 @@ public abstract class IgniteCacheConfigVariationsAbstractTest extends IgniteConf if (!storeEnabled()) throw new IllegalStateException("Failed to put to store because store is disabled."); - map.put(key, val); + storeStgy.putToStore(key, val); } /** @@ -432,31 +429,6 @@ public abstract class IgniteCacheConfigVariationsAbstractTest extends IgniteConf } /** - * @return Write through storage emulator. - */ - public static CacheStore cacheStore() { - return new CacheStoreAdapter() { - @Override public void loadCache(IgniteBiInClosure clo, - Object... args) { - for (Map.Entry e : map.entrySet()) - clo.apply(e.getKey(), e.getValue()); - } - - @Override public Object load(Object key) { - return map.get(key); - } - - @Override public void write(Cache.Entry e) { - map.put(e.getKey(), e.getValue()); - } - - @Override public void delete(Object key) { - map.remove(key); - } - }; - } - - /** * @return {@code true} if near cache should be enabled. */ protected boolean nearEnabled() { @@ -572,13 +544,4 @@ public abstract class IgniteCacheConfigVariationsAbstractTest extends IgniteConf protected static boolean containsKey(IgniteCache cache, Object key) throws Exception { return offheapTiered(cache) ? cache.localPeek(key, CachePeekMode.OFFHEAP) != null : cache.containsKey(key); } - - /** - * Serializable factory. - */ - public static class TestStoreFactory implements Factory { - @Override public CacheStore create() { - return cacheStore(); - } - } } http://git-wip-us.apache.org/repos/asf/ignite/blob/f91b6996/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryIndexSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryIndexSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryIndexSelfTest.java index d834eb3..73b665e 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryIndexSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheQueryIndexSelfTest.java @@ -74,7 +74,7 @@ public class IgniteCacheQueryIndexSelfTest extends GridCacheAbstractSelfTest { */ public void testWithStoreLoad() throws Exception { for (int i = 0; i < ENTRY_CNT; i++) - putToStore(i, new CacheValue(i)); + storeStgy.putToStore(i, new CacheValue(i)); IgniteCache cache0 = grid(0).cache(null);