You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by GitBox <gi...@apache.org> on 2020/03/05 07:38:50 UTC

[GitHub] [helix] jiajunwang commented on a change in pull request #849: Add REST APIs for get, set, update RestConfig

jiajunwang commented on a change in pull request #849: Add REST APIs for get, set, update RestConfig
URL: https://github.com/apache/helix/pull/849#discussion_r388118574
 
 

 ##########
 File path: helix-core/src/main/java/org/apache/helix/ConfigAccessor.java
 ##########
 @@ -605,6 +606,45 @@ public RESTConfig getRESTConfig(String clusterName) {
     return new RESTConfig(record);
   }
 
+  /**
+   * Set RestConfig of a given cluster
+   * @param clusterName the cluster id
+   * @param restConfig the RestConfig to be set to the cluster
+   */
+  public void setRESTConfig(String clusterName, RESTConfig restConfig) {
+    updateRESTConfig(clusterName, restConfig, true);
+  }
+
+  /**
+   * Update RestConfig of a given cluster
+   * @param clusterName the cluster id
+   * @param restConfig the new RestConfig to be set to the cluster
+   */
+  public void updateRESTConfig(String clusterName, RESTConfig restConfig) {
+    updateRESTConfig(clusterName, restConfig, false);
+  }
+
+  private void updateRESTConfig(String clusterName, RESTConfig restConfig, boolean overwrite) {
+    if (!ZKUtil.isClusterSetup(clusterName, _zkClient)) {
+      throw new HelixException("fail to update REST config. cluster: " + clusterName + " is NOT setup.");
+    }
+
+    HelixConfigScope scope = new HelixConfigScopeBuilder(ConfigScopeProperty.REST).forCluster(clusterName).build();
+    String zkPath = scope.getZkPath();
+
+    // Create "/{clusterId}/CONFIGS/REST" if it does not exist
+    String parentPath = HelixUtil.getZkParentPath(zkPath);
 
 Review comment:
   I see "HelixUtil.getZkParentPath(zkPath)" twice. I guess you are trying to use parentPath.

----------------------------------------------------------------
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: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org