jackjlli commented on a change in pull request #4047: Create
leadControllerResource in helix cluster
URL: https://github.com/apache/incubator-pinot/pull/4047#discussion_r281861301
##########
File path:
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/util/HelixSetupUtils.java
##########
@@ -175,4 +185,40 @@ private static HelixManager
startHelixControllerInStandadloneMode(String helixCl
return HelixControllerMain
.startHelixController(zkUrl, helixClusterName,
pinotControllerInstanceId, HelixControllerMain.STANDALONE);
}
+
+ private static void createLeadControllerResourceIfNeeded(String
helixClusterName, HelixAdmin admin,
+ boolean enableBatchMessageMode, boolean enableLeadControllerResource) {
+ List<String> resources = admin.getResourcesInCluster(helixClusterName);
+ if
(!resources.contains(CommonConstants.Helix.LEAD_CONTROLLER_RESOURCE_NAME)) {
+ LOGGER.info("Cluster {} doesn't contain {}. Creating one..",
helixClusterName,
+ CommonConstants.Helix.LEAD_CONTROLLER_RESOURCE_NAME);
+
+ admin.addStateModelDef(helixClusterName,
CommonConstants.Helix.MASTER_SLAVE_STATE_MODEL_DEFINITION,
+ MasterSlaveSMD.build());
+
+ HelixHelper.updateResourceConfigsFor(new HashMap<>(),
CommonConstants.Helix.LEAD_CONTROLLER_RESOURCE_NAME,
+ helixClusterName, admin);
+ admin.addResource(helixClusterName,
CommonConstants.Helix.LEAD_CONTROLLER_RESOURCE_NAME,
+
CommonConstants.Helix.DEFAULT_NUMBER_OF_PARTITIONS_IN_LEAD_CONTROLLER_RESOURCE,
+ CommonConstants.Helix.MASTER_SLAVE_STATE_MODEL_DEFINITION,
IdealState.RebalanceMode.FULL_AUTO.toString());
+
+ // Set instance group tag for lead controller resource.
+ IdealState leadControllerIdealState =
+ admin.getResourceIdealState(helixClusterName,
CommonConstants.Helix.LEAD_CONTROLLER_RESOURCE_NAME);
+
leadControllerIdealState.setInstanceGroupTag(CommonConstants.Helix.CONTROLLER_INSTANCE_TYPE);
+ leadControllerIdealState.setBatchMessageMode(enableBatchMessageMode);
+ admin.setResourceIdealState(helixClusterName,
CommonConstants.Helix.LEAD_CONTROLLER_RESOURCE_NAME,
+ leadControllerIdealState);
+ }
+
+ LOGGER.info("Re-balance lead controller resource with replicas: {}",
+ CommonConstants.Helix.DEFAULT_NUMBER_OF_CONTROLLER_REPLICAS);
+ admin.rebalance(helixClusterName,
CommonConstants.Helix.LEAD_CONTROLLER_RESOURCE_NAME,
+ CommonConstants.Helix.DEFAULT_NUMBER_OF_CONTROLLER_REPLICAS);
+
+ // Enable or disable lead controller resource.
+ LOGGER.info("{} lead controller resource.", enableLeadControllerResource ?
"Enabling" : "Disabling");
+ admin.enableResource(helixClusterName,
CommonConstants.Helix.LEAD_CONTROLLER_RESOURCE_NAME,
Review comment:
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]