Jackie-Jiang commented on code in PR #11073:
URL: https://github.com/apache/pinot/pull/11073#discussion_r1261580052


##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/rebalance/TableRebalancer.java:
##########
@@ -226,8 +226,12 @@ public RebalanceResult rebalance(TableConfig tableConfig, 
Configuration rebalanc
 
     // Calculate instance partitions map
     Map<InstancePartitionsType, InstancePartitions> instancePartitionsMap;
+    Boolean instancePartitionsUnchanged;

Review Comment:
   (minor)
   ```suggestion
       boolean instancePartitionsUnchanged;
   ```



##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/rebalance/TableRebalancer.java:
##########
@@ -480,22 +483,32 @@ public RebalanceResult rebalance(TableConfig tableConfig, 
Configuration rebalanc
     }
   }
 
-  private Map<InstancePartitionsType, InstancePartitions> 
getInstancePartitionsMap(TableConfig tableConfig,
-      boolean reassignInstances, boolean bootstrap, boolean dryRun) {
+  /**
+   * Gets the instance partitions for instance partition types and also 
returns a boolean for whether they are unchanged
+   */
+  private Pair<Map<InstancePartitionsType, InstancePartitions>, Boolean> 
getInstancePartitionsMap(

Review Comment:
   (Optional) Might be more readable if we pass in a `MutableBoolean`



##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/rebalance/TableRebalancer.java:
##########
@@ -531,7 +547,7 @@ private InstancePartitions 
getInstancePartitions(TableConfig tableConfig,
             
InstancePartitionsUtils.persistInstancePartitions(_helixManager.getHelixPropertyStore(),
                 instancePartitions);
           }
-          return instancePartitions;
+          return Pair.of(instancePartitions, true);

Review Comment:
   We want to check if it is the same as existing instance partitions. If so, 
we can also skip the persisting step



##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/rebalance/TableRebalancer.java:
##########
@@ -237,9 +241,13 @@ public RebalanceResult rebalance(TableConfig tableConfig, 
Configuration rebalanc
 
     // Calculate instance partitions for tiers if configured
     List<Tier> sortedTiers = getSortedTiers(tableConfig);
-    Map<String, InstancePartitions> tierToInstancePartitionsMap =
+
+    Pair<Map<String, InstancePartitions>, Boolean> 
tierToInstancePartitionsMapAndUnchanged =
         getTierToInstancePartitionsMap(tableConfig, sortedTiers, 
reassignInstances, bootstrap, dryRun);
 
+    Map<String, InstancePartitions> tierToInstancePartitionsMap = 
tierToInstancePartitionsMapAndUnchanged.getLeft();
+    Boolean tierInstancePartitionsUnchanged = 
tierToInstancePartitionsMapAndUnchanged.getRight();

Review Comment:
   (minor)
   ```suggestion
       boolean tierInstancePartitionsUnchanged = 
tierToInstancePartitionsMapAndUnchanged.getRight();
   ```



##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/rebalance/TableRebalancer.java:
##########
@@ -548,12 +564,12 @@ private InstancePartitions 
getInstancePartitions(TableConfig tableConfig,
           LOGGER.info("Persisting instance partitions: {} to ZK", 
instancePartitions);
           
InstancePartitionsUtils.persistInstancePartitions(_helixManager.getHelixPropertyStore(),
 instancePartitions);
         }
-        return instancePartitions;
+        return Pair.of(instancePartitions, 
instancePartitions.equals(existingInstancePartitions));

Review Comment:
   We can skip the persisting step when they match



##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/rebalance/TableRebalancer.java:
##########
@@ -256,22 +264,15 @@ public RebalanceResult rebalance(TableConfig tableConfig, 
Configuration rebalanc
           tierToInstancePartitionsMap, null);
     }
 
-    if (currentAssignment.equals(targetAssignment)) {
+    boolean segmentAssignmentUnchanged = 
currentAssignment.equals(targetAssignment);
+    LOGGER.info("For rebalanceId: {},  segmentAssignmentUnchanged: {}, "
+            + "tierInstancePartitionsUnchanged: {}, 
instancePartitionsUnchanged: {}",
+        rebalanceJobId, segmentAssignmentUnchanged, 
tierInstancePartitionsUnchanged, instancePartitionsUnchanged);
+
+    if (segmentAssignmentUnchanged && tierInstancePartitionsUnchanged && 
instancePartitionsUnchanged) {

Review Comment:
   We want to follow the existing logic, and always terminate when segment 
assignment is not changed:
   ```
   if (segmentAssignmentUnchanged) {
     if (instancePartitionsUnchanged && tierInstancePartitionsUnchanged) {
       // NO_OP
       ...
     } else {
       // DONE
       if (dryRun) {
         ...
       } else {
         ...
       }
     }
   }
   ```



##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/rebalance/TableRebalancer.java:
##########
@@ -569,7 +585,7 @@ private InstancePartitions 
getInstancePartitions(TableConfig tableConfig,
         LOGGER.info("Removing instance partitions: {} from ZK if it exists", 
instancePartitionsName);
         
InstancePartitionsUtils.removeInstancePartitions(_helixManager.getHelixPropertyStore(),
 instancePartitionsName);
       }
-      return instancePartitions;
+      return Pair.of(instancePartitions, true);

Review Comment:
   Here we want to check if there is existing instance partitions, and return 
false if there is no existing instance partitions



##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/rebalance/TableRebalancer.java:
##########
@@ -256,22 +264,15 @@ public RebalanceResult rebalance(TableConfig tableConfig, 
Configuration rebalanc
           tierToInstancePartitionsMap, null);
     }
 
-    if (currentAssignment.equals(targetAssignment)) {
+    boolean segmentAssignmentUnchanged = 
currentAssignment.equals(targetAssignment);
+    LOGGER.info("For rebalanceId: {},  segmentAssignmentUnchanged: {}, "

Review Comment:
   Let's include the table name, and follow the sequence of 
`instancePartitionsUnchanged`, `tierInstancePartitionsUnchanged`, 
`segmentAssignmentUnchanged`



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

To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to