nyl3532016 commented on a change in pull request #1279: HBASE-23949 refactor 
loadBalancer implements for rsgroup balance by t…
URL: https://github.com/apache/hbase/pull/1279#discussion_r395982033
 
 

 ##########
 File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupBasedLoadBalancer.java
 ##########
 @@ -111,51 +109,45 @@ 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 IOException {
-    return balanceCluster(clusterState);
-  }
-
-  @Override
-  public List<RegionPlan> balanceCluster(Map<ServerName, List<RegionInfo>> 
clusterState)
-      throws IOException {
+  public List<RegionPlan> balanceCluster(
+      Map<TableName, Map<ServerName, List<RegionInfo>>> loadOfAllTable) throws 
IOException {
     if (!isOnline()) {
       throw new ConstraintException(
           RSGroupInfoManager.class.getSimpleName() + " is not online, unable 
to perform balance");
     }
 
     // Calculate correct assignments and a list of RegionPlan for mis-placed 
regions
-    Pair<Map<ServerName,List<RegionInfo>>, List<RegionPlan>> 
correctedStateAndRegionPlans =
-        correctAssignments(clusterState);
-    Map<ServerName,List<RegionInfo>> correctedState = 
correctedStateAndRegionPlans.getFirst();
+    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();
-
+    RSGroupInfo defaultInfo = 
rsGroupInfoManager.getRSGroup(RSGroupInfo.DEFAULT_GROUP);
     // Add RegionPlan
     // for the regions which have been placed according to the region server 
group assignment
     // into the movement list
     try {
-      // Record which region servers have been processed,so as to skip them 
after processed
-      HashSet<ServerName> processedServers = new HashSet<>();
-
       // For each rsgroup
       for (RSGroupInfo rsgroup : rsGroupInfoManager.listRSGroups()) {
-        Map<ServerName, List<RegionInfo>> groupClusterState = new HashMap<>();
-        Map<TableName, Map<ServerName, List<RegionInfo>>> groupClusterLoad = 
new HashMap<>();
-        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<RegionInfo> regionsOnServer = correctedState.get(server);
-            groupClusterState.put(server, regionsOnServer);
-
-            processedServers.add(server);
+        Map<TableName, Map<ServerName, List<RegionInfo>>> loadOfTablesInGroup =
+            new HashMap<>();
+        for (Map.Entry<TableName, Map<ServerName, List<RegionInfo>>> entry: 
correctedLoadOfAllTable.entrySet()) {
+          TableName tableName = entry.getKey();
+          RSGroupInfo targetRSGInfo = RSGroupUtil
+              .getRSGroupInfo(masterServices, rsGroupInfoManager, 
tableName).orElse(defaultInfo);
+          if (targetRSGInfo.getName().equals(rsgroup.getName())) {
+            loadOfTablesInGroup.put(tableName, entry.getValue());
           }
         }
-
-        groupClusterLoad.put(HConstants.ENSEMBLE_TABLE_NAME, 
groupClusterState);
-        this.internalBalancer.setClusterLoad(groupClusterLoad);
-        List<RegionPlan> groupPlans = this.internalBalancer
-            .balanceCluster(groupClusterState);
+        List<RegionPlan> groupPlans = null;
+        if (!loadOfTablesInGroup.isEmpty()) {
 
 Review comment:
   well , I add some log

----------------------------------------------------------------
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

Reply via email to