@ExportedBean public abstract class Node extends AbstractModelObject implements ReconfigurableDescribable<Node>, ExtensionPoint, AccessControlled, OnMaster, Saveable
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 Computer
s.
There is no URL binding for Node
. Computer
and TransientComputerActionFactory
must
be used to associate new Action
s to agents.
NodeDescriptor
,
Computer
Modifier and Type | Class and Description |
---|---|
static class |
Node.InternalComputerListener
Let Nodes be aware of the lifecycle of their own
Computer . |
static class |
Node.Mode
Constants that control how Hudson allocates jobs to agents.
|
ExtensionPoint.LegacyInstancesAreScopedToHudson
Modifier and Type | Field and Description |
---|---|
protected boolean |
holdOffLaunchUntilSave
Newly 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 |
SKIP_BUILD_CHECK_ON_FLYWEIGHTS |
Constructor and Description |
---|
Node() |
Modifier and Type | Method and Description |
---|---|
CauseOfBlockage |
canTake(Queue.BuildableItem item)
Called by the
Queue to determine whether or not this node can
take the given task. |
CauseOfBlockage |
canTake(Queue.Task task)
Deprecated.
as of 1.413
Use
canTake(Queue.BuildableItem) |
protected abstract Computer |
createComputer()
|
abstract Launcher |
createLauncher(TaskListener listener)
Returns a
Launcher for executing programs on this node. |
FilePath |
createPath(String absolutePath)
Gets the
FilePath on this node. |
ACL |
getACL()
Obtains the ACL associated with this object.
|
Set<LabelAtom> |
getAssignedLabels()
Returns the possibly empty set of labels that are assigned to this node,
including the automatic
self label , manually
assigned labels and dynamically assigned labels via the
LabelFinder extension point. |
hudson.remoting.VirtualChannel |
getChannel()
Gets the current channel, if the node is connected and online, or null.
|
ClockDifference |
getClockDifference()
Estimates the clock difference with this agent.
|
abstract hudson.remoting.Callable<ClockDifference,IOException> |
getClockDifferenceCallable()
Returns a
Callable that when run on the channel, estimates the clock difference. |
abstract NodeDescriptor |
getDescriptor()
Gets the descriptor for this instance.
|
String |
getDisplayName() |
FileSystemProvisioner |
getFileSystemProvisioner()
Deprecated.
|
TagCloud<LabelAtom> |
getLabelCloud()
Return the possibly empty tag cloud for the labels of this node.
|
abstract String |
getLabelString()
Returns the manually configured label for a node.
|
abstract Node.Mode |
getMode()
Returns
Node.Mode.EXCLUSIVE if this node is only available
for those jobs that exclusively specifies this node
as the assigned node. |
abstract String |
getNodeDescription()
Human-readable description of this node.
|
abstract String |
getNodeName()
Name of this node.
|
abstract DescribableList<NodeProperty<?>,NodePropertyDescriptor> |
getNodeProperties()
Gets the
NodeProperty instances configured for this Node . |
<T extends NodeProperty> |
getNodeProperty(Class<T> clazz)
Gets the specified property or null if the property is not configured for this Node.
|
NodeProperty |
getNodeProperty(String className)
Gets the property from the given classname or null if the property
is not configured for this Node.
|
List<NodePropertyDescriptor> |
getNodePropertyDescriptors() |
abstract int |
getNumExecutors()
Returns the number of
Executor s. |
abstract FilePath |
getRootPath()
Gets the root directory of this node.
|
String |
getSearchUrl()
Returns the URL of this item relative to the parent
SearchItem . |
LabelAtom |
getSelfLabel()
Gets the special label that represents this node itself.
|
abstract FilePath |
getWorkspaceFor(TopLevelItem item)
Returns a "workspace" directory for the given
TopLevelItem . |
boolean |
isAcceptingTasks()
Returns
true if the node is accepting tasks. |
boolean |
isHoldOffLaunchUntilSave() |
Node |
reconfigure(org.kohsuke.stapler.StaplerRequest 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.
|
void |
save()
Persists the state of this object into XML.
|
void |
setLabelString(String labelString)
Sets the label string for a node.
|
abstract void |
setNodeName(String name)
Deprecated.
to indicate that this method isn't really meant to be called by random code.
|
Computer |
toComputer()
Gets the corresponding
Computer object. |
getSearch, getSearchIndex, getSearchName, makeSearchIndex, requirePOST, sendError, sendError, sendError, sendError, sendError
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
checkAnyPermission, checkPermission, hasAnyPermission, hasPermission, hasPermission, hasPermission2
public static boolean SKIP_BUILD_CHECK_ON_FLYWEIGHTS
protected transient volatile boolean holdOffLaunchUntilSave
public String getDisplayName()
getDisplayName
in interface ModelObject
public String getSearchUrl()
SearchItem
SearchItem
.getSearchUrl
in interface SearchItem
public boolean isHoldOffLaunchUntilSave()
public void save() throws IOException
Saveable
For making a bulk change efficiently, see BulkChange
.
To support listeners monitoring changes to this object, call SaveableListener.fireOnChange(hudson.model.Saveable, hudson.XmlFile)
save
in interface Saveable
IOException
- if the persistence failed.@Exported(visibility=999) @NonNull public abstract String getNodeName()
@Deprecated public abstract void setNodeName(String name)
@Exported public abstract String getNodeDescription()
public abstract Launcher createLauncher(TaskListener listener)
Launcher
for executing programs on this node.
The callee must call Launcher.decorateFor(Node)
before returning to complete the decoration.
@Exported public abstract int getNumExecutors()
Executor
s.
This may be different from getExecutors().size()
because it takes time to adjust the number of executors.@Exported public abstract Node.Mode getMode()
Node.Mode.EXCLUSIVE
if this node is only available
for those jobs that exclusively specifies this node
as the assigned node.@CheckForNull public final Computer toComputer()
Computer
object.Computer
object for this node,
such as when this node has no executors at all.@CheckForNull public final hudson.remoting.VirtualChannel getChannel()
Computer.getChannel()
with null check.@CheckForNull @Restricted(value=org.kohsuke.accmod.restrictions.ProtectedExternally.class) protected abstract Computer createComputer()
Computer
object that acts as the UI peer of this Node
.
Nobody but Jenkins.updateComputerList()
should call this method.public boolean isAcceptingTasks()
true
if the node is accepting tasks. Needed to allow agents programmatic suspension of task
scheduling that does not overlap with being offline. Called by Computer.isAcceptingTasks()
.
This method is distinct from Computer.isAcceptingTasks()
as sometimes the Node
concrete
class may not have control over the Computer
concrete class associated with it.true
if the node is accepting tasks.Computer.isAcceptingTasks()
public TagCloud<LabelAtom> getLabelCloud()
@Exported public Set<LabelAtom> getAssignedLabels()
self label
, manually
assigned labels and dynamically assigned labels via the
LabelFinder
extension 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. a agent
connecting.public abstract String getLabelString()
getAssignedLabels()
and includes all labels that have been
manually configured.
Mainly for form binding.public void setLabelString(String labelString) throws IOException
getLabelString()
.labelString
- The new label string to use.IOException
@NonNull @WithBridgeMethods(value=Label.class) public LabelAtom getSelfLabel()
@Deprecated public CauseOfBlockage canTake(Queue.Task task)
canTake(Queue.BuildableItem)
Queue
to 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 in
Node.Mode.EXCLUSIVE
mode if it is not in the task's assigned label,
and whether or not any of this node's NodeProperty
s say that the
task cannot be run.public CauseOfBlockage canTake(Queue.BuildableItem item)
Queue
to 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 in
Node.Mode.EXCLUSIVE
mode if it is not in the task's assigned label,
and whether or not any of this node's NodeProperty
s say that the
task cannot be run.@CheckForNull public abstract FilePath getWorkspaceFor(TopLevelItem item)
TopLevelItem
.
Workspace directory is usually used for keeping out the checked out source code, but it can be used for anything.
@CheckForNull public abstract FilePath getRootPath()
Hudson always owns a directory on every node. This method returns that.
FilePath
object is not available.@CheckForNull public FilePath createPath(String absolutePath)
FilePath
on this node.@Deprecated public FileSystemProvisioner getFileSystemProvisioner()
@NonNull public abstract DescribableList<NodeProperty<?>,NodePropertyDescriptor> getNodeProperties()
NodeProperty
instances configured for this Node
.@CheckForNull public <T extends NodeProperty> T getNodeProperty(Class<T> clazz)
clazz
- the type of the property@CheckForNull public NodeProperty getNodeProperty(String className)
className
- The classname of the propertypublic List<NodePropertyDescriptor> getNodePropertyDescriptors()
public ACL getACL()
AccessControlled
getACL
in interface AccessControlled
public Node reconfigure(org.kohsuke.stapler.StaplerRequest req, net.sf.json.JSONObject form) throws Descriptor.FormException
ReconfigurableDescribable
The default implementation of this should be the following:
return form==null ? null : getDescriptor().newInstance(req, form);
reconfigure
in interface ReconfigurableDescribable<Node>
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.Descriptor.FormException
public abstract NodeDescriptor getDescriptor()
Describable
Descriptor
is a singleton for every concrete Describable
implementation, so if a.getClass() == b.getClass()
then by default
a.getDescriptor() == b.getDescriptor()
as well.
(In rare cases a single implementation class may be used for instances with distinct descriptors.)
getDescriptor
in interface Describable<Node>
public ClockDifference getClockDifference() throws IOException, InterruptedException
InterruptedException
- if the operation is aborted.IOException
public abstract hudson.remoting.Callable<ClockDifference,IOException> getClockDifferenceCallable()
Callable
that when run on the channel, estimates the clock difference.Copyright © 2004–2021. All rights reserved.