Apache9 commented on a change in pull request #3217:
URL: https://github.com/apache/hbase/pull/3217#discussion_r626212599



##########
File path: 
hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java
##########
@@ -610,13 +610,35 @@ private void roundRobinAssignment(BalancerClusterState 
cluster, List<RegionInfo>
     return returnMap;
   }
 
-  @Override
-  public abstract List<RegionPlan> balanceTable(TableName tableName,
-      Map<ServerName, List<RegionInfo>> loadOfOneTable);
+  /**
+   * Perform the major balance operation for table, all class implement of 
{@link LoadBalancer}
+   * should override this method
+   * @param tableName the table to be balanced
+   * @param loadOfOneTable region load of servers for the specific one table
+   * @return List of plans
+   */
+  protected abstract List<RegionPlan> balanceTable(TableName tableName,
+    Map<ServerName, List<RegionInfo>> loadOfOneTable);
 
+  /**
+   * Called before actually executing balanceCluster. The sub classes could 
override this method to
+   * do some initialization work.
+   */
+  protected void
+    preBalanceCluster(Map<TableName, Map<ServerName, List<RegionInfo>>> 
loadOfAllTable) {
+  }
+
+  /**
+   * Perform the major balance operation for cluster, will invoke {@link 
#balanceTable} to do actual
+   * balance.
+   * @param loadOfAllTable region load of servers for all table
+   * @return a list of regions to be moved, including source and destination, 
or null if cluster is
+   *         already balanced
+   */
   @Override
-  public List<RegionPlan>
-      balanceCluster(Map<TableName, Map<ServerName, List<RegionInfo>>> 
loadOfAllTable) {
+  public final synchronized List<RegionPlan>
+    balanceCluster(Map<TableName, Map<ServerName, List<RegionInfo>>> 
loadOfAllTable) {

Review comment:
       Added more comments for balanceCluster and balanceTable methods.




-- 
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:
us...@infra.apache.org


Reply via email to