public static class GcpManagedChannelOptions.GcpChannelPoolOptions.BuilderConstructors
Builder()
public Builder()Builder(GcpManagedChannelOptions.GcpChannelPoolOptions options)
public Builder(GcpManagedChannelOptions.GcpChannelPoolOptions options)| Parameter | |
|---|---|
| Name | Description |
options |
GcpManagedChannelOptions.GcpChannelPoolOptions |
Methods
build()
public GcpManagedChannelOptions.GcpChannelPoolOptions build()| Returns | |
|---|---|
| Type | Description |
GcpManagedChannelOptions.GcpChannelPoolOptions |
|
disableDynamicScaling()
public GcpManagedChannelOptions.GcpChannelPoolOptions.Builder disableDynamicScaling()Disables dynamic scaling functionality. See Also: #setDynamicScaling(int, int, Duration)
| Returns | |
|---|---|
| Type | Description |
GcpManagedChannelOptions.GcpChannelPoolOptions.Builder |
|
setAffinityKeyLifetime(Duration affinityKeyLifetime)
public GcpManagedChannelOptions.GcpChannelPoolOptions.Builder setAffinityKeyLifetime(Duration affinityKeyLifetime)How long to keep an affinity key after its last use. Zero value means keeping keys forever.
| Parameter | |
|---|---|
| Name | Description |
affinityKeyLifetime |
Durationtime since last use of a key to include the key in a cleanup. |
| Returns | |
|---|---|
| Type | Description |
GcpManagedChannelOptions.GcpChannelPoolOptions.Builder |
|
setChannelPickStrategy(GcpManagedChannelOptions.ChannelPickStrategy strategy)
public GcpManagedChannelOptions.GcpChannelPoolOptions.Builder setChannelPickStrategy(GcpManagedChannelOptions.ChannelPickStrategy strategy)Sets the strategy for picking the least busy channel from the pool.
Defaults to ChannelPickStrategy#POWER_OF_TWO which avoids the thundering herd problem by randomly sampling two channels and picking the less busy one, with ties broken by channel warmth (most recently active).
Use ChannelPickStrategy#LINEAR_SCAN to restore the legacy behavior of scanning all channels and always picking the one with the fewest active streams.
| Parameter | |
|---|---|
| Name | Description |
strategy |
GcpManagedChannelOptions.ChannelPickStrategythe channel pick strategy to use. |
| Returns | |
|---|---|
| Type | Description |
GcpManagedChannelOptions.GcpChannelPoolOptions.Builder |
|
setCleanupInterval(Duration cleanupInterval)
public GcpManagedChannelOptions.GcpChannelPoolOptions.Builder setCleanupInterval(Duration cleanupInterval)How frequently affinity key cleanup process should run. Zero value disables cleanup process. If affinityKeyLifetime is not zero, this defaults to affinityKeyLifetime / 10.
| Parameter | |
|---|---|
| Name | Description |
cleanupInterval |
Durationfrequency of affinity key cleanup. |
| Returns | |
|---|---|
| Type | Description |
GcpManagedChannelOptions.GcpChannelPoolOptions.Builder |
|
setConcurrentStreamsLowWatermark(int concurrentStreamsLowWatermark)
public GcpManagedChannelOptions.GcpChannelPoolOptions.Builder setConcurrentStreamsLowWatermark(int concurrentStreamsLowWatermark)Sets the concurrent streams low watermark. If every channel in the pool has at least this amount of concurrent streams then a new channel will be created in the pool unless the pool reached its maximum size.
| Parameter | |
|---|---|
| Name | Description |
concurrentStreamsLowWatermark |
intnumber of streams every channel must reach before adding a new channel to the pool. |
| Returns | |
|---|---|
| Type | Description |
GcpManagedChannelOptions.GcpChannelPoolOptions.Builder |
|
setDynamicScaling(int minRpcPerChannel, int maxRpcPerChannel, Duration scaleDownInterval)
public GcpManagedChannelOptions.GcpChannelPoolOptions.Builder setDynamicScaling(int minRpcPerChannel, int maxRpcPerChannel, Duration scaleDownInterval)Enables dynamic scaling functionality.
When the average number of concurrent calls per channel reaches maxRpcPerChannel
the pool will create and add a new channel unless already at max size.
Every scaleDownInterval a check for downscaling is performed. Based on the
maximum total concurrent calls observed since the last check, the desired number of
channels is calculated as:
(max_total_concurrent_calls / minRpcPerChannel) rounded up.
If the calculated desired number of channels is lower than the current number of channels, the pool will be downscaled to the desired number or min size (whichever is greater).
When downscaling, channels with the oldest connections are selected. Then the selected channels are removed from the pool but are not instructed to shutdown until all calls are completed. In a case when the pool is scaling up and there is a ready channel awaiting calls completion, the channel will be re-used instead of creating a new channel.
| Parameters | |
|---|---|
| Name | Description |
minRpcPerChannel |
intminimum desired average concurrent calls per channel. |
maxRpcPerChannel |
intmaximum desired average concurrent calls per channel. |
scaleDownInterval |
Durationhow often to check for a possibility to scale down. |
| Returns | |
|---|---|
| Type | Description |
GcpManagedChannelOptions.GcpChannelPoolOptions.Builder |
|
setInitSize(int initSize)
public GcpManagedChannelOptions.GcpChannelPoolOptions.Builder setInitSize(int initSize)Sets the initial channel pool size. This is the number of channels that the pool will start with. If it is less than #setMinSize(int) it is ignored.
| Parameter | |
|---|---|
| Name | Description |
initSize |
intnumber of channels to start the pool with. |
| Returns | |
|---|---|
| Type | Description |
GcpManagedChannelOptions.GcpChannelPoolOptions.Builder |
|
setMaxSize(int maxSize)
public GcpManagedChannelOptions.GcpChannelPoolOptions.Builder setMaxSize(int maxSize)Sets the maximum size of the channel pool.
| Parameter | |
|---|---|
| Name | Description |
maxSize |
intmaximum number of channels the pool can have. |
| Returns | |
|---|---|
| Type | Description |
GcpManagedChannelOptions.GcpChannelPoolOptions.Builder |
|
setMinSize(int minSize)
public GcpManagedChannelOptions.GcpChannelPoolOptions.Builder setMinSize(int minSize)Sets the minimum size of the channel pool. This number of channels will be created and these channels will try to always keep connection to the server established.
| Parameter | |
|---|---|
| Name | Description |
minSize |
intminimum number of channels the pool must have. |
| Returns | |
|---|---|
| Type | Description |
GcpManagedChannelOptions.GcpChannelPoolOptions.Builder |
|
setUseRoundRobinOnBind(boolean enabled)
public GcpManagedChannelOptions.GcpChannelPoolOptions.Builder setUseRoundRobinOnBind(boolean enabled)Enables/disables using round-robin channel selection for affinity binding calls.
| Parameter | |
|---|---|
| Name | Description |
enabled |
booleanIf true, use round-robin channel selection for affinity binding calls. |
| Returns | |
|---|---|
| Type | Description |
GcpManagedChannelOptions.GcpChannelPoolOptions.Builder |
|