Package hudson
Class TcpSlaveAgentListener
- java.lang.Object
-
- java.lang.Thread
-
- hudson.TcpSlaveAgentListener
-
- All Implemented Interfaces:
Runnable
@StaplerAccessibleType public final class TcpSlaveAgentListener extends Thread
Listens to incoming TCP connections, for example from agents.Aside from the HTTP endpoint, Jenkins runs
TcpSlaveAgentListener
that listens on a TCP socket. Historically this was used for inbound connection from agents (hence the name), but over time it was extended and made generic, so that multiple protocols of different purposes can co-exist on the same socket.This class accepts the socket, then after a short handshaking, it dispatches to appropriate
AgentProtocol
s.- Author:
- Kohsuke Kawaguchi
- See Also:
AgentProtocol
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TcpSlaveAgentListener.ConnectionFromCurrentPeer
Connection terminated because we are reconnected from the current peer.static class
TcpSlaveAgentListener.PingAgentProtocol
This extension provides a Ping protocol that allows people to verify that theTcpSlaveAgentListener
is alive.-
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
-
-
Field Summary
Fields Modifier and Type Field Description static String
CLI_HOST_NAME
Host name that we advertise protocol clients to connect to.static Integer
CLI_PORT
Port number that we advertise protocol clients to connect to.int
configuredPort
-
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
-
Constructor Summary
Constructors Constructor Description TcpSlaveAgentListener(int port)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getAdvertisedHost()
Gets the host name that we advertise protocol clients to connect to.int
getAdvertisedPort()
Gets the TCP port number in which we are advertising.String
getAgentProtocolNames()
Returns a comma separated list of the enabledAgentProtocol.getName()
implementations so that clients can avoid creating additional work for the server attempting to connect with unsupported protocols.String
getIdentityPublicKey()
Gets the Base64 encoded public key that forms part of this instance's identity keypair.int
getPort()
Gets the TCP port number in which we are listening.VersionNumber
getRemotingMinimumVersion()
Gets Remoting minimum supported version to prevent unsupported agents from connectingvoid
run()
void
shutdown()
Initiates the shuts down of the listener.-
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 Detail
-
configuredPort
public final int configuredPort
-
CLI_HOST_NAME
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public static String CLI_HOST_NAME
Host name that we advertise protocol clients to connect to. This is primarily for those who have reverse proxies in place such that the HTTP host name and the TCP/IP connection host names are different. (Note: despite the name, this is used for any client, not only deprecated Remoting-based CLI.) TODO: think about how to expose this (including whether this needs to be exposed at all.)
-
CLI_PORT
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public static Integer CLI_PORT
Port number that we advertise protocol clients to connect to. This is primarily for the case where the port that Jenkins runs is different from the port that external world should connect to, because of the presence of NAT / port-forwarding / TCP reverse proxy. (Note: despite the name, this is used for any client, not only deprecated Remoting-based CLI.) If left to null, fall back togetPort()
- Since:
- 1.611
-
-
Constructor Detail
-
TcpSlaveAgentListener
public TcpSlaveAgentListener(int port) throws IOException
- Parameters:
port
- Use 0 to choose a random port.- Throws:
IOException
-
-
Method Detail
-
getPort
public int getPort()
Gets the TCP port number in which we are listening.
-
getAdvertisedPort
public int getAdvertisedPort()
Gets the TCP port number in which we are advertising.- Since:
- 1.656
-
getAdvertisedHost
public String getAdvertisedHost()
Gets the host name that we advertise protocol clients to connect to.- Since:
- 2.198
-
getIdentityPublicKey
@Nullable public String getIdentityPublicKey()
Gets the Base64 encoded public key that forms part of this instance's identity keypair.- Returns:
- the Base64 encoded public key
- Since:
- 2.16
-
getAgentProtocolNames
public String getAgentProtocolNames()
Returns a comma separated list of the enabledAgentProtocol.getName()
implementations so that clients can avoid creating additional work for the server attempting to connect with unsupported protocols.- Returns:
- a comma separated list of the enabled
AgentProtocol.getName()
implementations - Since:
- 2.16
-
getRemotingMinimumVersion
public VersionNumber getRemotingMinimumVersion()
Gets Remoting minimum supported version to prevent unsupported agents from connecting- Since:
- 2.171
-
shutdown
public void shutdown()
Initiates the shuts down of the listener.
-
-