Top Description Inners Fields Constructors Methods
org.apache.tomcat.util.net

public Class NioEndpoint

extends AbstractJsseEndpoint<NioChannel, SocketChannel>
Class Inheritance
Imports
java.io.EOFException, .File, .FileInputStream, .IOException, java.net.InetAddress, .InetSocketAddress, .SocketAddress, .SocketTimeoutException, java.nio.ByteBuffer, java.nio.channels.CancelledKeyException, .Channel, .ClosedChannelException, .CompletionHandler, .FileChannel, .NetworkChannel, .SelectionKey, .Selector, .ServerSocketChannel, .SocketChannel, .WritableByteChannel, java.nio.file.Files, .Path, .Paths, java.nio.file.attribute.FileAttribute, .PosixFilePermission, .PosixFilePermissions, java.util.ConcurrentModificationException, .Iterator, .Set, java.util.concurrent.CountDownLatch, .Semaphore, .TimeUnit, java.util.concurrent.atomic.AtomicLong, javax.net.ssl.SSLEngine, org.apache.juli.logging.Log, .LogFactory, org.apache.tomcat.util.ExceptionUtils, org.apache.tomcat.util.collections.SynchronizedQueue, .SynchronizedStack, org.apache.tomcat.util.compat.JreCompat, .JrePlatform, org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState, .Acceptor.AcceptorState, org.apache.tomcat.util.net.jsse.JSSESupport

NIO tailored thread pool, providing the following services:

Todo

Consider using the virtual machine's thread pool.

Authors
Mladen Turk, Remy Maucherat

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public class
NioEndpoint.Poller

Poller class.

public static class
NioEndpoint.PollerEvent

PollerEvent, cacheable object for poller events to avoid GC

public static class
NioEndpoint.SendfileData

SendfileData class.

protected class
NioEndpoint.SocketProcessor

This class is the equivalent of the Worker, but will simply use in an external Executor thread pool.

Field Summary

Modifier and TypeField and Description
private SynchronizedStack<NioEndpoint.PollerEvent>
eventCache

Cache for poller events

private static final Log
private static final Log
private static final Log
private SynchronizedStack<NioChannel>
nioChannels

Bytebuffer cache, each channel holds a set of buffers (two, except for SSL holds four)

public static final int
private NioEndpoint.Poller
poller

The socket poller.

private int
pollerThreadPriority

Priority of the poller thread.

private long
private SocketAddress
private long
private volatile ServerSocketChannel
serverSock

Server socket "pointer".

private volatile CountDownLatch
stopLatch

Stop latch used to wait for poller stop

private String
unixDomainSocketPath

Path for the Unix domain socket, used to create the socket address.

private String
unixDomainSocketPathPermissions

Permissions which will be set on the Unix domain socket if it is created.

private boolean
useInheritedChannel

Use System.inheritableChannel to obtain channel from stdin/stdout.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
bind()

Implements abstract org.apache.tomcat.util.net.AbstractEndpoint.bind.

Initialize the endpoint.

protected SocketProcessorBase<NioChannel>
protected void
destroySocket(SocketChannel
The newly accepted socket
socket
)

Implements abstract org.apache.tomcat.util.net.AbstractEndpoint.destroySocket.

Close the socket.

protected void
doCloseServerSocket()

Implements abstract org.apache.tomcat.util.net.AbstractEndpoint.doCloseServerSocket.

Actually close the server socket but don't perform any other clean-up.

public String
getId()

Overrides org.apache.tomcat.util.net.AbstractEndpoint.getId.

The default behavior is to identify connectors uniquely with address and port.

public int

Returns:

The number of sockets currently in the keep-alive state waiting for the next request to be received on the socket
getKeepAliveCount
()

Number of keep-alive sockets.

protected Log
protected Log
protected SynchronizedStack<NioChannel>
protected NioEndpoint.Poller
public int
public long
protected NetworkChannel
protected CountDownLatch
public String
public String
public boolean
protected void
protected SocketChannel
public void
setPollerThreadPriority(int pollerThreadPriority)

public void
setSelectorTimeout(long timeout)

protected boolean

Returns:

true if the socket was correctly configured and processing may continue, false if the socket needs to be close immediately
setSocketOptions
(SocketChannel
The socket channel
socket
)

Implements abstract org.apache.tomcat.util.net.AbstractEndpoint.setSocketOptions.

Process the specified connection.

protected void
public void
setUnixDomainSocketPath(String unixDomainSocketPath)

public void
setUnixDomainSocketPathPermissions(String unixDomainSocketPathPermissions)

public void
setUseInheritedChannel(boolean useInheritedChannel)

public void
startInternal()

Implements abstract org.apache.tomcat.util.net.AbstractEndpoint.startInternal.

Start the NIO endpoint, creating acceptor, poller threads.

public void
public void
unbind()

Overrides org.apache.tomcat.util.net.AbstractJsseEndpoint.unbind.

Deallocate NIO memory pools, and close server socket.

protected void
unlockAccept()

Overrides org.apache.tomcat.util.net.AbstractEndpoint.unlockAccept.

Unlock the server socket acceptor threads using bogus connections.

Inherited from org.apache.tomcat.util.net.AbstractJsseEndpoint:
createSSLContextcreateSSLEnginegetLocalAddressgetSniParseLimitgetSslImplementationgetSslImplementationNameinitialiseSslsetSniParseLimitsetSslImplementationName