Package jenkins.slaves.iterators.api
Class NodeIterator<N extends Node>
java.lang.Object
jenkins.slaves.iterators.api.NodeIterator<N>
- All Implemented Interfaces:
ExtensionPoint,Iterator<N>
public abstract class NodeIterator<N extends Node>
extends Object
implements Iterator<N>, ExtensionPoint
A class that iterates through all the
Nodes in the system, even nodes which are not attached to the main
Jenkins object. If you are holding onto nodes that are not attached to the main Jenkins object
then you need to have an Extension which extends this class and can iterate through your Nodes.- Author:
- Stephen Connolly
-
Nested Class Summary
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected <N extends Node>
booleanhasCompleteLiveSet(Class<N> nodeClass) Implementers ofNodeIteratorshould override this method if they "lend"Nodeinstances to other JVMs and they require an on-line connection to those JVMs in order to iterate theNodeinstances that have been "lent".static booleanstatic <N extends Node>
booleanisComplete(Class<N> nodeClass) Returnstrueif and only ifiterator()will iterate all live instances of the specified subtype ofNode.static NodeIterator<Node>iterator()Returns a new iterator of all theNodes in the system.static <N extends Node>
NodeIterator<N>Returns a new iterator of all theNodes in the system.nodes()Adapter to allow easy use from Java 5+ for loops.Adapter to allow easy use from Java 5+ for loops.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining, hasNext, next, remove
-
Constructor Details
-
NodeIterator
public NodeIterator()
-
-
Method Details
-
iterator
Returns a new iterator of all theNodes in the system.- Returns:
- a new iterator of all the
Nodes in the system.
-
nodes
Adapter to allow easy use from Java 5+ for loops.- Returns:
- an
Iterable.
-
iterator
Returns a new iterator of all theNodes in the system. -
nodes
Adapter to allow easy use from Java 5+ for loops. If attempting to get all nodes usenodes() -
isComplete
public static boolean isComplete()Returnstrueif and only ifiterator()will iterate all live instances ofNode. This is useful if you want to resolve any backing resources that do not have a correspondingNodeinstance. If this method returnsfalsethen it will not be possible to definitively determine the complete live set and hence it will not be possible to definitively identify unused backing resources.- Returns:
trueif and only ifiterator()will iterate all live instances ofNode.- Since:
- 1.2
-
isComplete
Returnstrueif and only ifiterator()will iterate all live instances of the specified subtype ofNode. This is useful if you want to resolve any backing resources that do not have a correspondingNodeinstance. If this method returnsfalsethen it will not be possible to definitively determine the complete live set and hence it will not be possible to definitively identify unused backing resources.- Type Parameters:
N- the class type of node- Parameters:
nodeClass- the type ofNode- Returns:
trueif and only ifiterator()will iterate all live instances ofNode.- Since:
- 1.2
-
hasCompleteLiveSet
Implementers ofNodeIteratorshould override this method if they "lend"Nodeinstances to other JVMs and they require an on-line connection to those JVMs in order to iterate theNodeinstances that have been "lent". Where an implementer only "lends" a specific sub-type ofNodeit should returntrueif the specified node type is not a sub-type of the type ofNodethat it leases. Implementers should only returnfalsewhen the type ofNodethey "lend" is a sub-type of the specified type and at least one of their connections to remote JVMs is off-line in order to allow clients of theNodeIteratorAPI to identify unused backing resources.- Type Parameters:
N- the sub-type ofNodethat is being queried.- Parameters:
nodeClass- the sub-type ofNodethat is being queried.- Returns:
falseif and only if thisNodeIteratorcannot currently return the full set ofNodeinstances of the specified type as a result of a transient loss of remote connectivity- Since:
- 1.2
-