Repository: ignite
Updated Branches:
  refs/heads/ignite-1093-2 9dd41d5f1 -> d4a6f5aa3


1093


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d4a6f5aa
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d4a6f5aa
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d4a6f5aa

Branch: refs/heads/ignite-1093-2
Commit: d4a6f5aa3d7757744008ef62b5a8562abe4c0e9e
Parents: 9dd41d5
Author: Anton Vinogradov <[email protected]>
Authored: Sun Oct 11 12:39:56 2015 +0300
Committer: Anton Vinogradov <[email protected]>
Committed: Sun Oct 11 12:39:56 2015 +0300

----------------------------------------------------------------------
 .../distributed/dht/GridDhtLocalPartition.java  | 64 ++++----------------
 .../distributed/dht/GridDhtPartitionState.java  |  5 +-
 .../dht/GridDhtPartitionTopologyImpl.java       |  3 +-
 .../distributed/dht/GridDhtTxPrepareFuture.java |  4 +-
 4 files changed, 14 insertions(+), 62 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/d4a6f5aa/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 3a5ef5c..6e6ccfd 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
@@ -60,7 +60,6 @@ import org.jsr166.LongAdder8;
 import static 
org.apache.ignite.IgniteSystemProperties.IGNITE_ATOMIC_CACHE_DELETE_HISTORY_SIZE;
 import static 
org.apache.ignite.events.EventType.EVT_CACHE_REBALANCE_OBJECT_UNLOADED;
 import static 
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState.EVICTED;
-import static 
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState.EVICTING;
 import static 
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState.MOVING;
 import static 
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState.OWNING;
 import static 
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState.RENTING;
@@ -69,9 +68,6 @@ import static 
org.apache.ignite.internal.processors.cache.distributed.dht.GridDh
  * Key partition.
  */
 public class GridDhtLocalPartition implements 
Comparable<GridDhtLocalPartition>, GridReservable {
-    /** Maximum entries to be cleared at eviction attempt at once. */
-    private final static long EVICTION_CLEAR_LIMIT = 1000;
-
     /** Maximum size for delete queue. */
     public static final int MAX_DELETE_QUEUE_SIZE = 
Integer.getInteger(IGNITE_ATOMIC_CACHE_DELETE_HISTORY_SIZE,
         200_000);
@@ -154,8 +150,7 @@ public class GridDhtLocalPartition implements 
Comparable<GridDhtLocalPartition>,
      * @return {@code false} If such reservation already added.
      */
     public boolean addReservation(GridDhtPartitionsReservation r) {
-        assert state.getReference() != EVICTED && state.getReference() != 
EVICTING :
-            "we can reserve only active partitions";
+        assert state.getReference() != EVICTED : "we can reserve only active 
partitions";
         assert state.getStamp() != 0 : "partition must be already reserved 
before adding group reservation";
 
         return reservations.addIfAbsent(r);
@@ -261,7 +256,7 @@ public class GridDhtLocalPartition implements 
Comparable<GridDhtLocalPartition>,
     void onAdded(GridDhtCacheEntry entry) {
         GridDhtPartitionState state = state();
 
-        if (state == EVICTED || state == EVICTING)
+        if (state == EVICTED)
             throw new GridDhtInvalidPartitionException(id, "Adding entry to 
invalid partition [part=" + id + ']');
 
         map.put(entry.key(), entry);
@@ -390,7 +385,7 @@ public class GridDhtLocalPartition implements 
Comparable<GridDhtLocalPartition>,
 
             GridDhtPartitionState s = state.getReference();
 
-            if (s == EVICTED || s == EVICTING)
+            if (s == EVICTED)
                 return false;
 
             if (state.compareAndSet(s, s, reservations, reservations + 1))
@@ -430,7 +425,7 @@ public class GridDhtLocalPartition implements 
Comparable<GridDhtLocalPartition>,
 
             GridDhtPartitionState s = state.getReference();
 
-            if (s == RENTING || s == EVICTING || s == EVICTED)
+            if (s == RENTING || s == EVICTED)
                 return false;
 
             if (s == OWNING)
@@ -460,7 +455,7 @@ public class GridDhtLocalPartition implements 
Comparable<GridDhtLocalPartition>,
 
             GridDhtPartitionState s = state.getReference();
 
-            if (s == RENTING || s == EVICTING || s == EVICTED)
+            if (s == RENTING || s == EVICTED)
                 return rent;
 
             if (state.compareAndSet(s, RENTING, reservations, reservations)) {
@@ -527,29 +522,14 @@ public class GridDhtLocalPartition implements 
Comparable<GridDhtLocalPartition>,
      * @param updateSeq Update sequence.
      * @return {@code True} if entry has been transitioned to state EVICTED.
      */
-    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 evict(true);
-                }
-            }, /*system pool*/ true);
-
+    boolean tryEvict(boolean updateSeq) {
+        if (state.getReference() != RENTING || state.getStamp() != 0 || 
groupReserved())
             return false;
-        }
 
-        if (!map.isEmpty()) {
-            cctx.closures().callLocalSafe(new GPC<Boolean>() {
-                @Override public Boolean call() {
-                    return evict(true);
-                }
-            }, /*system pool*/ true);
-
-            return false;
-        }
+        // Attempt to evict partition entries from cache.
+        clearAll();
 
-        if (state.compareAndSet(EVICTING, EVICTED, 0, 0)) {
+        if (map.isEmpty() && state.compareAndSet(RENTING, EVICTED, 0, 0)) {
             if (log.isDebugEnabled())
                 log.debug("Evicted partition: " + this);
 
@@ -570,23 +550,10 @@ public class GridDhtLocalPartition implements 
Comparable<GridDhtLocalPartition>,
             return true;
         }
 
-        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() {
@@ -636,10 +603,8 @@ public class GridDhtLocalPartition implements 
Comparable<GridDhtLocalPartition>,
 
     /**
      * Clears values for this partition.
-     * @param limit Clear limit.
-     * @return
      */
-    private boolean clearAll(long limit) {
+    private void clearAll() {
         GridCacheVersion clearVer = cctx.versions().next();
 
         boolean swap = cctx.isSwapOrOffheapEnabled();
@@ -665,13 +630,8 @@ public class GridDhtLocalPartition implements 
Comparable<GridDhtLocalPartition>,
                 it = F.concat(it, unswapIt);
         }
 
-        long cnt = 0;
-
         try {
             while (it.hasNext()) {
-                if (limit > 0 && cnt++ > limit)
-                    return false;
-
                 GridDhtCacheEntry cached = null;
 
                 try {
@@ -715,8 +675,6 @@ public class GridDhtLocalPartition implements 
Comparable<GridDhtLocalPartition>,
         finally {
             U.close(swapIt, log);
         }
-
-        return true;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/d4a6f5aa/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionState.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionState.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionState.java
index 9849c0a..7b49369 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionState.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionState.java
@@ -32,9 +32,6 @@ public enum GridDhtPartitionState {
     /** This node is neither primary or back up owner. */
     RENTING,
 
-    /** Partition eviction from cache in progress. */
-    EVICTING,
-
     /** Partition has been evicted from cache. */
     EVICTED;
 
@@ -53,6 +50,6 @@ public enum GridDhtPartitionState {
      * @return {@code True} if state is active or owning.
      */
     public boolean active() {
-        return this != EVICTED && this != EVICTING;
+        return this != EVICTED;
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/d4a6f5aa/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
index bbddbb5..a0c9c88 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
@@ -53,7 +53,6 @@ import org.jsr166.ConcurrentHashMap8;
 
 import static 
org.apache.ignite.events.EventType.EVT_CACHE_REBALANCE_PART_DATA_LOST;
 import static 
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState.EVICTED;
-import static 
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState.EVICTING;
 import static 
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState.MOVING;
 import static 
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState.OWNING;
 import static 
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState.RENTING;
@@ -170,7 +169,7 @@ class GridDhtPartitionTopologyImpl implements 
GridDhtPartitionTopology {
 
             GridDhtPartitionState state = p.state();
 
-            if (state == RENTING || state == EVICTING || state == EVICTED) {
+            if (state == RENTING || state == EVICTED) {
                 if (log.isDebugEnabled())
                     log.debug("Waiting for renting partition: " + p);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/d4a6f5aa/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
index 09ce270..761bbb0 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
@@ -1212,9 +1212,7 @@ public final class GridDhtTxPrepareFuture extends 
GridCompoundFuture<IgniteInter
                     GridDhtPartitionState state = 
entry.context().topology().partitionState(n.id(),
                         entry.cached().partition());
 
-                    if (state != GridDhtPartitionState.OWNING &&
-                            state != GridDhtPartitionState.EVICTING &&
-                            state != GridDhtPartitionState.EVICTED) {
+                    if (state != GridDhtPartitionState.OWNING && state != 
GridDhtPartitionState.EVICTED) {
                         CacheObject procVal = 
entry.entryProcessorCalculatedValue();
 
                         entry.op(procVal == null ? DELETE : UPDATE);

Reply via email to