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,SocketChannel>
-
- org.apache.tomcat.util.net.NioEndpoint
-
public class NioEndpoint extends AbstractJsseEndpoint<NioChannel,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 Modifier and Type Method Description voidbind()Initialize the endpoint.protected SocketProcessorBase<NioChannel>createSocketProcessor(SocketWrapperBase<NioChannel> socketWrapper, SocketEvent event)protected voiddestroySocket(SocketChannel socket)Close the socket.protected voiddoCloseServerSocket()Actually close the server socket but don't perform any other clean-up.StringgetId()The default behavior is to identify connectors uniquely with address and port.intgetKeepAliveCount()Number of keep-alive sockets.protected LoggetLog()protected SynchronizedStack<NioChannel>getNioChannels()protected NioEndpoint.PollergetPoller()intgetPollerThreadPriority()longgetSelectorTimeout()protected NetworkChannelgetServerSocket()protected CountDownLatchgetStopLatch()StringgetUnixDomainSocketPath()StringgetUnixDomainSocketPathPermissions()booleangetUseInheritedChannel()protected voidinitServerSocket()protected SocketChannelserverSocketAccept()voidsetPollerThreadPriority(int pollerThreadPriority)voidsetSelectorTimeout(long timeout)protected booleansetSocketOptions(SocketChannel socket)Process the specified connection.protected voidsetStopLatch(CountDownLatch stopLatch)voidsetUnixDomainSocketPath(String unixDomainSocketPath)voidsetUnixDomainSocketPathPermissions(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.AbstractJsseEndpoint
createSSLContext, createSSLEngine, getLocalAddress, getSniParseLimit, getSslImplementation, getSslImplementationName, 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, getAcceptCount, getAcceptorThreadPriority, getAddress, getAttribute, getBindOnInit, getBindState, getConnectionCount, getConnectionLinger, getConnections, getConnectionTimeout, getCurrentThreadCount, getCurrentThreadsBusy, getDaemon, getDefaultSSLHostConfigName, getDeferAccept, getDomain, getExecutor, getExecutorTerminationTimeoutMillis, getHandler, getKeepAliveTimeout, getLocalPort, getMaxConnections, getMaxKeepAliveRequests, getMaxThreads, getMinSpareThreads, getName, getPort, getPortOffset, getPortWithOffset, getProperty, getSocketProperties, getSSLHostConfig, getTcpNoDelay, getThreadPriority, getUseAsyncIO, getUseSendfile, getUtilityExecutor, hasNegotiableProtocols, init, initializeConnectionLatch, isPaused, isRunning, isSSLEnabled, pause, processSocket, releaseSSLContext, reloadSslHostConfig, reloadSslHostConfigs, removeSslHostConfig, resume, setAcceptCount, 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, setUtilityExecutor, shutdownExecutor, start, startAcceptorThread, stop, toTimeout
-
-
-
-
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()
-
getUnixDomainSocketPath
public String getUnixDomainSocketPath()
-
setUnixDomainSocketPath
public void setUnixDomainSocketPath(String unixDomainSocketPath)
-
getUnixDomainSocketPathPermissions
public String getUnixDomainSocketPathPermissions()
-
setUnixDomainSocketPathPermissions
public void setUnixDomainSocketPathPermissions(String unixDomainSocketPathPermissions)
-
setPollerThreadPriority
public void setPollerThreadPriority(int pollerThreadPriority)
-
getPollerThreadPriority
public int getPollerThreadPriority()
-
setSelectorTimeout
public void setSelectorTimeout(long timeout)
-
getSelectorTimeout
public long getSelectorTimeout()
-
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
public 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 classAbstractEndpoint<NioChannel,SocketChannel>- Returns:
- the id
-
bind
public void bind() throws ExceptionInitialize the endpoint.- Specified by:
bindin classAbstractEndpoint<NioChannel,SocketChannel>- Throws:
Exception
-
startInternal
public void startInternal() throws ExceptionStart the NIO endpoint, creating acceptor, poller threads.- Specified by:
startInternalin classAbstractEndpoint<NioChannel,SocketChannel>- Throws:
Exception
-
stopInternal
public void stopInternal()
Stop the endpoint. This will cause all processing threads to stop.- Specified by:
stopInternalin classAbstractEndpoint<NioChannel,SocketChannel>
-
unbind
public void unbind() throws ExceptionDeallocate NIO memory pools, and close server socket.- Overrides:
unbindin classAbstractJsseEndpoint<NioChannel,SocketChannel>- Throws:
Exception
-
doCloseServerSocket
protected void doCloseServerSocket() throws IOExceptionDescription 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
protected SynchronizedStack<NioChannel> getNioChannels()
-
getPoller
protected NioEndpoint.Poller getPoller()
-
getStopLatch
protected CountDownLatch getStopLatch()
-
setStopLatch
protected void setStopLatch(CountDownLatch stopLatch)
-
setSocketOptions
protected boolean setSocketOptions(SocketChannel socket)
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
protected void destroySocket(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,SocketChannel>- Parameters:
socket- The newly accepted socket
-
getServerSocket
protected NetworkChannel getServerSocket()
- Specified by:
getServerSocketin classAbstractJsseEndpoint<NioChannel,SocketChannel>
-
serverSocketAccept
protected SocketChannel serverSocketAccept() throws Exception
- Specified by:
serverSocketAcceptin classAbstractEndpoint<NioChannel,SocketChannel>- Throws:
Exception
-
getLog
protected Log getLog()
- Specified by:
getLogin classAbstractEndpoint<NioChannel,SocketChannel>
-
createSocketProcessor
protected SocketProcessorBase<NioChannel> createSocketProcessor(SocketWrapperBase<NioChannel> socketWrapper, SocketEvent event)
- Specified by:
createSocketProcessorin classAbstractEndpoint<NioChannel,SocketChannel>
-
-