org.apache.http.nio.pool

## Class AbstractNIOConnPool<T,C,E extends PoolEntry<T,C>>

- java.lang.Object
- - org.apache.http.nio.pool.AbstractNIOConnPool<T,C,E>

- Type Parameters:
    `T` - route
    `C` - connection object
    `E` - pool entry
  All Implemented Interfaces:
    ConnPool<T,E>, ConnPoolControl<T>
  Direct Known Subclasses:
    BasicNIOConnPool

      @ThreadSafe
      public abstract class AbstractNIOConnPool<T,C,E extends PoolEntry<T,C>>
      extends Object
      implements ConnPool<T,E>, ConnPoolControl<T>

  Abstract non-blocking connection pool.
  Since:
    4.2

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractNIOConnPool(ConnectingIOReactor ioreactor, NIOConnFactory<T,C> connFactory, int defaultMaxPerRoute, int maxTotal)` Deprecated. use `AbstractNIOConnPool(ConnectingIOReactor, NIOConnFactory, SocketAddressResolver, int, int)`
    `AbstractNIOConnPool(ConnectingIOReactor ioreactor, NIOConnFactory<T,C> connFactory, SocketAddressResolver<T> addressResolver, int defaultMaxPerRoute, int maxTotal)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `closeExpired()`
    `void` | `closeIdle(long idletime, TimeUnit tunit)`
    `protected abstract E` | `createEntry(T route, C conn)`
    `protected void` | `enumAvailable(PoolEntryCallback<T,C> callback)` Enumerates all available connections.
    `protected void` | `enumEntries(Iterator<E> it, PoolEntryCallback<T,C> callback)`
    `protected void` | `enumLeased(PoolEntryCallback<T,C> callback)` Enumerates all leased connections.
    `int` | `getDefaultMaxPerRoute()`
    `int` | `getMaxPerRoute(T route)`
    `int` | `getMaxTotal()`
    `PoolStats` | `getStats(T route)`
    `PoolStats` | `getTotalStats()`
    `boolean` | `isShutdown()`
    `Future<E>` | `lease(T route, Object state)`
    `Future<E>` | `lease(T route, Object state, FutureCallback<E> callback)` Attempts to lease a connection for the given route and with the given state from the pool.
    `Future<E>` | `lease(T route, Object state, long connectTimeout, long leaseTimeout, TimeUnit tunit, FutureCallback<E> callback)`
    `Future<E>` | `lease(T route, Object state, long connectTimeout, TimeUnit tunit, FutureCallback<E> callback)`
    `protected void` | `onLease(E entry)`
    `protected void` | `onRelease(E entry)`
    `void` | `release(E entry, boolean reusable)` Releases the pool entry back to the pool.
    `protected void` | `requestCancelled(SessionRequest request)`
    `protected void` | `requestCompleted(SessionRequest request)`
    `protected void` | `requestFailed(SessionRequest request)`
    `protected void` | `requestTimeout(SessionRequest request)`
    `protected SocketAddress` | `resolveLocalAddress(T route)` Deprecated. (4.3) use `SocketAddressResolver`
    `protected SocketAddress` | `resolveRemoteAddress(T route)` Deprecated. (4.3) use `SocketAddressResolver`
    `void` | `setDefaultMaxPerRoute(int max)`
    `void` | `setMaxPerRoute(T route, int max)`
    `void` | `setMaxTotal(int max)`
    `void` | `shutdown(long waitMs)`
    `String` | `toString()`
    `void` | `validatePendingRequests()`

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

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

- - ### Constructor Detail

    - #### AbstractNIOConnPool

          @Deprecated
          public AbstractNIOConnPool(ConnectingIOReactor ioreactor,
                                        NIOConnFactory<T,C> connFactory,
                                        int defaultMaxPerRoute,
                                        int maxTotal)

      Deprecated. use `AbstractNIOConnPool(ConnectingIOReactor, NIOConnFactory, SocketAddressResolver, int, int)`

    - #### AbstractNIOConnPool

          public AbstractNIOConnPool(ConnectingIOReactor ioreactor,
                             NIOConnFactory<T,C> connFactory,
                             SocketAddressResolver<T> addressResolver,
                             int defaultMaxPerRoute,
                             int maxTotal)

      Since:
        4.3

  - ### Method Detail

    - #### resolveRemoteAddress

          @Deprecated
          protected SocketAddress resolveRemoteAddress(T route)

      Deprecated. (4.3) use `SocketAddressResolver`

    - #### resolveLocalAddress

          @Deprecated
          protected SocketAddress resolveLocalAddress(T route)

      Deprecated. (4.3) use `SocketAddressResolver`

    - #### createEntry

          protected abstract E createEntry(T route,
                      C conn)

    - #### onLease

          protected void onLease(E entry)

      Since:
        4.3

    - #### onRelease

          protected void onRelease(E entry)

      Since:
        4.3

    - #### isShutdown

          public boolean isShutdown()

    - #### shutdown

          public void shutdown(long waitMs)
                        throws IOException

      Throws:
        `IOException`

    - #### lease

          public Future<E> lease(T route,
                        Object state,
                        long connectTimeout,
                        TimeUnit tunit,
                        FutureCallback<E> callback)

    - #### lease

          public Future<E> lease(T route,
                        Object state,
                        long connectTimeout,
                        long leaseTimeout,
                        TimeUnit tunit,
                        FutureCallback<E> callback)

      Since:
        4.3

    - #### lease

          public Future<E> lease(T route,
                        Object state,
                        FutureCallback<E> callback)

      Description copied from interface: `ConnPool`
      Attempts to lease a connection for the given route and with the given state from the pool.
      Specified by:
        `lease` in interface `ConnPool<T,E extends PoolEntry<T,C>>`
      Parameters:
        `route` - route of the connection.
        `state` - arbitrary object that represents a particular state (usually a security principal or a unique token identifying the user whose credentials have been used while establishing the connection). May be `null`.
        `callback` - operation completion callback.
      Returns:
        future for a leased pool entry.

    - #### lease

          public Future<E> lease(T route,
                        Object state)

    - #### release

          public void release(E entry,
                     boolean reusable)

      Description copied from interface: `ConnPool`
      Releases the pool entry back to the pool.
      Specified by:
        `release` in interface `ConnPool<T,E extends PoolEntry<T,C>>`
      Parameters:
        `entry` - pool entry leased from the pool
        `reusable` - flag indicating whether or not the released connection is in a consistent state and is safe for further use.

    - #### validatePendingRequests

          public void validatePendingRequests()

    - #### requestCompleted

          protected void requestCompleted(SessionRequest request)

    - #### requestCancelled

          protected void requestCancelled(SessionRequest request)

    - #### requestFailed

          protected void requestFailed(SessionRequest request)

    - #### requestTimeout

          protected void requestTimeout(SessionRequest request)

    - #### setMaxTotal

          public void setMaxTotal(int max)

      Specified by:
        `setMaxTotal` in interface `ConnPoolControl<T>`

    - #### getMaxTotal

          public int getMaxTotal()

      Specified by:
        `getMaxTotal` in interface `ConnPoolControl<T>`

    - #### setDefaultMaxPerRoute

          public void setDefaultMaxPerRoute(int max)

      Specified by:
        `setDefaultMaxPerRoute` in interface `ConnPoolControl<T>`

    - #### getDefaultMaxPerRoute

          public int getDefaultMaxPerRoute()

      Specified by:
        `getDefaultMaxPerRoute` in interface `ConnPoolControl<T>`

    - #### setMaxPerRoute

          public void setMaxPerRoute(T route,
                            int max)

      Specified by:
        `setMaxPerRoute` in interface `ConnPoolControl<T>`

    - #### getMaxPerRoute

          public int getMaxPerRoute(T route)

      Specified by:
        `getMaxPerRoute` in interface `ConnPoolControl<T>`

    - #### getTotalStats

          public PoolStats getTotalStats()

      Specified by:
        `getTotalStats` in interface `ConnPoolControl<T>`

    - #### getStats

          public PoolStats getStats(T route)

      Specified by:
        `getStats` in interface `ConnPoolControl<T>`

    - #### enumAvailable

          protected void enumAvailable(PoolEntryCallback<T,C> callback)

      Enumerates all available connections.
      Since:
        4.3

    - #### enumLeased

          protected void enumLeased(PoolEntryCallback<T,C> callback)

      Enumerates all leased connections.
      Since:
        4.3

    - #### enumEntries

          protected void enumEntries(Iterator<E> it,
                         PoolEntryCallback<T,C> callback)

    - #### closeIdle

          public void closeIdle(long idletime,
                       TimeUnit tunit)

    - #### closeExpired

          public void closeExpired()

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2005–2013 The Apache Software Foundation. All rights reserved.