Class Slave
- java.lang.Object
-
- hudson.model.AbstractModelObject
-
- hudson.model.Node
-
- hudson.model.Slave
-
- All Implemented Interfaces:
ExtensionPoint
,Describable<Node>
,ModelObject
,ReconfigurableDescribable<Node>
,Saveable
,SearchableModelObject
,SearchItem
,AccessControlled
,Serializable
,OnMaster
- Direct Known Subclasses:
AbstractCloudSlave
,DumbSlave
public abstract class Slave extends Node implements Serializable
Information about a Hudson agent node.Ideally this would have been in the
hudson.slaves
package, but for compatibility reasons, it can't.TODO: move out more stuff to
DumbSlave
. On February, 2016 a general renaming was done internally: the "slave" term was replaced by "Agent". This change was applied in: UI labels/HTML pages, javadocs and log messages. Java classes, fields, methods, etc were not renamed to avoid compatibility issues. See JENKINS-27268.- Author:
- Kohsuke Kawaguchi
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Slave.JnlpJar
Web-bound object used to serve jar files for inbound connections.static class
Slave.SlaveDescriptor
-
Nested classes/interfaces inherited from class hudson.model.Node
Node.InternalComputerListener, Node.Mode
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Field Summary
Fields Modifier and Type Field Description protected String
name
Name of this agent node.protected String
remoteFS
Path to the root of the workspace from the view point of this node, such as "/hudson", this need not be absolute provided that the launcher establishes a consistent working directory, such as "./.jenkins-agent" when used with an SSH launcher.-
Fields inherited from class hudson.model.Node
holdOffLaunchUntilSave, SKIP_BUILD_CHECK_ON_FLYWEIGHTS
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Slave(String name, String remoteFS, ComputerLauncher launcher)
protected
Slave(String name, String nodeDescription, String remoteFS, int numExecutors, Node.Mode mode, String labelString, ComputerLauncher launcher, RetentionStrategy retentionStrategy)
Deprecated.since 2009-02-20.protected
Slave(String name, String nodeDescription, String remoteFS, int numExecutors, Node.Mode mode, String labelString, ComputerLauncher launcher, RetentionStrategy retentionStrategy, List<? extends NodeProperty<?>> nodeProperties)
Deprecated.as of 2.2 UseSlave(String, String, ComputerLauncher)
and set the rest through setters.protected
Slave(String name, String nodeDescription, String remoteFS, String numExecutors, Node.Mode mode, String labelString, ComputerLauncher launcher, RetentionStrategy retentionStrategy, List<? extends NodeProperty<?>> nodeProperties)
Deprecated.since 2.184
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Computer
createComputer()
Launcher
createLauncher(TaskListener listener)
Creates a launcher for the agent.boolean
equals(Object o)
hudson.remoting.Callable<ClockDifference,IOException>
getClockDifferenceCallable()
Returns aCallable
that when run on the channel, estimates the clock difference.SlaveComputer
getComputer()
Gets the corresponding computer object.Slave.SlaveDescriptor
getDescriptor()
Gets the descriptor for this instance.String
getLabelString()
Returns the manually configured label for a node.ComputerLauncher
getLauncher()
Node.Mode
getMode()
ReturnsNode.Mode.EXCLUSIVE
if this node is only available for those jobs that exclusively specifies this node as the assigned node.String
getNodeDescription()
Human-readable description of this node.String
getNodeName()
Name of this node.DescribableList<NodeProperty<?>,NodePropertyDescriptor>
getNodeProperties()
Gets theNodeProperty
instances configured for thisNode
.int
getNumExecutors()
Returns the number ofExecutor
s.String
getRemoteFS()
RetentionStrategy
getRetentionStrategy()
FilePath
getRootPath()
Gets the root directory of this node.String
getUserId()
Deprecated.Removed with no replacementFilePath
getWorkspaceFor(TopLevelItem item)
Returns a "workspace" directory for the givenTopLevelItem
.FilePath
getWorkspaceRoot()
Root directory on this agent where all the job workspaces are laid out.int
hashCode()
protected Object
readResolve()
Invoked by XStream when this object is read into memory.void
setLabelString(String labelString)
Sets the label string for a node.void
setLauncher(ComputerLauncher launcher)
void
setMode(Node.Mode mode)
void
setNodeDescription(String value)
void
setNodeName(String name)
void
setNodeProperties(List<? extends NodeProperty<?>> properties)
void
setNumExecutors(int n)
void
setRetentionStrategy(RetentionStrategy availabilityStrategy)
void
setUserId(String userId)
Deprecated.Removed with no replacementString
toString()
-
Methods inherited from class hudson.model.Node
canTake, canTake, createPath, getACL, getAssignedLabels, getChannel, getClockDifference, getDisplayName, getFileSystemProvisioner, getLabelCloud, getNodeProperty, getNodeProperty, getNodePropertyDescriptors, getSearchUrl, getSelfLabel, getTemporaryOfflineCause, isAcceptingTasks, isHoldOffLaunchUntilSave, reconfigure, save, toComputer
-
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
-
Methods inherited from interface hudson.security.AccessControlled
checkAnyPermission, checkPermission, hasAnyPermission, hasPermission, hasPermission, hasPermission2
-
-
-
-
Field Detail
-
name
protected String name
Name of this agent node.
-
remoteFS
protected final String remoteFS
Path to the root of the workspace from the view point of this node, such as "/hudson", this need not be absolute provided that the launcher establishes a consistent working directory, such as "./.jenkins-agent" when used with an SSH launcher. NOTE: if the administrator is using a relative path they are responsible for ensuring that the launcher used provides a consistent working directory
-
-
Constructor Detail
-
Slave
@Deprecated protected Slave(String name, String nodeDescription, String remoteFS, String numExecutors, Node.Mode mode, String labelString, ComputerLauncher launcher, RetentionStrategy retentionStrategy, List<? extends NodeProperty<?>> nodeProperties) throws Descriptor.FormException, IOException
Deprecated.since 2.184UseSlave(String, String, ComputerLauncher)
and set the rest through setters.- Throws:
Descriptor.FormException
IOException
-
Slave
@Deprecated protected Slave(String name, String nodeDescription, String remoteFS, int numExecutors, Node.Mode mode, String labelString, ComputerLauncher launcher, RetentionStrategy retentionStrategy) throws Descriptor.FormException, IOException
Deprecated.since 2009-02-20.- Throws:
Descriptor.FormException
IOException
-
Slave
protected Slave(@NonNull String name, String remoteFS, ComputerLauncher launcher) throws Descriptor.FormException, IOException
- Throws:
Descriptor.FormException
IOException
-
Slave
@Deprecated protected Slave(@NonNull String name, String nodeDescription, String remoteFS, int numExecutors, Node.Mode mode, String labelString, ComputerLauncher launcher, RetentionStrategy retentionStrategy, List<? extends NodeProperty<?>> nodeProperties) throws Descriptor.FormException, IOException
Deprecated.as of 2.2 UseSlave(String, String, ComputerLauncher)
and set the rest through setters.- Throws:
Descriptor.FormException
IOException
-
-
Method Detail
-
getUserId
@Deprecated @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) @RestrictedSince("2.220") public String getUserId()
Deprecated.Removed with no replacementReturn id of user which created this agent- Returns:
- id of user
-
setUserId
@Deprecated @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) @RestrictedSince("2.220") public void setUserId(String userId)
Deprecated.Removed with no replacementThis method no longer does anything.
-
getLauncher
public ComputerLauncher getLauncher()
-
setLauncher
public void setLauncher(ComputerLauncher launcher)
-
getRemoteFS
public String getRemoteFS()
-
getNodeName
@NonNull public String getNodeName()
Description copied from class:Node
Name of this node.- Specified by:
getNodeName
in classNode
- Returns:
- "" if this is master
-
setNodeName
public void setNodeName(String name)
Description copied from class:Node
When the user clones aNode
, Hudson uses this method to change the node name right after the clonedNode
object is instantiated.This method is never used for any other purpose, and as such for all practical intents and purposes, the node name should be treated like immutable.
- Specified by:
setNodeName
in classNode
-
setNodeDescription
@DataBoundSetter public void setNodeDescription(String value)
-
getNodeDescription
public String getNodeDescription()
Description copied from class:Node
Human-readable description of this node.- Specified by:
getNodeDescription
in classNode
-
getNumExecutors
public int getNumExecutors()
Description copied from class:Node
Returns the number ofExecutor
s. This may be different fromgetExecutors().size()
because it takes time to adjust the number of executors.- Specified by:
getNumExecutors
in classNode
-
setNumExecutors
@DataBoundSetter public void setNumExecutors(int n)
-
getMode
public Node.Mode getMode()
Description copied from class:Node
ReturnsNode.Mode.EXCLUSIVE
if this node is only available for those jobs that exclusively specifies this node as the assigned node.
-
setMode
@DataBoundSetter public void setMode(Node.Mode mode)
-
getNodeProperties
@NonNull public DescribableList<NodeProperty<?>,NodePropertyDescriptor> getNodeProperties()
Description copied from class:Node
Gets theNodeProperty
instances configured for thisNode
.- Specified by:
getNodeProperties
in classNode
-
setNodeProperties
@DataBoundSetter public void setNodeProperties(List<? extends NodeProperty<?>> properties) throws IOException
- Throws:
IOException
-
getRetentionStrategy
public RetentionStrategy getRetentionStrategy()
-
setRetentionStrategy
@DataBoundSetter public void setRetentionStrategy(RetentionStrategy availabilityStrategy)
-
getLabelString
public String getLabelString()
Description copied from class:Node
Returns the manually configured label for a node. The list of assigned and dynamically determined labels is available viaNode.getAssignedLabels()
and includes all labels that have been manually configured. Mainly for form binding.- Specified by:
getLabelString
in classNode
-
setLabelString
@DataBoundSetter public void setLabelString(String labelString) throws IOException
Description copied from class:Node
Sets the label string for a node. This value will be returned byNode.getLabelString()
.- Overrides:
setLabelString
in classNode
- Parameters:
labelString
- The new label string to use.- Throws:
IOException
-
getClockDifferenceCallable
public hudson.remoting.Callable<ClockDifference,IOException> getClockDifferenceCallable()
Description copied from class:Node
Returns aCallable
that when run on the channel, estimates the clock difference.- Specified by:
getClockDifferenceCallable
in classNode
- Returns:
- always non-null.
-
createComputer
public Computer createComputer()
Description copied from class:Node
Creates a newComputer
object that acts as the UI peer of thisNode
. Nobody butJenkins.updateComputerList()
should call this method.- Specified by:
createComputer
in classNode
- Returns:
- Created instance of the computer.
Can be
null
if theNode
implementation does not support it (e.g.Cloud
agent).
-
getWorkspaceFor
public FilePath getWorkspaceFor(TopLevelItem item)
Description copied from class:Node
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.
- Specified by:
getWorkspaceFor
in classNode
- Returns:
- null if this node is not connected hence the path is not available
-
getRootPath
@CheckForNull public FilePath getRootPath()
Description copied from class:Node
Gets the root directory of this node.Hudson always owns a directory on every node. This method returns that.
- Specified by:
getRootPath
in classNode
- Returns:
- null if the node is offline and hence the
FilePath
object is not available.
-
getWorkspaceRoot
@CheckForNull public FilePath getWorkspaceRoot()
Root directory on this agent where all the job workspaces are laid out.- Returns:
- null if not connected.
-
createLauncher
@NonNull public Launcher createLauncher(TaskListener listener)
Creates a launcher for the agent.- Specified by:
createLauncher
in classNode
- Returns:
- If there is no computer it will return a
Launcher.DummyLauncher
, otherwise it will return aLauncher.RemoteLauncher
instead.
-
getComputer
@CheckForNull public SlaveComputer getComputer()
Gets the corresponding computer object.- Returns:
- this method can return null if there's no
Computer
object for this node, such as when this node has no executors at all.
-
readResolve
protected Object readResolve()
Invoked by XStream when this object is read into memory.
-
getDescriptor
public Slave.SlaveDescriptor getDescriptor()
Description copied from interface:Describable
Gets the descriptor for this instance.Descriptor
is a singleton for every concreteDescribable
implementation, 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.)- Specified by:
getDescriptor
in interfaceDescribable<Node>
- Specified by:
getDescriptor
in classNode
-
-