Package io.grpc.grpclb
Class GrpclbLoadBalancerProvider
- java.lang.Object
-
- io.grpc.LoadBalancer.Factory
-
- io.grpc.LoadBalancerProvider
-
- io.grpc.grpclb.GrpclbLoadBalancerProvider
-
@Internal public final class GrpclbLoadBalancerProvider extends LoadBalancerProvider
The provider for the "grpclb" balancing policy. This class should not be directly referenced in code. The policy should be accessed throughLoadBalancerRegistry.getProvider(java.lang.String)
with the name "grpclb".
-
-
Field Summary
Fields Modifier and Type Field Description private static GrpclbState.Mode
DEFAULT_MODE
-
Constructor Summary
Constructors Constructor Description GrpclbLoadBalancerProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getPolicyName()
Returns the load-balancing policy name associated with this provider, which makes it selectable viaLoadBalancerRegistry.getProvider(java.lang.String)
.int
getPriority()
A priority, from 0 to 10 that this provider should be used, taking the current environment into consideration.boolean
isAvailable()
Whether this provider is available for use, taking the current environment into consideration.LoadBalancer
newLoadBalancer(LoadBalancer.Helper helper)
Creates aLoadBalancer
that will be used inside a channel.(package private) NameResolver.ConfigOrError
parseLoadBalancingConfigPolicyInternal(java.util.Map<java.lang.String,?> rawLoadBalancingPolicyConfig)
NameResolver.ConfigOrError
parseLoadBalancingPolicyConfig(java.util.Map<java.lang.String,?> rawLoadBalancingConfigPolicy)
Parses the config for the Load Balancing policy unpacked from the service config.-
Methods inherited from class io.grpc.LoadBalancerProvider
equals, hashCode, toString
-
-
-
-
Field Detail
-
DEFAULT_MODE
private static final GrpclbState.Mode DEFAULT_MODE
-
-
Method Detail
-
isAvailable
public boolean isAvailable()
Description copied from class:LoadBalancerProvider
Whether this provider is available for use, taking the current environment into consideration. Iffalse
,LoadBalancer.Factory.newLoadBalancer(io.grpc.LoadBalancer.Helper)
is not safe to be called.- Specified by:
isAvailable
in classLoadBalancerProvider
-
getPriority
public int getPriority()
Description copied from class:LoadBalancerProvider
A priority, from 0 to 10 that this provider should be used, taking the current environment into consideration. 5 should be considered the default, and then tweaked based on environment detection. A priority of 0 does not imply that the provider wouldn't work; just that it should be last in line.- Specified by:
getPriority
in classLoadBalancerProvider
-
getPolicyName
public java.lang.String getPolicyName()
Description copied from class:LoadBalancerProvider
Returns the load-balancing policy name associated with this provider, which makes it selectable viaLoadBalancerRegistry.getProvider(java.lang.String)
. This is called only when the class is loaded. It shouldn't change, and there is no point doing so.The policy name should consist of only lower case letters letters, underscore and digits, and can only start with letters.
- Specified by:
getPolicyName
in classLoadBalancerProvider
-
newLoadBalancer
public LoadBalancer newLoadBalancer(LoadBalancer.Helper helper)
Description copied from class:LoadBalancer.Factory
Creates aLoadBalancer
that will be used inside a channel.- Specified by:
newLoadBalancer
in classLoadBalancer.Factory
-
parseLoadBalancingPolicyConfig
public NameResolver.ConfigOrError parseLoadBalancingPolicyConfig(java.util.Map<java.lang.String,?> rawLoadBalancingConfigPolicy)
Description copied from class:LoadBalancerProvider
Parses the config for the Load Balancing policy unpacked from the service config. This will return aNameResolver.ConfigOrError
which contains either the successfully parsed config, or theStatus
representing the failure to parse. Implementations are expected to not throw exceptions but return a Status representing the failure. If successful, the load balancing policy config should be immutable.- Overrides:
parseLoadBalancingPolicyConfig
in classLoadBalancerProvider
- Parameters:
rawLoadBalancingConfigPolicy
- TheMap
representation of the load balancing policy choice.- Returns:
- a tuple of the fully parsed and validated balancer configuration, else the Status.
- See Also:
- A24-lb-policy-config.md
-
parseLoadBalancingConfigPolicyInternal
NameResolver.ConfigOrError parseLoadBalancingConfigPolicyInternal(java.util.Map<java.lang.String,?> rawLoadBalancingPolicyConfig)
-
-