Package org.apache.tomcat.util.net
Class NioEndpoint
- java.lang.Object
-
- org.apache.tomcat.util.net.AbstractEndpoint<S,U>
-
- org.apache.tomcat.util.net.AbstractJsseEndpoint<NioChannel,java.nio.channels.SocketChannel>
-
- org.apache.tomcat.util.net.NioEndpoint
-
public class NioEndpoint extends AbstractJsseEndpoint<NioChannel,java.nio.channels.SocketChannel>
NIO tailored thread pool, providing the following services:- Socket acceptor thread
- Socket poller thread
- Worker threads pool
- Author:
- Mladen Turk, Remy Maucherat
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classNioEndpoint.NioSocketWrapperclassNioEndpoint.PollerPoller class.static classNioEndpoint.PollerEventPollerEvent, cacheable object for poller events to avoid GCstatic classNioEndpoint.SendfileDataSendfileData class.protected classNioEndpoint.SocketProcessorThis class is the equivalent of the Worker, but will simply use in an external Executor thread pool.-
Nested classes/interfaces inherited from class org.apache.tomcat.util.net.AbstractEndpoint
AbstractEndpoint.BindState, AbstractEndpoint.Handler<S>
-
-
Field Summary
Fields Modifier and Type Field Description static intOP_REGISTER-
Fields inherited from class org.apache.tomcat.util.net.AbstractEndpoint
acceptor, acceptorThreadCount, acceptorThreadPriority, attributes, connections, internalExecutor, negotiableProtocols, paused, processorCache, running, sm, socketProperties, sslHostConfigs, threadPriority
-
-
Constructor Summary
Constructors Constructor Description NioEndpoint()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidbind()Initialize the endpoint.protected SocketProcessorBase<NioChannel>createSocketProcessor(SocketWrapperBase<NioChannel> socketWrapper, SocketEvent event)protected voiddestroySocket(java.nio.channels.SocketChannel socket)Close the socket.protected voiddoCloseServerSocket()Actually close the server socket but don't perform any other clean-up.booleangetDeferAccept()Is deferAccept supported?intgetKeepAliveCount()Number of keep-alive sockets.protected LoggetLog()protected LoggetLogCertificate()protected SynchronizedStack<NioChannel>getNioChannels()protected NioEndpoint.PollergetPoller()NioEndpoint.PollergetPoller0()Deprecated.Will be removed in Tomcat 9.intgetPollerThreadCount()Deprecated.Will be removed in Tomcat 10.intgetPollerThreadPriority()longgetSelectorTimeout()protected java.nio.channels.NetworkChannelgetServerSocket()protected java.util.concurrent.CountDownLatchgetStopLatch()booleangetUseInheritedChannel()protected voidinitServerSocket()protected java.nio.channels.SocketChannelserverSocketAccept()voidsetPollerThreadCount(int pollerThreadCount)Deprecated.Will be removed in Tomcat 10.voidsetPollerThreadPriority(int pollerThreadPriority)voidsetSelectorTimeout(long timeout)protected booleansetSocketOptions(java.nio.channels.SocketChannel socket)Process the specified connection.protected voidsetStopLatch(java.util.concurrent.CountDownLatch stopLatch)voidsetUseInheritedChannel(boolean useInheritedChannel)voidstartInternal()Start the NIO endpoint, creating acceptor, poller threads.voidstopInternal()Stop the endpoint.voidunbind()Deallocate NIO memory pools, and close server socket.-
Methods inherited from class org.apache.tomcat.util.net.AbstractJsseEndpoint
createSSLContext, createSSLEngine, getLocalAddress, getSniParseLimit, getSslImplementation, getSslImplementationName, init, initialiseSsl, isAlpnSupported, setSniParseLimit, setSslImplementationName
-
Methods inherited from class org.apache.tomcat.util.net.AbstractEndpoint
addNegotiatedProtocol, addSslHostConfig, addSslHostConfig, awaitConnectionsClose, closeServerSocketGraceful, closeSocket, countDownConnection, countUpOrAwaitConnection, createExecutor, destroy, destroySsl, findSslHostConfigs, generateCertificateDebug, getAcceptCount, getAcceptorThreadCount, getAcceptorThreadPriority, getAddress, getAttribute, getBacklog, getBindOnInit, getBindState, getConnectionCount, getConnectionLinger, getConnections, getConnectionTimeout, getCurrentThreadCount, getCurrentThreadsBusy, getDaemon, getDefaultSSLHostConfigName, getDomain, getExecutor, getExecutorTerminationTimeoutMillis, getHandler, getKeepAliveTimeout, getLocalPort, getMaxConnections, getMaxHeaderCount, getMaxKeepAliveRequests, getMaxThreads, getMinSpareThreads, getName, getPort, getPortOffset, getPortWithOffset, getProperty, getSocketProperties, getSoLinger, getSoTimeout, getSSLHostConfig, getTcpNoDelay, getThreadPriority, getUseAsyncIO, getUseSendfile, getUseVirtualThreads, hasNegotiableProtocols, initializeConnectionLatch, isPaused, isRunning, isSSLEnabled, logCertificate, pause, processSocket, releaseConnectionLatch, releaseSSLContext, reloadSslHostConfig, reloadSslHostConfigs, removeSslHostConfig, resume, setAcceptCount, setAcceptorThreadCount, setAcceptorThreadPriority, setAddress, setAttribute, setBacklog, setBindOnInit, setConnectionLinger, setConnectionTimeout, setDaemon, setDefaultSSLHostConfigName, setDomain, setExecutor, setExecutorTerminationTimeoutMillis, setHandler, setKeepAliveTimeout, setMaxConnections, setMaxHeaderCount, setMaxKeepAliveRequests, setMaxThreads, setMinSpareThreads, setName, setPort, setPortOffset, setProperty, setSoLinger, setSoTimeout, setSSLEnabled, setTcpNoDelay, setThreadPriority, setUseAsyncIO, setUseSendfile, setUseVirtualThreads, shutdownExecutor, start, startAcceptorThread, stop, toTimeout, unlockAccept
-
-
-
-
Field Detail
-
OP_REGISTER
public static final int OP_REGISTER
- See Also:
- Constant Field Values
-
-
Method Detail
-
setUseInheritedChannel
public void setUseInheritedChannel(boolean useInheritedChannel)
-
getUseInheritedChannel
public boolean getUseInheritedChannel()
-
setPollerThreadPriority
public void setPollerThreadPriority(int pollerThreadPriority)
-
getPollerThreadPriority
public int getPollerThreadPriority()
-
setPollerThreadCount
@Deprecated public void setPollerThreadCount(int pollerThreadCount)
Deprecated.Will be removed in Tomcat 10.NO-OP.- Parameters:
pollerThreadCount- Unused
-
getPollerThreadCount
@Deprecated public int getPollerThreadCount()
Deprecated.Will be removed in Tomcat 10.Always returns 1.- Returns:
- Always 1.
-
setSelectorTimeout
public void setSelectorTimeout(long timeout)
-
getSelectorTimeout
public long getSelectorTimeout()
-
getPoller0
@Deprecated public NioEndpoint.Poller getPoller0()
Deprecated.Will be removed in Tomcat 9.Not used.- Returns:
- The poller
-
getDeferAccept
public boolean getDeferAccept()
Is deferAccept supported?- Specified by:
getDeferAcceptin classAbstractEndpoint<NioChannel,java.nio.channels.SocketChannel>
-
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
-
bind
public void bind() throws java.lang.ExceptionInitialize the endpoint.- Specified by:
bindin classAbstractEndpoint<NioChannel,java.nio.channels.SocketChannel>- Throws:
java.lang.Exception
-
initServerSocket
protected void initServerSocket() throws java.lang.Exception- Throws:
java.lang.Exception
-
startInternal
public void startInternal() throws java.lang.ExceptionStart the NIO endpoint, creating acceptor, poller threads.- Specified by:
startInternalin classAbstractEndpoint<NioChannel,java.nio.channels.SocketChannel>- Throws:
java.lang.Exception
-
stopInternal
public void stopInternal()
Stop the endpoint. This will cause all processing threads to stop.- Specified by:
stopInternalin classAbstractEndpoint<NioChannel,java.nio.channels.SocketChannel>
-
unbind
public void unbind() throws java.lang.ExceptionDeallocate NIO memory pools, and close server socket.- Overrides:
unbindin classAbstractJsseEndpoint<NioChannel,java.nio.channels.SocketChannel>- Throws:
java.lang.Exception
-
doCloseServerSocket
protected void doCloseServerSocket() throws java.io.IOExceptionDescription copied from class:AbstractEndpointActually close the server socket but don't perform any other clean-up.- Specified by:
doCloseServerSocketin classAbstractEndpoint<NioChannel,java.nio.channels.SocketChannel>- Throws:
java.io.IOException- If an error occurs closing the socket
-
getNioChannels
protected SynchronizedStack<NioChannel> getNioChannels()
-
getPoller
protected NioEndpoint.Poller getPoller()
-
getStopLatch
protected java.util.concurrent.CountDownLatch getStopLatch()
-
setStopLatch
protected void setStopLatch(java.util.concurrent.CountDownLatch stopLatch)
-
setSocketOptions
protected boolean setSocketOptions(java.nio.channels.SocketChannel socket)
Process the specified connection.- Specified by:
setSocketOptionsin classAbstractEndpoint<NioChannel,java.nio.channels.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
protected void destroySocket(java.nio.channels.SocketChannel socket)
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,java.nio.channels.SocketChannel>- Parameters:
socket- The newly accepted socket
-
getServerSocket
protected java.nio.channels.NetworkChannel getServerSocket()
- Specified by:
getServerSocketin classAbstractJsseEndpoint<NioChannel,java.nio.channels.SocketChannel>
-
serverSocketAccept
protected java.nio.channels.SocketChannel serverSocketAccept() throws java.lang.Exception- Specified by:
serverSocketAcceptin classAbstractEndpoint<NioChannel,java.nio.channels.SocketChannel>- Throws:
java.lang.Exception
-
getLog
protected Log getLog()
- Specified by:
getLogin classAbstractEndpoint<NioChannel,java.nio.channels.SocketChannel>
-
getLogCertificate
protected Log getLogCertificate()
- Overrides:
getLogCertificatein classAbstractEndpoint<NioChannel,java.nio.channels.SocketChannel>
-
createSocketProcessor
protected SocketProcessorBase<NioChannel> createSocketProcessor(SocketWrapperBase<NioChannel> socketWrapper, SocketEvent event)
- Specified by:
createSocketProcessorin classAbstractEndpoint<NioChannel,java.nio.channels.SocketChannel>
-
-