You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2019/03/07 02:37:16 UTC

[GitHub] [incubator-pinot] sunithabeeram commented on a change in pull request #3864: Add controller mode logic in ControllerStarter

sunithabeeram commented on a change in pull request #3864: Add controller mode logic in ControllerStarter
URL: https://github.com/apache/incubator-pinot/pull/3864#discussion_r263218052
 
 

 ##########
 File path: pinot-controller/src/main/java/org/apache/pinot/controller/ControllerStarter.java
 ##########
 @@ -133,50 +165,72 @@ public PinotTaskManager getTaskManager() {
   }
 
   public void start() {
-    LOGGER.info("Starting Pinot controller");
-
+    LOGGER.info("Starting Pinot controller in mode: {}.", _controllerMode.name());
     Utils.logVersions();
 
     // Set up controller metrics
     MetricsHelper.initializeMetrics(_config.subset(METRICS_REGISTRY_NAME));
     MetricsHelper.registerMetricsRegistry(_metricsRegistry);
 
-    Configuration pinotFSConfig = _config.subset(CommonConstants.Controller.PREFIX_OF_CONFIG_OF_PINOT_FS_FACTORY);
-    Configuration segmentFetcherFactoryConfig =
-        _config.subset(CommonConstants.Controller.PREFIX_OF_CONFIG_OF_SEGMENT_FETCHER_FACTORY);
-    Configuration pinotCrypterConfig = _config.subset(CommonConstants.Controller.PREFIX_OF_CONFIG_OF_PINOT_CRYPTER);
-
-    // Start all components
-    LOGGER.info("Initializing PinotFSFactory");
-    try {
-      PinotFSFactory.init(pinotFSConfig);
-    } catch (Exception e) {
-      Utils.rethrowException(e);
+    switch (_controllerMode) {
+      case DUAL:
+        setUpHelixController();
+        setUpPinotController();
+        break;
+      case PINOT_ONLY:
+        setUpPinotController();
+        break;
+      case HELIX_ONLY:
+        setUpHelixController();
+        break;
+      default:
+        LOGGER.error("Invalid mode: " + _controllerMode);
     }
 
-    LOGGER.info("Initializing SegmentFetcherFactory");
-    try {
-      SegmentFetcherFactory.getInstance().init(segmentFetcherFactoryConfig);
-    } catch (Exception e) {
-      throw new RuntimeException("Caught exception while initializing SegmentFetcherFactory", e);
-    }
+    _controllerMetrics.initializeGlobalMeters();
+  }
 
-    LOGGER.info("Initializing PinotCrypterFactory");
-    try {
-      PinotCrypterFactory.init(pinotCrypterConfig);
-    } catch (Exception e) {
-      throw new RuntimeException("Caught exception while initializing PinotCrypterFactory", e);
+  private void setUpHelixController() {
+    // Register and connect instance as Helix controller.
+    LOGGER.info("Starting Helix controller");
+    _helixControllerManager = HelixSetupUtils
+        .setup(_helixClusterName, _helixZkURL, _instanceId, _isUpdateStateModel, _enableBatchMessageMode);
+
+    // Emit helix controller metrics
+    _controllerMetrics.addCallbackGauge("helix.connected", () -> _helixControllerManager.isConnected() ? 1L : 0L);
+    _controllerMetrics.addCallbackGauge("helix.leader", () -> _helixControllerManager.isLeader() ? 1L : 0L);
+    _helixControllerManager.addPreConnectCallback(
+        () -> _controllerMetrics.addMeteredGlobalValue(ControllerMeter.HELIX_ZOOKEEPER_RECONNECTS, 1L));
+  }
+
+  private void setUpPinotController() {
+    // Note: Right now we don't allow pinot-only mode to be used in production yet.
+    // Now we only have this mode used in tests.
+    // TODO: Remove this logic once all the helix separation PRs are committed.
+    if (_controllerMode == ControllerConf.ControllerMode.PINOT_ONLY && !isPinotOnlyModeSupported()) {
 
 Review comment:
   Do we support HELIX only mode? I thought we would still rollout with just Dual mode initially, right?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

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