diff --git a/xds/src/main/java/io/grpc/xds/WeightedRoundRobinLoadBalancer.java b/xds/src/main/java/io/grpc/xds/WeightedRoundRobinLoadBalancer.java index e72ddadf58..b200b9fdd6 100644 --- a/xds/src/main/java/io/grpc/xds/WeightedRoundRobinLoadBalancer.java +++ b/xds/src/main/java/io/grpc/xds/WeightedRoundRobinLoadBalancer.java @@ -64,6 +64,30 @@ import java.util.logging.Logger; * A {@link LoadBalancer} that provides weighted-round-robin load-balancing over the * {@link EquivalentAddressGroup}s from the {@link NameResolver}. The subchannel weights are * determined by backend metrics using ORCA. + * To use WRR, users may configure through channel serviceConfig. Example config: + *
{@code
+ * String wrrConfig = "{\"loadBalancingConfig\":" +
+ * "[{\"weighted_round_robin\":{\"enableOobLoadReport\":true, " +
+ * "\"blackoutPeriod\":\"10s\"," +
+ * "\"oobReportingPeriod\":\"10s\"," +
+ * "\"weightExpirationPeriod\":\"180s\"," +
+ * "\"errorUtilizationPenalty\":\"1.0\"," +
+ * "\"weightUpdatePeriod\":\"1s\"}}]}";
+ * serviceConfig = (Map) JsonParser.parse(wrrConfig);
+ * channel = ManagedChannelBuilder.forTarget("test:///lb.test.grpc.io")
+ * .defaultServiceConfig(serviceConfig)
+ * .build();
+ * }
+ *
+ * Users may also configure through xDS control plane via custom lb policy. But that is much more
+ * complex to set up. Example config:
+ *
+ * localityLbPolicies:
+ * - customPolicy:
+ * name: weighted_round_robin
+ * data: '{ "enableOobLoadReport": true }'
+ *
+ * See related documentation: https://cloud.google.com/service-mesh/legacy/load-balancing-apis/proxyless-configure-advanced-traffic-management#custom-lb-config
*/
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/9885")
final class WeightedRoundRobinLoadBalancer extends RoundRobinLoadBalancer {