amrishlal commented on a change in pull request #7174:
URL: https://github.com/apache/pinot/pull/7174#discussion_r691550554
##########
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
+ // needs to be cleaned up sometime.
List<String> tablesToProcess = new ArrayList<>();
for (String tableNameWithType :
_pinotHelixResourceManager.getAllTables()) {
- if (_leadControllerManager.isLeaderForTable(tableNameWithType)) {
+ if (shouldRunTaskForTable(tableNameWithType)) {
Review comment:
Refactored a bit to make it more efficient.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]