File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\core\src\main\java\hudson\model\queue\CauseOfBlockage.java.html

1 package hudson.model.queue;
2
3 import hudson.console.ModelHyperlinkNote;
4 import hudson.model.Queue.Task;
5 import hudson.model.Node;
6 import hudson.model.Messages;
7 import hudson.model.Label;
8 import hudson.model.TaskListener;
9 import hudson.slaves.Cloud;
10 import org.jvnet.localizer.Localizable;
11
12 /**
13 * If a {@link Task} execution is blocked in the queue, this object represents why.
14 *
15 * <h2>View</h2>
16 * <tt>summary.jelly</tt> should do one-line HTML rendering to be used while rendering
17 * "build history" widget, next to the blocking build. By default it simply renders
18 * {@link #getShortDescription()} text.
19 *
20 * @since 1.330
21 */
22 public abstract class CauseOfBlockage {
23 /**
24 * Human readable description of why the build is blocked.
25 */
26 public abstract String getShortDescription();
27
28 /**
29 * Report a line to the listener about this cause.
30 */
31 public void print(TaskListener listener) {
32 listener.getLogger().println(getShortDescription());
33 }
34
35 /**
36 * Obtains a simple implementation backed by {@link Localizable}.
37 */
38 public static CauseOfBlockage fromMessage(final Localizable l) {
39 return new CauseOfBlockage() {
40 public String getShortDescription() {
41 return l.toString();
42 }
43 };
44 }
45
46 /**
47 * Marker interface to indicates that we can reasonably expect
48 * that adding a suitable executor/node will resolve this blockage.
49 *
50 * Primarily this is used by {@link Cloud} to see if it should
51 * consider provisioning new node.
52 *
53 * @since 1.427
54 */
55 interface NeedsMoreExecutor {}
56
57 public static CauseOfBlockage createNeedsMoreExecutor(Localizable l) {
58 return new NeedsMoreExecutorImpl(l);
59 }
60
61 private static final class NeedsMoreExecutorImpl extends CauseOfBlockage implements NeedsMoreExecutor {
62 private final Localizable l;
63
64 private NeedsMoreExecutorImpl(Localizable l) {
65 this.l = l;
66 }
67
68 public String getShortDescription() {
69 return l.toString();
70 }
71 }
72
73 /**
74 * Build is blocked because a node is offline.
75 */
76 public static final class BecauseNodeIsOffline extends CauseOfBlockage implements NeedsMoreExecutor {
77 public final Node node;
78
79 public BecauseNodeIsOffline(Node node) {
80 this.node = node;
81 }
82
83 public String getShortDescription() {
84 return Messages.Queue_NodeOffline(node.getDisplayName());
85 }
86
87 @Override
88 public void print(TaskListener listener) {
89 listener.getLogger().println(
90 Messages.Queue_NodeOffline(ModelHyperlinkNote.encodeTo(node)));
91 }
92 }
93
94 /**
95 * Build is blocked because all the nodes that match a given label is offline.
96 */
97 public static final class BecauseLabelIsOffline extends CauseOfBlockage implements NeedsMoreExecutor {
98 public final Label label;
99
100 public BecauseLabelIsOffline(Label l) {
101 this.label = l;
102 }
103
104 public String getShortDescription() {
105 return Messages.Queue_AllNodesOffline(label.getName());
106 }
107 }
108
109 /**
110 * Build is blocked because a node is fully busy
111 */
112 public static final class BecauseNodeIsBusy extends CauseOfBlockage implements NeedsMoreExecutor {
113 public final Node node;
114
115 public BecauseNodeIsBusy(Node node) {
116 this.node = node;
117 }
118
119 public String getShortDescription() {
120 return Messages.Queue_WaitingForNextAvailableExecutorOn(node.getNodeName());
121 }
122
123 @Override
124 public void print(TaskListener listener) {
125 listener.getLogger().println(Messages.Queue_WaitingForNextAvailableExecutorOn(ModelHyperlinkNote.encodeTo(node)));
126 }
127 }
128
129 /**
130 * Build is blocked because everyone that matches the specified label is fully busy
131 */
132 public static final class BecauseLabelIsBusy extends CauseOfBlockage implements NeedsMoreExecutor {
133 public final Label label;
134
135 public BecauseLabelIsBusy(Label label) {
136 this.label = label;
137 }
138
139 public String getShortDescription() {
140 return Messages.Queue_WaitingForNextAvailableExecutorOn(label.getName());
141 }
142 }
143 }
144