snleee commented on a change in pull request #6094: URL: https://github.com/apache/incubator-pinot/pull/6094#discussion_r517709063
########## File path: pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/minion/generator/TaskGeneratorUtils.java ########## @@ -104,4 +106,33 @@ private static boolean isTaskOlderThanOneDay(String taskName) { Long.parseLong(taskName.substring(taskName.lastIndexOf(PinotHelixTaskResourceManager.TASK_NAME_SEPARATOR) + 1)); return System.currentTimeMillis() - scheduleTimeMs > ONE_DAY_IN_MILLIS; } + + /** + * Get all the segments that are scheduled for all existing tables. + * + * @param taskType Task type + * @param clusterInfoAccessor Cluster info accessor + * @return a map of table name as a key and the list of scheduled segments as the value. + */ + public static Map<String, Set<String>> getScheduledSegmentsMap(@Nonnull String taskType, + @Nonnull ClusterInfoAccessor clusterInfoAccessor) { + Map<String, Set<String>> scheduledSegments = new HashMap<>(); + Map<String, TaskState> taskStates = clusterInfoAccessor.getTaskStates(taskType); + for (Map.Entry<String, TaskState> entry : taskStates.entrySet()) { + // Skip COMPLETED tasks + if (entry.getValue() == TaskState.COMPLETED) { + continue; + } + for (PinotTaskConfig pinotTaskConfig : clusterInfoAccessor.getTaskConfigs(entry.getKey())) { + Map<String, String> configs = pinotTaskConfig.getConfigs(); + Set<String> scheduledSegmentsForTable = + scheduledSegments.computeIfAbsent(configs.get(MinionConstants.TABLE_NAME_KEY), v -> new HashSet<>()); + String segmentName = configs.get(MinionConstants.SEGMENT_NAME_KEY); + Set<String> segmentNames = Review comment: changed to the traditional for loop ---------------------------------------------------------------- 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