Package io.grpc.xds
Class LoadBalancerConfigFactory
java.lang.Object
io.grpc.xds.LoadBalancerConfigFactory
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
Builds a JSON LB configuration based on the old style of using the xDS Cluster proto message.(package private) static class
Responsible for converting from aenvoy.config.cluster.v3.LoadBalancingPolicy
proto message to a gRPC service config format. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final String
private static final XdsLogger
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static com.google.common.collect.ImmutableMap
<String, ?> buildLeastRequestConfig
(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
<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
<String, ?> buildRingHashConfig
(Long minRingSize, 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
<String, ?> Builds an empty service config JSON config object for round robin (it is not configurable).private static com.google.common.collect.ImmutableMap
<String, ?> buildWrrConfig
(String blackoutPeriod, String weightExpirationPeriod, String oobReportingPeriod, Boolean enableOobLoadReport, String weightUpdatePeriod, 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
<String, ?> buildWrrLocalityConfig
(com.google.common.collect.ImmutableMap<String, ?> childConfig) Builds a service config JSON wrr_locality by wrapping another policy config.(package private) static com.google.common.collect.ImmutableMap
<String, ?> Factory method for creating a new {link LoadBalancerConfigConverter} for a given xDSCluster
.
-
Field Details
-
logger
-
ROUND_ROBIN_FIELD_NAME
- See Also:
-
RING_HASH_FIELD_NAME
- See Also:
-
MIN_RING_SIZE_FIELD_NAME
- See Also:
-
MAX_RING_SIZE_FIELD_NAME
- See Also:
-
LEAST_REQUEST_FIELD_NAME
- See Also:
-
CHOICE_COUNT_FIELD_NAME
- See Also:
-
WRR_LOCALITY_FIELD_NAME
- See Also:
-
CHILD_POLICY_FIELD
- See Also:
-
BLACK_OUT_PERIOD
- See Also:
-
WEIGHT_EXPIRATION_PERIOD
- See Also:
-
OOB_REPORTING_PERIOD
- See Also:
-
ENABLE_OOB_LOAD_REPORT
- See Also:
-
WEIGHT_UPDATE_PERIOD
- See Also:
-
PICK_FIRST_FIELD_NAME
- See Also:
-
SHUFFLE_ADDRESS_LIST_FIELD_NAME
- See Also:
-
ERROR_UTILIZATION_PENALTY
- See Also:
-
-
Constructor Details
-
LoadBalancerConfigFactory
LoadBalancerConfigFactory()
-
-
Method Details
-
newConfig
static com.google.common.collect.ImmutableMap<String,?> newConfig(Cluster cluster, boolean enableLeastRequest) throws XdsResourceType.ResourceInvalidException Factory method for creating a new {link LoadBalancerConfigConverter} for a given xDSCluster
.- Throws:
XdsResourceType.ResourceInvalidException
- If theCluster
has an invalid LB configuration.
-
buildRingHashConfig
private static com.google.common.collect.ImmutableMap<String,?> buildRingHashConfig(Long minRingSize, 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<String,?> buildWrrConfig(String blackoutPeriod, String weightExpirationPeriod, String oobReportingPeriod, Boolean enableOobLoadReport, String weightUpdatePeriod, 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<String,?> buildLeastRequestConfig(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<String,?> buildWrrLocalityConfig(com.google.common.collect.ImmutableMap<String, ?> childConfig) Builds a service config JSON wrr_locality by wrapping another policy config. -
buildRoundRobinConfig
Builds an empty service config JSON config object for round robin (it is not configurable). -
buildPickFirstConfig
private static com.google.common.collect.ImmutableMap<String,?> buildPickFirstConfig(boolean shuffleAddressList) Builds a service config JSON object for the pick_first load balancer config based on the given config values.
-