Overview | Package | Class | Tree | Deprecated | Index | Help
| Apache Tomcat 7.0.29
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.tomcat.util.net
Class NioEndpoint

    java.lang.Object
      org.apache.tomcat.util.net.AbstractEndpoint
          org.apache.tomcat.util.net.NioEndpoint

    public class NioEndpoint

extends AbstractEndpoint

NIO tailored thread pool, providing the following services:

- Socket acceptor thread
- Socket poller thread
- Worker threads pool

When switching to Java 5, there's an opportunity to use the virtual machine's thread pool.

Author:
  Mladen Turk, Remy Maucherat, Filip Hanik

Nested Class Summary
`protected class` | `NioEndpoint.Acceptor` The background thread that listens for incoming TCP/IP connections and hands them off to an appropriate processor.
`static interface` | `NioEndpoint.Handler` Bare bones interface used for socket processing.
`static class` | `NioEndpoint.KeyAttachment`
`static class` | `NioEndpoint.NioBufferHandler`
`class` | `NioEndpoint.Poller` Poller class.
`static class` | `NioEndpoint.PollerEvent` PollerEvent, cacheable object for poller events to avoid GC
`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.

Nested classes/interfaces inherited from class org.apache.tomcat.util.net.AbstractEndpoint
`AbstractEndpoint.BindState`

Field Summary
`protected ConcurrentLinkedQueue<NioEndpoint.PollerEvent>` | `eventCache` Cache for poller events
`protected NioEndpoint.Handler` | `handler` Handling of accepted sockets.
`protected ConcurrentLinkedQueue<NioEndpoint.KeyAttachment>` | `keyCache` Cache for key attachment objects
`protected ConcurrentLinkedQueue<NioChannel>` | `nioChannels` Bytebuffer cache, each channel holds a set of buffers (two, except for SSL holds four)
`protected int` | `oomParachute` The size of the OOM parachute.
`protected byte[]` | `oomParachuteData` The oom parachute, when an OOM error happens, will release the data, giving the JVM instantly a chunk of data to be able to recover with.
`protected static String` | `oomParachuteMsg` Make sure this string has already been allocated
`static int` | `OP_CALLBACK`
`static int` | `OP_REGISTER`
`protected AtomicInteger` | `pollerRotater`
`protected NioEndpoint.Poller[]` | `pollers` The socket poller.
`protected int` | `pollerThreadCount` Poller thread count.
`protected int` | `pollerThreadPriority` Priority of the poller threads.
`protected ConcurrentLinkedQueue<NioEndpoint.SocketProcessor>` | `processorCache` Cache for SocketProcessor objects
`protected NioSelectorPool` | `selectorPool`
`protected long` | `selectorTimeout`
`protected ServerSocketChannel` | `serverSock` Server socket "pointer".
`protected SSLContext` | `sslContext`
`protected CountDownLatch` | `stopLatch`
`protected boolean` | `useComet` Allow comet request handling.
`protected boolean` | `useSendfile` use send file

Fields inherited from class org.apache.tomcat.util.net.AbstractEndpoint
`acceptors, acceptorThreadCount, acceptorThreadPriority, attributes, internalExecutor, paused, running, sm, socketProperties, threadPriority`

Constructor Summary
`NioEndpoint()`

Method Summary
`void` | `bind()` Initialize the endpoint.
`protected void` | `checkParachute()`
`protected AbstractEndpoint.Acceptor` | `createAcceptor()` Hook to allow Endpoints to provide a specific Acceptor implementation.
`protected SSLEngine` | `createSSLEngine()`
`boolean` | `getDeferAccept()` Is deferAccept supported?
`NioEndpoint.Handler` | `getHandler()`
`int` | `getKeepAliveCount()` Number of keepalive sockets.
`int` | `getLocalPort()` Port in use.
`protected Log` | `getLog()`
`int` | `getOomParachute()`
`byte[]` | `getOomParachuteData()`
`NioEndpoint.Poller` | `getPoller0()` Return an available poller in true round robin fashion
`int` | `getPollerThreadCount()`
`int` | `getPollerThreadPriority()`
`int` | `getReadBufSize()`
`NioSelectorPool` | `getSelectorPool()`
`long` | `getSelectorTimeout()`
`SSLContext` | `getSSLContext()`
`boolean` | `getUseComet()`
`boolean` | `getUseCometTimeout()`
`boolean` | `getUsePolling()`
`boolean` | `getUseSendfile()`
`int` | `getWriteBufSize()`
`protected boolean` | `isWorkerAvailable()` Returns true if a worker thread is available for processing.
`boolean` | `processSocket(NioChannel socket, SocketStatus status, boolean dispatch)`
`protected boolean` | `reclaimParachute(boolean force)`
`protected void` | `releaseCaches()`
`void` | `setHandler(NioEndpoint.Handler handler)`
`void` | `setOomParachute(int oomParachute)`
`void` | `setOomParachuteData(byte[] oomParachuteData)`
`void` | `setPollerThreadCount(int pollerThreadCount)`
`void` | `setPollerThreadPriority(int pollerThreadPriority)`
`boolean` | `setProperty(String name, String value)` Generic properties, introspected
`void` | `setSelectorPool(NioSelectorPool selectorPool)`
`void` | `setSelectorTimeout(long timeout)`
`protected boolean` | `setSocketOptions(SocketChannel socket)` Process the specified connection.
`void` | `setSocketProperties(SocketProperties socketProperties)`
`void` | `setSSLContext(SSLContext c)`
`void` | `setUseComet(boolean useComet)`
`void` | `setUseSendfile(boolean useSendfile)`
`void` | `startInternal()` Start the NIO endpoint, creating acceptor, poller threads.
`void` | `stopInternal()` Stop the endpoint.
`void` | `unbind()` Deallocate NIO memory pools, and close server socket.
`KeyManager[]` | `wrap(KeyManager[] managers)`

Methods inherited from class org.apache.tomcat.util.net.AbstractEndpoint
`adjustRelativePath, countDownConnection, countUpOrAwaitConnection, createExecutor, destroy, getAcceptorThreadCount, getAcceptorThreadPriority, getAddress, getAlgorithm, getAllowUnsafeLegacyRenegotiation, getAttribute, getBacklog, getBindOnInit, getCiphers, getCiphersArray, getClientAuth, getConnectionCount, getCrlFile, getCurrentThreadCount, getCurrentThreadsBusy, getDaemon, getExecutor, getKeepAliveTimeout, getKeyAlias, getKeyPass, getKeystoreFile, getKeystorePass, getKeystoreProvider, getKeystoreType, getMaxConnections, getMaxHeaderCount, getMaxKeepAliveRequests, getMaxThreads, getMaxThreadsExecutor, getMinSpareThreads, getName, getPort, getProperty, getSessionCacheSize, getSessionTimeout, getSocketProperties, getSoLinger, getSoTimeout, getSslEnabledProtocolsArray, getSslProtocol, getTcpNoDelay, getThreadPriority, getTrustManagerClassName, getTrustMaxCertLength, getTruststoreAlgorithm, getTruststoreFile, getTruststorePass, getTruststoreProvider, getTruststoreType, handleExceptionWithDelay, init, initializeConnectionLatch, isPaused, isRunning, isSSLEnabled, pause, releaseConnectionLatch, resume, setAcceptorThreadCount, setAcceptorThreadPriority, setAddress, setAlgorithm, setAllowUnsafeLegacyRenegotiation, setAttribute, setBacklog, setBindOnInit, setCiphers, setClientAuth, setCrlFile, setDaemon, setExecutor, setKeepAliveTimeout, setKeyAlias, setKeyPass, setKeystoreFile, setKeystorePass, setKeystoreProvider, setKeystoreType, setMaxConnections, setMaxHeaderCount, setMaxKeepAliveRequests, setMaxThreads, setMinSpareThreads, setName, setPort, setSessionCacheSize, setSessionTimeout, setSoLinger, setSoTimeout, setSSLEnabled, setSslEnabledProtocols, setSslProtocol, setTcpNoDelay, setThreadPriority, setTrustManagerClassName, setTrustMaxCertLength, setTruststoreAlgorithm, setTruststoreFile, setTruststorePass, setTruststoreProvider, setTruststoreType, shutdownExecutor, start, startAcceptorThreads, stop, unlockAccept`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### OP_REGISTER

    public static final int OP_REGISTER

See Also:
  Constant Field Values

### OP_CALLBACK

    public static final int OP_CALLBACK

See Also:
  Constant Field Values

### selectorPool

    protected NioSelectorPool selectorPool

### serverSock

    protected ServerSocketChannel serverSock

  Server socket "pointer".

### useSendfile

    protected boolean useSendfile

  use send file

### oomParachute

    protected int oomParachute

  The size of the OOM parachute.

### oomParachuteData

    protected byte[] oomParachuteData

  The oom parachute, when an OOM error happens, will release the data, giving the JVM instantly a chunk of data to be able to recover with.

### oomParachuteMsg

    protected static final String oomParachuteMsg

  Make sure this string has already been allocated

  See Also:
    Constant Field Values

### stopLatch

    protected volatile CountDownLatch stopLatch

### processorCache

    protected ConcurrentLinkedQueue<NioEndpoint.SocketProcessor> processorCache

  Cache for SocketProcessor objects

### keyCache

    protected ConcurrentLinkedQueue<NioEndpoint.KeyAttachment> keyCache

  Cache for key attachment objects

### eventCache

    protected ConcurrentLinkedQueue<NioEndpoint.PollerEvent> eventCache

  Cache for poller events

### nioChannels

    protected ConcurrentLinkedQueue<NioChannel> nioChannels

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

### pollerThreadPriority

    protected int pollerThreadPriority

  Priority of the poller threads.

### handler

    protected NioEndpoint.Handler handler

  Handling of accepted sockets.

### useComet

    protected boolean useComet

  Allow comet request handling.

### pollerThreadCount

    protected int pollerThreadCount

  Poller thread count.

### selectorTimeout

    protected long selectorTimeout

### pollers

    protected NioEndpoint.Poller[] pollers

  The socket poller.

### pollerRotater

    protected AtomicInteger pollerRotater

### sslContext

    protected SSLContext sslContext

Constructor Detail

### NioEndpoint

    public NioEndpoint()

Method Detail

### setProperty

    public boolean setProperty(String name,
                               String value)

  Generic properties, introspected

  Overrides:
    `setProperty` in class `AbstractEndpoint`

### setPollerThreadPriority

    public void setPollerThreadPriority(int pollerThreadPriority)

### getPollerThreadPriority

    public int getPollerThreadPriority()

### setHandler

    public void setHandler(NioEndpoint.Handler handler)

### getHandler

    public NioEndpoint.Handler getHandler()

### setUseComet

    public void setUseComet(boolean useComet)

### getUseComet

    public boolean getUseComet()

  Specified by:
    `getUseComet` in class `AbstractEndpoint`

### getUseCometTimeout

    public boolean getUseCometTimeout()

  Specified by:
    `getUseCometTimeout` in class `AbstractEndpoint`

### getUsePolling

    public boolean getUsePolling()

  Specified by:
    `getUsePolling` in class `AbstractEndpoint`

### setPollerThreadCount

    public void setPollerThreadCount(int pollerThreadCount)

### getPollerThreadCount

    public int getPollerThreadCount()

### setSelectorTimeout

    public void setSelectorTimeout(long timeout)

### getSelectorTimeout

    public long getSelectorTimeout()

### getPoller0

    public NioEndpoint.Poller getPoller0()

  Return an available poller in true round robin fashion

### setSelectorPool

    public void setSelectorPool(NioSelectorPool selectorPool)

### setSocketProperties

    public void setSocketProperties(SocketProperties socketProperties)

### setUseSendfile

    public void setUseSendfile(boolean useSendfile)

### getDeferAccept

    public boolean getDeferAccept()

  Is deferAccept supported?

  Specified by:
    `getDeferAccept` in class `AbstractEndpoint`

### setOomParachute

    public void setOomParachute(int oomParachute)

### setOomParachuteData

    public void setOomParachuteData(byte[] oomParachuteData)

### getSSLContext

    public SSLContext getSSLContext()

### setSSLContext

    public void setSSLContext(SSLContext c)

### getLocalPort

    public int getLocalPort()

  Port in use.

  Specified by:
    `getLocalPort` in class `AbstractEndpoint`

### checkParachute

    protected void checkParachute()

### reclaimParachute

    protected boolean reclaimParachute(boolean force)

### releaseCaches

    protected void releaseCaches()

### getKeepAliveCount

    public int getKeepAliveCount()

  Number of keepalive sockets.

### bind

    public void bind()
              throws Exception

  Initialize the endpoint.

  Specified by:
    `bind` in class `AbstractEndpoint`
  Throws:
    `Exception`

### wrap

    public KeyManager[] wrap(KeyManager[] managers)

### startInternal

    public void startInternal()
                       throws Exception

  Start the NIO endpoint, creating acceptor, poller threads.

  Specified by:
    `startInternal` in class `AbstractEndpoint`
  Throws:
    `Exception`

### stopInternal

    public void stopInternal()

  Stop the endpoint. This will cause all processing threads to stop.

  Specified by:
    `stopInternal` in class `AbstractEndpoint`

### unbind

    public void unbind()
                throws Exception

  Deallocate NIO memory pools, and close server socket.

  Specified by:
    `unbind` in class `AbstractEndpoint`
  Throws:
    `Exception`

### getWriteBufSize

    public int getWriteBufSize()

### getReadBufSize

    public int getReadBufSize()

### getSelectorPool

    public NioSelectorPool getSelectorPool()

### getUseSendfile

    public boolean getUseSendfile()

  Specified by:
    `getUseSendfile` in class `AbstractEndpoint`

### getOomParachute

    public int getOomParachute()

### getOomParachuteData

    public byte[] getOomParachuteData()

### createAcceptor

    protected AbstractEndpoint.Acceptor createAcceptor()

  Description copied from class: `AbstractEndpoint`
  Hook to allow Endpoints to provide a specific Acceptor implementation.

  Specified by:
    `createAcceptor` in class `AbstractEndpoint`

### setSocketOptions

    protected boolean setSocketOptions(SocketChannel socket)

  Process the specified connection.

### createSSLEngine

    protected SSLEngine createSSLEngine()

### isWorkerAvailable

    protected boolean isWorkerAvailable()

  Returns true if a worker thread is available for processing.

  Returns:
    boolean

### processSocket

    public boolean processSocket(NioChannel socket,
                                 SocketStatus status,
                                 boolean dispatch)

### getLog

    protected Log getLog()

  Specified by:
    `getLog` in class `AbstractEndpoint`

Overview | Package | Class | Tree | Deprecated | Index | Help
| Apache Tomcat 7.0.29
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.