Package io.grpc.xds

Class ClusterResolverLoadBalancer


  • final class ClusterResolverLoadBalancer
    extends io.grpc.LoadBalancer
    Load balancer for cluster_resolver_experimental LB policy. This LB policy is the child LB policy of the cds_experimental LB policy and the parent LB policy of the priority_experimental LB policy in the xDS load balancing hierarchy. This policy resolves endpoints of non-aggregate clusters (e.g., EDS or Logical DNS) and groups endpoints in priorities and localities to be used in the downstream LB policies for fine-grained load balancing purposes.
    • Field Detail

      • LOGICAL_DNS_CLUSTER_LOCALITY

        private static final Locality LOGICAL_DNS_CLUSTER_LOCALITY
      • syncContext

        private final io.grpc.SynchronizationContext syncContext
      • timeService

        private final java.util.concurrent.ScheduledExecutorService timeService
      • lbRegistry

        private final io.grpc.LoadBalancerRegistry lbRegistry
      • backoffPolicyProvider

        private final io.grpc.internal.BackoffPolicy.Provider backoffPolicyProvider
      • delegate

        private final io.grpc.util.GracefulSwitchLoadBalancer delegate
      • xdsClientPool

        private io.grpc.internal.ObjectPool<XdsClient> xdsClientPool
    • Constructor Detail

      • ClusterResolverLoadBalancer

        ClusterResolverLoadBalancer​(io.grpc.LoadBalancer.Helper helper)
      • ClusterResolverLoadBalancer

        ClusterResolverLoadBalancer​(io.grpc.LoadBalancer.Helper helper,
                                    io.grpc.LoadBalancerRegistry lbRegistry,
                                    io.grpc.internal.BackoffPolicy.Provider backoffPolicyProvider)
    • Method Detail

      • acceptResolvedAddresses

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

        public void handleNameResolutionError​(io.grpc.Status error)
        Specified by:
        handleNameResolutionError in class io.grpc.LoadBalancer
      • shutdown

        public void shutdown()
        Specified by:
        shutdown in class io.grpc.LoadBalancer
      • generateEdsBasedPriorityChildConfigs

        private static java.util.Map<java.lang.String,​PriorityLoadBalancerProvider.PriorityLbConfig.PriorityChildConfig> generateEdsBasedPriorityChildConfigs​(java.lang.String cluster,
                                                                                                                                                                    @Nullable
                                                                                                                                                                    java.lang.String edsServiceName,
                                                                                                                                                                    @Nullable
                                                                                                                                                                    Bootstrapper.ServerInfo lrsServerInfo,
                                                                                                                                                                    @Nullable
                                                                                                                                                                    java.lang.Long maxConcurrentRequests,
                                                                                                                                                                    @Nullable
                                                                                                                                                                    EnvoyServerProtoData.UpstreamTlsContext tlsContext,
                                                                                                                                                                    java.util.Map<java.lang.String,​com.google.protobuf.Struct> filterMetadata,
                                                                                                                                                                    @Nullable
                                                                                                                                                                    EnvoyServerProtoData.OutlierDetection outlierDetection,
                                                                                                                                                                    java.lang.Object endpointLbConfig,
                                                                                                                                                                    io.grpc.LoadBalancerRegistry lbRegistry,
                                                                                                                                                                    java.util.Map<java.lang.String,​java.util.Map<Locality,​java.lang.Integer>> prioritizedLocalityWeights,
                                                                                                                                                                    java.util.List<Endpoints.DropOverload> dropOverloads)
        Generates configs to be used in the priority LB policy for priorities in an EDS cluster.

        priority LB -> cluster_impl LB (one per priority) -> (weighted_target LB -> round_robin / least_request_experimental (one per locality)) / ring_hash_experimental

      • buildOutlierDetectionLbConfig

        private static io.grpc.util.OutlierDetectionLoadBalancer.OutlierDetectionLoadBalancerConfig buildOutlierDetectionLbConfig​(EnvoyServerProtoData.OutlierDetection outlierDetection,
                                                                                                                                  java.lang.Object childConfig)
        Converts EnvoyServerProtoData.OutlierDetection that represents the xDS configuration to OutlierDetectionLoadBalancer.OutlierDetectionLoadBalancerConfig that the OutlierDetectionLoadBalancer understands.
      • priorityName

        private static java.lang.String priorityName​(java.lang.String cluster,
                                                     int priority)
        Generates a string that represents the priority in the LB policy config. The string is unique across priorities in all clusters and priorityName(c, p1) < priorityName(c, p2) iff p1 < p2. The ordering is undefined for priorities in different clusters.
      • localityName

        private static java.lang.String localityName​(Locality locality)
        Generates a string that represents the locality in the LB policy config. The string is unique across all localities in all clusters.