public class MaxConnectionsBasedStrategy extends java.lang.Object implements CompositeHttpClientBuilder.CloneablePoolLimitDeterminationStrategy
PoolLimitDeterminationStrategy that limits the pool based on a maximum connections limit.
This limit can be increased or decreased at runtime.| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_MAX_CONNECTIONS |
NO_DURATION, NO_ERROR, NO_TIME_UNIT, NO_VALUE| Constructor and Description |
|---|
MaxConnectionsBasedStrategy() |
MaxConnectionsBasedStrategy(int maxConnections) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
acquireCreationPermit(long acquireStartTime,
java.util.concurrent.TimeUnit timeUnit)
Attempts to acquire a creation permit.
|
CompositeHttpClientBuilder.CloneablePoolLimitDeterminationStrategy |
copy() |
int |
decrementMaxConnections(int decrementBy) |
int |
getAvailablePermits() |
int |
getMaxConnections() |
int |
incrementMaxConnections(int incrementBy) |
void |
onCompleted()
Marks the end of all event callbacks.
|
void |
onEvent(ClientMetricsEvent<?> event,
long duration,
java.util.concurrent.TimeUnit timeUnit,
java.lang.Throwable throwable,
java.lang.Object value)
Event callback for any
MetricsEvent. |
void |
onSubscribe()
A callback when this listener is subscribed to a
MetricEventsPublisher. |
public static final int DEFAULT_MAX_CONNECTIONS
public MaxConnectionsBasedStrategy()
public MaxConnectionsBasedStrategy(int maxConnections)
public boolean acquireCreationPermit(long acquireStartTime,
java.util.concurrent.TimeUnit timeUnit)
PoolLimitDeterminationStrategyacquireCreationPermit in interface PoolLimitDeterminationStrategyacquireStartTime - The start time for the acquire process in milliseconds since epoch.timeUnit - The timeunit for the acquire start time.true if the permit was acquired, false otherwise.public int incrementMaxConnections(int incrementBy)
public int decrementMaxConnections(int decrementBy)
public int getMaxConnections()
public int getAvailablePermits()
getAvailablePermits in interface PoolLimitDeterminationStrategypublic CompositeHttpClientBuilder.CloneablePoolLimitDeterminationStrategy copy()
copy in interface CompositeHttpClientBuilder.CloneablePoolLimitDeterminationStrategypublic void onEvent(ClientMetricsEvent<?> event, long duration, java.util.concurrent.TimeUnit timeUnit, java.lang.Throwable throwable, java.lang.Object value)
MetricEventsListenerMetricsEvent. The parameters passed are all the contextual information possible for
any event. There presence or absence will depend on the type of event.onEvent in interface MetricEventsListener<ClientMetricsEvent<?>>event - Event for which this callback has been invoked. This will never be nullduration - If the passed event is MetricsEvent.isTimed() then the actual duration, else
MetricEventsListener.NO_DURATIONtimeUnit - The time unit for the duration, if exists, else MetricEventsListener.NO_TIME_UNITthrowable - If the passed event is MetricsEvent.isError() then the cause of the error, else
MetricEventsListener.NO_ERRORvalue - If the passed event requires custom object to be passed, then that object, else MetricEventsListener.NO_VALUEpublic void onCompleted()
MetricEventsListeneronCompleted in interface MetricEventsListener<ClientMetricsEvent<?>>public void onSubscribe()
MetricEventsListenerMetricEventsPublisher.onSubscribe in interface MetricEventsListener<ClientMetricsEvent<?>>