amaoisnb commented on code in PR #14569:
URL: 
https://github.com/apache/dolphinscheduler/pull/14569#discussion_r1303688092


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/AbstractCommandExecutor.java:
##########
@@ -125,6 +128,32 @@ public TaskResponse run(IShellInterceptorBuilder 
iShellInterceptorBuilder,
             result.setExitStatusCode(EXIT_CODE_KILL);
             return result;
         }
+        // the task instance needs fault tolerance
+        if(Objects.nonNull(taskRequest.getProcessId()) || 
StringUtils.isNotEmpty(taskRequest.getAppIds())){
+
+            int pid = taskRequest.getProcessId();
+            // Yarn task is determined by parsing whether the task log 
contains the content of the application
+            String applicationId  = String.join(TaskConstants.COMMA, 
LogUtils.getAppIds(taskRequest.getLogPath(), taskRequest.getAppInfoPath(),
+                    PropertyUtils.getString(APPID_COLLECT, 
DEFAULT_COLLECT_WAY)));
+            boolean isRunningTaskFaultTolerance = false;
+            if(applicationId.isEmpty()){
+                // not a Yarn task
+                isRunningTaskFaultTolerance = isProcessRunning(pid);
+            }else {
+                // is a Yarn task
+                isRunningTaskFaultTolerance = 
isApplicationRunning(applicationId);
+            }
+            //determines whether the task is running
+            if(Boolean.TRUE.equals(isRunningTaskFaultTolerance)){
+                logger.warn(
+                        "Can not recover tolerance fault task instance: {} , 
the task may be running and does not need to be repeated",
+                        taskInstanceId);
+                result.setExitStatusCode(EXIT_CODE_KILL);
+                cancelApplication();
+                return result;

Review Comment:
   Okay, I'll adjust



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