somandal commented on code in PR #16878:
URL: https://github.com/apache/pinot/pull/16878#discussion_r2376683301


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotRealtimeTableResource.java:
##########
@@ -395,6 +397,69 @@ public ConsumingSegmentInfoReader.ConsumingSegmentsInfoMap 
getConsumingSegmentsI
     }
   }
 
+  @GET
+  @Path("/tables/{tableName}/partitionCount")
+  @Authorize(targetType = TargetType.TABLE, paramName = "tableName", action = 
Actions.Table.GET_METADATA)
+  @Produces(MediaType.APPLICATION_JSON)
+  @ApiOperation(value = "Get partition count for a realtime table",
+      notes = "Returns the numbers of consumers for a realtime table by 
checking "
+          + "the number of partitions in the table in"
+          + " IdealState")
+  @ApiResponses(value = {
+      @ApiResponse(code = 200, message = "Success"),
+      @ApiResponse(code = 404, message = "Table not found"),
+      @ApiResponse(code = 500, message = "Internal server error")
+  })
+  public Map<String, Integer> getTablePartitionCount(
+      @ApiParam(value = "Realtime table name with or without type", required = 
true, example = "myTable | "
+          + "myTable_REALTIME") @PathParam("tableName") String 
realtimeTableName,
+      @Context HttpHeaders headers) {
+    realtimeTableName = DatabaseUtils.translateTableName(realtimeTableName, 
headers);
+    try {
+      TableType tableType = 
TableNameBuilder.getTableTypeFromTableName(realtimeTableName);
+      if (TableType.OFFLINE == tableType) {
+        throw new IllegalStateException("Cannot get partition count for 
OFFLINE table: " + realtimeTableName);
+      }
+      String tableNameWithType = 
TableNameBuilder.forType(TableType.REALTIME).tableNameWithType(realtimeTableName);
+      int partitionCount = getPartitionCountFromSegment(tableNameWithType, 
_pinotHelixResourceManager);
+
+      Map<String, Integer> response = new HashMap<>();
+      response.put("partitionCount", partitionCount);

Review Comment:
   nit: does this need to return a map? can it just return an Integer?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to