Class Slave
- All Implemented Interfaces:
ExtensionPoint,Describable<Node>,ModelObject,PersistenceRoot,ReconfigurableDescribable<Node>,Saveable,SearchableModelObject,SearchItem,AccessControlled,Serializable,OnMaster
- Direct Known Subclasses:
AbstractCloudSlave,DumbSlave
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classWeb-bound object used to serve jar files for inbound connections.static classNested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringName of this agent node.protected final StringPath 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
ConstructorsModifierConstructorDescriptionprotectedSlave(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
Modifier and TypeMethodDescriptioncreateLauncher(TaskListener listener) Creates a launcher for the agent.booleanhudson.remoting.Callable<ClockDifference, IOException> Returns aCallablethat when run on the channel, estimates the clock difference.Gets the corresponding computer object.Gets the descriptor for this instance.Returns the manually configured label for a node.getMode()ReturnsNode.Mode.EXCLUSIVEif this node is only available for those jobs that exclusively specifies this node as the assigned node.Human-readable description of this node.Name of this node.Gets theNodePropertyinstances configured for thisNode.intReturns the number ofExecutors.Gets the root directory of this node.Deprecated.Removed with no replacementgetWorkspaceFor(TopLevelItem item) Returns a "workspace" directory for the givenTopLevelItem.Root directory on this agent where all the job workspaces are laid out.inthashCode()protected ObjectInvoked by XStream when this object is read into memory.voidsave()Deprecated.In most cases, you should not call this method directly, butJenkins.updateNode(Node)instead.voidsetLabelString(String labelString) Sets the label string for a node.voidsetLauncher(ComputerLauncher launcher) voidvoidsetNodeDescription(String value) voidsetNodeName(String name) voidsetNodeProperties(List<? extends NodeProperty<?>> properties) voidsetNumExecutors(int n) voidsetRetentionStrategy(RetentionStrategy availabilityStrategy) voidDeprecated.Removed with no replacementtoString()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, reconfigure, toComputerMethods 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, finalize, getClass, notify, notifyAll, 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
-
name
Name of this agent node. -
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 Details
-
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 Details
-
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
-
save
Deprecated.In most cases, you should not call this method directly, butJenkins.updateNode(Node)instead.Description copied from class:NodeIn most cases, you should not call this method directly, butJenkins.updateNode(Node)instead.- Specified by:
savein interfaceSaveable- Overrides:
savein classNode- Throws:
IOException- if the persistence failed.
-
setLauncher
-
getRemoteFS
-
getNodeName
Description copied from class:NodeName of this node.- Specified by:
getNodeNamein classNode- Returns:
- "" if this is master
-
toString
-
setNodeName
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
-
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
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
-
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
-
setRetentionStrategy
-
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
-
drainLabelsToTrim
@NonNull @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public Set<LabelAtom> drainLabelsToTrim()- Overrides:
drainLabelsToTrimin classNode- Returns:
- the labels to be trimmed for this node. This includes current and previous labels that were applied before the last call to this method.
-
setLabelString
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
- Overrides:
getLabelAtomSetin classNode- Returns:
- An immutable set of LabelAtom associated with the current node label.
-
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
Description copied from class:NodeCreates a newComputerobject that acts as the UI peer of thisNode. Nobody butAbstractCIBase.updateComputerList(boolean, Collection)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
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
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
Root directory on this agent where all the job workspaces are laid out.- Returns:
- null if not connected.
-
createLauncher
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
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.
-
equals
-
hashCode
public int hashCode() -
readResolve
Invoked by XStream when this object is read into memory. -
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>- Specified by:
getDescriptorin classNode
-