AmatyaAvadhanula commented on code in PR #13328:
URL: https://github.com/apache/druid/pull/13328#discussion_r1018196844


##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/SeekableStreamSupervisor.java:
##########
@@ -2276,17 +2277,35 @@ public Void apply(@Nullable Boolean result)
     );
   }
 
+  /**
+   * Determines whether a given task was created by the current version of the 
supervisor.
+   * Uses the Task object mapped to this taskId in the {@code activeTaskMap}.
+   * If not found in the map, fetch it from the metadata store.
+   * @param taskGroupId task group id
+   * @param taskId task id
+   * @param activeTaskMap Set of active tasks that were pre-fetched
+   * @return true if the task was created by the current supervisor
+   */
   @VisibleForTesting
-  public boolean isTaskCurrent(int taskGroupId, String taskId)
+  public boolean isTaskCurrent(int taskGroupId, String taskId, Map<String, 
Task> activeTaskMap)
   {
-    Optional<Task> taskOptional = taskStorage.getTask(taskId);
-    if (!taskOptional.isPresent() || 
!doesTaskTypeMatchSupervisor(taskOptional.get())) {
-      return false;
+    Task genericTask;
+    if (activeTaskMap == null || !activeTaskMap.containsKey(taskId)) {
+      Optional<Task> taskOptional = taskStorage.getTask(taskId);
+      if (!taskOptional.isPresent() || 
!doesTaskTypeMatchSupervisor(taskOptional.get())) {
+        return false;
+      }
+      genericTask = (SeekableStreamIndexTask<PartitionIdType, 
SequenceOffsetType, RecordType>) taskOptional.get();
+    } else {
+      if (!doesTaskTypeMatchSupervisor(activeTaskMap.get(taskId))) {
+        return false;
+      }
+      genericTask = (SeekableStreamIndexTask<PartitionIdType, 
SequenceOffsetType, RecordType>) activeTaskMap.get(taskId);

Review Comment:
   Done



-- 
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