Package io.grpc.xds

Class LoadBalancerConfigFactory


  • class LoadBalancerConfigFactory
    extends java.lang.Object
    Creates service config JSON load balancer config objects for a given xDS Cluster message. Supports both the "legacy" configuration style and the new, more advanced one that utilizes the xDS "typed extension" mechanism.

    Legacy configuration is done by setting the lb_policy enum field and any supporting configuration fields needed by the particular policy.

    The new approach is to set the load_balancing_policy field that contains both the policy selection as well as any supporting configuration data. Providing a list of acceptable policies is also supported. Note that if this field is used, it will override any configuration set using the legacy approach. The new configuration approach is explained in detail in the Custom LB Policies gRFC

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static com.google.common.collect.ImmutableMap<java.lang.String,​?> buildLeastRequestConfig​(java.lang.Integer choiceCount)
      Builds a service config JSON object for the least_request load balancer config based on the given config values.
      private static com.google.common.collect.ImmutableMap<java.lang.String,​?> buildPickFirstConfig​(boolean shuffleAddressList)
      Builds a service config JSON object for the pick_first load balancer config based on the given config values.
      private static com.google.common.collect.ImmutableMap<java.lang.String,​?> buildRingHashConfig​(java.lang.Long minRingSize, java.lang.Long maxRingSize)
      Builds a service config JSON object for the ring_hash load balancer config based on the given config values.
      private static com.google.common.collect.ImmutableMap<java.lang.String,​?> buildRoundRobinConfig()
      Builds an empty service config JSON config object for round robin (it is not configurable).
      private static com.google.common.collect.ImmutableMap<java.lang.String,​?> buildWrrConfig​(java.lang.String blackoutPeriod, java.lang.String weightExpirationPeriod, java.lang.String oobReportingPeriod, java.lang.Boolean enableOobLoadReport, java.lang.String weightUpdatePeriod, java.lang.Float errorUtilizationPenalty)
      Builds a service config JSON object for the weighted_round_robin load balancer config based on the given config values.
      private static com.google.common.collect.ImmutableMap<java.lang.String,​?> buildWrrLocalityConfig​(com.google.common.collect.ImmutableMap<java.lang.String,​?> childConfig)
      Builds a service config JSON wrr_locality by wrapping another policy config.
      (package private) static com.google.common.collect.ImmutableMap<java.lang.String,​?> newConfig​(Cluster cluster, boolean enableLeastRequest)
      Factory method for creating a new {link LoadBalancerConfigConverter} for a given xDS Cluster.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LoadBalancerConfigFactory

        LoadBalancerConfigFactory()
    • Method Detail

      • buildRingHashConfig

        private static com.google.common.collect.ImmutableMap<java.lang.String,​?> buildRingHashConfig​(java.lang.Long minRingSize,
                                                                                                            java.lang.Long maxRingSize)
        Builds a service config JSON object for the ring_hash load balancer config based on the given config values.
      • buildWrrConfig

        private static com.google.common.collect.ImmutableMap<java.lang.String,​?> buildWrrConfig​(java.lang.String blackoutPeriod,
                                                                                                       java.lang.String weightExpirationPeriod,
                                                                                                       java.lang.String oobReportingPeriod,
                                                                                                       java.lang.Boolean enableOobLoadReport,
                                                                                                       java.lang.String weightUpdatePeriod,
                                                                                                       java.lang.Float errorUtilizationPenalty)
        Builds a service config JSON object for the weighted_round_robin load balancer config based on the given config values.
      • buildLeastRequestConfig

        private static com.google.common.collect.ImmutableMap<java.lang.String,​?> buildLeastRequestConfig​(java.lang.Integer choiceCount)
        Builds a service config JSON object for the least_request load balancer config based on the given config values.
      • buildWrrLocalityConfig

        private static com.google.common.collect.ImmutableMap<java.lang.String,​?> buildWrrLocalityConfig​(com.google.common.collect.ImmutableMap<java.lang.String,​?> childConfig)
        Builds a service config JSON wrr_locality by wrapping another policy config.
      • buildRoundRobinConfig

        private static com.google.common.collect.ImmutableMap<java.lang.String,​?> buildRoundRobinConfig()
        Builds an empty service config JSON config object for round robin (it is not configurable).
      • buildPickFirstConfig

        private static com.google.common.collect.ImmutableMap<java.lang.String,​?> buildPickFirstConfig​(boolean shuffleAddressList)
        Builds a service config JSON object for the pick_first load balancer config based on the given config values.