提交 31d97920 编写于 作者: K kohsuke

exposing more contextual information to MappingWorksheet

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@35545 71c3de6d-444a-0410-be80-ed276b4c234a
上级 dced4d4c
......@@ -751,7 +751,7 @@ public class Queue extends ResourceController implements Saveable {
if(j.canTake(p.task))
candidates.add(j);
Mapping m = loadBalancer.map(p.task, new MappingWorksheet(p.task, candidates));
Mapping m = loadBalancer.map(p.task, new MappingWorksheet(p, candidates));
if (m == null)
// if we couldn't find the executor that fits,
// just leave it in the buildables list and
......@@ -1309,7 +1309,7 @@ public class Queue extends ResourceController implements Saveable {
@Exported
public Calendar timestamp;
WaitingItem(Calendar timestamp, Task project, List<Action> actions) {
public WaitingItem(Calendar timestamp, Task project, List<Action> actions) {
super(project, actions, COUNTER.incrementAndGet(), new FutureImpl(project));
this.timestamp = timestamp;
}
......
......@@ -31,6 +31,7 @@ import hudson.model.Label;
import hudson.model.LoadBalancer;
import hudson.model.Node;
import hudson.model.Queue;
import hudson.model.Queue.BuildableItem;
import hudson.model.Queue.Executable;
import hudson.model.Queue.JobOffer;
import hudson.model.Queue.Task;
......@@ -84,6 +85,10 @@ import static java.lang.Math.*;
public class MappingWorksheet {
public final List<ExecutorChunk> executors;
public final List<WorkChunk> works;
/**
* {@link BuildableItem} for which we are trying to figure out the execution plan. Never null.
*/
public final BuildableItem item;
private static class ReadOnlyList<E> extends AbstractList<E> {
protected final List<E> base;
......@@ -276,7 +281,9 @@ public class MappingWorksheet {
}
public MappingWorksheet(Task task, List<JobOffer> offers) {
public MappingWorksheet(BuildableItem item, List<JobOffer> offers) {
this.item = item;
// group executors by their computers
Map<Computer,List<JobOffer>> j = new HashMap<Computer, List<JobOffer>>();
for (JobOffer o : offers) {
......@@ -288,7 +295,7 @@ public class MappingWorksheet {
}
{// take load prediction into account and reduce the available executor pool size accordingly
long duration = task.getEstimatedDuration();
long duration = item.task.getEstimatedDuration();
if (duration > 0) {
long now = System.currentTimeMillis();
for (Entry<Computer, List<JobOffer>> e : j.entrySet()) {
......@@ -325,7 +332,7 @@ public class MappingWorksheet {
// group execution units into chunks. use of LinkedHashMap ensures that the main work comes at the top
Map<Object,List<SubTask>> m = new LinkedHashMap<Object,List<SubTask>>();
for (SubTask meu : Tasks.getSubTasksOf(task)) {
for (SubTask meu : Tasks.getSubTasksOf(item.task)) {
Object c = Tasks.getSameNodeConstraintOf(meu);
if (c==null) c = new Object();
......
......@@ -23,17 +23,20 @@
*/
package hudson.model.queue;
import hudson.model.Action;
import hudson.model.Computer;
import hudson.model.Executor;
import hudson.model.Node;
import hudson.model.Queue;
import hudson.model.Queue.BuildableItem;
import hudson.model.Queue.JobOffer;
import hudson.model.Queue.Task;
import hudson.model.Queue.WaitingItem;
import org.jvnet.hudson.test.HudsonTestCase;
import org.jvnet.hudson.test.TestExtension;
import java.lang.reflect.Field;
import java.util.Collection;
import java.util.List;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import static java.util.Arrays.*;
......@@ -69,13 +72,17 @@ public class LoadPredictorTest extends HudsonTestCase {
JobOffer o = createMockOffer(c.getExecutors().get(0));
MappingWorksheet mw = new MappingWorksheet(t, asList(o));
MappingWorksheet mw = new MappingWorksheet(wrap(t), asList(o));
// the test load predictor should have pushed down the executor count to 0
assertTrue(mw.executors.isEmpty());
assertEquals(1,mw.works.size());
}
private BuildableItem wrap(Queue.Task t) {
return new BuildableItem(new WaitingItem(new GregorianCalendar(),t,new ArrayList<Action>()));
}
/**
* Test scenario is:
*
......@@ -97,7 +104,7 @@ public class LoadPredictorTest extends HudsonTestCase {
JobOffer o = createMockOffer(c.getExecutors().get(1));
MappingWorksheet mw = new MappingWorksheet(t, asList(o));
MappingWorksheet mw = new MappingWorksheet(wrap(t), asList(o));
// since the currently busy executor will free up before a future predicted load starts,
// we should have a valid executor remain in the queue
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册