Package hudson.remoting
Class Engine
java.lang.Object
java.lang.Thread
hudson.remoting.Engine
- All Implemented Interfaces:
Runnable
Agent engine that proactively connects to Jenkins controller.
- Author:
- Kohsuke Kawaguchi
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
Modifier and TypeFieldDescriptionboolean
Fail the initialization if the workDir or internalDir are missing.Specifies a directory withinworkDir
, which stores all the remoting-internal files.final EngineListener
Deprecated.static final String
HTTP header sent by Jenkins to indicate the earliest version of Remoting it is prepared to accept connections from.static final String
The header name to be used for the connection cookie when using websockets.Specifies a default working directory of the remoting instance.Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addCandidateCertificate
(X509Certificate certificate) void
static Engine
current()
Get the agent name associated with this Engine instance.Provides Jenkins URL if available.Get the name of the communication protocol used in this Engine instance.boolean
Determines if JNLPAgentEndpointResolver will not perform certificate validation in the HTTPs mode.boolean
Returnstrue
if and only if the socket to the controller will haveSocket.setKeepAlive(boolean)
set.void
void
run()
void
setAgentLog
(Path agentLog) Sets the destination for agent logs.void
setCandidateCertificates
(List<X509Certificate> candidateCertificates) void
setCredentials
(String creds) void
setDisableHttpsCertValidation
(boolean disableHttpsCertValidation) Sets if JNLPAgentEndpointResolver will not perform certificate validation in the HTTPs mode.void
setFailIfWorkDirIsMissing
(boolean failIfWorkDirIsMissing) Sets up behavior if the workDir or internalDir are missing during the startup.void
setInternalDir
(String internalDir) Specifies name of the internal data directory withinworkDir
.void
setJarCache
(JarCache jarCache) Configures custom JAR Cache location.void
setKeepAlive
(boolean keepAlive) Sets theSocket.setKeepAlive(boolean)
to use for the connection to the controller.void
setLoggingConfigFile
(Path filePath) Sets path to the property file with JUL settings.void
setNoReconnect
(boolean noReconnect) void
setNoReconnectAfter
(Duration noReconnectAfter) void
setProxyCredentials
(String proxyCredentials) void
If set, connect to the specified host and port instead of connecting directly to Jenkins.void
setWebSocket
(boolean webSocket) void
setWebSocketHeaders
(Map<String, String> webSocketHeaders) Sets map of custom websocket headers.void
setWorkDir
(Path workDir) Specified a path to the work directory.void
Starts the engine.Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
Field Details
-
REMOTING_MINIMUM_VERSION_HEADER
HTTP header sent by Jenkins to indicate the earliest version of Remoting it is prepared to accept connections from.- See Also:
-
WEBSOCKET_COOKIE_HEADER
The header name to be used for the connection cookie when using websockets.- See Also:
-
listener
Deprecated.Useevents
. -
workDir
Specifies a default working directory of the remoting instance. If specified, this directory will be used to store logs, JAR cache, etc.In order to retain compatibility, the option is disabled by default.
Jenkins specifics: This working directory is expected to be equal to the agent root specified in Jenkins configuration.
- Since:
- 3.8
-
internalDir
Specifies a directory withinworkDir
, which stores all the remoting-internal files.This option is not expected to be used frequently, but it allows remoting users to specify a custom storage directory if the default
remoting
directory is consumed by other stuff.- Since:
- 3.8
-
failIfWorkDirIsMissing
public boolean failIfWorkDirIsMissingFail the initialization if the workDir or internalDir are missing. This option presumes that the workspace structure gets initialized previously in order to ensure that we do not start up with a borked instance (e.g. if a filesystem mount gets disconnected).- Since:
- 3.8
-
-
Constructor Details
-
Engine
-
Engine
-
-
Method Details
-
startEngine
Starts the engine. The procedure initializes the working directory and all the required environment- Throws:
IOException
- Initialization error- Since:
- 3.9
-
setJarCache
Configures custom JAR Cache location. This option disables JAR Caching in the working directory.- Parameters:
jarCache
- JAR Cache to be used- Since:
- 2.24
-
setLoggingConfigFile
Sets path to the property file with JUL settings.- Parameters:
filePath
- JAR Cache to be used- Since:
- 3.8
-
getHudsonUrl
Provides Jenkins URL if available.- Returns:
- Jenkins URL. May return
null
if the connection is not established or if the URL cannot be determined in theJnlpAgentEndpointResolver
.
-
setWebSocket
public void setWebSocket(boolean webSocket) -
setWebSocketHeaders
Sets map of custom websocket headers. These headers will be applied to the websocket connection to Jenkins.- Parameters:
webSocketHeaders
- a map of the headers to apply to the websocket connection
-
setTunnel
If set, connect to the specified host and port instead of connecting directly to Jenkins.- Parameters:
tunnel
- Value.null
to disable tunneling
-
setCredentials
-
setProxyCredentials
-
setNoReconnect
public void setNoReconnect(boolean noReconnect) -
setNoReconnectAfter
-
isDisableHttpsCertValidation
public boolean isDisableHttpsCertValidation()Determines if JNLPAgentEndpointResolver will not perform certificate validation in the HTTPs mode.- Returns:
true
if the certificate validation is disabled.
-
setDisableHttpsCertValidation
public void setDisableHttpsCertValidation(boolean disableHttpsCertValidation) Sets if JNLPAgentEndpointResolver will not perform certificate validation in the HTTPs mode.- Parameters:
disableHttpsCertValidation
-true
if the certificate validation is disabled.
-
setAgentLog
Sets the destination for agent logs.- Parameters:
agentLog
- Path to the agent log. Ifnull
, the engine will pick the default behavior depending on theworkDir
value- Since:
- 3.8
-
setWorkDir
Specified a path to the work directory.- Parameters:
workDir
- Path to the working directory of the remoting instance.null
Disables the working directory.- Since:
- 3.8
-
setInternalDir
Specifies name of the internal data directory withinworkDir
.- Parameters:
internalDir
- Directory name- Since:
- 3.8
-
setFailIfWorkDirIsMissing
public void setFailIfWorkDirIsMissing(boolean failIfWorkDirIsMissing) Sets up behavior if the workDir or internalDir are missing during the startup. This option presumes that the workspace structure gets initialized previously in order to ensure that we do not start up with a borked instance (e.g. if a filesystem mount gets disconnected).- Parameters:
failIfWorkDirIsMissing
- Flag- Since:
- 3.8
-
isKeepAlive
public boolean isKeepAlive()Returnstrue
if and only if the socket to the controller will haveSocket.setKeepAlive(boolean)
set.- Returns:
true
if and only if the socket to the controller will haveSocket.setKeepAlive(boolean)
set.
-
setKeepAlive
public void setKeepAlive(boolean keepAlive) Sets theSocket.setKeepAlive(boolean)
to use for the connection to the controller.- Parameters:
keepAlive
- theSocket.setKeepAlive(boolean)
to use for the connection to the controller.
-
setCandidateCertificates
-
addCandidateCertificate
-
addListener
-
removeListener
-
run
public void run() -
current
-
getAgentName
Get the agent name associated with this Engine instance.- Returns:
- the agent name.
- Since:
- TODO
-
getProtocolName
Get the name of the communication protocol used in this Engine instance. When the channel is not established by Engine (that is,current()
) returns null), useLauncher.getCommunicationProtocolName()
instead.- Returns:
- the communication protocol name.
- Since:
- 4.8
-
events
.