Package org.apache.tomcat.util.net
Class NioEndpoint
java.lang.Object
org.apache.tomcat.util.net.AbstractEndpoint<NioChannel,SocketChannel>
org.apache.tomcat.util.net.AbstractNetworkChannelEndpoint<NioChannel,SocketChannel>
org.apache.tomcat.util.net.NioEndpoint
NIO endpoint.
- Author:
- Mladen Turk
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
class
Poller class.static class
PollerEvent, cacheable object for poller events to avoid GCstatic class
SendfileData class.protected class
This 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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
bind()
Initialize the endpoint.protected NioChannel
createChannel
(SocketBufferHandler buffer) protected SocketProcessorBase
<NioChannel> createSocketProcessor
(SocketWrapperBase<NioChannel> socketWrapper, SocketEvent event) protected void
destroySocket
(SocketChannel socket) Close the socket.protected void
Actually 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.int
Number of keep-alive sockets.protected Log
getLog()
protected Log
protected SynchronizedStack
<NioChannel> protected NioEndpoint.Poller
int
long
protected NetworkChannel
protected CountDownLatch
boolean
protected void
protected SocketChannel
void
setPollerThreadPriority
(int pollerThreadPriority) void
setSelectorTimeout
(long timeout) protected boolean
setSocketOptions
(SocketChannel socket) Process the specified connection.protected void
setStopLatch
(CountDownLatch stopLatch) void
setUnixDomainSocketPath
(String unixDomainSocketPath) void
setUnixDomainSocketPathPermissions
(String unixDomainSocketPathPermissions) void
setUseInheritedChannel
(boolean useInheritedChannel) void
Start the NIO endpoint, creating acceptor, poller threads.void
Stop the endpoint.void
unbind()
Deallocate NIO memory pools, and close server socket.protected void
Unlock the server socket acceptor threads using bogus connections.Methods inherited from class org.apache.tomcat.util.net.AbstractNetworkChannelEndpoint
getLocalAddress
Methods inherited from class org.apache.tomcat.util.net.AbstractEndpoint
addNegotiatedProtocol, addSslHostConfig, addSslHostConfig, awaitConnectionsClose, closeServerSocketGraceful, closeSocket, countDownConnection, countUpOrAwaitConnection, createExecutor, createSSLContext, createSSLEngine, destroy, destroySsl, findSslHostConfigs, generateCertificateDebug, getAcceptCount, getAcceptorThreadPriority, getAddress, getAttribute, getBindOnInit, getBindState, getConnectionCount, getConnectionLinger, getConnections, getConnectionTimeout, getCurrentThreadCount, getCurrentThreadsBusy, getDaemon, getDefaultSSLHostConfigName, getDomain, getExecutor, getExecutorTerminationTimeoutMillis, getHandler, getKeepAliveTimeout, getLocalPort, getMaxConnections, getMaxKeepAliveRequests, getMaxQueueSize, getMaxThreads, getMinSpareThreads, getName, getPort, getPortOffset, getPortWithOffset, getProperty, getSniParseLimit, getSocketProperties, getSSLHostConfig, getSslImplementation, getSslImplementationName, getTcpNoDelay, getThreadPriority, getThreadsMaxIdleTime, getUseAsyncIO, getUseSendfile, getUseVirtualThreads, getUtilityExecutor, hasNegotiableProtocols, init, initialiseSsl, 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, setSniParseLimit, setSSLEnabled, setSslImplementationName, setTcpNoDelay, setThreadPriority, setThreadsMaxIdleTime, setUseAsyncIO, setUseSendfile, setUseVirtualThreads, setUtilityExecutor, shutdownExecutor, start, startAcceptorThread, stop, toTimeout
-
Field Details
-
OP_REGISTER
public static final int OP_REGISTER- See Also:
-
-
Constructor Details
-
NioEndpoint
public NioEndpoint()
-
-
Method Details
-
setUseInheritedChannel
public void setUseInheritedChannel(boolean useInheritedChannel) -
getUseInheritedChannel
public boolean getUseInheritedChannel() -
getUnixDomainSocketPath
-
setUnixDomainSocketPath
-
getUnixDomainSocketPathPermissions
-
setUnixDomainSocketPathPermissions
-
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
Description copied from class:AbstractEndpoint
The 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:
getId
in classAbstractEndpoint<NioChannel,
SocketChannel> - Returns:
- the id
-
bind
Initialize the endpoint.- Specified by:
bind
in classAbstractEndpoint<NioChannel,
SocketChannel> - Throws:
Exception
-
initServerSocket
-
startInternal
Start the NIO endpoint, creating acceptor, poller threads.- Specified by:
startInternal
in classAbstractEndpoint<NioChannel,
SocketChannel> - Throws:
Exception
-
stopInternal
public void stopInternal()Stop the endpoint. This will cause all processing threads to stop.- Specified by:
stopInternal
in classAbstractEndpoint<NioChannel,
SocketChannel>
-
unbind
Deallocate NIO memory pools, and close server socket.- Overrides:
unbind
in classAbstractEndpoint<NioChannel,
SocketChannel> - Throws:
Exception
-
doCloseServerSocket
Description copied from class:AbstractEndpoint
Actually close the server socket but don't perform any other clean-up.- Specified by:
doCloseServerSocket
in classAbstractEndpoint<NioChannel,
SocketChannel> - Throws:
IOException
- If an error occurs closing the socket
-
unlockAccept
protected void unlockAccept()Description copied from class:AbstractEndpoint
Unlock the server socket acceptor threads using bogus connections.- Overrides:
unlockAccept
in classAbstractEndpoint<NioChannel,
SocketChannel>
-
getNioChannels
-
getPoller
-
getStopLatch
-
setStopLatch
-
setSocketOptions
Process the specified connection.- Specified by:
setSocketOptions
in classAbstractEndpoint<NioChannel,
SocketChannel> - Parameters:
socket
- The socket channel- Returns:
true
if the socket was correctly configured and processing may continue,false
if the socket needs to be close immediately
-
destroySocket
Description copied from class:AbstractEndpoint
Close 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:
destroySocket
in classAbstractEndpoint<NioChannel,
SocketChannel> - Parameters:
socket
- The newly accepted socket
-
getServerSocket
- Specified by:
getServerSocket
in classAbstractNetworkChannelEndpoint<NioChannel,
SocketChannel>
-
serverSocketAccept
- Specified by:
serverSocketAccept
in classAbstractEndpoint<NioChannel,
SocketChannel> - Throws:
Exception
-
getLog
- Specified by:
getLog
in classAbstractEndpoint<NioChannel,
SocketChannel>
-
getLogCertificate
- Overrides:
getLogCertificate
in classAbstractEndpoint<NioChannel,
SocketChannel>
-
createSocketProcessor
protected SocketProcessorBase<NioChannel> createSocketProcessor(SocketWrapperBase<NioChannel> socketWrapper, SocketEvent event) - Specified by:
createSocketProcessor
in classAbstractEndpoint<NioChannel,
SocketChannel>
-
createChannel
- Specified by:
createChannel
in classAbstractNetworkChannelEndpoint<NioChannel,
SocketChannel>
-