提交 3ff23b5d 编写于 作者: K kohsuke

adding a convenience base class for various Cloud implementations.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@29689 71c3de6d-444a-0410-be80-ed276b4c234a
上级 05cf2ddc
package hudson.slaves;
/**
* Additional convenience implementation on top of {@link Cloud} that are likely useful to
* typical {@link Cloud} implementations.
*
* <p>
* Whereas {@link Cloud} is the contract between the rest of Hudson and a cloud implementation,
* this class focuses on providing a convenience to minimize the effort it takes to integrate
* a new cloud to Hudson.
*
* @author Kohsuke Kawaguchi
*/
public abstract class AbstractCloudImpl extends Cloud {
/**
* Upper bound on how many instances we may provision.
*/
private int instanceCap;
protected AbstractCloudImpl(String name, String instanceCapStr) {
super(name);
setInstanceCapStr(instanceCapStr);
}
protected void setInstanceCapStr(String value) {
if(value==null || value.equals(""))
this.instanceCap = Integer.MAX_VALUE;
else
this.instanceCap = Integer.parseInt(value);
}
/**
* Gets the instance cap as string. Used primarily for form binding.
*/
public String getInstanceCapStr() {
if(instanceCap==Integer.MAX_VALUE)
return "";
else
return String.valueOf(instanceCap);
}
/**
* Gets the instance cap as int, where the capless is represented as {@link Integer#MAX_VALUE}
*/
public int getInstanceCap() {
return instanceCap;
}
protected void setInstanceCap(int v) {
this.instanceCap = v;
}
}
......@@ -49,6 +49,7 @@ import java.util.Collection;
*
* @author Kohsuke Kawaguchi
* @see NodeProvisioner
* @see AbstractCloudImpl
*/
public abstract class Cloud extends AbstractModelObject implements ExtensionPoint, Describable<Cloud>, AccessControlled {
......
<div>
You can place the upward limit to the number of slaves that Hudson may launch from this cloud.
This is useful for avoiding surprises in the billing statement.
<P>
For example, if this field is 3, Hudson will only launch a new instance
as long as total number of instances you run on this cloud doesn't exceed this number. In this way,
even in the worst case of Hudson starting instances and forgetting about them,
you have an upper bound in the number of instances that are concurrently executed.
<p>
Leave this field empty to remove a cap.
</div>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册