Package com.google.cloud.grpc
Enum GcpManagedChannelOptions.ChannelPickStrategy
java.lang.Object
java.lang.Enum<GcpManagedChannelOptions.ChannelPickStrategy>
com.google.cloud.grpc.GcpManagedChannelOptions.ChannelPickStrategy
- All Implemented Interfaces:
Serializable,Comparable<GcpManagedChannelOptions.ChannelPickStrategy>
- Enclosing class:
- GcpManagedChannelOptions
public static enum GcpManagedChannelOptions.ChannelPickStrategy
extends Enum<GcpManagedChannelOptions.ChannelPickStrategy>
Strategy for picking the least busy channel from the pool.
This controls how a channel is selected when there is no affinity key or when a new affinity binding is being established.
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionScans all channels and picks the one with the lowest picker load: active streams plus active error penalty.Samples two channels at random with replacement and returns the one with lower picker load. -
Method Summary
Modifier and TypeMethodDescriptionReturns the enum constant of this type with the specified name.values()Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
LINEAR_SCAN
Scans all channels and picks the one with the lowest picker load: active streams plus active error penalty. Ties are broken by iteration order (lowest index wins). This is the legacy behavior.This strategy finds the global minimum but is susceptible to the thundering herd problem: under burst traffic, all concurrent callers observe the same minimum and pile onto the same channel.
-
POWER_OF_TWO
Samples two channels at random with replacement and returns the one with lower picker load. The first sample wins ties, with no channel-warmth preference. Inactive or draining samples are retried.This is the default strategy. It avoids the thundering herd problem. The trade-off is that it may not always find the global minimum, but in practice the difference is negligible because picker load is inherently racy.
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-