AprEndpoint (Apache Tomcat 7.0.104 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

-     public class AprEndpoint
      extends AbstractEndpoint<Long>

  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.
    `protected class` | `AprEndpoint.AsyncTimeout` Async timeout thread
    `static interface` | `AprEndpoint.Handler` Bare bones interface used for socket processing.
    `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`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected AprEndpoint.AsyncTimeout` | `asyncTimeout` The socket poller.
    `protected boolean` | `deferAccept` Defer accept.
    `protected AprEndpoint.Handler` | `handler` Handling of accepted sockets.
    `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 int` | `sendfileThreadCount` Sendfile thread count.
    `protected long` | `serverSock` Server socket "pointer".
    `protected long` | `serverSockPool` APR memory pool for the server socket.
    `protected String` | `SSLCACertificateFile` SSL CA certificate file.
    `protected String` | `SSLCACertificatePath` SSL CA certificate path.
    `protected String` | `SSLCARevocationFile` SSL CA revocation file.
    `protected String` | `SSLCARevocationPath` SSL CA revocation path.
    `protected String` | `SSLCertificateChainFile` SSL certificate chain file.
    `protected String` | `SSLCertificateFile` SSL certificate file.
    `protected String` | `SSLCertificateKeyFile` SSL certificate key file.
    `protected String` | `SSLCipherSuite` SSL cipher suite.
    `protected long` | `sslContext` SSL context.
    `protected boolean` | `SSLDisableCompression` Disables compression of the SSL stream.
    `protected boolean` | `SSLHonorCipherOrder`
    `protected boolean` | `SSLInsecureRenegotiation` SSL allow insecure renegotiation for the the client that does not support the secure renegotiation.
    `protected String` | `SSLPassword` SSL password (if a cert is encrypted, and no password has been provided, a callback will ask for a password).
    `protected String` | `SSLProtocol` SSL protocols.
    `protected String` | `SSLVerifyClient` SSL verify client.
    `protected int` | `SSLVerifyDepth` SSL verify depth.
    `protected boolean` | `useComet` Allow comet request handling.
    `protected boolean` | `useSendfile` Use sendfile for sending static files.
    `protected ConcurrentLinkedQueue<SocketWrapper<Long>>` | `waitingRequests`

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

      `acceptors, acceptorThreadCount, acceptorThreadPriority, attributes, internalExecutor, paused, running, sm, socketProperties, 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.
    `AprEndpoint.AsyncTimeout` | `getAsyncTimeout()`
    `boolean` | `getDeferAccept()`
    `AprEndpoint.Handler` | `getHandler()`
    `int` | `getKeepAliveCount()` Obtain the number of kept alive sockets.
    `int` | `getLocalPort()` Port in use.
    `protected Log` | `getLog()`
    `AprEndpoint.Poller` | `getPoller()`
    `int` | `getPollTime()`
    `AprEndpoint.Sendfile` | `getSendfile()`
    `int` | `getSendfileCount()` Obtain the number of sendfile sockets.
    `int` | `getSendfileSize()`
    `int` | `getSendfileThreadCount()`
    `String` | `getSSLCACertificateFile()`
    `String` | `getSSLCACertificatePath()`
    `String` | `getSSLCARevocationFile()`
    `String` | `getSSLCARevocationPath()`
    `String` | `getSSLCertificateChainFile()`
    `String` | `getSSLCertificateFile()`
    `String` | `getSSLCertificateKeyFile()`
    `String` | `getSSLCipherSuite()`
    `boolean` | `getSSLDisableCompression()`
    `boolean` | `getSSLHonorCipherOrder()`
    `boolean` | `getSSLInsecureRenegotiation()`
    `String` | `getSSLPassword()`
    `String` | `getSSLProtocol()`
    `protected static Set<String>` | `getSslProtocolAll()`
    `String` | `getSSLVerifyClient()`
    `int` | `getSSLVerifyDepth()`
    `boolean` | `getUseComet()`
    `boolean` | `getUseCometTimeout()`
    `boolean` | `getUsePolling()`
    `boolean` | `getUseSendfile()`
    `boolean` | `processSocket(long socket, SocketStatus status)` Process given socket.
    `void` | `processSocketAsync(SocketWrapper<Long> socket, SocketStatus status)`
    `protected boolean` | `processSocketWithOptions(long socket)` Process given socket.
    `void` | `removeWaitingRequest(SocketWrapper<Long> socketWrapper)`
    `void` | `setDeferAccept(boolean deferAccept)`
    `void` | `setHandler(AprEndpoint.Handler handler)`
    `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)`
    `void` | `setSendfileThreadCount(int sendfileThreadCount)`
    `protected boolean` | `setSocketOptions(long socket)` Process the specified connection.
    `void` | `setSSLCACertificateFile(String SSLCACertificateFile)`
    `void` | `setSSLCACertificatePath(String SSLCACertificatePath)`
    `void` | `setSSLCARevocationFile(String SSLCARevocationFile)`
    `void` | `setSSLCARevocationPath(String SSLCARevocationPath)`
    `void` | `setSSLCertificateChainFile(String SSLCertificateChainFile)`
    `void` | `setSSLCertificateFile(String SSLCertificateFile)`
    `void` | `setSSLCertificateKeyFile(String SSLCertificateKeyFile)`
    `void` | `setSSLCipherSuite(String SSLCipherSuite)`
    `void` | `setSSLDisableCompression(boolean SSLDisableCompression)` Set to `true` to disable SSL compression.
    `void` | `setSSLHonorCipherOrder(boolean SSLHonorCipherOrder)` Set to `true` to enforce the server's cipher order instead of the default which is to allow the client to choose a preferred cipher.
    `void` | `setSSLInsecureRenegotiation(boolean SSLInsecureRenegotiation)`
    `void` | `setSSLPassword(String SSLPassword)`
    `void` | `setSSLProtocol(String SSLProtocol)`
    `void` | `setSSLVerifyClient(String SSLVerifyClient)`
    `void` | `setSSLVerifyDepth(int SSLVerifyDepth)`
    `void` | `setUseComet(boolean useComet)`
    `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

      `configureUseServerCipherSuitesOrder, countDownConnection, countUpOrAwaitConnection, createExecutor, destroy, getAcceptorThreadCount, getAcceptorThreadPriority, getAddress, getAlgorithm, getAllowUnsafeLegacyRenegotiation, getAttribute, getBacklog, getBindOnInit, getCiphers, getClientAuth, getConnectionCount, getCrlFile, getCurrentThreadCount, getCurrentThreadsBusy, getDaemon, getExecutor, getExecutorTerminationTimeoutMillis, getKeepAliveTimeout, getKeyAlias, getKeyPass, getKeystoreFile, getKeystorePass, getKeystoreProvider, getKeystoreType, getMaxConnections, getMaxHeaderCount, getMaxKeepAliveRequests, getMaxThreads, getMaxThreadsInternal, getMaxThreadsWithExecutor, getMinSpareThreads, getName, getPort, getProperty, getSessionCacheSize, getSessionTimeout, getSocketProperties, getSoLinger, getSoTimeout, getSslEnabledProtocolsArray, getSslProtocol, getTcpNoDelay, getThreadPriority, getTrustManagerClassName, getTrustMaxCertLength, getTruststoreAlgorithm, getTruststoreFile, getTruststorePass, getTruststoreProvider, getTruststoreType, getUseServerCipherSuitesOrder, handleExceptionWithDelay, init, initializeConnectionLatch, isPaused, isRunning, isSSLEnabled, pause, releaseConnectionLatch, resume, setAcceptorThreadCount, setAcceptorThreadPriority, setAddress, setAlgorithm, setAllowUnsafeLegacyRenegotiation, setAttribute, setBacklog, setBindOnInit, setCiphers, setClientAuth, setCrlFile, setDaemon, setExecutor, setExecutorTerminationTimeoutMillis, setKeepAliveTimeout, setKeyAlias, setKeyPass, setKeystoreFile, setKeystorePass, setKeystoreProvider, setKeystoreType, setMaxHeaderCount, setMaxKeepAliveRequests, setMaxThreads, setMinSpareThreads, setName, setPort, setProperty, setSessionCacheSize, setSessionTimeout, setSoLinger, setSoTimeout, setSSLEnabled, setSslEnabledProtocols, setSslProtocol, setTcpNoDelay, setThreadPriority, setTrustManagerClassName, setTrustMaxCertLength, setTruststoreAlgorithm, setTruststoreFile, setTruststorePass, setTruststoreProvider, setTruststoreType, setUseServerCipherSuitesOrder, 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

    - #### rootPool

          protected long rootPool

      Root APR memory pool.

    - #### serverSock

          protected long serverSock

      Server socket "pointer".

    - #### serverSockPool

          protected long serverSockPool

      APR memory pool for the server socket.

    - #### sslContext

          protected long sslContext

      SSL context.

    - #### waitingRequests

          protected ConcurrentLinkedQueue<SocketWrapper<Long>> waitingRequests

    - #### deferAccept

          protected boolean deferAccept

      Defer accept.

    - #### sendfileSize

          protected int sendfileSize

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

    - #### handler

          protected AprEndpoint.Handler handler

      Handling of accepted sockets.

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

    - #### useSendfile

          protected boolean useSendfile

      Use sendfile for sending static files.

    - #### useComet

          protected boolean useComet

      Allow comet request handling.

    - #### sendfileThreadCount

          protected int sendfileThreadCount

      Sendfile thread count.

    - #### poller

          protected AprEndpoint.Poller poller

      The socket poller.

    - #### asyncTimeout

          protected AprEndpoint.AsyncTimeout asyncTimeout

      The socket poller.

    - #### sendfile

          protected AprEndpoint.Sendfile sendfile

      The static file sender.

    - #### SSLProtocol

          protected String SSLProtocol

      SSL protocols.

    - #### SSLPassword

          protected String SSLPassword

      SSL password (if a cert is encrypted, and no password has been provided, a callback will ask for a password).

    - #### SSLCipherSuite

          protected String SSLCipherSuite

      SSL cipher suite.

    - #### SSLCertificateFile

          protected String SSLCertificateFile

      SSL certificate file.

    - #### SSLCertificateKeyFile

          protected String SSLCertificateKeyFile

      SSL certificate key file.

    - #### SSLCertificateChainFile

          protected String SSLCertificateChainFile

      SSL certificate chain file.

    - #### SSLCACertificatePath

          protected String SSLCACertificatePath

      SSL CA certificate path.

    - #### SSLCACertificateFile

          protected String SSLCACertificateFile

      SSL CA certificate file.

    - #### SSLCARevocationPath

          protected String SSLCARevocationPath

      SSL CA revocation path.

    - #### SSLCARevocationFile

          protected String SSLCARevocationFile

      SSL CA revocation file.

    - #### SSLVerifyClient

          protected String SSLVerifyClient

      SSL verify client.

    - #### SSLVerifyDepth

          protected int SSLVerifyDepth

      SSL verify depth.

    - #### SSLInsecureRenegotiation

          protected boolean SSLInsecureRenegotiation

      SSL allow insecure renegotiation for the the client that does not support the secure renegotiation.

    - #### SSLHonorCipherOrder

          protected boolean SSLHonorCipherOrder

    - #### SSLDisableCompression

          protected boolean SSLDisableCompression

      Disables compression of the SSL stream. This thwarts CRIME attack and possibly improves performance by not compressing uncompressible content such as JPEG, etc.

  - ### Constructor Detail

    - #### AprEndpoint

          public AprEndpoint()

  - ### Method Detail

    - #### getSslProtocolAll

          protected static Set<String> getSslProtocolAll()

    - #### removeWaitingRequest

          public void removeWaitingRequest(SocketWrapper<Long> socketWrapper)

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

    - #### setDeferAccept

          public void setDeferAccept(boolean deferAccept)

    - #### getDeferAccept

          public boolean getDeferAccept()

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

    - #### setSendfileSize

          public void setSendfileSize(int sendfileSize)

    - #### getSendfileSize

          public int getSendfileSize()

    - #### setHandler

          public void setHandler(AprEndpoint.Handler handler)

    - #### getHandler

          public AprEndpoint.Handler getHandler()

    - #### getPollTime

          public int getPollTime()

    - #### setPollTime

          public void setPollTime(int pollTime)

    - #### setUseSendfile

          public void setUseSendfile(boolean useSendfile)

    - #### getUseSendfile

          public boolean getUseSendfile()

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

    - #### setUseComet

          public void setUseComet(boolean useComet)

    - #### getUseComet

          public boolean getUseComet()

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

    - #### getUseCometTimeout

          public boolean getUseCometTimeout()

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

    - #### getUsePolling

          public boolean getUsePolling()

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

    - #### setSendfileThreadCount

          public void setSendfileThreadCount(int sendfileThreadCount)

    - #### getSendfileThreadCount

          public int getSendfileThreadCount()

    - #### getPoller

          public AprEndpoint.Poller getPoller()

    - #### getAsyncTimeout

          public AprEndpoint.AsyncTimeout getAsyncTimeout()

    - #### getSendfile

          public AprEndpoint.Sendfile getSendfile()

    - #### getSSLProtocol

          public String getSSLProtocol()

    - #### setSSLProtocol

          public void setSSLProtocol(String SSLProtocol)

    - #### getSSLPassword

          public String getSSLPassword()

    - #### setSSLPassword

          public void setSSLPassword(String SSLPassword)

    - #### getSSLCipherSuite

          public String getSSLCipherSuite()

    - #### setSSLCipherSuite

          public void setSSLCipherSuite(String SSLCipherSuite)

    - #### getSSLCertificateFile

          public String getSSLCertificateFile()

    - #### setSSLCertificateFile

          public void setSSLCertificateFile(String SSLCertificateFile)

    - #### getSSLCertificateKeyFile

          public String getSSLCertificateKeyFile()

    - #### setSSLCertificateKeyFile

          public void setSSLCertificateKeyFile(String SSLCertificateKeyFile)

    - #### getSSLCertificateChainFile

          public String getSSLCertificateChainFile()

    - #### setSSLCertificateChainFile

          public void setSSLCertificateChainFile(String SSLCertificateChainFile)

    - #### getSSLCACertificatePath

          public String getSSLCACertificatePath()

    - #### setSSLCACertificatePath

          public void setSSLCACertificatePath(String SSLCACertificatePath)

    - #### getSSLCACertificateFile

          public String getSSLCACertificateFile()

    - #### setSSLCACertificateFile

          public void setSSLCACertificateFile(String SSLCACertificateFile)

    - #### getSSLCARevocationPath

          public String getSSLCARevocationPath()

    - #### setSSLCARevocationPath

          public void setSSLCARevocationPath(String SSLCARevocationPath)

    - #### getSSLCARevocationFile

          public String getSSLCARevocationFile()

    - #### setSSLCARevocationFile

          public void setSSLCARevocationFile(String SSLCARevocationFile)

    - #### getSSLVerifyClient

          public String getSSLVerifyClient()

    - #### setSSLVerifyClient

          public void setSSLVerifyClient(String SSLVerifyClient)

    - #### getSSLVerifyDepth

          public int getSSLVerifyDepth()

    - #### setSSLVerifyDepth

          public void setSSLVerifyDepth(int SSLVerifyDepth)

    - #### setSSLInsecureRenegotiation

          public void setSSLInsecureRenegotiation(boolean SSLInsecureRenegotiation)

    - #### getSSLInsecureRenegotiation

          public boolean getSSLInsecureRenegotiation()

    - #### setSSLHonorCipherOrder

          public void setSSLHonorCipherOrder(boolean SSLHonorCipherOrder)

      Set to `true` to enforce the server's cipher order instead of the default which is to allow the client to choose a preferred cipher.

    - #### getSSLHonorCipherOrder

          public boolean getSSLHonorCipherOrder()

    - #### setSSLDisableCompression

          public void setSSLDisableCompression(boolean SSLDisableCompression)

      Set to `true` to disable SSL compression. This thwarts CRIME attack.

    - #### getSSLDisableCompression

          public boolean getSSLDisableCompression()

    - #### getLocalPort

          public int getLocalPort()

      Port in use.
      Specified by:
        `getLocalPort` in class `AbstractEndpoint<Long>`

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

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

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

    - #### setSocketOptions

          protected boolean setSocketOptions(long socket)

      Process the specified connection.

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

          public boolean processSocket(long socket,
                              SocketStatus status)

      Process given socket. Called in non-comet mode, typically keep alive or upgraded protocol.

    - #### processSocketAsync

          public void processSocketAsync(SocketWrapper<Long> socket,
                                SocketStatus status)

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

    - #### getLog

          protected Log getLog()

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

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