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());
|
||||
}
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
<!--
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2004-2009, Sun Microsystems, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
-->
|
||||
|
||||
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt">
|
||||
<st:structuredMessageFormat key="description">
|
||||
<st:structuredMessageArgument>
|
||||
<a href="${rootURL}/label/${it.label.name}">${it.label.name}</a>
|
||||
</st:structuredMessageArgument>
|
||||
</st:structuredMessageFormat>
|
||||
</j:jelly>
|
||||
+1
@@ -0,0 +1 @@
|
||||
description=Waiting for next available executor on {0}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
<!--
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2004-2009, Sun Microsystems, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
-->
|
||||
|
||||
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt">
|
||||
<st:structuredMessageFormat key="description">
|
||||
<st:structuredMessageArgument>
|
||||
<a href="${rootURL}/label/${it.label.name}">${it.label.name}</a>
|
||||
</st:structuredMessageArgument>
|
||||
</st:structuredMessageFormat>
|
||||
</j:jelly>
|
||||
+1
@@ -0,0 +1 @@
|
||||
description=All nodes of label ''{0}'' are offline
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
<!--
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2004-2009, Sun Microsystems, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
-->
|
||||
|
||||
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt">
|
||||
<st:structuredMessageFormat key="description">
|
||||
<st:structuredMessageArgument>
|
||||
<t:node value="${it.node}" />
|
||||
</st:structuredMessageArgument>
|
||||
</st:structuredMessageFormat>
|
||||
</j:jelly>
|
||||
+1
@@ -0,0 +1 @@
|
||||
description=Waiting for next available executor on {0}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
<!--
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2004-2009, Sun Microsystems, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
-->
|
||||
|
||||
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt">
|
||||
<st:structuredMessageFormat key="description">
|
||||
<st:structuredMessageArgument>
|
||||
<t:node value="${it.node}" />
|
||||
</st:structuredMessageArgument>
|
||||
</st:structuredMessageFormat>
|
||||
</j:jelly>
|
||||
+1
@@ -0,0 +1 @@
|
||||
description={0} is offline
|
||||
File renamed without changes.
@@ -35,7 +35,6 @@ import hudson.tasks.Maven.MavenInstallation;
|
||||
import hudson.tasks.*;
|
||||
import hudson.tasks.junit.JUnitResultArchiver;
|
||||
import static hudson.Util.fixEmpty;
|
||||
import static hudson.Util.fixEmptyAndTrim;
|
||||
import hudson.util.CopyOnWriteMap;
|
||||
import hudson.util.DescribableList;
|
||||
import hudson.util.Function1;
|
||||
|
||||
Reference in new issue
Block a user