Package org.apache.tomcat.util.net
Class Nio2Endpoint
- java.lang.Object
-
- org.apache.tomcat.util.net.AbstractEndpoint<S,U>
-
- org.apache.tomcat.util.net.AbstractJsseEndpoint<Nio2Channel,AsynchronousSocketChannel>
-
- org.apache.tomcat.util.net.Nio2Endpoint
-
public class Nio2Endpoint extends AbstractJsseEndpoint<Nio2Channel,AsynchronousSocketChannel>
NIO2 endpoint.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classNio2Endpoint.Nio2Acceptorstatic classNio2Endpoint.Nio2SocketWrapperstatic classNio2Endpoint.SendfileDataSendfileData class.protected classNio2Endpoint.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 inherited from class org.apache.tomcat.util.net.AbstractEndpoint
acceptor, acceptorThreadPriority, attributes, connections, internalExecutor, negotiableProtocols, paused, processorCache, running, sm, socketProperties, sslHostConfigs, threadPriority
-
-
Constructor Summary
Constructors Constructor Description Nio2Endpoint()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbind()Initialize the endpoint.protected SocketProcessorBase<Nio2Channel>createSocketProcessor(SocketWrapperBase<Nio2Channel> socketWrapper, SocketEvent event)protected voiddestroySocket(AsynchronousSocketChannel socket)Close the socket.protected voiddoCloseServerSocket()Actually close the server socket but don't perform any other clean-up.static voidendInline()intgetKeepAliveCount()Number of keep-alive sockets.protected LoggetLog()protected SynchronizedStack<Nio2Channel>getNioChannels()protected NetworkChannelgetServerSocket()static booleanisInline()voidresume()Resume the endpoint, which will make it start accepting new connections again.protected AsynchronousSocketChannelserverSocketAccept()protected booleansetSocketOptions(AsynchronousSocketChannel socket)Process the specified connection.voidshutdownExecutor()protected voidstartAcceptorThread()static voidstartInline()voidstartInternal()Start the NIO2 endpoint, creating acceptor.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, initialiseSsl, 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, getId, 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, 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, start, stop, toTimeout, unlockAccept
-
-
-
-
Method Detail
-
getKeepAliveCount
public int getKeepAliveCount()
Number of keep-alive sockets.- Returns:
- Always returns -1.
-
bind
public void bind() throws ExceptionInitialize the endpoint.- Specified by:
bindin classAbstractEndpoint<Nio2Channel,AsynchronousSocketChannel>- Throws:
Exception
-
startInternal
public void startInternal() throws ExceptionStart the NIO2 endpoint, creating acceptor.- Specified by:
startInternalin classAbstractEndpoint<Nio2Channel,AsynchronousSocketChannel>- Throws:
Exception
-
startAcceptorThread
protected void startAcceptorThread()
- 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
public void unbind() throws ExceptionDeallocate NIO memory pools, and close server socket.- Overrides:
unbindin classAbstractJsseEndpoint<Nio2Channel,AsynchronousSocketChannel>- 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<Nio2Channel,AsynchronousSocketChannel>- Throws:
IOException- If an error occurs closing the socket
-
shutdownExecutor
public void shutdownExecutor()
- Overrides:
shutdownExecutorin classAbstractEndpoint<Nio2Channel,AsynchronousSocketChannel>
-
setSocketOptions
protected boolean setSocketOptions(AsynchronousSocketChannel socket)
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
protected void destroySocket(AsynchronousSocketChannel 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<Nio2Channel,AsynchronousSocketChannel>- Parameters:
socket- The newly accepted socket
-
getNioChannels
protected SynchronizedStack<Nio2Channel> getNioChannels()
-
getServerSocket
protected NetworkChannel getServerSocket()
- Specified by:
getServerSocketin classAbstractJsseEndpoint<Nio2Channel,AsynchronousSocketChannel>
-
serverSocketAccept
protected AsynchronousSocketChannel serverSocketAccept() throws Exception
- Specified by:
serverSocketAcceptin classAbstractEndpoint<Nio2Channel,AsynchronousSocketChannel>- Throws:
Exception
-
getLog
protected Log getLog()
- Specified by:
getLogin classAbstractEndpoint<Nio2Channel,AsynchronousSocketChannel>
-
createSocketProcessor
protected SocketProcessorBase<Nio2Channel> createSocketProcessor(SocketWrapperBase<Nio2Channel> socketWrapper, SocketEvent event)
- Specified by:
createSocketProcessorin classAbstractEndpoint<Nio2Channel,AsynchronousSocketChannel>
-
startInline
public static void startInline()
-
endInline
public static void endInline()
-
isInline
public static boolean isInline()
-
-