This is an automated email from the ASF dual-hosted git repository.

gian pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-druid.git


The following commit(s) were added to refs/heads/master by this push:
     new b0cf8d0  'shutdownAllTasks' API for a dataSource (#6185)
b0cf8d0 is described below

commit b0cf8d02525ee9324de3844c5273b96af6019361
Author: QiuMM <csurj...@gmail.com>
AuthorDate: Sat Aug 18 00:57:09 2018 +0800

    '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
---
 docs/content/operations/api-reference.md           |  3 +++
 .../indexing/overlord/http/OverlordResource.java   | 22 ++++++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/docs/content/operations/api-reference.md 
b/docs/content/operations/api-reference.md
index d933c4f..a38be3b 100644
--- a/docs/content/operations/api-reference.md
+++ b/docs/content/operations/api-reference.md
@@ -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
 
diff --git 
a/indexing-service/src/main/java/io/druid/indexing/overlord/http/OverlordResource.java
 
b/indexing-service/src/main/java/io/druid/indexing/overlord/http/OverlordResource.java
index 6eb428c..3425a87 100644
--- 
a/indexing-service/src/main/java/io/druid/indexing/overlord/http/OverlordResource.java
+++ 
b/indexing-service/src/main/java/io/druid/indexing/overlord/http/OverlordResource.java
@@ -338,6 +338,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)
   @ResourceFilters(StateResourceFilter.class)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org
For additional commands, e-mail: commits-h...@druid.apache.org

Reply via email to