Package hudson.slaves

Class RetentionStrategy<T extends Computer>

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 take Computer offline, bring it back online, or even to destroy it.
Author:
Stephen Connolly, Kohsuke Kawaguchi
  • Field Details

  • Constructor Details

    • RetentionStrategy

      public RetentionStrategy()
  • Method Details

    • 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)
      Returns true if the computer is accepting tasks. Needed to allow retention strategies programmatic suspension of task scheduling that in preparation for going offline. Called by Computer.isAcceptingTasks()
      Parameters:
      c - the computer.
      Returns:
      true if the computer is accepting tasks
      Since:
      1.586
      See Also:
    • start

      public void start(@NonNull T c)
      Called when a new Computer 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 allows RetentionStrategy to distinguish the first time invocation from the rest.

      Parameters:
      c - Computer instance
      Since:
      1.275
    • all

      Returns all the registered RetentionStrategy descriptors.