2222import static io .grpc .ConnectivityState .SHUTDOWN ;
2323import static io .grpc .ConnectivityState .TRANSIENT_FAILURE ;
2424
25+ import com .google .common .annotations .VisibleForTesting ;
2526import com .google .common .base .MoreObjects ;
27+ import com .google .common .base .Strings ;
2628import io .grpc .ConnectivityState ;
2729import io .grpc .ConnectivityStateInfo ;
2830import io .grpc .EquivalentAddressGroup ;
@@ -44,6 +46,10 @@ final class PickFirstLoadBalancer extends LoadBalancer {
4446 private final Helper helper ;
4547 private Subchannel subchannel ;
4648 private ConnectivityState currentState = IDLE ;
49+ @ VisibleForTesting
50+ static boolean enablePickFirstConfig =
51+ !Strings .isNullOrEmpty (System .getenv ("GRPC_EXPERIMENTAL_PICKFIRST_LB_CONFIG" ))
52+ && Boolean .parseBoolean (System .getenv ("GRPC_EXPERIMENTAL_PICKFIRST_LB_CONFIG" ));
4753
4854 PickFirstLoadBalancer (Helper helper ) {
4955 this .helper = checkNotNull (helper , "helper" );
@@ -61,7 +67,7 @@ public boolean acceptResolvedAddresses(ResolvedAddresses resolvedAddresses) {
6167
6268 // We can optionally be configured to shuffle the address list. This can help better distribute
6369 // the load.
64- if (resolvedAddresses .getLoadBalancingPolicyConfig () != null ) {
70+ if (enablePickFirstConfig && resolvedAddresses .getLoadBalancingPolicyConfig () != null ) {
6571 PickFirstLoadBalancerConfig config
6672 = (PickFirstLoadBalancerConfig ) resolvedAddresses .getLoadBalancingPolicyConfig ();
6773 if (config .shuffleAddressList != null && config .shuffleAddressList ) {
0 commit comments