Package hudson.model
Class Label
java.lang.Object
hudson.model.AbstractModelObject
hudson.model.Actionable
hudson.model.Label
- All Implemented Interfaces:
ModelObject
,SearchableModelObject
,SearchItem
,Comparable<Label>
,ModelObjectWithChildren
,ModelObjectWithContextMenu
- Direct Known Subclasses:
LabelAtom
,LabelExpression
@ExportedBean
public abstract class Label
extends Actionable
implements Comparable<Label>, ModelObjectWithChildren
Group of
Node
s.- Author:
- Kohsuke Kawaguchi
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface jenkins.model.ModelObjectWithContextMenu
ModelObjectWithContextMenu.ContextMenu, ModelObjectWithContextMenu.ContextMenuVisibility, ModelObjectWithContextMenu.MenuItem, ModelObjectWithContextMenu.MenuItemType
-
Field Summary
Modifier and TypeFieldDescriptionfinal LoadStatistics
protected final String
Display name of this label.final NodeProvisioner
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract <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'.Returns the label that representsthis&&rhs
final int
boolean
doChildrenContextMenu
(org.kohsuke.stapler.StaplerRequest2 request, org.kohsuke.stapler.StaplerResponse2 response) Generates the context menu to list up all the children.final boolean
static Label
Obtains a label by its name.getApi()
Expose this object to the remote API.int
Number of busyExecutor
s that are carrying out some work right now.Gets allCloud
s that can launch for this label.Returns a human readable text that explains this label.Returns a human-readable text that represents this label.abstract String
Returns a label expression that represents this label.int
Number of idleExecutor
s that can start working immediately.final String
getName()
Alias forgetDisplayName()
.getNodes()
Gets allNode
s that belong to this label.Returns the URL of this item relative to the parentSearchItem
.int
Returns an approximate count of projects that are tied on this node.Returns projects that are tied on this node.int
Number of totalExecutor
s that belong to this label.int
Number of totalExecutor
s that belong to this label that are functioning.getUrl()
Relative URL from the context path, that ends with '/'.final int
hashCode()
Returns the label that representsthis<->rhs
Returns the label that representsthis->rhs
boolean
Can jobs be assigned to this label?boolean
isAtom()
Returns true iff this label is an atom.boolean
isEmpty()
boolean
Returns true if all the nodes of this label is offline.boolean
Returns true if this label is a "self label", which means the label is the name of aNode
.Lists all the atoms contained in this label.final boolean
abstract boolean
matches
(VariableResolver<Boolean> resolver) Evaluates whether the label expression is true given the specified value assignment.final boolean
matches
(Collection<LabelAtom> labels) Evaluates whether the label expression is true when an entity owns the given set ofLabelAtom
s.not()
Returns the label that represents!this
Returns the label that representsthis||rhs
paren()
Returns the label that represents(this)
This is a pointless operation for machines, but useful for humans who find the additional parenthesis often usefulConvert a whitespace-separate list of tokens into a set ofLabel
s.static Label
parseExpression
(String labelExpression) Parses the expression into a label expression tree.abstract LabelOperatorPrecedence
Precedence of the top most operator.toString()
Methods inherited from class hudson.model.Actionable
addAction, addOrReplaceAction, doContextMenu, doContextMenu, getAction, getAction, getActions, getActions, getAllActions, getDynamic, getDynamic, removeAction, removeActions, replaceAction, replaceActions
Methods inherited from class hudson.model.AbstractModelObject
getSearch, getSearchIndex, getSearchName, makeSearchIndex, requirePOST, sendError, sendError, sendError, sendError, sendError, sendError, sendError, sendError
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface jenkins.model.ModelObjectWithChildren
doChildrenContextMenu
Methods inherited from interface hudson.search.SearchItem
getSearchIcon
-
Field Details
-
name
Display name of this label. -
loadStatistics
-
nodeProvisioner
-
-
Constructor Details
-
Label
-
-
Method Details
-
getName
Alias forgetDisplayName()
. -
getDisplayName
Returns a human-readable text that represents this label.- Specified by:
getDisplayName
in interfaceModelObject
-
getExpression
Returns a label expression that represents this label. -
getUrl
Relative URL from the context path, that ends with '/'. -
getSearchUrl
Description copied from interface:SearchItem
Returns the URL of this item relative to the parentSearchItem
.- Specified by:
getSearchUrl
in interfaceSearchItem
- 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 Jenkins.)
-
isAtom
public boolean isAtom()Returns true iff this label is an atom.- Since:
- 1.580
-
matches
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
Evaluates whether the label expression is true when an entity owns the given set ofLabelAtom
s. -
matches
-
isSelfLabel
public boolean isSelfLabel()Returns true if this label is a "self label", which means the label is the name of aNode
. -
getNodes
Gets allNode
s that belong to this label. -
getSortedNodes
-
getClouds
Gets allCloud
s 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 totalExecutor
s 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, useisAssignable()
. -
getTotalExecutors
@Exported public int getTotalExecutors()Number of totalExecutor
s that belong to this label that are functioning.This excludes executors that belong to offline nodes.
-
getBusyExecutors
@Exported public int getBusyExecutors()Number of busyExecutor
s that are carrying out some work right now. -
getIdleExecutors
@Exported public int getIdleExecutors()Number of idleExecutor
s that can start working immediately. -
isOffline
@Exported public boolean isOffline()Returns true if all the nodes of this label is offline. -
getDescription
Returns a human readable text that explains this label. -
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 asgetTiedJobs().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.- Returns:
- a count of projects that are tied on this node.
-
contains
-
isEmpty
public boolean isEmpty() -
getApi
Expose this object to the remote API. -
accept
Accepts a visitor and call its respective "onXYZ" method based no the actual type of 'this'. -
listAtoms
Lists all the atoms contained in this label.- Since:
- 1.420
-
and
Returns the label that representsthis&&rhs
-
or
Returns the label that representsthis||rhs
-
iff
Returns the label that representsthis<->rhs
-
implies
Returns the label that representsthis->rhs
-
not
Returns the label that represents!this
-
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
Precedence of the top most operator. -
equals
-
hashCode
public final int hashCode() -
compareTo
- Specified by:
compareTo
in interfaceComparable<Label>
-
toString
-
doChildrenContextMenu
public ModelObjectWithContextMenu.ContextMenu doChildrenContextMenu(org.kohsuke.stapler.StaplerRequest2 request, org.kohsuke.stapler.StaplerResponse2 response) throws Exception Description copied from interface:ModelObjectWithChildren
Generates the context menu to list up all the children.- Specified by:
doChildrenContextMenu
in interfaceModelObjectWithChildren
- Throws:
Exception
-
parse
Convert a whitespace-separate list of tokens into a set ofLabel
s.- 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
Obtains a label by its name. -
parseExpression
Parses the expression into a label expression tree. TODO: replace this with a real parser later- Parameters:
labelExpression
- the label expression to be parsed- Throws:
IllegalArgumentException
- if the label expression cannot be parsed
-