walterddr commented on code in PR #8828:
URL: https://github.com/apache/pinot/pull/8828#discussion_r1359063941
##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -577,6 +599,107 @@ public SuccessResponse reloadSegmentDeprecated2(
return reloadSegmentDeprecated1(tableName, segmentName, tableTypeStr);
}
+ @GET
+ @Path("segments/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 = "Reload job id", required = true) @PathParam("jobId")
String reloadJobId)
+ throws Exception {
+ Map<String, String> controllerJobZKMetadata =
_pinotHelixResourceManager.getControllerJobZKMetadata(reloadJobId);
+ if (controllerJobZKMetadata == null) {
+ throw new ControllerApplicationException(LOGGER, "Failed to find
controller job id: " + reloadJobId,
+ Status.NOT_FOUND);
+ }
+
+ String tableNameWithType =
+
controllerJobZKMetadata.get(CommonConstants.ControllerJob.TABLE_NAME_WITH_TYPE);
+ Map<String, List<String>> serverToSegments;
+
+ String singleSegmentName = null;
+ if (controllerJobZKMetadata.get(CommonConstants.ControllerJob.JOB_TYPE)
+ .equals(ControllerJobType.RELOAD_SEGMENT.toString())) {
+ // No need to query servers where this segment is not supposed to be
hosted
+ singleSegmentName =
controllerJobZKMetadata.get(CommonConstants.ControllerJob.SEGMENT_RELOAD_JOB_SEGMENT_NAME);
+ serverToSegments = new HashMap<>();
+ List<String> segmentList = Arrays.asList(singleSegmentName);
+ _pinotHelixResourceManager.getServers(tableNameWithType,
singleSegmentName).forEach(server -> {
+ serverToSegments.put(server, segmentList);
+ });
+ } else {
+ serverToSegments =
_pinotHelixResourceManager.getServerToSegmentsMap(tableNameWithType);
+ }
+
+ BiMap<String, String> serverEndPoints =
+
_pinotHelixResourceManager.getDataInstanceAdminEndpoints(serverToSegments.keySet());
+ CompletionServiceHelper completionServiceHelper =
+ new CompletionServiceHelper(_executor, _connectionManager,
serverEndPoints);
+
+ List<String> serverUrls = new ArrayList<>();
+ BiMap<String, String> endpointsToServers = serverEndPoints.inverse();
+ for (String endpoint : endpointsToServers.keySet()) {
+ String reloadTaskStatusEndpoint =
+ endpoint + "/controllerJob/reloadStatus/" + tableNameWithType +
"?reloadJobTimestamp="
+ +
controllerJobZKMetadata.get(CommonConstants.ControllerJob.SUBMISSION_TIME_MS);
+ if (singleSegmentName != null) {
+ reloadTaskStatusEndpoint = reloadTaskStatusEndpoint + "&segmentName="
+ singleSegmentName;
+ }
+ serverUrls.add(reloadTaskStatusEndpoint);
+ }
+
+ CompletionServiceHelper.CompletionServiceResponse serviceResponse =
+ completionServiceHelper.doMultiGetRequest(serverUrls, null, true,
10000);
+
+ ServerReloadControllerJobStatusResponse
serverReloadControllerJobStatusResponse =
+ new ServerReloadControllerJobStatusResponse();
+ serverReloadControllerJobStatusResponse.setSuccessCount(0);
+
+ int totalSegments = 0;
+ for (Map.Entry<String, List<String>> entry: serverToSegments.entrySet()) {
+ totalSegments += entry.getValue().size();
+ }
+
serverReloadControllerJobStatusResponse.setTotalSegmentCount(totalSegments);
+
serverReloadControllerJobStatusResponse.setTotalServersQueried(serverUrls.size());
+
serverReloadControllerJobStatusResponse.setTotalServerCallsFailed(serviceResponse._failedResponseCount);
+
+ for (Map.Entry<String, String> streamResponse :
serviceResponse._httpResponses.entrySet()) {
+ String responseString = streamResponse.getValue();
+ try {
+ ServerReloadControllerJobStatusResponse response =
+ JsonUtils.stringToObject(responseString,
ServerReloadControllerJobStatusResponse.class);
Review Comment:
why are we using `ServerReloadControllerJobStatusResponse.class` in JsonUtil
instead of `SegmentReloadStatusValue.class` ? does it guarantee to be always
compatible? this seems like a risky assumption consider controller and server
are upgraded separately during rolling upgrade
--
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]