Class NodeIterator<N extends Node>

  • 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
    • Constructor Detail

      • NodeIterator

        public NodeIterator()
    • Method Detail

      • iterator

        @NonNull
        public static NodeIterator<Node> iterator()
        Returns a new iterator of all the Nodes in the system.
        Returns:
        a new iterator of all the Nodes in the system.
      • nodes

        @NonNull
        public static Iterable<Node> nodes()
        Adapter to allow easy use from Java 5+ for loops.
        Returns:
        an Iterable.
      • iterator

        @NonNull
        public static <N extends NodeNodeIterator<N> iterator​(@NonNull
                                                                Class<N> nodeClass)
        Returns a new iterator of all the Nodes in the system.
        Type Parameters:
        N - the class type of node
        Parameters:
        nodeClass - the type of Node
        Returns:
        a new iterator of all the Nodes in the system.
      • nodes

        @NonNull
        public static <N extends NodeIterable<N> nodes​(@NonNull
                                                         Class<N> nodeClass)
        Adapter to allow easy use from Java 5+ for loops. If attempting to get all nodes use nodes()
        Type Parameters:
        N - the class type of node
        Parameters:
        nodeClass - the type of Node
        Returns:
        an Iterable.
      • isComplete

        public static boolean isComplete()
        Returns true if and only if iterator() will iterate all live instances of Node. This is useful if you want to resolve any backing resources that do not have a corresponding Node instance. If this method returns false then 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:
        true if and only if iterator() will iterate all live instances of Node.
        Since:
        1.2
      • isComplete

        public static <N extends Node> boolean isComplete​(@NonNull
                                                          Class<N> nodeClass)
        Returns true if and only if iterator() will iterate all live instances of the specified subtype of Node. This is useful if you want to resolve any backing resources that do not have a corresponding Node instance. If this method returns false then 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 of Node
        Returns:
        true if and only if iterator() will iterate all live instances of Node.
        Since:
        1.2
      • hasCompleteLiveSet

        protected <N extends Node> boolean hasCompleteLiveSet​(@NonNull
                                                              Class<N> nodeClass)
        Implementers of NodeIterator should override this method if they "lend" Node instances to other JVMs and they require an on-line connection to those JVMs in order to iterate the Node instances that have been "lent". Where an implementer only "lends" a specific sub-type of Node it should return true if the specified node type is not a sub-type of the type of Node that it leases. Implementers should only return false when the type of Node they "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 the NodeIterator API to identify unused backing resources.
        Type Parameters:
        N - the sub-type of Node that is being queried.
        Parameters:
        nodeClass - the sub-type of Node that is being queried.
        Returns:
        false if and only if this NodeIterator cannot currently return the full set of Node instances of the specified type as a result of a transient loss of remote connectivity
        Since:
        1.2