hudson.model
Class Label

java.lang.Object
  extended by hudson.model.AbstractModelObject
      extended by hudson.model.Actionable
          extended by hudson.model.Label
All Implemented Interfaces:
ModelObject, SearchableModelObject, SearchItem, Comparable<Label>, ModelObjectWithContextMenu
Direct Known Subclasses:
LabelAtom, LabelExpression

@ExportedBean
public abstract class Label
extends Actionable
implements Comparable<Label>, ModelObject

Group of Nodes.

Author:
Kohsuke Kawaguchi
See Also:
Jenkins.getLabels(), Jenkins.getLabel(String)

Nested Class Summary
static class Label.ConverterImpl
           
 
Nested classes/interfaces inherited from interface jenkins.model.ModelObjectWithContextMenu
ModelObjectWithContextMenu.ContextMenu, ModelObjectWithContextMenu.MenuItem
 
Field Summary
 LoadStatistics loadStatistics
           
protected  String name
          Display name of this label.
 NodeProvisioner nodeProvisioner
           
 
Constructor Summary
Label(String name)
           
 
Method Summary
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'.
 Label and(Label rhs)
          Returns the label that represents "this&rhs"
 int compareTo(Label that)
           
 boolean contains(Node node)
           
 boolean equals(Object that)
           
static Label get(String l)
          Obtains a label by its name.
 Api getApi()
          Expose this object to the remote API.
 int getBusyExecutors()
          Number of busy Executors that are carrying out some work right now.
 Set<Cloud> getClouds()
          Gets all Clouds that can launch for this label.
 String getDescription()
          Returns a human readable text that explains this label.
 String getDisplayName()
          Returns a human-readable text that represents this label.
abstract  String getExpression()
          Returns a label expression that represents this label.
 int getIdleExecutors()
          Number of idle Executors that can start working immediately.
 String getName()
          Alias for getDisplayName().
 Set<Node> getNodes()
          Gets all Nodes that belong to this label.
 String getSearchUrl()
          Returns the URL of this item relative to the parent SearchItem.
 List<AbstractProject> getTiedJobs()
          Returns projects that are tied on this node.
 int getTotalConfiguredExecutors()
          Number of total Executors that belong to this label.
 int getTotalExecutors()
          Number of total Executors that belong to this label that are functioning.
 String getUrl()
          Relative URL from the context path, that ends with '/'.
 int hashCode()
           
 Label iff(Label rhs)
          Returns the label that represents "this<->rhs"
 Label implies(Label rhs)
          Returns the label that represents "this->rhs"
 boolean isAssignable()
          Can jobs be assigned to this label?
 boolean isEmpty()
          If there's no such label defined in Node or Cloud.
 boolean isOffline()
          Returns true if all the nodes of this label is offline.
 boolean isSelfLabel()
          Returns true if this label is a "self label", which means the label is the name of a Node.
 Set<LabelAtom> listAtoms()
          Lists up all the atoms contained in in this label.
 boolean matches(Collection<LabelAtom> labels)
          Evaluates whether the label expression is true when an entity owns the given set of LabelAtoms.
 boolean matches(Node n)
           
abstract  boolean matches(VariableResolver<Boolean> resolver)
          Evaluates whether the label expression is true given the specified value assignment.
 Label not()
          Returns the label that represents "!this"
 Label or(Label rhs)
          Returns the label that represents "this|rhs"
 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
static Set<LabelAtom> parse(String labels)
          Convers a whitespace-separate list of tokens into a set of Labels.
static Label parseExpression(String labelExpression)
          Parses the expression into a label expression tree.
abstract  LabelOperatorPrecedence precedence()
          Precedence of the top most operator.
 String toString()
           
 
Methods inherited from class hudson.model.Actionable
addAction, doContextMenu, getAction, getAction, getActions, getActions, getDynamic
 
Methods inherited from class hudson.model.AbstractModelObject
getSearch, getSearchIndex, getSearchName, makeSearchIndex, requirePOST, sendError, sendError, sendError, sendError, sendError
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected final transient String name
Display name of this label.


loadStatistics

@Exported
public final transient LoadStatistics loadStatistics

nodeProvisioner

public final transient NodeProvisioner nodeProvisioner
Constructor Detail

Label

public Label(String name)
Method Detail

getName

@Exported
public final String getName()
Alias for getDisplayName().


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
Returns:
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 Hudson.)

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

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


getClouds

@Exported
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 slaves that have this label (2) clouds exist that can provision slaves 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

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

This excludes executors that belong to offline nodes.


getBusyExecutors

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


getIdleExecutors

@Exported
public int getIdleExecutors()
Number of idle Executors that can start working immediately.


isOffline

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


getDescription

@Exported
public String getDescription()
Returns a human readable text that explains this label.


getTiedJobs

@Exported
public List<AbstractProject> getTiedJobs()
Returns 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 up all the atoms contained in in this label.

Since:
1.420

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


precedence

public abstract LabelOperatorPrecedence precedence()
Precedence of the top most operator.


equals

public boolean equals(Object that)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

compareTo

public int compareTo(Label that)
Specified by:
compareTo in interface Comparable<Label>

toString

public String toString()
Overrides:
toString in class Object

parse

public static Set<LabelAtom> parse(String labels)
Convers a whitespace-separate list of tokens into a set of Labels.

Parameters:
labels - Strings like "abc def ghi". Can be empty or null.
Returns:
Can be empty but never null. A new writable set is always returned, so that the caller can add more to the set.
Since:
1.308

get

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


parseExpression

public static Label parseExpression(String labelExpression)
                             throws antlr.ANTLRException
Parses the expression into a label expression tree. TODO: replace this with a real parser later

Throws:
antlr.ANTLRException


Copyright © 2004-2013. All Rights Reserved.