xyuanlu commented on a change in pull request #1129:
URL: https://github.com/apache/helix/pull/1129#discussion_r458423984
##########
File path:
helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/PerInstanceAccessor.java
##########
@@ -542,4 +558,23 @@ public Response getHealthReportsOnInstance(
private boolean validInstance(JsonNode node, String instanceName) {
return
instanceName.equals(node.get(Properties.id.name()).getValueAsText());
}
+
+ private boolean validateDeltaInstanceConfigForUpdate(String clusterName,
String instanceName,
+ ConfigAccessor configAccessor, InstanceConfig newInstanceConfig, boolean
isDelete)
+ throws IllegalArgumentException {
+ InstanceConfig originalInstanceConfigCopy =
+ configAccessor.getInstanceConfig(clusterName, instanceName);
+ if (isDelete) {
+ for (Map.Entry<String, String> entry :
newInstanceConfig.getRecord().getSimpleFields()
+ .entrySet()) {
+
originalInstanceConfigCopy.getRecord().getSimpleFields().remove(entry.getKey());
+ }
+ } else {
+
originalInstanceConfigCopy.getRecord().update(newInstanceConfig.getRecord());
+ }
+
+ return ConfigAccessor
Review comment:
Updated.
##########
File path: helix-core/src/main/java/org/apache/helix/ConfigAccessor.java
##########
@@ -945,23 +947,23 @@ public void setInstanceConfig(String clusterName, String
instanceName,
* 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 config..
* The list fields and map fields will be replaced as a single entry.
- * The current Cluster config will be replaced with the given clusterConfig.
WARNING: This is not
+ * The current instanceConfig will be replaced with the given
instanceConfig. WARNING: This is not
* thread-safe or concurrent updates safe.
* *
*
* @param clusterName
* @param instanceName
- * @param instanceConfig
+ * @param newInstanceConfig
*
* @return
*/
public void updateInstanceConfig(String clusterName, String instanceName,
- InstanceConfig instanceConfig) {
- updateInstanceConfig(clusterName, instanceName, instanceConfig, false);
+ InstanceConfig newInstanceConfig) {
Review comment:
Updated,
##########
File path: helix-core/src/main/java/org/apache/helix/ConfigAccessor.java
##########
@@ -1009,4 +1010,19 @@ public ConfigAccessor build() {
_zkAddress), false);
}
}
+
+ /**
+ * Validate if the topology related settings (Domain or ZoneId) in the given
instanceConfig
+ * are valid and align with current clusterConfig.
+ * This function should be called when instance added to cluster or caller
updates instanceConfig.
+ *
+ * @throws IllegalArgumentException
+ */
+ public static boolean validateTopologySettingInInstanceConfig(ClusterConfig
clusterConfig,
Review comment:
Updated.
----------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]