Top Inners Fields Constructors Methods
org.apache.tomcat.util.net

public abstract Class AbstractEndpoint<S, U>

extends Object
Class Inheritance
Known Direct Subclasses
org.apache.tomcat.util.net.AbstractJsseEndpoint
Type Parameters
<S>
The type used by the socket wrapper associated with this endpoint. May be the same as U.
<U>
The type of the underlying socket used by this endpoint. May be the same as S.
Imports
java.io.IOException, .OutputStreamWriter, java.net.InetAddress, .InetSocketAddress, .NetworkInterface, .SocketException, java.security.MessageDigest, .NoSuchAlgorithmException, java.security.cert.CertificateEncodingException, .X509Certificate, java.util.ArrayList, .Enumeration, .HashMap, .HashSet, .List, .Locale, .Map, .Set, java.util.concurrent.ConcurrentHashMap, .ConcurrentMap, .Executor, .RejectedExecutionException, .ScheduledExecutorService, .ScheduledThreadPoolExecutor, .TimeUnit, javax.management.MalformedObjectNameException, .ObjectName, org.apache.juli.logging.Log, org.apache.tomcat.util.ExceptionUtils, .IntrospectionUtils, org.apache.tomcat.util.buf.HexUtils, org.apache.tomcat.util.collections.SynchronizedStack, org.apache.tomcat.util.modeler.Registry, org.apache.tomcat.util.net.Acceptor.AcceptorState, .SSLHostConfigCertificate.StoreType, org.apache.tomcat.util.res.StringManager, org.apache.tomcat.util.threads.LimitLatch, .ResizableExecutor, .TaskQueue, .TaskThreadFactory, .ThreadPoolExecutor, .VirtualThreadExecutor

Authors
Mladen Turk, Remy Maucherat

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static enum
public static interface

Field Summary

Modifier and TypeField and Description
private int
acceptCount

Allows the server developer to specify the acceptCount (backlog) that should be used for server sockets.

protected Acceptor<U>
acceptor

Thread used to accept new connections and pass them to worker threads.

protected int
acceptorThreadPriority

Priority of the acceptor threads.

private InetAddress
address

Address for the server socket.

protected HashMap<String, Object>
attributes

Attributes provide a way for configuration to be passed to sub-components without the org.apache.coyote.ProtocolHandler being aware of the properties available on those sub-components.

private boolean
bindOnInit

Controls when the Endpoint binds the port.

private volatile AbstractEndpoint.BindState
private volatile LimitLatch
connectionLimitLatch

counter for nr of connections handled by an endpoint

protected Map<U, SocketWrapperBase<S>>
connections

Map holding all current connections keyed with the sockets.

private boolean
daemon

The default is true - the created threads will be in daemon mode.

private String
private String
domain

Name of domain to use for JMX registration.

private Executor
executor

External Executor based thread pool.

private long
executorTerminationTimeoutMillis

Time to wait for the internal executor (if used) to terminate when the endpoint is stopped in milliseconds.

private AbstractEndpoint.Handler<S>
handler

Handling of accepted sockets.

protected volatile boolean
internalExecutor

Are we using an internal executor

private Integer
keepAliveTimeout

Keepalive timeout, if not set the soTimeout is used.

private int
private int
maxKeepAliveRequests

Max keep alive requests

private int
maxThreads

Maximum amount of worker threads.

private int
private String
name

Name of the thread pool, which will be used for naming child threads.

protected final List<String>
private ObjectName
protected volatile boolean
paused

Will be set to true whenever the endpoint is paused.

private int
port

Server socket port.

private int
protected SynchronizedStack<SocketProcessorBase<S>>
processorCache

Cache for SocketProcessor objects

protected volatile boolean
running

Running state of the endpoint.

protected static final StringManager
protected final SocketProperties
socketProperties

Socket properties

private boolean
SSLEnabled

SSL engine.

protected ConcurrentMap<String, SSLHostConfig>
protected int
threadPriority

Priority of the worker threads.

private boolean
useAsyncIO

Expose asynchronous IO capability.

private boolean
useSendfile

Has the user requested that send file be used where possible?

private boolean
private ScheduledExecutorService
utilityExecutor

External Executor based thread pool for utility tasks.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addNegotiatedProtocol(String negotiableProtocol)

public void
addSslHostConfig(SSLHostConfig
The configuration to add
sslHostConfig
)

Add the given SSL Host configuration.

public void
addSslHostConfig(SSLHostConfig
The configuration to add
sslHostConfig
,
boolean
If true replacement of an existing configuration is permitted, otherwise any such attempted replacement will trigger an exception
replace
)

Add the given SSL Host configuration, optionally replacing the existing configuration for the given host.

public final long

Returns:

The wait time, if any remaining when the method returned
awaitConnectionsClose
(long
The maximum time to wait in milliseconds for the client connections to close.
waitMillis
)

Wait for the client connections to the server to close gracefully.

public abstract void
bind()

private void
public final void
closeServerSocketGraceful()

Close the server socket (to prevent further connections) if the server socket was originally bound on start() (rather than on init()).

protected void
closeSocket(U
The newly accepted socket
socket
)

Close the socket when the connection has to be immediately closed when an error occurs while configuring the accepted socket or trying to dispatch it for processing.

protected long
protected void
public void
protected abstract SocketProcessorBase<S>
protected abstract void
createSSLContext(SSLHostConfig
The SSLHostConfig for which the SSLContext should be created
sslHostConfig
)

Create the SSLContext for the given SSLHostConfig.

public final void
protected abstract void
destroySocket(U
The newly accepted socket
socket
)

Close the socket.

protected void
protected abstract void
doCloseServerSocket()

Actually close the server socket but don't perform any other clean-up.

public SSLHostConfig[]
protected String
public int
public int
public InetAddress
public Object

Returns:

The value of the specified property
getAttribute
(String
The name of the property for which the value should be retrieved
key
)

Used by sub-components to retrieve configuration information.

public boolean
protected AbstractEndpoint.BindState
public long

Returns:

The count
getConnectionCount
()

Return the current count of connections handled by this endpoint, if the connections are counted (which happens when the maximum count of connections is limited), or -1 if they are not.

public int

Returns:

The current socket linger time for sockets created by this endpoint
getConnectionLinger
()

Socket linger.

public Set<SocketWrapperBase<S>>

Returns:

A set with the open socket wrappers
getConnections
()

Get a set with the current open connections.

public int

Returns:

The current socket timeout for sockets created by this endpoint
getConnectionTimeout
()

Socket timeout.

public int

Returns:

the amount of threads that are managed by the pool
getCurrentThreadCount
()

Return the amount of threads that are managed by the pool.

public int

Returns:

the amount of threads that are in use
getCurrentThreadsBusy
()

Return the amount of threads that are in use

public boolean
public String

Returns:

The host name for the default SSL configuration for this endpoint - always in lower case.
getDefaultSSLHostConfigName
()

protected boolean

Returns:

Always false
getDeferAccept
()
Deprecated This code will be removed in Tomcat 11 onwards

Always returns false.

public String
public Executor
public long
public AbstractEndpoint.Handler<S>
public String

Returns:

the id
getId
()

The default behavior is to identify connectors uniquely with address and port.

public int
protected abstract InetSocketAddress

Returns:

The network address that the server socket is listening on or null if the server socket is not currently bound.
getLocalAddress
()

Obtain the network address the server socket is bound to.

public final int
protected abstract Log
protected Log
public int
public int
public int
public int
private int
public String
public int
public int
public int
public String
public SocketProperties
protected SSLHostConfig

Returns:

The SSLHostConfig for the given host name.
getSSLHostConfig
(String
Host name - must be in lower case
sniHostName
)

Look up the SSLHostConfig for the given host name.

public boolean

Returns:

The current TCP no delay setting for sockets created by this endpoint
getTcpNoDelay
()

Socket TCP no delay.

public int
private static InetSocketAddress
public boolean
public boolean
public boolean
public ScheduledExecutorService
public boolean
public final void
init()

protected LimitLatch
public boolean
public boolean
public boolean
protected void
public void
pause()

Pause the endpoint, which will stop it accepting new connections and unlock the acceptor.

public boolean

Returns:

if processing was triggered successfully
processSocket
(SocketWrapperBase<S>
The socket wrapper to process
socketWrapper
,
SocketEvent
The socket event to be processed
event
,
boolean
Should the processing be performed on a new container thread
dispatch
)

Process the given SocketWrapper with the given status.

private void
registerJmx(SSLHostConfig sslHostConfig)

private void
protected void
releaseSSLContext(SSLHostConfig
The SSLHostConfig for which the SSLContext should be released
sslHostConfig
)

Release the SSLContext, if any, associated with the SSLHostConfig.

public void
reloadSslHostConfig(String
The SSL host for which the configuration should be reloaded. This must match a current SSL host
hostName
)

Re-read the configuration files for the SSL host and replace the existing SSL configuration with the updated settings.

public void
reloadSslHostConfigs()

Re-read the configuration files for all SSL hosts and replace the existing SSL configuration with the updated settings.

public SSLHostConfig

Returns:

The SSL host configuration that was removed, if any
removeSslHostConfig
(String
The host name associated with the SSL host configuration to remove
hostName
)

Removes the SSL host configuration for the given host name, if such a configuration exists.

public void
resume()

Resume the endpoint, which will make it start accepting new connections again.

protected abstract U
public void
setAcceptCount(int acceptCount)

public void
setAcceptorThreadPriority(int acceptorThreadPriority)

public void
public void
setAttribute(String
Name of property to set
name
,
Object
The value to set the property to
value
)

Generic property setter called when a property for which a specific setter already exists within the org.apache.coyote.ProtocolHandler needs to be made available to sub-components.

public void
setBindOnInit(boolean b)

public void
setConnectionLinger(int connectionLinger)

public void
setConnectionTimeout(int soTimeout)

public void
setDaemon(boolean b)

public void
setDefaultSSLHostConfigName(String defaultSSLHostConfigName)

public void
setDomain(String domain)

public void
public void
setExecutorTerminationTimeoutMillis(long executorTerminationTimeoutMillis)

public void
public void
setKeepAliveTimeout(int keepAliveTimeout)

public void
setMaxConnections(int maxCon)

public void
setMaxKeepAliveRequests(int maxKeepAliveRequests)

public void
setMaxThreads(int maxThreads)

public void
setMinSpareThreads(int minSpareThreads)

public void
public void
setPort(int port)

public void
setPortOffset(int portOffset)

public boolean
setProperty(String name, String value)

protected abstract boolean
setSocketOptions(U socket)

public void
setSSLEnabled(boolean SSLEnabled)

public void
setTcpNoDelay(boolean tcpNoDelay)

public void
setThreadPriority(int threadPriority)

public void
setUseAsyncIO(boolean useAsyncIO)

public void
setUseSendfile(boolean useSendfile)

public void
setUseVirtualThreads(boolean useVirtualThreads)

public void
public void
public final void
protected void
public abstract void
public final void
stop()

public abstract void
public static long
toTimeout(long timeout)

public abstract void
protected void
unlockAccept()

Unlock the server socket acceptor threads using bogus connections.

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait