jasperjiaguo commented on code in PR #11578: URL: https://github.com/apache/pinot/pull/11578#discussion_r1371070042
########## pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTenantRestletResource.java: ########## @@ -286,6 +291,75 @@ public String getTablesOnTenant( } } + @GET + @Path("/tenants/{tenantName}/instancePartitions") + @Authorize(targetType = TargetType.CLUSTER, action = Actions.Cluster.GET_INSTANCE_PARTITION) + @Authenticate(AccessType.READ) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Get the instance partitions of a tenant") + @ApiResponses(value = {@ApiResponse(code = 200, message = "Success"), + @ApiResponse(code = 500, message = "Instance partitions not found")}) + public InstancePartitions getInstancePartitions( + @ApiParam(value = "Tenant name ", required = true) @PathParam("tenantName") String tenantName, + @ApiParam(value = "instancePartitionType (OFFLINE|CONSUMING|COMPLETED)", required = true) + @QueryParam("instancePartitionType") String instancePartitionType) { + String tenantNameWithType = InstancePartitionsType.valueOf(instancePartitionType) + .getInstancePartitionsName(tenantName); + InstancePartitions instancePartitions = + InstancePartitionsUtils.fetchInstancePartitions(_pinotHelixResourceManager.getPropertyStore(), + tenantNameWithType); + + if (instancePartitions == null) { + throw new ControllerApplicationException(LOGGER, "Failed to find the instance partitions", + Response.Status.NOT_FOUND); + } else { + return instancePartitions; + } + } + + @PUT + @Path("/tenants/{tenantName}/instancePartitions") + @Authorize(targetType = TargetType.CLUSTER, action = Actions.Cluster.UPDATE_INSTANCE_PARTITION) + @Authenticate(AccessType.UPDATE) + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Update an instance partition for a server type in a tenant") + @ApiResponses(value = {@ApiResponse(code = 200, message = "Success"), + @ApiResponse(code = 500, message = "Failed to update the tenant")}) + public InstancePartitions assignInstancesPartitionMap( + @ApiParam(value = "Tenant name ", required = true) @PathParam("tenantName") String tenantName, + @ApiParam(value = "instancePartitionType (OFFLINE|CONSUMING|COMPLETED)", required = true) + @QueryParam("instancePartitionType") String instancePartitionType, + String instancePartitionsStr) { + InstancePartitions instancePartitions; + try { + instancePartitions = JsonUtils.stringToObject(instancePartitionsStr, InstancePartitions.class); + } catch (IOException e) { + throw new ControllerApplicationException(LOGGER, "Failed to deserialize the instance partitions", + Response.Status.BAD_REQUEST); + } + + String tenantNameWithType = InstancePartitionsType.valueOf(instancePartitionType) + .getInstancePartitionsName(tenantName); + Preconditions.checkState(instancePartitions.getInstancePartitionsName().equals(tenantNameWithType), Review Comment: throw bad request for 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. To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org 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