You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by xu...@apache.org on 2019/03/18 17:52:43 UTC

[hbase] branch branch-2.2 updated: HBASE-22009 Improve RSGroupInfoManagerImpl#getDefaultServers()

This is an automated email from the ASF dual-hosted git repository.

xucang pushed a commit to branch branch-2.2
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2.2 by this push:
     new 845cc08  HBASE-22009 Improve RSGroupInfoManagerImpl#getDefaultServers()
845cc08 is described below

commit 845cc08e51874718913cfb2fd560a44087b86a8a
Author: Xiang Li <li...@freewheel.tv>
AuthorDate: Thu Mar 7 16:20:18 2019 +0000

    HBASE-22009 Improve RSGroupInfoManagerImpl#getDefaultServers()
    
    Signed-off-by: Xu Cang <xu...@apache.org>
---
 .../hadoop/hbase/rsgroup/RSGroupInfoManagerImpl.java   | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfoManagerImpl.java b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfoManagerImpl.java
index 275b84f..72f268f 100644
--- a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfoManagerImpl.java
+++ b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfoManagerImpl.java
@@ -586,17 +586,19 @@ final class RSGroupInfoManagerImpl implements RSGroupInfoManager {
 
   // Called by ServerEventsListenerThread. Presume it has lock on this manager when it runs.
   private SortedSet<Address> getDefaultServers() throws IOException {
+    // Build a list of servers in other groups than default group, from rsGroupMap
+    Set<Address> serversInOtherGroup = new HashSet<>();
+    for (RSGroupInfo group : listRSGroups() /* get from rsGroupMap */) {
+      if (!RSGroupInfo.DEFAULT_GROUP.equals(group.getName())) { // not default group
+        serversInOtherGroup.addAll(group.getServers());
+      }
+    }
+
+    // Get all online servers from Zookeeper and find out servers in default group
     SortedSet<Address> defaultServers = Sets.newTreeSet();
     for (ServerName serverName : getOnlineRS()) {
       Address server = Address.fromParts(serverName.getHostname(), serverName.getPort());
-      boolean found = false;
-      for (RSGroupInfo rsgi : listRSGroups()) {
-        if (!RSGroupInfo.DEFAULT_GROUP.equals(rsgi.getName()) && rsgi.containsServer(server)) {
-          found = true;
-          break;
-        }
-      }
-      if (!found) {
+      if (!serversInOtherGroup.contains(server)) { // not in other groups
         defaultServers.add(server);
       }
     }