hudson.model
Class Computer

java.lang.Object
  extended by hudson.model.AbstractModelObject
      extended by hudson.model.Actionable
          extended by hudson.model.Computer
All Implemented Interfaces:
ExecutorListener, ModelObject, SearchableModelObject, SearchItem, AccessControlled, ModelObjectWithContextMenu
Direct Known Subclasses:
Jenkins.MasterComputer, SlaveComputer

@ExportedBean
public abstract class Computer
extends Actionable
implements AccessControlled, ExecutorListener

Represents the running state of a remote computer that holds Executors.

Executors on one Computer are transparently interchangeable (that is the definition of Computer.)

This object is related to Node but they have some significant difference. Computer primarily works as a holder of Executors, so if a Node is configured (probably temporarily) with 0 executors, you won't have a Computer object for it (except for the master node, which always get its Computer in case we have no static executors and we need to run a Queue.FlyweightTask - see JENKINS-7291 for more discussion.) Also, even if you remove a Node, it takes time for the corresponding Computer to be removed, if some builds are already in progress on that node. Or when the node configuration is changed, unaffected Computer object remains intact, while all the Node objects will go away.

This object also serves UI (since Node is an interface and can't have related side pages.)

Author:
Kohsuke Kawaguchi

Nested Class Summary
 
Nested classes/interfaces inherited from interface jenkins.model.ModelObjectWithContextMenu
ModelObjectWithContextMenu.ContextMenu, ModelObjectWithContextMenu.MenuItem
 
Field Summary
static Permission CONFIGURE
          Permission to configure slaves.
static Permission CONNECT
           
static Permission CREATE
           
static Permission DELETE
           
static Permission DISCONNECT
           
protected  String nodeName
          Node object may be created and deleted independently from this object.
protected  OfflineCause offlineCause
          Contains info about reason behind computer being offline.
static PermissionGroup PERMISSIONS
           
protected  Object statusChangeLock
           
static ExecutorService threadPoolForRemoting
           
protected  List<Action> transientActions
           
 
Constructor Summary
Computer(Node node)
           
 
Method Summary
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)
           
 void addAction(Action a)
          Adds a new action.
 EnvVars buildEnvironment(TaskListener listener)
          Creates an environment variable override to be used for launching processes on this node.
 void checkPermission(Permission permission)
          Convenient short-cut for getACL().checkPermission(permission)
 void cliConnect(boolean force)
          CLI command to reconnect this node.
 void cliDisconnect(String cause)
          CLI command to disconnects this node.
 void cliOffline(String cause)
          CLI command to mark the node offline.
 void cliOnline()
           
 Future<?> connect(boolean forceReconnect)
          Do the same as doLaunchSlaveAgent(StaplerRequest, StaplerResponse) but outside the context of serving a request.
 int countBusy()
          Returns the number of Executors that are doing some work right now.
 int countExecutors()
          Returns the current size of the executor pool for this computer.
 int countIdle()
          Returns the number of idle Executors that can start working immediately.
static Computer currentComputer()
          Gets the current Computer that the build is running.
 Future<?> disconnect()
          Deprecated. as of 1.320. Use disconnect(OfflineCause) and specify the cause.
 Future<?> disconnect(OfflineCause cause)
          Disconnect this computer.
 org.kohsuke.stapler.HttpResponse doChangeOfflineCause(String offlineMessage)
           
 void doConfigDotXml(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
          Accepts config.xml submission, as well as serve it.
 void doConfigSubmit(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
          Accepts the update to the node configuration.
 org.kohsuke.stapler.HttpResponse doDoDelete()
          Really deletes the slave.
 void doDumpExportTable(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
          Dumps the contents of the export table.
abstract  void doLaunchSlaveAgent(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
          If getChannel()==null, attempts to relaunch the slave agent.
 void doProgressiveLog(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
          Handles incremental log.
 void doRssAll(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
           
 void doRssFailed(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
           
 void doScript(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
          For system diagnostics.
 void doScriptText(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
          Run arbitrary Groovy script and return result as plain text.
 org.kohsuke.stapler.HttpResponse doToggleOffline(String offlineMessage)
           
 ACL getACL()
          Obtains the ACL associated with this object.
 List<Action> getActions()
          Returns the transient Actions associated with the computer.
 Api getApi()
           
 RunList getBuilds()
           
 String getCaption()
           
abstract  hudson.remoting.VirtualChannel getChannel()
          Gets the channel that can be used to run a program on this computer.
 List<ComputerPanelBox> getComputerPanelBoxs()
          Returns list of all boxes ComputerPanelBoxs.
 long getConnectTime()
          Gets the time (since epoch) when this computer connected.
abstract  Charset getDefaultCharset()
          Gets the default charset of this computer.
 long getDemandStartMilliseconds()
          Returns the time when this computer first became in demand.
 String getDisplayName()
           
 EnvVars getEnvironment()
          Gets the environment variables of the JVM on this computer.
 Map<String,String> getEnvVars()
          Deprecated. as of 1.292 Use getEnvironment() instead.
 List<Executor> getExecutors()
          Gets the read-only snapshot view of all Executors.
 RemotingDiagnostics.HeapDump getHeapDump()
          Obtains the heap dump.
 String getHostName()
          This method tries to compute the name of the host that's reachable by all the other nodes.
 String getIcon()
           
 String getIconAltText()
           
 long getIdleStartMilliseconds()
          Returns the time when this computer last became idle.
 LoadStatistics getLoadStatistics()
           
 String getLog()
          Gets the string representation of the slave log.
protected  File getLogFile()
          This is where the log from the remote agent goes.
abstract  List<LogRecord> getLogRecords()
          Gets the logs recorded by this slave.
 AnnotatedLargeText<Computer> getLogText()
          Used to URL-bind AnnotatedLargeText.
 Map<String,Object> getMonitorData()
          Expose monitoring data for the remote API.
 String getName()
          Returns the name of the node.
 Node getNode()
          Returns the Node that this computer represents.
 int getNumExecutors()
          Number of Executors that are configured for this computer.
 OfflineCause getOfflineCause()
          If the computer was offline (either temporarily or not), this method will return the cause.
 String getOfflineCauseReason()
          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 all OneOffExecutors.
abstract  RetentionStrategy getRetentionStrategy()
          RetentionStrategy associated with this computer.
 String getSearchUrl()
          Returns the URL of this item relative to the parent SearchItem.
 Map<Object,Object> getSystemProperties()
          Gets the system properties of the JVM on this computer.
 Map<String,String> getThreadDump()
          Gets the thread dump of the slave JVM.
 List<AbstractProject> getTiedJobs()
          Returns projects that are tied on this node.
 BuildTimelineWidget getTimeline()
           
 String getUrl()
           
 WorkspaceList getWorkspaceList()
          Gets the object that coordinates the workspace allocation on this computer.
 boolean hasPermission(Permission permission)
          Convenient short-cut for getACL().hasPermission(permission)
 void interrupt()
          Interrupt all Executors.
 boolean isAcceptingTasks()
          Returns true if the computer is accepting tasks.
protected  boolean isAlive()
          Returns true if any of the executors are functioning.
abstract  boolean isConnecting()
          Is a connect(boolean) operation in progress?
 boolean isIdle()
          Returns true if all the executors of this computer are idle.
 boolean isJnlpAgent()
          Deprecated. since 2008-05-18. See isLaunchSupported() and ComputerLauncher
 boolean isLaunchSupported()
          Returns true if this computer can be launched by Hudson proactively and automatically.
 boolean isManualLaunchAllowed()
          This method is called to determine whether manual launching of the slave is allowed at this point in time.
 boolean isOffline()
           
 boolean isOnline()
           
 boolean isPartiallyIdle()
          Returns true if this computer has some idle executors that can take more workload.
 boolean isTemporarilyOffline()
          Deprecated. You should almost always want isOffline(). This method is marked as deprecated to warn people when they accidentally call this method.
protected  void kill()
          Called by Jenkins.updateComputerList() to notify Computer that it will be discarded.
 void launch()
          Deprecated. since 2009-01-06. Use connect(boolean)
protected  void onRemoved()
          Called by Jenkins when this computer is removed.
static void relocateOldLogs()
          Relocate log files in the old location to the new location.
static Computer resolveForCLI(String name)
          Used for CLI binding.
protected  void setNode(Node node)
          Called to notify Computer that its corresponding Node configuration is updated.
 void setTemporarilyOffline(boolean temporarilyOffline)
          Deprecated. as of 1.320. Use setTemporarilyOffline(boolean, OfflineCause)
 void setTemporarilyOffline(boolean temporarilyOffline, OfflineCause cause)
          Marks the computer as temporarily offline.
 void taskAccepted(Executor executor, Queue.Task task)
          Called whenever a task is accepted by an executor.
 void taskCompleted(Executor executor, Queue.Task task, long durationMS)
          Called whenever a task is completed without any problems by an executor.
 void taskCompletedWithProblems(Executor executor, Queue.Task task, long durationMS, Throwable problems)
          Called whenever a task is completed without any problems by an executor.
 void waitUntilOffline()
           
 void waitUntilOnline()
          Blocks until the node becomes online/offline.
 
Methods inherited from class hudson.model.Actionable
doContextMenu, getAction, getAction, getActions, getDynamic
 
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
 

Field Detail

offlineCause

protected volatile OfflineCause offlineCause
Contains info about reason behind computer being offline.


nodeName

protected String nodeName
Node object may be created and deleted independently from this object.


transientActions

protected transient List<Action> transientActions

statusChangeLock

protected final Object statusChangeLock

threadPoolForRemoting

public static final ExecutorService threadPoolForRemoting

PERMISSIONS

public static final PermissionGroup PERMISSIONS

CONFIGURE

public static final Permission CONFIGURE
Permission to configure slaves.


DELETE

public static final Permission DELETE

CREATE

public static final Permission CREATE

DISCONNECT

public static final Permission DISCONNECT

CONNECT

public static final Permission CONNECT
Constructor Detail

Computer

public Computer(Node node)
Method Detail

getComputerPanelBoxs

public List<ComputerPanelBox> getComputerPanelBoxs()
Returns list of all boxes ComputerPanelBoxs.


getActions

public List<Action> getActions()
Returns the transient Actions associated with the computer.

Overrides:
getActions in class Actionable
Returns:
may be empty but never null.

addAction

public void addAction(Action a)
Description copied from class: Actionable
Adds a new action. Short for getActions().add(a)

Overrides:
addAction in class Actionable

getLogFile

protected File getLogFile()
This is where the log from the remote agent goes.

See Also:
relocateOldLogs()

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 slave log.

Throws:
IOException

getLogText

public AnnotatedLargeText<Computer> getLogText()
Used to URL-bind AnnotatedLargeText.


getACL

public ACL getACL()
Description copied from interface: AccessControlled
Obtains the ACL associated with this object.

Specified by:
getACL in interface AccessControlled
Returns:
never null.

checkPermission

public void checkPermission(Permission permission)
Description copied from interface: AccessControlled
Convenient short-cut for getACL().checkPermission(permission)

Specified by:
checkPermission in interface AccessControlled

hasPermission

public boolean hasPermission(Permission permission)
Description copied from interface: AccessControlled
Convenient short-cut for getACL().hasPermission(permission)

Specified by:
hasPermission in interface AccessControlled

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 slave.

Throws:
IOException
InterruptedException

doLaunchSlaveAgent

public abstract void doLaunchSlaveAgent(org.kohsuke.stapler.StaplerRequest req,
                                        org.kohsuke.stapler.StaplerResponse rsp)
                                 throws IOException,
                                        javax.servlet.ServletException
If getChannel()==null, attempts to relaunch the slave agent.

Throws:
IOException
javax.servlet.ServletException

launch

public final void launch()
Deprecated. since 2009-01-06. Use connect(boolean)


connect

public final Future<?> connect(boolean forceReconnect)
Do the same as doLaunchSlaveAgent(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 Future representing 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 as Computer is 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 Future representing 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 as Computer is connected it can be disconnected by some other threads.)
See Also:
disconnect()

cliConnect

@CLIMethod(name="connect-node")
public void cliConnect(boolean force)
                throws ExecutionException,
                       InterruptedException
CLI command to reconnect this node.

Throws:
ExecutionException
InterruptedException

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 master, 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:
Future to track the asynchronous disconnect operation.
Since:
1.320
See Also:
connect(boolean)

disconnect

public Future<?> disconnect()
Deprecated. as of 1.320. Use disconnect(OfflineCause) and specify the cause.

Equivalent to disconnect(null)


cliDisconnect

@CLIMethod(name="disconnect-node")
public void cliDisconnect(String cause)
                   throws ExecutionException,
                          InterruptedException
CLI command to disconnects this node.

Throws:
ExecutionException
InterruptedException

cliOffline

@CLIMethod(name="offline-node")
public void cliOffline(String cause)
                throws ExecutionException,
                       InterruptedException
CLI command to mark the node offline.

Throws:
ExecutionException
InterruptedException

cliOnline

@CLIMethod(name="online-node")
public void cliOnline()
               throws ExecutionException,
                      InterruptedException
Throws:
ExecutionException
InterruptedException

getNumExecutors

@Exported
public int getNumExecutors()
Number of Executors that are configured for this computer.

When this value is decreased, it is temporarily possible for executors to have a larger number than this.


getName

public String getName()
Returns the name of the node.


getNode

@CheckForNull
public Node getNode()
Returns the Node that this computer represents.

Returns:
null if the configuration has changed and the node is removed, yet the corresponding Computer is not yet gone.

getLoadStatistics

@Exported
public LoadStatistics getLoadStatistics()

getTimeline

public BuildTimelineWidget getTimeline()

taskAccepted

public void taskAccepted(Executor executor,
                         Queue.Task task)
Called whenever a task is accepted by an executor.

Specified by:
taskAccepted in interface ExecutorListener
Parameters:
executor - The executor.
task - The task.

taskCompleted

public void taskCompleted(Executor executor,
                          Queue.Task task,
                          long durationMS)
Called whenever a task is completed without any problems by an executor.

Specified by:
taskCompleted in interface ExecutorListener
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)
Called whenever a task is completed without any problems by an executor.

Specified by:
taskCompletedWithProblems in interface ExecutorListener
Parameters:
executor - The executor.
task - The task.
durationMS - The number of milliseconds that the task took to complete.
problems - The exception that was thrown.

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 slave is allowed at this point in time.

Returns:
true if manual launching of the slave is allowed at this point in time.

isConnecting

public abstract boolean isConnecting()
Is a connect(boolean) operation in progress?


isJnlpAgent

@Exported
@Deprecated
public boolean isJnlpAgent()
Deprecated. since 2008-05-18. See isLaunchSupported() and ComputerLauncher

Returns true if this computer is supposed to be launched via JNLP.


isLaunchSupported

@Exported
public boolean isLaunchSupported()
Returns true if this computer can be launched by Hudson proactively and automatically.

For example, JNLP slaves return false from this, because the launch process needs to be initiated from the slave side.


isTemporarilyOffline

@Exported
public boolean isTemporarilyOffline()
Deprecated. You should almost always want isOffline(). 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 while isOffline() returns true if the slave agent failed to launch.


setTemporarilyOffline

public void setTemporarilyOffline(boolean temporarilyOffline)
Deprecated. as of 1.320. Use setTemporarilyOffline(boolean, OfflineCause)


setTemporarilyOffline

public void setTemporarilyOffline(boolean temporarilyOffline,
                                  OfflineCause cause)
Marks the computer as temporarily offline. This retains the underlying Channel connection, 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()

getIconAltText

public String getIconAltText()

getDisplayName

@Exported
public String getDisplayName()
Specified by:
getDisplayName in interface ModelObject

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)
Called to notify Computer that its corresponding Node configuration is updated.


kill

protected void kill()
Called by Jenkins.updateComputerList() to notify Computer that it will be discarded.

Note that at this point getNode() returns null.

See Also:
onRemoved()

onRemoved

protected void onRemoved()
Called by Jenkins when this computer is removed.

This happens when list of nodes are updated (for example by Jenkins.setNodes(List) and the computer becomes redundant. Such Computers 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 idle Executors that can start working immediately.


countBusy

public final int countBusy()
Returns the number of Executors 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 from getNumExecutors() if there are busy tasks when the configured size is decreased. OneOffExecutors are not included in this count.


getExecutors

@Exported
public List<Executor> getExecutors()
Gets the read-only snapshot view of all Executors.


getOneOffExecutors

@Exported
public List<OneOffExecutor> getOneOffExecutors()
Gets the read-only snapshot view of all OneOffExecutors.


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.


isAlive

protected boolean isAlive()
Returns true if any of the executors are functioning. Note that if an executor dies, we'll leave it in executors until the administrator yanks it out, so that we can see why it died.

Since:
1.509

interrupt

public void interrupt()
Interrupt all Executors.


getSearchUrl

public String getSearchUrl()
Description copied from interface: SearchItem
Returns the URL of this item relative to the parent SearchItem.

Specified by:
getSearchUrl in interface SearchItem
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 Hudson.)

getRetentionStrategy

public abstract RetentionStrategy getRetentionStrategy()
RetentionStrategy associated with this computer.

Returns:
never null. This method return RetentionStrategy<? super T> where T=this.getClass().

getMonitorData

@Exported(inline=true)
public Map<String,Object> getMonitorData()
Expose monitoring data for the remote API.


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:
IOException
InterruptedException

getEnvVars

public Map<String,String> getEnvVars()
                              throws IOException,
                                     InterruptedException
Deprecated. as of 1.292 Use getEnvironment() instead.

Throws:
IOException
InterruptedException

getEnvironment

public EnvVars getEnvironment()
                       throws IOException,
                              InterruptedException
Gets the environment variables of the JVM on this computer. If this is the master, it returns the system property of the master computer.

Throws:
IOException
InterruptedException

buildEnvironment

public EnvVars buildEnvironment(TaskListener listener)
                         throws IOException,
                                InterruptedException
Creates an environment variable override to be used for launching processes on this node.

Throws:
IOException
InterruptedException
Since:
1.489
See Also:
Launcher.ProcStarter.envs(Map)

getThreadDump

public Map<String,String> getThreadDump()
                                 throws IOException,
                                        InterruptedException
Gets the thread dump of the slave JVM.

Returns:
key is the thread name, and the value is the pre-formatted dump.
Throws:
IOException
InterruptedException

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 slave is not reachable from the master (it may be behind a firewall, connecting to master via JNLP), 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 slave, 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 slave is behind the firewall, etc.)
Throws:
IOException
InterruptedException
Since:
1.300

doRssAll

public void doRssAll(org.kohsuke.stapler.StaplerRequest req,
                     org.kohsuke.stapler.StaplerResponse rsp)
              throws IOException,
                     javax.servlet.ServletException
Throws:
IOException
javax.servlet.ServletException

doRssFailed

public void doRssFailed(org.kohsuke.stapler.StaplerRequest req,
                        org.kohsuke.stapler.StaplerResponse rsp)
                 throws IOException,
                        javax.servlet.ServletException
Throws:
IOException
javax.servlet.ServletException

doToggleOffline

public org.kohsuke.stapler.HttpResponse doToggleOffline(@QueryParameter
                                                        String offlineMessage)
                                                 throws IOException,
                                                        javax.servlet.ServletException
Throws:
IOException
javax.servlet.ServletException

doChangeOfflineCause

public org.kohsuke.stapler.HttpResponse doChangeOfflineCause(@QueryParameter
                                                             String offlineMessage)
                                                      throws IOException,
                                                             javax.servlet.ServletException
Throws:
IOException
javax.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,
                              InterruptedException
Dumps the contents of the export table.

Throws:
IOException
javax.servlet.ServletException
InterruptedException

doScript

public void doScript(org.kohsuke.stapler.StaplerRequest req,
                     org.kohsuke.stapler.StaplerResponse rsp)
              throws IOException,
                     javax.servlet.ServletException
For system diagnostics. Run arbitrary Groovy script.

Throws:
IOException
javax.servlet.ServletException

doScriptText

public void doScriptText(org.kohsuke.stapler.StaplerRequest req,
                         org.kohsuke.stapler.StaplerResponse rsp)
                  throws IOException,
                         javax.servlet.ServletException
Run arbitrary Groovy script and return result as plain text.

Throws:
IOException
javax.servlet.ServletException

_doScript

protected void _doScript(org.kohsuke.stapler.StaplerRequest req,
                         org.kohsuke.stapler.StaplerResponse rsp,
                         String view)
                  throws IOException,
                         javax.servlet.ServletException
Throws:
IOException
javax.servlet.ServletException

doConfigSubmit

public void doConfigSubmit(org.kohsuke.stapler.StaplerRequest req,
                           org.kohsuke.stapler.StaplerResponse rsp)
                    throws IOException,
                           javax.servlet.ServletException,
                           Descriptor.FormException
Accepts the update to the node configuration.

Throws:
IOException
javax.servlet.ServletException
Descriptor.FormException

doConfigDotXml

@WebMethod(name="config.xml")
public void doConfigDotXml(org.kohsuke.stapler.StaplerRequest req,
                                     org.kohsuke.stapler.StaplerResponse rsp)
                    throws IOException,
                           javax.servlet.ServletException
Accepts config.xml submission, as well as serve it.

Throws:
IOException
javax.servlet.ServletException

doDoDelete

@CLIMethod(name="delete-node")
public org.kohsuke.stapler.HttpResponse doDoDelete()
                                            throws IOException
Really deletes the slave.

Throws:
IOException

waitUntilOnline

@CLIMethod(name="wait-node-online")
public void waitUntilOnline()
                     throws InterruptedException
Blocks until the node becomes online/offline.

Throws:
InterruptedException

waitUntilOffline

@CLIMethod(name="wait-node-offline")
public void waitUntilOffline()
                      throws InterruptedException
Throws:
InterruptedException

doProgressiveLog

public void doProgressiveLog(org.kohsuke.stapler.StaplerRequest req,
                             org.kohsuke.stapler.StaplerResponse rsp)
                      throws IOException
Handles incremental log.

Throws:
IOException

currentComputer

public static Computer currentComputer()
Gets the current Computer that the build is running. This method only works when called during a build, such as by Publisher, BuildWrapper, etc.


isAcceptingTasks

public boolean isAcceptingTasks()
Returns true if the computer is accepting tasks. Needed to allow slaves programmatic suspension of task scheduling that does not overlap with being offline.

Returns:
true if the computer is accepting tasks

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()


Copyright © 2004-2013. All Rights Reserved.