1616package com .google .cloud .bigtable .batch .common ;
1717
1818import com .google .bigtable .repackaged .com .google .api .core .InternalApi ;
19+ import com .google .bigtable .repackaged .com .google .api .gax .grpc .ChannelPoolSettings ;
20+ import com .google .bigtable .repackaged .com .google .api .gax .grpc .InstantiatingGrpcChannelProvider ;
1921import com .google .bigtable .repackaged .com .google .cloud .bigtable .data .v2 .BigtableDataClient ;
22+ import com .google .bigtable .repackaged .com .google .cloud .bigtable .data .v2 .BigtableDataSettings ;
2023import com .google .bigtable .repackaged .com .google .cloud .bigtable .data .v2 .models .KeyOffset ;
2124import com .google .cloud .bigtable .beam .CloudBigtableTableConfiguration ;
2225import com .google .cloud .bigtable .hbase .wrappers .veneer .BigtableHBaseVeneerSettings ;
@@ -32,8 +35,26 @@ public List<KeyOffset> getSampleRowKeys(CloudBigtableTableConfiguration config)
3235
3336 // TODO: figure out how to stick to HBase api here
3437 BigtableHBaseVeneerSettings settings =
35- (BigtableHBaseVeneerSettings ) BigtableHBaseVeneerSettings .create (config .toHBaseConfig ());
36- try (BigtableDataClient client = BigtableDataClient .create (settings .getDataSettings ())) {
38+ BigtableHBaseVeneerSettings .create (config .toHBaseConfig ());
39+
40+ // Lighten the client instance since it's only used for a single RPC
41+ BigtableDataSettings .Builder builder = settings .getDataSettings ().toBuilder ();
42+ InstantiatingGrpcChannelProvider oldTransportProvider =
43+ (InstantiatingGrpcChannelProvider )
44+ settings .getDataSettings ().getStubSettings ().getTransportChannelProvider ();
45+
46+ builder
47+ .stubSettings ()
48+ .setTransportChannelProvider (
49+ oldTransportProvider
50+ .toBuilder ()
51+ .setChannelPoolSettings (
52+ ChannelPoolSettings .staticallySized (1 )
53+ .toBuilder ()
54+ .setPreemptiveRefreshEnabled (false )
55+ .build ())
56+ .build ());
57+ try (BigtableDataClient client = BigtableDataClient .create (builder .build ())) {
3758 return client .sampleRowKeys (config .getTableId ());
3859 }
3960 }
0 commit comments