saurabhd336 commented on code in PR #10255:
URL: https://github.com/apache/pinot/pull/10255#discussion_r1126078642


##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/rebalance/TableRebalancer.java:
##########
@@ -524,31 +525,73 @@ private List<Tier> getSortedTiers(TableConfig 
tableConfig) {
   }
 
   @Nullable
-  private Map<String, InstancePartitions> 
getTierToInstancePartitionsMap(String tableNameWithType,
-      @Nullable List<Tier> sortedTiers) {
+  private Map<String, InstancePartitions> 
getTierToInstancePartitionsMap(TableConfig tableConfig,
+      @Nullable List<Tier> sortedTiers, boolean reassignInstances, boolean 
bootstrap, boolean dryRun) {
     if (sortedTiers == null) {
       return null;
     }
     Map<String, InstancePartitions> tierToInstancePartitionsMap = new 
HashMap<>();
     for (Tier tier : sortedTiers) {
       LOGGER.info("Fetching/computing instance partitions for tier: {} of 
table: {}", tier.getName(),
-          tableNameWithType);
-      tierToInstancePartitionsMap.put(tier.getName(), 
getInstancePartitionsForTier(tier, tableNameWithType));
+          tableConfig.getTableName());
+      tierToInstancePartitionsMap.put(tier.getName(),
+          getInstancePartitionsForTier(tableConfig, tier, reassignInstances, 
bootstrap, dryRun));
     }
     return tierToInstancePartitionsMap;
   }
 
   /**
-   * Creates a default instance assignment for the tier.
-   * TODO: We only support default server-tag based assignment currently.
-   *  In next iteration, we will add InstanceAssignmentConfig to the 
TierConfig and also support persisting of the
-   *  InstancePartitions to zk.
-   *  Then we'll be able to support replica group assignment while creating 
InstancePartitions for tiers
+   * Computes the instance partitions for the given tier. If table's 
instanceAssignmentConfigMap has an entry for the
+   * tier, it's used to calculate the instance partitions. Else default 
instance partitions are returned
    */
-  private InstancePartitions getInstancePartitionsForTier(Tier tier, String 
tableNameWithType) {
+  private InstancePartitions getInstancePartitionsForTier(TableConfig 
tableConfig, Tier tier, boolean reassignInstances,
+      boolean bootstrap, boolean dryRun) {
     PinotServerTierStorage storage = (PinotServerTierStorage) 
tier.getStorage();
-    return 
InstancePartitionsUtils.computeDefaultInstancePartitionsForTag(_helixManager, 
tableNameWithType,
-        tier.getName(), storage.getServerTag());
+    InstancePartitions defaultInstancePartitions =
+        
InstancePartitionsUtils.computeDefaultInstancePartitionsForTag(_helixManager, 
tableConfig.getTableName(),
+            tier.getName(), storage.getServerTag());
+
+    if (tableConfig.getInstanceAssignmentConfigMap() == null || 
!tableConfig.getInstanceAssignmentConfigMap()
+        .containsKey(tier.getName())) {
+      LOGGER.info("Skipping fetching/computing instance partitions for tier {} 
for table: {}", tier.getName(),
+          tableConfig.getTableName());
+      if (!dryRun) {
+        String instancePartitionsName =
+            
InstancePartitionsUtils.getInstancePartitonNameForTier(tableConfig.getTableName(),
 tier.getName());
+        LOGGER.info("Removing instance partitions: {} from ZK if it exists", 
instancePartitionsName);
+        
InstancePartitionsUtils.removeInstancePartitions(_helixManager.getHelixPropertyStore(),
 instancePartitionsName);
+      }
+      return defaultInstancePartitions;
+    }
+
+    String tableNameWithType = tableConfig.getTableName();
+    String instancePartitionName =

Review Comment:
   Ack



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