Class NioEndpoint
java.lang.Object
org.apache.tomcat.util.net.AbstractEndpoint<NioChannel, SocketChannel>
org.apache.tomcat.util.net.AbstractJsseEndpoint<NioChannel, SocketChannel>
org.apache.tomcat.util.net.NioEndpoint
NIO endpoint.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classNIO socket wrapper that wraps an NioChannel.classPoller class.static classPollerEvent, cacheable object for poller events to avoid GCstatic 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
FieldsModifier and TypeFieldDescriptionstatic final intCustom operation for registering interest in a socket.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 SocketProcessorBase<NioChannel> createSocketProcessor(SocketWrapperBase<NioChannel> socketWrapper, SocketEvent event) Create a socket processor for the given socket wrapper.protected voiddestroySocket(SocketChannel socket) Close the socket.protected voidActually close the server socket but don't perform any other clean-up.getId()The default behavior is to identify connectors uniquely with address and port.intNumber of keep-alive sockets.protected LoggetLog()Get the logger for this endpoint.protected LogGet the logger for certificate-related messages.protected SynchronizedStack<NioChannel> Returns the NIO channel cache.protected NioEndpoint.PollerReturns the poller instance.intReturns the poller thread priority.longReturns the selector timeout.protected NetworkChannelprotected CountDownLatchReturns the stop latch.Returns the Unix domain socket path.Returns the Unix domain socket path permissions.booleanReturns whether an inherited channel is used.protected voidInitializes the server socket channel.protected SocketChannelAccept a connection from the server socket.voidsetPollerThreadPriority(int pollerThreadPriority) Sets the poller thread priority.voidsetSelectorTimeout(long timeout) Sets the selector timeout.protected booleansetSocketOptions(SocketChannel socket) Process the specified connection.protected voidsetStopLatch(CountDownLatch stopLatch) Sets the stop latch.voidsetUnixDomainSocketPath(String unixDomainSocketPath) Sets the Unix domain socket path.voidsetUnixDomainSocketPathPermissions(String unixDomainSocketPathPermissions) Sets the Unix domain socket path permissions.voidsetUseInheritedChannel(boolean useInheritedChannel) Sets whether to use an inherited channel.voidStart the NIO endpoint, creating acceptor, poller threads.voidStop the endpoint.voidunbind()Deallocate NIO memory pools, and close server socket.protected voidUnlock the server socket acceptor threads using bogus connections.Methods inherited from class AbstractJsseEndpoint
createSSLContext, createSSLEngine, getLocalAddress, getSniParseLimit, getSslImplementation, getSslImplementationName, initialiseSsl, setSniParseLimit, setSslImplementationNameMethods inherited from class AbstractEndpoint
addNegotiatedProtocol, addSslHostConfig, addSslHostConfig, awaitConnectionsClose, checkSni, closeServerSocketGraceful, closeSocket, countDownConnection, countUpOrAwaitConnection, createExecutor, destroy, destroySsl, findSslHostConfigs, generateCertificateDebug, getAcceptCount, getAcceptorThreadPriority, getAddress, getAttribute, getBindOnInit, getBindState, getConnectionCount, getConnectionLinger, getConnections, getConnectionTimeout, getCurrentThreadCount, getCurrentThreadsBusy, getDaemon, getDefaultSSLHostConfigName, getDeferAccept, getDomain, getExecutor, getExecutorTerminationTimeoutMillis, getHandler, getKeepAliveTimeout, getLocalPort, getMaxConnections, getMaxKeepAliveRequests, getMaxQueueSize, getMaxThreads, getMinSpareThreads, getName, getPort, getPortOffset, getPortWithOffset, getProperty, getSocketProperties, getSSLHostConfig, getStrictSni, getTcpNoDelay, getThreadPriority, getThreadsMaxIdleTime, getUseAsyncIO, getUseSendfile, getUseVirtualThreads, getUtilityExecutor, hasNegotiableProtocols, init, initializeConnectionLatch, isPaused, isRunning, isSSLEnabled, logCertificate, pause, processSocket, releaseSSLContext, reloadSslHostConfig, reloadSslHostConfigs, removeSslHostConfig, resume, setAcceptCount, setAcceptorThreadPriority, setAddress, setAttribute, setBindOnInit, setConnectionLinger, setConnectionTimeout, setDaemon, setDefaultSSLHostConfigName, setDomain, setExecutor, setExecutorTerminationTimeoutMillis, setHandler, setKeepAliveTimeout, setMaxConnections, setMaxKeepAliveRequests, setMaxQueueSize, setMaxThreads, setMinSpareThreads, setName, setPort, setPortOffset, setProperty, setSSLEnabled, setStrictSni, setTcpNoDelay, setThreadPriority, setThreadsMaxIdleTime, setUseAsyncIO, setUseSendfile, setUseVirtualThreads, setUtilityExecutor, shutdownExecutor, start, startAcceptorThread, stop, toTimeout
-
Field Details
-
OP_REGISTER
public static final int OP_REGISTERCustom operation for registering interest in a socket.- See Also:
-
-
Constructor Details
-
NioEndpoint
public NioEndpoint()Default constructor.
-
-
Method Details
-
setUseInheritedChannel
public void setUseInheritedChannel(boolean useInheritedChannel) Sets whether to use an inherited channel.- Parameters:
useInheritedChannel-trueto use System.inheritedChannel
-
getUseInheritedChannel
public boolean getUseInheritedChannel()Returns whether an inherited channel is used.- Returns:
trueif System.inheritedChannel is used
-
getUnixDomainSocketPath
Returns the Unix domain socket path.- Returns:
- the Unix domain socket path
-
setUnixDomainSocketPath
Sets the Unix domain socket path.- Parameters:
unixDomainSocketPath- the path to the Unix domain socket
-
getUnixDomainSocketPathPermissions
Returns the Unix domain socket path permissions.- Returns:
- the permissions string
-
setUnixDomainSocketPathPermissions
Sets the Unix domain socket path permissions.- Parameters:
unixDomainSocketPathPermissions- the permissions string
-
setPollerThreadPriority
public void setPollerThreadPriority(int pollerThreadPriority) Sets the poller thread priority.- Parameters:
pollerThreadPriority- the thread priority
-
getPollerThreadPriority
public int getPollerThreadPriority()Returns the poller thread priority.- Returns:
- the thread priority
-
setSelectorTimeout
public void setSelectorTimeout(long timeout) Sets the selector timeout.- Parameters:
timeout- The timeout in milliseconds
-
getSelectorTimeout
public long getSelectorTimeout()Returns the selector timeout.- Returns:
- the timeout in milliseconds
-
getKeepAliveCount
public int getKeepAliveCount()Number of keep-alive sockets.- Returns:
- The number of sockets currently in the keep-alive state waiting for the next request to be received on the socket
-
getId
Description copied from class:AbstractEndpointThe default behavior is to identify connectors uniquely with address and port. However, certain connectors are not using that and need some other identifier, which then can be used as a replacement.- Overrides:
getIdin classAbstractEndpoint<NioChannel, SocketChannel>- Returns:
- the id
-
bind
Initialize the endpoint.- Specified by:
bindin classAbstractEndpoint<NioChannel, SocketChannel>- Throws:
Exception- If an error occurs during binding
-
initServerSocket
-
startInternal
Start the NIO endpoint, creating acceptor, poller threads.- Specified by:
startInternalin classAbstractEndpoint<NioChannel, SocketChannel>- Throws:
Exception- If an error occurs during startup
-
stopInternal
public void stopInternal()Stop the endpoint. This will cause all processing threads to stop.- Specified by:
stopInternalin classAbstractEndpoint<NioChannel, SocketChannel>
-
unbind
Deallocate NIO memory pools, and close server socket.- Overrides:
unbindin classAbstractJsseEndpoint<NioChannel, SocketChannel>- Throws:
Exception
-
doCloseServerSocket
Description copied from class:AbstractEndpointActually close the server socket but don't perform any other clean-up.- Specified by:
doCloseServerSocketin classAbstractEndpoint<NioChannel, SocketChannel>- Throws:
IOException- If an error occurs closing the socket
-
unlockAccept
protected void unlockAccept()Description copied from class:AbstractEndpointUnlock the server socket acceptor threads using bogus connections.- Overrides:
unlockAcceptin classAbstractEndpoint<NioChannel, SocketChannel>
-
getNioChannels
Returns the NIO channel cache.- Returns:
- the channel cache stack
-
getPoller
-
getStopLatch
-
setStopLatch
Sets the stop latch.- Parameters:
stopLatch- the stop latch
-
setSocketOptions
Process the specified connection.- Specified by:
setSocketOptionsin classAbstractEndpoint<NioChannel, SocketChannel>- 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<NioChannel, SocketChannel>- Parameters:
socket- The newly accepted socket
-
getServerSocket
- Specified by:
getServerSocketin classAbstractJsseEndpoint<NioChannel, SocketChannel>
-
serverSocketAccept
Description copied from class:AbstractEndpointAccept a connection from the server socket.- Specified by:
serverSocketAcceptin classAbstractEndpoint<NioChannel, SocketChannel>- 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<NioChannel, SocketChannel>- Returns:
- The logger
-
getLogCertificate
Description copied from class:AbstractEndpointGet the logger for certificate-related messages.- Overrides:
getLogCertificatein classAbstractEndpoint<NioChannel, SocketChannel>- Returns:
- The logger (defaults to
AbstractEndpoint.getLog())
-
createSocketProcessor
protected SocketProcessorBase<NioChannel> createSocketProcessor(SocketWrapperBase<NioChannel> socketWrapper, SocketEvent event) Description copied from class:AbstractEndpointCreate a socket processor for the given socket wrapper.- Specified by:
createSocketProcessorin classAbstractEndpoint<NioChannel, SocketChannel>- Parameters:
socketWrapper- The socket wrapper to processevent- The socket event- Returns:
- The socket processor
-