You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by mb...@apache.org on 2016/07/28 18:20:39 UTC

[2/2] hbase git commit: HBASE-16275 Change ServerManager#onlineServers from ConcurrentHashMap to ConcurrentSkipListMap (Huaxiang Sun)

HBASE-16275 Change ServerManager#onlineServers from ConcurrentHashMap to ConcurrentSkipListMap (Huaxiang Sun)


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

Branch: refs/heads/branch-1
Commit: 7983d2f45b073d6e36f0623e142c83e7500f0774
Parents: 968e464
Author: Matteo Bertozzi <ma...@cloudera.com>
Authored: Thu Jul 28 11:13:58 2016 -0700
Committer: Matteo Bertozzi <ma...@cloudera.com>
Committed: Thu Jul 28 11:19:06 2016 -0700

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/master/ServerManager.java | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/7983d2f4/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java
index d30157d..4ee349a 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java
@@ -137,8 +137,8 @@ public class ServerManager {
     new ConcurrentSkipListMap<byte[], ConcurrentNavigableMap<byte[], Long>>(Bytes.BYTES_COMPARATOR);
 
   /** Map of registered servers to their current load */
-  private final ConcurrentHashMap<ServerName, ServerLoad> onlineServers =
-    new ConcurrentHashMap<ServerName, ServerLoad>();
+  private final ConcurrentNavigableMap<ServerName, ServerLoad> onlineServers =
+    new ConcurrentSkipListMap<ServerName, ServerLoad>();
 
   /**
    * Map of admin interfaces per registered regionserver; these interfaces we use to control
@@ -449,8 +449,14 @@ public class ServerManager {
    */
   private ServerName findServerWithSameHostnamePortWithLock(
       final ServerName serverName) {
-    for (ServerName sn: this.onlineServers.keySet()) {
-      if (ServerName.isSameHostnameAndPort(serverName, sn)) return sn;
+    ServerName end = ServerName.valueOf(serverName.getHostname(), serverName.getPort(),
+        Long.MAX_VALUE);
+
+    ServerName r = onlineServers.lowerKey(end);
+    if (r != null) {
+      if (ServerName.isSameHostnameAndPort(r, serverName)) {
+        return r;
+      }
     }
     return null;
   }