提交 67646214 编写于 作者: K Kohsuke Kawaguchi

Prototype label parameterization.

上级 872b4dfb
......@@ -26,6 +26,7 @@ package hudson.model;
import hudson.EnvVars;
import hudson.Util;
import hudson.model.queue.SubTask;
import hudson.scm.SCM;
import hudson.slaves.OfflineCause;
import hudson.tasks.BuildWrapper;
......@@ -256,5 +257,12 @@ public abstract class ParameterValue implements Serializable {
*/
public boolean isSensitive() {
return false;
}
}
/**
* @since 1.414
*/
public Label getAssignedLabel(SubTask task) {
return null;
}
}
......@@ -27,6 +27,8 @@ import hudson.Util;
import hudson.EnvVars;
import hudson.diagnosis.OldDataMonitor;
import hudson.model.Queue.QueueAction;
import hudson.model.labels.LabelAssignmentAction;
import hudson.model.queue.SubTask;
import hudson.tasks.BuildStep;
import hudson.tasks.BuildWrapper;
import hudson.util.VariableResolver;
......@@ -50,7 +52,7 @@ import java.util.Set;
* that were specified when scheduling.
*/
@ExportedBean
public class ParametersAction implements Action, Iterable<ParameterValue>, QueueAction, EnvironmentContributingAction {
public class ParametersAction implements Action, Iterable<ParameterValue>, QueueAction, EnvironmentContributingAction, LabelAssignmentAction {
private final List<ParameterValue> parameters;
......@@ -119,6 +121,14 @@ public class ParametersAction implements Action, Iterable<ParameterValue>, Queue
return null;
}
public Label getAssignedLabel(SubTask task) {
for (ParameterValue p : parameters) {
Label l = p.getAssignedLabel(task);
if (l!=null) return l;
}
return null;
}
public String getDisplayName() {
return Messages.ParameterAction_DisplayName();
}
......
......@@ -36,6 +36,7 @@ import static hudson.util.Iterators.reverse;
import hudson.cli.declarative.CLIMethod;
import hudson.cli.declarative.CLIResolver;
import hudson.model.labels.LabelAssignmentAction;
import hudson.model.queue.AbstractQueueTask;
import hudson.model.queue.Executables;
import hudson.model.queue.SubTask;
......@@ -678,10 +679,10 @@ public class Queue extends ResourceController implements Saveable {
public synchronized int countBuildableItemsFor(Label l) {
int r = 0;
for (BuildableItem bi : buildables.values())
if(bi.task.getAssignedLabel()==l)
if(bi.getAssignedLabel()==l)
r++;
for (BuildableItem bi : pendings.values())
if(bi.task.getAssignedLabel()==l)
if(bi.getAssignedLabel()==l)
r++;
return r;
}
......@@ -960,7 +961,7 @@ public class Queue extends ResourceController implements Saveable {
for (Node n : h.getNodes())
hash.add(n,n.getNumExecutors()*100);
Label lbl = p.task.getAssignedLabel();
Label lbl = p.getAssignedLabel();
for (Node n : hash.list(p.task.getFullDisplayName())) {
Computer c = n.toComputer();
if (c==null || c.isOffline()) continue;
......@@ -1215,6 +1216,14 @@ public class Queue extends ResourceController implements Saveable {
*/
public Future<Executable> getFuture() { return future; }
public Label getAssignedLabel() {
for (LabelAssignmentAction laa : getActions(LabelAssignmentAction.class)) {
Label l = laa.getAssignedLabel(task);
if (l!=null) return l;
}
return task.getAssignedLabel();
}
/**
* Convenience method that returns a read only view of the {@link Cause}s associated with this item in the queue.
*
......@@ -1448,7 +1457,7 @@ public class Queue extends ResourceController implements Saveable {
if(ifBlockedByHudsonShutdown(task))
return CauseOfBlockage.fromMessage(Messages._Queue_HudsonIsAboutToShutDown());
Label label = task.getAssignedLabel();
Label label = getAssignedLabel();
if (hudson.getNodes().isEmpty())
label = null; // no master/slave. pointless to talk about nodes
......@@ -1470,7 +1479,7 @@ public class Queue extends ResourceController implements Saveable {
@Override
public boolean isStuck() {
Label label = task.getAssignedLabel();
Label label = getAssignedLabel();
if(label!=null && label.isOffline())
// no executor online to process this job. definitely stuck.
return true;
......
package hudson.model.labels;
import hudson.model.Action;
import hudson.model.Label;
import hudson.model.queue.SubTask;
/**
* @author Kohsuke Kawaguchi
*/
public interface LabelAssignmentAction extends Action {
Label getAssignedLabel(SubTask task);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册