2323import com .google .api .gax .rpc .StubSettings ;
2424import com .google .api .gax .rpc .UnaryCallSettings ;
2525import com .google .bigtable .admin .v2 .InstanceName ;
26+ import com .google .cloud .bigtable .data .v2 .wrappers .KeyOffset ;
2627import com .google .cloud .bigtable .data .v2 .wrappers .Query ;
2728import com .google .cloud .bigtable .data .v2 .wrappers .Row ;
2829import com .google .common .base .Preconditions ;
30+ import java .util .List ;
2931import javax .annotation .Nonnull ;
3032import org .threeten .bp .Duration ;
3133
@@ -69,6 +71,7 @@ public class EnhancedBigtableStubSettings extends StubSettings<EnhancedBigtableS
6971 private final String appProfileId ;
7072
7173 private final ServerStreamingCallSettings <Query , Row > readRowsSettings ;
74+ private final UnaryCallSettings <String , List <KeyOffset >> sampleRowKeysSettings ;
7275
7376 private EnhancedBigtableStubSettings (Builder builder ) {
7477 super (builder );
@@ -77,6 +80,7 @@ private EnhancedBigtableStubSettings(Builder builder) {
7780
7881 // Per method settings.
7982 readRowsSettings = builder .readRowsSettings .build ();
83+ sampleRowKeysSettings = builder .sampleRowKeysSettings .build ();
8084 }
8185
8286 /** Create a new builder. */
@@ -99,6 +103,11 @@ public ServerStreamingCallSettings<Query, Row> readRowsSettings() {
99103 return readRowsSettings ;
100104 }
101105
106+ /** Returns the object with the settings used for calls to SampleRowKeys. */
107+ public UnaryCallSettings <String , List <KeyOffset >> sampleRowKeysSettings () {
108+ return sampleRowKeysSettings ;
109+ }
110+
102111 /** Returns a builder containing all the values of this settings class. */
103112 public Builder toBuilder () {
104113 return new Builder (this );
@@ -110,6 +119,7 @@ public static class Builder extends StubSettings.Builder<EnhancedBigtableStubSet
110119 private String appProfileId ;
111120
112121 private final ServerStreamingCallSettings .Builder <Query , Row > readRowsSettings ;
122+ private final UnaryCallSettings .Builder <String , List <KeyOffset >> sampleRowKeysSettings ;
113123
114124 /**
115125 * Initializes a new Builder with sane defaults for all settings.
@@ -152,6 +162,22 @@ private Builder() {
152162 .setRpcTimeoutMultiplier (1 )
153163 .setMaxRpcTimeout (Duration .ofSeconds (20 ))
154164 .build ());
165+
166+ sampleRowKeysSettings = UnaryCallSettings .newUnaryCallSettingsBuilder ();
167+ /* TODO: copy retryCodes & retrySettings from baseSettings.sampleRowKeysSettings once it exists in GAPIC */
168+ sampleRowKeysSettings
169+ .setRetryableCodes (Code .DEADLINE_EXCEEDED , Code .UNAVAILABLE , Code .ABORTED )
170+ .setRetrySettings (
171+ RetrySettings .newBuilder ()
172+ .setMaxAttempts (10 )
173+ .setTotalTimeout (Duration .ofMinutes (1 ))
174+ .setInitialRetryDelay (Duration .ofMillis (100 ))
175+ .setRetryDelayMultiplier (1.3 )
176+ .setMaxRetryDelay (Duration .ofMinutes (1 ))
177+ .setInitialRpcTimeout (Duration .ofSeconds (20 ))
178+ .setRpcTimeoutMultiplier (1 )
179+ .setMaxRpcTimeout (Duration .ofSeconds (20 ))
180+ .build ());
155181 }
156182
157183 private Builder (EnhancedBigtableStubSettings settings ) {
@@ -161,6 +187,7 @@ private Builder(EnhancedBigtableStubSettings settings) {
161187
162188 // Per method settings.
163189 readRowsSettings = settings .readRowsSettings .toBuilder ();
190+ sampleRowKeysSettings = settings .sampleRowKeysSettings .toBuilder ();
164191 }
165192
166193 // <editor-fold desc="Private Helpers">
@@ -213,6 +240,11 @@ public ServerStreamingCallSettings.Builder<Query, Row> readRowsSettings() {
213240 return readRowsSettings ;
214241 }
215242
243+ /** Returns the builder for the settings used for calls to SampleRowKeysSettings. */
244+ public UnaryCallSettings .Builder <String , List <KeyOffset >> sampleRowKeysSettings () {
245+ return sampleRowKeysSettings ;
246+ }
247+
216248 @ SuppressWarnings ("unchecked" )
217249 public EnhancedBigtableStubSettings build () {
218250 Preconditions .checkState (instanceName != null , "InstanceName must be set" );
0 commit comments