提交 af55e534 编写于 作者: A Andrey Klochkov

Take subtasks into account when deciding to provision new nodes

上级 c49d6b5b
...@@ -26,6 +26,8 @@ package hudson.model; ...@@ -26,6 +26,8 @@ package hudson.model;
import hudson.Extension; import hudson.Extension;
import hudson.model.MultiStageTimeSeries.TimeScale; import hudson.model.MultiStageTimeSeries.TimeScale;
import hudson.model.MultiStageTimeSeries.TrendChart; import hudson.model.MultiStageTimeSeries.TrendChart;
import hudson.model.queue.SubTask;
import hudson.model.queue.Tasks;
import hudson.util.ColorPalette; import hudson.util.ColorPalette;
import hudson.util.NoOverlapCategoryAxis; import hudson.util.NoOverlapCategoryAxis;
import jenkins.model.Jenkins; import jenkins.model.Jenkins;
...@@ -232,6 +234,9 @@ public abstract class LoadStatistics { ...@@ -232,6 +234,9 @@ public abstract class LoadStatistics {
for (Queue.BuildableItem bi : bis) { for (Queue.BuildableItem bi : bis) {
if(bi.task.getAssignedLabel()==l) if(bi.task.getAssignedLabel()==l)
q++; q++;
for (SubTask st : Tasks.getSubTasksOf(bi.task))
if (st != bi.task && st.getAssignedLabel()==l)
q++;
} }
return q; return q;
} }
......
...@@ -756,11 +756,19 @@ public class Queue extends ResourceController implements Saveable { ...@@ -756,11 +756,19 @@ public class Queue extends ResourceController implements Saveable {
public synchronized int countBuildableItemsFor(Label l) { public synchronized int countBuildableItemsFor(Label l) {
int r = 0; int r = 0;
for (BuildableItem bi : buildables.values()) for (BuildableItem bi : buildables.values())
if(bi.getAssignedLabel()==l) if(null==l || bi.getAssignedLabel()==l) {
r++; r++;
for (SubTask st : bi.task.getSubTasks())
if (st != bi.task && (null==l || st.getAssignedLabel()==l))
r++;
}
for (BuildableItem bi : pendings.values()) for (BuildableItem bi : pendings.values())
if(bi.getAssignedLabel()==l) if(bi.getAssignedLabel()==l) {
r++; r++;
for (SubTask st : bi.task.getSubTasks())
if (st != bi.task && (null==l || st.getAssignedLabel()==l))
r++;
}
return r; return r;
} }
...@@ -768,7 +776,7 @@ public class Queue extends ResourceController implements Saveable { ...@@ -768,7 +776,7 @@ public class Queue extends ResourceController implements Saveable {
* Counts all the {@link BuildableItem}s currently in the queue. * Counts all the {@link BuildableItem}s currently in the queue.
*/ */
public synchronized int countBuildableItems() { public synchronized int countBuildableItems() {
return buildables.size()+pendings.size(); return countBuildableItemsFor(null);
} }
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册