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


##########
dolphinscheduler-task-executor/src/main/java/org/apache/dolphinscheduler/task/executor/events/TaskExecutorFinishedLifecycleEvent.java:
##########
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.task.executor.events;
+
+import org.apache.dolphinscheduler.task.executor.ITaskExecutor;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+import lombok.experimental.SuperBuilder;
+
+@Data
+@ToString(callSuper = true)
+@EqualsAndHashCode(callSuper = true)
+@SuperBuilder
+@NoArgsConstructor
+public class TaskExecutorFinishedLifecycleEvent extends 
AbstractTaskExecutorLifecycleEvent {

Review Comment:
   Please don't import a new Event type here. We don't really need this.



##########
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:
   This is too complex. It's better to publish 
`TaskExecutorFinalizeLifecycleEvent` in `receiveTaskExecutorLifecycleEventACK` 
after receive a finished ack.



##########
dolphinscheduler-task-executor/src/main/java/org/apache/dolphinscheduler/task/executor/eventbus/TaskExecutorLifecycleEventRemoteReporter.java:
##########
@@ -138,15 +148,10 @@ public void receiveTaskExecutorLifecycleEventACK(final 
TaskExecutorLifecycleEven
     }
 
     @Override
-    public boolean reassignWorkflowInstanceHost(int taskInstanceId, String 
workflowHost) {
+    public void wake() {

Review Comment:
   It's better to revert this method, and change the implementation. Once the 
workflow host changed, we may need to reset the event's lastReportTime or set a 
new flag to mark the event need to retry now, and notify the reporter by 
`taskExecutionEventEmptyCondition.signalAll()`.



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