mayankshriv commented on a change in pull request #6977: URL: https://github.com/apache/incubator-pinot/pull/6977#discussion_r640883715
########## File path: pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/TableDebugResource.java ########## @@ -253,4 +330,46 @@ private TableDebugInfo debugTable(PinotHelixResourceManager pinotHelixResourceMa } return serverDebugInfos; } + + /** + * This method makes a MultiGet call to all servers to get the segments debug info. + * @return Map of server to list of segment debug info's on the server. + */ + private Map<String, Map<String, SegmentServerDebugInfo>> getSegmentsDebugInfoFromServers(String tableNameWithType, + BiMap<String, String> serverToEndpoints, int timeoutMs) { + LOGGER.info("Reading segments debug info from servers: {} for table: {}", serverToEndpoints.keySet(), + tableNameWithType); + + List<String> serverUrls = new ArrayList<>(serverToEndpoints.size()); + BiMap<String, String> endpointsToServers = serverToEndpoints.inverse(); + for (String endpoint : endpointsToServers.keySet()) { + String segmentDebugInfoURI = String.format("%s/debug/tables/%s", endpoint, tableNameWithType); + serverUrls.add(segmentDebugInfoURI); + } + + CompletionServiceHelper completionServiceHelper = + new CompletionServiceHelper(_executor, _connectionManager, endpointsToServers); + CompletionServiceHelper.CompletionServiceResponse serviceResponse = + completionServiceHelper.doMultiGetRequest(serverUrls, tableNameWithType, timeoutMs); + + Map<String, Map<String, SegmentServerDebugInfo>> serverToSegmentDebugInfoList = new HashMap<>(); + int failedParses = 0; + for (Map.Entry<String, String> streamResponse : serviceResponse._httpResponses.entrySet()) { + try { + List<SegmentServerDebugInfo> segmentDebugInfos = + JsonUtils.stringToObject(streamResponse.getValue(), new TypeReference<List<SegmentServerDebugInfo>>() { + }); + Map<String, SegmentServerDebugInfo> segmentsMap = segmentDebugInfos.stream() + .collect(Collectors.toMap(SegmentServerDebugInfo::getSegmentName, Function.identity())); + serverToSegmentDebugInfoList.put(streamResponse.getKey(), segmentsMap); + } catch (IOException e) { + failedParses++; + LOGGER.error("Unable to parse server {} response due to an error: ", streamResponse.getKey(), e); + } + } + if (failedParses != 0) { Review comment: Sounds like a good idea. However, this pattern (of getting info from servers and aggregating) is repeated in multiple places (eg table size), I'll think about consolidating and cleaning in a separate PR. -- 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. 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