Package hudson.slaves
Class RetentionStrategy<T extends Computer>
- java.lang.Object
-
- hudson.model.AbstractDescribableImpl<RetentionStrategy<?>>
-
- hudson.slaves.RetentionStrategy<T>
-
- All Implemented Interfaces:
ExtensionPoint
,Describable<RetentionStrategy<?>>
- Direct Known Subclasses:
CloudRetentionStrategy
,CloudSlaveRetentionStrategy
,RetentionStrategy.Always
,RetentionStrategy.Demand
,SimpleScheduledRetentionStrategy
public abstract class RetentionStrategy<T extends Computer> extends AbstractDescribableImpl<RetentionStrategy<?>> implements ExtensionPoint
Controls when to takeComputer
offline, bring it back online, or even to destroy it.- Author:
- Stephen Connolly, Kohsuke Kawaguchi
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RetentionStrategy.Always
RetentionStrategy
that tries to keep the node online all the time.static class
RetentionStrategy.Demand
RetentionStrategy
that tries to keep the node offline when not in use.-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Field Summary
Fields Modifier and Type Field Description static RetentionStrategy.Always
INSTANCE
Convenient singleton instance, since thisRetentionStrategy
is stateless.static DescriptorList<RetentionStrategy<?>>
LIST
static RetentionStrategy<Computer>
NOOP
Dummy instance that doesn't do any attempt to retention.
-
Constructor Summary
Constructors Constructor Description RetentionStrategy()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static DescriptorExtensionList<RetentionStrategy<?>,Descriptor<RetentionStrategy<?>>>
all()
Returns all the registeredRetentionStrategy
descriptors.abstract long
check(T c)
This method will be called periodically to allow this strategy to decide what to do with its owning agent.boolean
isAcceptingTasks(T c)
Returnstrue
if the computer is accepting tasks.boolean
isManualLaunchAllowed(T c)
This method is called to determine whether manual launching of the agent is allowed right now.void
start(T c)
Called when a newComputer
object is introduced (such as when Hudson started, or when a new agent is added).-
Methods inherited from class hudson.model.AbstractDescribableImpl
getDescriptor
-
-
-
-
Field Detail
-
LIST
@Deprecated public static final DescriptorList<RetentionStrategy<?>> LIST
All registeredRetentionStrategy
implementations.
-
NOOP
public static final RetentionStrategy<Computer> NOOP
Dummy instance that doesn't do any attempt to retention.
-
INSTANCE
public static final RetentionStrategy.Always INSTANCE
Convenient singleton instance, since thisRetentionStrategy
is stateless.
-
-
Method Detail
-
check
public abstract long check(@NonNull T c)
This method will be called periodically to allow this strategy to decide what to do with its owning agent.- Parameters:
c
-Computer
for which this strategy is assigned. This computer may be online or offline. This object also exposes a bunch of properties that the callee can use to decide what action to take.- Returns:
- The number of minutes after which the strategy would like to be checked again. The strategy may be rechecked earlier or later than this!
-
isManualLaunchAllowed
public boolean isManualLaunchAllowed(T c)
This method is called to determine whether manual launching of the agent is allowed right now.- Parameters:
c
-Computer
for which this strategy is assigned. This computer may be online or offline. This object also exposes a bunch of properties that the callee can use to decide if manual launching is allowed.- Returns:
true
if manual launching of the agent is allowed right now.
-
isAcceptingTasks
public boolean isAcceptingTasks(T c)
Returnstrue
if the computer is accepting tasks. Needed to allow retention strategies programmatic suspension of task scheduling that in preparation for going offline. Called byComputer.isAcceptingTasks()
- Parameters:
c
- the computer.- Returns:
true
if the computer is accepting tasks- Since:
- 1.586
- See Also:
Computer.isAcceptingTasks()
-
start
public void start(@NonNull T c)
Called when a newComputer
object is introduced (such as when Hudson started, or when a new agent is added).The default implementation of this method delegates to
check(Computer)
, but this allowsRetentionStrategy
to distinguish the first time invocation from the rest.- Parameters:
c
- Computer instance- Since:
- 1.275
-
all
public static DescriptorExtensionList<RetentionStrategy<?>,Descriptor<RetentionStrategy<?>>> all()
Returns all the registeredRetentionStrategy
descriptors.
-
-