Package reactor.netty.http.client
Class Http2AllocationStrategy
java.lang.Object
reactor.netty.http.client.Http2AllocationStrategy
- All Implemented Interfaces:
ConnectionProvider.AllocationStrategy<Http2AllocationStrategy>
public final class Http2AllocationStrategy
extends Object
implements ConnectionProvider.AllocationStrategy<Http2AllocationStrategy>
HTTP/2
ConnectionProvider.AllocationStrategy
.
This class is based on https://github.com/reactor/reactor-pool/blob/d5cb5b72cdbcbbee8d781e06972c4da21766107f/src/main/java/reactor/pool/AllocationStrategies.java#L73
- Since:
- 1.0.20
- Author:
- Violeta Georgieva
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionbuilder()
Creates a builder forHttp2AllocationStrategy
.copy()
Returns a deep copy of this instance.int
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 adesired
positive number of new connections.long
Returns the configured maximum number of the concurrent streams that can be opened to the remote peer.int
Returns the best estimate of the number of permits currently granted, between 0 andInteger.MAX_VALUE
.int
Returns the maximum number of permits this strategy can grant in total, orInteger.MAX_VALUE
for unbounded.int
Return the minimum number of permits this strategy tries to maintain granted (reflecting a minimal size for the pool), or0
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.
-
Method Details
-
builder
Creates a builder forHttp2AllocationStrategy
.- Returns:
- a new
Http2AllocationStrategy.Builder
-
copy
Description copied from interface:ConnectionProvider.AllocationStrategy
Returns a deep copy of this instance.- Specified by:
copy
in interfaceConnectionProvider.AllocationStrategy<Http2AllocationStrategy>
- Returns:
- a deep copy of this instance
-
estimatePermitCount
public int estimatePermitCount()Description copied from interface:ConnectionProvider.AllocationStrategy
Best-effort peek at the state of the strategy which indicates roughly how many more connections can currently be allocated. Should be paired withConnectionProvider.AllocationStrategy.getPermits(int)
for an atomic permission.- Specified by:
estimatePermitCount
in interfaceConnectionProvider.AllocationStrategy<Http2AllocationStrategy>
- Returns:
- an ESTIMATED count of how many more connections can currently be allocated
-
getPermits
public int getPermits(int desired) Description copied from interface:ConnectionProvider.AllocationStrategy
Try to get the permission to allocate adesired
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 thandesired
. Once a connection is discarded from the pool, it must update the strategy usingConnectionProvider.AllocationStrategy.returnPermits(int)
(which can happen in batches or with value 1).- Specified by:
getPermits
in interfaceConnectionProvider.AllocationStrategy<Http2AllocationStrategy>
- Parameters:
desired
- the desired number of new connections- Returns:
- the actual number of new connections that MUST be created, can be 0 and can be more than
desired
-
maxConcurrentStreams
public long maxConcurrentStreams()Returns the configured maximum number of the concurrent streams that can be opened to the remote peer.- Returns:
- the configured maximum number of the concurrent streams that can be opened to the remote peer
-
permitGranted
public int permitGranted()Description copied from interface:ConnectionProvider.AllocationStrategy
Returns the best estimate of the number of permits currently granted, between 0 andInteger.MAX_VALUE
.- Specified by:
permitGranted
in interfaceConnectionProvider.AllocationStrategy<Http2AllocationStrategy>
- Returns:
- the best estimate of the number of permits currently granted, between 0 and
Integer.MAX_VALUE
-
permitMinimum
public int permitMinimum()Description copied from interface:ConnectionProvider.AllocationStrategy
Return the minimum number of permits this strategy tries to maintain granted (reflecting a minimal size for the pool), or0
for scale-to-zero.- Specified by:
permitMinimum
in interfaceConnectionProvider.AllocationStrategy<Http2AllocationStrategy>
- Returns:
- the minimum number of permits this strategy tries to maintain, or
0
-
permitMaximum
public int permitMaximum()Description copied from interface:ConnectionProvider.AllocationStrategy
Returns the maximum number of permits this strategy can grant in total, orInteger.MAX_VALUE
for unbounded.- Specified by:
permitMaximum
in interfaceConnectionProvider.AllocationStrategy<Http2AllocationStrategy>
- Returns:
- the maximum number of permits this strategy can grant in total, or
Integer.MAX_VALUE
for unbounded
-
returnPermits
public void returnPermits(int returned) Description copied from interface:ConnectionProvider.AllocationStrategy
Update the strategy to indicate that N connections were discarded, potentially leaving space for N new ones to be allocated. Users MUST ensure that this method isn't called with a value greater than the number of held permits it has.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.- Specified by:
returnPermits
in interfaceConnectionProvider.AllocationStrategy<Http2AllocationStrategy>
-