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

chore: clean up BigtableIO client creation code #29538

Merged
merged 2 commits into from
Nov 28, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,13 @@ private static BigtableDataSettings configureReadSettings(
Duration.ofMillis(readOptions.getOperationTimeout().getMillis()));
}

if (readOptions.getWaitTimeout() != null) {
settings
.stubSettings()
.readRowsSettings()
.setWaitTimeout(Duration.ofMillis(readOptions.getWaitTimeout().getMillis()));
}

settings.stubSettings().readRowsSettings().setRetrySettings(retrySettings.build());

return settings.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,7 @@ BigtableServiceEntry getServiceForReading(
BigtableDataSettings.enableBuiltinMetrics();
}

BigtableService service;
if (opts.getWaitTimeout() != null) {
service = new BigtableServiceImpl(settings, opts.getWaitTimeout());
} else {
service = new BigtableServiceImpl(settings);
}
BigtableService service = new BigtableServiceImpl(settings);
entry = BigtableServiceEntry.create(configId, service);
entries.put(configId.id(), entry);
refCounts.put(configId.id(), new AtomicInteger(1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,33 +101,13 @@ class BigtableServiceImpl implements BigtableService {
private static final long MIN_BYTE_BUFFER_SIZE = 100 * 1024 * 1024; // 100MB

BigtableServiceImpl(BigtableDataSettings settings) throws IOException {
this(settings, null);
}

// TODO remove this constructor once https://github.com/googleapis/gapic-generator-java/pull/1473
// is resolved. readWaitTimeout is a hack to workaround incorrect mapping from attempt timeout to
// Watchdog's wait timeout.
BigtableServiceImpl(BigtableDataSettings settings, Duration readWaitTimeout) throws IOException {
this.projectId = settings.getProjectId();
this.instanceId = settings.getInstanceId();
RetrySettings retry = settings.getStubSettings().readRowsSettings().getRetrySettings();
this.readAttemptTimeout = Duration.millis(retry.getInitialRpcTimeout().toMillis());
this.readOperationTimeout = Duration.millis(retry.getTotalTimeout().toMillis());
BigtableDataSettings.Builder builder = settings.toBuilder();
if (readWaitTimeout != null) {
builder
.stubSettings()
.readRowsSettings()
.setRetrySettings(
retry
.toBuilder()
.setInitialRpcTimeout(
org.threeten.bp.Duration.ofMillis(readWaitTimeout.getMillis()))
.setMaxRpcTimeout(org.threeten.bp.Duration.ofMillis(readWaitTimeout.getMillis()))
.build());
}
LOG.info("Started Bigtable service with settings " + builder.build());
this.client = BigtableDataClient.create(builder.build());
LOG.info("Started Bigtable service with settings {}", settings);
this.client = BigtableDataClient.create(settings);
}

private final BigtableDataClient client;
Expand Down
Loading