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 7A707200C7D for ; Tue, 16 May 2017 13:32:08 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 74362160BAC; Tue, 16 May 2017 11:32:08 +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 9477D160B9D for ; Tue, 16 May 2017 13:32:07 +0200 (CEST) Received: (qmail 79264 invoked by uid 500); 16 May 2017 11:32:06 -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 79255 invoked by uid 99); 16 May 2017 11:32:06 -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; Tue, 16 May 2017 11:32:06 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 916B0DFDD5; Tue, 16 May 2017 11:32:06 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sboikov@apache.org To: commits@ignite.apache.org Message-Id: <2f610d54351a41c1afd1f1902083139b@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: ignite git commit: ignite-5075 Date: Tue, 16 May 2017 11:32:06 +0000 (UTC) archived-at: Tue, 16 May 2017 11:32:08 -0000 Repository: ignite Updated Branches: refs/heads/ignite-5075 e84d4a2d1 -> 3f6a79f77 ignite-5075 Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/3f6a79f7 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/3f6a79f7 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/3f6a79f7 Branch: refs/heads/ignite-5075 Commit: 3f6a79f7719189eeb3f4fe5169f9f1f346293508 Parents: e84d4a2 Author: sboikov Authored: Tue May 16 14:31:59 2017 +0300 Committer: sboikov Committed: Tue May 16 14:31:59 2017 +0300 ---------------------------------------------------------------------- .../cache/IgniteCacheOffheapManagerImpl.java | 1 + .../processors/cache/IgniteCacheGroupsTest.java | 96 +++++++++++++++++--- 2 files changed, 83 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/3f6a79f7/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java index 471f073..9553491 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java @@ -1159,6 +1159,7 @@ public class IgniteCacheOffheapManagerImpl implements IgniteCacheOffheapManager } /** + * @param cctx Cache context. * @param newRow New row. * @param oldRow Old row if available. * @throws IgniteCheckedException If failed. http://git-wip-us.apache.org/repos/asf/ignite/blob/3f6a79f7/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsTest.java index 9fb72d7..8ff45f2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsTest.java @@ -168,7 +168,7 @@ public class IgniteCacheGroupsTest extends GridCommonAbstractTest { for (int i = 0; i < srvs; i++) { checkCacheGroup(i, GROUP1, true); - //checkCache(i, "cache2"); + checkCache(i, "cache2"); } srv0.destroyCache("cache2"); @@ -262,14 +262,52 @@ public class IgniteCacheGroupsTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ - public void _testCacheApiTx() throws Exception { + public void testCacheApiTxPartitioned() throws Exception { + cacheApiTest(PARTITIONED, TRANSACTIONAL); + } + + /** + * @throws Exception If failed. + */ + public void testCacheApiTxReplicated() throws Exception { + cacheApiTest(REPLICATED, TRANSACTIONAL); + } + + /** + * @throws Exception If failed. + */ + public void testCacheApiAtomicPartitioned() throws Exception { + cacheApiTest(PARTITIONED, ATOMIC); + } + + /** + * @throws Exception If failed. + */ + public void testCacheApiAtomicReplicated() throws Exception { + cacheApiTest(REPLICATED, ATOMIC); + } + + /** + * @param cacheMode Cache mode. + * @param atomicityMode Atomicity mode. + * @throws Exception If failed. + */ + private void cacheApiTest(CacheMode cacheMode, CacheAtomicityMode atomicityMode) throws Exception { startGridsMultiThreaded(4); client = true; startGrid(4); - cacheApiTest(PARTITIONED, TRANSACTIONAL, 2, false); + int[] backups = cacheMode == REPLICATED ? new int[]{Integer.MAX_VALUE} : new int[]{0, 1, 2, 3}; + + for (int backups0 : backups) + cacheApiTest(cacheMode, atomicityMode, backups0, false); + + int backups0 = cacheMode == REPLICATED ? Integer.MAX_VALUE : + backups[ThreadLocalRandom.current().nextInt(backups.length)]; + + cacheApiTest(cacheMode, atomicityMode, backups0, true); } /** @@ -282,27 +320,57 @@ public class IgniteCacheGroupsTest extends GridCommonAbstractTest { for (int i = 0; i < 2; i++) ignite(0).createCache(cacheConfiguration(GROUP1, "cache-" + i, cacheMode, atomicityMode, backups, heapCache)); - for (Ignite node : Ignition.allGrids()) { - for (int i = 0; i < 2; i++) { - IgniteCache cache = node.cache("cache-" + i); - - log.info("Test cache [node=" + node.name() + ", cache=" + cache.getName() + - ", mode=" + cacheMode + ", atomicity=" + atomicityMode + ", backups=" + backups + ']'); - - cacheApiTest(cache); + try { + for (Ignite node : Ignition.allGrids()) { + for (int i = 0; i < 2; i++) { + IgniteCache cache = node.cache("cache-" + i); + + log.info("Test cache [node=" + node.name() + + ", cache=" + cache.getName() + + ", mode=" + cacheMode + + ", atomicity=" + atomicityMode + + ", backups=" + backups + + ", heapCache=" + heapCache + + ']'); + + cacheApiTest(cache); + } } } + finally { + for (int i = 0; i < 2; i++) + ignite(0).destroyCache("cache-" + i); + } } /** * @param cache Cache. */ private void cacheApiTest(IgniteCache cache) { - int key = 1; + ThreadLocalRandom rnd = ThreadLocalRandom.current(); - cache.put(key, 1); + for (int i = 0; i < 10; i++) { + Integer key = rnd.nextInt(10_000); + + assertNull(cache.get(key)); + assertFalse(cache.containsKey(key)); + + Integer val = key + 1; + + cache.put(key, val); + + assertEquals(val, cache.get(key)); + assertTrue(cache.containsKey(key)); + + cache.remove(key); + + assertNull(cache.get(key)); + assertFalse(cache.containsKey(key)); + } + + cache.clear(); - cache.remove(key); + cache.removeAll(); } /**