ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [03/15] incubator-ignite git commit: i-485 review
Date Tue, 21 Apr 2015 11:51:15 GMT
i-485 review


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

Branch: refs/heads/ignite-gg-9613
Commit: fef22b6eb646624008ef4d54e6e4d6a3e41b54c0
Parents: 0bd101c
Author: Yakov Zhdanov <yzhdanov@gridgain.com>
Authored: Fri Apr 17 19:06:09 2015 +0300
Committer: Yakov Zhdanov <yzhdanov@gridgain.com>
Committed: Fri Apr 17 19:06:09 2015 +0300

----------------------------------------------------------------------
 .../cache/eviction/fifo/FifoEvictionPolicy.java |  5 ++-
 .../igfs/IgfsPerBlockLruEvictionPolicy.java     |  3 +-
 .../cache/eviction/lru/LruEvictionPolicy.java   |  5 ++-
 .../eviction/sorted/SortedEvictionPolicy.java   | 35 ++++++--------------
 4 files changed, 17 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fef22b6e/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/FifoEvictionPolicy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/FifoEvictionPolicy.java
b/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/FifoEvictionPolicy.java
index ca3cc1b..375e955 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/FifoEvictionPolicy.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/eviction/fifo/FifoEvictionPolicy.java
@@ -203,11 +203,10 @@ public class FifoEvictionPolicy<K, V> implements EvictionPolicy<K,
V>, FifoEvict
                 if (entry == null)
                     break;
 
-                if (!entry.evict()) {
-                    entry.removeMeta();
+                Node<EvictableEntry<K, V>> meta = entry.removeMeta();
 
+                if (meta != null && !entry.evict())
                     touch(entry);
-                }
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fef22b6e/modules/core/src/main/java/org/apache/ignite/cache/eviction/igfs/IgfsPerBlockLruEvictionPolicy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/eviction/igfs/IgfsPerBlockLruEvictionPolicy.java
b/modules/core/src/main/java/org/apache/ignite/cache/eviction/igfs/IgfsPerBlockLruEvictionPolicy.java
index ff4aeea..f4d95df 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/eviction/igfs/IgfsPerBlockLruEvictionPolicy.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/eviction/igfs/IgfsPerBlockLruEvictionPolicy.java
@@ -34,7 +34,8 @@ import java.util.regex.*;
 /**
  * IGFS eviction policy which evicts particular blocks.
  */
-public class IgfsPerBlockLruEvictionPolicy implements EvictionPolicy<IgfsBlockKey, byte[]>,
IgfsPerBlockLruEvictionPolicyMXBean, Externalizable {
+public class IgfsPerBlockLruEvictionPolicy implements EvictionPolicy<IgfsBlockKey, byte[]>,
+    IgfsPerBlockLruEvictionPolicyMXBean, Externalizable {
     /** */
     private static final long serialVersionUID = 0L;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fef22b6e/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/LruEvictionPolicy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/LruEvictionPolicy.java
b/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/LruEvictionPolicy.java
index 2ba3c41..309d577 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/LruEvictionPolicy.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/eviction/lru/LruEvictionPolicy.java
@@ -173,11 +173,10 @@ public class LruEvictionPolicy<K, V> implements EvictionPolicy<K,
V>, LruEvictio
             if (entry == null)
                 break;
 
-            if (!entry.evict()) {
-                entry.removeMeta();
+            Node<EvictableEntry<K, V>> meta = entry.removeMeta();
 
+            if (meta != null && !entry.evict())
                 touch(entry);
-            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fef22b6e/modules/core/src/main/java/org/apache/ignite/cache/eviction/sorted/SortedEvictionPolicy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/eviction/sorted/SortedEvictionPolicy.java
b/modules/core/src/main/java/org/apache/ignite/cache/eviction/sorted/SortedEvictionPolicy.java
index b3f3119..0e2b610 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/eviction/sorted/SortedEvictionPolicy.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/eviction/sorted/SortedEvictionPolicy.java
@@ -48,7 +48,7 @@ public class SortedEvictionPolicy<K, V> implements EvictionPolicy<K,
V>, SortedE
     private final AtomicLong orderCnt = new AtomicLong();
 
     /** Backed sorted set. */
-    private final GridConcurrentSkipListSetEx<Holder<K, V>> set;
+    private final GridConcurrentSkipListSetEx<K, V> set;
 
     /**
      * Constructs sorted eviction policy with all defaults.
@@ -203,11 +203,8 @@ public class SortedEvictionPolicy<K, V> implements EvictionPolicy<K,
V>, SortedE
 
                 EvictableEntry<K, V> entry = h.entry;
 
-                if (h.order > 0 && !entry.evict()) {
-                    entry.removeMeta();
-
+                if (h.order > 0 && entry.removeMeta(h) && !entry.evict())
                     touch(entry);
-                }
             }
         }
     }
@@ -319,7 +316,7 @@ public class SortedEvictionPolicy<K, V> implements EvictionPolicy<K,
V>, SortedE
             EvictableEntry<K, V> e1 = h1.entry;
             EvictableEntry<K, V> e2 = h2.entry;
 
-            int cmp = ((Comparable<K>) e1.getKey()).compareTo(e2.getKey());
+            int cmp = ((Comparable<K>)e1.getKey()).compareTo(e2.getKey());
 
             return cmp == 0 ? Long.compare(abs(h1.order), abs(h2.order)) : cmp;
         }
@@ -334,7 +331,7 @@ public class SortedEvictionPolicy<K, V> implements EvictionPolicy<K,
V>, SortedE
      *     <li>{@code #clone()}</li>
      * <ul/>
      */
-    private static class GridConcurrentSkipListSetEx<E> extends GridConcurrentSkipListSet<E>
{
+    private static class GridConcurrentSkipListSetEx<K, V> extends GridConcurrentSkipListSet<Holder<K,
V>> {
         /** */
         private static final long serialVersionUID = 0L;
 
@@ -344,7 +341,7 @@ public class SortedEvictionPolicy<K, V> implements EvictionPolicy<K,
V>, SortedE
         /**
          * @param comp Comparator.
          */
-        public GridConcurrentSkipListSetEx(Comparator<? super E> comp) {
+        public GridConcurrentSkipListSetEx(Comparator<? super Holder<K, V>> comp)
{
             super(comp);
         }
 
@@ -356,11 +353,12 @@ public class SortedEvictionPolicy<K, V> implements EvictionPolicy<K,
V>, SortedE
         }
 
         /** {@inheritDoc} */
-        @Override public boolean add(E e) {
+        @Override public boolean add(Holder<K, V> e) {
             boolean res = super.add(e);
 
-            if (res)
-                size.increment();
+            assert res;
+
+            size.increment();
 
             return res;
         }
@@ -376,24 +374,13 @@ public class SortedEvictionPolicy<K, V> implements EvictionPolicy<K,
V>, SortedE
         }
 
         /** {@inheritDoc} */
-        @Nullable @Override public E pollFirst() {
-            E e = super.pollFirst();
+        @Nullable @Override public Holder<K, V> pollFirst() {
+            Holder<K, V> e = super.pollFirst();
 
             if (e != null)
                 size.decrement();
 
             return e;
         }
-
-        /** {@inheritDoc} */
-        @Override public GridConcurrentSkipListSetEx<E> clone() {
-            GridConcurrentSkipListSetEx<E> clone = (GridConcurrentSkipListSetEx<E>)super.clone();
-
-            clone.size = new LongAdder8();
-
-            clone.size.add(size.intValue());
-
-            return clone;
-        }
     }
 }


Mime
View raw message