NioEndpoint (Apache Tomcat 8.5.57 API Documentation)

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)`
    `protected void` | `doCloseServerSocket()` Actually close the server socket but don't perform any other clean-up.
    `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()`
    `boolean` | `getUseInheritedChannel()`
    `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` | `setUseInheritedChannel(boolean useInheritedChannel)`
    `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, getLocalAddress, getSniParseLimit, getSslImplementation, getSslImplementationName, init, initialiseSsl, isAlpnSupported, setSniParseLimit, setSslImplementationName`

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

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

    - #### setUseInheritedChannel

          public void setUseInheritedChannel(boolean useInheritedChannel)

    - #### getUseInheritedChannel

          public boolean getUseInheritedChannel()

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

    - #### doCloseServerSocket

          protected void doCloseServerSocket()
                                      throws IOException

      Description copied from class: `AbstractEndpoint`
      Actually close the server socket but don't perform any other clean-up.
      Specified by:
        `doCloseServerSocket` in class `AbstractEndpoint<NioChannel>`
      Throws:
        `IOException` - If an error occurs closing the socket

    - #### 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-2020 Apache Software Foundation. All Rights Reserved.