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

 ##########
 File path: 
indexing-service/src/main/java/io/druid/indexing/overlord/http/OverlordResource.java
 ##########
 @@ -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) {
 
 Review comment:
   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()))`?

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


With regards,
Apache Git Services

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

Reply via email to