ruanwenjun commented on code in PR #18736:
URL: 
https://github.com/apache/dolphinscheduler/pull/18736#discussion_r4537595735


##########
dolphinscheduler-task-executor/src/main/java/org/apache/dolphinscheduler/task/executor/eventbus/TaskExecutorLifecycleEventRemoteReporter.java:
##########
@@ -179,13 +191,22 @@ public Map<Integer, 
ReportableTaskExecutorLifecycleEventChannel> getEventChannel
         return eventChannels;
     }
 
-    private void finalizeTaskExecutor(final Integer taskExecutorId) {
-        final Optional<ITaskExecutor> taskExecutorOptional = 
taskExecutorRepository.get(taskExecutorId);
-        if (taskExecutorOptional.isPresent()) {
-            taskExecutorOptional.get().getTaskExecutorEventBus()
-                    
.publish(TaskExecutorFinalizeLifecycleEvent.of(taskExecutorOptional.get()));
-        } else {
-            log.warn("TaskExecutor is not exists: {}", taskExecutorId);
+    private boolean expireFinishedTaskEventChannel(final 
ReportableTaskExecutorLifecycleEventChannel eventChannel) {
+        eventChannelsLock.lock();
+        try {
+            if (eventChannel.finishedTime == null
+                    || System.currentTimeMillis() - eventChannel.finishedTime 
< taskEventReportMaxDurationMillis) {
+                return false;
+            }
+            if (eventChannels.remove(eventChannel.getTaskExecutorId(), 
eventChannel)) {
+                log.error("Task executor {} result was not acknowledged within 
{} ms after completion. "
+                        + "Discarding pending events for master {}",
+                        eventChannel.getTaskExecutorId(), 
taskEventReportMaxDurationMillis,
+                        eventChannel.workflowInstanceHost);
+            }
+            return true;
+        } finally {
+            eventChannelsLock.unlock();
         }
     }

Review Comment:
   Change the method name to `removeExpiredEventChannel` and keep the 
channel-level cleanup.



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