org.apache.tomcat.util.net

## Class AbstractEndpoint<S>

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

- Direct Known Subclasses:
    AprEndpoint, JIoEndpoint, NioEndpoint

      public abstract class AbstractEndpoint<S>
      extends Object

  Author:
    fhanik, Mladen Turk, Remy Maucherat

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `AbstractEndpoint.Acceptor`
    `protected static class` | `AbstractEndpoint.BindState`
    `static interface` | `AbstractEndpoint.Handler`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected AbstractEndpoint.Acceptor[]` | `acceptors` Threads used to accept new connections and pass them to worker threads.
    `protected int` | `acceptorThreadCount` Acceptor thread count.
    `protected int` | `acceptorThreadPriority` Priority of the acceptor threads.
    `protected HashMap<String,Object>` | `attributes` Attributes provide a way for configuration to be passed to sub-components without the `ProtocolHandler` being aware of the properties available on those sub-components.
    `protected boolean` | `internalExecutor` Are we using an internal executor
    `protected boolean` | `paused` Will be set to true whenever the endpoint is paused.
    `protected boolean` | `running` Running state of the endpoint.
    `protected static StringManager` | `sm`
    `protected SocketProperties` | `socketProperties` Socket properties
    `protected int` | `threadPriority` Priority of the worker threads.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractEndpoint()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract void` | `bind()`
    `protected void` | `configureUseServerCipherSuitesOrder(SSLEngine engine)` Configures SSLEngine to honor cipher suites ordering based upon endpoint configuration.
    `protected long` | `countDownConnection()`
    `protected void` | `countUpOrAwaitConnection()`
    `protected abstract AbstractEndpoint.Acceptor` | `createAcceptor()` Hook to allow Endpoints to provide a specific Acceptor implementation.
    `void` | `createExecutor()`
    `void` | `destroy()`
    `int` | `getAcceptorThreadCount()`
    `int` | `getAcceptorThreadPriority()`
    `InetAddress` | `getAddress()`
    `String` | `getAlgorithm()`
    `String` | `getAllowUnsafeLegacyRenegotiation()`
    `Object` | `getAttribute(String key)` Used by sub-components to retrieve configuration information.
    `int` | `getBacklog()`
    `boolean` | `getBindOnInit()`
    `String` | `getCiphers()`
    `String` | `getClientAuth()`
    `long` | `getConnectionCount()` Return the current count of connections handled by this endpoint, if the connections are counted (which happens when the maximum count of connections is limited), or `-1` if they are not.
    `String` | `getCrlFile()`
    `int` | `getCurrentThreadCount()` Return the amount of threads that are managed by the pool.
    `int` | `getCurrentThreadsBusy()` Return the amount of threads that are in use
    `boolean` | `getDaemon()`
    `protected abstract boolean` | `getDeferAccept()`
    `Executor` | `getExecutor()`
    `long` | `getExecutorTerminationTimeoutMillis()`
    `int` | `getKeepAliveTimeout()`
    `String` | `getKeyAlias()`
    `String` | `getKeyPass()`
    `String` | `getKeystoreFile()`
    `String` | `getKeystorePass()`
    `String` | `getKeystoreProvider()`
    `String` | `getKeystoreType()`
    `abstract int` | `getLocalPort()`
    `protected abstract Log` | `getLog()`
    `int` | `getMaxConnections()`
    `int` | `getMaxHeaderCount()`
    `int` | `getMaxKeepAliveRequests()`
    `int` | `getMaxThreads()`
    `protected int` | `getMaxThreadsExecutor(boolean useExecutor)`
    `int` | `getMinSpareThreads()`
    `String` | `getName()`
    `int` | `getPort()`
    `String` | `getProperty(String name)`
    `String` | `getSessionCacheSize()`
    `String` | `getSessionTimeout()`
    `SocketProperties` | `getSocketProperties()`
    `int` | `getSoLinger()` Socket linger.
    `int` | `getSoTimeout()` Socket timeout.
    `String[]` | `getSslEnabledProtocolsArray()`
    `String` | `getSslProtocol()`
    `boolean` | `getTcpNoDelay()` Socket TCP no delay.
    `int` | `getThreadPriority()`
    `String` | `getTrustManagerClassName()`
    `String` | `getTrustMaxCertLength()`
    `String` | `getTruststoreAlgorithm()`
    `String` | `getTruststoreFile()`
    `String` | `getTruststorePass()`
    `String` | `getTruststoreProvider()`
    `String` | `getTruststoreType()`
    `abstract boolean` | `getUseComet()`
    `abstract boolean` | `getUseCometTimeout()`
    `abstract boolean` | `getUsePolling()`
    `abstract boolean` | `getUseSendfile()`
    `String` | `getUseServerCipherSuitesOrder()`
    `protected int` | `handleExceptionWithDelay(int currentErrorDelay)` Provides a common approach for sub-classes to handle exceptions where a delay is required to prevent a Thread from entering a tight loop which will consume CPU and may also trigger large amounts of logging.
    `void` | `init()`
    `protected LimitLatch` | `initializeConnectionLatch()`
    `boolean` | `isPaused()`
    `boolean` | `isRunning()`
    `boolean` | `isSSLEnabled()`
    `void` | `pause()` Pause the endpoint, which will stop it accepting new connections.
    `abstract void` | `processSocketAsync(SocketWrapper<S> socketWrapper, SocketStatus socketStatus)`
    `protected void` | `releaseConnectionLatch()`
    `abstract void` | `removeWaitingRequest(SocketWrapper<S> socketWrapper)`
    `void` | `resume()` Resume the endpoint, which will make it start accepting new connections again.
    `void` | `setAcceptorThreadCount(int acceptorThreadCount)`
    `void` | `setAcceptorThreadPriority(int acceptorThreadPriority)`
    `void` | `setAddress(InetAddress address)`
    `void` | `setAlgorithm(String s)`
    `void` | `setAllowUnsafeLegacyRenegotiation(String s)`
    `void` | `setAttribute(String name, Object value)` Generic property setter called when a property for which a specific setter already exists within the `ProtocolHandler` needs to be made available to sub-components.
    `void` | `setBacklog(int backlog)`
    `void` | `setBindOnInit(boolean b)`
    `void` | `setCiphers(String s)`
    `void` | `setClientAuth(String s)`
    `void` | `setCrlFile(String crlFile)`
    `void` | `setDaemon(boolean b)`
    `void` | `setExecutor(Executor executor)`
    `void` | `setExecutorTerminationTimeoutMillis(long executorTerminationTimeoutMillis)`
    `void` | `setKeepAliveTimeout(int keepAliveTimeout)`
    `void` | `setKeyAlias(String s)`
    `void` | `setKeyPass(String s)`
    `void` | `setKeystoreFile(String s)`
    `void` | `setKeystorePass(String s)`
    `void` | `setKeystoreProvider(String s)`
    `void` | `setKeystoreType(String s)`
    `void` | `setMaxConnections(int maxCon)`
    `void` | `setMaxHeaderCount(int maxHeaderCount)`
    `void` | `setMaxKeepAliveRequests(int maxKeepAliveRequests)`
    `void` | `setMaxThreads(int maxThreads)`
    `void` | `setMinSpareThreads(int minSpareThreads)`
    `void` | `setName(String name)`
    `void` | `setPort(int port)`
    `boolean` | `setProperty(String name, String value)`
    `void` | `setSessionCacheSize(String s)`
    `void` | `setSessionTimeout(String s)`
    `void` | `setSoLinger(int soLinger)`
    `void` | `setSoTimeout(int soTimeout)`
    `void` | `setSSLEnabled(boolean SSLEnabled)`
    `void` | `setSslEnabledProtocols(String s)`
    `void` | `setSslProtocol(String s)`
    `void` | `setTcpNoDelay(boolean tcpNoDelay)`
    `void` | `setThreadPriority(int threadPriority)`
    `void` | `setTrustManagerClassName(String trustManagerClassName)`
    `void` | `setTrustMaxCertLength(String trustMaxCertLength)`
    `void` | `setTruststoreAlgorithm(String truststoreAlgorithm)`
    `void` | `setTruststoreFile(String s)`
    `void` | `setTruststorePass(String truststorePass)`
    `void` | `setTruststoreProvider(String truststoreProvider)`
    `void` | `setTruststoreType(String truststoreType)`
    `void` | `setUseServerCipherSuitesOrder(String s)`
    `void` | `shutdownExecutor()`
    `void` | `start()`
    `protected void` | `startAcceptorThreads()`
    `abstract void` | `startInternal()`
    `void` | `stop()`
    `abstract void` | `stopInternal()`
    `abstract void` | `unbind()`
    `protected void` | `unlockAccept()` Unlock the server socket accept using a bogus connection.

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

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

- - ### Field Detail

    - #### sm

          protected static final StringManager sm

    - #### running

          protected volatile boolean running

      Running state of the endpoint.

    - #### paused

          protected volatile boolean paused

      Will be set to true whenever the endpoint is paused.

    - #### internalExecutor

          protected volatile boolean internalExecutor

      Are we using an internal executor

    - #### socketProperties

          protected SocketProperties socketProperties

      Socket properties

    - #### acceptors

          protected AbstractEndpoint.Acceptor[] acceptors

      Threads used to accept new connections and pass them to worker threads.

    - #### acceptorThreadCount

          protected int acceptorThreadCount

      Acceptor thread count.

    - #### acceptorThreadPriority

          protected int acceptorThreadPriority

      Priority of the acceptor threads.

    - #### threadPriority

          protected int threadPriority

      Priority of the worker threads.

    - #### attributes

          protected HashMap<String,Object> attributes

      Attributes provide a way for configuration to be passed to sub-components without the `ProtocolHandler` being aware of the properties available on those sub-components. One example of such a sub-component is the `ServerSocketFactory`.

  - ### Constructor Detail

    - #### AbstractEndpoint

          public AbstractEndpoint()

  - ### Method Detail

    - #### getSocketProperties

          public SocketProperties getSocketProperties()

    - #### getExecutorTerminationTimeoutMillis

          public long getExecutorTerminationTimeoutMillis()

    - #### setExecutorTerminationTimeoutMillis

          public void setExecutorTerminationTimeoutMillis(long executorTerminationTimeoutMillis)

    - #### setAcceptorThreadCount

          public void setAcceptorThreadCount(int acceptorThreadCount)

    - #### getAcceptorThreadCount

          public int getAcceptorThreadCount()

    - #### setAcceptorThreadPriority

          public void setAcceptorThreadPriority(int acceptorThreadPriority)

    - #### getAcceptorThreadPriority

          public int getAcceptorThreadPriority()

    - #### setMaxConnections

          public void setMaxConnections(int maxCon)

    - #### getMaxConnections

          public int getMaxConnections()

    - #### getConnectionCount

          public long getConnectionCount()

      Return the current count of connections handled by this endpoint, if the connections are counted (which happens when the maximum count of connections is limited), or `-1` if they are not. This property is added here so that this value can be inspected through JMX. It is visible on "ThreadPool" MBean.

      The count is incremented by the Acceptor before it tries to accept a new connection. Until the limit is reached and thus the count cannot be incremented, this value is more by 1 (the count of acceptors) than the actual count of connections that are being served.

      Returns:
        The count

    - #### setExecutor

          public void setExecutor(Executor executor)

    - #### getExecutor

          public Executor getExecutor()

    - #### getPort

          public int getPort()

    - #### setPort

          public void setPort(int port)

    - #### getLocalPort

          public abstract int getLocalPort()

    - #### getAddress

          public InetAddress getAddress()

    - #### setAddress

          public void setAddress(InetAddress address)

    - #### setBacklog

          public void setBacklog(int backlog)

    - #### getBacklog

          public int getBacklog()

    - #### getBindOnInit

          public boolean getBindOnInit()

    - #### setBindOnInit

          public void setBindOnInit(boolean b)

    - #### getKeepAliveTimeout

          public int getKeepAliveTimeout()

    - #### setKeepAliveTimeout

          public void setKeepAliveTimeout(int keepAliveTimeout)

    - #### getTcpNoDelay

          public boolean getTcpNoDelay()

      Socket TCP no delay.

    - #### setTcpNoDelay

          public void setTcpNoDelay(boolean tcpNoDelay)

    - #### getSoLinger

          public int getSoLinger()

      Socket linger.

    - #### setSoLinger

          public void setSoLinger(int soLinger)

    - #### getSoTimeout

          public int getSoTimeout()

      Socket timeout.

    - #### setSoTimeout

          public void setSoTimeout(int soTimeout)

    - #### isSSLEnabled

          public boolean isSSLEnabled()

    - #### setSSLEnabled

          public void setSSLEnabled(boolean SSLEnabled)

    - #### getMinSpareThreads

          public int getMinSpareThreads()

    - #### setMinSpareThreads

          public void setMinSpareThreads(int minSpareThreads)

    - #### setMaxThreads

          public void setMaxThreads(int maxThreads)

    - #### getMaxThreads

          public int getMaxThreads()

    - #### getMaxThreadsExecutor

          protected int getMaxThreadsExecutor(boolean useExecutor)

    - #### getMaxKeepAliveRequests

          public int getMaxKeepAliveRequests()

    - #### setMaxKeepAliveRequests

          public void setMaxKeepAliveRequests(int maxKeepAliveRequests)

    - #### getMaxHeaderCount

          public int getMaxHeaderCount()

    - #### setMaxHeaderCount

          public void setMaxHeaderCount(int maxHeaderCount)

    - #### setName

          public void setName(String name)

    - #### getName

          public String getName()

    - #### setDaemon

          public void setDaemon(boolean b)

    - #### getDaemon

          public boolean getDaemon()

    - #### setThreadPriority

          public void setThreadPriority(int threadPriority)

    - #### getThreadPriority

          public int getThreadPriority()

    - #### getDeferAccept

          protected abstract boolean getDeferAccept()

    - #### setAttribute

          public void setAttribute(String name,
                          Object value)

      Generic property setter called when a property for which a specific setter already exists within the `ProtocolHandler` needs to be made available to sub-components. The specific setter will call this method to populate the attributes.

    - #### getAttribute

          public Object getAttribute(String key)

      Used by sub-components to retrieve configuration information.

    - #### setProperty

          public boolean setProperty(String name,
                            String value)

    - #### getProperty

          public String getProperty(String name)

    - #### getCurrentThreadCount

          public int getCurrentThreadCount()

      Return the amount of threads that are managed by the pool.
      Returns:
        the amount of threads that are managed by the pool

    - #### getCurrentThreadsBusy

          public int getCurrentThreadsBusy()

      Return the amount of threads that are in use
      Returns:
        the amount of threads that are in use

    - #### isRunning

          public boolean isRunning()

    - #### isPaused

          public boolean isPaused()

    - #### createExecutor

          public void createExecutor()

    - #### shutdownExecutor

          public void shutdownExecutor()

    - #### unlockAccept

          protected void unlockAccept()

      Unlock the server socket accept using a bogus connection.

    - #### processSocketAsync

          public abstract void processSocketAsync(SocketWrapper<S> socketWrapper,
                                SocketStatus socketStatus)

    - #### removeWaitingRequest

          public abstract void removeWaitingRequest(SocketWrapper<S> socketWrapper)

    - #### bind

          public abstract void bind()
                             throws Exception

      Throws:
        `Exception`

    - #### unbind

          public abstract void unbind()
                               throws Exception

      Throws:
        `Exception`

    - #### startInternal

          public abstract void startInternal()
                                      throws Exception

      Throws:
        `Exception`

    - #### stopInternal

          public abstract void stopInternal()
                                     throws Exception

      Throws:
        `Exception`

    - #### init

          public final void init()
                          throws Exception

      Throws:
        `Exception`

    - #### start

          public final void start()
                           throws Exception

      Throws:
        `Exception`

    - #### startAcceptorThreads

          protected final void startAcceptorThreads()

    - #### createAcceptor

          protected abstract AbstractEndpoint.Acceptor createAcceptor()

      Hook to allow Endpoints to provide a specific Acceptor implementation.

    - #### pause

          public void pause()

      Pause the endpoint, which will stop it accepting new connections.

    - #### resume

          public void resume()

      Resume the endpoint, which will make it start accepting new connections again.

    - #### stop

          public final void stop()
                          throws Exception

      Throws:
        `Exception`

    - #### destroy

          public final void destroy()
                             throws Exception

      Throws:
        `Exception`

    - #### getLog

          protected abstract Log getLog()

    - #### getUseSendfile

          public abstract boolean getUseSendfile()

    - #### getUseComet

          public abstract boolean getUseComet()

    - #### getUseCometTimeout

          public abstract boolean getUseCometTimeout()

    - #### getUsePolling

          public abstract boolean getUsePolling()

    - #### initializeConnectionLatch

          protected LimitLatch initializeConnectionLatch()

    - #### releaseConnectionLatch

          protected void releaseConnectionLatch()

    - #### countUpOrAwaitConnection

          protected void countUpOrAwaitConnection()
                                           throws InterruptedException

      Throws:
        `InterruptedException`

    - #### countDownConnection

          protected long countDownConnection()

    - #### handleExceptionWithDelay

          protected int handleExceptionWithDelay(int currentErrorDelay)

      Provides a common approach for sub-classes to handle exceptions where a delay is required to prevent a Thread from entering a tight loop which will consume CPU and may also trigger large amounts of logging. For example, this can happen with the Acceptor thread if the ulimit for open files is reached.
      Parameters:
        `currentErrorDelay` - The current delay being applied on failure
      Returns:
        The delay to apply on the next failure

    - #### getAlgorithm

          public String getAlgorithm()

    - #### setAlgorithm

          public void setAlgorithm(String s)

    - #### getClientAuth

          public String getClientAuth()

    - #### setClientAuth

          public void setClientAuth(String s)

    - #### getKeystoreFile

          public String getKeystoreFile()

    - #### setKeystoreFile

          public void setKeystoreFile(String s)

    - #### getKeystorePass

          public String getKeystorePass()

    - #### setKeystorePass

          public void setKeystorePass(String s)

    - #### getKeystoreType

          public String getKeystoreType()

    - #### setKeystoreType

          public void setKeystoreType(String s)

    - #### getKeystoreProvider

          public String getKeystoreProvider()

    - #### setKeystoreProvider

          public void setKeystoreProvider(String s)

    - #### getSslProtocol

          public String getSslProtocol()

    - #### setSslProtocol

          public void setSslProtocol(String s)

    - #### getCiphers

          public String getCiphers()

    - #### setCiphers

          public void setCiphers(String s)

    - #### getUseServerCipherSuitesOrder

          public String getUseServerCipherSuitesOrder()

    - #### setUseServerCipherSuitesOrder

          public void setUseServerCipherSuitesOrder(String s)

    - #### getKeyAlias

          public String getKeyAlias()

    - #### setKeyAlias

          public void setKeyAlias(String s)

    - #### getKeyPass

          public String getKeyPass()

    - #### setKeyPass

          public void setKeyPass(String s)

    - #### getTruststoreFile

          public String getTruststoreFile()

    - #### setTruststoreFile

          public void setTruststoreFile(String s)

    - #### getTruststorePass

          public String getTruststorePass()

    - #### setTruststorePass

          public void setTruststorePass(String truststorePass)

    - #### getTruststoreType

          public String getTruststoreType()

    - #### setTruststoreType

          public void setTruststoreType(String truststoreType)

    - #### getTruststoreProvider

          public String getTruststoreProvider()

    - #### setTruststoreProvider

          public void setTruststoreProvider(String truststoreProvider)

    - #### getTruststoreAlgorithm

          public String getTruststoreAlgorithm()

    - #### setTruststoreAlgorithm

          public void setTruststoreAlgorithm(String truststoreAlgorithm)

    - #### getTrustManagerClassName

          public String getTrustManagerClassName()

    - #### setTrustManagerClassName

          public void setTrustManagerClassName(String trustManagerClassName)

    - #### getCrlFile

          public String getCrlFile()

    - #### setCrlFile

          public void setCrlFile(String crlFile)

    - #### getTrustMaxCertLength

          public String getTrustMaxCertLength()

    - #### setTrustMaxCertLength

          public void setTrustMaxCertLength(String trustMaxCertLength)

    - #### getSessionCacheSize

          public String getSessionCacheSize()

    - #### setSessionCacheSize

          public void setSessionCacheSize(String s)

    - #### getSessionTimeout

          public String getSessionTimeout()

    - #### setSessionTimeout

          public void setSessionTimeout(String s)

    - #### getAllowUnsafeLegacyRenegotiation

          public String getAllowUnsafeLegacyRenegotiation()

    - #### setAllowUnsafeLegacyRenegotiation

          public void setAllowUnsafeLegacyRenegotiation(String s)

    - #### getSslEnabledProtocolsArray

          public String[] getSslEnabledProtocolsArray()

    - #### setSslEnabledProtocols

          public void setSslEnabledProtocols(String s)

    - #### configureUseServerCipherSuitesOrder

          protected void configureUseServerCipherSuitesOrder(SSLEngine engine)

      Configures SSLEngine to honor cipher suites ordering based upon endpoint configuration.
      Throws:
        `InvalidAlgorithmParameterException` - If the runtime JVM doesn't support this setting.

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