Top Description Inners Fields Constructors Methods
org.apache.hc.core5.pool

public Class LaxConnPool<T, C extends org.apache.hc.core5.io.ModalCloseable>

extends Object
implements ManagedConnPool<T, C extends ModalCloseable>
Class Inheritance
All Implemented Interfaces
org.apache.hc.core5.pool.ManagedConnPool, org.apache.hc.core5.io.ModalCloseable, java.io.Closeable, java.lang.AutoCloseable, org.apache.hc.core5.pool.ConnPoolControl, org.apache.hc.core5.pool.ConnPoolStats, org.apache.hc.core5.pool.ConnPool
Annotations
@Contract
threading:SAFE
@Experimental
Type Parameters
<T>
route
<C>
connection object
Imports
java.util.Deque, .HashSet, .Iterator, .Objects, .Set, java.util.concurrent.ConcurrentHashMap, .ConcurrentLinkedDeque, .ConcurrentMap, .ExecutionException, .Future, .TimeUnit, .TimeoutException, java.util.concurrent.atomic.AtomicBoolean, .AtomicInteger, .AtomicLong, .AtomicMarkableReference, org.apache.hc.core5.annotation.Contract, .Experimental, .ThreadingBehavior, org.apache.hc.core5.concurrent.BasicFuture, .Cancellable, .FutureCallback, org.apache.hc.core5.function.Callback, org.apache.hc.core5.io.CloseMode, .ModalCloseable, org.apache.hc.core5.util.Args, .Asserts, .Deadline, .DeadlineTimeoutException, .TimeValue, .Timeout

Connection pool with higher concurrency but with lax connection limit guarantees.
Since
5.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv static class

Field Summary

Modifier and TypeField and Description
private final ConnPoolListener<T>
private volatile int
private final DisposalCallback<C>
private final AtomicBoolean
private final PoolReusePolicy
private final ConcurrentMap<T, LaxConnPool.PerRoutePool<T, C>>
private final TimeValue

Constructor Summary

AccessConstructor and Description
public
LaxConnPool(final int defaultMaxPerRoute, final TimeValue timeToLive, final PoolReusePolicy policy, final DisposalCallback<C> disposalCallback, final ConnPoolListener<T> connPoolListener)

public
LaxConnPool(final int defaultMaxPerRoute, final TimeValue timeToLive, final PoolReusePolicy policy, final ConnPoolListener<T> connPoolListener)

public
LaxConnPool(final int defaultMaxPerRoute)

Method Summary

Modifier and TypeMethod and Description
public void
close(final CloseMode
How to close the receiver.
closeMode
)

Implements org.apache.hc.core5.io.ModalCloseable.close.

Closes this process or endpoint and releases any system resources associated with it.
public void
close()

Implements java.io.Closeable.close.

Closes this stream and releases any system resources associated with it.
public void
public void
public void
enumAvailable(final Callback<PoolEntry<T, C>> callback)

public void
enumLeased(final Callback<PoolEntry<T, C>> callback)

public int
public int
public int
private LaxConnPool.PerRoutePool<T, C>
getPool(final T route)

public Set<T>
public PoolStats
public PoolStats
public boolean
public Future<PoolEntry<T, C>>
lease(final T
route of the connection.
route
,
final Object
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.
state
,
final Timeout
request timeout. In case of a timeout the request can get automatically cancelled by the pool.
requestTimeout
,
final FutureCallback<PoolEntry<T, C>>
operation completion callback.
callback
)

Implements org.apache.hc.core5.pool.ConnPool.lease.

Attempts to lease a connection for the given route and with the given state from the pool.
public Future<PoolEntry<T, C>>
lease(final T route, final Object state)

public void
release(final PoolEntry<T, C>
pool entry leased from the pool
entry
,
final boolean
flag indicating whether or not the released connection is in a consistent state and is safe for further use.
reusable
)

Implements org.apache.hc.core5.pool.ConnPool.release.

Releases the pool entry back to the pool.
public void
public void
public void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

connPoolListenerback to summary
private final ConnPoolListener<T> connPoolListener
defaultMaxPerRouteback to summary
private volatile int defaultMaxPerRoute
disposalCallbackback to summary
private final DisposalCallback<C> disposalCallback
isShutDownback to summary
private final AtomicBoolean isShutDown
policyback to summary
private final PoolReusePolicy policy
routeToPoolback to summary
private final ConcurrentMap<T, LaxConnPool.PerRoutePool<T, C>> routeToPool
timeToLiveback to summary
private final TimeValue timeToLive

Constructor Detail

LaxConnPoolback to summary
public LaxConnPool(final int defaultMaxPerRoute, final TimeValue timeToLive, final PoolReusePolicy policy, final DisposalCallback<C> disposalCallback, final ConnPoolListener<T> connPoolListener)
Since
5.0
LaxConnPoolback to summary
public LaxConnPool(final int defaultMaxPerRoute, final TimeValue timeToLive, final PoolReusePolicy policy, final ConnPoolListener<T> connPoolListener)
Since
5.0
LaxConnPoolback to summary
public LaxConnPool(final int defaultMaxPerRoute)

Method Detail

closeback to summary
public void close(final CloseMode closeMode)

Implements org.apache.hc.core5.io.ModalCloseable.close.

Doc from org.apache.hc.core5.io.ModalCloseable.close.

Closes this process or endpoint and releases any system resources associated with it. If the endpoint or the process is already closed then invoking this method has no effect.

Parameters
closeMode:CloseMode

How to close the receiver.

Annotations
@Override
closeback to summary
public void close()

Implements java.io.Closeable.close.

Doc from java.io.Closeable.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

Annotations
@Override
closeExpiredback to summary
public void closeExpired()

Implements org.apache.hc.core5.pool.ConnPoolControl.closeExpired.

Annotations
@Override
closeIdleback to summary
public void closeIdle(final TimeValue idleTime)

Implements org.apache.hc.core5.pool.ConnPoolControl.closeIdle.

Annotations
@Override
enumAvailableback to summary
public void enumAvailable(final Callback<PoolEntry<T, C>> callback)
enumLeasedback to summary
public void enumLeased(final Callback<PoolEntry<T, C>> callback)
getDefaultMaxPerRouteback to summary
public int getDefaultMaxPerRoute()

Implements org.apache.hc.core5.pool.ConnPoolControl.getDefaultMaxPerRoute.

Annotations
@Override
getMaxPerRouteback to summary
public int getMaxPerRoute(final T route)

Implements org.apache.hc.core5.pool.ConnPoolControl.getMaxPerRoute.

Annotations
@Override
getMaxTotalback to summary
public int getMaxTotal()

Implements org.apache.hc.core5.pool.ConnPoolControl.getMaxTotal.

Annotations
@Override
getPoolback to summary
private LaxConnPool.PerRoutePool<T, C> getPool(final T route)
getRoutesback to summary
public Set<T> getRoutes()

Implements org.apache.hc.core5.pool.ConnPoolControl.getRoutes.

Annotations
@Override
getStatsback to summary
public PoolStats getStats(final T route)

Implements org.apache.hc.core5.pool.ConnPoolStats.getStats.

Annotations
@Override
getTotalStatsback to summary
public PoolStats getTotalStats()

Implements org.apache.hc.core5.pool.ConnPoolStats.getTotalStats.

Annotations
@Override
isShutdownback to summary
public boolean isShutdown()
leaseback to summary
public Future<PoolEntry<T, C>> lease(final T route, final Object state, final Timeout requestTimeout, final FutureCallback<PoolEntry<T, C>> callback)

Implements org.apache.hc.core5.pool.ConnPool.lease.

Doc from org.apache.hc.core5.pool.ConnPool.lease.

Attempts to lease a connection for the given route and with the given state from the pool.

Please note the connection request can get automatically cancelled by the pool in case of a request timeout.

Parameters
route:T

route of the connection.

state:Object

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.

requestTimeout:Timeout

request timeout. In case of a timeout the request can get automatically cancelled by the pool.

callback:FutureCallback<PoolEntry<T, C>>

operation completion callback.

Returns:Future<PoolEntry<T, C>>

future for a leased pool entry.

Annotations
@Override
leaseback to summary
public Future<PoolEntry<T, C>> lease(final T route, final Object state)
releaseback to summary
public void release(final PoolEntry<T, C> entry, final boolean reusable)

Implements org.apache.hc.core5.pool.ConnPool.release.

Doc from org.apache.hc.core5.pool.ConnPool.release.

Releases the pool entry back to the pool.

Parameters
entry:PoolEntry<T, C>

pool entry leased from the pool

reusable:boolean

flag indicating whether or not the released connection is in a consistent state and is safe for further use.

Annotations
@Override
setDefaultMaxPerRouteback to summary
public void setDefaultMaxPerRoute(final int max)

Implements org.apache.hc.core5.pool.ConnPoolControl.setDefaultMaxPerRoute.

Annotations
@Override
setMaxPerRouteback to summary
public void setMaxPerRoute(final T route, final int max)

Implements org.apache.hc.core5.pool.ConnPoolControl.setMaxPerRoute.

Annotations
@Override
setMaxTotalback to summary
public void setMaxTotal(final int max)

Implements org.apache.hc.core5.pool.ConnPoolControl.setMaxTotal.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
validatePendingRequestsback to summary
public void validatePendingRequests()
org.apache.hc.core5.pool back to summary

pack-priv Class LaxConnPool.LeaseRequest<T, C extends org.apache.hc.core5.io.ModalCloseable>

extends Object
implements Cancellable
Class Inheritance
All Implemented Interfaces
org.apache.hc.core5.concurrent.Cancellable

Field Summary

Modifier and TypeField and Description
private final Deadline
private final BasicFuture<PoolEntry<T, C>>
private final Object

Constructor Summary

AccessConstructor and Description
pack-priv
LeaseRequest(final Object state, final Timeout requestTimeout, final BasicFuture<PoolEntry<T, C>> future)

Method Summary

Modifier and TypeMethod and Description
public boolean
cancel()

Implements org.apache.hc.core5.concurrent.Cancellable.cancel.

Cancels the ongoing operation or process.
public boolean
completed(final PoolEntry<T, C> result)

public boolean
failed(final Exception ex)

public Deadline
pack-priv BasicFuture<PoolEntry<T, C>>
public Object
public boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

deadlineback to summary
private final Deadline deadline
futureback to summary
private final BasicFuture<PoolEntry<T, C>> future
stateback to summary
private final Object state

Constructor Detail

LeaseRequestback to summary
pack-priv LeaseRequest(final Object state, final Timeout requestTimeout, final BasicFuture<PoolEntry<T, C>> future)

Method Detail

cancelback to summary
public boolean cancel()

Implements org.apache.hc.core5.concurrent.Cancellable.cancel.

Doc from org.apache.hc.core5.concurrent.Cancellable.cancel.

Cancels the ongoing operation or process.

Returns:boolean

true if the operation or process has been cancelled as a result of this method call or false if it has already been cancelled or not started.

Annotations
@Override
completedback to summary
public boolean completed(final PoolEntry<T, C> result)
failedback to summary
public boolean failed(final Exception ex)
getDeadlineback to summary
public Deadline getDeadline()
getFutureback to summary
pack-priv BasicFuture<PoolEntry<T, C>> getFuture()
getStateback to summary
public Object getState()
isDoneback to summary
public boolean isDone()
org.apache.hc.core5.pool back to summary

pack-priv Class LaxConnPool.PerRoutePool<T, C extends org.apache.hc.core5.io.ModalCloseable>

extends Object
Class Inheritance

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum

Field Summary

Modifier and TypeField and Description
private final AtomicInteger
private final Deque<AtomicMarkableReference<PoolEntry<T, C>>>
private final ConnPoolListener<T>
private final ConnPoolStats<T>
private final DisposalCallback<C>
private final ConcurrentMap<PoolEntry<T, C>, Boolean>
private volatile int
private final Deque<LaxConnPool.LeaseRequest<T, C>>
private final PoolReusePolicy
private final AtomicLong
private final T
private final AtomicBoolean
private final TimeValue

Constructor Summary

AccessConstructor and Description
pack-priv
PerRoutePool(final T route, final int max, final TimeValue timeToLive, final PoolReusePolicy policy, final ConnPoolStats<T> connPoolStats, final DisposalCallback<C> disposalCallback, final ConnPoolListener<T> connPoolListener)

Method Summary

Modifier and TypeMethod and Description
private void
addLeased(final PoolEntry<T, C> entry)

private PoolEntry<T, C>
private void
public void
enumAvailable(final Callback<PoolEntry<T, C>> callback)

public void
enumLeased(final Callback<PoolEntry<T, C>> callback)

public int
private PoolEntry<T, C>
public int
public int
public int
public final T
public Future<PoolEntry<T, C>>
lease(final Object state, final Timeout requestTimeout, final FutureCallback<PoolEntry<T, C>> callback)

public void
release(final PoolEntry<T, C> releasedEntry, final boolean reusable)

private void
removeLeased(final PoolEntry<T, C> entry)

private void
private void
public void
setMax(final int max)

public void
shutdown(final CloseMode closeMode)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

allocatedback to summary
private final AtomicInteger allocated
availableback to summary
private final Deque<AtomicMarkableReference<PoolEntry<T, C>>> available
connPoolListenerback to summary
private final ConnPoolListener<T> connPoolListener
connPoolStatsback to summary
private final ConnPoolStats<T> connPoolStats
disposalCallbackback to summary
private final DisposalCallback<C> disposalCallback
leasedback to summary
private final ConcurrentMap<PoolEntry<T, C>, Boolean> leased
maxback to summary
private volatile int max
pendingback to summary
private final Deque<LaxConnPool.LeaseRequest<T, C>> pending
policyback to summary
private final PoolReusePolicy policy
releaseSeqNumback to summary
private final AtomicLong releaseSeqNum
routeback to summary
private final T route
terminatedback to summary
private final AtomicBoolean terminated
timeToLiveback to summary
private final TimeValue timeToLive

Constructor Detail

PerRoutePoolback to summary
pack-priv PerRoutePool(final T route, final int max, final TimeValue timeToLive, final PoolReusePolicy policy, final ConnPoolStats<T> connPoolStats, final DisposalCallback<C> disposalCallback, final ConnPoolListener<T> connPoolListener)

Method Detail

addLeasedback to summary
private void addLeased(final PoolEntry<T, C> entry)
createPoolEntryback to summary
private PoolEntry<T, C> createPoolEntry()
deallocatePoolEntryback to summary
private void deallocatePoolEntry()
enumAvailableback to summary
public void enumAvailable(final Callback<PoolEntry<T, C>> callback)
enumLeasedback to summary
public void enumLeased(final Callback<PoolEntry<T, C>> callback)
getAvailableCountback to summary
public int getAvailableCount()
getAvailableEntryback to summary
private PoolEntry<T, C> getAvailableEntry(final Object state)
getLeasedCountback to summary
public int getLeasedCount()
getMaxback to summary
public int getMax()
getPendingCountback to summary
public int getPendingCount()
getRouteback to summary
public final T getRoute()
leaseback to summary
public Future<PoolEntry<T, C>> lease(final Object state, final Timeout requestTimeout, final FutureCallback<PoolEntry<T, C>> callback)
releaseback to summary
public void release(final PoolEntry<T, C> releasedEntry, final boolean reusable)
removeLeasedback to summary
private void removeLeased(final PoolEntry<T, C> entry)
servicePendingRequestback to summary
private void servicePendingRequest()
servicePendingRequestsback to summary
private void servicePendingRequests(final LaxConnPool.PerRoutePool.RequestServiceStrategy serviceStrategy)
setMaxback to summary
public void setMax(final int max)
shutdownback to summary
public void shutdown(final CloseMode closeMode)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
validatePendingRequestsback to summary
public void validatePendingRequests()
org.apache.hc.core5.pool back to summary

private final Enum LaxConnPool.PerRoutePool.RequestServiceStrategy

extends Enum<LaxConnPool.PerRoutePool.RequestServiceStrategy>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final LaxConnPool.PerRoutePool.RequestServiceStrategy
public static final LaxConnPool.PerRoutePool.RequestServiceStrategy

Constructor Summary

AccessConstructor and Description
private

Field Detail

ALLback to summary
public static final LaxConnPool.PerRoutePool.RequestServiceStrategy ALL
FIRST_SUCCESSFULback to summary
public static final LaxConnPool.PerRoutePool.RequestServiceStrategy FIRST_SUCCESSFUL

Constructor Detail

RequestServiceStrategyback to summary
private RequestServiceStrategy()

Method Detail

valueOfback to summary
public static LaxConnPool.PerRoutePool.RequestServiceStrategy valueOf(String name)
valuesback to summary
public static LaxConnPool.PerRoutePool.RequestServiceStrategy[] values()