提交 d6419f1c 编写于 作者: K kohsuke

rolling back my 9366 to bring Stephen's slave related changes to the main line

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@9382 71c3de6d-444a-0410-be80-ed276b4c234a
上级 36c60b32
package hudson.model;
import hudson.util.DescriptorList;
import hudson.ExtensionPoint;
import org.kohsuke.stapler.StaplerRequest;
import net.sf.json.JSONObject;
/**
* Slave availability strategy
*/
public abstract class SlaveAvailabilityStrategy implements Describable<SlaveAvailabilityStrategy>, ExtensionPoint {
/**
* This method will be called periodically to allow this strategy to decide what to do with it's owning slave.
* The default implementation takes the slave on-line every time it's off-line.
*
* @param slave The slave that owns this strategy, i.e. {@code slave.getAvailabilityStrategy() == this}
* @param state Some state information that may be useful in deciding what to do.
* @return The number of minutes after which the strategy would like to be checked again. The strategy may be
* rechecked earlier or later that this!
*/
public long check(Slave slave, State state) {
Slave.ComputerImpl c = slave.getComputer();
if (c != null && c.isOffline() && c.isStartSupported())
c.tryReconnect();
return 5;
}
/**
* All registered {@link SlaveAvailabilityStrategy} implementations.
*/
public static final DescriptorList<SlaveAvailabilityStrategy> LIST = new DescriptorList<SlaveAvailabilityStrategy>(
Always.DESCRIPTOR
);
public static class State {
private final boolean jobWaiting;
private final boolean jobRunning;
public State(boolean jobWaiting, boolean jobRunning) {
this.jobWaiting = jobWaiting;
this.jobRunning = jobRunning;
}
public boolean isJobWaiting() {
return jobWaiting;
}
public boolean isJobRunning() {
return jobRunning;
}
}
public static class Always extends SlaveAvailabilityStrategy {
public Descriptor<SlaveAvailabilityStrategy> getDescriptor() {
return DESCRIPTOR;
}
public static final Descriptor<SlaveAvailabilityStrategy> DESCRIPTOR =
new DescriptorImpl();
private static class DescriptorImpl extends Descriptor<SlaveAvailabilityStrategy> {
public DescriptorImpl() {
super(Always.class);
}
public String getDisplayName() {
return "Keep this slave on-line as much as possible";
}
public SlaveAvailabilityStrategy newInstance(StaplerRequest req, JSONObject formData) throws FormException {
return new Always();
}
}
}
}
<div>
Controls when Hudson starts and stops the slave.
<dl>
<dt><b>
Keep this slave on-line as much as possible
</b></dt>
<dd>
This is the default and normal setting.
In this mode, Hudson uses tries to keep the slave on-line.
If Hudson can start the slave without user assistance, it will periodically
attempt to restart the slave if it is unavailable.
Hudson will not take the slave off-line.
</dd>
<dt><b>
Take this slave on-line and off-line at specific times
</b></dt>
<dd>
In this mode, Hudson will keep the slave on-line according to the configured schedule.
If Hudson can start the slave without user assistance, it will periodically
attempt to start the slave if it is unavailable during an on-line window.
During an off-line window, the slave will only be taken off-line if there are no active
jobs running on the slave.
</dd>
<dt><b>
Take this slave on-line and off-line as needed
</b></dt>
<dd>
In this mode, if Hudson can start the slave without user assistance, it will periodically
attempt to start the slave while there are unexecuted jobs which meet the following criteria:
<ul>
<li>They have been in the queue for at least the specified startup demand period</li>
<li>They can execute on this slave</li>
</ul>
The slave will be taken off-line if:
<ul>
<li>There are no active jobs running on the slave</li>
<li>The slave has been idle for at least the specified idle period</li>
</ul>
</dd>
</dl>
</div>
\ No newline at end of file
<div>
Controls how Hudson starts the slave.
</div>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册