Class Node
- All Implemented Interfaces:
ExtensionPoint,Describable<Node>,ModelObject,PersistenceRoot,ReconfigurableDescribable<Node>,Saveable,SearchableModelObject,SearchItem,AccessControlled,OnMaster
- Direct Known Subclasses:
AbstractCIBase,Slave
Slave to define a new agent type).
As a special case, Jenkins extends from here.
Nodes are persisted objects that capture user configurations, and instances get thrown away and recreated whenever
the configuration changes. Running state of nodes are captured by Computers.
There is no URL binding for Node. Computer and TransientComputerActionFactory must
be used to associate new Actions to agents.
- Author:
- Kohsuke Kawaguchi
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumConstants that control how Hudson allocates jobs to agents.Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanNewly copied agents get this flag set, so that Jenkins doesn't try to start/remove this node until its configuration is saved once.static boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncanTake(Queue.BuildableItem item) Called by theQueueto determine whether or not this node can take the given task.canTake(Queue.Task task) Deprecated.protected abstract Computerabstract LaunchercreateLauncher(TaskListener listener) Returns aLauncherfor executing programs on this node.createPath(String absolutePath) Gets theFilePathon this node.getACL()Obtains the ACL associated with this object.Returns the possibly empty set of labels that are assigned to this node, including the automaticself label, manually assigned labels and dynamically assigned labels via theLabelFinderextension point.final hudson.remoting.VirtualChannelGets the current channel, if the node is connected and online, or null.Estimates the clock difference with this agent.abstract hudson.remoting.Callable<ClockDifference, IOException> Returns aCallablethat when run on the channel, estimates the clock difference.protected XmlFileabstract NodeDescriptorGets the descriptor for this instance.Deprecated.Return the possibly empty tag cloud for the labels of this node.abstract StringReturns the manually configured label for a node.abstract Node.ModegetMode()ReturnsNode.Mode.EXCLUSIVEif this node is only available for those jobs that exclusively specifies this node as the assigned node.abstract StringHuman-readable description of this node.abstract StringName of this node.abstract DescribableList<NodeProperty<?>, NodePropertyDescriptor> Gets theNodePropertyinstances configured for thisNode.<T extends NodeProperty>
TgetNodeProperty(Class<T> clazz) Gets the specified property or null if the property is not configured for this Node.getNodeProperty(String className) Gets the property from the given classname or null if the property is not configured for this Node.abstract intReturns the number ofExecutors.Gets the root directory on the file system that thisItemcan use freely for storing the configuration data.abstract FilePathGets the root directory of this node.Returns the URL of this item relative to the parentSearchItem.Gets the special label that represents this node itself.Get the cause if temporary offline.abstract FilePathgetWorkspaceFor(TopLevelItem item) Returns a "workspace" directory for the givenTopLevelItem.booleanReturnstrueif the node is accepting tasks.booleanvoidreconfigure(org.kohsuke.stapler.StaplerRequest2 req, net.sf.json.JSONObject form) When a parent/owner object of a Describable gets a config form submission and instances are recreated, this method is invoked on the existing instance (meaning the 'this' reference points to the existing instance) to create a new instance to be added to the parent/owner object.reconfigure(org.kohsuke.stapler.StaplerRequest req, net.sf.json.JSONObject form) Deprecated.voidsave()In most cases, you should not call this method directly, butJenkins.updateNode(Node)instead.voidsetLabelString(String labelString) Sets the label string for a node.abstract voidsetNodeName(String name) Deprecated.to indicate that this method isn't really meant to be called by random code.final ComputerGets the correspondingComputerobject.Methods inherited from class hudson.model.AbstractModelObject
getSearch, getSearchIndex, getSearchName, makeSearchIndex, requirePOST, sendError, sendError, sendError, sendError, sendError, sendError, sendError, sendErrorMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface hudson.security.AccessControlled
checkAnyPermission, checkPermission, hasAnyPermission, hasPermission, hasPermission, hasPermission2Methods inherited from interface hudson.search.SearchItem
getSearchGroup, getSearchIcon
-
Field Details
-
SKIP_BUILD_CHECK_ON_FLYWEIGHTS
public static boolean SKIP_BUILD_CHECK_ON_FLYWEIGHTS- See Also:
-
holdOffLaunchUntilSave
protected transient volatile boolean holdOffLaunchUntilSaveNewly copied agents get this flag set, so that Jenkins doesn't try to start/remove this node until its configuration is saved once.
-
-
Constructor Details
-
Node
public Node()
-
-
Method Details
-
getDisplayName
- Specified by:
getDisplayNamein interfaceModelObject
-
getSearchUrl
Description copied from interface:SearchItemReturns the URL of this item relative to the parentSearchItem.- Specified by:
getSearchUrlin 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.)
-
isHoldOffLaunchUntilSave
public boolean isHoldOffLaunchUntilSave() -
save
In most cases, you should not call this method directly, butJenkins.updateNode(Node)instead.- Specified by:
savein interfaceSaveable- Throws:
IOException- if the persistence failed.- Since:
- 1.635.
-
getConfigFile
-
getNodeName
Name of this node.- Returns:
- "" if this is master
-
setNodeName
Deprecated.to indicate that this method isn't really meant to be called by random code. -
getNodeDescription
Human-readable description of this node. -
createLauncher
Returns aLauncherfor executing programs on this node.The callee must call
Launcher.decorateFor(Node)before returning to complete the decoration. -
getNumExecutors
@Exported public abstract int getNumExecutors()Returns the number ofExecutors. This may be different fromgetExecutors().size()because it takes time to adjust the number of executors. -
getMode
ReturnsNode.Mode.EXCLUSIVEif this node is only available for those jobs that exclusively specifies this node as the assigned node. -
toComputer
Gets the correspondingComputerobject.- Returns:
- this method can return null if there's no
Computerobject for this node, such as when this node has no executors at all.
-
getChannel
@CheckForNull public final hudson.remoting.VirtualChannel getChannel()Gets the current channel, if the node is connected and online, or null. This is just a convenience method forComputer.getChannel()with null check. -
createComputer
@CheckForNull @Restricted(org.kohsuke.accmod.restrictions.ProtectedExternally.class) protected abstract Computer createComputer()Creates a newComputerobject that acts as the UI peer of thisNode. Nobody butAbstractCIBase.updateComputerList(boolean, Collection)should call this method. -
isAcceptingTasks
public boolean isAcceptingTasks()Returnstrueif the node is accepting tasks. Needed to allow agents programmatic suspension of task scheduling that does not overlap with being offline. Called byComputer.isAcceptingTasks(). This method is distinct fromComputer.isAcceptingTasks()as sometimes theNodeconcrete class may not have control over theComputerconcrete class associated with it.- Returns:
trueif the node is accepting tasks.- Since:
- 1.586
- See Also:
-
onLoad
-
getTemporaryOfflineCause
Get the cause if temporary offline.- Returns:
- null if not temporary offline or there was no cause given.
- Since:
- 2.340
-
getLabelCloud
Return the possibly empty tag cloud for the labels of this node. -
getLabelAtomSet
@NonNull @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) protected Set<LabelAtom> getLabelAtomSet()- Returns:
- An immutable set of LabelAtom associated with the current node label.
-
getAssignedLabels
Returns the possibly empty set of labels that are assigned to this node, including the automaticself label, manually assigned labels and dynamically assigned labels via theLabelFinderextension point. This method has a side effect of updating the hudson-wide set of labels and should be called after events that will change that - e.g. an agent connecting. -
drainLabelsToTrim
@NonNull @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public Set<LabelAtom> drainLabelsToTrim()- Returns:
- the labels to be trimmed for this node.
-
getLabelString
Returns the manually configured label for a node. The list of assigned and dynamically determined labels is available viagetAssignedLabels()and includes all labels that have been manually configured. Mainly for form binding. -
setLabelString
Sets the label string for a node. This value will be returned bygetLabelString().- Parameters:
labelString- The new label string to use.- Throws:
IOException- Since:
- 1.477
-
getSelfLabel
Gets the special label that represents this node itself. -
canTake
Deprecated.as of 1.413 UsecanTake(Queue.BuildableItem)Called by theQueueto determine whether or not this node can take the given task. The default checks include whether or not this node is part of the task's assigned label, whether this node is inNode.Mode.EXCLUSIVEmode if it is not in the task's assigned label, and whether or not any of this node'sNodePropertys say that the task cannot be run.- Since:
- 1.360
-
canTake
Called by theQueueto determine whether or not this node can take the given task. The default checks include whether or not this node is part of the task's assigned label, whether this node is inNode.Mode.EXCLUSIVEmode if it is not in the task's assigned label, and whether or not any of this node'sNodePropertys say that the task cannot be run.- Since:
- 1.413
-
getWorkspaceFor
Returns a "workspace" directory for the givenTopLevelItem.Workspace directory is usually used for keeping out the checked out source code, but it can be used for anything.
- Returns:
- null if this node is not connected hence the path is not available
-
getRootPath
Gets the root directory of this node.Hudson always owns a directory on every node. This method returns that.
- Returns:
- null if the node is offline and hence the
FilePathobject is not available.
-
createPath
Gets theFilePathon this node. -
getFileSystemProvisioner
Deprecated. -
getNodeProperties
@NonNull public abstract DescribableList<NodeProperty<?>,NodePropertyDescriptor> getNodeProperties()Gets theNodePropertyinstances configured for thisNode. -
getNodeProperty
Gets the specified property or null if the property is not configured for this Node.- Parameters:
clazz- the type of the property- Returns:
- null if the property is not configured
- Since:
- 2.37
-
getNodeProperty
Gets the property from the given classname or null if the property is not configured for this Node.- Parameters:
className- The classname of the property- Returns:
- null if the property is not configured
- Since:
- 2.37
-
getNodePropertyDescriptors
-
getACL
Description copied from interface:AccessControlledObtains the ACL associated with this object.- Specified by:
getACLin interfaceAccessControlled- Returns:
- never null.
-
reconfigure
public Node reconfigure(@NonNull org.kohsuke.stapler.StaplerRequest2 req, net.sf.json.JSONObject form) throws Descriptor.FormException Description copied from interface:ReconfigurableDescribableWhen a parent/owner object of a Describable gets a config form submission and instances are recreated, this method is invoked on the existing instance (meaning the 'this' reference points to the existing instance) to create a new instance to be added to the parent/owner object.The default implementation of this should be the following:
return form==null ? null : getDescriptor().newInstance(req, form);
- Specified by:
reconfigurein interfaceReconfigurableDescribable<Node>- Parameters:
req- The current HTTP request being processed.form- JSON fragment that corresponds to this describable object. If the newly submitted form doesn't include a fragment for this describable (meaning the user has de-selected your descriptor), then this argument is null.- Returns:
- The new instance. To not to create an instance of a describable, return null.
- Throws:
Descriptor.FormException
-
reconfigure
@Deprecated public Node reconfigure(@NonNull org.kohsuke.stapler.StaplerRequest req, net.sf.json.JSONObject form) throws Descriptor.FormException Deprecated.- Specified by:
reconfigurein interfaceReconfigurableDescribable<Node>- Throws:
Descriptor.FormException
-
getDescriptor
Description copied from interface:DescribableGets the descriptor for this instance.Descriptoris a singleton for every concreteDescribableimplementation, so ifa.getClass() == b.getClass()then by defaulta.getDescriptor() == b.getDescriptor()as well. (In rare cases a single implementation class may be used for instances with distinct descriptors.)By default looks for a nested class (conventionally named
DescriptorImpl) implementingDescriptorand marked withExtension.- Specified by:
getDescriptorin interfaceDescribable<Node>
-
getClockDifference
Estimates the clock difference with this agent.- Returns:
- always non-null.
- Throws:
InterruptedException- if the operation is aborted.IOException
-
getClockDifferenceCallable
Returns aCallablethat when run on the channel, estimates the clock difference.- Returns:
- always non-null.
- Since:
- 1.522
-
getRootDir
Description copied from interface:PersistenceRootGets the root directory on the file system that thisItemcan use freely for storing the configuration data.This parameter is given by the
ItemGroupwhenItemis loaded from memory.- Specified by:
getRootDirin interfacePersistenceRoot
-
canTake(Queue.BuildableItem)