hudson.slaves
Class CloudSlaveRetentionStrategy<T extends Computer>

java.lang.Object
  extended by hudson.model.AbstractDescribableImpl<RetentionStrategy<?>>
      extended by hudson.slaves.RetentionStrategy<T>
          extended by hudson.slaves.CloudSlaveRetentionStrategy<T>
All Implemented Interfaces:
ExtensionPoint, Describable<RetentionStrategy<?>>

public class CloudSlaveRetentionStrategy<T extends Computer>
extends RetentionStrategy<T>

Default convenience implementation of RetentionStrategy for slaves provisioned from Cloud. If a slave is idle for 10 mins, this retention strategy will remove the slave. This can be used as-is for a Node provisioned by cloud to implement the auto-scaling semantics, it can be subtyped to tweak the behavior, or it can be used as an example.

Since:
1.510
Author:
Kohsuke Kawaguchi

Nested Class Summary
 
Nested classes/interfaces inherited from class hudson.slaves.RetentionStrategy
RetentionStrategy.Always, RetentionStrategy.Demand
 
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
 
Field Summary
static long TIMEOUT
           
 
Fields inherited from class hudson.slaves.RetentionStrategy
INSTANCE, LIST, NOOP
 
Constructor Summary
CloudSlaveRetentionStrategy()
           
 
Method Summary
 long check(T c)
          This method will be called periodically to allow this strategy to decide what to do with it's owning slave.
protected  long checkCycle()
          When do we check again next time?
protected  long getIdleMaxTime()
          If the computer has been idle longer than this time, we'll kill the slave.
protected  boolean isIdleForTooLong(T c)
          Has this computer been idle for too long?
protected  void kill(Node n)
          Remove the node.
 
Methods inherited from class hudson.slaves.RetentionStrategy
all, isManualLaunchAllowed, start
 
Methods inherited from class hudson.model.AbstractDescribableImpl
getDescriptor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TIMEOUT

public static long TIMEOUT
Constructor Detail

CloudSlaveRetentionStrategy

public CloudSlaveRetentionStrategy()
Method Detail

check

public long check(T c)
Description copied from class: RetentionStrategy
This method will be called periodically to allow this strategy to decide what to do with it's owning slave.

Specified by:
check in class RetentionStrategy<T extends Computer>
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 that this!

kill

protected void kill(Node n)
             throws IOException
Remove the node.

To actually deallocate the resource tied to this Node, implement Computer.onRemoved().

Throws:
IOException

checkCycle

protected long checkCycle()
When do we check again next time?


isIdleForTooLong

protected boolean isIdleForTooLong(T c)
Has this computer been idle for too long?


getIdleMaxTime

protected long getIdleMaxTime()
If the computer has been idle longer than this time, we'll kill the slave.



Copyright © 2004-2013. All Rights Reserved.