Package io.grpc.util

Class GracefulSwitchLoadBalancer


  • @ExperimentalApi("https://github.com/grpc/grpc-java/issues/5999")
    @NotThreadSafe
    public final class GracefulSwitchLoadBalancer
    extends ForwardingLoadBalancer
    A load balancer that gracefully swaps to a new lb policy. If the channel is currently in a state other than READY, the new policy will be swapped into place immediately. Otherwise, the channel will keep using the old policy until the new policy leaves CONNECTING or the old policy exits READY.

    The child balancer and configuration is specified using service config. Config objects are generally created by calling parseLoadBalancingPolicyConfig(List) from a provider's parseLoadBalancingPolicyConfig() implementation.

    • Constructor Detail

      • GracefulSwitchLoadBalancer

        public GracefulSwitchLoadBalancer​(io.grpc.LoadBalancer.Helper helper)
    • Method Detail

      • acceptResolvedAddresses

        public io.grpc.Status acceptResolvedAddresses​(io.grpc.LoadBalancer.ResolvedAddresses resolvedAddresses)
        Overrides:
        acceptResolvedAddresses in class io.grpc.LoadBalancer
      • delegateType

        public String delegateType()
      • parseLoadBalancingPolicyConfig

        public static io.grpc.NameResolver.ConfigOrError parseLoadBalancingPolicyConfig​(List<Map<String,​?>> loadBalancingConfigs)
        Provided a JSON list of LoadBalancingConfigs, parse it into a config to pass to GracefulSwitch.
      • parseLoadBalancingPolicyConfig

        public static io.grpc.NameResolver.ConfigOrError parseLoadBalancingPolicyConfig​(List<Map<String,​?>> loadBalancingConfigs,
                                                                                        io.grpc.LoadBalancerRegistry lbRegistry)
        Provided a JSON list of LoadBalancingConfigs, parse it into a config to pass to GracefulSwitch.
      • createLoadBalancingPolicyConfig

        public static Object createLoadBalancingPolicyConfig​(io.grpc.LoadBalancer.Factory childFactory,
                                                             @Nullable
                                                             Object childConfig)
        Directly create a config to pass to GracefulSwitch. The object returned is the same as would be found in ConfigOrError.getConfig().