Skip to content
Merged
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 numberDiff line numberDiff line change
Expand Up@@ -107,6 +107,7 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import javax.annotation.Nullable;
import org.threeten.bp.Duration;

Expand DownExpand Up@@ -139,6 +140,8 @@ public class GapicSpannerRpc implements SpannerRpc {
private final Duration checkInterval =
systemProperty(PROPERTY_PERIOD_SECONDS, DEFAULT_PERIOD_SECONDS);

private final ScheduledExecutorService spannerWatchdog;
Comment thread
javabrown marked this conversation as resolved.

public static GapicSpannerRpc create(SpannerOptions options) {
return new GapicSpannerRpc(options);
}
Expand DownExpand Up@@ -191,14 +194,15 @@ public GapicSpannerRpc(SpannerOptions options) {
CredentialsProvider credentialsProvider =
GrpcTransportOptions.setUpCredentialsProvider(options);

spannerWatchdog =
Executors.newSingleThreadScheduledExecutor(
new ThreadFactoryBuilder()
.setDaemon(true)
.setNameFormat("Cloud-Spanner-WatchdogProvider-%d")
.build());
WatchdogProvider watchdogProvider =
InstantiatingWatchdogProvider.create()
.withExecutor(
Executors.newSingleThreadScheduledExecutor(
new ThreadFactoryBuilder()
.setDaemon(true)
.setNameFormat("Cloud-Spanner-WatchdogProvider-%d")
.build()))
.withExecutor(spannerWatchdog)
.withCheckInterval(checkInterval)
.withClock(NanoClock.getDefaultClock());

Expand DownExpand Up@@ -572,6 +576,7 @@ public void shutdown() {
this.spannerStub.close();
this.instanceAdminStub.close();
this.databaseAdminStub.close();
this.spannerWatchdog.shutdown();
}

/**
Expand Down