Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

Fix InstantiatingGrpcChannelProvider's channel pool to play nicely with DirectPath #798

Merged
merged 5 commits into from Oct 16, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -42,6 +42,7 @@
import com.google.auth.oauth2.ComputeEngineCredentials;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import io.grpc.alts.ComputeEngineChannelBuilder;
Expand Down Expand Up @@ -238,6 +239,21 @@ private ManagedChannel createSingleChannel() throws IOException {
// Will be overridden by user defined values if any.
builder.keepAliveTime(DIRECT_PATH_KEEP_ALIVE_TIME_SECONDS, TimeUnit.SECONDS);
builder.keepAliveTimeout(DIRECT_PATH_KEEP_ALIVE_TIMEOUT_SECONDS, TimeUnit.SECONDS);

// When channel pooling is enabled, force the pick_first grpclb strategy.
// This is necessary to avoid the multiplicative effect of creating channel pool with
// `poolSize` number of `ManagedChannel`s, each with a `subSetting` number of number of subchannels.
igorbernstein2 marked this conversation as resolved.
Show resolved Hide resolved
if (poolSize > 1) {
igorbernstein2 marked this conversation as resolved.
Show resolved Hide resolved
builder.defaultServiceConfig(
ImmutableMap.of(
"loadBalancingConfig",
ImmutableList.of(
ImmutableMap.of(
"grpclb",
ImmutableMap.of(
"childPolicy",
ImmutableList.of(ImmutableMap.of("pick_first", ImmutableMap.of())))))));
}
} else {
builder = ManagedChannelBuilder.forAddress(serviceAddress, port);
}
Expand Down