mgao0 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_r388494177
 
 

 ##########
 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:
   You are right. I'm trying to use the parentPath. I'm trying to resolve the 
problem that when we want to update the rest config in the path 
"/{clusterId}/CONFIGS/REST{clusterId}", the parent path 
"/{clusterId}/CONFIGS/REST" doesn't exist yet, so I would create the parentPath 
first.

----------------------------------------------------------------
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]

Reply via email to