Jackie-Jiang commented on code in PR #13951:
URL: https://github.com/apache/pinot/pull/13951#discussion_r1951279865
##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableRestletResource.java:
##########
@@ -1284,4 +1291,59 @@ private void handleLegacySchemaConfig(TableConfig
tableConfig, HttpHeaders httpH
validationConfig.setSchemaName(DatabaseUtils.translateTableName(validationConfig.getSchemaName(),
httpHeaders));
}
}
+
+ /*
+ For the given table config, calculates a target assignment, if possible.
Otherwise, throws an exception
+ */
+ private void validateInstanceAssignmentPossible(TableConfig tableConfig) {
+
+ String tableNameWithType = tableConfig.getTableName();
+
+ TableRebalancer tableRebalancer = new
TableRebalancer(_pinotHelixResourceManager.getHelixZkManager());
+
+ RebalanceConfig rebalanceConfig = new RebalanceConfig();
+ rebalanceConfig.setIncludeConsuming(true);
+ rebalanceConfig.setReassignInstances(true);
+ rebalanceConfig.setBootstrap(true);
+
+ boolean dryRun = rebalanceConfig.isDryRun();
+ boolean reassignInstances = rebalanceConfig.isReassignInstances();
+ boolean bootstrap = rebalanceConfig.isBootstrap();
+
+ try {
+
+ Pair<Map<InstancePartitionsType, InstancePartitions>, Boolean>
instancePartitionsMapAndUnchanged =
+ tableRebalancer.getInstancePartitionsMap(tableConfig,
reassignInstances, bootstrap, dryRun);
+ Map<InstancePartitionsType, InstancePartitions> instancePartitionsMap =
+ instancePartitionsMapAndUnchanged.getLeft();
+
+ // Calculate instance partitions for tiers if configured
+ List<Tier> sortedTiers = tableRebalancer.getSortedTiers(tableConfig,
null);
+ Pair<Map<String, InstancePartitions>, Boolean>
tierToInstancePartitionsMapAndUnchanged =
+ tableRebalancer.getTierToInstancePartitionsMap(tableConfig,
sortedTiers, reassignInstances, bootstrap,
+ dryRun);
+ Map<String, InstancePartitions> tierToInstancePartitionsMap =
tierToInstancePartitionsMapAndUnchanged.getLeft();
+
+ PropertyKey idealStatePropertyKey =
+
_pinotHelixResourceManager.getHelixZkManager().getHelixDataAccessor().keyBuilder()
+ .idealStates(tableNameWithType);
+ IdealState currentIdealState =
+
_pinotHelixResourceManager.getHelixZkManager().getHelixDataAccessor().getProperty(idealStatePropertyKey);
+
+ Preconditions.checkState(currentIdealState != null, "Ideal state for
table: %s is null", tableNameWithType);
+
+ SegmentAssignment segmentAssignment =
+
SegmentAssignmentFactory.getSegmentAssignment(_pinotHelixResourceManager.getHelixZkManager(),
tableConfig,
+ _controllerMetrics);
+
+ Map<String, Map<String, String>> currentAssignment =
currentIdealState.getRecord().getMapFields();
+
+ segmentAssignment.rebalanceTable(currentAssignment,
instancePartitionsMap, sortedTiers,
+ tierToInstancePartitionsMap, rebalanceConfig);
+ } catch (Exception e) {
+ LOGGER.error("Could not calculate target assignment for table: {} for
the provided table config",
+ tableNameWithType);
+ throw e;
Review Comment:
Let's wrap the error message into a new exception and not adding this error
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]