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-950 Commit: c1fc7b5d6d7deb895bdf13d3b7e199161d494277 Parents: ca253a8 Author: S.Vladykin <svlady...@gridgain.com> Authored: Wed Jun 17 13:44:36 2015 +0300 Committer: S.Vladykin <svlady...@gridgain.com> 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<GridDhtLocalPartition>, * @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<GridDhtPartitionsReservation> NO_OP = new CI1<GridDhtPartitionsReservation>() { + @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<GridDhtPartitionsReservation> 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<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;