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:49:36 UTC
[hbase] branch branch-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
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2 by this push:
new baeeddb HBASE-22009 Improve RSGroupInfoManagerImpl#getDefaultServers()
baeeddb is described below
commit baeeddbb0a5a5f356760a9e3874fd2de23598b66
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 203052c..402e369 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
@@ -596,17 +596,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);
}
}