Class Nio2Endpoint
java.lang.Object
org.apache.tomcat.util.net.AbstractEndpoint<Nio2Channel, AsynchronousSocketChannel>
org.apache.tomcat.util.net.AbstractNetworkChannelEndpoint<Nio2Channel, AsynchronousSocketChannel>
org.apache.tomcat.util.net.Nio2Endpoint
public class Nio2Endpoint
extends AbstractNetworkChannelEndpoint<Nio2Channel, AsynchronousSocketChannel>
NIO2 endpoint.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classstatic classstatic classSendfileData class.protected classThis class is the equivalent of the Worker, but will simply use in an external Executor thread pool.Nested classes/interfaces inherited from class AbstractEndpoint
AbstractEndpoint.BindState, AbstractEndpoint.Handler<S> -
Field Summary
Fields inherited from class AbstractEndpoint
acceptor, acceptorThreadPriority, attributes, connections, internalExecutor, negotiableProtocols, paused, processorCache, running, sm, socketProperties, sslHostConfigs, threadPriority -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbind()Initialize the endpoint.protected Nio2ChannelcreateChannel(SocketBufferHandler buffer) Creates the channel to be used by this endpoint.protected SocketProcessorBase<Nio2Channel> createSocketProcessor(SocketWrapperBase<Nio2Channel> socketWrapper, SocketEvent event) Create a socket processor for the given socket wrapper.protected voidClose the socket.protected voidActually close the server socket but don't perform any other clean-up.static voidintNumber of keep-alive sockets.protected LoggetLog()Get the logger for this endpoint.protected LogGet the logger for certificate-related messages.protected SynchronizedStack<Nio2Channel> protected NetworkChannelReturns the server socket used by this endpoint.static booleanisInline()voidresume()Resume the endpoint, which will make it start accepting new connections again.protected AsynchronousSocketChannelAccept a connection from the server socket.protected booleanProcess the specified connection.voidShutdown the internal executor.protected voidStart the acceptor thread.static voidvoidStart the NIO2 endpoint, creating acceptor.voidStop the endpoint.voidunbind()Deallocate NIO memory pools, and close server socket.Methods inherited from class AbstractNetworkChannelEndpoint
getLocalAddressMethods inherited from class AbstractEndpoint
addNegotiatedProtocol, addSslHostConfig, addSslHostConfig, awaitConnectionsClose, checkSni, closeServerSocketGraceful, closeSocket, countDownConnection, countUpOrAwaitConnection, createExecutor, createSSLContext, createSSLEngine, destroy, destroySsl, findSslHostConfigs, generateCertificateDebug, getAcceptCount, getAcceptorThreadPriority, getAddress, getAttribute, getBindOnInit, getBindState, getConnectionCount, getConnectionLinger, getConnections, getConnectionTimeout, getCurrentThreadCount, getCurrentThreadsBusy, getDaemon, getDefaultSSLHostConfigName, getDomain, getExecutor, getExecutorTerminationTimeoutMillis, getHandler, getId, getKeepAliveTimeout, getLocalPort, getMaxConnections, getMaxKeepAliveRequests, getMaxQueueSize, getMaxThreads, getMinSpareThreads, getName, getPort, getPortOffset, getPortWithOffset, getProperty, getSniParseLimit, getSocketProperties, getSSLHostConfig, getSslImplementation, getSslImplementationName, getStrictSni, getTcpNoDelay, getThreadPriority, getThreadsMaxIdleTime, getUseAsyncIO, getUseSendfile, getUseVirtualThreads, getUtilityExecutor, hasNegotiableProtocols, init, initialiseSsl, initializeConnectionLatch, isPaused, isRunning, isSSLEnabled, logCertificate, pause, processSocket, releaseSSLContext, reloadSslHostConfig, reloadSslHostConfigs, removeSslHostConfig, setAcceptCount, setAcceptorThreadPriority, setAddress, setAttribute, setBindOnInit, setConnectionLinger, setConnectionTimeout, setDaemon, setDefaultSSLHostConfigName, setDomain, setExecutor, setExecutorTerminationTimeoutMillis, setHandler, setKeepAliveTimeout, setMaxConnections, setMaxKeepAliveRequests, setMaxQueueSize, setMaxThreads, setMinSpareThreads, setName, setPort, setPortOffset, setProperty, setSniParseLimit, setSSLEnabled, setSslImplementationName, setStrictSni, setTcpNoDelay, setThreadPriority, setThreadsMaxIdleTime, setUseAsyncIO, setUseSendfile, setUseVirtualThreads, setUtilityExecutor, start, stop, toTimeout, unlockAccept
-
Constructor Details
-
Nio2Endpoint
public Nio2Endpoint()
-
-
Method Details
-
getKeepAliveCount
public int getKeepAliveCount()Number of keep-alive sockets.- Returns:
- Always returns -1.
-
bind
Initialize the endpoint.- Specified by:
bindin classAbstractEndpoint<Nio2Channel, AsynchronousSocketChannel>- Throws:
Exception- If an error occurs during binding
-
startInternal
Start the NIO2 endpoint, creating acceptor.- Specified by:
startInternalin classAbstractEndpoint<Nio2Channel, AsynchronousSocketChannel>- Throws:
Exception- If an error occurs during startup
-
startAcceptorThread
protected void startAcceptorThread()Description copied from class:AbstractEndpointStart the acceptor thread.- Overrides:
startAcceptorThreadin classAbstractEndpoint<Nio2Channel, AsynchronousSocketChannel>
-
resume
public void resume()Description copied from class:AbstractEndpointResume the endpoint, which will make it start accepting new connections again.- Overrides:
resumein classAbstractEndpoint<Nio2Channel, AsynchronousSocketChannel>
-
stopInternal
public void stopInternal()Stop the endpoint. This will cause all processing threads to stop.- Specified by:
stopInternalin classAbstractEndpoint<Nio2Channel, AsynchronousSocketChannel>
-
unbind
Deallocate NIO memory pools, and close server socket.- Overrides:
unbindin classAbstractEndpoint<Nio2Channel, AsynchronousSocketChannel>- Throws:
Exception- If an error occurs during unbinding
-
doCloseServerSocket
Description copied from class:AbstractEndpointActually close the server socket but don't perform any other clean-up.- Specified by:
doCloseServerSocketin classAbstractEndpoint<Nio2Channel, AsynchronousSocketChannel>- Throws:
IOException- If an error occurs closing the socket
-
shutdownExecutor
public void shutdownExecutor()Description copied from class:AbstractEndpointShutdown the internal executor.- Overrides:
shutdownExecutorin classAbstractEndpoint<Nio2Channel, AsynchronousSocketChannel>
-
setSocketOptions
Process the specified connection.- Specified by:
setSocketOptionsin classAbstractEndpoint<Nio2Channel, AsynchronousSocketChannel>- Parameters:
socket- The socket channel- Returns:
trueif the socket was correctly configured and processing may continue,falseif the socket needs to be close immediately
-
destroySocket
Description copied from class:AbstractEndpointClose the socket. This is used when the connector is not in a state which allows processing the socket, or if there was an error which prevented the allocation of the socket wrapper.- Specified by:
destroySocketin classAbstractEndpoint<Nio2Channel, AsynchronousSocketChannel>- Parameters:
socket- The newly accepted socket
-
getNioChannels
-
getServerSocket
Description copied from class:AbstractNetworkChannelEndpointReturns the server socket used by this endpoint.- Specified by:
getServerSocketin classAbstractNetworkChannelEndpoint<Nio2Channel, AsynchronousSocketChannel>- Returns:
- the server socket
-
serverSocketAccept
Description copied from class:AbstractEndpointAccept a connection from the server socket.- Specified by:
serverSocketAcceptin classAbstractEndpoint<Nio2Channel, AsynchronousSocketChannel>- Returns:
- The accepted socket
- Throws:
Exception- If an error occurs during accept
-
getLog
Description copied from class:AbstractEndpointGet the logger for this endpoint.- Specified by:
getLogin classAbstractEndpoint<Nio2Channel, AsynchronousSocketChannel>- Returns:
- The logger
-
getLogCertificate
Description copied from class:AbstractEndpointGet the logger for certificate-related messages.- Overrides:
getLogCertificatein classAbstractEndpoint<Nio2Channel, AsynchronousSocketChannel>- Returns:
- The logger (defaults to
AbstractEndpoint.getLog())
-
createSocketProcessor
protected SocketProcessorBase<Nio2Channel> createSocketProcessor(SocketWrapperBase<Nio2Channel> socketWrapper, SocketEvent event) Description copied from class:AbstractEndpointCreate a socket processor for the given socket wrapper.- Specified by:
createSocketProcessorin classAbstractEndpoint<Nio2Channel, AsynchronousSocketChannel>- Parameters:
socketWrapper- The socket wrapper to processevent- The socket event- Returns:
- The socket processor
-
createChannel
Description copied from class:AbstractNetworkChannelEndpointCreates the channel to be used by this endpoint.- Specified by:
createChannelin classAbstractNetworkChannelEndpoint<Nio2Channel, AsynchronousSocketChannel>- Parameters:
buffer- The buffer handler to use for the channel- Returns:
- the created channel
-
startInline
public static void startInline() -
endInline
public static void endInline() -
isInline
public static boolean isInline()
-