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 86810184C6 for ; Thu, 18 Jun 2015 13:15:55 +0000 (UTC) Received: (qmail 67804 invoked by uid 500); 18 Jun 2015 13:15:55 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 67774 invoked by uid 500); 18 Jun 2015 13:15:55 -0000 Mailing-List: contact commits-help@ignite.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.incubator.apache.org Delivered-To: mailing list commits@ignite.incubator.apache.org Received: (qmail 67765 invoked by uid 99); 18 Jun 2015 13:15:55 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Jun 2015 13:15:55 +0000 X-ASF-Spam-Status: No, hits=-2000.4 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 18 Jun 2015 13:13:31 +0000 Received: (qmail 64481 invoked by uid 99); 18 Jun 2015 13:15:18 -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; Thu, 18 Jun 2015 13:15:18 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 60C63E3C9F; Thu, 18 Jun 2015 13:15:18 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sboikov@apache.org To: commits@ignite.incubator.apache.org Date: Thu, 18 Jun 2015 13:15:30 -0000 Message-Id: <26104c0ea05a4f4091fc2b7c26452430@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [13/50] incubator-ignite git commit: ignite-484-1 - minor X-Virus-Checked: Checked by ClamAV on apache.org ignite-484-1 - minor Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/c1fc7b5d Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/c1fc7b5d Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/c1fc7b5d Branch: refs/heads/ignite-1003-debug Commit: c1fc7b5d6d7deb895bdf13d3b7e199161d494277 Parents: ca253a8 Author: S.Vladykin Authored: Wed Jun 17 13:44:36 2015 +0300 Committer: S.Vladykin Committed: Wed Jun 17 13:44:36 2015 +0300 ---------------------------------------------------------------------- .../distributed/dht/GridDhtLocalPartition.java | 8 +++----- .../dht/GridDhtPartitionsReservation.java | 20 ++++++++++++++------ .../IgniteCacheQueryNodeRestartSelfTest2.java | 8 ++++++-- 3 files changed, 23 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c1fc7b5d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java index 5938fc8..1392f5e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java @@ -505,14 +505,12 @@ public class GridDhtLocalPartition implements Comparable, * @return {@code true} If there is a group reservation. */ private boolean groupReserved() { - boolean reserved = false; - for (GridDhtPartitionsReservation reservation : reservations) { - if (!reservation.canEvict()) - reserved = true; // Calling all the reservations to allow them unregister themselves. + if (!reservation.invalidate()) + return true; // Failed to invalidate reservation -> we are reserved. } - return reserved; + return false; } /** http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c1fc7b5d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionsReservation.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionsReservation.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionsReservation.java index a32946a..aced999 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionsReservation.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionsReservation.java @@ -34,6 +34,13 @@ public class GridDhtPartitionsReservation implements GridReservable { private static final GridDhtLocalPartition[] EMPTY = {}; /** */ + private static final CI1 NO_OP = new CI1() { + @Override public void apply(GridDhtPartitionsReservation gridDhtPartitionsReservation) { + throw new IllegalStateException(); + } + }; + + /** */ private final Object appKey; /** */ @@ -154,7 +161,7 @@ public class GridDhtPartitionsReservation implements GridReservable { for (;;) { int r = reservations.get(); - if (r == -1) // Invalidated by successful canEvict call. + if (r == -1) // Invalidated. return false; assert r >= 0 : r; @@ -224,20 +231,21 @@ public class GridDhtPartitionsReservation implements GridReservable { // Unpublish. CI1 u = unpublish.get(); - if (u != null && unpublish.compareAndSet(u, null)) + if (u != null && u != NO_OP && unpublish.compareAndSet(u, NO_OP)) u.apply(this); } /** * Must be checked in {@link GridDhtLocalPartition#tryEvict(boolean)}. - * If returns {@code true} then probably partition will be evicted (or at least cleared), - * so this reservation object becomes invalid and must be dropped from the partition. + * If returns {@code true} this reservation object becomes invalid and partitions + * can be evicted or at least cleared. * Also this means that after returning {@code true} here method {@link #reserve()} can not * return {@code true} anymore. * - * @return {@code true} If this reservation is NOT reserved and partition CAN be evicted. + * @return {@code true} If this reservation was successfully invalidated because it was not + * reserved and partitions can be evicted. */ - public boolean canEvict() { + public boolean invalidate() { assert parts.get() != null : "all parts must be reserved before registration"; int r = reservations.get(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c1fc7b5d/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest2.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest2.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest2.java index d440b13..527dfea 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest2.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest2.java @@ -177,7 +177,7 @@ public class IgniteCacheQueryNodeRestartSelfTest2 extends GridCommonAbstractTest * @throws Exception If failed. */ public void testRestarts() throws Exception { - int duration = 150 * 1000; + int duration = 90 * 1000; int qryThreadNum = 4; int restartThreadsNum = 2; // 4 + 2 = 6 nodes final int nodeLifeTime = 2 * 1000; @@ -197,6 +197,9 @@ public class IgniteCacheQueryNodeRestartSelfTest2 extends GridCommonAbstractTest final List> rRes = grid(0).cache("co").query(new SqlFieldsQuery(REPLICATED_QRY)).getAll(); + assertFalse(pRes.isEmpty()); + assertFalse(rRes.isEmpty()); + final AtomicInteger qryCnt = new AtomicInteger(); final AtomicBoolean qrysDone = new AtomicBoolean(); @@ -235,7 +238,8 @@ public class IgniteCacheQueryNodeRestartSelfTest2 extends GridCommonAbstractTest if (!(th instanceof CacheException)) continue; - if (th.getMessage().startsWith("Failed to fetch data from node:")) { + if (th.getMessage() != null && + th.getMessage().startsWith("Failed to fetch data from node:")) { failedOnRemoteFetch = true; break;