You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2020/01/19 23:48:19 UTC

[GitHub] [incubator-pinot] mcvsubbu commented on a change in pull request #4990: Enhance TableRebalancer to be able to rebalance table under any condition

mcvsubbu commented on a change in pull request #4990: Enhance TableRebalancer to be able to rebalance table under any condition
URL: https://github.com/apache/incubator-pinot/pull/4990#discussion_r368332133
 
 

 ##########
 File path: pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/rebalance/TableRebalancer.java
 ##########
 @@ -175,67 +166,127 @@ public RebalanceResult rebalance(TableConfig tableConfig, Configuration rebalanc
     if (currentAssignment.equals(targetAssignment)) {
       LOGGER.info("Table: {} is already balanced", tableNameWithType);
       if (reassignInstances) {
-        return new RebalanceResult(RebalanceResult.Status.DONE, "Instance reassigned, table is already balanced",
-            instancePartitionsMap, targetAssignment);
+        if (dryRun) {
+          return new RebalanceResult(RebalanceResult.Status.DONE,
+              "Instance reassigned in dry-run mode, table is already balanced", instancePartitionsMap,
+              targetAssignment);
+        } else {
+          return new RebalanceResult(RebalanceResult.Status.DONE, "Instance reassigned, table is already balanced",
+              instancePartitionsMap, targetAssignment);
+        }
       } else {
         return new RebalanceResult(RebalanceResult.Status.NO_OP, "Table is already balanced", instancePartitionsMap,
             targetAssignment);
       }
     }
 
     if (dryRun) {
-      LOGGER.info("Rebalance table: {} in dry-run mode, returning the target assignment", tableNameWithType);
+      LOGGER.info("Rebalancing table: {} in dry-run mode, returning the target assignment", tableNameWithType);
       return new RebalanceResult(RebalanceResult.Status.DONE, "Dry-run mode", instancePartitionsMap, targetAssignment);
     }
 
-    int minAvailableReplicas;
-    if (rebalanceConfig.getBoolean(RebalanceConfigConstants.DOWNTIME, RebalanceConfigConstants.DEFAULT_DOWNTIME)) {
-      minAvailableReplicas = 0;
+    if (!downtime && !currentIdealState.isEnabled()) {
+      LOGGER.warn("Table: {} is disabled, rebalancing it with downtime", tableNameWithType);
+      downtime = true;
+    }
+
+    if (downtime) {
       LOGGER.info("Rebalancing table: {} with downtime", tableNameWithType);
-    } else {
-      minAvailableReplicas = rebalanceConfig.getInt(RebalanceConfigConstants.MIN_REPLICAS_TO_KEEP_UP_FOR_NO_DOWNTIME,
-          RebalanceConfigConstants.DEFAULT_MIN_REPLICAS_TO_KEEP_UP_FOR_NO_DOWNTIME);
-      int numCurrentReplicas = currentAssignment.values().iterator().next().size();
-      int numTargetReplicas = targetAssignment.values().iterator().next().size();
-      // Use the smaller one to determine the min available replicas
-      int numReplicas = Math.min(numCurrentReplicas, numTargetReplicas);
-      if (minAvailableReplicas > 0) {
-        if (minAvailableReplicas >= numReplicas) {
-          LOGGER.warn(
-              "Illegal config for min available replicas: {} for table: {}, must be less than number of replicas (current: {}, target: {})",
-              minAvailableReplicas, tableNameWithType, numCurrentReplicas, numTargetReplicas);
-          return new RebalanceResult(RebalanceResult.Status.FAILED, "Illegal min available replicas config",
+
+      while (true) {
 
 Review comment:
   Is is useful to extract this part into a method (provided it has reasonable number of arguments. Similarly the else part.

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org