tracehh commented on code in PR #12159:
URL: https://github.com/apache/dolphinscheduler/pull/12159#discussion_r984380581


##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/host/assign/LowerWeightRoundRobin.java:
##########
@@ -49,23 +51,28 @@ public HostWeight doSelect(Collection<HostWeight> sources) {
                 lowWeight = hostWeight.getCurrentWeight();
             }
         }
-        lowerNode.setCurrentWeight(lowerNode.getCurrentWeight() + totalWeight);
+        if (lowerNode != null) {
+            lowerNode.setCurrentWeight(lowerNode.getCurrentWeight() + 
totalWeight);
+        }
         return lowerNode;
     }
 
     private List<HostWeight> canAssignTaskHost(Collection<HostWeight> sources) 
{
-        List<HostWeight> zeroWaitingTask = sources.stream().filter(h -> 
h.getWaitingTaskCount() == 0).collect(Collectors.toList());
-        if (!zeroWaitingTask.isEmpty()) {
-            return zeroWaitingTask;
-        }
-        HostWeight hostWeight = 
sources.stream().min(Comparator.comparing(HostWeight::getWaitingTaskCount)).get();
-        List<HostWeight> waitingTask = Lists.newArrayList(hostWeight);
-        List<HostWeight> equalWaitingTask = sources.stream().filter(h -> 
!h.getHost().equals(hostWeight.getHost()) && h.getWaitingTaskCount() == 
hostWeight.getWaitingTaskCount())
-            .collect(Collectors.toList());
-        if (!equalWaitingTask.isEmpty()) {
-            waitingTask.addAll(equalWaitingTask);
+        if (!CollectionUtils.isEmpty(sources)) {

Review Comment:
   @ruanwenjun fixed



##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/dispatch/host/assign/LowerWeightRoundRobin.java:
##########
@@ -49,23 +51,28 @@ public HostWeight doSelect(Collection<HostWeight> sources) {
                 lowWeight = hostWeight.getCurrentWeight();
             }
         }
-        lowerNode.setCurrentWeight(lowerNode.getCurrentWeight() + totalWeight);
+        if (lowerNode != null) {
+            lowerNode.setCurrentWeight(lowerNode.getCurrentWeight() + 
totalWeight);
+        }
         return lowerNode;
     }
 
     private List<HostWeight> canAssignTaskHost(Collection<HostWeight> sources) 
{
-        List<HostWeight> zeroWaitingTask = sources.stream().filter(h -> 
h.getWaitingTaskCount() == 0).collect(Collectors.toList());
-        if (!zeroWaitingTask.isEmpty()) {
-            return zeroWaitingTask;
-        }
-        HostWeight hostWeight = 
sources.stream().min(Comparator.comparing(HostWeight::getWaitingTaskCount)).get();
-        List<HostWeight> waitingTask = Lists.newArrayList(hostWeight);
-        List<HostWeight> equalWaitingTask = sources.stream().filter(h -> 
!h.getHost().equals(hostWeight.getHost()) && h.getWaitingTaskCount() == 
hostWeight.getWaitingTaskCount())
-            .collect(Collectors.toList());
-        if (!equalWaitingTask.isEmpty()) {
-            waitingTask.addAll(equalWaitingTask);
+        if (!CollectionUtils.isEmpty(sources)) {

Review Comment:
   update it



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