Jackie-Jiang commented on a change in pull request #4952: Adding new Controller
APIs for retrieving and setting tag for an instance
URL: https://github.com/apache/incubator-pinot/pull/4952#discussion_r363992207
##########
File path:
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotInstanceRestletResource.java
##########
@@ -176,4 +177,68 @@ public SuccessResponse dropInstance(
}
return new SuccessResponse("Successfully dropped instance");
}
-}
+
+ @GET
+ @Path("/instances/{instanceName}/tags")
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "Get all the tags for the specified instance",
produces = MediaType.APPLICATION_JSON)
+ @ApiResponses(value = {@ApiResponse(code = 200, message = "Success"),
@ApiResponse(code = 404, message = "Instance not found"), @ApiResponse(code =
500, message = "Internal error")})
+ public String getInstanceTags(
+ @ApiParam(value = "Instance name", required = true, example =
"Server_a.b.com_20000 | Broker_my.broker.com_30000") @PathParam("instanceName")
String instanceName) {
+ InstanceConfig instanceConfig =
pinotHelixResourceManager.getHelixInstanceConfig(instanceName);
+ if (instanceConfig == null) {
+ throw new ControllerApplicationException(LOGGER, "Instance " +
instanceName + " not found",
+ Response.Status.NOT_FOUND);
+ }
+ ObjectNode response = JsonUtils.newObjectNode();
+ response.set("tags", JsonUtils.objectToJsonNode(instanceConfig.getTags()));
+ return response.toString();
+ }
+
+ /**
+ * This API is used to tag a previously untagged instance. This is used when
allocating a new
+ * instance to a particular tenant. See
https://github.com/apache/incubator-pinot/issues/4082
+ */
+ @POST
+ @Path("/instances/{instanceName}/tags")
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "Add a tag to an untagged instance", notes = "Add a
tag to an untagged instance")
+ @ApiResponses(value = {@ApiResponse(code = 200, message = "Success"),
@ApiResponse(code = 400, message = "Bad Request"), @ApiResponse(code = 404,
message = "Instance not found"), @ApiResponse(code = 409, message = "Instance
cannot be dropped"), @ApiResponse(code = 500, message = "Internal error")})
+ public SuccessResponse addInstanceTag(
Review comment:
I suggest adding a `PUT /instances/{instanceName}` to modify the existing
instance configs (similar to the existing `POST /instances` which adds a new
instance config), that will be much more general than this
----------------------------------------------------------------
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]