Skip to content

Commit 0d8e061

Browse files
committed
fix(gax-grpc): replace grpclb with pick_first in direct path service config
1 parent f765e29 commit 0d8e061

2 files changed

Lines changed: 8 additions & 19 deletions

File tree

gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProvider.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,7 +1422,7 @@ public ApiFunction<ManagedChannelBuilder, ManagedChannelBuilder> getChannelConfi
14221422
}
14231423

14241424
private static ImmutableMap<String, ?> getDefaultDirectPathServiceConfig() {
1425-
// When channel pooling is enabled, force the pick_first grpclb strategy.
1425+
// When channel pooling is enabled, force the pick_first strategy.
14261426
// This is necessary to avoid the multiplicative effect of creating channel pool with
14271427
// `poolSize` number of `ManagedChannel`s, each with a `subSetting` number of number of
14281428
// subchannels.
@@ -1431,14 +1431,8 @@ public ApiFunction<ManagedChannelBuilder, ManagedChannelBuilder> getChannelConfi
14311431
ImmutableMap<String, Object> pickFirstStrategy =
14321432
ImmutableMap.<String, Object>of("pick_first", ImmutableMap.of());
14331433

1434-
ImmutableMap<String, Object> childPolicy =
1435-
ImmutableMap.<String, Object>of("childPolicy", ImmutableList.of(pickFirstStrategy));
1436-
1437-
ImmutableMap<String, Object> grpcLbPolicy =
1438-
ImmutableMap.<String, Object>of("grpclb", childPolicy);
1439-
14401434
return ImmutableMap.<String, Object>of(
1441-
"loadBalancingConfig", ImmutableList.of(grpcLbPolicy, pickFirstStrategy));
1435+
"loadBalancingConfig", ImmutableList.of(pickFirstStrategy));
14421436
}
14431437

14441438
private static void validateEndpoint(String endpoint) {

gax-java/gax-grpc/src/test/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProviderTest.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ void testToBuilder() {
235235
builder -> {
236236
throw new UnsupportedOperationException();
237237
};
238-
Map<String, ?> directPathServiceConfig = ImmutableMap.of("loadbalancingConfig", "grpclb");
238+
Map<String, ?> directPathServiceConfig = ImmutableMap.of("loadbalancingConfig", "pick_first");
239239
List<InstantiatingGrpcChannelProvider.HardBoundTokenTypes> hardBoundTokenTypes =
240240
new ArrayList<>();
241241
hardBoundTokenTypes.add(InstantiatingGrpcChannelProvider.HardBoundTokenTypes.ALTS);
@@ -547,14 +547,9 @@ void testWithDefaultDirectPathServiceConfig() {
547547
ImmutableMap<String, ?> defaultServiceConfig = provider.directPathServiceConfig;
548548

549549
List<Map<String, ?>> lbConfigs = getAsObjectList(defaultServiceConfig, "loadBalancingConfig");
550-
assertThat(lbConfigs).hasSize(2);
550+
assertThat(lbConfigs).hasSize(1);
551551
Map<String, ?> lbConfig = lbConfigs.get(0);
552-
Map<String, ?> grpclb = getAsObject(lbConfig, "grpclb");
553-
List<Map<String, ?>> childPolicies = getAsObjectList(grpclb, "childPolicy");
554-
assertThat(childPolicies).hasSize(1);
555-
Map<String, ?> childPolicy = childPolicies.get(0);
556-
assertThat(childPolicy.keySet()).containsExactly("pick_first");
557-
assertThat(lbConfigs.get(1).keySet()).containsExactly("pick_first");
552+
assertThat(lbConfig.keySet()).containsExactly("pick_first");
558553
}
559554

560555
@Nullable
@@ -600,10 +595,10 @@ void testWithCustomDirectPathServiceConfig() {
600595
ImmutableMap<String, Object> childPolicy =
601596
ImmutableMap.<String, Object>of(
602597
"childPolicy", ImmutableList.of(pickFirstStrategy), "foo", "bar");
603-
ImmutableMap<String, Object> grpcLbPolicy =
604-
ImmutableMap.<String, Object>of("grpclb", childPolicy);
598+
ImmutableMap<String, Object> customLbPolicy =
599+
ImmutableMap.<String, Object>of("my_custom_lb", childPolicy);
605600
Map<String, Object> passedServiceConfig = new HashMap<>();
606-
passedServiceConfig.put("loadBalancingConfig", ImmutableList.of(grpcLbPolicy));
601+
passedServiceConfig.put("loadBalancingConfig", ImmutableList.of(customLbPolicy));
607602

608603
InstantiatingGrpcChannelProvider provider =
609604
InstantiatingGrpcChannelProvider.newBuilder()

0 commit comments

Comments
 (0)