public final class Http2AllocationStrategy extends Object implements ConnectionProvider.AllocationStrategy<Http2AllocationStrategy>
ConnectionProvider.AllocationStrategy
.
This class is based on https://github.com/reactor/reactor-pool/blob/d5cb5b72cdbcbbee8d781e06972c4da21766107f/src/main/java/reactor/pool/AllocationStrategies.java#L73
Modifier and Type | Class and Description |
---|---|
static interface |
Http2AllocationStrategy.Builder |
Modifier and Type | Method and Description |
---|---|
static Http2AllocationStrategy.Builder |
builder()
Creates a builder for
Http2AllocationStrategy . |
Http2AllocationStrategy |
copy()
Returns a deep copy of this instance.
|
int |
estimatePermitCount()
Best-effort peek at the state of the strategy which indicates roughly how many more connections can currently be
allocated.
|
int |
getPermits(int desired)
Try to get the permission to allocate a
desired positive number of new connections. |
long |
maxConcurrentStreams()
Returns the configured maximum number of the concurrent streams that can be opened to the remote peer.
|
int |
permitGranted()
Returns the best estimate of the number of permits currently granted, between 0 and
Integer.MAX_VALUE . |
int |
permitMaximum()
Returns the maximum number of permits this strategy can grant in total, or
Integer.MAX_VALUE for unbounded. |
int |
permitMinimum()
Return the minimum number of permits this strategy tries to maintain granted
(reflecting a minimal size for the pool), or
0 for scale-to-zero. |
void |
returnPermits(int returned)
Update the strategy to indicate that N connections were discarded, potentially leaving space
for N new ones to be allocated.
|
public static Http2AllocationStrategy.Builder builder()
Http2AllocationStrategy
.Http2AllocationStrategy.Builder
public Http2AllocationStrategy copy()
ConnectionProvider.AllocationStrategy
copy
in interface ConnectionProvider.AllocationStrategy<Http2AllocationStrategy>
public int estimatePermitCount()
ConnectionProvider.AllocationStrategy
ConnectionProvider.AllocationStrategy.getPermits(int)
for an atomic permission.estimatePermitCount
in interface ConnectionProvider.AllocationStrategy<Http2AllocationStrategy>
public int getPermits(int desired)
ConnectionProvider.AllocationStrategy
desired
positive number of new connections. Returns the permissible
number of connections which MUST be created (otherwise the internal live counter of the strategy might be off).
This permissible number might be zero, and it can also be a greater number than desired
.
Once a connection is discarded from the pool, it must update the strategy using ConnectionProvider.AllocationStrategy.returnPermits(int)
(which can happen in batches or with value 1).getPermits
in interface ConnectionProvider.AllocationStrategy<Http2AllocationStrategy>
desired
- the desired number of new connectionsdesired
public long maxConcurrentStreams()
public int permitGranted()
ConnectionProvider.AllocationStrategy
Integer.MAX_VALUE
.permitGranted
in interface ConnectionProvider.AllocationStrategy<Http2AllocationStrategy>
Integer.MAX_VALUE
public int permitMinimum()
ConnectionProvider.AllocationStrategy
0
for scale-to-zero.permitMinimum
in interface ConnectionProvider.AllocationStrategy<Http2AllocationStrategy>
0
public int permitMaximum()
ConnectionProvider.AllocationStrategy
Integer.MAX_VALUE
for unbounded.permitMaximum
in interface ConnectionProvider.AllocationStrategy<Http2AllocationStrategy>
Integer.MAX_VALUE
for unboundedpublic void returnPermits(int returned)
ConnectionProvider.AllocationStrategy
Some strategy MIGHT throw an IllegalArgumentException
if it can be determined the number of returned permits
is not consistent with the strategy's limits and delivered permits.
returnPermits
in interface ConnectionProvider.AllocationStrategy<Http2AllocationStrategy>