HBASE-20186 Improve RSGroupBasedLoadBalancer#balanceCluster() to be more efficient when calculating cluster state for each rsgroup
Signed-off-by: tedyu <yuzhihong@gmail.com>
This commit is contained in:
parent
3f1c86786c
commit
03e7b78260
|
@ -127,17 +127,23 @@ public class RSGroupBasedLoadBalancer implements RSGroupableBalancer {
|
||||||
regionPlans.add(new RegionPlan(regionInfo, serverName, null));
|
regionPlans.add(new RegionPlan(regionInfo, serverName, null));
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
List<RSGroupInfo> rsgi = rsGroupInfoManager.listRSGroups();
|
// Record which region servers have been processed,so as to skip them after processed
|
||||||
for (RSGroupInfo info: rsgi) {
|
HashSet<ServerName> processedServers = new HashSet<>();
|
||||||
|
|
||||||
|
// For each rsgroup
|
||||||
|
for (RSGroupInfo rsgroup : rsGroupInfoManager.listRSGroups()) {
|
||||||
Map<ServerName, List<RegionInfo>> groupClusterState = new HashMap<>();
|
Map<ServerName, List<RegionInfo>> groupClusterState = new HashMap<>();
|
||||||
Map<TableName, Map<ServerName, List<RegionInfo>>> groupClusterLoad = new HashMap<>();
|
Map<TableName, Map<ServerName, List<RegionInfo>>> groupClusterLoad = new HashMap<>();
|
||||||
for (Address sName : info.getServers()) {
|
for (ServerName server : clusterState.keySet()) { // for each region server
|
||||||
for(ServerName curr: clusterState.keySet()) {
|
if (!processedServers.contains(server) // server is not processed yet
|
||||||
if(curr.getAddress().equals(sName)) {
|
&& rsgroup.containsServer(server.getAddress())) { // server belongs to this rsgroup
|
||||||
groupClusterState.put(curr, correctedState.get(curr));
|
List<RegionInfo> regionsOnServer = correctedState.get(server);
|
||||||
}
|
groupClusterState.put(server, regionsOnServer);
|
||||||
|
|
||||||
|
processedServers.add(server);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
groupClusterLoad.put(HConstants.ENSEMBLE_TABLE_NAME, groupClusterState);
|
groupClusterLoad.put(HConstants.ENSEMBLE_TABLE_NAME, groupClusterState);
|
||||||
this.internalBalancer.setClusterLoad(groupClusterLoad);
|
this.internalBalancer.setClusterLoad(groupClusterLoad);
|
||||||
List<RegionPlan> groupPlans = this.internalBalancer
|
List<RegionPlan> groupPlans = this.internalBalancer
|
||||||
|
|
Loading…
Reference in New Issue