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.public abstract class AbstractEndpoint<S,U>
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractEndpoint.BindState |
static interface |
AbstractEndpoint.Handler<S> |
Modifier and Type | Field and Description |
---|---|
protected java.util.List<Acceptor<U>> |
acceptors
Threads used to accept new connections and pass them to worker threads.
|
protected int |
acceptorThreadCount
Acceptor thread count.
|
protected int |
acceptorThreadPriority
Priority of the acceptor threads.
|
protected java.util.HashMap<java.lang.String,java.lang.Object> |
attributes
Attributes provide a way for configuration to be passed to sub-components
without the
ProtocolHandler being aware of the
properties available on those sub-components. |
protected boolean |
internalExecutor
Are we using an internal executor
|
protected java.util.List<java.lang.String> |
negotiableProtocols |
protected boolean |
paused
Will be set to true whenever the endpoint is paused.
|
protected SynchronizedStack<SocketProcessorBase<S>> |
processorCache
Cache for SocketProcessor objects
|
protected boolean |
running
Running state of the endpoint.
|
protected static StringManager |
sm |
protected SocketProperties |
socketProperties
Socket properties
|
protected java.util.concurrent.ConcurrentMap<java.lang.String,SSLHostConfig> |
sslHostConfigs |
protected int |
threadPriority
Priority of the worker threads.
|
Constructor and Description |
---|
AbstractEndpoint() |
Modifier and Type | Method and Description |
---|---|
void |
addNegotiatedProtocol(java.lang.String negotiableProtocol) |
void |
addSslHostConfig(SSLHostConfig sslHostConfig)
Add the given SSL Host configuration.
|
void |
addSslHostConfig(SSLHostConfig sslHostConfig,
boolean replace)
Add the given SSL Host configuration, optionally replacing the existing
configuration for the given host.
|
abstract void |
bind() |
protected abstract void |
closeSocket(U socket) |
protected long |
countDownConnection() |
protected void |
countUpOrAwaitConnection() |
void |
createExecutor() |
protected abstract SocketProcessorBase<S> |
createSocketProcessor(SocketWrapperBase<S> socketWrapper,
SocketEvent event) |
protected abstract void |
createSSLContext(SSLHostConfig sslHostConfig)
Create the SSLContextfor the the given SSLHostConfig.
|
void |
destroy() |
protected void |
destroySocket(U socket) |
SSLHostConfig[] |
findSslHostConfigs() |
int |
getAcceptCount() |
int |
getAcceptorThreadCount() |
int |
getAcceptorThreadPriority() |
java.net.InetAddress |
getAddress() |
java.lang.Object |
getAttribute(java.lang.String key)
Used by sub-components to retrieve configuration information.
|
boolean |
getBindOnInit() |
long |
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. |
int |
getConnectionLinger()
Socket linger.
|
int |
getConnectionTimeout()
Socket timeout.
|
int |
getCurrentThreadCount()
Return the amount of threads that are managed by the pool.
|
int |
getCurrentThreadsBusy()
Return the amount of threads that are in use
|
boolean |
getDaemon() |
java.lang.String |
getDefaultSSLHostConfigName() |
protected abstract boolean |
getDeferAccept() |
java.lang.String |
getDomain() |
java.util.concurrent.Executor |
getExecutor() |
long |
getExecutorTerminationTimeoutMillis() |
AbstractEndpoint.Handler<S> |
getHandler() |
int |
getKeepAliveTimeout() |
protected abstract java.net.InetSocketAddress |
getLocalAddress()
Obtain the network address the server socket is bound to.
|
int |
getLocalPort() |
protected abstract Log |
getLog() |
int |
getMaxConnections() |
int |
getMaxKeepAliveRequests() |
int |
getMaxThreads() |
int |
getMinSpareThreads() |
java.lang.String |
getName() |
int |
getPort() |
java.lang.String |
getProperty(java.lang.String name) |
SocketProperties |
getSocketProperties() |
protected abstract SSLHostConfig.Type |
getSslConfigType() |
protected SSLHostConfig |
getSSLHostConfig(java.lang.String sniHostName) |
boolean |
getTcpNoDelay()
Socket TCP no delay.
|
int |
getThreadPriority() |
boolean |
getUseSendfile() |
boolean |
hasNegotiableProtocols() |
void |
init() |
protected LimitLatch |
initializeConnectionLatch() |
abstract boolean |
isAlpnSupported()
Identifies if the endpoint supports ALPN.
|
boolean |
isPaused() |
boolean |
isRunning() |
boolean |
isSSLEnabled() |
void |
pause()
Pause the endpoint, which will stop it accepting new connections and
unlock the acceptor.
|
boolean |
processSocket(SocketWrapperBase<S> socketWrapper,
SocketEvent event,
boolean dispatch)
Process the given SocketWrapper with the given status.
|
protected abstract void |
releaseSSLContext(SSLHostConfig sslHostConfig)
Release the SSLContext, if any, associated with the SSLHostConfig.
|
void |
reloadSslHostConfig(java.lang.String hostName)
Re-read the configuration files for the SSL host and replace the existing
SSL configuration with the updated settings.
|
void |
reloadSslHostConfigs()
Re-read the configuration files for all SSL hosts and replace the
existing SSL configuration with the updated settings.
|
SSLHostConfig |
removeSslHostConfig(java.lang.String hostName)
Removes the SSL host configuration for the given host name, if such a
configuration exists.
|
void |
resume()
Resume the endpoint, which will make it start accepting new connections
again.
|
protected abstract U |
serverSocketAccept() |
void |
setAcceptCount(int acceptCount) |
void |
setAcceptorThreadCount(int acceptorThreadCount) |
void |
setAcceptorThreadPriority(int acceptorThreadPriority) |
void |
setAddress(java.net.InetAddress address) |
void |
setAttribute(java.lang.String name,
java.lang.Object value)
Generic property setter called when a property for which a specific
setter already exists within the
ProtocolHandler needs to be made available to
sub-components. |
void |
setBindOnInit(boolean b) |
void |
setConnectionLinger(int connectionLinger) |
void |
setConnectionTimeout(int soTimeout) |
void |
setDaemon(boolean b) |
void |
setDefaultSSLHostConfigName(java.lang.String defaultSSLHostConfigName) |
void |
setDomain(java.lang.String domain) |
void |
setExecutor(java.util.concurrent.Executor executor) |
void |
setExecutorTerminationTimeoutMillis(long executorTerminationTimeoutMillis) |
void |
setHandler(AbstractEndpoint.Handler<S> handler) |
void |
setKeepAliveTimeout(int keepAliveTimeout) |
void |
setMaxConnections(int maxCon) |
void |
setMaxKeepAliveRequests(int maxKeepAliveRequests) |
void |
setMaxThreads(int maxThreads) |
void |
setMinSpareThreads(int minSpareThreads) |
void |
setName(java.lang.String name) |
void |
setPort(int port) |
boolean |
setProperty(java.lang.String name,
java.lang.String value) |
protected abstract boolean |
setSocketOptions(U socket) |
void |
setSSLEnabled(boolean SSLEnabled) |
void |
setTcpNoDelay(boolean tcpNoDelay) |
void |
setThreadPriority(int threadPriority) |
void |
setUseSendfile(boolean useSendfile) |
void |
shutdownExecutor() |
void |
start() |
protected void |
startAcceptorThreads() |
abstract void |
startInternal() |
void |
stop() |
abstract void |
stopInternal() |
abstract void |
unbind() |
protected static final StringManager sm
protected volatile boolean running
protected volatile boolean paused
protected volatile boolean internalExecutor
protected final SocketProperties socketProperties
protected java.util.List<Acceptor<U>> acceptors
protected SynchronizedStack<SocketProcessorBase<S>> processorCache
protected java.util.concurrent.ConcurrentMap<java.lang.String,SSLHostConfig> sslHostConfigs
protected int acceptorThreadCount
protected int acceptorThreadPriority
protected int threadPriority
protected final java.util.List<java.lang.String> negotiableProtocols
protected java.util.HashMap<java.lang.String,java.lang.Object> attributes
ProtocolHandler
being aware of the
properties available on those sub-components.public SocketProperties getSocketProperties()
public java.lang.String getDefaultSSLHostConfigName()
public void setDefaultSSLHostConfigName(java.lang.String defaultSSLHostConfigName)
public void addSslHostConfig(SSLHostConfig sslHostConfig) throws java.lang.IllegalArgumentException
sslHostConfig
- The configuration to addjava.lang.IllegalArgumentException
- If the host name is not valid or if a
configuration has already been provided
for that hostpublic void addSslHostConfig(SSLHostConfig sslHostConfig, boolean replace) throws java.lang.IllegalArgumentException
sslHostConfig
- The configuration to addreplace
- If true
replacement of an existing
configuration is permitted, otherwise any such
attempted replacement will trigger an exceptionjava.lang.IllegalArgumentException
- If the host name is not valid or if a
configuration has already been provided
for that host and replacement is not
allowedpublic SSLHostConfig removeSslHostConfig(java.lang.String hostName)
hostName
- The host name associated with the SSL host configuration
to removepublic void reloadSslHostConfig(java.lang.String hostName)
hostName
- The SSL host for which the configuration should be
reloaded. This must match a current SSL hostpublic void reloadSslHostConfigs()
public SSLHostConfig[] findSslHostConfigs()
protected abstract SSLHostConfig.Type getSslConfigType()
protected abstract void createSSLContext(SSLHostConfig sslHostConfig) throws java.lang.Exception
sslHostConfig
- The SSLHostConfig for which the SSLContext should be
createdjava.lang.Exception
- If the SSLContext cannot be created for the given
SSLHostConfigprotected abstract void releaseSSLContext(SSLHostConfig sslHostConfig)
sslHostConfig
- The SSLHostConfig for which the SSLContext should be
releasedprotected SSLHostConfig getSSLHostConfig(java.lang.String sniHostName)
public boolean getUseSendfile()
public void setUseSendfile(boolean useSendfile)
public long getExecutorTerminationTimeoutMillis()
public void setExecutorTerminationTimeoutMillis(long executorTerminationTimeoutMillis)
public void setAcceptorThreadCount(int acceptorThreadCount)
public int getAcceptorThreadCount()
public void setAcceptorThreadPriority(int acceptorThreadPriority)
public int getAcceptorThreadPriority()
public void setMaxConnections(int maxCon)
public int getMaxConnections()
public long getConnectionCount()
-1
if they are not. This
property is added here so that this value can be inspected through JMX.
It is visible on "ThreadPool" MBean.
The count is incremented by the Acceptor before it tries to accept a new connection. Until the limit is reached and thus the count cannot be incremented, this value is more by 1 (the count of acceptors) than the actual count of connections that are being served.
public void setExecutor(java.util.concurrent.Executor executor)
public java.util.concurrent.Executor getExecutor()
public int getPort()
public void setPort(int port)
public final int getLocalPort()
public java.net.InetAddress getAddress()
public void setAddress(java.net.InetAddress address)
protected abstract java.net.InetSocketAddress getLocalAddress() throws java.io.IOException
java.io.IOException
- If there is a problem determining the currently bound
socketpublic void setAcceptCount(int acceptCount)
public int getAcceptCount()
public boolean getBindOnInit()
public void setBindOnInit(boolean b)
public int getKeepAliveTimeout()
public void setKeepAliveTimeout(int keepAliveTimeout)
public boolean getTcpNoDelay()
public void setTcpNoDelay(boolean tcpNoDelay)
public int getConnectionLinger()
public void setConnectionLinger(int connectionLinger)
public int getConnectionTimeout()
public void setConnectionTimeout(int soTimeout)
public boolean isSSLEnabled()
public void setSSLEnabled(boolean SSLEnabled)
public abstract boolean isAlpnSupported()
true
implies that isSSLEnabled()
will also return
true
.true
if the endpoint supports ALPN in its current
configuration, otherwise false
.public void setMinSpareThreads(int minSpareThreads)
public int getMinSpareThreads()
public void setMaxThreads(int maxThreads)
public int getMaxThreads()
public void setThreadPriority(int threadPriority)
public int getThreadPriority()
public int getMaxKeepAliveRequests()
public void setMaxKeepAliveRequests(int maxKeepAliveRequests)
public void setName(java.lang.String name)
public java.lang.String getName()
public void setDomain(java.lang.String domain)
public java.lang.String getDomain()
public void setDaemon(boolean b)
public boolean getDaemon()
protected abstract boolean getDeferAccept()
public void addNegotiatedProtocol(java.lang.String negotiableProtocol)
public boolean hasNegotiableProtocols()
public void setHandler(AbstractEndpoint.Handler<S> handler)
public AbstractEndpoint.Handler<S> getHandler()
public void setAttribute(java.lang.String name, java.lang.Object value)
ProtocolHandler
needs to be made available to
sub-components. The specific setter will call this method to populate the
attributes.name
- Name of property to setvalue
- The value to set the property topublic java.lang.Object getAttribute(java.lang.String key)
key
- The name of the property for which the value should be
retrievedpublic boolean setProperty(java.lang.String name, java.lang.String value)
public java.lang.String getProperty(java.lang.String name)
public int getCurrentThreadCount()
public int getCurrentThreadsBusy()
public boolean isRunning()
public boolean isPaused()
public void createExecutor()
public void shutdownExecutor()
public boolean processSocket(SocketWrapperBase<S> socketWrapper, SocketEvent event, boolean dispatch)
socketWrapper
- The socket wrapper to processevent
- The socket event to be processeddispatch
- Should the processing be performed on a new
container threadprotected abstract SocketProcessorBase<S> createSocketProcessor(SocketWrapperBase<S> socketWrapper, SocketEvent event)
public abstract void bind() throws java.lang.Exception
java.lang.Exception
public abstract void unbind() throws java.lang.Exception
java.lang.Exception
public abstract void startInternal() throws java.lang.Exception
java.lang.Exception
public abstract void stopInternal() throws java.lang.Exception
java.lang.Exception
public final void init() throws java.lang.Exception
java.lang.Exception
public final void start() throws java.lang.Exception
java.lang.Exception
protected final void startAcceptorThreads()
public void pause()
public void resume()
public final void stop() throws java.lang.Exception
java.lang.Exception
public final void destroy() throws java.lang.Exception
java.lang.Exception
protected abstract Log getLog()
protected LimitLatch initializeConnectionLatch()
protected void countUpOrAwaitConnection() throws java.lang.InterruptedException
java.lang.InterruptedException
protected long countDownConnection()
protected abstract U serverSocketAccept() throws java.lang.Exception
java.lang.Exception
protected abstract boolean setSocketOptions(U socket)
protected abstract void closeSocket(U socket)
protected void destroySocket(U socket)
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.