kishoreg commented on a change in pull request #5902:
URL: https://github.com/apache/incubator-pinot/pull/5902#discussion_r473733017



##########
File path: 
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java
##########
@@ -399,6 +400,28 @@ public synchronized PinotResourceManagerResponse 
updateInstance(String instanceI
     }
   }
 
+  /**
+   * Updates the tags of the specified instance ID
+   */
+  public synchronized PinotResourceManagerResponse updateInstanceTags(String 
instanceIdToUpdate, String tags) {
+    InstanceConfig instanceConfig = getHelixInstanceConfig(instanceIdToUpdate);

Review comment:
       run this in a compare and set loop to handle race conditions. we can 
wrap this function in updater

##########
File path: 
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotInstanceRestletResource.java
##########
@@ -196,4 +197,25 @@ public SuccessResponse updateInstance(
     }
     return new SuccessResponse("Instance successfully updated");
   }
+
+  @PUT
+  @Path("/instances/{instanceName}/updateTags")
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Produces(MediaType.APPLICATION_JSON)
+  @ApiOperation(value = "Update the tags of the specified instance", consumes 
= MediaType.APPLICATION_JSON, notes = "Update the tags of the specified 
instance")
+  @ApiResponses(value = {@ApiResponse(code = 200, message = "Success"), 
@ApiResponse(code = 500, message = "Internal error")})
+  public SuccessResponse updateInstanceTags(
+      @ApiParam(value = "Instance name", required = true, example = 
"Server_a.b.com_20000 | Broker_my.broker.com_30000") @PathParam("instanceName") 
String instanceName,
+      @ApiParam(value = "Comma separated tags list", required = true) 
@QueryParam("tags") String tags) {
+    LOGGER.info("Instance update request received for instance: {}", 
instanceName);
+    if (tags == null) {
+      throw new ControllerApplicationException(LOGGER, "Must provide tags to 
update", Response.Status.BAD_REQUEST);
+    }
+    PinotResourceManagerResponse response = 
pinotHelixResourceManager.updateInstanceTags(instanceName, tags);
+    if (!response.isSuccessful()) {
+      throw new ControllerApplicationException(LOGGER,
+          "Failure to update instance tags. Reason: " + response.getMessage(), 
Response.Status.INTERNAL_SERVER_ERROR);
+    }
+    return new SuccessResponse("Instance successfully updated");

Review comment:
       print the new tags. Instance tags successfully updated from:{old tags} 
to: {new tags}




----------------------------------------------------------------
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:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to