'shutdownAllTasks' API for a dataSource (#6185)

* 'shutdownAllTasks' API for a dataSource

Change-Id: I30d14390457d39e0427d23a48f4f224223dc5777

* fix api path and return

Change-Id: Ib463f31ee2c4cb168cf2697f149be845b57c42e5

* optimize implementation

Change-Id: I50a8dcd44dd9d36c9ecbfa78e103eb9bff32eab9
This commit is contained in:
QiuMM 2018-08-18 00:57:09 +08:00 committed by Gian Merlino
parent 1c8032f9f3
commit b0cf8d0252
2 changed files with 25 additions and 0 deletions

View File

@ -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

View File

@ -337,6 +337,28 @@ public class OverlordResource
);
}
@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) {
taskQueue.shutdown(task.getId());
}
return Response.ok(ImmutableMap.of("dataSource", dataSource)).build();
}
}
);
}
@POST
@Path("/taskStatus")
@Produces(MediaType.APPLICATION_JSON)