jiajunwang commented on a change in pull request #647: Add java API to create
cluster with CloudConfig
URL: https://github.com/apache/helix/pull/647#discussion_r359062377
##########
File path: helix-core/src/main/java/org/apache/helix/ConfigAccessor.java
##########
@@ -673,6 +673,41 @@ private void updateClusterConfig(String clusterName,
ClusterConfig clusterConfig
}
}
+
+
+ /**
+ * Update CloudConfig of the given cluster.
+ * The value of field in current config will be replaced with the value of
the same field in given config if it
+ * presents. If there is new field in given config but not in current
config, the field will be added into
+ * the current cloud config.
+ * The list fields and map fields will be replaced as a single entry.
+ *
+ * The current Cloud config will be replaced with the given cloudConfig.
+ * WARNING: This is not thread-safe or concurrent updates safe.
+ *
+ * @param clusterName
+ * @param cloudConfig
+ */
+ public void updateCloudConfig(String clusterName, CloudConfig cloudConfig) {
+ updateCloudConfig(clusterName, cloudConfig, false);
+ }
+
+ private void updateCloudConfig(String clusterName, CloudConfig cloudConfig,
boolean overwrite) {
+ if (!ZKUtil.isClusterSetup(clusterName, _zkClient)) {
+ throw new HelixException("fail to update config. cluster: " +
clusterName + " is NOT setup.");
+ }
+
+ HelixConfigScope scope =
+ new
HelixConfigScopeBuilder(ConfigScopeProperty.CLOUD).forCluster(clusterName).build();
+ String zkPath = scope.getZkPath();
+
+ if (overwrite) {
+ ZKUtil.createOrReplace(_zkClient, zkPath, cloudConfig.getRecord(), true);
+ } else {
+ ZKUtil.createOrUpdate(_zkClient, zkPath, cloudConfig.getRecord(), true,
true);
Review comment:
Any case, now or in the future, we need to support updates? I don't think
so. So shall we just simplify the code and get rid of the private method and
the overwrite option?
----------------------------------------------------------------
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]