Class SlaveComputer
- All Implemented Interfaces:
ExtensionPoint,DescriptorByNameOwner,ExecutorListener,ModelObject,SearchableModelObject,SearchItem,AccessControlled,IComputer,ModelObjectWithContextMenu,Named,HasWidgets,IconSpec,org.kohsuke.stapler.StaplerProxy
- Direct Known Subclasses:
AbstractCloudComputer
- Author:
- Kohsuke Kawaguchi
-
Nested Class Summary
Nested classes/interfaces inherited from class hudson.model.Computer
Computer.InternalComputerListener, Computer.TerminationRequestNested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudsonNested classes/interfaces inherited from interface jenkins.model.ModelObjectWithContextMenu
ModelObjectWithContextMenu.ContextMenu, ModelObjectWithContextMenu.ContextMenuVisibility, ModelObjectWithContextMenu.MenuItem, ModelObjectWithContextMenu.MenuItemType -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic booleanEscape hatch for allowing connections from agents with unsupported Remoting versions.Fields inherited from class hudson.model.Computer
BUILD, CONFIGURE, CONNECT, CREATE, DELETE, DISCONNECT, EXTENDED_READ, EXTENDED_READ_AND_CONNECT, nodeName, offlineCause, PERMISSIONS, SKIP_PERMISSION_CHECK, statusChangeLock, threadPoolForRemoting, transientActions -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Future<?> _connect(boolean forceReconnect) Allows implementing-classes to provide an implementation for the connect method.voidcloseLog()Future<?> disconnect(OfflineCause cause) Disconnect this computer.org.kohsuke.stapler.HttpResponsedoDoDisconnect(String offlineMessage) org.kohsuke.stapler.HttpResponsedoJenkinsAgentJnlp(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 res) voiddoLaunchSlaveAgent(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) IfComputer.getChannel()==null, attempts to relaunch the agent.org.kohsuke.stapler.HttpResponsedoSlaveAgentJnlp(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 res) voiddoSubmitDescription(org.kohsuke.stapler.StaplerResponse2 rsp, String description) Inline editing of descriptionReturns the remote FS root absolute path ornullif the agent is off-line.Just for restFul api.hudson.remoting.ChannelGets the channel that can be used to run a program on this computer.static hudson.remoting.VirtualChannelDeprecated.intShowsChannel.classLoadingCount.intShowsChannel.classLoadingPrefetchCacheCount.longShowsChannel.classLoadingTime.Gets the default charset of this computer.Return theComputerLauncherfor this SlaveComputer, strips off anyDelegatingComputerLaunchers orComputerLauncherFilters.Expose real full env vars map from agent for UI presentationReturns the class name that will be used to look up the icon.getJnlpJars(String fileName) Deprecated.since 2008-08-18.Return theComputerLauncherfor thisSlaveComputer.Offers a way to write to the log file for this agent.Gets the logs recorded by this agent.getNode()Returns theNodethat this computer represents.Get the OS description.intShowsChannel.resourceLoadingCount.longShowsChannel.resourceLoadingTime.RetentionStrategyassociated with this computer.Get the agent versionstatic List<SlaveSystemInfo> Helper method for Jelly.protected ComputerLaunchergrabLauncher(Node node) booleanReturnstrueif the computer is accepting tasks.booleanbooleanDeprecated.since 2008-05-20.booleanisUnix()True if this computer is a Unix machine (as opposed to Windows machine).protected voidkill()Called byAbstractCIBase.updateComputerList(boolean, Collection)to notifyComputerthat it will be discarded.voidsetAcceptingTasks(boolean acceptingTasks) Allows suspension of tasks being accepted by the agent computer.voidsetChannel(hudson.remoting.ChannelBuilder cb, hudson.remoting.CommandTransport commandTransport, hudson.remoting.Channel.Listener listener) Creates aChannelfrom the given Channel Builder and Command Transport.voidsetChannel(hudson.remoting.Channel channel, OutputStream launchLog, hudson.remoting.Channel.Listener listener) Sets up the connection through an existing channel.voidsetChannel(InputStream in, OutputStream out, TaskListener taskListener, hudson.remoting.Channel.Listener listener) Creates aChannelfrom the given stream and sets that to this agent.voidsetChannel(InputStream in, OutputStream out, OutputStream launchLog, hudson.remoting.Channel.Listener listener) Creates aChannelfrom the given stream and sets that to this agent.protected voidvoidtaskAccepted(Executor executor, Queue.Task task) Called whenever a task is accepted by an executor.voidtaskCompleted(Executor executor, Queue.Task task, long durationMS) Called whenever a task is completed without any problems by an executor.voidtaskCompletedWithProblems(Executor executor, Queue.Task task, long durationMS, Throwable problems) Called whenever a task is completed with some problems by an executor.voidtaskStarted(Executor executor, Queue.Task task) Called whenever a task is started by an executor.toString()voidMethods inherited from class hudson.model.Computer
_doScript, addAction, buildEnvironment, cliConnect, cliDisconnect, cliOffline, cliOnline, connect, countBusy, countExecutors, countIdle, currentComputer, disconnect, doChangeOfflineCause, doConfigDotXml, doConfigSubmit, doDoDelete, doDumpExportTable, doProgressiveLog, doRssAll, doRssFailed, doRssLatest, doScript, doScriptText, doToggleOffline, getActions, getAllExecutors, getApi, getAssignedLabels, getBuilds, getCaption, getComputerPanelBoxs, getConnectTime, getDemandStartMilliseconds, getDescription, getDisplayExecutors, getDisplayName, getEnvironment, getEnvVars, getExecutors, getHeapDump, getHostName, getIcon, getIdleStartMilliseconds, getLoadStatistics, getLog, getLogDir, getLogFile, getLogText, getMonitorData, getMonitoringData, getName, getNumExecutors, getOfflineCause, getOfflineCauseReason, getOneOffExecutors, getSearchGroup, getSearchUrl, getSystemProperties, getTemporaryOfflineCauseReason, getTerminatedBy, getThreadDump, getTiedJobs, getTimeline, getUrl, getWorkspaceList, hasOfflineCause, interrupt, isAlive, isConnected, isIdle, isManualLaunchAllowed, isOffline, isOnline, isPartiallyIdle, isTemporarilyOffline, launch, onRemoved, recordTermination, relocateOldLogs, removeExecutor, resolveForCLI, setNumExecutors, setOfflineCause, setTemporarilyOffline, setTemporarilyOffline, setTemporaryOfflineCause, updateByXml, waitUntilOffline, waitUntilOnlineMethods inherited from class hudson.model.Actionable
addOrReplaceAction, doContextMenu, doContextMenu, getAction, getAction, getActions, getAllActions, getDynamic, getDynamic, removeAction, removeActions, replaceAction, replaceActionsMethods 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, wait, wait, waitMethods inherited from interface hudson.security.AccessControlled
checkAnyPermission, checkPermission, hasAnyPermission, hasPermission, hasPermission, hasPermission2Methods inherited from interface hudson.model.DescriptorByNameOwner
getDescriptorByNameMethods inherited from interface jenkins.widgets.HasWidgets
getWidget, getWidgetsMethods inherited from interface jenkins.model.IComputer
getACL, getIconAltText, getTooltipMethods inherited from interface hudson.search.SearchItem
getSearchIcon
-
Field Details
-
ALLOW_UNSUPPORTED_REMOTING_VERSIONS
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public static boolean ALLOW_UNSUPPORTED_REMOTING_VERSIONSEscape hatch for allowing connections from agents with unsupported Remoting versions.
-
-
Constructor Details
-
SlaveComputer
-
-
Method Details
-
isAcceptingTasks
@OverrideMustInvoke public boolean isAcceptingTasks()Description copied from interface:IComputerReturnstrueif the computer is accepting tasks. Needed to allow agents programmatic suspension of task scheduling that does not overlap with being offline.- Specified by:
isAcceptingTasksin interfaceIComputer- Overrides:
isAcceptingTasksin classComputer- Returns:
trueif the computer is accepting tasks- See Also:
-
getJnlpMac
- Since:
- 1.498
-
setAcceptingTasks
public void setAcceptingTasks(boolean acceptingTasks) Allows suspension of tasks being accepted by the agent computer. While this could be called by a ComputerLauncher or a RetentionStrategy, such usage can result in fights between multiple actors calling setting differential values. A better approach is to overrideRetentionStrategy.isAcceptingTasks(hudson.model.Computer)if theRetentionStrategyneeds to control availability.- Parameters:
acceptingTasks-trueif the agent can accept tasks.
-
isUnix
Description copied from class:ComputerTrue if this computer is a Unix machine (as opposed to Windows machine). -
getNode
Description copied from class:ComputerReturns theNodethat this computer represents. -
getListener
Offers a way to write to the log file for this agent.- Since:
- 2.9
-
getIconClassName
Description copied from class:ComputerReturns the class name that will be used to look up the icon.This class name will be added as a class tag to the html img tags where the icon should show up followed by a size specifier given by
Icon.toNormalizedIconSizeClass(String)The conversion of class tag to src tag is registered throughIconSet.addIcon(Icon)- Specified by:
getIconClassNamein interfaceIComputer- Specified by:
getIconClassNamein interfaceIconSpec- Overrides:
getIconClassNamein classComputer- Returns:
- The Icon class specification e.g. 'icon-notepad'.
- See Also:
-
isJnlpAgent
Deprecated.since 2008-05-20.Description copied from class:ComputerReturns true if this computer is supposed to be launched via inbound protocol.- Overrides:
isJnlpAgentin classComputer
-
isLaunchSupported
public boolean isLaunchSupported()- Specified by:
isLaunchSupportedin interfaceIComputer- Overrides:
isLaunchSupportedin classComputer- Returns:
- true if this computer can be launched by Jenkins proactively and automatically.
For example, inbound agents return
falsefrom this, because the launch process needs to be initiated from the agent side.
-
getLauncher
Return theComputerLauncherfor thisSlaveComputer.- Since:
- 1.312
-
getDelegatedLauncher
Return theComputerLauncherfor this SlaveComputer, strips off anyDelegatingComputerLaunchers orComputerLauncherFilters.- Since:
- 2.83
-
_connect
Description copied from class:ComputerAllows implementing-classes to provide an implementation for the connect method.If already connected or if this computer doesn't support proactive launching, no-op. This method may return immediately while the launch operation happens asynchronously.
- Specified by:
_connectin classComputer- Parameters:
forceReconnect- If true and a connect activity is already in progress, it will be cancelled and the new one will be started. If false, and a connect activity is already in progress, this method will do nothing and just return the pending connection operation.- Returns:
- A
Futurerepresenting pending completion of the task. The 'completion' includes both a successful completion and a non-successful completion (such distinction typically doesn't make much sense because as soon asComputeris connected it can be disconnected by some other threads.) - See Also:
-
taskAccepted
Description copied from interface:ExecutorListenerCalled whenever a task is accepted by an executor.- Parameters:
executor- The executor.task- The task.
-
taskStarted
Description copied from interface:ExecutorListenerCalled whenever a task is started by an executor.- Parameters:
executor- The executor.task- The task.
-
taskCompleted
Description copied from interface:ExecutorListenerCalled whenever a task is completed without any problems by an executor.- Parameters:
executor- The executor.task- The task.durationMS- The number of milliseconds that the task took to complete.
-
taskCompletedWithProblems
public void taskCompletedWithProblems(Executor executor, Queue.Task task, long durationMS, Throwable problems) Description copied from interface:ExecutorListenerCalled whenever a task is completed with some problems by an executor.- Parameters:
executor- The executor.task- The task.durationMS- The number of milliseconds that the task took to complete.problems- The exception that was thrown.
-
isConnecting
public boolean isConnecting()- Returns:
- true if the node is currently connecting to the Jenkins controller.
-
openLogFile
-
setChannel
public void setChannel(@NonNull InputStream in, @NonNull OutputStream out, @NonNull TaskListener taskListener, @CheckForNull hudson.remoting.Channel.Listener listener) throws IOException, InterruptedException Creates aChannelfrom the given stream and sets that to this agent. Same assetChannel(InputStream, OutputStream, OutputStream, Channel.Listener), but forTaskListener.- Throws:
IOExceptionInterruptedException
-
setChannel
public void setChannel(@NonNull InputStream in, @NonNull OutputStream out, @CheckForNull OutputStream launchLog, @CheckForNull hudson.remoting.Channel.Listener listener) throws IOException, InterruptedException Creates aChannelfrom the given stream and sets that to this agent.- Parameters:
in- Stream connected to the remote agent. It's the caller's responsibility to do buffering on this stream, if that's necessary.out- Stream connected to the remote peer. It's the caller's responsibility to do buffering on this stream, if that's necessary.launchLog- If non-null, receive the portion of data inisbefore the data goes into the "binary mode". This is useful when the established communication channel might include some data that might be useful for debugging/trouble-shooting.listener- Gets a notification when the channel closes, to perform clean up. Can be null. By the time this method is called, the cause of the termination is reported to the user, so the implementation of the listener doesn't need to do that again.- Throws:
IOExceptionInterruptedException
-
setChannel
@Restricted(org.kohsuke.accmod.restrictions.Beta.class) public void setChannel(@NonNull hudson.remoting.ChannelBuilder cb, @NonNull hudson.remoting.CommandTransport commandTransport, @CheckForNull hudson.remoting.Channel.Listener listener) throws IOException, InterruptedException Creates aChannelfrom the given Channel Builder and Command Transport. This method can be used to allowComputerLaunchers to create channels not based on I/O streams.- Parameters:
cb- Channel Builder. To print launch logs this channel builder should have a Header Stream defined (seeChannelBuilder.getHeaderStream()) in this argument or by one ofChannelConfigurators.commandTransport- Command Transportlistener- Gets a notification when the channel closes, to perform clean up. Can benull. By the time this method is called, the cause of the termination is reported to the user, so the implementation of the listener doesn't need to do that again.- Throws:
IOExceptionInterruptedException- Since:
- 2.127
-
getClassLoadingCount
ShowsChannel.classLoadingCount.- Returns:
- Requested value or
-1if the agent is offline. - Throws:
IOExceptionInterruptedException- Since:
- 1.495
-
getClassLoadingPrefetchCacheCount
@CheckReturnValue public int getClassLoadingPrefetchCacheCount() throws IOException, InterruptedExceptionShowsChannel.classLoadingPrefetchCacheCount.- Returns:
- Requested value or
-1in case that capability is not supported or if the agent is offline. - Throws:
IOExceptionInterruptedException- Since:
- 1.519
-
getResourceLoadingCount
ShowsChannel.resourceLoadingCount.- Returns:
- Requested value or
-1if the agent is offline. - Throws:
IOExceptionInterruptedException- Since:
- 1.495
-
getClassLoadingTime
ShowsChannel.classLoadingTime.- Returns:
- Requested value or
-1if the agent is offline. - Throws:
IOExceptionInterruptedException- Since:
- 1.495
-
getResourceLoadingTime
ShowsChannel.resourceLoadingTime.- Returns:
- Requested value or
-1if the agent is offline. - Throws:
IOExceptionInterruptedException- Since:
- 1.495
-
getAbsoluteRemoteFs
Returns the remote FS root absolute path ornullif the agent is off-line. The absolute path may change between connections if the connection method does not provide a consistent working directory and the node's remote FS is specified as a relative path.- Returns:
- the remote FS root absolute path or
nullif the agent is off-line. - Since:
- 1.606
-
getAbsoluteRemotePath
@Exported @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) @CheckForNull public String getAbsoluteRemotePath()Just for restFul api. Returns the remote FS root absolute path ornullif the agent is off-line. The absolute path may change between connections if the connection method does not provide a consistent working directory and the node's remote FS is specified as a relative path.- Returns:
- the remote FS root absolute path or
nullif the agent is off-line or don't have connect permission. - Since:
- 2.125
- See Also:
-
setChannel
public void setChannel(@NonNull hudson.remoting.Channel channel, @CheckForNull OutputStream launchLog, @CheckForNull hudson.remoting.Channel.Listener listener) throws IOException, InterruptedException Sets up the connection through an existing channel.- Parameters:
channel- the channel to use; warning: callers are expected to have calledChannelConfiguratoralready.launchLog- Launch log. If notnull, will receive launch log messageslistener- Channel event listener to be attached (if notnull)- Throws:
IOExceptionInterruptedException- Since:
- 1.444
-
getChannel
public hudson.remoting.Channel getChannel()Description copied from class:ComputerGets the channel that can be used to run a program on this computer.- Specified by:
getChannelin classComputer- Returns:
- never null when
Computer.isOffline()==false.
-
getDefaultCharset
Description copied from class:ComputerGets the default charset of this computer.- Specified by:
getDefaultCharsetin classComputer- Returns:
- never null when
Computer.isOffline()==false.
-
getLogRecords
Description copied from class:ComputerGets the logs recorded by this agent.- Specified by:
getLogRecordsin classComputer- Throws:
IOExceptionInterruptedException
-
doSubmitDescription
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public void doSubmitDescription(org.kohsuke.stapler.StaplerResponse2 rsp, @QueryParameter String description) throws IOException Inline editing of description- Throws:
IOException
-
doDoDisconnect
-
disconnect
Description copied from class:ComputerDisconnect this computer. If this is the built-in node, no-op. This method may return immediately while the launch operation happens asynchronously.- Overrides:
disconnectin classComputer- Parameters:
cause- Object that identifies the reason the node was disconnected.- Returns:
Futureto track the asynchronous disconnect operation.- See Also:
-
doLaunchSlaveAgent
public void doLaunchSlaveAgent(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) throws IOException Description copied from class:ComputerIfComputer.getChannel()==null, attempts to relaunch the agent.- Specified by:
doLaunchSlaveAgentin classComputer- Throws:
IOException
-
tryReconnect
public void tryReconnect() -
getJnlpJars
Deprecated.since 2008-08-18. This URL binding is no longer used and moved up directly under toJenkins, but it's left here for now just in case some old inbound agents request it.Serves jar files for inbound agents. -
doSlaveAgentJnlp
@WebMethod(name="slave-agent.jnlp") public org.kohsuke.stapler.HttpResponse doSlaveAgentJnlp(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 res) -
doJenkinsAgentJnlp
@WebMethod(name="jenkins-agent.jnlp") public org.kohsuke.stapler.HttpResponse doJenkinsAgentJnlp(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 res) -
getTarget
-
kill
protected void kill()Description copied from class:ComputerCalled byAbstractCIBase.updateComputerList(boolean, Collection)to notifyComputerthat it will be discarded.Note that at this point
Computer.getNode()returns null. -
closeLog
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public void closeLog() -
getRetentionStrategy
Description copied from class:ComputerRetentionStrategyassociated with this computer.- Specified by:
getRetentionStrategyin classComputer- Returns:
- never null. This method return
RetentionStrategy<? super T>whereT=this.getClass().
-
setNode
Description copied from class:Computer -
toString
-
grabLauncher
Grabs aComputerLauncherout ofNodeto keep it in thisComputer. The returned launcher will be set tolauncherand used to carry out the actual launch operation.Subtypes that needs to decorate
ComputerLaunchercan do so by overriding this method. This is useful forSlaveComputers for clouds for example, where one normally needs additional pre-launch step (such as waiting for the provisioned node to become available) before the user specified launch step (like SSH connection) kicks in.- See Also:
-
getSlaveVersion
Get the agent version- Throws:
IOExceptionInterruptedException
-
getOSDescription
Get the OS description.- Throws:
IOExceptionInterruptedException
-
getEnvVarsFull
@CheckReturnValue public Map<String,String> getEnvVarsFull() throws IOException, InterruptedExceptionExpose real full env vars map from agent for UI presentation- Throws:
IOExceptionInterruptedException
-
getChannelToMaster
Deprecated.UseAgentComputerUtil.getChannelToController()instead.Obtains aVirtualChannelthat allows some computation to be performed on the controller. This method can be called from any thread on the controller, or from agent (more precisely, it only works from the remoting request-handling thread in agents, which means if you've started separate thread on agents, that'll fail.)- Returns:
- null if the calling thread doesn't have any trace of where its controller is.
- Since:
- 1.362
-
getSystemInfoExtensions
@Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) @RestrictedSince("2.163") public static List<SlaveSystemInfo> getSystemInfoExtensions()Helper method for Jelly.
-
AgentComputerUtil.getChannelToController()instead.