AprEndpoint (Apache Tomcat 8.5.57 API Documentation)

org.apache.tomcat.util.net

## Class AprEndpoint

- java.lang.Object
- - org.apache.tomcat.util.net.AbstractEndpoint<Long>
  - - org.apache.tomcat.util.net.AprEndpoint

- All Implemented Interfaces:
    SSLContext.SNICallBack

      public class AprEndpoint
      extends AbstractEndpoint<Long>
      implements SSLContext.SNICallBack

  APR tailored thread pool, providing the following services:
  - Socket acceptor thread
  - Socket poller thread
  - Sendfile 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` | `AprEndpoint.Acceptor` The background thread that listens for incoming TCP/IP connections and hands them off to an appropriate processor.
    `static class` | `AprEndpoint.AprSocketWrapper`
    `class` | `AprEndpoint.Poller`
    `class` | `AprEndpoint.Sendfile`
    `static class` | `AprEndpoint.SendfileData` SendfileData class.
    `static class` | `AprEndpoint.SocketInfo`
    `static class` | `AprEndpoint.SocketList`
    `protected class` | `AprEndpoint.SocketProcessor` This class is the equivalent of the Worker, but will simply use in an external Executor thread pool.
    `static class` | `AprEndpoint.SocketTimeouts`
    `protected class` | `AprEndpoint.SocketWithOptionsProcessor` 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
    --- | ---
    `protected boolean` | `deferAccept` Defer accept.
    `protected AprEndpoint.Poller` | `poller` The socket poller.
    `protected int` | `pollTime` Poll interval, in microseconds.
    `protected long` | `rootPool` Root APR memory pool.
    `protected AprEndpoint.Sendfile` | `sendfile` The static file sender.
    `protected int` | `sendfileSize` Size of the sendfile (= concurrent files which can be served).
    `protected long` | `serverSock` Server socket "pointer".
    `protected long` | `serverSockPool` APR memory pool for the server socket.
    `protected long` | `sslContext` SSL context.

    - ### 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
    `AprEndpoint()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected long` | `allocatePoller(int size, long pool, int timeout)` Allocate a new poller of the specified size.
    `void` | `bind()` Initialize the endpoint.
    `protected AbstractEndpoint.Acceptor` | `createAcceptor()` Hook to allow Endpoints to provide a specific Acceptor implementation.
    `protected SocketProcessorBase<Long>` | `createSocketProcessor(SocketWrapperBase<Long> socketWrapper, SocketEvent event)`
    `protected void` | `createSSLContext(SSLHostConfig sslHostConfig)` Create the SSLContextfor the the given SSLHostConfig.
    `protected void` | `doCloseServerSocket()` Actually close the server socket but don't perform any other clean-up.
    `boolean` | `getDeferAccept()`
    `boolean` | `getIpv6v6only()`
    `int` | `getKeepAliveCount()` Obtain the number of kept alive sockets.
    `InetSocketAddress` | `getLocalAddress()` Obtain the network address the server socket is bound to.
    `protected Log` | `getLog()`
    `AprEndpoint.Poller` | `getPoller()`
    `int` | `getPollTime()`
    `AprEndpoint.Sendfile` | `getSendfile()`
    `int` | `getSendfileCount()` Obtain the number of sendfile sockets.
    `int` | `getSendfileSize()`
    `long` | `getSslContext(String sniHostName)` This callback is made during the TLS handshake when the client uses the SNI extension to request a specific TLS host.
    `boolean` | `isAlpnSupported()` Identifies if the endpoint supports ALPN.
    `protected boolean` | `processSocket(long socket, SocketEvent event)` Process the given socket.
    `protected boolean` | `processSocketWithOptions(long socket)` Process given socket.
    `void` | `setDeferAccept(boolean deferAccept)`
    `void` | `setIpv6v6only(boolean ipv6v6only)`
    `void` | `setMaxConnections(int maxConnections)` This endpoint does not support `-1` for unlimited connections, nor does it support setting this attribute while the endpoint is running.
    `void` | `setPollTime(int pollTime)`
    `void` | `setSendfileSize(int sendfileSize)`
    `protected boolean` | `setSocketOptions(SocketWrapperBase<Long> socketWrapper)` Process the specified connection.
    `void` | `setUseSendfile(boolean useSendfile)`
    `void` | `startInternal()` Start the APR endpoint, creating acceptor, poller and sendfile threads.
    `void` | `stopInternal()` Stop the endpoint.
    `void` | `unbind()` Deallocate APR memory pools, and close server socket.

    - ### 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, init, 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, setMaxHeaderCount, setMaxKeepAliveRequests, setMaxThreads, setMinSpareThreads, setName, setPort, setProperty, setSoLinger, setSoTimeout, setSSLEnabled, setTcpNoDelay, setThreadPriority, setUseAsyncIO, 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

    - #### rootPool

          protected long rootPool

      Root APR memory pool.

    - #### serverSock

          protected volatile long serverSock

      Server socket "pointer".

    - #### serverSockPool

          protected long serverSockPool

      APR memory pool for the server socket.

    - #### sslContext

          protected long sslContext

      SSL context.

    - #### deferAccept

          protected boolean deferAccept

      Defer accept.

    - #### sendfileSize

          protected int sendfileSize

      Size of the sendfile (= concurrent files which can be served).

    - #### pollTime

          protected int pollTime

      Poll interval, in microseconds. The smaller the value, the more CPU the poller will use, but the more responsive to activity it will be.

    - #### poller

          protected AprEndpoint.Poller poller

      The socket poller.

    - #### sendfile

          protected AprEndpoint.Sendfile sendfile

      The static file sender.

  - ### Constructor Detail

    - #### AprEndpoint

          public AprEndpoint()

  - ### Method Detail

    - #### setDeferAccept

          public void setDeferAccept(boolean deferAccept)

    - #### getDeferAccept

          public boolean getDeferAccept()

      Specified by:
        `getDeferAccept` in class `AbstractEndpoint<Long>`

    - #### setIpv6v6only

          public void setIpv6v6only(boolean ipv6v6only)

    - #### getIpv6v6only

          public boolean getIpv6v6only()

    - #### setSendfileSize

          public void setSendfileSize(int sendfileSize)

    - #### getSendfileSize

          public int getSendfileSize()

    - #### getPollTime

          public int getPollTime()

    - #### setPollTime

          public void setPollTime(int pollTime)

    - #### setUseSendfile

          public void setUseSendfile(boolean useSendfile)

      Overrides:
        `setUseSendfile` in class `AbstractEndpoint<Long>`

    - #### getPoller

          public AprEndpoint.Poller getPoller()

    - #### getSendfile

          public AprEndpoint.Sendfile getSendfile()

    - #### getLocalAddress

          public InetSocketAddress getLocalAddress()
                                            throws IOException

      Description copied from class: `AbstractEndpoint`
      Obtain the network address the server socket is bound to. This primarily exists to enable the correct address to be used when unlocking the server socket since it removes the guess-work involved if no address is specifically set.
      Specified by:
        `getLocalAddress` in class `AbstractEndpoint<Long>`
      Returns:
        The network address that the server socket is listening on or null if the server socket is not currently bound.
      Throws:
        `IOException` - If there is a problem determining the currently bound socket

    - #### setMaxConnections

          public void setMaxConnections(int maxConnections)

      This endpoint does not support `-1` for unlimited connections, nor does it support setting this attribute while the endpoint is running.
      Overrides:
        `setMaxConnections` in class `AbstractEndpoint<Long>`

    - #### getKeepAliveCount

          public int getKeepAliveCount()

      Obtain the number of kept alive sockets.
      Returns:
        The number of open sockets currently managed by the Poller

    - #### getSendfileCount

          public int getSendfileCount()

      Obtain the number of sendfile sockets.
      Returns:
        The number of sockets currently managed by the Sendfile poller.

    - #### bind

          public void bind()
                    throws Exception

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

    - #### createSSLContext

          protected void createSSLContext(SSLHostConfig sslHostConfig)
                                   throws Exception

      Description copied from class: `AbstractEndpoint`
      Create the SSLContextfor the the given SSLHostConfig.
      Specified by:
        `createSSLContext` in class `AbstractEndpoint<Long>`
      Parameters:
        `sslHostConfig` - The SSLHostConfig for which the SSLContext should be created
      Throws:
        `Exception` - If the SSLContext cannot be created for the given SSLHostConfig

    - #### getSslContext

          public long getSslContext(String sniHostName)

      Description copied from interface: `SSLContext.SNICallBack`
      This callback is made during the TLS handshake when the client uses the SNI extension to request a specific TLS host.
      Specified by:
        `getSslContext` in interface `SSLContext.SNICallBack`
      Parameters:
        `sniHostName` - The host name requested by the client
      Returns:
        The Java representation of the pointer to the OpenSSL SSLContext to use for the given host or zero if no SSLContext could be identified

    - #### isAlpnSupported

          public boolean isAlpnSupported()

      Description copied from class: `AbstractEndpoint`
      Identifies if the endpoint supports ALPN. Note that a return value of `true` implies that `AbstractEndpoint.isSSLEnabled()` will also return `true`.
      Specified by:
        `isAlpnSupported` in class `AbstractEndpoint<Long>`
      Returns:
        `true` if the endpoint supports ALPN in its current configuration, otherwise `false`.

    - #### startInternal

          public void startInternal()
                             throws Exception

      Start the APR endpoint, creating acceptor, poller and sendfile threads.
      Specified by:
        `startInternal` in class `AbstractEndpoint<Long>`
      Throws:
        `Exception`

    - #### stopInternal

          public void stopInternal()

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

    - #### unbind

          public void unbind()
                      throws Exception

      Deallocate APR memory pools, and close server socket.
      Specified by:
        `unbind` in class `AbstractEndpoint<Long>`
      Throws:
        `Exception`

    - #### doCloseServerSocket

          protected void doCloseServerSocket()

      Description copied from class: `AbstractEndpoint`
      Actually close the server socket but don't perform any other clean-up.
      Specified by:
        `doCloseServerSocket` in class `AbstractEndpoint<Long>`

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

    - #### setSocketOptions

          protected boolean setSocketOptions(SocketWrapperBase<Long> socketWrapper)

      Process the specified connection.
      Parameters:
        `socketWrapper` - The socket wrapper
      Returns:
        `true` if the socket was correctly configured and processing may continue, `false` if the socket needs to be close immediately

    - #### allocatePoller

          protected long allocatePoller(int size,
                            long pool,
                            int timeout)

      Allocate a new poller of the specified size.
      Parameters:
        `size` - The size
        `pool` - The pool from which the poller will be allocated
        `timeout` - The timeout
      Returns:
        the poller pointer

    - #### processSocketWithOptions

          protected boolean processSocketWithOptions(long socket)

      Process given socket. This is called when the socket has been accepted.
      Parameters:
        `socket` - The socket
      Returns:
        `true` if the socket was correctly configured and processing may continue, `false` if the socket needs to be close immediately

    - #### processSocket

          protected boolean processSocket(long socket,
                              SocketEvent event)

      Process the given socket. Typically keep alive or upgraded protocol.
      Parameters:
        `socket` - The socket to process
        `event` - The event to process
      Returns:
        `true` if the processing completed normally otherwise `false` which indicates an error occurred and that the socket should be closed

    - #### createSocketProcessor

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

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

    - #### getLog

          protected Log getLog()

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

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