Class ComputerListener
- All Implemented Interfaces:
ExtensionPoint
- Direct Known Subclasses:
ChannelPinger,Computer.DisplayExecutor.InternalComputerListener,JnlpSlaveRestarterInstaller,LogRecorder.ComputerLogInitializer,Node.InternalComputerListener,NodeMonitorUpdater,StandardOutputSwapper,SystemProperties.AgentCopier
Computers.- Since:
- 1.246
- Author:
- Kohsuke Kawaguchi
-
Nested Class Summary
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ExtensionList<ComputerListener>all()All the registeredComputerListeners.voidCalled when configuration of the node was changed, a node is added/removed, etc.voidIndicates that the computer has become idle.voidonLaunchFailure(Computer c, TaskListener taskListener) Called when an agent attempted to connect viaComputerLauncherbut it failed.voidDeprecated.since 1.571.voidonOffline(Computer c, OfflineCause cause) Called right after aComputerwent offline.voidDeprecated.as of 1.292 UseonOnline(Computer, TaskListener)voidonOnline(Computer c, TaskListener listener) Called right after aComputercomes online.voidonTemporarilyOffline(Computer c, OfflineCause cause) Indicates that the computer was marked as temporarily offline by the administrator.voidIndicates that the computer was marked as temporarily online by the administrator.voidpreLaunch(Computer c, TaskListener taskListener) Called before aComputerLauncheris asked to launch a connection withComputer.voidpreOnline(Computer c, hudson.remoting.Channel channel, FilePath root, TaskListener listener) Called before aComputeris marked online.final voidregister()Deprecated.as of 1.286 putExtensionon your class to have it auto-registered.final booleanUnregisters thisComputerListenerso that it will never receive further events.
-
Constructor Details
-
ComputerListener
public ComputerListener()
-
-
Method Details
-
preLaunch
public void preLaunch(Computer c, TaskListener taskListener) throws IOException, InterruptedException Called before aComputerLauncheris asked to launch a connection withComputer.This enables you to do some configurable checks to see if we want to bring this agent online or if there are considerations that would keep us from doing so.
Throwing
AbortExceptionwould let you veto the launch operation. Other thrown exceptions will also have the same effect, but their stack trace will be dumped, so they are meant for error situation.- Parameters:
c- Computer that's being launched. Never null.taskListener- Connected to the agent console log. Useful for reporting progress/errors on a lengthy operation. Never null.- Throws:
AbortException- Exceptions will be recorded to the listener, and the computer will not become online.IOExceptionInterruptedException- Since:
- 1.402
-
onLaunchFailure
public void onLaunchFailure(Computer c, TaskListener taskListener) throws IOException, InterruptedException Called when an agent attempted to connect viaComputerLauncherbut it failed.- Parameters:
c- Computer that was trying to launch. Never null.taskListener- Connected to the agent console log. Useful for reporting progress/errors on a lengthy operation. Never null.- Throws:
IOExceptionInterruptedException- Since:
- 1.402
-
preOnline
public void preOnline(Computer c, hudson.remoting.Channel channel, FilePath root, TaskListener listener) throws IOException, InterruptedException Called before aComputeris marked online.This enables you to do some work on all the agents as they get connected. Unlike
onOnline(Computer, TaskListener), a failure to carry out this function normally will prevent a computer from marked as online.- Parameters:
channel- This is the channel object to talk to the agent. (This is the same object returned byComputer.getChannel()once it's connected.root- The directory where this agent stores files. The same asNode.getRootPath(), except that method returns null until the agent is connected. So this parameter is passed explicitly instead.listener- This is connected to the launch log of the computer. Since this method is called synchronously from the thread that launches a computer, if this method performs a time-consuming operation, this listener should be notified of the progress. This is also a good listener for reporting problems.- Throws:
IOException- Exceptions will be recorded to the listener, and the computer will not become online.InterruptedException- Exceptions will be recorded to the listener, and the computer will not become online.- Since:
- 1.295
- See Also:
-
onOnline
Deprecated.as of 1.292 UseonOnline(Computer, TaskListener)Called right after aComputercomes online. -
onOnline
Called right after aComputercomes online.This enables you to do some work on all the agents as they get connected. Any thrown
Exceptions will be recorded to the listener. NoExceptionwill put the computer offline, however anyErrorwill put the computer offline since they indicate unrecoverable conditions.Starting Hudson 1.312, this method is also invoked for the master, not just for agents.
- Parameters:
listener- This is connected to the launch log of the computer or Jenkins master. Since this method is called synchronously from the thread that launches a computer, if this method performs a time-consuming operation, this listener should be notified of the progress. This is also a good listener for reporting problems.- Throws:
IOException- Exceptions will be recorded to the listener. Note that throwing an exception doesn't put the computer offline.InterruptedException- Exceptions will be recorded to the listener. Note that throwing an exception doesn't put the computer offline.- See Also:
-
onOffline
Deprecated.since 1.571. UseonOffline(Computer, OfflineCause)instead.Called right after aComputerwent offline. -
onOffline
Called right after aComputerwent offline.- Since:
- 1.571
-
onTemporarilyOnline
Indicates that the computer was marked as temporarily online by the administrator. This is the reverse operation ofonTemporarilyOffline(Computer, OfflineCause)- Since:
- 1.452
-
onTemporarilyOffline
Indicates that the computer was marked as temporarily offline by the administrator. This is the reverse operation ofonTemporarilyOnline(Computer)- Since:
- 1.452
-
onConfigurationChange
public void onConfigurationChange()Called when configuration of the node was changed, a node is added/removed, etc.This callback is to signal when there's any change to the list of agents registered to the system, including addition, removal, changing of the setting, and so on.
- Since:
- 1.377
-
onIdle
Indicates that the computer has become idle.- Since:
- 2.476
-
register
Deprecated.as of 1.286 putExtensionon your class to have it auto-registered.Registers thisComputerListenerso that it will start receiving events. -
unregister
public final boolean unregister()Unregisters thisComputerListenerso that it will never receive further events.Unless
ComputerListeneris unregistered, it will never be a subject of GC. -
all
All the registeredComputerListeners.
-