JIoEndpoint (Apache Tomcat 7.0.104 API Documentation)

org.apache.tomcat.util.net

## Class JIoEndpoint

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

-     public class JIoEndpoint
      extends AbstractEndpoint<Socket>

  Handle incoming TCP connections. This class implement a simple server model: one listener thread accepts on a socket and creates a new worker thread for each incoming connection. More advanced Endpoints will reuse the threads, use queues, etc.
  Author:
    James Duncan Davidson, Jason Hunter, James Todd, Costin Manolache, Gal Shachor, Yoav Shapira, Remy Maucherat

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected class` | `JIoEndpoint.Acceptor` The background thread that listens for incoming TCP/IP connections and hands them off to an appropriate processor.
    `protected class` | `JIoEndpoint.AsyncTimeout` Async timeout thread
    `static interface` | `JIoEndpoint.Handler` Bare bones interface used for socket processing.
    `protected class` | `JIoEndpoint.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`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected JIoEndpoint.Handler` | `handler` Handling of accepted sockets.
    `protected ServerSocket` | `serverSocket` Associated server socket.
    `protected ServerSocketFactory` | `serverSocketFactory` Server socket factory.
    `protected ConcurrentLinkedQueue<SocketWrapper<Socket>>` | `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
    `JIoEndpoint()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `bind()`
    `protected AbstractEndpoint.Acceptor` | `createAcceptor()` Hook to allow Endpoints to provide a specific Acceptor implementation.
    `boolean` | `getDeferAccept()`
    `JIoEndpoint.Handler` | `getHandler()`
    `int` | `getLocalPort()` Port in use.
    `protected Log` | `getLog()`
    `ServerSocketFactory` | `getServerSocketFactory()`
    `boolean` | `getUseComet()`
    `boolean` | `getUseCometTimeout()`
    `boolean` | `getUsePolling()`
    `boolean` | `getUseSendfile()`
    `protected boolean` | `processSocket(Socket socket)` Process a new connection from a new client.
    `void` | `processSocketAsync(SocketWrapper<Socket> socket, SocketStatus status)` Process an existing async connection.
    `void` | `removeWaitingRequest(SocketWrapper<Socket> socketWrapper)`
    `void` | `setHandler(JIoEndpoint.Handler handler)`
    `void` | `setServerSocketFactory(ServerSocketFactory factory)`
    `protected boolean` | `setSocketOptions(Socket socket)` Configure the socket.
    `void` | `startInternal()`
    `void` | `stopInternal()`
    `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, setMaxConnections, 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

    - #### serverSocket

          protected ServerSocket serverSocket

      Associated server socket.

    - #### handler

          protected JIoEndpoint.Handler handler

      Handling of accepted sockets.

    - #### serverSocketFactory

          protected ServerSocketFactory serverSocketFactory

      Server socket factory.

    - #### waitingRequests

          protected ConcurrentLinkedQueue<SocketWrapper<Socket>> waitingRequests

  - ### Constructor Detail

    - #### JIoEndpoint

          public JIoEndpoint()

  - ### Method Detail

    - #### setHandler

          public void setHandler(JIoEndpoint.Handler handler)

    - #### getHandler

          public JIoEndpoint.Handler getHandler()

    - #### setServerSocketFactory

          public void setServerSocketFactory(ServerSocketFactory factory)

    - #### getServerSocketFactory

          public ServerSocketFactory getServerSocketFactory()

    - #### getLocalPort

          public int getLocalPort()

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

    - #### getUseSendfile

          public boolean getUseSendfile()

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

    - #### getUseComet

          public boolean getUseComet()

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

    - #### getUseCometTimeout

          public boolean getUseCometTimeout()

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

    - #### getDeferAccept

          public boolean getDeferAccept()

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

    - #### getUsePolling

          public boolean getUsePolling()

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

    - #### bind

          public void bind()
                    throws Exception

      Specified by:
        `bind` in class `AbstractEndpoint<Socket>`
      Throws:
        `Exception`

    - #### startInternal

          public void startInternal()
                             throws Exception

      Specified by:
        `startInternal` in class `AbstractEndpoint<Socket>`
      Throws:
        `Exception`

    - #### stopInternal

          public void stopInternal()

      Specified by:
        `stopInternal` in class `AbstractEndpoint<Socket>`

    - #### unbind

          public void unbind()
                      throws Exception

      Deallocate APR memory pools, and close server socket.
      Specified by:
        `unbind` in class `AbstractEndpoint<Socket>`
      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<Socket>`

    - #### setSocketOptions

          protected boolean setSocketOptions(Socket socket)

      Configure the socket.

    - #### processSocket

          protected boolean processSocket(Socket socket)

      Process a new connection from a new client. Wraps the socket so keep-alive and other attributes can be tracked and then passes the socket to the executor for processing.
      Parameters:
        `socket` - The socket associated with the client.
      Returns:
        `true` if the socket is passed to the executor, `false` if something went wrong or if the endpoint is shutting down. Returning `false` is an indication to close the socket immediately.

    - #### processSocketAsync

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

      Process an existing async connection. If processing is required, passes the wrapped socket to an executor for processing.
      Specified by:
        `processSocketAsync` in class `AbstractEndpoint<Socket>`
      Parameters:
        `socket` - The socket associated with the client.
        `status` - Only OPEN and TIMEOUT are used. The others are used for Comet requests that are not supported by the BIO (JIO) Connector.

    - #### removeWaitingRequest

          public void removeWaitingRequest(SocketWrapper<Socket> socketWrapper)

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

    - #### getLog

          protected Log getLog()

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

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