Top Description Inners Fields Constructors Methods
reactor.netty.http.client

public final Class Http2AllocationStrategy

extends Object
implements ConnectionProvider.AllocationStrategy<Http2AllocationStrategy>
Class Inheritance
All Implemented Interfaces
reactor.netty.resources.ConnectionProvider.AllocationStrategy
Imports
reactor.netty.resources.ConnectionProvider, java.util.concurrent.atomic.AtomicIntegerFieldUpdater

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

Author
Violeta Georgieva
Since
1.0.20

Nested and Inner Type Summary

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

Field Summary

Modifier and TypeField and Description
pack-priv final long
pack-priv final int
pack-priv final int
pack-priv volatile int
pack-priv static final AtomicIntegerFieldUpdater<Http2AllocationStrategy>

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv

Method Summary

Modifier and TypeMethod and Description
public static Http2AllocationStrategy.Builder
builder()

Creates a builder for Http2AllocationStrategy.

public Http2AllocationStrategy
copy()

Implements reactor.netty.resources.ConnectionProvider.AllocationStrategy.copy.

Returns a deep copy of this instance.
public int
estimatePermitCount()

Implements reactor.netty.resources.ConnectionProvider.AllocationStrategy.estimatePermitCount.

Best-effort peek at the state of the strategy which indicates roughly how many more connections can currently be allocated.
public int
getPermits(int
the desired number of new connections
desired
)

Implements reactor.netty.resources.ConnectionProvider.AllocationStrategy.getPermits.

Try to get the permission to allocate a desired positive number of new connections.
public long

Returns:

the configured maximum number of the concurrent streams that can be opened to the remote peer
maxConcurrentStreams
()

Returns the configured maximum number of the concurrent streams that can be opened to the remote peer.

public int
permitGranted()

Implements reactor.netty.resources.ConnectionProvider.AllocationStrategy.permitGranted.

Returns the best estimate of the number of permits currently granted, between 0 and Integer#MAX_VALUE.
public int
permitMaximum()

Implements reactor.netty.resources.ConnectionProvider.AllocationStrategy.permitMaximum.

Returns the maximum number of permits this strategy can grant in total, or Integer#MAX_VALUE for unbounded.
public int
permitMinimum()

Implements reactor.netty.resources.ConnectionProvider.AllocationStrategy.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.
public void
returnPermits(int returned)

Implements reactor.netty.resources.ConnectionProvider.AllocationStrategy.returnPermits.

Update the strategy to indicate that N connections were discarded, potentially leaving space for N new ones to be allocated.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

maxConcurrentStreamsback to summary
pack-priv final long maxConcurrentStreams
maxConnectionsback to summary
pack-priv final int maxConnections
minConnectionsback to summary
pack-priv final int minConnections
permitsback to summary
pack-priv volatile int permits
PERMITSback to summary
pack-priv static final AtomicIntegerFieldUpdater<Http2AllocationStrategy> PERMITS

Constructor Detail

Http2AllocationStrategyback to summary
pack-priv Http2AllocationStrategy(Http2AllocationStrategy.Build build)
Http2AllocationStrategyback to summary
pack-priv Http2AllocationStrategy(Http2AllocationStrategy copy)

Method Detail

builderback to summary
public static Http2AllocationStrategy.Builder builder()

Creates a builder for Http2AllocationStrategy.

Returns:Http2AllocationStrategy.Builder

a new Http2AllocationStrategy.Builder

copyback to summary
public Http2AllocationStrategy copy()

Implements reactor.netty.resources.ConnectionProvider.AllocationStrategy.copy.

Doc from reactor.netty.resources.ConnectionProvider.AllocationStrategy.copy.

Returns a deep copy of this instance.

Returns:Http2AllocationStrategy

a deep copy of this instance

Annotations
@Override
estimatePermitCountback to summary
public int estimatePermitCount()

Implements reactor.netty.resources.ConnectionProvider.AllocationStrategy.estimatePermitCount.

Doc from reactor.netty.resources.ConnectionProvider.AllocationStrategy.estimatePermitCount.

Best-effort peek at the state of the strategy which indicates roughly how many more connections can currently be allocated. Should be paired with getPermits(int) for an atomic permission.

Returns:int

an ESTIMATED count of how many more connections can currently be allocated

Annotations
@Override
getPermitsback to summary
public int getPermits(int desired)

Implements reactor.netty.resources.ConnectionProvider.AllocationStrategy.getPermits.

Doc from reactor.netty.resources.ConnectionProvider.AllocationStrategy.getPermits.

Try to get the permission to allocate a 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 returnPermits(int) (which can happen in batches or with value 1).

Parameters
desired:int

the desired number of new connections

Returns:int

the actual number of new connections that MUST be created, can be 0 and can be more than desired

Annotations
@Override
maxConcurrentStreamsback to summary
public long maxConcurrentStreams()

Returns the configured maximum number of the concurrent streams that can be opened to the remote peer.

Returns:long

the configured maximum number of the concurrent streams that can be opened to the remote peer

permitGrantedback to summary
public int permitGranted()

Implements reactor.netty.resources.ConnectionProvider.AllocationStrategy.permitGranted.

Doc from reactor.netty.resources.ConnectionProvider.AllocationStrategy.permitGranted.

Returns the best estimate of the number of permits currently granted, between 0 and Integer#MAX_VALUE.

Returns:int

the best estimate of the number of permits currently granted, between 0 and Integer#MAX_VALUE

Annotations
@Override
permitMaximumback to summary
public int permitMaximum()

Implements reactor.netty.resources.ConnectionProvider.AllocationStrategy.permitMaximum.

Doc from reactor.netty.resources.ConnectionProvider.AllocationStrategy.permitMaximum.

Returns the maximum number of permits this strategy can grant in total, or Integer#MAX_VALUE for unbounded.

Returns:int

the maximum number of permits this strategy can grant in total, or Integer#MAX_VALUE for unbounded

Annotations
@Override
permitMinimumback to summary
public int permitMinimum()

Implements reactor.netty.resources.ConnectionProvider.AllocationStrategy.permitMinimum.

Doc from reactor.netty.resources.ConnectionProvider.AllocationStrategy.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.

Returns:int

the minimum number of permits this strategy tries to maintain, or 0

Annotations
@Override
returnPermitsback to summary
public void returnPermits(int returned)

Implements reactor.netty.resources.ConnectionProvider.AllocationStrategy.returnPermits.

Doc from reactor.netty.resources.ConnectionProvider.AllocationStrategy.returnPermits.

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.

Annotations
@Override
reactor.netty.http.client back to summary

pack-priv final Class Http2AllocationStrategy.Build

extends Object
implements Builder
Class Inheritance
All Implemented Interfaces
reactor.netty.http.client.Http2AllocationStrategy.Builder

Field Summary

Modifier and TypeField and Description
pack-priv static final long
pack-priv static final int
pack-priv static final int
pack-priv long
pack-priv int
pack-priv int

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public Http2AllocationStrategy
public Http2AllocationStrategy.Builder
maxConcurrentStreams(long
the maximum number of the concurrent streams that can be opened to the remote peer
maxConcurrentStreams
)

Implements reactor.netty.http.client.Http2AllocationStrategy.Builder.maxConcurrentStreams.

Configures the maximum number of the concurrent streams that can be opened to the remote peer.
public Http2AllocationStrategy.Builder
maxConnections(int
the maximum number of live connections to keep in the pool
maxConnections
)

Implements reactor.netty.http.client.Http2AllocationStrategy.Builder.maxConnections.

Configures the maximum number of live connections to keep in the pool.
public Http2AllocationStrategy.Builder
minConnections(int minConnections)

Implements reactor.netty.http.client.Http2AllocationStrategy.Builder.minConnections.

Configures the minimum number of live connections to keep in the pool (can be the best effort).
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_MAX_CONCURRENT_STREAMSback to summary
pack-priv static final long DEFAULT_MAX_CONCURRENT_STREAMS
DEFAULT_MAX_CONNECTIONSback to summary
pack-priv static final int DEFAULT_MAX_CONNECTIONS
DEFAULT_MIN_CONNECTIONSback to summary
pack-priv static final int DEFAULT_MIN_CONNECTIONS
maxConcurrentStreamsback to summary
pack-priv long maxConcurrentStreams
maxConnectionsback to summary
pack-priv int maxConnections
minConnectionsback to summary
pack-priv int minConnections

Constructor Detail

Buildback to summary
pack-priv Build()

Method Detail

buildback to summary
public Http2AllocationStrategy build()

Implements reactor.netty.http.client.Http2AllocationStrategy.Builder.build.

Doc from reactor.netty.http.client.Http2AllocationStrategy.Builder.build.

Build a new Http2AllocationStrategy.

Returns:Http2AllocationStrategy

a new Http2AllocationStrategy

Annotations
@Override
maxConcurrentStreamsback to summary
public Http2AllocationStrategy.Builder maxConcurrentStreams(long maxConcurrentStreams)

Implements reactor.netty.http.client.Http2AllocationStrategy.Builder.maxConcurrentStreams.

Doc from reactor.netty.http.client.Http2AllocationStrategy.Builder.maxConcurrentStreams.

Configures the maximum number of the concurrent streams that can be opened to the remote peer. When evaluating how many streams can be opened to the remote peer, the minimum of this configuration and the remote peer configuration is taken (unless -1 is used). Default to -1 - use always the remote peer configuration.

Parameters
maxConcurrentStreams:long

the maximum number of the concurrent streams that can be opened to the remote peer

Returns:Http2AllocationStrategy.Builder

this

Annotations
@Override
maxConnectionsback to summary
public Http2AllocationStrategy.Builder maxConnections(int maxConnections)

Implements reactor.netty.http.client.Http2AllocationStrategy.Builder.maxConnections.

Doc from reactor.netty.http.client.Http2AllocationStrategy.Builder.maxConnections.

Configures the maximum number of live connections to keep in the pool. Default to Integer#MAX_VALUE - no upper limit.

Parameters
maxConnections:int

the maximum number of live connections to keep in the pool

Returns:Http2AllocationStrategy.Builder

this

Annotations
@Override
minConnectionsback to summary
public Http2AllocationStrategy.Builder minConnections(int minConnections)

Implements reactor.netty.http.client.Http2AllocationStrategy.Builder.minConnections.

Doc from reactor.netty.http.client.Http2AllocationStrategy.Builder.minConnections.

Configures the minimum number of live connections to keep in the pool (can be the best effort). Default to 0.

Returns:Http2AllocationStrategy.Builder

this

Annotations
@Override
reactor.netty.http.client back to summary

public Interface Http2AllocationStrategy.Builder

Known Direct Implementers
reactor.netty.http.client.Http2AllocationStrategy.Build

Method Summary

Modifier and TypeMethod and Description
public Http2AllocationStrategy
public Http2AllocationStrategy.Builder

Returns:

this
maxConcurrentStreams
(long
the maximum number of the concurrent streams that can be opened to the remote peer
maxConcurrentStreams
)

Configures the maximum number of the concurrent streams that can be opened to the remote peer.

public Http2AllocationStrategy.Builder

Returns:

this
maxConnections
(int
the maximum number of live connections to keep in the pool
maxConnections
)

Configures the maximum number of live connections to keep in the pool.

public Http2AllocationStrategy.Builder

Returns:

this
minConnections
(int minConnections)

Configures the minimum number of live connections to keep in the pool (can be the best effort).

Method Detail

buildback to summary
public Http2AllocationStrategy build()

Build a new Http2AllocationStrategy.

Returns:Http2AllocationStrategy

a new Http2AllocationStrategy

maxConcurrentStreamsback to summary
public Http2AllocationStrategy.Builder maxConcurrentStreams(long maxConcurrentStreams)

Configures the maximum number of the concurrent streams that can be opened to the remote peer. When evaluating how many streams can be opened to the remote peer, the minimum of this configuration and the remote peer configuration is taken (unless -1 is used). Default to -1 - use always the remote peer configuration.

Parameters
maxConcurrentStreams:long

the maximum number of the concurrent streams that can be opened to the remote peer

Returns:Http2AllocationStrategy.Builder

this

maxConnectionsback to summary
public Http2AllocationStrategy.Builder maxConnections(int maxConnections)

Configures the maximum number of live connections to keep in the pool. Default to Integer#MAX_VALUE - no upper limit.

Parameters
maxConnections:int

the maximum number of live connections to keep in the pool

Returns:Http2AllocationStrategy.Builder

this

minConnectionsback to summary
public Http2AllocationStrategy.Builder minConnections(int minConnections)

Configures the minimum number of live connections to keep in the pool (can be the best effort). Default to 0.

Returns:Http2AllocationStrategy.Builder

this