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 2022/08/15 14:41:03 UTC

[GitHub] [druid] panhongan commented on a diff in pull request #11296: Fix future control bug for taskClient.pause

panhongan commented on code in PR #11296:
URL: https://github.com/apache/druid/pull/11296#discussion_r945818295


##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/SeekableStreamIndexTaskClient.java:
##########
@@ -376,10 +396,56 @@ public ListenableFuture<DateTime> getStartTimeAsync(final String id)
     return doAsync(() -> getStartTime(id));
   }
 
-
   public ListenableFuture<Map<PartitionIdType, SequenceOffsetType>> pauseAsync(final String id)
   {
-    return doAsync(() -> pause(id));
+    PauseCallable pauseCallable = new PauseCallable(id, this);
+    ListenableFuture<Map<PartitionIdType, SequenceOffsetType>> future = doAsync(pauseCallable);
+    pausingTaskFutureMap.put(future, pauseCallable);
+    return future;
+  }
+
+  public boolean stopUnfinishedPauseTasks()
+  {
+    for (Map.Entry<ListenableFuture<Map<PartitionIdType, SequenceOffsetType>>, PauseCallable> entry : pausingTaskFutureMap.entrySet()) {
+      ListenableFuture<Map<PartitionIdType, SequenceOffsetType>> future = entry.getKey();
+      PauseCallable pauseCallable = entry.getValue();
+
+      if (!future.isDone()) {
+        this.stopPausingTask(future, pauseCallable);
+        log.info("Stop unfinished pause task [%s]", pauseCallable.getTaskId());
+      } else {
+        log.info("Finished pause task [%s]", pauseCallable.getTaskId());
+      }
+    }
+
+    pausingTaskFutureMap.clear();
+    waitPausingTaskFinishedMap.clear();
+
+    return true;

Review Comment:
   I thought `boolean type` can be easy to test. Now I change to `void` type.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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