nyl3532016 commented on a change in pull request #1324: HBASE-23949 refactor
loadBalancer implements for rsgroup balance by t…
URL: https://github.com/apache/hbase/pull/1324#discussion_r396869888
##########
File path:
hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupBasedLoadBalancer.java
##########
@@ -110,50 +108,46 @@ public void setMasterServices(MasterServices
masterServices) {
this.masterServices = masterServices;
}
+ /**
+ * Override to balance by RSGroup
+ * not invoke {@link #balanceTable(TableName, Map)}
+ */
@Override
- public List<RegionPlan> balanceCluster(TableName tableName, Map<ServerName,
List<RegionInfo>>
- clusterState) throws HBaseIOException {
- return balanceCluster(clusterState);
- }
-
- @Override
- public List<RegionPlan> balanceCluster(Map<ServerName, List<RegionInfo>>
clusterState)
- throws HBaseIOException {
+ public List<RegionPlan> balanceCluster(
+ Map<TableName, Map<ServerName, List<RegionInfo>>> loadOfAllTable) throws
IOException {
if (!isOnline()) {
throw new ConstraintException(RSGroupInfoManager.RSGROUP_TABLE_NAME +
" is not online, unable to perform balance");
}
-
- Map<ServerName,List<RegionInfo>> correctedState =
correctAssignments(clusterState);
- List<RegionPlan> regionPlans = new ArrayList<>();
-
- List<RegionInfo> misplacedRegions =
correctedState.get(LoadBalancer.BOGUS_SERVER_NAME);
- for (RegionInfo regionInfo : misplacedRegions) {
- ServerName serverName = findServerForRegion(clusterState, regionInfo);
- regionPlans.add(new RegionPlan(regionInfo, serverName, null));
- }
+ // Calculate correct assignments and a list of RegionPlan for mis-placed
regions
+ Pair<Map<TableName, Map<ServerName, List<RegionInfo>>>, List<RegionPlan>>
+ correctedStateAndRegionPlans = correctAssignments(loadOfAllTable);
+ Map<TableName, Map<ServerName, List<RegionInfo>>> correctedLoadOfAllTable =
+ correctedStateAndRegionPlans.getFirst();
+ List<RegionPlan> regionPlans = correctedStateAndRegionPlans.getSecond();
+ // Add RegionPlan
Review comment:
see TestRSGroupBasedLoadBalancer#testBalanceCluster , we add test for
rsgroup with bytable
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services