surekhasaharan commented on a change in pull request #6185: 'shutdownAllTasks'
API for a dataSource
URL: https://github.com/apache/incubator-druid/pull/6185#discussion_r210754293
##########
File path:
indexing-service/src/main/java/io/druid/indexing/overlord/http/OverlordResource.java
##########
@@ -350,24 +350,12 @@ public Response
shutdownTasksForDataSource(@PathParam("dataSource") final String
public Response apply(TaskQueue taskQueue)
{
final List<Task> tasks = taskStorageQueryAdapter.getActiveTasks();
- boolean ownTask = false;
for (final Task task : tasks) {
if (task.getDataSource().equals(dataSource)) {
taskQueue.shutdown(task.getId());
- ownTask = true;
}
}
Review comment:
You can also use this API `getActiveTaskInfo(@Nullable String dataSource)`
which takes a `dataSource` as argument and filters at the DB query time, so you
will only get the matching `dataSource` active tasks. So like below. It might
be efficient as you don't have to compare every task's dataSource in the for
loop.
```
final List<TaskInfo<Task, TaskStatus>> tasks =
taskStorageQueryAdapter.getActiveTaskInfo(dataSource);
for (final TaskInfo<Task, TaskStatus> task : tasks) {
taskQueue.shutdown(task.getId());
}```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]