saurabhd336 commented on code in PR #8828: URL: https://github.com/apache/pinot/pull/8828#discussion_r930647944
########## pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java: ########## @@ -577,6 +598,98 @@ public SuccessResponse reloadSegmentDeprecated2( return reloadSegmentDeprecated1(tableName, segmentName, tableTypeStr); } + @GET + @Path("tables/{tableName}/segmentReloadStatus/{jobId}") + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Get status for a submitted reload operation", + notes = "Get status for a submitted reload operation") + public ServerReloadControllerJobStatusResponse getReloadJobStatus( + @ApiParam(value = "Name of the table", required = true) @PathParam("tableName") String tableName, + @ApiParam(value = "OFFLINE|REALTIME", required = true) @QueryParam("type") String tableTypeStr, + @ApiParam(value = "Reload job id", required = true) @PathParam("jobId") String reloadJobId) + throws Exception { + TableType tableTypeFromRequest = Constants.validateTableType(tableTypeStr); + String tableNameWithType = TableNameBuilder.forType(tableTypeFromRequest).tableNameWithType(tableName); + Map<String, List<String>> serverToSegments = _pinotHelixResourceManager.getServerToSegmentsMap(tableNameWithType); + Map<String, String> controllerJobZKMetadata = _pinotHelixResourceManager.getControllerJobZKMetadata(reloadJobId); + + if (controllerJobZKMetadata == null) { + throw new ControllerApplicationException(LOGGER, + "Failed to find controller job: " + reloadJobId + " for table: " + tableNameWithType, Status.NOT_FOUND); + } + + String singleSegmentName = null; + if (controllerJobZKMetadata.get(CommonConstants.ControllerJob.CONTROLLER_JOB_TYPE).equals( + ControllerJobType.RELOAD_SEGMENT.toString())) { + singleSegmentName = controllerJobZKMetadata.get(CommonConstants.ControllerJob.SEGMENT_RELOAD_JOB_SEGMENT_NAME); + } + + BiMap<String, String> serverEndPoints = + _pinotHelixResourceManager.getDataInstanceAdminEndpoints(serverToSegments.keySet()); + CompletionServiceHelper completionServiceHelper = + new CompletionServiceHelper(_executor, _connectionManager, serverEndPoints); + + List<String> serverUrls = new ArrayList<>(); Review Comment: The other part makes sense. I've 1) Used ideal state to calculate the total number of segments for the response 2) If its a single segment reload job, I've filtered server endpoints to only those (the one) that hosts the segment. -- 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