mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-08 01:26:03 +00:00
Queue has too many inner classes to make it hard to read.
Moving some of the pieces into its own package. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@22948 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
5c5274bc24
commit
fa3a50b96f
14 files changed
+237
-41
No files matched your search
@@ -24,7 +24,6 @@
|
||||
package hudson.matrix;
|
||||
|
||||
import hudson.CopyOnWrite;
|
||||
import hudson.FilePath;
|
||||
import hudson.XmlFile;
|
||||
import hudson.Util;
|
||||
import hudson.Extension;
|
||||
@@ -39,12 +38,10 @@ import hudson.model.Items;
|
||||
import hudson.model.JDK;
|
||||
import hudson.model.Job;
|
||||
import hudson.model.Label;
|
||||
import hudson.model.Node;
|
||||
import hudson.model.Result;
|
||||
import hudson.model.SCMedItem;
|
||||
import hudson.model.Saveable;
|
||||
import hudson.model.TopLevelItem;
|
||||
import hudson.model.TopLevelItemDescriptor;
|
||||
import hudson.model.ResourceController;
|
||||
import hudson.model.Queue.FlyweightTask;
|
||||
import hudson.model.Descriptor.FormException;
|
||||
|
||||
@@ -38,7 +38,7 @@ import hudson.model.Fingerprint.RangeSet;
|
||||
import hudson.model.RunMap.Constructor;
|
||||
import hudson.model.Queue.WaitingItem;
|
||||
import hudson.model.Queue.Executable;
|
||||
import hudson.model.Queue.CauseOfBlockage;
|
||||
import hudson.model.queue.CauseOfBlockage;
|
||||
import hudson.scm.ChangeLogSet;
|
||||
import hudson.scm.ChangeLogSet.Entry;
|
||||
import hudson.scm.NullSCM;
|
||||
|
||||
@@ -32,6 +32,11 @@ import hudson.cli.declarative.CLIMethod;
|
||||
import hudson.cli.declarative.CLIResolver;
|
||||
import hudson.remoting.AsyncFutureImpl;
|
||||
import hudson.model.Node.Mode;
|
||||
import hudson.model.queue.CauseOfBlockage;
|
||||
import hudson.model.queue.CauseOfBlockage.BecauseLabelIsBusy;
|
||||
import hudson.model.queue.CauseOfBlockage.BecauseNodeIsOffline;
|
||||
import hudson.model.queue.CauseOfBlockage.BecauseLabelIsOffline;
|
||||
import hudson.model.queue.CauseOfBlockage.BecauseNodeIsBusy;
|
||||
import hudson.triggers.SafeTimerTask;
|
||||
import hudson.triggers.Trigger;
|
||||
import hudson.util.OneShotEvent;
|
||||
@@ -71,7 +76,6 @@ import org.kohsuke.stapler.StaplerRequest;
|
||||
import org.kohsuke.stapler.StaplerResponse;
|
||||
import org.kohsuke.stapler.export.Exported;
|
||||
import org.kohsuke.stapler.export.ExportedBean;
|
||||
import org.jvnet.localizer.Localizable;
|
||||
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.converters.basic.AbstractSingleValueConverter;
|
||||
@@ -948,32 +952,6 @@ public class Queue extends ResourceController implements Saveable {
|
||||
*/
|
||||
public interface FlyweightTask extends Task {}
|
||||
|
||||
/**
|
||||
* If a {@link Task} execution is blocked in the queue, this object represents why.
|
||||
*
|
||||
* <h2>View</h2>
|
||||
* <tt>summary.jelly</tt> should do one-line HTML rendering to be used while rendering
|
||||
* "build history" widget, next to the blocking build. By default it simply renders
|
||||
* {@link #getShortDescription()} text.
|
||||
*/
|
||||
public abstract static class CauseOfBlockage {
|
||||
/**
|
||||
* Human readable description of why the build is blocked.
|
||||
*/
|
||||
public abstract String getShortDescription();
|
||||
|
||||
/**
|
||||
* Obtains a simple implementation backed by {@link Localizable}.
|
||||
*/
|
||||
public static CauseOfBlockage fromMessage(final Localizable l) {
|
||||
return new CauseOfBlockage() {
|
||||
public String getShortDescription() {
|
||||
return l.toString();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Task whose execution is controlled by the queue.
|
||||
*
|
||||
@@ -1416,21 +1394,20 @@ public class Queue extends ResourceController implements Saveable {
|
||||
if (hudson.getNodes().isEmpty())
|
||||
label = null; // no master/slave. pointless to talk about nodes
|
||||
|
||||
String name = null;
|
||||
if (label != null) {
|
||||
name = label.getName();
|
||||
if (label.isOffline()) {
|
||||
if (label.getNodes().size() > 1)
|
||||
return CauseOfBlockage.fromMessage(Messages._Queue_AllNodesOffline(name));
|
||||
else
|
||||
return CauseOfBlockage.fromMessage(Messages._Queue_NodeOffline(name));
|
||||
Set<Node> nodes = label.getNodes();
|
||||
if (nodes.size() > 1) return new BecauseLabelIsOffline(label);
|
||||
else return new BecauseNodeIsOffline(nodes.iterator().next());
|
||||
}
|
||||
}
|
||||
|
||||
if(name==null)
|
||||
if(label==null)
|
||||
return CauseOfBlockage.fromMessage(Messages._Queue_WaitingForNextAvailableExecutor());
|
||||
else
|
||||
return CauseOfBlockage.fromMessage(Messages._Queue_WaitingForNextAvailableExecutorOn(name));
|
||||
|
||||
Set<Node> nodes = label.getNodes();
|
||||
if (nodes.size() > 1) return new BecauseLabelIsBusy(label);
|
||||
else return new BecauseNodeIsBusy(nodes.iterator().next());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
package hudson.model.queue;
|
||||
|
||||
import hudson.model.Queue.Task;
|
||||
import hudson.model.Node;
|
||||
import hudson.model.Messages;
|
||||
import hudson.model.Label;
|
||||
import org.jvnet.localizer.Localizable;
|
||||
|
||||
/**
|
||||
* If a {@link Task} execution is blocked in the queue, this object represents why.
|
||||
*
|
||||
* <h2>View</h2>
|
||||
* <tt>summary.jelly</tt> should do one-line HTML rendering to be used while rendering
|
||||
* "build history" widget, next to the blocking build. By default it simply renders
|
||||
* {@link #getShortDescription()} text.
|
||||
*
|
||||
* @since 1.330
|
||||
*/
|
||||
public abstract class CauseOfBlockage {
|
||||
/**
|
||||
* Human readable description of why the build is blocked.
|
||||
*/
|
||||
public abstract String getShortDescription();
|
||||
|
||||
/**
|
||||
* Obtains a simple implementation backed by {@link Localizable}.
|
||||
*/
|
||||
public static CauseOfBlockage fromMessage(final Localizable l) {
|
||||
return new CauseOfBlockage() {
|
||||
public String getShortDescription() {
|
||||
return l.toString();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Build is blocked because a node is offline.
|
||||
*/
|
||||
public static final class BecauseNodeIsOffline extends CauseOfBlockage {
|
||||
public final Node node;
|
||||
|
||||
public BecauseNodeIsOffline(Node node) {
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
public String getShortDescription() {
|
||||
return Messages.Queue_NodeOffline(node.getDisplayName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build is blocked because all the nodes in a given label is offline.
|
||||
*/
|
||||
public static final class BecauseLabelIsOffline extends CauseOfBlockage {
|
||||
public final Label label;
|
||||
|
||||
public BecauseLabelIsOffline(Label l) {
|
||||
this.label = l;
|
||||
}
|
||||
|
||||
public String getShortDescription() {
|
||||
return Messages.Queue_AllNodesOffline(label.getName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build is blocked because a node is fully busy
|
||||
*/
|
||||
public static final class BecauseNodeIsBusy extends CauseOfBlockage {
|
||||
public final Node node;
|
||||
|
||||
public BecauseNodeIsBusy(Node node) {
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
public String getShortDescription() {
|
||||
return Messages.Queue_WaitingForNextAvailableExecutorOn(node.getNodeName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build is blocked because a node is fully busy
|
||||
*/
|
||||
public static final class BecauseLabelIsBusy extends CauseOfBlockage {
|
||||
public final Label label;
|
||||
|
||||
public BecauseLabelIsBusy(Label label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getShortDescription() {
|
||||
return Messages.Queue_WaitingForNextAvailableExecutorOn(label.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user