Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AB0F718F24 for ; Mon, 26 Oct 2015 14:22:25 +0000 (UTC) Received: (qmail 52417 invoked by uid 500); 26 Oct 2015 14:22:25 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 52384 invoked by uid 500); 26 Oct 2015 14:22:25 -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 52375 invoked by uid 99); 26 Oct 2015 14:22:25 -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, 26 Oct 2015 14:22:25 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 3C79EDFDCC; Mon, 26 Oct 2015 14:22:25 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: yzhdanov@apache.org To: commits@ignite.apache.org Message-Id: <5ccbcc05a34a4b80b1d081c8cc7ef260@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: ignite git commit: fixing tests Date: Mon, 26 Oct 2015 14:22:25 +0000 (UTC) Repository: ignite Updated Branches: refs/heads/ignite-1.4-slow-server-debug 0c11727fd -> 960e91c8d fixing tests Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/960e91c8 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/960e91c8 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/960e91c8 Branch: refs/heads/ignite-1.4-slow-server-debug Commit: 960e91c8d7cc69729cae93ac09cf36914de25549 Parents: 0c11727 Author: Yakov Zhdanov Authored: Mon Oct 26 17:22:17 2015 +0300 Committer: Yakov Zhdanov Committed: Mon Oct 26 17:22:17 2015 +0300 ---------------------------------------------------------------------- .../org/jsr166/ConcurrentLinkedHashMap.java | 24 ++++++------- .../GridCacheMissingCommitVersionSelfTest.java | 38 ++++++++++++-------- 2 files changed, 34 insertions(+), 28 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/960e91c8/modules/core/src/main/java/org/jsr166/ConcurrentLinkedHashMap.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/jsr166/ConcurrentLinkedHashMap.java b/modules/core/src/main/java/org/jsr166/ConcurrentLinkedHashMap.java index a6112b3..e8f8e0f 100644 --- a/modules/core/src/main/java/org/jsr166/ConcurrentLinkedHashMap.java +++ b/modules/core/src/main/java/org/jsr166/ConcurrentLinkedHashMap.java @@ -758,7 +758,7 @@ public class ConcurrentLinkedHashMap extends AbstractMap implements recordInsert(e, (ConcurrentLinkedDeque8)segEntryQ); if (maxCap > 0) - checkRemoveEldestEntrySegment(); + checkRemoveEldestEntrySegment(c); break; @@ -766,7 +766,7 @@ public class ConcurrentLinkedHashMap extends AbstractMap implements segEntryQ.add(e); if (maxCap > 0) - checkRemoveEldestEntrySegment(); + checkRemoveEldestEntrySegment(c); break; @@ -788,23 +788,21 @@ public class ConcurrentLinkedHashMap extends AbstractMap implements } /** - * + * @param cnt Segment entries count. */ - private void checkRemoveEldestEntrySegment() { + private void checkRemoveEldestEntrySegment(int cnt) { assert maxCap > 0; - int rmvCnt = sizex() - maxCap; - - for (int i = 0; i < rmvCnt; i++) { + if (cnt - ((maxCap / segments.length) + 1) > 0) { HashEntry e0 = segEntryQ.poll(); - if (e0 == null) - break; + assert e0 != null; - removeLocked(e0.key, e0.hash, null /*no need to compare*/, false); - - if (sizex() <= maxCap) - break; + removeLocked( + e0.key, + e0.hash, + null /*no need to compare*/, + false); } } http://git-wip-us.apache.org/repos/asf/ignite/blob/960e91c8/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMissingCommitVersionSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMissingCommitVersionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMissingCommitVersionSelfTest.java index 891f257..19e49f3 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMissingCommitVersionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMissingCommitVersionSelfTest.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal.processors.cache; import java.util.concurrent.Callable; +import java.util.concurrent.ConcurrentLinkedDeque; import java.util.concurrent.atomic.AtomicInteger; import org.apache.ignite.IgniteCache; import org.apache.ignite.configuration.CacheConfiguration; @@ -32,13 +33,14 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import static org.apache.ignite.IgniteSystemProperties.IGNITE_MAX_COMPLETED_TX_COUNT; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.cache.CacheMode.PARTITIONED; +import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; /** * */ public class GridCacheMissingCommitVersionSelfTest extends GridCommonAbstractTest { /** */ - private volatile Integer failedKey; + private volatile boolean putFailed; /** */ private String maxCompletedTxCount; @@ -67,6 +69,7 @@ public class GridCacheMissingCommitVersionSelfTest extends GridCommonAbstractTes ccfg.setCacheMode(PARTITIONED); ccfg.setAtomicityMode(TRANSACTIONAL); + ccfg.setWriteSynchronizationMode(FULL_SYNC); cfg.setCacheConfiguration(ccfg); @@ -90,43 +93,48 @@ public class GridCacheMissingCommitVersionSelfTest extends GridCommonAbstractTes final AtomicInteger keyStart = new AtomicInteger(); + final ConcurrentLinkedDeque q = new ConcurrentLinkedDeque<>(); + GridTestUtils.runMultiThreaded(new Callable() { @Override public Object call() throws Exception { int start = keyStart.getAndAdd(KEYS_PER_THREAD); - for (int i = 0; i < KEYS_PER_THREAD && failedKey == null; i++) { + for (int i = 0; i < KEYS_PER_THREAD && !putFailed; i++) { int key = start + i; try { cache.put(key, 1); } catch (Exception e) { - log.info("Put failed: " + e); + log.info("Put failed [err=" + e + ", i=" + i + ']'); + + putFailed = true; - failedKey = key; + q.add(key); } } - return null; } }, 10, "put-thread"); - assertNotNull("Test failed to provoke 'missing commit version' error.", failedKey); + assertTrue("Test failed to provoke 'missing commit version' error.", putFailed); - log.info("Trying to update " + failedKey); + for (Integer key : q) { + log.info("Trying to update " + key); - IgniteCache asyncCache = cache.withAsync(); + IgniteCache asyncCache = cache.withAsync(); - asyncCache.put(failedKey, 2); + asyncCache.put(key, 2); - IgniteFuture fut = asyncCache.future(); + IgniteFuture fut = asyncCache.future(); - try { - fut.get(5000); - } - catch (IgniteFutureTimeoutException ignore) { - fail("Put failed to finish in 5s."); + try { + fut.get(5000); + } + catch (IgniteFutureTimeoutException ignore) { + fail("Put failed to finish in 5s: " + key); + } } } }