Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add keepalive changes in java client library #409

Merged
merged 5 commits into from Oct 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -177,7 +177,13 @@ public synchronized ManagedChannel getDataChannel() {
}

if (dataChannel == null) {
dataChannel = newChannelBuilder(port).maxInboundMessageSize(256 * 1024 * 1024).build();
dataChannel =
newChannelBuilder(port)
.maxInboundMessageSize(256 * 1024 * 1024)
.keepAliveTimeout(10, TimeUnit.SECONDS)
.keepAliveTime(10, TimeUnit.SECONDS)
.keepAliveWithoutCalls(true)
.build();
}
return dataChannel;
}
Expand Down
Expand Up @@ -29,6 +29,7 @@
import java.util.List;
import java.util.logging.Logger;
import javax.annotation.Nonnull;
import org.threeten.bp.Duration;

/**
* Settings class to configure an instance of {@link BigtableDataClient}.
Expand Down Expand Up @@ -122,6 +123,10 @@ public ManagedChannelBuilder apply(ManagedChannelBuilder input) {
return input.usePlaintext();
}
})
.setKeepAliveTime(Duration.ofSeconds(10)) // sends ping in this interval
.setKeepAliveTimeout(
Duration.ofSeconds(10)) // wait this long before considering the connection dead
.setKeepAliveWithoutCalls(true) // sends ping without active streams
.build());

LOGGER.info("Connecting to the Bigtable emulator at " + hostname + ":" + port);
Expand Down
Expand Up @@ -238,6 +238,10 @@ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProvi
return BigtableStubSettings.defaultGrpcTransportProviderBuilder()
.setPoolSize(getDefaultChannelPoolSize())
.setMaxInboundMessageSize(MAX_MESSAGE_SIZE)
.setKeepAliveTime(Duration.ofSeconds(10)) // sends ping in this interval
.setKeepAliveTimeout(
Duration.ofSeconds(10)) // wait this long before considering the connection dead
.setKeepAliveWithoutCalls(true) // sends ping without active streams
// TODO(weiranf): Set this to true by default once DirectPath goes to public beta
.setAttemptDirectPath(isDirectPathEnabled());
}
Expand Down