Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/content/operations/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,9 @@ Endpoint for submitting tasks and supervisor specs to the overlord. Returns the

Shuts down a task.

* `druid/indexer/v1/task/{dataSource}/shutdownAllTasks`

Shuts down all tasks for a dataSource.

## MiddleManager

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,28 @@ public Response apply(TaskQueue taskQueue)
);
}

@POST
@Path("/task/{dataSource}/shutdownAllTasks")
@Produces(MediaType.APPLICATION_JSON)
public Response shutdownTasksForDataSource(@PathParam("dataSource") final String dataSource)
{
return asLeaderWith(
taskMaster.getTaskQueue(),
new Function<TaskQueue, Response>()
{
@Override
public Response apply(TaskQueue taskQueue)
{
final List<TaskInfo<Task, TaskStatus>> tasks = taskStorageQueryAdapter.getActiveTaskInfo(dataSource);
for (final TaskInfo<Task, TaskStatus> task : tasks) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe tasks.parallelStream().forEach(t -> taskQueue.shutdown(t.getId())) will be better.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think so, taskQueue.shutdown is a synchronized operation. Use parallelStream has no performance improvement.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right. Even if ReentrantLock is good at handling with concurrent scenes, we should not try to use parallelStream here. I didn't notice it. My fault. Forget it, what do you think of converting it into a more functional programming style, such as tasks.forEach(t -> taskQueue.shutdown(t.getId()))?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is no need. Other for loop code in class OverlordResource are not functional programming style. Coding style should keep consistency.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, it's up to you. 😅

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree that it's good to be consistent within a file, and the rest of this file is totally down with for loops.

taskQueue.shutdown(task.getId());
}
return Response.ok(ImmutableMap.of("dataSource", dataSource)).build();
}
}
);
}

@POST
@Path("/taskStatus")
@Produces(MediaType.APPLICATION_JSON)
Expand Down