ruanwenjun commented on code in PR #11088:
URL: https://github.com/apache/dolphinscheduler/pull/11088#discussion_r926630567
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskInstanceServiceImpl.java:
##########
@@ -194,6 +198,24 @@ public Map<String, Object> forceTaskSuccess(User
loginUser, long projectCode, In
return result;
}
+ ProcessInstance processInstance =
processService.findProcessInstanceDetailById(task.getProcessInstanceId());
+ if (processInstance != null &&
(processInstance.getState().typeIsFailure() ||
processInstance.getState().typeIsCancel())) {
+ List<TaskInstance> validTaskList =
processService.findValidTaskListByProcessId(processInstance.getId());
+ List<Long> instanceTaskCodeList =
validTaskList.stream().map(TaskInstance::getTaskCode).collect(Collectors.toList());
+ List<ProcessTaskRelation> taskRelations =
processService.findRelationByCode(processInstance.getProcessDefinitionCode(),
+ processInstance.getProcessDefinitionVersion());
+ List<TaskDefinitionLog> taskDefinitionLogs =
processService.genTaskDefineList(taskRelations);
+ List<Long> definiteTaskCodeList =
taskDefinitionLogs.stream().filter(definitionLog -> definitionLog.getFlag() ==
Flag.YES)
+ .map(TaskDefinitionLog::getCode).collect(Collectors.toList());
+ if (CollectionUtils.equalLists(instanceTaskCodeList,
definiteTaskCodeList)) {
+ List<Integer> failTaskList =
validTaskList.stream().filter(instance -> instance.getState().typeIsFailure()
|| instance.getState().typeIsCancel())
+ .map(TaskInstance::getId).collect(Collectors.toList());
+ if (failTaskList.size() == 1 &&
failTaskList.contains(taskInstanceId)) {
Review Comment:
It's better to update the taskInstance and then judge if the
workflowInstance is success, if the workflow success, we can update the
workflow status to success.
The advantage of creating a method to judge a workflowInstance success it
that this method can be used in other place.
--
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]