saurabhd336 commented on code in PR #8828: URL: https://github.com/apache/pinot/pull/8828#discussion_r930664772
########## pinot-server/src/main/java/org/apache/pinot/server/api/resources/ControllerJobStatusResource.java: ########## @@ -0,0 +1,94 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.pinot.server.api.resources; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import java.util.List; +import javax.inject.Inject; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import org.apache.pinot.segment.local.data.manager.SegmentDataManager; +import org.apache.pinot.segment.local.data.manager.TableDataManager; +import org.apache.pinot.server.starter.ServerInstance; +import org.apache.pinot.server.starter.helix.SegmentReloadStatusValue; +import org.apache.pinot.spi.utils.JsonUtils; + + +@Api(tags = "Tasks") +@Path("/") +public class ControllerJobStatusResource { + + @Inject + private ServerInstance _serverInstance; + + @GET + @Path("/controllerJob/reloadStatus/{tableNameWithType}") + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Task status", notes = "Return status of the given task") + public String taskStatus(@PathParam("tableNameWithType") String tableNameWithType, + @QueryParam("reloadJobTimestamp") long reloadJobSubmissionTimestamp, + @QueryParam("segmentName") String segmentName) + throws Exception { + TableDataManager tableDataManager = + ServerResourceUtils.checkGetTableDataManager(_serverInstance, tableNameWithType); + + if (segmentName == null) { + // All segments + List<SegmentDataManager> allSegments = tableDataManager.acquireAllSegments(); + try { + long successCount = 0; + for (SegmentDataManager segmentDataManager : allSegments) { + if (segmentDataManager.getLoadTimeMs() >= reloadJobSubmissionTimestamp) { + successCount++; + } + } + SegmentReloadStatusValue segmentReloadStatusValue = + new SegmentReloadStatusValue(allSegments.size(), successCount); + return JsonUtils.objectToString(segmentReloadStatusValue); + } finally { + for (SegmentDataManager segmentDataManager : allSegments) { + tableDataManager.releaseSegment(segmentDataManager); + } + } + } else { + SegmentDataManager segmentDataManager = tableDataManager.acquireSegment(segmentName); + if (segmentDataManager == null) { + throw new WebApplicationException("Segment: " + segmentName + " is not found", Response.Status.NOT_FOUND); Review Comment: With controller now filtering servers for the segment being queried using idealstate, this should be far less frequent. And yes the controller makes the API calls using `CompletionServiceHelper` which handles non 200 responses correctly. -- 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