Package hudson.model

Class Label

    • Field Detail

      • name

        protected final transient String name
        Display name of this label.
      • loadStatistics

        public final transient LoadStatistics loadStatistics
      • nodeProvisioner

        public final transient NodeProvisioner nodeProvisioner
    • Constructor Detail

      • Label

        protected Label​(@NonNull
                        String name)
    • Method Detail

      • getDisplayName

        public String getDisplayName()
        Returns a human-readable text that represents this label.
        Specified by:
        getDisplayName in interface ModelObject
      • getExpression

        public abstract String getExpression()
        Returns a label expression that represents this label.
      • getUrl

        public String getUrl()
        Relative URL from the context path, that ends with '/'.
      • getSearchUrl

        public String getSearchUrl()
        Description copied from interface: SearchItem
        Returns the URL of this item relative to the parent SearchItem.
        Specified by:
        getSearchUrl in interface SearchItem
        URL like "foo" or "foo/bar". The path can end with '/'. The path that starts with '/' will be interpreted as the absolute path (within the context path of Jenkins.)
      • isAtom

        public boolean isAtom()
        Returns true iff this label is an atom.
      • matches

        public abstract boolean matches​(VariableResolver<Boolean> resolver)
        Evaluates whether the label expression is true given the specified value assignment. IOW, returns true if the assignment provided by the resolver matches this label expression.
      • matches

        public final boolean matches​(Collection<LabelAtom> labels)
        Evaluates whether the label expression is true when an entity owns the given set of LabelAtoms.
      • matches

        public final boolean matches​(Node n)
      • isSelfLabel

        public boolean isSelfLabel()
        Returns true if this label is a "self label", which means the label is the name of a Node.
      • getNodes

        public Set<Node> getNodes()
        Gets all Nodes that belong to this label.
      • getSortedNodes

        public Set<Node> getSortedNodes()
      • getClouds

        public Set<Cloud> getClouds()
        Gets all Clouds that can launch for this label.
      • isAssignable

        public boolean isAssignable()
        Can jobs be assigned to this label?

        The answer is yes if there is a reasonable basis to believe that Hudson can have an executor under this label, given the current configuration. This includes situations such as (1) there are offline agents that have this label (2) clouds exist that can provision agents that have this label.

      • getTotalConfiguredExecutors

        public int getTotalConfiguredExecutors()
        Number of total Executors that belong to this label.

        This includes executors that belong to offline nodes, so the result can be thought of as a potential capacity, whereas getTotalExecutors() is the currently functioning total number of executors.

        This method doesn't take the dynamically allocatable nodes (via Cloud) into account. If you just want to test if there's some executors, use isAssignable().

      • getTotalExecutors

        public int getTotalExecutors()
        Number of total Executors that belong to this label that are functioning.

        This excludes executors that belong to offline nodes.

      • getBusyExecutors

        public int getBusyExecutors()
        Number of busy Executors that are carrying out some work right now.
      • getIdleExecutors

        public int getIdleExecutors()
        Number of idle Executors that can start working immediately.
      • isOffline

        public boolean isOffline()
        Returns true if all the nodes of this label is offline.
      • getDescription

        public String getDescription()
        Returns a human readable text that explains this label.
      • getTiedJobs

        public List<AbstractProject> getTiedJobs()
        Returns projects that are tied on this node.
      • getTiedJobCount

        public int getTiedJobCount()
        Returns an approximate count of projects that are tied on this node. In a system without security this should be the same as getTiedJobs().size() but significantly faster as it involves fewer temporary objects and avoids sorting the intermediary list. In a system with security, this will likely return a higher value as it counts all jobs (mostly) irrespective of access.
        a count of projects that are tied on this node.
      • contains

        public boolean contains​(Node node)
      • isEmpty

        public boolean isEmpty()
        If there's no such label defined in Node or Cloud. This is usually used as a signal that this label is invalid.
      • getApi

        public Api getApi()
        Expose this object to the remote API.
      • accept

        public abstract <V,​P> V accept​(LabelVisitor<V,​P> visitor,
                                             P param)
        Accepts a visitor and call its respective "onXYZ" method based no the actual type of 'this'.
      • listAtoms

        public Set<LabelAtom> listAtoms()
        Lists all the atoms contained in this label.
      • and

        public Label and​(Label rhs)
        Returns the label that represents this&&rhs
      • or

        public Label or​(Label rhs)
        Returns the label that represents this||rhs
      • iff

        public Label iff​(Label rhs)
        Returns the label that represents this<->rhs
      • implies

        public Label implies​(Label rhs)
        Returns the label that represents this->rhs
      • not

        public Label not()
        Returns the label that represents !this
      • paren

        public Label paren()
        Returns the label that represents (this) This is a pointless operation for machines, but useful for humans who find the additional parenthesis often useful
      • equals

        public final boolean equals​(Object that)
        equals in class Object
      • hashCode

        public final int hashCode()
        hashCode in class Object
      • parse

        public static Set<LabelAtom> parse​(@CheckForNull
                                           String labels)
        Convert a whitespace-separate list of tokens into a set of Labels.
        labels - Strings like "abc def ghi". Can be empty or null.
        Can be empty but never null. A new writable set is always returned, so that the caller can add more to the set.
      • get

        public static Label get​(String l)
        Obtains a label by its name.
      • parseExpression

        public static Label parseExpression​(@NonNull
                                            String labelExpression)
        Parses the expression into a label expression tree. TODO: replace this with a real parser later
        labelExpression - the label expression to be parsed
        IllegalArgumentException - if the label expression cannot be parsed