YongGang commented on code in PR #14643:
URL: https://github.com/apache/druid/pull/14643#discussion_r1275218449


##########
extensions-contrib/kubernetes-overlord-extensions/src/main/java/org/apache/druid/k8s/overlord/KubernetesTaskRunner.java:
##########
@@ -134,46 +134,37 @@ public Optional<InputStream> streamTaskLog(String taskid, 
long offset)
   @Override
   public ListenableFuture<TaskStatus> run(Task task)
   {
-    return tasks.computeIfAbsent(
-        task.getId(), k -> new KubernetesWorkItem(task, exec.submit(() -> 
runTask(task)))
-    ).getResult();
+    return runOrJoinTask(task, true);
   }
 
-  protected ListenableFuture<TaskStatus> joinAsync(Task task)
+  protected ListenableFuture<TaskStatus> runOrJoinTask(Task task, boolean run)
   {
-    return tasks.computeIfAbsent(
-        task.getId(), k -> new KubernetesWorkItem(task, exec.submit(() -> 
joinTask(task)))
-    ).getResult();
-  }
-
-  private TaskStatus runTask(Task task)
-  {
-    return doTask(task, true);
-  }
-
-  private TaskStatus joinTask(Task task)
-  {
-    return doTask(task, false);
+    synchronized (tasks) {
+      tasks.computeIfAbsent(task.getId(), k -> new KubernetesWorkItem(task, 
exec.submit(() -> doTask(task, run))));
+      return tasks.get(task.getId()).getResult();

Review Comment:
   Updated.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to