This is an automated email from the ASF dual-hosted git repository.
kharekartik pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new 11d64d08f5 Make task manager APIs database aware (#12766)
11d64d08f5 is described below
commit 11d64d08f5f536d13cd449bf6ffe6f36f463e7bb
Author: Shounak kulkarni <[email protected]>
AuthorDate: Wed Apr 3 18:58:54 2024 +0500
Make task manager APIs database aware (#12766)
* Deprecate getAllTables() in favour of getAllTables(databaseName)
* Expect database context for scheduling tasks
* test fixes
---
.../api/resources/PinotTaskRestletResource.java | 6 ++--
.../helix/core/minion/PinotTaskManager.java | 33 ++++++++++++++++++----
2 files changed, 32 insertions(+), 7 deletions(-)
diff --git
a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTaskRestletResource.java
b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTaskRestletResource.java
index f6b38fdc88..fbee62fc71 100644
---
a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTaskRestletResource.java
+++
b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTaskRestletResource.java
@@ -104,6 +104,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.apache.pinot.spi.utils.CommonConstants.DATABASE;
+import static org.apache.pinot.spi.utils.CommonConstants.DEFAULT_DATABASE;
import static
org.apache.pinot.spi.utils.CommonConstants.SWAGGER_AUTHORIZATION_KEY;
@@ -618,17 +619,18 @@ public class PinotTaskRestletResource {
public Map<String, String> scheduleTasks(@ApiParam(value = "Task type")
@QueryParam("taskType") String taskType,
@ApiParam(value = "Table name (with type suffix)")
@QueryParam("tableName") String tableName,
@Context HttpHeaders headers) {
+ String database = headers != null ? headers.getHeaderString(DATABASE) :
DEFAULT_DATABASE;
if (taskType != null) {
// Schedule task for the given task type
String taskName = tableName != null
? _pinotTaskManager.scheduleTask(taskType,
DatabaseUtils.translateTableName(tableName, headers))
- : _pinotTaskManager.scheduleTask(taskType);
+ : _pinotTaskManager.scheduleTask(taskType, database);
return Collections.singletonMap(taskType, taskName);
} else {
// Schedule tasks for all task types
return tableName != null
?
_pinotTaskManager.scheduleTasks(DatabaseUtils.translateTableName(tableName,
headers))
- : _pinotTaskManager.scheduleTasks();
+ : _pinotTaskManager.scheduleTasksForDatabase(database);
}
}
diff --git
a/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/minion/PinotTaskManager.java
b/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/minion/PinotTaskManager.java
index d2086dfb1c..f656108cb7 100644
---
a/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/minion/PinotTaskManager.java
+++
b/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/minion/PinotTaskManager.java
@@ -479,11 +479,22 @@ public class PinotTaskManager extends
ControllerPeriodicTask<Void> {
}
/**
- * Public API to schedule tasks (all task types) for all tables. It might be
called from the non-leader controller.
+ * Public API to schedule tasks (all task types) for all tables in default
database.
+ * It might be called from the non-leader controller.
* Returns a map from the task type to the task scheduled.
*/
+ @Deprecated
public synchronized Map<String, String> scheduleTasks() {
- return scheduleTasks(_pinotHelixResourceManager.getAllTables(), false);
+ return
scheduleTasks(_pinotHelixResourceManager.getAllTables(CommonConstants.DEFAULT_DATABASE),
false);
+ }
+
+ /**
+ * Public API to schedule tasks (all task types) for all tables in given
database.
+ * It might be called from the non-leader controller.
+ * Returns a map from the task type to the task scheduled.
+ */
+ public synchronized Map<String, String> scheduleTasksForDatabase(String
database) {
+ return scheduleTasks(_pinotHelixResourceManager.getAllTables(database),
false);
}
/**
@@ -597,17 +608,29 @@ public class PinotTaskManager extends
ControllerPeriodicTask<Void> {
}
/**
- * Public API to schedule task for the given task type. It might be called
from the non-leader controller. Returns the
- * task name, or {@code null} if no task is scheduled.
+ * Public API to schedule task for the given task type in default database.
+ * It might be called from the non-leader controller.
+ * Returns the task name, or {@code null} if no task is scheduled.
*/
+ @Deprecated
@Nullable
public synchronized String scheduleTask(String taskType) {
+ return scheduleTaskForDatabase(taskType, CommonConstants.DEFAULT_DATABASE);
+ }
+
+ /**
+ * Public API to schedule task for the given task type in given database.
+ * It might be called from the non-leader controller.
+ * Returns the task name, or {@code null} if no task is scheduled.
+ */
+ @Nullable
+ public synchronized String scheduleTaskForDatabase(String taskType, String
database) {
PinotTaskGenerator taskGenerator =
_taskGeneratorRegistry.getTaskGenerator(taskType);
Preconditions.checkState(taskGenerator != null, "Task type: %s is not
registered", taskType);
// Scan all table configs to get the tables with task enabled
List<TableConfig> enabledTableConfigs = new ArrayList<>();
- for (String tableNameWithType : _pinotHelixResourceManager.getAllTables())
{
+ for (String tableNameWithType :
_pinotHelixResourceManager.getAllTables(database)) {
TableConfig tableConfig =
_pinotHelixResourceManager.getTableConfig(tableNameWithType);
if (tableConfig != null && tableConfig.getTaskConfig() != null &&
tableConfig.getTaskConfig()
.isTaskTypeEnabled(taskType)) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]