Class Computer
- java.lang.Object
-
- hudson.model.AbstractModelObject
-
- hudson.model.Actionable
-
- hudson.model.Computer
-
- All Implemented Interfaces:
ExtensionPoint,DescriptorByNameOwner,ExecutorListener,ModelObject,SearchableModelObject,SearchItem,AccessControlled,ModelObjectWithContextMenu,HasWidgets,org.kohsuke.stapler.StaplerProxy
- Direct Known Subclasses:
Jenkins.MasterComputer,SlaveComputer
@ExportedBean public abstract class Computer extends Actionable implements AccessControlled, ExecutorListener, DescriptorByNameOwner, org.kohsuke.stapler.StaplerProxy, HasWidgets
Represents the running state of a remote computer that holdsExecutors.Executors on oneComputerare transparently interchangeable (that is the definition ofComputer).This object is related to
Nodebut they have some significant differences.Computerprimarily works as a holder ofExecutors, so if aNodeis configured (probably temporarily) with 0 executors, you won't have aComputerobject for it (except for the built-in node, which always gets itsComputerin case we have no static executors and we need to run aQueue.FlyweightTask- see JENKINS-7291 for more discussion.) Also, even if you remove aNode, it takes time for the correspondingComputerto be removed, if some builds are already in progress on that node. Or when the node configuration is changed, unaffectedComputerobject remains intact, while all theNodeobjects will go away.This object also serves UI (unlike
Node), and can be used along withTransientComputerActionFactoryto addActions toComputers.- Author:
- Kohsuke Kawaguchi
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classComputer.DisplayExecutorA value class to provide a consistent snapshot view of the state of an executor to avoid race conditions during rendering of the executors list.static classComputer.TerminationRequestUsed to trace requests to terminate a computer.-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Nested classes/interfaces inherited from interface jenkins.model.ModelObjectWithContextMenu
ModelObjectWithContextMenu.ContextMenu, ModelObjectWithContextMenu.ContextMenuVisibility, ModelObjectWithContextMenu.MenuItem, ModelObjectWithContextMenu.MenuItemType
-
-
Field Summary
Fields Modifier and Type Field Description static PermissionBUILDstatic PermissionCONFIGUREstatic PermissionCONNECTstatic PermissionCREATEstatic PermissionDELETEstatic PermissionDISCONNECTstatic PermissionEXTENDED_READstatic Permission[]EXTENDED_READ_AND_CONNECTprotected StringnodeNameNodeobject may be created and deleted independently from this object.protected OfflineCauseofflineCauseContains info about reason behind computer being offline.static PermissionGroupPERMISSIONSstatic booleanSKIP_PERMISSION_CHECKEscape hatch for StaplerProxy-based access controlprotected ObjectstatusChangeLockstatic ExecutorServicethreadPoolForRemotingprotected List<Action>transientActions
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected abstract Future<?>_connect(boolean forceReconnect)Allows implementing-classes to provide an implementation for the connect method.protected void_doScript(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp, String view)voidaddAction(Action a)Adds a new action.EnvVarsbuildEnvironment(TaskListener listener)Creates an environment variable override to be used for launching processes on this node.voidcliConnect(boolean force)Deprecated.Implementation of CLI command "connect-node" moved toConnectNodeCommand.voidcliDisconnect(String cause)Deprecated.Implementation of CLI command "disconnect-node" moved toDisconnectNodeCommand.voidcliOffline(String cause)Deprecated.Implementation of CLI command "offline-node" moved toOfflineNodeCommand.voidcliOnline()Deprecated.Implementation of CLI command "online-node" moved toOnlineNodeCommand.Future<?>connect(boolean forceReconnect)Do the same asdoLaunchSlaveAgent(StaplerRequest, StaplerResponse)but outside the context of serving a request.intcountBusy()Returns the number ofExecutors that are doing some work right now.intcountExecutors()Returns the current size of the executor pool for this computer.intcountIdle()Returns the number of idleExecutors that can start working immediately.static ComputercurrentComputer()Gets the currentComputerthat the build is running.Future<?>disconnect()Deprecated.as of 1.320.Future<?>disconnect(OfflineCause cause)Disconnect this computer.org.kohsuke.stapler.HttpResponsedoChangeOfflineCause(String offlineMessage)voiddoConfigDotXml(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)Acceptsconfig.xmlsubmission, as well as serve it.voiddoConfigSubmit(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)Accepts the update to the node configuration.org.kohsuke.stapler.HttpResponsedoDoDelete()Really deletes the agent.voiddoDumpExportTable(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)Dumps the contents of the export table.abstract voiddoLaunchSlaveAgent(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)IfgetChannel()==null, attempts to relaunch the agent.voiddoProgressiveLog(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)Handles incremental log.voiddoRssAll(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)voiddoRssFailed(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)voiddoRssLatest(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)Retrieve the RSS feed for the last build for each project executed in this computer.voiddoScript(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)For system diagnostics.voiddoScriptText(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)Run arbitrary Groovy script and return result as plain text.org.kohsuke.stapler.HttpResponsedoToggleOffline(String offlineMessage)ACLgetACL()Obtains the ACL associated with this object.List<Action>getActions()Returns the transientActions associated with the computer.List<Executor>getAllExecutors()Gets the read-only snapshot view of allExecutorinstances including OneOffExecutors.ApigetApi()Set<LabelAtom>getAssignedLabels()RunListgetBuilds()StringgetCaption()abstract hudson.remoting.VirtualChannelgetChannel()Gets the channel that can be used to run a program on this computer.List<ComputerPanelBox>getComputerPanelBoxs()Returns list of all boxesComputerPanelBoxs.longgetConnectTime()Gets the time (since epoch) when this computer connected.abstract CharsetgetDefaultCharset()Gets the default charset of this computer.longgetDemandStartMilliseconds()Returns the time when this computer first became in demand.StringgetDescription()Returns theNodedescription for this computer.List<Computer.DisplayExecutor>getDisplayExecutors()Used to render the list of executors.StringgetDisplayName()EnvVarsgetEnvironment()Returns cached environment variables (copy to prevent modification) for the JVM on this computer.Map<String,String>getEnvVars()Deprecated.as of 1.292 UsegetEnvironment()instead.List<Executor>getExecutors()Gets the read-only snapshot view of allExecutors.RemotingDiagnostics.HeapDumpgetHeapDump()Obtains the heap dump.StringgetHostName()This method tries to compute the name of the host that's reachable by all the other nodes.StringgetIcon()Returns the icon for this computer.StringgetIconAltText()StringgetIconClassName()Returns the class name that will be used to lookup the icon.longgetIdleStartMilliseconds()Returns the time when this computer last became idle.LoadStatisticsgetLoadStatistics()StringgetLog()Gets the string representation of the agent log.protected FilegetLogDir()Directory where rotated agent logs are stored.FilegetLogFile()This is where the log from the remote agent goes.abstract List<LogRecord>getLogRecords()Gets the logs recorded by this agent.AnnotatedLargeText<Computer>getLogText()Used to URL-bindAnnotatedLargeText.Map<String,Object>getMonitorData()Expose monitoring data for the remote API.Map<NodeMonitor,Object>getMonitoringData()StringgetName()Returnsthe name of the node.NodegetNode()Returns theNodethat this computer represents.intgetNumExecutors()Number ofExecutors that are configured for this computer.OfflineCausegetOfflineCause()If the computer was offline (either temporarily or not), this method will return the cause.StringgetOfflineCauseReason()If the computer was offline (either temporarily or not), this method will return the cause as a string (without user info).List<OneOffExecutor>getOneOffExecutors()Gets the read-only snapshot view of allOneOffExecutors.abstract RetentionStrategygetRetentionStrategy()RetentionStrategyassociated with this computer.StringgetSearchUrl()Returns the URL of this item relative to the parentSearchItem.Map<Object,Object>getSystemProperties()Gets the system properties of the JVM on this computer.ObjectgetTarget()List<Computer.TerminationRequest>getTerminatedBy()Returns the list of captured termination requests for this Computer.Map<String,String>getThreadDump()Gets the thread dump of the agent JVM.List<AbstractProject>getTiedJobs()Returns projects that are tied on this node.BuildTimelineWidgetgetTimeline()Deprecated.StringgetUrl()WorkspaceListgetWorkspaceList()Gets the object that coordinates the workspace allocation on this computer.voidinterrupt()Interrupt allExecutors.booleanisAcceptingTasks()Returnstrueif the computer is accepting tasks.protected booleanisAlive()Returns true if any of the executors are active.abstract booleanisConnecting()Is aconnect(boolean)operation in progress?booleanisIdle()Returns true if all the executors of this computer are idle.booleanisJnlpAgent()Deprecated.since 2008-05-18.booleanisLaunchSupported()Returns true if this computer can be launched by Hudson proactively and automatically.booleanisManualLaunchAllowed()This method is called to determine whether manual launching of the agent is allowed at this point in time.booleanisOffline()booleanisOnline()booleanisPartiallyIdle()Returns true if this computer has some idle executors that can take more workload.booleanisTemporarilyOffline()Deprecated.You should almost always wantisOffline().abstract BooleanisUnix()True if this computer is a Unix machine (as opposed to Windows machine).protected voidkill()Called byJenkins.updateComputerList()to notifyComputerthat it will be discarded.voidlaunch()Deprecated.since 2009-01-06.protected voidonRemoved()Called byJenkinswhen this computer is removed.voidrecordTermination()This method captures the information of a request to terminate a computer instance.static voidrelocateOldLogs()Relocate log files in the old location to the new location.protected voidremoveExecutor(Executor e)Called byExecutorto kill excessive executors from this computer.static ComputerresolveForCLI(String name)Used for CLI binding.protected voidsetNode(Node node)voidsetTemporarilyOffline(boolean temporarilyOffline)Deprecated.as of 1.320.voidsetTemporarilyOffline(boolean temporarilyOffline, OfflineCause cause)Marks the computer as temporarily offline.voidupdateByXml(InputStream source)Updates Job by its XML definition.voidwaitUntilOffline()voidwaitUntilOnline()Blocks until the node becomes online/offline.-
Methods inherited from class hudson.model.Actionable
addOrReplaceAction, doContextMenu, getAction, getAction, getActions, getAllActions, getDynamic, removeAction, removeActions, replaceAction, replaceActions
-
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, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface hudson.security.AccessControlled
checkAnyPermission, checkPermission, hasAnyPermission, hasPermission, hasPermission, hasPermission2
-
Methods inherited from interface hudson.model.DescriptorByNameOwner
getDescriptorByName
-
Methods inherited from interface hudson.model.ExecutorListener
taskAccepted, taskCompleted, taskCompletedWithProblems, taskStarted
-
Methods inherited from interface jenkins.widgets.HasWidgets
getWidget, getWidgets
-
-
-
-
Field Detail
-
offlineCause
protected volatile OfflineCause offlineCause
Contains info about reason behind computer being offline.
-
nodeName
protected String nodeName
Nodeobject may be created and deleted independently from this object.
-
statusChangeLock
protected final Object statusChangeLock
-
threadPoolForRemoting
public static final ExecutorService threadPoolForRemoting
-
SKIP_PERMISSION_CHECK
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public static boolean SKIP_PERMISSION_CHECK
Escape hatch for StaplerProxy-based access control
-
PERMISSIONS
public static final PermissionGroup PERMISSIONS
-
CONFIGURE
public static final Permission CONFIGURE
-
EXTENDED_READ
public static final Permission EXTENDED_READ
- Since:
- 1.532
-
DELETE
public static final Permission DELETE
-
CREATE
public static final Permission CREATE
-
DISCONNECT
public static final Permission DISCONNECT
-
CONNECT
public static final Permission CONNECT
-
BUILD
public static final Permission BUILD
-
EXTENDED_READ_AND_CONNECT
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public static final Permission[] EXTENDED_READ_AND_CONNECT
-
-
Constructor Detail
-
Computer
protected Computer(Node node)
-
-
Method Detail
-
recordTermination
public void recordTermination()
This method captures the information of a request to terminate a computer instance. Method is public as it needs to be called fromAbstractCloudSlaveandNodes. In general you should not need to call this method directly, however if implementing a custom node type or a different path for removing nodes, it may make sense to call this method in order to capture the originating request.- Since:
- 1.607
-
getTerminatedBy
public List<Computer.TerminationRequest> getTerminatedBy()
Returns the list of captured termination requests for this Computer. This method is used byExecutorto provide details on why a Computer was removed in-between work being scheduled against theExecutorand theExecutorstarting to execute the task.- Returns:
- the (possibly empty) list of termination requests.
- Since:
- 1.607
- See Also:
Executor.resetWorkUnit(String)
-
getComputerPanelBoxs
public List<ComputerPanelBox> getComputerPanelBoxs()
Returns list of all boxesComputerPanelBoxs.
-
getActions
@NonNull public List<Action> getActions()
Returns the transientActions associated with the computer.- Overrides:
getActionsin classActionable- Returns:
- a possibly empty list
-
addAction
public void addAction(@NonNull Action a)Description copied from class:ActionableAdds a new action. Note: calls toActionable.getAllActions()that happen before calls to this method may not see the update. Note: this method will always modify the actions- Overrides:
addActionin classActionable
-
getLogFile
@NonNull public File getLogFile()
This is where the log from the remote agent goes. The method also creates a log directory if required.- See Also:
getLogDir(),relocateOldLogs()
-
getLogDir
@NonNull protected File getLogDir()
Directory where rotated agent logs are stored. The method also creates a log directory if required.- Since:
- 1.613
-
getWorkspaceList
public WorkspaceList getWorkspaceList()
Gets the object that coordinates the workspace allocation on this computer.
-
getLog
public String getLog() throws IOException
Gets the string representation of the agent log.- Throws:
IOException
-
getLogText
public AnnotatedLargeText<Computer> getLogText()
Used to URL-bindAnnotatedLargeText.
-
getACL
@NonNull public ACL getACL()
Description copied from interface:AccessControlledObtains the ACL associated with this object.- Specified by:
getACLin interfaceAccessControlled- Returns:
- never null.
-
getOfflineCause
@Exported public OfflineCause getOfflineCause()
If the computer was offline (either temporarily or not), this method will return the cause.- Returns:
- null if the system was put offline without given a cause.
-
getOfflineCauseReason
@Exported public String getOfflineCauseReason()
If the computer was offline (either temporarily or not), this method will return the cause as a string (without user info).- Returns:
- empty string if the system was put offline without given a cause.
-
getChannel
@Nullable public abstract hudson.remoting.VirtualChannel getChannel()
Gets the channel that can be used to run a program on this computer.- Returns:
- never null when
isOffline()==false.
-
getDefaultCharset
public abstract Charset getDefaultCharset()
Gets the default charset of this computer.- Returns:
- never null when
isOffline()==false.
-
getLogRecords
public abstract List<LogRecord> getLogRecords() throws IOException, InterruptedException
Gets the logs recorded by this agent.- Throws:
IOExceptionInterruptedException
-
doLaunchSlaveAgent
public abstract void doLaunchSlaveAgent(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletExceptionIfgetChannel()==null, attempts to relaunch the agent.- Throws:
IOExceptionjavax.servlet.ServletException
-
launch
@Deprecated public final void launch()
Deprecated.since 2009-01-06. Useconnect(boolean)
-
connect
public final Future<?> connect(boolean forceReconnect)
Do the same asdoLaunchSlaveAgent(StaplerRequest, StaplerResponse)but outside the context of serving a request.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.
- 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:
disconnect()
-
_connect
protected abstract Future<?> _connect(boolean forceReconnect)
Allows 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.
- 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:
disconnect()
-
cliConnect
@Deprecated public void cliConnect(boolean force) throws ExecutionException, InterruptedException
Deprecated.Implementation of CLI command "connect-node" moved toConnectNodeCommand.- Parameters:
force- If true cancel any currently pending connect operation and retry from scratch- Throws:
ExecutionExceptionInterruptedException
-
getConnectTime
public final long getConnectTime()
Gets the time (since epoch) when this computer connected.- Returns:
- The time in ms since epoch when this computer last connected.
-
disconnect
public Future<?> disconnect(OfflineCause cause)
Disconnect this computer. If this is the built-in node, no-op. This method may return immediately while the launch operation happens asynchronously.- Parameters:
cause- Object that identifies the reason the node was disconnected.- Returns:
Futureto track the asynchronous disconnect operation.- Since:
- 1.320
- See Also:
connect(boolean)
-
disconnect
@Deprecated public Future<?> disconnect()
Deprecated.as of 1.320. Usedisconnect(OfflineCause)and specify the cause.Equivalent todisconnect(null)
-
cliDisconnect
@Deprecated public void cliDisconnect(String cause) throws ExecutionException, InterruptedException
Deprecated.Implementation of CLI command "disconnect-node" moved toDisconnectNodeCommand.- Parameters:
cause- Record the note about why you are disconnecting this node- Throws:
ExecutionExceptionInterruptedException
-
cliOffline
@Deprecated public void cliOffline(String cause) throws ExecutionException, InterruptedException
Deprecated.Implementation of CLI command "offline-node" moved toOfflineNodeCommand.- Parameters:
cause- Record the note about why you are disconnecting this node- Throws:
ExecutionExceptionInterruptedException
-
cliOnline
@Deprecated public void cliOnline() throws ExecutionException, InterruptedException
Deprecated.Implementation of CLI command "online-node" moved toOnlineNodeCommand.
-
getNumExecutors
@Exported public int getNumExecutors()
-
getName
@NonNull public String getName()
Returnsthe name of the node.
-
isUnix
@CheckForNull public abstract Boolean isUnix()
True if this computer is a Unix machine (as opposed to Windows machine).- Returns:
nullif the computer is disconnected and therefore we don't know whether it is Unix or not.- Since:
- 1.624
-
getNode
@CheckForNull public Node getNode()
Returns theNodethat this computer represents.- Returns:
- null if the configuration has changed and the node is removed, yet the corresponding
Computeris not yet gone.
-
getLoadStatistics
@Exported public LoadStatistics getLoadStatistics()
-
getTimeline
@Deprecated @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) public BuildTimelineWidget getTimeline()
Deprecated.
-
isOffline
@Exported public boolean isOffline()
-
isOnline
public final boolean isOnline()
-
isManualLaunchAllowed
@Exported public boolean isManualLaunchAllowed()
This method is called to determine whether manual launching of the agent is allowed at this point in time.- Returns:
trueif manual launching of the agent is allowed at this point in time.
-
isConnecting
public abstract boolean isConnecting()
Is aconnect(boolean)operation in progress?
-
isJnlpAgent
@Exported @Deprecated public boolean isJnlpAgent()
Deprecated.since 2008-05-18. See isLaunchSupported() and ComputerLauncherReturns true if this computer is supposed to be launched via inbound protocol.
-
isLaunchSupported
@Exported public boolean isLaunchSupported()
Returns true if this computer can be launched by Hudson proactively and automatically.For example, inbound agents return
falsefrom this, because the launch process needs to be initiated from the agent side.
-
isTemporarilyOffline
@Exported @Deprecated public boolean isTemporarilyOffline()
Deprecated.You should almost always wantisOffline(). This method is marked as deprecated to warn people when they accidentally call this method.Returns true if this node is marked temporarily offline by the user.In contrast,
isOffline()represents the actual online/offline state. For example, this method may return false whileisOffline()returns true if the agent failed to launch.
-
setTemporarilyOffline
@Deprecated public void setTemporarilyOffline(boolean temporarilyOffline)
Deprecated.as of 1.320. UsesetTemporarilyOffline(boolean, OfflineCause)
-
setTemporarilyOffline
public void setTemporarilyOffline(boolean temporarilyOffline, OfflineCause cause)Marks the computer as temporarily offline. This retains the underlyingChannelconnection, but prevent builds from executing.- Parameters:
cause- If the first argument is true, specify the reason why the node is being put offline.
-
getIcon
@Exported public String getIcon()
Returns the icon for this computer. It is both the recommended and default implementation to serve different icons based onisOffline()- See Also:
getIconClassName()
-
getIconClassName
@Exported public String getIconClassName()
Returns the class name that will be used to lookup 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 byIcon.toNormalizedIconSizeClass(String)The conversion of class tag to src tag is registered throughIconSet.addIcon(Icon)It is both the recommended and default implementation to serve different icons based onisOffline()- See Also:
getIcon()
-
getIconAltText
public String getIconAltText()
-
getDisplayName
@Exported @NonNull public String getDisplayName()
- Specified by:
getDisplayNamein interfaceModelObject
-
getCaption
public String getCaption()
-
getUrl
public String getUrl()
-
getTiedJobs
public List<AbstractProject> getTiedJobs()
Returns projects that are tied on this node.
-
getBuilds
public RunList getBuilds()
-
setNode
protected void setNode(Node node)
-
kill
protected void kill()
Called byJenkins.updateComputerList()to notifyComputerthat it will be discarded.Note that at this point
getNode()returns null.- See Also:
onRemoved()
-
onRemoved
protected void onRemoved()
Called byJenkinswhen this computer is removed.This happens when list of nodes are updated (for example by
Jenkins.setNodes(List)and the computer becomes redundant. SuchComputers get killed, then after all its executors are finished, this method is called.Note that at this point
getNode()returns null.- Since:
- 1.510
- See Also:
kill()
-
countIdle
public int countIdle()
Returns the number of idleExecutors that can start working immediately.
-
countBusy
public final int countBusy()
Returns the number ofExecutors that are doing some work right now.
-
countExecutors
public final int countExecutors()
Returns the current size of the executor pool for this computer. This number may temporarily differ fromgetNumExecutors()if there are busy tasks when the configured size is decreased. OneOffExecutors are not included in this count.
-
getExecutors
@Exported @StaplerDispatchable public List<Executor> getExecutors()
Gets the read-only snapshot view of allExecutors.
-
getOneOffExecutors
@Exported @StaplerDispatchable public List<OneOffExecutor> getOneOffExecutors()
Gets the read-only snapshot view of allOneOffExecutors.
-
getAllExecutors
public List<Executor> getAllExecutors()
Gets the read-only snapshot view of allExecutorinstances including OneOffExecutors.- Returns:
- the read-only snapshot view of all
Executorinstances including OneOffExecutors. - Since:
- 2.55
-
getDisplayExecutors
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public List<Computer.DisplayExecutor> getDisplayExecutors()
Used to render the list of executors.- Returns:
- a snapshot of the executor display information
- Since:
- 1.607
-
isIdle
@Exported public final boolean isIdle()
Returns true if all the executors of this computer are idle.
-
isPartiallyIdle
public final boolean isPartiallyIdle()
Returns true if this computer has some idle executors that can take more workload.
-
getIdleStartMilliseconds
public final long getIdleStartMilliseconds()
Returns the time when this computer last became idle.If this computer is already idle, the return value will point to the time in the past since when this computer has been idle.
If this computer is busy, the return value will point to the time in the future where this computer will be expected to become free.
-
getDemandStartMilliseconds
public final long getDemandStartMilliseconds()
Returns the time when this computer first became in demand.
-
getDescription
@Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) @Exported @NonNull public String getDescription()
-
removeExecutor
protected void removeExecutor(Executor e)
Called byExecutorto kill excessive executors from this computer.
-
isAlive
protected boolean isAlive()
Returns true if any of the executors are active.- Since:
- 1.509
-
interrupt
public void interrupt()
Interrupt allExecutors. Called fromJenkins.cleanUp().
-
getSearchUrl
public String getSearchUrl()
Description copied from interface:SearchItemReturns the URL of this item relative to the parentSearchItem.- Specified by:
getSearchUrlin interfaceSearchItem- Returns:
- URL like "foo" or "foo/bar". The path can end with '/'. The path that starts with '/' will be interpreted as the absolute path (within the context path of Jenkins.)
-
getRetentionStrategy
public abstract RetentionStrategy getRetentionStrategy()
RetentionStrategyassociated with this computer.- Returns:
- never null. This method return
RetentionStrategy<? super T>whereT=this.getClass().
-
getMonitorData
@Exported(inline=true) public Map<String,Object> getMonitorData()
Expose monitoring data for the remote API.
-
getMonitoringData
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public Map<NodeMonitor,Object> getMonitoringData()
-
getSystemProperties
public Map<Object,Object> getSystemProperties() throws IOException, InterruptedException
Gets the system properties of the JVM on this computer. If this is the master, it returns the system property of the master computer.- Throws:
IOExceptionInterruptedException
-
getEnvVars
@Deprecated public Map<String,String> getEnvVars() throws IOException, InterruptedException
Deprecated.as of 1.292 UsegetEnvironment()instead.- Throws:
IOExceptionInterruptedException
-
getEnvironment
public EnvVars getEnvironment() throws IOException, InterruptedException
Returns cached environment variables (copy to prevent modification) for the JVM on this computer. If this is the master, it returns the system property of the master computer.- Throws:
IOExceptionInterruptedException
-
buildEnvironment
@NonNull public EnvVars buildEnvironment(@NonNull TaskListener listener) throws IOException, InterruptedException
Creates an environment variable override to be used for launching processes on this node.- Throws:
IOExceptionInterruptedException- Since:
- 1.489
- See Also:
Launcher.ProcStarter.envs(Map)
-
getThreadDump
public Map<String,String> getThreadDump() throws IOException, InterruptedException
Gets the thread dump of the agent JVM.- Returns:
- key is the thread name, and the value is the pre-formatted dump.
- Throws:
IOExceptionInterruptedException
-
getHeapDump
public RemotingDiagnostics.HeapDump getHeapDump() throws IOException
Obtains the heap dump.- Throws:
IOException
-
getHostName
public String getHostName() throws IOException, InterruptedException
This method tries to compute the name of the host that's reachable by all the other nodes.Since it's possible that the agent is not reachable from the master (it may be behind a firewall, connecting to master via inbound protocol), this method may return null. It's surprisingly tricky for a machine to know a name that other systems can get to, especially between things like DNS search suffix, the hosts file, and YP.
So the technique here is to compute possible interfaces and names on the agent, then try to ping them from the master, and pick the one that worked.
The computation may take some time, so it employs caching to make the successive lookups faster.
- Returns:
- null if the host name cannot be computed (for example because this computer is offline, because the agent is behind the firewall, etc.)
- Throws:
IOExceptionInterruptedException- Since:
- 1.300
-
doRssAll
@Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) public void doRssAll(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException- Throws:
IOExceptionjavax.servlet.ServletException
-
doRssFailed
@Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) public void doRssFailed(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException- Throws:
IOExceptionjavax.servlet.ServletException
-
doRssLatest
@Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) public void doRssLatest(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletExceptionRetrieve the RSS feed for the last build for each project executed in this computer. Only the information fromAbstractProjectis displayed since there isn't a proper API to gather information about the node where the builds are executed for other sorts of projects such as Pipeline- Throws:
IOExceptionjavax.servlet.ServletException- Since:
- 2.215
-
doToggleOffline
public org.kohsuke.stapler.HttpResponse doToggleOffline(@QueryParameter String offlineMessage) throws IOException, javax.servlet.ServletException- Throws:
IOExceptionjavax.servlet.ServletException
-
doChangeOfflineCause
public org.kohsuke.stapler.HttpResponse doChangeOfflineCause(@QueryParameter String offlineMessage) throws IOException, javax.servlet.ServletException- Throws:
IOExceptionjavax.servlet.ServletException
-
getApi
public Api getApi()
-
doDumpExportTable
public void doDumpExportTable(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException, InterruptedExceptionDumps the contents of the export table.- Throws:
IOExceptionjavax.servlet.ServletExceptionInterruptedException
-
doScript
public void doScript(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletExceptionFor system diagnostics. Run arbitrary Groovy script.- Throws:
IOExceptionjavax.servlet.ServletException
-
doScriptText
public void doScriptText(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletExceptionRun arbitrary Groovy script and return result as plain text.- Throws:
IOExceptionjavax.servlet.ServletException
-
_doScript
protected void _doScript(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp, String view) throws IOException, javax.servlet.ServletException- Throws:
IOExceptionjavax.servlet.ServletException
-
doConfigSubmit
@POST public void doConfigSubmit(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException, Descriptor.FormExceptionAccepts the update to the node configuration.- Throws:
IOExceptionjavax.servlet.ServletExceptionDescriptor.FormException
-
doConfigDotXml
@WebMethod(name="config.xml") public void doConfigDotXml(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletExceptionAcceptsconfig.xmlsubmission, as well as serve it.- Throws:
IOExceptionjavax.servlet.ServletException
-
updateByXml
public void updateByXml(InputStream source) throws IOException, javax.servlet.ServletException
Updates Job by its XML definition.- Throws:
IOExceptionjavax.servlet.ServletException- Since:
- 1.526
-
doDoDelete
public org.kohsuke.stapler.HttpResponse doDoDelete() throws IOExceptionReally deletes the agent.- Throws:
IOException
-
waitUntilOnline
public void waitUntilOnline() throws InterruptedExceptionBlocks until the node becomes online/offline.- Throws:
InterruptedException
-
waitUntilOffline
public void waitUntilOffline() throws InterruptedException- Throws:
InterruptedException
-
doProgressiveLog
public void doProgressiveLog(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOExceptionHandles incremental log.- Throws:
IOException
-
getTarget
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public Object getTarget()
- Specified by:
getTargetin interfaceorg.kohsuke.stapler.StaplerProxy
-
currentComputer
@Nullable public static Computer currentComputer()
Gets the currentComputerthat the build is running. This method only works when called during a build, such as byPublisher,BuildWrapper, etc.- Returns:
- the
Computerassociated withExecutor.currentExecutor(), or (consistently as of 1.591) null if not on an executor thread
-
isAcceptingTasks
@OverrideMustInvoke public boolean isAcceptingTasks()
Returnstrueif the computer is accepting tasks. Needed to allow agents programmatic suspension of task scheduling that does not overlap with being offline.- Returns:
trueif the computer is accepting tasks- See Also:
RetentionStrategy.isAcceptingTasks(Computer),Node.isAcceptingTasks()
-
resolveForCLI
@CLIResolver public static Computer resolveForCLI(String name) throws org.kohsuke.args4j.CmdLineException
Used for CLI binding.- Throws:
org.kohsuke.args4j.CmdLineException
-
relocateOldLogs
@Initializer public static void relocateOldLogs()
Relocate log files in the old location to the new location. Files were used to be $JENKINS_ROOT/slave-NAME.log (and .1, .2, ...) but now they are at $JENKINS_ROOT/logs/slaves/NAME/slave.log (and .1, .2, ...)- See Also:
getLogFile()
-
-