Repository: ignite Updated Branches: refs/heads/ignite-1093-2 427ea5169 -> 4baf249db
1093 Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4baf249d Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4baf249d Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4baf249d Branch: refs/heads/ignite-1093-2 Commit: 4baf249db793001a982864222cbdfa50f2dcaade Parents: 427ea51 Author: Anton Vinogradov <[email protected]> Authored: Fri Oct 9 22:12:20 2015 +0300 Committer: Anton Vinogradov <[email protected]> Committed: Fri Oct 9 22:12:20 2015 +0300 ---------------------------------------------------------------------- .../distributed/dht/GridDhtLocalPartition.java | 31 ++++++++++++-------- 1 file changed, 19 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/4baf249d/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 0eccad8..9fea4f9 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 @@ -526,36 +526,29 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>, * @param updateSeq Update sequence. * @return {@code True} if entry has been transitioned to state EVICTED. */ - boolean tryEvict(boolean updateSeq) { - if ((state.getReference() != RENTING && state.getReference() != EVICTING) || - state.getStamp() != 0 || groupReserved()) - return false; - - if (!state.compareAndSet(RENTING, EVICTING, 0, 0)) - return false; - + private boolean evict(boolean updateSeq) { // Attempt to evict partition entries from cache. if (!clearAll(EVICTION_CLEAR_LIMIT)){ //Resend to pool to stop another threads blocking. cctx.closures().callLocalSafe(new GPC<Boolean>() { @Override public Boolean call() { - return tryEvict(true); + return evict(true); } }, /*system pool*/ true); return false; } - while (!map.isEmpty()) { + if (!map.isEmpty()) { cctx.closures().callLocalSafe(new GPC<Boolean>() { @Override public Boolean call() { - return tryEvict(true); + return evict(true); } }, /*system pool*/ true); return false; } - if (map.isEmpty() && state.compareAndSet(EVICTING, EVICTED, 0, 0)) { + if (state.compareAndSet(EVICTING, EVICTED, 0, 0)) { if (log.isDebugEnabled()) log.debug("Evicted partition: " + this); @@ -575,11 +568,25 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>, return true; } + else { + assert false : "expected EVICTING state"; + } return false; } /** + * @param updateSeq Update sequence. + * @return {@code True} if entry has been transitioned to state EVICTED. + */ + boolean tryEvict(boolean updateSeq) { + if (!state.compareAndSet(RENTING, EVICTING, 0, 0) || state.getStamp() != 0 || groupReserved()) + return false; + + return evict(updateSeq); + } + + /** * Clears swap entries for evicted partition. */ private void clearSwap() {
