bziobrowski commented on code in PR #16664:
URL: https://github.com/apache/pinot/pull/16664#discussion_r2293059082
##########
pinot-server/src/main/java/org/apache/pinot/server/api/resources/TablesResource.java:
##########
@@ -409,6 +409,53 @@ public String getSegmentMetadata(
}
}
+ @GET
+ @Encoded
+ @Path("/tables/{tableName}/segments/metadata")
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "Provide segment metadata for all segments not OFFLINE
in IdealState",
+ notes = "Provide segments metadata for all segments of a table on the
server which aren't OFFLINE in IdealState")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "Success"),
+ @ApiResponse(code = 500, message = "Internal server error", response =
ErrorInfo.class),
+ @ApiResponse(code = 404, message = "Table not found", response =
ErrorInfo.class)
+ })
+ public List<String> getAllSegmentsMetadata(
+ @ApiParam(value = "Table name including type", required = true, example
= "myTable_OFFLINE")
+ @PathParam("tableName") String tableName,
+ @ApiParam(value = "Column name", allowMultiple = true)
@QueryParam("columns") @DefaultValue("")
+ List<String> columns, @Context HttpHeaders headers) {
+ tableName = DatabaseUtils.translateTableName(tableName, headers);
+ for (int i = 0; i < columns.size(); i++) {
+ columns.set(i, URIUtils.decode(columns.get(i)));
+ }
+
+ TableDataManager tableDataManager =
ServerResourceUtils.checkGetTableDataManager(_serverInstance, tableName);
+ List<SegmentDataManager> segmentDataManagers =
tableDataManager.acquireAllSegments();
+ List<String> segmentMetadataList = new ArrayList<>();
+ try {
+ // The SegmentDataManager doesn't exist for OFFLINE segments as this is
removed when a segment goes into OFFLINE
+ // state and is offloaded in the Helix state transition callback. So
this naturally only returns data for
+ // segments which haven't been offloaded (and are not OFFLINE in
IdealState)
+ for (SegmentDataManager segmentDataManager : segmentDataManagers) {
+ String segmentName = segmentDataManager.getSegmentName();
+ try {
+
segmentMetadataList.add(SegmentMetadataFetcher.getSegmentMetadata(segmentDataManager,
columns));
+ } catch (Exception e) {
+ LOGGER.error("Failed to convert table {} segment {} to json",
tableName, segmentName);
Review Comment:
I think it'd be good to log exception e's message at least to give a clue
about why call failed.
--
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]