swaminathanmanish commented on code in PR #10359:
URL: https://github.com/apache/pinot/pull/10359#discussion_r1128611410


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableRestletResource.java:
##########
@@ -712,6 +719,37 @@ public String getTableState(
     }
   }
 
+  @GET
+  @Produces(MediaType.APPLICATION_JSON)
+  @Authenticate(AccessType.UPDATE)
+  @Path("/rebalanceStatus/{jobId}")
+  @ApiOperation(value = "Gets detailed stats of a rebalance operation",
+          notes = "Gets detailed stats of a rebalance operation")
+  public ServerRebalanceJobStatusResponse rebalanceStatus(@ApiParam(value = 
"Rebalance Job Id", required = true)
+                                         @PathParam("jobId") String jobId)
+          throws JsonProcessingException {
+    Map<String, String> controllerJobZKMetadata =
+            
_pinotHelixResourceManager.getControllerJobZKMetadataResource(jobId,
+                    CommonConstants.Helix.ZkClient.ZK_REBALANCE_RESOURCE);
+    if (controllerJobZKMetadata == null) {
+      throw new ControllerApplicationException(LOGGER, "Failed to find 
controller job id: " + jobId,
+              Response.Status.NOT_FOUND);
+    }
+    TableRebalanceProgressStats tableRebalanceProgressStats = 
JsonUtils.stringToObject(
+            
controllerJobZKMetadata.get(RebalanceConfigConstants.REBALANCE_PROGRESS_STATS),
+            TableRebalanceProgressStats.class);
+    Long timeSinceStartInSecs = 0L;
+    if 
(!tableRebalanceProgressStats.getStatus().toString().equals(RebalanceResult.Status.DONE.toString()))
 {
+      timeSinceStartInSecs = (long) (System.currentTimeMillis()
+              - tableRebalanceProgressStats.getStartTimeInMilliseconds()) / 
1000;
+    }
+    ServerRebalanceJobStatusResponse serverRebalanceJobStatusResponse = new 
ServerRebalanceJobStatusResponse();
+    
serverRebalanceJobStatusResponse.setTableRebalanceProgressStats(tableRebalanceProgressStats);
+    
serverRebalanceJobStatusResponse.setTimeElapsedSinceStartInSeconds(timeSinceStartInSecs);
+    return serverRebalanceJobStatusResponse;

Review Comment:
   Yes response code is automatically included.  Snippet of the output
   
   Code | Details
   -- | --
   200.   Response body
   Download
   {
     "tableRebalanceProgressStats": {
       "initialToTargetStateConvergence": {
         "_segmentsMissing": 0,
         "_segmentsToRebalance": 31,
         "_percentSegmentsToRebalance": 100,
         "_replicasToRebalance": 279
       },
       "externalViewToIdealStateConvergence": {
         "_segmentsMissing": 0,
         "_segmentsToRebalance": 31,
         "_percentSegmentsToRebalance": 100,
         "_replicasToRebalance": 279
       },
       "currentToTargetConverg
   
   



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

Reply via email to