ruanwenjun commented on code in PR #17372:
URL:
https://github.com/apache/dolphinscheduler/pull/17372#discussion_r2230538743
##########
dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/executor/PhysicalTaskEngineDelegator.java:
##########
@@ -76,9 +78,14 @@ public boolean reassignWorkflowInstanceHost(final
TaskExecutorReassignMasterRequ
final int taskInstanceId =
taskExecutorReassignMasterRequest.getTaskInstanceId();
final String workflowHost =
taskExecutorReassignMasterRequest.getWorkflowHost();
// todo: Is this reassign can make sure there is no concurrent problem?
- physicalTaskExecutorRepository.get(taskInstanceId).ifPresent(
- taskExecutor ->
taskExecutor.getTaskExecutionContext().setWorkflowInstanceHost(workflowHost));
- return
physicalTaskExecutorEventReporter.reassignWorkflowInstanceHost(taskInstanceId,
workflowHost);
+ final Optional<ITaskExecutor> taskExecutorOptional =
physicalTaskExecutorRepository.get(taskInstanceId);
+
physicalTaskExecutorEventReporter.reassignWorkflowInstanceHost(taskInstanceId,
workflowHost);
+ if (taskExecutorOptional.isPresent()) {
+ final ITaskExecutor taskExecutor = taskExecutorOptional.get();
+
taskExecutor.getTaskExecutionContext().setWorkflowInstanceHost(workflowHost);
+ return true;
+ }
+ return false;
Review Comment:
```suggestion
Optional<ITaskExecutor> iTaskExecutorOptional =
physicalTaskExecutorRepository.get(taskInstanceId);
if (iTaskExecutorOptional.isPresent()) {
iTaskExecutorOptional.get().getTaskExecutionContext().setWorkflowInstanceHost(workflowHost);
return true;
}
return false;
```
It's better to only change the workflow instance host in
`TaskExecutionContext`, and inject `ITaskExecutorRepository` into
`TaskExecutorLifecycleEventRemoteReporter`.
We can remove workflowInstanceHost from
IReportableTaskExecutorLifecycleEvent, as this event does not inherently
require knowledge of the workflow instance host. Instead, when reporting the
event, the reporter should retrieve the current host from a centralized
repository. This approach simplifies workflow host management and helps prevent
potential concurrency issues that may arise if the host information is embedded
directly within the event payload.
--
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]