Package 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
- routeC
- connection objectE
- pool entry
- All Implemented Interfaces:
ConnPool<T,E>
,ConnPoolControl<T>
- Direct Known Subclasses:
BasicNIOConnPool
@Contract(threading=SAFE_CONDITIONAL) public abstract class AbstractNIOConnPool<T,C,E extends PoolEntry<T,C>> extends java.lang.Object implements ConnPool<T,E>, ConnPoolControl<T>
Abstract non-blocking connection pool.- Since:
- 4.2
-
-
Constructor Summary
Constructors Constructor Description AbstractNIOConnPool(ConnectingIOReactor ioreactor, NIOConnFactory<T,C> connFactory, int defaultMaxPerRoute, int maxTotal)
AbstractNIOConnPool(ConnectingIOReactor ioreactor, NIOConnFactory<T,C> connFactory, SocketAddressResolver<T> addressResolver, int defaultMaxPerRoute, int maxTotal)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
closeExpired()
void
closeIdle(long idletime, java.util.concurrent.TimeUnit tunit)
int
getDefaultMaxPerRoute()
int
getMaxPerRoute(T route)
int
getMaxTotal()
java.util.Set<T>
getRoutes()
Returns snapshot of all knows routesPoolStats
getStats(T route)
PoolStats
getTotalStats()
boolean
isShutdown()
java.util.concurrent.Future<E>
lease(T route, java.lang.Object state)
java.util.concurrent.Future<E>
lease(T route, java.lang.Object state, long connectTimeout, long leaseTimeout, java.util.concurrent.TimeUnit tunit, FutureCallback<E> callback)
java.util.concurrent.Future<E>
lease(T route, java.lang.Object state, long connectTimeout, java.util.concurrent.TimeUnit tunit, FutureCallback<E> callback)
java.util.concurrent.Future<E>
lease(T route, java.lang.Object state, FutureCallback<E> callback)
Attempts to lease a connection for the given route and with the given state from the pool.void
release(E entry, boolean reusable)
Releases the pool entry back to the pool.void
setDefaultMaxPerRoute(int max)
void
setMaxPerRoute(T route, int max)
void
setMaxTotal(int max)
void
shutdown(long waitMs)
java.lang.String
toString()
void
validatePendingRequests()
-
-
-
Constructor Detail
-
AbstractNIOConnPool
@Deprecated public AbstractNIOConnPool(ConnectingIOReactor ioreactor, NIOConnFactory<T,C> connFactory, int defaultMaxPerRoute, int maxTotal)
-
AbstractNIOConnPool
public AbstractNIOConnPool(ConnectingIOReactor ioreactor, NIOConnFactory<T,C> connFactory, SocketAddressResolver<T> addressResolver, int defaultMaxPerRoute, int maxTotal)
- Since:
- 4.3
-
-
Method Detail
-
isShutdown
public boolean isShutdown()
-
shutdown
public void shutdown(long waitMs) throws java.io.IOException
- Throws:
java.io.IOException
-
lease
public java.util.concurrent.Future<E> lease(T route, java.lang.Object state, long connectTimeout, java.util.concurrent.TimeUnit tunit, FutureCallback<E> callback)
-
lease
public java.util.concurrent.Future<E> lease(T route, java.lang.Object state, long connectTimeout, long leaseTimeout, java.util.concurrent.TimeUnit tunit, FutureCallback<E> callback)
- Since:
- 4.3
-
lease
public java.util.concurrent.Future<E> lease(T route, java.lang.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 interfaceConnPool<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 benull
.callback
- operation completion callback.- Returns:
- future for a leased pool entry.
-
release
public void release(E entry, boolean reusable)
Description copied from interface:ConnPool
Releases the pool entry back to the pool.
-
validatePendingRequests
public void validatePendingRequests()
-
setMaxTotal
public void setMaxTotal(int max)
- Specified by:
setMaxTotal
in interfaceConnPoolControl<T>
-
getMaxTotal
public int getMaxTotal()
- Specified by:
getMaxTotal
in interfaceConnPoolControl<T>
-
setDefaultMaxPerRoute
public void setDefaultMaxPerRoute(int max)
- Specified by:
setDefaultMaxPerRoute
in interfaceConnPoolControl<T>
-
getDefaultMaxPerRoute
public int getDefaultMaxPerRoute()
- Specified by:
getDefaultMaxPerRoute
in interfaceConnPoolControl<T>
-
setMaxPerRoute
public void setMaxPerRoute(T route, int max)
- Specified by:
setMaxPerRoute
in interfaceConnPoolControl<T>
-
getMaxPerRoute
public int getMaxPerRoute(T route)
- Specified by:
getMaxPerRoute
in interfaceConnPoolControl<T>
-
getTotalStats
public PoolStats getTotalStats()
- Specified by:
getTotalStats
in interfaceConnPoolControl<T>
-
getStats
public PoolStats getStats(T route)
- Specified by:
getStats
in interfaceConnPoolControl<T>
-
getRoutes
public java.util.Set<T> getRoutes()
Returns snapshot of all knows routes- Since:
- 4.4
-
closeIdle
public void closeIdle(long idletime, java.util.concurrent.TimeUnit tunit)
-
closeExpired
public void closeExpired()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-