@@ -89,6 +89,9 @@ public class EnhancedBigtableStubSettings extends StubSettings<EnhancedBigtableS
89
89
private static final int MAX_MESSAGE_SIZE = 256 * 1024 * 1024 ;
90
90
private static final String SERVER_DEFAULT_APP_PROFILE_ID = "" ;
91
91
92
+ // TODO(weiranf): Remove this temporary endpoint once DirectPath goes to public beta
93
+ private static final String DIRECT_PATH_ENDPOINT = "test-bigtable.sandbox.googleapis.com:443" ;
94
+
92
95
private static final Set <Code > IDEMPOTENT_RETRY_CODES =
93
96
ImmutableSet .of (Code .DEADLINE_EXCEEDED , Code .UNAVAILABLE );
94
97
@@ -167,6 +170,12 @@ public class EnhancedBigtableStubSettings extends StubSettings<EnhancedBigtableS
167
170
private EnhancedBigtableStubSettings (Builder builder ) {
168
171
super (builder );
169
172
173
+ if (DIRECT_PATH_ENDPOINT .equals (builder .getEndpoint ())) {
174
+ logger .warning (
175
+ "Connecting to Bigtable using DirectPath."
176
+ + " This is currently an experimental feature and should not be used in production." );
177
+ }
178
+
170
179
// Since point reads, streaming reads, bulk reads share the same base callable that converts
171
180
// grpc errors into ApiExceptions, they must have the same retry codes.
172
181
Preconditions .checkState (
@@ -240,9 +249,13 @@ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProvi
240
249
.setKeepAliveTimeout (
241
250
Duration .ofSeconds (10 )) // wait this long before considering the connection dead
242
251
.setKeepAliveWithoutCalls (true ) // sends ping without active streams
243
- // Attempts direct access to CBT service over gRPC to improve throughput,
244
- // whether the attempt is allowed is totally controlled by service owner.
245
- .setAttemptDirectPath (true );
252
+ // TODO(weiranf): Set this to true by default once DirectPath goes to public beta
253
+ .setAttemptDirectPath (isDirectPathEnabled ());
254
+ }
255
+
256
+ // TODO(weiranf): Remove this once DirectPath goes to public beta
257
+ private static boolean isDirectPathEnabled () {
258
+ return Boolean .getBoolean ("bigtable.attempt-directpath" );
246
259
}
247
260
248
261
static int getDefaultChannelPoolSize () {
@@ -517,7 +530,13 @@ private Builder() {
517
530
// Defaults provider
518
531
BigtableStubSettings .Builder baseDefaults = BigtableStubSettings .newBuilder ();
519
532
520
- setEndpoint (baseDefaults .getEndpoint ());
533
+ // TODO(weiranf): remove this once DirectPath goes to public Beta and uses the default
534
+ // endpoint.
535
+ if (isDirectPathEnabled ()) {
536
+ setEndpoint (DIRECT_PATH_ENDPOINT );
537
+ } else {
538
+ setEndpoint (baseDefaults .getEndpoint ());
539
+ }
521
540
522
541
setTransportChannelProvider (defaultTransportChannelProvider ());
523
542
setStreamWatchdogCheckInterval (baseDefaults .getStreamWatchdogCheckInterval ());
0 commit comments