Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.http.nio.conn
Interface NHttpClientConnectionManager

All Known Implementing Classes:
  PoolingNHttpClientConnectionManager

    public interface NHttpClientConnectionManager

Represents a manager of persistent client connections.

The purpose of an HTTP connection manager is to serve as a factory for new HTTP connections, manage persistent connections and synchronize access to persistent connections making sure that only one thread of execution can have access to a connection at a time.

Implementations of this interface must be thread-safe. Access to shared data must be synchronized as methods of this interface may be executed from multiple threads.

Since:
  4.0

Method Summary
`void` | `closeExpiredConnections()` Closes all expired connections in the pool.
`void` | `closeIdleConnections(long idletime, TimeUnit timeUnit)` Closes idle connections in the pool.
`void` | `execute(org.apache.http.nio.reactor.IOEventDispatch eventDispatch)` Starts the underlying I/O reactor and initiates the dispatch of I/O event notifications to the given `IOEventDispatch`.
`boolean` | `isRouteComplete(org.apache.http.nio.NHttpClientConnection conn)` Determines if the given connection has been fully established and marked as route complete.
`void` | `releaseConnection(org.apache.http.nio.NHttpClientConnection conn, Object newState, long validDuration, TimeUnit timeUnit)` Releases the connection back to the manager making it potentially re-usable by other consumers.
`Future<org.apache.http.nio.NHttpClientConnection>` | `requestConnection(org.apache.http.conn.routing.HttpRoute route, Object state, long connectTimeout, long connectionRequestTimeout, TimeUnit timeUnit, org.apache.http.concurrent.FutureCallback<org.apache.http.nio.NHttpClientConnection> callback)` Returns a `Future` for a `NHttpClientConnection`.
`void` | `routeComplete(org.apache.http.nio.NHttpClientConnection conn, org.apache.http.conn.routing.HttpRoute route, org.apache.http.protocol.HttpContext context)` Marks the connection as fully established with all its intermediate hops completed.
`void` | `shutdown()` Shuts down this connection manager and releases allocated resources.
`void` | `startRoute(org.apache.http.nio.NHttpClientConnection conn, org.apache.http.conn.routing.HttpRoute route, org.apache.http.protocol.HttpContext context)` Starts the process of connection initialization.
`void` | `upgrade(org.apache.http.nio.NHttpClientConnection conn, org.apache.http.conn.routing.HttpRoute route, org.apache.http.protocol.HttpContext context)` Upgrades the underlying connection I/O session to TLS/SSL (or another layering protocol) after having executed `CONNECT` method to all intermediate proxy hops.

Method Detail

### requestConnection

    Future<org.apache.http.nio.NHttpClientConnection> requestConnection(org.apache.http.conn.routing.HttpRoute route,
                                                                        Object state,
                                                                        long connectTimeout,
                                                                        long connectionRequestTimeout,
                                                                        TimeUnit timeUnit,
                                                                        org.apache.http.concurrent.FutureCallback<org.apache.http.nio.NHttpClientConnection> callback)

  Returns a `Future` for a `NHttpClientConnection`.

  Please note that the consumer of that connection is responsible for fully establishing the route the to the connection target by calling `startRoute` in order to start the process of connection initialization, optionally calling `upgrade` method to upgrade the connection after having executed `CONNECT` method to all intermediate proxy hops and and finally calling `routeComplete` to mark the route as fully completed.

  Parameters:
    `route` - HTTP route of the requested connection.
    `state` - expected state of the connection or `null` if the connection is not expected to carry any state.
    `connectTimeout` - connect timeout.
    `connectionRequestTimeout` - connection request timeout.
    `timeUnit` - time unit of the previous two timeout values.
    `callback` - future callback.

### releaseConnection

    void releaseConnection(org.apache.http.nio.NHttpClientConnection conn,
                           Object newState,
                           long validDuration,
                           TimeUnit timeUnit)

  Releases the connection back to the manager making it potentially re-usable by other consumers. Optionally, the maximum period of how long the manager should keep the connection alive can be defined using `validDuration` and `timeUnit` parameters.

  Parameters:
    `conn` - the managed connection to release.
    `validDuration` - the duration of time this connection is valid for reuse.
    `timeUnit` - the time unit.
  See Also:
    `closeExpiredConnections()`

### startRoute

    void startRoute(org.apache.http.nio.NHttpClientConnection conn,
                    org.apache.http.conn.routing.HttpRoute route,
                    org.apache.http.protocol.HttpContext context)
                    throws IOException

  Starts the process of connection initialization. Connection route may consist of several intermediate hops and may require a protocol upgrade. Once the route is fully established the `routeComplete` method must be called.

  Parameters:
    `conn` - the managed connection to initialize.
    `route` - the connection route.
    `context` - the context
  Throws:
    `IOException`

### upgrade

    void upgrade(org.apache.http.nio.NHttpClientConnection conn,
                 org.apache.http.conn.routing.HttpRoute route,
                 org.apache.http.protocol.HttpContext context)
                 throws IOException

  Upgrades the underlying connection I/O session to TLS/SSL (or another layering protocol) after having executed `CONNECT` method to all intermediate proxy hops.

  Parameters:
    `conn` - the managed connection to upgrade.
    `route` - the connection route.
    `context` - the context
  Throws:
    `IOException`

### routeComplete

    void routeComplete(org.apache.http.nio.NHttpClientConnection conn,
                       org.apache.http.conn.routing.HttpRoute route,
                       org.apache.http.protocol.HttpContext context)

  Marks the connection as fully established with all its intermediate hops completed.

  Parameters:
    `conn` - the managed connection to mark as route complete.
    `route` - the connection route.
    `context` - the context

### isRouteComplete

    boolean isRouteComplete(org.apache.http.nio.NHttpClientConnection conn)

  Determines if the given connection has been fully established and marked as route complete.

  Parameters:
    `conn` - the managed connection.

### closeIdleConnections

    void closeIdleConnections(long idletime,
                              TimeUnit timeUnit)

  Closes idle connections in the pool.

  Open connections in the pool that have not been used for the timespan given by the argument will be closed. Currently allocated connections are not subject to this method. Times will be checked with milliseconds precision All expired connections will also be closed.

  Parameters:
    `idletime` - the idle time of connections to be closed
    `timeUnit` - the unit for the `idletime`
  See Also:
    `closeExpiredConnections()`

### closeExpiredConnections

    void closeExpiredConnections()

  Closes all expired connections in the pool.

  Open connections in the pool that have not been used for the timespan defined when the connection was released will be closed. Currently allocated connections are not subject to this method. Times will be checked with milliseconds precision.

### execute

    void execute(org.apache.http.nio.reactor.IOEventDispatch eventDispatch)
                 throws IOException

  Starts the underlying I/O reactor and initiates the dispatch of I/O event notifications to the given `IOEventDispatch`.

  Throws:
    `IOException`

### shutdown

    void shutdown()
                  throws IOException

  Shuts down this connection manager and releases allocated resources. This includes closing all connections, whether they are currently used or not.

  Throws:
    `IOException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2010–2021 The Apache Software Foundation. All rights reserved.