Class Slave
- java.lang.Object
-
- hudson.model.AbstractModelObject
-
- hudson.model.Node
-
- hudson.model.Slave
-
- All Implemented Interfaces:
ExtensionPoint,Describable<Node>,ModelObject,PersistenceRoot,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.slavespackage, 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 classSlave.JnlpJarWeb-bound object used to serve jar files for inbound connections.static classSlave.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 StringnameName of this agent node.protected StringremoteFSPath 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 protectedSlave(String name, String remoteFS, ComputerLauncher launcher)protectedSlave(String name, String nodeDescription, String remoteFS, int numExecutors, Node.Mode mode, String labelString, ComputerLauncher launcher, RetentionStrategy retentionStrategy)Deprecated.since 2009-02-20.protectedSlave(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.protectedSlave(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 ComputercreateComputer()LaunchercreateLauncher(TaskListener listener)Creates a launcher for the agent.booleanequals(Object o)hudson.remoting.Callable<ClockDifference,IOException>getClockDifferenceCallable()Returns aCallablethat when run on the channel, estimates the clock difference.SlaveComputergetComputer()Gets the corresponding computer object.Slave.SlaveDescriptorgetDescriptor()Gets the descriptor for this instance.protected Set<LabelAtom>getLabelAtomSet()StringgetLabelString()Returns the manually configured label for a node.ComputerLaunchergetLauncher()Node.ModegetMode()ReturnsNode.Mode.EXCLUSIVEif this node is only available for those jobs that exclusively specifies this node as the assigned node.StringgetNodeDescription()Human-readable description of this node.StringgetNodeName()Name of this node.DescribableList<NodeProperty<?>,NodePropertyDescriptor>getNodeProperties()Gets theNodePropertyinstances configured for thisNode.intgetNumExecutors()Returns the number ofExecutors.StringgetRemoteFS()RetentionStrategygetRetentionStrategy()FilePathgetRootPath()Gets the root directory of this node.StringgetUserId()Deprecated.Removed with no replacementFilePathgetWorkspaceFor(TopLevelItem item)Returns a "workspace" directory for the givenTopLevelItem.FilePathgetWorkspaceRoot()Root directory on this agent where all the job workspaces are laid out.inthashCode()protected ObjectreadResolve()Invoked by XStream when this object is read into memory.voidsetLabelString(String labelString)Sets the label string for a node.voidsetLauncher(ComputerLauncher launcher)voidsetMode(Node.Mode mode)voidsetNodeDescription(String value)voidsetNodeName(String name)voidsetNodeProperties(List<? extends NodeProperty<?>> properties)voidsetNumExecutors(int n)voidsetRetentionStrategy(RetentionStrategy availabilityStrategy)voidsetUserId(String userId)Deprecated.Removed with no replacementStringtoString()-
Methods inherited from class hudson.model.Node
canTake, canTake, createPath, getACL, getAssignedLabels, getChannel, getClockDifference, getConfigFile, getDisplayName, getFileSystemProvisioner, getLabelCloud, getNodeProperty, getNodeProperty, getNodePropertyDescriptors, getRootDir, getSearchUrl, getSelfLabel, getTemporaryOfflineCause, isAcceptingTasks, isHoldOffLaunchUntilSave, onLoad, 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.FormExceptionIOException
-
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.FormExceptionIOException
-
Slave
protected Slave(@NonNull String name, String remoteFS, ComputerLauncher launcher) throws Descriptor.FormException, IOException- Throws:
Descriptor.FormExceptionIOException
-
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.FormExceptionIOException
-
-
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:NodeName of this node.- Specified by:
getNodeNamein classNode- Returns:
- "" if this is master
-
setNodeName
public void setNodeName(String name)
Description copied from class:NodeWhen the user clones aNode, Hudson uses this method to change the node name right after the clonedNodeobject 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:
setNodeNamein classNode
-
setNodeDescription
@DataBoundSetter public void setNodeDescription(String value)
-
getNodeDescription
public String getNodeDescription()
Description copied from class:NodeHuman-readable description of this node.- Specified by:
getNodeDescriptionin classNode
-
getNumExecutors
public int getNumExecutors()
Description copied from class:NodeReturns the number ofExecutors. This may be different fromgetExecutors().size()because it takes time to adjust the number of executors.- Specified by:
getNumExecutorsin classNode
-
setNumExecutors
@DataBoundSetter public void setNumExecutors(int n)
-
getMode
public Node.Mode getMode()
Description copied from class:NodeReturnsNode.Mode.EXCLUSIVEif 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:NodeGets theNodePropertyinstances configured for thisNode.- Specified by:
getNodePropertiesin 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:NodeReturns 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:
getLabelStringin classNode
-
setLabelString
@DataBoundSetter public void setLabelString(String labelString) throws IOException
Description copied from class:NodeSets the label string for a node. This value will be returned byNode.getLabelString().- Overrides:
setLabelStringin classNode- Parameters:
labelString- The new label string to use.- Throws:
IOException
-
getLabelAtomSet
protected Set<LabelAtom> getLabelAtomSet()
- Overrides:
getLabelAtomSetin classNode- Returns:
- An immutable set of LabelAtom associated with the current node label.
-
getClockDifferenceCallable
public hudson.remoting.Callable<ClockDifference,IOException> getClockDifferenceCallable()
Description copied from class:NodeReturns aCallablethat when run on the channel, estimates the clock difference.- Specified by:
getClockDifferenceCallablein classNode- Returns:
- always non-null.
-
createComputer
public Computer createComputer()
Description copied from class:NodeCreates a newComputerobject that acts as the UI peer of thisNode. Nobody butJenkins.updateComputerList()should call this method.- Specified by:
createComputerin classNode- Returns:
- Created instance of the computer.
Can be
nullif theNodeimplementation does not support it (e.g.Cloudagent).
-
getWorkspaceFor
public FilePath getWorkspaceFor(TopLevelItem item)
Description copied from class:NodeReturns 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:
getWorkspaceForin classNode- Returns:
- null if this node is not connected hence the path is not available
-
getRootPath
@CheckForNull public FilePath getRootPath()
Description copied from class:NodeGets the root directory of this node.Hudson always owns a directory on every node. This method returns that.
- Specified by:
getRootPathin classNode- Returns:
- null if the node is offline and hence the
FilePathobject 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:
createLauncherin classNode- Returns:
- If there is no computer it will return a
Launcher.DummyLauncher, otherwise it will return aLauncher.RemoteLauncherinstead.
-
getComputer
@CheckForNull public SlaveComputer getComputer()
Gets the corresponding computer object.- Returns:
- this method can return null if there's no
Computerobject 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: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.)- Specified by:
getDescriptorin interfaceDescribable<Node>- Specified by:
getDescriptorin classNode
-
-