Nio2Endpoint (Apache Tomcat 9.0.22 API Documentation)

org.apache.tomcat.util.net

## Class Nio2Endpoint

- java.lang.Object
- - org.apache.tomcat.util.net.AbstractEndpoint<S,U>
  - - org.apache.tomcat.util.net.AbstractJsseEndpoint<Nio2Channel,java.nio.channels.AsynchronousSocketChannel>
    - - org.apache.tomcat.util.net.Nio2Endpoint

-     public class Nio2Endpoint
      extends AbstractJsseEndpoint<Nio2Channel,java.nio.channels.AsynchronousSocketChannel>

  NIO2 endpoint.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected class` | `Nio2Endpoint.Nio2Acceptor`
    `static class` | `Nio2Endpoint.Nio2SocketWrapper`
    `static class` | `Nio2Endpoint.SendfileData` SendfileData class.
    `protected class` | `Nio2Endpoint.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 inherited from class org.apache.tomcat.util.net.AbstractEndpoint

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

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Nio2Endpoint()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `bind()` Initialize the endpoint.
    `protected void` | `closeSocket(java.nio.channels.AsynchronousSocketChannel socket)` Close the socket when the connection has to be immediately closed when an error occurs while configuring the accepted socket, allocating a wrapper for the socket, or trying to dispatch it for processing.
    `protected SocketProcessorBase<Nio2Channel>` | `createSocketProcessor(SocketWrapperBase<Nio2Channel> socketWrapper, SocketEvent event)`
    `protected void` | `doCloseServerSocket()` Actually close the server socket but don't perform any other clean-up.
    `static void` | `endInline()`
    `boolean` | `getDeferAccept()` Is deferAccept supported?
    `int` | `getKeepAliveCount()` Number of keep-alive sockets.
    `protected Log` | `getLog()`
    `protected SynchronizedStack<Nio2Channel>` | `getNioChannels()`
    `protected java.nio.channels.NetworkChannel` | `getServerSocket()`
    `static boolean` | `isInline()`
    `void` | `resume()` Resume the endpoint, which will make it start accepting new connections again.
    `protected java.nio.channels.AsynchronousSocketChannel` | `serverSocketAccept()`
    `protected boolean` | `setSocketOptions(java.nio.channels.AsynchronousSocketChannel socket)` Process the specified connection.
    `void` | `shutdownExecutor()`
    `protected void` | `startAcceptorThread()`
    `static void` | `startInline()`
    `void` | `startInternal()` Start the NIO2 endpoint, creating acceptor.
    `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, initialiseSsl, isAlpnSupported, setSniParseLimit, setSslImplementationName`

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

      `addNegotiatedProtocol, addSslHostConfig, addSslHostConfig, closeServerSocketGraceful, countDownConnection, countUpOrAwaitConnection, createExecutor, destroy, destroySocket, destroySsl, findSslHostConfigs, getAcceptCount, getAcceptorThreadCount, getAcceptorThreadPriority, getAddress, getAttribute, getBindOnInit, getConnectionCount, getConnectionLinger, getConnectionTimeout, getCurrentThreadCount, getCurrentThreadsBusy, getDaemon, getDefaultSSLHostConfigName, getDomain, getExecutor, getExecutorTerminationTimeoutMillis, getHandler, getKeepAliveTimeout, getLocalPort, getMaxConnections, getMaxKeepAliveRequests, getMaxThreads, getMinSpareThreads, getName, getPort, getPortOffset, getPortWithOffset, getProperty, getSocketProperties, getSSLHostConfig, getTcpNoDelay, getThreadPriority, getUseAsyncIO, getUseSendfile, getUtilityExecutor, hasNegotiableProtocols, init, initializeConnectionLatch, isPaused, isRunning, isSSLEnabled, pause, processSocket, releaseSSLContext, reloadSslHostConfig, reloadSslHostConfigs, removeSslHostConfig, setAcceptCount, setAcceptorThreadCount, setAcceptorThreadPriority, setAddress, setAttribute, setBindOnInit, setConnectionLinger, setConnectionTimeout, setDaemon, setDefaultSSLHostConfigName, setDomain, setExecutor, setExecutorTerminationTimeoutMillis, setHandler, setKeepAliveTimeout, setMaxConnections, setMaxKeepAliveRequests, setMaxThreads, setMinSpareThreads, setName, setPort, setPortOffset, setProperty, setSSLEnabled, setTcpNoDelay, setThreadPriority, setUseAsyncIO, setUseSendfile, setUtilityExecutor, start, stop, toTimeout`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Nio2Endpoint

          public Nio2Endpoint()

  - ### Method Detail

    - #### getDeferAccept

          public boolean getDeferAccept()

      Is deferAccept supported?
      Specified by:
        `getDeferAccept` in class `AbstractEndpoint<Nio2Channel,java.nio.channels.AsynchronousSocketChannel>`

    - #### getKeepAliveCount

          public int getKeepAliveCount()

      Number of keep-alive sockets.
      Returns:
        Always returns -1.

    - #### bind

          public void bind()
                    throws java.lang.Exception

      Initialize the endpoint.
      Specified by:
        `bind` in class `AbstractEndpoint<Nio2Channel,java.nio.channels.AsynchronousSocketChannel>`
      Throws:
        `java.lang.Exception`

    - #### startInternal

          public void startInternal()
                             throws java.lang.Exception

      Start the NIO2 endpoint, creating acceptor.
      Specified by:
        `startInternal` in class `AbstractEndpoint<Nio2Channel,java.nio.channels.AsynchronousSocketChannel>`
      Throws:
        `java.lang.Exception`

    - #### startAcceptorThread

          protected void startAcceptorThread()

      Overrides:
        `startAcceptorThread` in class `AbstractEndpoint<Nio2Channel,java.nio.channels.AsynchronousSocketChannel>`

    - #### resume

          public void resume()

      Description copied from class: `AbstractEndpoint`
      Resume the endpoint, which will make it start accepting new connections again.
      Overrides:
        `resume` in class `AbstractEndpoint<Nio2Channel,java.nio.channels.AsynchronousSocketChannel>`

    - #### stopInternal

          public void stopInternal()

      Stop the endpoint. This will cause all processing threads to stop.
      Specified by:
        `stopInternal` in class `AbstractEndpoint<Nio2Channel,java.nio.channels.AsynchronousSocketChannel>`

    - #### unbind

          public void unbind()
                      throws java.lang.Exception

      Deallocate NIO memory pools, and close server socket.
      Overrides:
        `unbind` in class `AbstractJsseEndpoint<Nio2Channel,java.nio.channels.AsynchronousSocketChannel>`
      Throws:
        `java.lang.Exception`

    - #### doCloseServerSocket

          protected void doCloseServerSocket()
                                      throws java.io.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<Nio2Channel,java.nio.channels.AsynchronousSocketChannel>`
      Throws:
        `java.io.IOException` - If an error occurs closing the socket

    - #### shutdownExecutor

          public void shutdownExecutor()

      Overrides:
        `shutdownExecutor` in class `AbstractEndpoint<Nio2Channel,java.nio.channels.AsynchronousSocketChannel>`

    - #### setSocketOptions

          protected boolean setSocketOptions(java.nio.channels.AsynchronousSocketChannel socket)

      Process the specified connection.
      Specified by:
        `setSocketOptions` in class `AbstractEndpoint<Nio2Channel,java.nio.channels.AsynchronousSocketChannel>`
      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

    - #### closeSocket

          protected void closeSocket(java.nio.channels.AsynchronousSocketChannel socket)

      Description copied from class: `AbstractEndpoint`
      Close the socket when the connection has to be immediately closed when an error occurs while configuring the accepted socket, allocating a wrapper for the socket, or trying to dispatch it for processing.
      Specified by:
        `closeSocket` in class `AbstractEndpoint<Nio2Channel,java.nio.channels.AsynchronousSocketChannel>`
      Parameters:
        `socket` - The newly accepted socket

    - #### getNioChannels

          protected SynchronizedStack<Nio2Channel> getNioChannels()

    - #### getServerSocket

          protected java.nio.channels.NetworkChannel getServerSocket()

      Specified by:
        `getServerSocket` in class `AbstractJsseEndpoint<Nio2Channel,java.nio.channels.AsynchronousSocketChannel>`

    - #### serverSocketAccept

          protected java.nio.channels.AsynchronousSocketChannel serverSocketAccept()
                                                                            throws java.lang.Exception

      Specified by:
        `serverSocketAccept` in class `AbstractEndpoint<Nio2Channel,java.nio.channels.AsynchronousSocketChannel>`
      Throws:
        `java.lang.Exception`

    - #### getLog

          protected Log getLog()

      Specified by:
        `getLog` in class `AbstractEndpoint<Nio2Channel,java.nio.channels.AsynchronousSocketChannel>`

    - #### createSocketProcessor

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

      Specified by:
        `createSocketProcessor` in class `AbstractEndpoint<Nio2Channel,java.nio.channels.AsynchronousSocketChannel>`

    - #### startInline

          public static void startInline()

    - #### endInline

          public static void endInline()

    - #### isInline

          public static boolean isInline()

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