You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by jl...@apache.org on 2019/07/23 00:01:26 UTC

[incubator-pinot] branch master updated: Add resource config for lead controller resource (#4449)

This is an automated email from the ASF dual-hosted git repository.

jlli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new 523f697  Add resource config for lead controller resource (#4449)
523f697 is described below

commit 523f697f7422725c1625105560ff55b331c077c3
Author: Jialiang Li <jl...@linkedin.com>
AuthorDate: Mon Jul 22 17:01:21 2019 -0700

    Add resource config for lead controller resource (#4449)
    
    * Add resource config for lead controller resource
    * Explicitly set resource_enabled to false if absent
---
 .../controller/helix/core/util/HelixSetupUtils.java    | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/util/HelixSetupUtils.java b/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/util/HelixSetupUtils.java
index eda9779..a501767 100644
--- a/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/util/HelixSetupUtils.java
+++ b/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/util/HelixSetupUtils.java
@@ -21,6 +21,7 @@ package org.apache.pinot.controller.helix.core.util;
 import com.google.common.base.Preconditions;
 import java.util.Collections;
 import java.util.concurrent.TimeUnit;
+import org.apache.helix.ConfigAccessor;
 import org.apache.helix.HelixAdmin;
 import org.apache.helix.HelixDataAccessor;
 import org.apache.helix.HelixManager;
@@ -37,6 +38,7 @@ import org.apache.helix.model.HelixConfigScope;
 import org.apache.helix.model.HelixConfigScope.ConfigScopeProperty;
 import org.apache.helix.model.IdealState;
 import org.apache.helix.model.MasterSlaveSMD;
+import org.apache.helix.model.ResourceConfig;
 import org.apache.helix.model.StateModelDefinition;
 import org.apache.helix.model.builder.CustomModeISBuilder;
 import org.apache.helix.model.builder.FullAutoModeISBuilder;
@@ -87,6 +89,7 @@ public class HelixSetupUtils {
       HelixAdmin helixAdmin = new ZKHelixAdmin(zkClient);
       HelixDataAccessor helixDataAccessor =
           new ZKHelixDataAccessor(helixClusterName, new ZkBaseDataAccessor<>(zkClient));
+      ConfigAccessor configAccessor = new ConfigAccessor(zkClient);
 
       Preconditions.checkState(helixAdmin.getClusters().contains(helixClusterName),
           String.format("Helix cluster: %s hasn't been set up", helixClusterName));
@@ -98,7 +101,7 @@ public class HelixSetupUtils {
       createBrokerResourceIfNeeded(helixClusterName, helixAdmin, enableBatchMessageMode);
 
       // Add lead controller resource if needed
-      createLeadControllerResourceIfNeeded(helixClusterName, helixAdmin, enableBatchMessageMode);
+      createLeadControllerResourceIfNeeded(helixClusterName, helixAdmin, configAccessor, enableBatchMessageMode);
     } finally {
       if (zkClient != null) {
         zkClient.close();
@@ -144,7 +147,7 @@ public class HelixSetupUtils {
   }
 
   private static void createLeadControllerResourceIfNeeded(String helixClusterName, HelixAdmin helixAdmin,
-      boolean enableBatchMessageMode) {
+      ConfigAccessor configAccessor, boolean enableBatchMessageMode) {
     if (helixAdmin.getResourceIdealState(helixClusterName, LEAD_CONTROLLER_RESOURCE_NAME) == null) {
       LOGGER.info("Adding resource: {}", LEAD_CONTROLLER_RESOURCE_NAME);
 
@@ -177,5 +180,16 @@ public class HelixSetupUtils {
 
       helixAdmin.addResource(helixClusterName, LEAD_CONTROLLER_RESOURCE_NAME, idealState);
     }
+
+    // Create resource config for lead controller resource if it doesn't exist
+    ResourceConfig resourceConfig = configAccessor.getResourceConfig(helixClusterName, LEAD_CONTROLLER_RESOURCE_NAME);
+    if (resourceConfig == null) {
+      resourceConfig = new ResourceConfig(LEAD_CONTROLLER_RESOURCE_NAME);
+    }
+    // Set RESOURCE_ENABLED to false if it's absent in resource config
+    if (resourceConfig.getSimpleConfig("RESOURCE_ENABLED") == null) {
+      resourceConfig.putSimpleConfig("RESOURCE_ENABLED", Boolean.FALSE.toString());
+    }
+    configAccessor.setResourceConfig(helixClusterName, LEAD_CONTROLLER_RESOURCE_NAME, resourceConfig);
   }
 }


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