reele commented on code in PR #17372:
URL: 
https://github.com/apache/dolphinscheduler/pull/17372#discussion_r2244135494


##########
dolphinscheduler-task-executor/src/main/java/org/apache/dolphinscheduler/task/executor/eventbus/TaskExecutorLifecycleEventRemoteReporter.java:
##########
@@ -164,6 +169,24 @@ public Map<Integer, 
ReportableTaskExecutorLifecycleEventChannel> getEventChannel
         return eventChannels;
     }
 
+    /**
+     * Extend the lifecycle of the TaskExecutor to span the entire processing 
cycle of the task.
+     * before TaskExecutor changes to inactive, all events will put into 
channel,
+     * so we can just remove the TaskExecutor after the associated channel has 
been removed.
+     */
+    private void finalizeFinishedTaskExecutors() {
+        eventChannelsLock.lock();
+        // check if the taskExecutor is inactive and no channel exist, then we 
can publish finalize event.
+        for (final ITaskExecutor taskExecutor : 
taskExecutorRepository.getAllWaitingReport()) {
+            final Integer taskExecutorId = taskExecutor.getId();
+            if (!eventChannels.containsKey(taskExecutorId)) {
+                taskExecutorRepository.finishReport(taskExecutorId);
+                
taskExecutor.getTaskExecutorEventBus().publish(TaskExecutorFinalizeLifecycleEvent.of(taskExecutor));
+            }
+        }
+        eventChannelsLock.unlock();
+    }
+

Review Comment:
   wow... it's pretty much better!



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

Reply via email to