org.apache.tomcat.util.net

## Class NioEndpoint

- java.lang.Object
- - org.apache.tomcat.util.net.AbstractEndpoint<S>
  - - org.apache.tomcat.util.net.AbstractJsseEndpoint<NioChannel>
    - - org.apache.tomcat.util.net.NioEndpoint

-     public class NioEndpoint
      extends AbstractJsseEndpoint<NioChannel>

  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

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected class` | `NioEndpoint.Acceptor` The background thread that listens for incoming TCP/IP connections and hands them off to an appropriate processor.
    `static class` | `NioEndpoint.NioSocketWrapper`
    `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, AbstractEndpoint.Handler<S>`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `OP_REGISTER`

    - ### Fields inherited from class org.apache.tomcat.util.net.AbstractEndpoint

      `acceptors, acceptorThreadCount, acceptorThreadPriority, attributes, internalExecutor, negotiableProtocols, paused, processorCache, running, sm, socketProperties, sslHostConfigs, threadPriority`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `NioEndpoint()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `bind()` Initialize the endpoint.
    `protected AbstractEndpoint.Acceptor` | `createAcceptor()` Hook to allow Endpoints to provide a specific Acceptor implementation.
    `protected SocketProcessorBase<NioChannel>` | `createSocketProcessor(SocketWrapperBase<NioChannel> socketWrapper, SocketEvent event)`
    `boolean` | `getDeferAccept()` Is deferAccept supported?
    `int` | `getKeepAliveCount()` Number of keep-alive sockets.
    `protected Log` | `getLog()`
    `NioEndpoint.Poller` | `getPoller0()` Return an available poller in true round robin fashion.
    `int` | `getPollerThreadCount()`
    `int` | `getPollerThreadPriority()`
    `int` | `getReadBufSize()`
    `NioSelectorPool` | `getSelectorPool()`
    `long` | `getSelectorTimeout()`
    `protected NetworkChannel` | `getServerSocket()`
    `protected CountDownLatch` | `getStopLatch()`
    `int` | `getWriteBufSize()`
    `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)`
    `protected void` | `setStopLatch(CountDownLatch stopLatch)`
    `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.

    - ### Methods inherited from class org.apache.tomcat.util.net.AbstractJsseEndpoint

      `createSSLContext, createSSLEngine, destroySsl, getLocalAddress, getSniParseLimit, getSslConfigType, getSslImplementation, getSslImplementationName, init, initialiseSsl, isAlpnSupported, releaseSSLContext, setSniParseLimit, setSslImplementationName`

    - ### Methods inherited from class org.apache.tomcat.util.net.AbstractEndpoint

      `addNegotiatedProtocol, addSslHostConfig, countDownConnection, countUpOrAwaitConnection, createExecutor, destroy, findSslHostConfigs, getAcceptCount, getAcceptorThreadCount, getAcceptorThreadPriority, getAddress, getAttribute, getBacklog, getBindOnInit, getConnectionCount, getConnectionLinger, getConnectionTimeout, getCurrentThreadCount, getCurrentThreadsBusy, getDaemon, getDefaultSSLHostConfigName, getExecutor, getExecutorTerminationTimeoutMillis, getHandler, getKeepAliveTimeout, getLocalPort, getMaxConnections, getMaxHeaderCount, getMaxKeepAliveRequests, getMaxThreads, getMinSpareThreads, getName, getPort, getProperty, getSocketProperties, getSoLinger, getSoTimeout, getSSLHostConfig, getTcpNoDelay, getThreadPriority, getUseSendfile, handleExceptionWithDelay, hasNegotiableProtocols, initializeConnectionLatch, isPaused, isRunning, isSSLEnabled, pause, processSocket, releaseConnectionLatch, resume, setAcceptCount, setAcceptorThreadCount, setAcceptorThreadPriority, setAddress, setAttribute, setBacklog, setBindOnInit, setConnectionLinger, setConnectionTimeout, setDaemon, setDefaultSSLHostConfigName, setExecutor, setExecutorTerminationTimeoutMillis, setHandler, setKeepAliveTimeout, setMaxConnections, setMaxHeaderCount, setMaxKeepAliveRequests, setMaxThreads, setMinSpareThreads, setName, setPort, setSoLinger, setSoTimeout, setSSLEnabled, setTcpNoDelay, setThreadPriority, setUseSendfile, 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

  - ### Constructor Detail

    - #### NioEndpoint

          public NioEndpoint()

  - ### Method Detail

    - #### setProperty

          public boolean setProperty(String name,
                            String value)

      Generic properties, introspected
      Overrides:
        `setProperty` in class `AbstractEndpoint<NioChannel>`

    - #### setPollerThreadPriority

          public void setPollerThreadPriority(int pollerThreadPriority)

    - #### getPollerThreadPriority

          public int getPollerThreadPriority()

    - #### 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.
      Returns:
        The next poller in sequence

    - #### setSelectorPool

          public void setSelectorPool(NioSelectorPool selectorPool)

    - #### setSocketProperties

          public void setSocketProperties(SocketProperties socketProperties)

    - #### getDeferAccept

          public boolean getDeferAccept()

      Is deferAccept supported?
      Specified by:
        `getDeferAccept` in class `AbstractEndpoint<NioChannel>`

    - #### 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

    - #### bind

          public void bind()
                    throws Exception

      Initialize the endpoint.
      Specified by:
        `bind` in class `AbstractEndpoint<NioChannel>`
      Throws:
        `Exception`

    - #### startInternal

          public void startInternal()
                             throws Exception

      Start the NIO endpoint, creating acceptor, poller threads.
      Specified by:
        `startInternal` in class `AbstractEndpoint<NioChannel>`
      Throws:
        `Exception`

    - #### stopInternal

          public void stopInternal()

      Stop the endpoint. This will cause all processing threads to stop.
      Specified by:
        `stopInternal` in class `AbstractEndpoint<NioChannel>`

    - #### unbind

          public void unbind()
                      throws Exception

      Deallocate NIO memory pools, and close server socket.
      Overrides:
        `unbind` in class `AbstractJsseEndpoint<NioChannel>`
      Throws:
        `Exception`

    - #### getWriteBufSize

          public int getWriteBufSize()

    - #### getReadBufSize

          public int getReadBufSize()

    - #### getSelectorPool

          public NioSelectorPool getSelectorPool()

    - #### 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<NioChannel>`
      Returns:
        the acceptor

    - #### getStopLatch

          protected CountDownLatch getStopLatch()

    - #### setStopLatch

          protected void setStopLatch(CountDownLatch stopLatch)

    - #### setSocketOptions

          protected boolean setSocketOptions(SocketChannel socket)

      Process the specified connection.
      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

    - #### getLog

          protected Log getLog()

      Specified by:
        `getLog` in class `AbstractEndpoint<NioChannel>`

    - #### getServerSocket

          protected NetworkChannel getServerSocket()

      Specified by:
        `getServerSocket` in class `AbstractJsseEndpoint<NioChannel>`

    - #### createSocketProcessor

          protected SocketProcessorBase<NioChannel> createSocketProcessor(SocketWrapperBase<NioChannel> socketWrapper,
                                                              SocketEvent event)

      Specified by:
        `createSocketProcessor` in class `AbstractEndpoint<NioChannel>`

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