jackjlli commented on code in PR #11509: URL: https://github.com/apache/pinot/pull/11509#discussion_r1322027323
########## pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/util/HelixSetupUtils.java: ########## @@ -226,4 +193,77 @@ private static void createLeadControllerResourceIfNeeded(String helixClusterName resourceConfig.putSimpleConfig(LEAD_CONTROLLER_RESOURCE_ENABLED_KEY, Boolean.TRUE.toString()); configAccessor.setResourceConfig(helixClusterName, LEAD_CONTROLLER_RESOURCE_NAME, resourceConfig); } + + private static IdealState constructIdealState(boolean enableBatchMessageMode, ControllerConf controllerConf) { + // FULL-AUTO Master-Slave state model with a rebalance strategy, auto-rebalance by default + FullAutoModeISBuilder idealStateBuilder = new FullAutoModeISBuilder(LEAD_CONTROLLER_RESOURCE_NAME); + idealStateBuilder.setStateModel(MasterSlaveSMD.name) + .setRebalanceStrategy(controllerConf.getLeadControllerResourceRebalanceStrategy()); + // Initialize partitions and replicas + idealStateBuilder.setNumPartitions(NUMBER_OF_PARTITIONS_IN_LEAD_CONTROLLER_RESOURCE); + for (int i = 0; i < NUMBER_OF_PARTITIONS_IN_LEAD_CONTROLLER_RESOURCE; i++) { + idealStateBuilder.add(LeadControllerUtils.generatePartitionName(i)); + } + idealStateBuilder.setNumReplica(LEAD_CONTROLLER_RESOURCE_REPLICA_COUNT); + // The below config guarantees if active number of replicas is no less than minimum active replica, there will + // not be partition movements happened. + // Set min active replicas to 0 and rebalance delay to 5 minutes so that if any master goes offline, Helix + // controller waits at most 5 minutes and then re-calculate the participant assignment. + // This delay is helpful when periodic tasks are running and we don't want them to be re-run too frequently. + // Plus, if virtual id is applied to controller hosts, swapping hosts would be easy as new hosts can use the + // same virtual id and it takes least effort to change the configs. + idealStateBuilder.setMinActiveReplica(MIN_ACTIVE_REPLICAS); + idealStateBuilder.setRebalanceDelay(controllerConf.getLeadControllerResourceRebalanceDelayMs()); + idealStateBuilder.enableDelayRebalance(); + // Set instance group tag + IdealState idealState = idealStateBuilder.build(); + idealState.setInstanceGroupTag(CONTROLLER_INSTANCE); + // Set batch message mode + idealState.setBatchMessageMode(enableBatchMessageMode); + // Explicitly disable this resource when creating this new resource. Review Comment: nit: you can clean up the comments from Line 223 to Line 227 since that's fully done. -- 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