Skip to content

Commit f0f453d

Browse files
feat: optimize dataflow job start by making sample row keys lighter (#4075)
Change-Id: I27718a29b6a48994462c215d02b43c407f2d8958
1 parent 56d32bd commit f0f453d

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

bigtable-dataflow-parent/bigtable-hbase-beam/src/main/java/com/google/cloud/bigtable/batch/common/CloudBigtableServiceImpl.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
package com.google.cloud.bigtable.batch.common;
1717

1818
import 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;
1921
import com.google.bigtable.repackaged.com.google.cloud.bigtable.data.v2.BigtableDataClient;
22+
import com.google.bigtable.repackaged.com.google.cloud.bigtable.data.v2.BigtableDataSettings;
2023
import com.google.bigtable.repackaged.com.google.cloud.bigtable.data.v2.models.KeyOffset;
2124
import com.google.cloud.bigtable.beam.CloudBigtableTableConfiguration;
2225
import 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

Comments
 (0)