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 SummaryNested 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.AbstractEndpointAbstractEndpoint.BindState, AbstractEndpoint.Handler<S>
 
- 
 - 
Field SummaryFields Modifier and Type Field Description static intOP_REGISTER- 
Fields inherited from class org.apache.tomcat.util.net.AbstractEndpointacceptor, acceptorThreadCount, acceptorThreadPriority, attributes, connections, internalExecutor, negotiableProtocols, paused, processorCache, running, sm, socketProperties, sslHostConfigs, threadPriority
 
- 
 - 
Constructor SummaryConstructors Constructor Description NioEndpoint()
 - 
Method SummaryAll 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?java.lang.StringgetId()The default behavior is to identify connectors uniquely with address and port.intgetKeepAliveCount()Number of keep-alive sockets.protected LoggetLog()protected LoggetLogCertificate()protected SynchronizedStack<NioChannel>getNioChannels()protected NioEndpoint.PollergetPoller()intgetPollerThreadCount()Deprecated.Will be removed in Tomcat 10.intgetPollerThreadPriority()longgetSelectorTimeout()protected java.nio.channels.NetworkChannelgetServerSocket()protected java.util.concurrent.CountDownLatchgetStopLatch()java.lang.StringgetUnixDomainSocketPath()java.lang.StringgetUnixDomainSocketPathPermissions()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)voidsetUnixDomainSocketPath(java.lang.String unixDomainSocketPath)voidsetUnixDomainSocketPathPermissions(java.lang.String unixDomainSocketPathPermissions)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.protected voidunlockAccept()Unlock the server socket acceptor threads using bogus connections.- 
Methods inherited from class org.apache.tomcat.util.net.AbstractJsseEndpointcreateSSLContext, createSSLEngine, getLocalAddress, getSniParseLimit, getSslImplementation, getSslImplementationName, initialiseSsl, isAlpnSupported, setSniParseLimit, setSslImplementationName
 - 
Methods inherited from class org.apache.tomcat.util.net.AbstractEndpointaddNegotiatedProtocol, addSslHostConfig, addSslHostConfig, awaitConnectionsClose, closeServerSocketGraceful, closeSocket, countDownConnection, countUpOrAwaitConnection, createExecutor, destroy, destroySsl, findSslHostConfigs, generateCertificateDebug, getAcceptCount, getAcceptorThreadCount, getAcceptorThreadPriority, getAddress, getAttribute, getBindOnInit, getBindState, getConnectionCount, getConnectionLinger, getConnections, getConnectionTimeout, getCurrentThreadCount, getCurrentThreadsBusy, getDaemon, getDefaultSSLHostConfigName, getDomain, getExecutor, getExecutorTerminationTimeoutMillis, getHandler, getKeepAliveTimeout, getLocalPort, getMaxConnections, getMaxKeepAliveRequests, getMaxThreads, getMinSpareThreads, getName, getPort, getPortOffset, getPortWithOffset, getProperty, getSocketProperties, getSSLHostConfig, getTcpNoDelay, getThreadPriority, getUseAsyncIO, getUseSendfile, getUseVirtualThreads, getUtilityExecutor, hasNegotiableProtocols, init, initializeConnectionLatch, isPaused, isRunning, isSSLEnabled, logCertificate, pause, processSocket, releaseSSLContext, reloadSslHostConfig, reloadSslHostConfigs, removeSslHostConfig, resume, setAcceptCount, setAcceptorThreadCount, setAcceptorThreadPriority, setAddress, setAttribute, setBindOnInit, setConnectionLinger, setConnectionTimeout, setDaemon, setDefaultSSLHostConfigName, setDomain, setExecutor, setExecutorTerminationTimeoutMillis, setHandler, setKeepAliveTimeout, setMaxConnections, setMaxKeepAliveRequests, setMaxThreads, setMinSpareThreads, setName, setPort, setPortOffset, setProperty, setSSLEnabled, setTcpNoDelay, setThreadPriority, setUseAsyncIO, setUseSendfile, setUseVirtualThreads, setUtilityExecutor, shutdownExecutor, start, startAcceptorThread, stop, toTimeout
 
- 
 
- 
- 
- 
Field Detail- 
OP_REGISTERpublic static final int OP_REGISTER - See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
setUseInheritedChannelpublic void setUseInheritedChannel(boolean useInheritedChannel) 
 - 
getUseInheritedChannelpublic boolean getUseInheritedChannel() 
 - 
getUnixDomainSocketPathpublic java.lang.String getUnixDomainSocketPath() 
 - 
setUnixDomainSocketPathpublic void setUnixDomainSocketPath(java.lang.String unixDomainSocketPath) 
 - 
getUnixDomainSocketPathPermissionspublic java.lang.String getUnixDomainSocketPathPermissions() 
 - 
setUnixDomainSocketPathPermissionspublic void setUnixDomainSocketPathPermissions(java.lang.String unixDomainSocketPathPermissions) 
 - 
setPollerThreadPrioritypublic void setPollerThreadPriority(int pollerThreadPriority) 
 - 
getPollerThreadPrioritypublic 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.
 
 - 
setSelectorTimeoutpublic void setSelectorTimeout(long timeout) 
 - 
getSelectorTimeoutpublic long getSelectorTimeout() 
 - 
getDeferAcceptpublic boolean getDeferAccept() Is deferAccept supported?- Specified by:
- getDeferAcceptin class- AbstractEndpoint<NioChannel,java.nio.channels.SocketChannel>
 
 - 
getKeepAliveCountpublic 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
 
 - 
getIdpublic java.lang.String 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 class- AbstractEndpoint<NioChannel,java.nio.channels.SocketChannel>
- Returns:
- the id
 
 - 
bindpublic void bind() throws java.lang.ExceptionInitialize the endpoint.- Specified by:
- bindin class- AbstractEndpoint<NioChannel,java.nio.channels.SocketChannel>
- Throws:
- java.lang.Exception
 
 - 
initServerSocketprotected void initServerSocket() throws java.lang.Exception- Throws:
- java.lang.Exception
 
 - 
startInternalpublic void startInternal() throws java.lang.ExceptionStart the NIO endpoint, creating acceptor, poller threads.- Specified by:
- startInternalin class- AbstractEndpoint<NioChannel,java.nio.channels.SocketChannel>
- Throws:
- java.lang.Exception
 
 - 
stopInternalpublic void stopInternal() Stop the endpoint. This will cause all processing threads to stop.- Specified by:
- stopInternalin class- AbstractEndpoint<NioChannel,java.nio.channels.SocketChannel>
 
 - 
unbindpublic void unbind() throws java.lang.ExceptionDeallocate NIO memory pools, and close server socket.- Overrides:
- unbindin class- AbstractJsseEndpoint<NioChannel,java.nio.channels.SocketChannel>
- Throws:
- java.lang.Exception
 
 - 
doCloseServerSocketprotected 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 class- AbstractEndpoint<NioChannel,java.nio.channels.SocketChannel>
- Throws:
- java.io.IOException- If an error occurs closing the socket
 
 - 
unlockAcceptprotected void unlockAccept() Description copied from class:AbstractEndpointUnlock the server socket acceptor threads using bogus connections.- Overrides:
- unlockAcceptin class- AbstractEndpoint<NioChannel,java.nio.channels.SocketChannel>
 
 - 
getNioChannelsprotected SynchronizedStack<NioChannel> getNioChannels() 
 - 
getPollerprotected NioEndpoint.Poller getPoller() 
 - 
getStopLatchprotected java.util.concurrent.CountDownLatch getStopLatch() 
 - 
setStopLatchprotected void setStopLatch(java.util.concurrent.CountDownLatch stopLatch) 
 - 
setSocketOptionsprotected boolean setSocketOptions(java.nio.channels.SocketChannel socket) Process the specified connection.- Specified by:
- setSocketOptionsin class- AbstractEndpoint<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
 
 - 
destroySocketprotected 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 class- AbstractEndpoint<NioChannel,java.nio.channels.SocketChannel>
- Parameters:
- socket- The newly accepted socket
 
 - 
getServerSocketprotected java.nio.channels.NetworkChannel getServerSocket() - Specified by:
- getServerSocketin class- AbstractJsseEndpoint<NioChannel,java.nio.channels.SocketChannel>
 
 - 
serverSocketAcceptprotected java.nio.channels.SocketChannel serverSocketAccept() throws java.lang.Exception- Specified by:
- serverSocketAcceptin class- AbstractEndpoint<NioChannel,java.nio.channels.SocketChannel>
- Throws:
- java.lang.Exception
 
 - 
getLogprotected Log getLog() - Specified by:
- getLogin class- AbstractEndpoint<NioChannel,java.nio.channels.SocketChannel>
 
 - 
getLogCertificateprotected Log getLogCertificate() - Overrides:
- getLogCertificatein class- AbstractEndpoint<NioChannel,java.nio.channels.SocketChannel>
 
 - 
createSocketProcessorprotected SocketProcessorBase<NioChannel> createSocketProcessor(SocketWrapperBase<NioChannel> socketWrapper, SocketEvent event) - Specified by:
- createSocketProcessorin class- AbstractEndpoint<NioChannel,java.nio.channels.SocketChannel>
 
 
- 
 
-