|
@@ -18,10 +18,13 @@
|
|
package org.apache.dolphinscheduler.server.master.dispatch.host.assign;
|
|
package org.apache.dolphinscheduler.server.master.dispatch.host.assign;
|
|
|
|
|
|
import java.util.Collection;
|
|
import java.util.Collection;
|
|
|
|
+import java.util.Collections;
|
|
import java.util.Comparator;
|
|
import java.util.Comparator;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
+
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -49,11 +52,16 @@ public class LowerWeightRoundRobin extends AbstractSelector<HostWeight> {
|
|
lowWeight = hostWeight.getCurrentWeight();
|
|
lowWeight = hostWeight.getCurrentWeight();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- lowerNode.setCurrentWeight(lowerNode.getCurrentWeight() + totalWeight);
|
|
|
|
|
|
+ if (lowerNode != null) {
|
|
|
|
+ lowerNode.setCurrentWeight(lowerNode.getCurrentWeight() + totalWeight);
|
|
|
|
+ }
|
|
return lowerNode;
|
|
return lowerNode;
|
|
}
|
|
}
|
|
|
|
|
|
private List<HostWeight> canAssignTaskHost(Collection<HostWeight> sources) {
|
|
private List<HostWeight> canAssignTaskHost(Collection<HostWeight> sources) {
|
|
|
|
+ if (CollectionUtils.isEmpty(sources)) {
|
|
|
|
+ return Collections.emptyList();
|
|
|
|
+ }
|
|
List<HostWeight> zeroWaitingTask = sources.stream().filter(h -> h.getWaitingTaskCount() == 0).collect(Collectors.toList());
|
|
List<HostWeight> zeroWaitingTask = sources.stream().filter(h -> h.getWaitingTaskCount() == 0).collect(Collectors.toList());
|
|
if (!zeroWaitingTask.isEmpty()) {
|
|
if (!zeroWaitingTask.isEmpty()) {
|
|
return zeroWaitingTask;
|
|
return zeroWaitingTask;
|