saurabhd336 commented on code in PR #9058: URL: https://github.com/apache/pinot/pull/9058#discussion_r926263366
########## pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTaskRestletResource.java: ########## @@ -231,6 +260,55 @@ public Map<String, PinotHelixTaskResourceManager.TaskDebugInfo> getTasksDebugInf return _pinotHelixTaskResourceManager.getTasksDebugInfoByTable(taskType, tableNameWithType, verbosity); } + @GET + @Produces(MediaType.APPLICATION_JSON) + @Path("/tasks/generator/{tableNameWithType}/{taskType}/debug") + @ApiOperation("Fetch task generation information for the recent runs of the given task for the given table") + public String getTaskGenerationDebugInto( + @ApiParam(value = "Task type", required = true) @PathParam("taskType") String taskType, + @ApiParam(value = "Table name with type", required = true) @PathParam("tableNameWithType") + String tableNameWithType, + @ApiParam(value = "Whether to only lookup local cache for logs", defaultValue = "false") @QueryParam("localOnly") + boolean localOnly) + throws JsonProcessingException { + if (localOnly) { + BaseTaskGeneratorInfo taskGeneratorMostRecentRunInfo = + _taskManagerStatusCache.fetchTaskGeneratorInfo(tableNameWithType, taskType); + if (taskGeneratorMostRecentRunInfo == null) { + throw new ControllerApplicationException(LOGGER, "Task generation information not found", + Response.Status.NOT_FOUND); + } + + return JsonUtils.objectToString(taskGeneratorMostRecentRunInfo); + } + + // Call all controllers + List<InstanceConfig> controllers = _pinotHelixResourceManager.getAllControllerInstanceConfigs(); + // Relying on original schema that was used to query the controller + URI uri = _uriInfo.getRequestUri(); + String scheme = uri.getScheme(); + List<String> controllerUrls = controllers.stream().map(controller -> { + return String.format("%s://%s:%d/tasks/generator/%s/%s/debug?localOnly=true", scheme, controller.getHostName(), + Integer.parseInt(controller.getPort()), tableNameWithType, taskType); + }).collect(Collectors.toList()); + + CompletionServiceHelper completionServiceHelper = + new CompletionServiceHelper(_executor, _connectionManager, HashBiMap.create(0)); + CompletionServiceHelper.CompletionServiceResponse serviceResponse = + completionServiceHelper.doMultiGetRequest(controllerUrls, null, true, 10000); + + List<JsonNode> result = new ArrayList<>(); + serviceResponse._httpResponses.values().forEach(resp -> { + try { + result.add(JsonUtils.stringToJsonNode(resp)); + } catch (IOException e) { + LOGGER.error("Failed to parse "); Review Comment: Ack -- 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