diff --git a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupBasedLoadBalancer.java b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupBasedLoadBalancer.java index 392cbab5ce8..3182a61a16c 100644 --- a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupBasedLoadBalancer.java +++ b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupBasedLoadBalancer.java @@ -127,17 +127,23 @@ public class RSGroupBasedLoadBalancer implements RSGroupableBalancer { regionPlans.add(new RegionPlan(regionInfo, serverName, null)); } try { - List rsgi = rsGroupInfoManager.listRSGroups(); - for (RSGroupInfo info: rsgi) { + // Record which region servers have been processed,so as to skip them after processed + HashSet processedServers = new HashSet<>(); + + // For each rsgroup + for (RSGroupInfo rsgroup : rsGroupInfoManager.listRSGroups()) { Map> groupClusterState = new HashMap<>(); Map>> groupClusterLoad = new HashMap<>(); - for (Address sName : info.getServers()) { - for(ServerName curr: clusterState.keySet()) { - if(curr.getAddress().equals(sName)) { - groupClusterState.put(curr, correctedState.get(curr)); - } + for (ServerName server : clusterState.keySet()) { // for each region server + if (!processedServers.contains(server) // server is not processed yet + && rsgroup.containsServer(server.getAddress())) { // server belongs to this rsgroup + List regionsOnServer = correctedState.get(server); + groupClusterState.put(server, regionsOnServer); + + processedServers.add(server); } } + groupClusterLoad.put(HConstants.ENSEMBLE_TABLE_NAME, groupClusterState); this.internalBalancer.setClusterLoad(groupClusterLoad); List groupPlans = this.internalBalancer