caishunfeng commented on code in PR #10695:
URL: https://github.com/apache/dolphinscheduler/pull/10695#discussion_r929547770


##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/SubTaskProcessor.java:
##########
@@ -126,11 +136,85 @@ private void updateTaskState() {
         if (subProcessInstance != null && 
subProcessInstance.getState().typeIsFinished()) {
             taskInstance.setState(subProcessInstance.getState());
             taskInstance.setEndTime(new Date());
-            dealFinish();
+            dealFinish1();
+            //dealFinish();
             processService.saveTaskInstance(taskInstance);
         }
     }
 
+    private  Map<String, Property> mergeEndNodeTaskInstanceVarPool(Set<String> 
taskCodes) {
+        List<TaskInstance> taskInstanceList = 
processService.findValidTaskListByProcessId(subProcessInstance.getId());
+        logger.info("in dealFinish1, mergeEndNodeTaskInstanceVarPool, 
taskInstanceList.size:{}, subProcessInstance.getId:{}", 
taskInstanceList.size(),subProcessInstance.getId());
+        // filter end nodes and sort by end time reversed
+        List<TaskInstance> endTaskInstancesSortedByEndTimeReversed = 
taskInstanceList.stream()
+                .filter(o -> 
taskCodes.contains(Long.toString(o.getTaskCode()))).
+                        
sorted(Comparator.comparing(TaskInstance::getEndTime).reversed()).collect(Collectors.toList());
+        logger.info("in dealFinish1, mergeEndNodeTaskInstanceVarPool, 
endTaskInstancesSortedByEndTimeReversed.size:{}", 
endTaskInstancesSortedByEndTimeReversed.size());
+        Map<String, Property> allProperties = new HashMap<>();
+        for (TaskInstance taskInstance : 
endTaskInstancesSortedByEndTimeReversed) {
+            String varPool = taskInstance.getVarPool();
+            if (org.apache.commons.lang.StringUtils.isNotEmpty(varPool)) {
+                List<Property> properties = JSONUtils.toList(varPool, 
Property.class);
+                properties.forEach(o -> {
+                    allProperties.put(o.getProp(), o);
+                });
+            }
+        }
+        return allProperties;
+    }
+
+    private void dealFinish1() {

Review Comment:
   Please add some comments and UT for this method.



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