Jackie-Jiang commented on a change in pull request #7174: URL: https://github.com/apache/pinot/pull/7174#discussion_r692560901
########## File path: pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/periodictask/ControllerPeriodicTask.java ########## @@ -54,14 +55,27 @@ public ControllerPeriodicTask(String taskName, long runFrequencyInSeconds, long _controllerMetrics = controllerMetrics; } + // Determine if this task can run on the specified table. Task can run on all tables for which the controller is lead + // if "tablename" property is not set. However, if "tablename" property is set (by calling the /periodictask/run + // controller API), then the task will only run on the specified by the "tablename" property key. + private boolean shouldRunTaskForTable(String tableNameWithType) { + if (_leadControllerManager.isLeaderForTable(tableNameWithType)) { + String propTableNameWithType = (String) _activePeriodicTaskProperties.get(PeriodicTask.PROPERTY_KEY_TABLE_NAME); + return propTableNameWithType == null || propTableNameWithType.equals(tableNameWithType); + } + return false; + } + @Override protected final void runTask() { _controllerMetrics.addMeteredTableValue(_taskName, ControllerMeter.CONTROLLER_PERIODIC_TASK_RUN, 1L); try { // Process the tables that are managed by this controller + // TODO: creating tablesToProcess list below is redundant since processTables will unroll the list anyway. This Review comment: We want to make them modular so that they can be reused. I agree current way will create one extra array, but that should not cause too much overhead (especially when not in performance critical path). With `processTables()` separate from the `runTask()`, we can override it (e.g. in `PinotTaskManager`) or reuse it. In this PR, since we might only want to process one table, we should not call `runTask()` and loop over all the tables (this overhead will be much bigger than creating an extra array), but just check if the target table is lead by the controller can call `processTables()` on one single table. -- 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