Skip to content
Permalink
Browse files
feat: add keepalive changes in java client library (#409)
* feat: Add keepalive logic in bigtable data client

* fix: code formatting

* fix: mvn formatting

* fix: setting in emulator

* feat: add keep alive in enhanced stub as well
  • Loading branch information
sushanb committed Oct 6, 2020
1 parent 25eafdd commit edbcde1a5b22317319803cb57401252aac6d580d
@@ -179,7 +179,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;
}
@@ -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}.
@@ -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);
@@ -241,6 +241,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());
}

0 comments on commit edbcde1

Please sign in to comment.