ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [36/38] ignite git commit: Simplified GridDiscoveryManager.resolveDiscoCache (with previous code observed on TC NoSuchElementException from Collections.min(discoCacheHist.entrySet()).
Date Thu, 26 Nov 2015 10:51:33 GMT
Simplified GridDiscoveryManager.resolveDiscoCache (with previous code observed on TC NoSuchElementException
from Collections.min(discoCacheHist.entrySet()).


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

Branch: refs/heads/ignite-1537
Commit: c3eeb6dc2ded5a22d80078b031a305b8c9f06805
Parents: e8a14da
Author: sboikov <sboikov@gridgain.com>
Authored: Thu Nov 26 13:30:36 2015 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Thu Nov 26 13:30:36 2015 +0300

----------------------------------------------------------------------
 .../managers/discovery/GridDiscoveryManager.java | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/c3eeb6dc/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
index 4880338..92d66d7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
@@ -43,6 +43,7 @@ import java.util.UUID;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ConcurrentNavigableMap;
 import java.util.concurrent.ConcurrentSkipListSet;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.CountDownLatch;
@@ -175,14 +176,6 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi>
{
         }
     };
 
-    /** Disco history entries comparator. */
-    private static final Comparator<Map.Entry<AffinityTopologyVersion, DiscoCache>>
histCmp =
-        new Comparator<Map.Entry<AffinityTopologyVersion, DiscoCache>>() {
-            @Override public int compare(Map.Entry<AffinityTopologyVersion, DiscoCache>
o1, Map.Entry<AffinityTopologyVersion, DiscoCache> o2) {
-                return o1.getKey().compareTo(o2.getKey());
-            }
-        };
-
     /** Discovery event worker. */
     private final DiscoveryWorker discoWrk = new DiscoveryWorker();
 
@@ -208,7 +201,7 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi>
{
     private final AtomicBoolean lastSegChkRes = new AtomicBoolean(true);
 
     /** Topology cache history. */
-    private final Map<AffinityTopologyVersion, DiscoCache> discoCacheHist =
+    private final ConcurrentNavigableMap<AffinityTopologyVersion, DiscoCache> discoCacheHist
=
         new GridBoundedConcurrentOrderedMap<>(DISCOVERY_HISTORY_SIZE);
 
     /** Topology snapshots history. */
@@ -1638,10 +1631,12 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi>
{
 
         if (cache == null) {
             // Find the eldest acceptable discovery cache.
-            Map.Entry<AffinityTopologyVersion, DiscoCache> eldest = Collections.min(discoCacheHist.entrySet(),
histCmp);
+            Map.Entry<AffinityTopologyVersion, DiscoCache> eldest = discoCacheHist.firstEntry();
 
-            if (topVer.compareTo(eldest.getKey()) < 0)
-                cache = eldest.getValue();
+            if (eldest != null) {
+                if (topVer.compareTo(eldest.getKey()) < 0)
+                    cache = eldest.getValue();
+            }
         }
 
         if (cache == null) {


Mime
View raw message