shounakmk219 commented on code in PR #14829: URL: https://github.com/apache/pinot/pull/14829#discussion_r1935676993
########## pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/minion/PinotTaskManager.java: ########## @@ -483,92 +489,34 @@ public void registerTaskGenerator(PinotTaskGenerator taskGenerator) { _taskGeneratorRegistry.registerTaskGenerator(taskGenerator); } - /** - * Schedules tasks (all task types) for all tables. - * It might be called from the non-leader controller. - * Returns a map from the task type to the {@link TaskSchedulingInfo} of tasks scheduled. - */ - public synchronized Map<String, TaskSchedulingInfo> scheduleAllTasksForAllTables(@Nullable String minionInstanceTag) { - return scheduleTasks(_pinotHelixResourceManager.getAllTables(), false, minionInstanceTag); - } - - /** - * Schedules tasks (all task types) for all tables in the given database. - * It might be called from the non-leader controller. - * Returns a map from the task type to the {@link TaskSchedulingInfo} of tasks scheduled. - */ - public synchronized Map<String, TaskSchedulingInfo> scheduleAllTasksForDatabase(@Nullable String database, - @Nullable String minionInstanceTag) { - return scheduleTasks(_pinotHelixResourceManager.getAllTables(database), false, minionInstanceTag); - } - - /** - * Schedules tasks (all task types) for the given table. - * It might be called from the non-leader controller. - * Returns a map from the task type to the {@link TaskSchedulingInfo} of tasks scheduled. - */ - public synchronized Map<String, TaskSchedulingInfo> scheduleAllTasksForTable(String tableNameWithType, - @Nullable String minionInstanceTag) { - return scheduleTasks(List.of(tableNameWithType), false, minionInstanceTag); - } - - /** - * Schedules task for the given task type for all tables. - * It might be called from the non-leader controller. - * Returns {@link TaskSchedulingInfo} which consists - * - list of scheduled task names (empty list if nothing to schedule), - * or {@code null} if no task is scheduled due to scheduling errors. - * - list of task generation errors if any - * - list of task scheduling errors if any - */ - public synchronized TaskSchedulingInfo scheduleTaskForAllTables(String taskType, @Nullable String minionInstanceTag) { - return scheduleTask(taskType, _pinotHelixResourceManager.getAllTables(), minionInstanceTag); - } - - /** - * Schedules task for the given task type for all tables in the given database. - * It might be called from the non-leader controller. - * Returns {@link TaskSchedulingInfo} which consists - * - list of scheduled task names (empty list if nothing to schedule), - * or {@code null} if no task is scheduled due to scheduling errors. - * - list of task generation errors if any - * - list of task scheduling errors if any - */ - public synchronized TaskSchedulingInfo scheduleTaskForDatabase(String taskType, @Nullable String database, - @Nullable String minionInstanceTag) { - return scheduleTask(taskType, _pinotHelixResourceManager.getAllTables(database), minionInstanceTag); - } - - /** - * Schedules task for the given task type for the give table. - * It might be called from the non-leader controller. - * Returns {@link TaskSchedulingInfo} which consists - * - list of scheduled task names (empty list if nothing to schedule), - * or {@code null} if no task is scheduled due to scheduling errors. - * - list of task generation errors if any - * - list of task scheduling errors if any - */ - public synchronized TaskSchedulingInfo scheduleTaskForTable(String taskType, String tableNameWithType, - @Nullable String minionInstanceTag) { - return scheduleTask(taskType, List.of(tableNameWithType), minionInstanceTag); - } - /** * Helper method to schedule tasks (all task types) for the given tables that have the tasks enabled. * Returns a map from the task type to the {@link TaskSchedulingInfo} of the tasks scheduled. */ - protected synchronized Map<String, TaskSchedulingInfo> scheduleTasks(List<String> tableNamesWithType, - boolean isLeader, @Nullable String minionInstanceTag) { + public synchronized Map<String, TaskSchedulingInfo> scheduleTasks(TaskSchedulingContext context) { _controllerMetrics.addMeteredGlobalValue(ControllerMeter.NUMBER_TIMES_SCHEDULE_TASKS_CALLED, 1L); - // Scan all table configs to get the tables with tasks enabled Map<String, List<TableConfig>> enabledTableConfigMap = new HashMap<>(); - for (String tableNameWithType : tableNamesWithType) { + Map<String, Set<String>> tableToTasksMap = context.getTableToTaskNamesMap(); + if (context.getTableToTaskNamesMap().isEmpty()) { + _pinotHelixResourceManager.getAllTables().forEach(table -> tableToTasksMap.put(table, null)); Review Comment: good point, let me refactor the code to avoid adding entries -- 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