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)
PoolLimitDeterminationStrategy
acquireCreationPermit
in interface PoolLimitDeterminationStrategy
acquireStartTime
- 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 PoolLimitDeterminationStrategy
public CompositeHttpClientBuilder.CloneablePoolLimitDeterminationStrategy copy()
copy
in interface CompositeHttpClientBuilder.CloneablePoolLimitDeterminationStrategy
public void onEvent(ClientMetricsEvent<?> event, long duration, java.util.concurrent.TimeUnit timeUnit, java.lang.Throwable throwable, java.lang.Object value)
MetricEventsListener
MetricsEvent
. 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 null
duration
- If the passed event is MetricsEvent.isTimed()
then the actual duration, else
MetricEventsListener.NO_DURATION
timeUnit
- The time unit for the duration, if exists, else MetricEventsListener.NO_TIME_UNIT
throwable
- If the passed event is MetricsEvent.isError()
then the cause of the error, else
MetricEventsListener.NO_ERROR
value
- If the passed event requires custom object to be passed, then that object, else MetricEventsListener.NO_VALUE
public void onCompleted()
MetricEventsListener
onCompleted
in interface MetricEventsListener<ClientMetricsEvent<?>>
public void onSubscribe()
MetricEventsListener
MetricEventsPublisher
.onSubscribe
in interface MetricEventsListener<ClientMetricsEvent<?>>