alirezazamani commented on a change in pull request #797: Add REST API to add, 
remove and update CustomizedStateAggregationConfig
URL: https://github.com/apache/helix/pull/797#discussion_r384044242
 
 

 ##########
 File path: 
helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/ClusterAccessor.java
 ##########
 @@ -267,6 +268,115 @@ public Response getClusterConfig(@PathParam("clusterId") 
String clusterId) {
     return JSONRepresentation(config.getRecord());
   }
 
+
+  @PUT
+  @Path("{clusterId}/customized-state-aggregation-config")
+  public Response addCustomizedStateAggregationConfig(@PathParam("clusterId") 
String clusterId,
+      String content) {
+    if (!doesClusterExist(clusterId)) {
+      return notFound(String.format("Cluster %s does not exist", clusterId));
+    }
+
+    HelixAdmin admin = getHelixAdmin();
+    ZNRecord record;
+    try {
+      record = toZNRecord(content);
+    } catch (IOException e) {
+      _logger.error("Failed to deserialize user's input " + content + ", 
Exception: " + e);
+      return badRequest("Input is not a vaild ZNRecord!");
+    }
+
+    try {
+      CustomizedStateAggregationConfig customizedStateAggregationConfig =
+          new CustomizedStateAggregationConfig.Builder(record).build();
+      admin.addCustomizedStateAggregationConfig(clusterId, 
customizedStateAggregationConfig);
+    } catch (Exception ex) {
 
 Review comment:
   Thanks for the comment. I still prefer to catch all the exception like we do 
in other functions.

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