This is an automated email from the ASF dual-hosted git repository.
jackie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new fafb518f75 Enhance cluster config update API to handle non-string
values properly (#9635)
fafb518f75 is described below
commit fafb518f757cdfeb198c3b4accd0c72b97e9d72c
Author: Xiaotian (Jackie) Jiang <[email protected]>
AuthorDate: Thu Oct 20 17:58:37 2022 -0700
Enhance cluster config update API to handle non-string values properly
(#9635)
---
.../controller/api/resources/PinotClusterConfigs.java | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git
a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotClusterConfigs.java
b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotClusterConfigs.java
index 4ad4567fec..4b84590dba 100644
---
a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotClusterConfigs.java
+++
b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotClusterConfigs.java
@@ -30,11 +30,11 @@ import io.swagger.annotations.Authorization;
import io.swagger.annotations.SecurityDefinition;
import io.swagger.annotations.SwaggerDefinition;
import java.io.IOException;
-import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.TreeMap;
import javax.inject.Inject;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
@@ -117,14 +117,17 @@ public class PinotClusterConfigs {
try {
JsonNode jsonNode = JsonUtils.stringToJsonNode(body);
HelixAdmin admin = _pinotHelixResourceManager.getHelixAdmin();
- HelixConfigScope configScope = new
HelixConfigScopeBuilder(HelixConfigScope.ConfigScopeProperty.CLUSTER)
-
.forCluster(_pinotHelixResourceManager.getHelixClusterName()).build();
+ HelixConfigScope configScope =
+ new
HelixConfigScopeBuilder(HelixConfigScope.ConfigScopeProperty.CLUSTER).forCluster(
+ _pinotHelixResourceManager.getHelixClusterName()).build();
Iterator<String> fieldNamesIterator = jsonNode.fieldNames();
+ Map<String, String> properties = new TreeMap<>();
while (fieldNamesIterator.hasNext()) {
String key = fieldNamesIterator.next();
- String value = jsonNode.get(key).textValue();
- admin.setConfig(configScope, Collections.singletonMap(key, value));
+ JsonNode valueNode = jsonNode.get(key);
+ properties.put(key, valueNode.isNull() ? null : valueNode.asText());
}
+ admin.setConfig(configScope, properties);
return new SuccessResponse("Updated cluster config.");
} catch (IOException e) {
throw new ControllerApplicationException(LOGGER, "Error converting
request to cluster config.",
@@ -150,7 +153,7 @@ public class PinotClusterConfigs {
HelixAdmin admin = _pinotHelixResourceManager.getHelixAdmin();
HelixConfigScope configScope = new
HelixConfigScopeBuilder(HelixConfigScope.ConfigScopeProperty.CLUSTER)
.forCluster(_pinotHelixResourceManager.getHelixClusterName()).build();
- admin.removeConfig(configScope, Arrays.asList(configName));
+ admin.removeConfig(configScope, Collections.singletonList(configName));
return new SuccessResponse("Deleted cluster config: " + configName);
} catch (Exception e) {
String errStr = "Failed to delete cluster config: " + configName;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]