You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2018/08/16 18:17:59 UTC

[GitHub] QiuMM commented on a change in pull request #6185: 'shutdownAllTasks' API for a dataSource

QiuMM commented on a change in pull request #6185: 'shutdownAllTasks' API for a dataSource
URL: https://github.com/apache/incubator-druid/pull/6185#discussion_r210693684
 
 

 ##########
 File path: indexing-service/src/main/java/io/druid/indexing/overlord/http/OverlordResource.java
 ##########
 @@ -337,6 +337,42 @@ public Response apply(TaskQueue taskQueue)
     );
   }
 
+  @POST
+  @Path("/task/{dataSource}/shutdown")
+  @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<Task> tasks = taskStorageQueryAdapter.getActiveTasks();
+            boolean ownTask = false;
+            for (final Task task : tasks) {
+              if (task.getDataSource().equals(dataSource)) {
+                taskQueue.shutdown(task.getId());
+                ownTask = true;
+              }
+            }
+
+            if (!ownTask) {
+              return Response.status(Response.Status.BAD_REQUEST)
 
 Review comment:
   If so,  I'll remove the `ownTask `  variable and return `Response.ok(ImmutableMap.of("dataSource", dataSource)).build()` for all case. Is that OK?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

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