3333import com .google .api .gax .rpc .TransportChannelProvider ;
3434import com .google .api .gax .rpc .UnaryCallSettings ;
3535import com .google .auth .Credentials ;
36+ import com .google .bigtable .v2 .PingAndWarmRequest ;
3637import com .google .cloud .bigtable .Version ;
3738import com .google .cloud .bigtable .data .v2 .models .ConditionalRowMutation ;
3839import com .google .cloud .bigtable .data .v2 .models .KeyOffset ;
@@ -94,6 +95,8 @@ public class EnhancedBigtableStubSettings extends StubSettings<EnhancedBigtableS
9495 private static final Set <Code > IDEMPOTENT_RETRY_CODES =
9596 ImmutableSet .of (Code .DEADLINE_EXCEEDED , Code .UNAVAILABLE );
9697
98+ private static Duration PRIME_REQUEST_TIMEOUT = Duration .ofSeconds (30 );
99+
97100 // Copy of default retrying settings in the yaml
98101 private static final RetrySettings IDEMPOTENT_RETRY_SETTINGS =
99102 RetrySettings .newBuilder ()
@@ -173,6 +176,7 @@ public class EnhancedBigtableStubSettings extends StubSettings<EnhancedBigtableS
173176 private final BigtableBulkReadRowsCallSettings bulkReadRowsSettings ;
174177 private final UnaryCallSettings <ConditionalRowMutation , Boolean > checkAndMutateRowSettings ;
175178 private final UnaryCallSettings <ReadModifyWriteRow , Row > readModifyWriteRowSettings ;
179+ private final UnaryCallSettings <PingAndWarmRequest , Void > pingAndWarmSettings ;
176180
177181 private EnhancedBigtableStubSettings (Builder builder ) {
178182 super (builder );
@@ -208,6 +212,7 @@ private EnhancedBigtableStubSettings(Builder builder) {
208212 bulkReadRowsSettings = builder .bulkReadRowsSettings .build ();
209213 checkAndMutateRowSettings = builder .checkAndMutateRowSettings .build ();
210214 readModifyWriteRowSettings = builder .readModifyWriteRowSettings .build ();
215+ pingAndWarmSettings = builder .pingAndWarmSettings .build ();
211216 }
212217
213218 /** Create a new builder. */
@@ -494,6 +499,15 @@ public UnaryCallSettings<ReadModifyWriteRow, Row> readModifyWriteRowSettings() {
494499 return readModifyWriteRowSettings ;
495500 }
496501
502+ /**
503+ * Returns the object with the settings used for calls to PingAndWarm.
504+ *
505+ * <p>By default the retries are disabled for PingAndWarm and deadline is set to 30 seconds.
506+ */
507+ UnaryCallSettings <PingAndWarmRequest , Void > pingAndWarmSettings () {
508+ return pingAndWarmSettings ;
509+ }
510+
497511 /** Returns a builder containing all the values of this settings class. */
498512 public Builder toBuilder () {
499513 return new Builder (this );
@@ -518,6 +532,7 @@ public static class Builder extends StubSettings.Builder<EnhancedBigtableStubSet
518532 private final UnaryCallSettings .Builder <ConditionalRowMutation , Boolean >
519533 checkAndMutateRowSettings ;
520534 private final UnaryCallSettings .Builder <ReadModifyWriteRow , Row > readModifyWriteRowSettings ;
535+ private final UnaryCallSettings .Builder <PingAndWarmRequest , Void > pingAndWarmSettings ;
521536
522537 /**
523538 * Initializes a new Builder with sane defaults for all settings.
@@ -629,6 +644,15 @@ private Builder() {
629644
630645 readModifyWriteRowSettings = UnaryCallSettings .newUnaryCallSettingsBuilder ();
631646 copyRetrySettings (baseDefaults .readModifyWriteRowSettings (), readModifyWriteRowSettings );
647+
648+ pingAndWarmSettings = UnaryCallSettings .newUnaryCallSettingsBuilder ();
649+ pingAndWarmSettings .setRetrySettings (
650+ RetrySettings .newBuilder ()
651+ .setMaxAttempts (1 )
652+ .setInitialRpcTimeout (PRIME_REQUEST_TIMEOUT )
653+ .setMaxRpcTimeout (PRIME_REQUEST_TIMEOUT )
654+ .setTotalTimeout (PRIME_REQUEST_TIMEOUT )
655+ .build ());
632656 }
633657
634658 private Builder (EnhancedBigtableStubSettings settings ) {
@@ -649,6 +673,7 @@ private Builder(EnhancedBigtableStubSettings settings) {
649673 bulkReadRowsSettings = settings .bulkReadRowsSettings .toBuilder ();
650674 checkAndMutateRowSettings = settings .checkAndMutateRowSettings .toBuilder ();
651675 readModifyWriteRowSettings = settings .readModifyWriteRowSettings .toBuilder ();
676+ pingAndWarmSettings = settings .pingAndWarmSettings .toBuilder ();
652677 }
653678 // <editor-fold desc="Private Helpers">
654679
@@ -817,6 +842,11 @@ public UnaryCallSettings.Builder<ReadModifyWriteRow, Row> readModifyWriteRowSett
817842 return readModifyWriteRowSettings ;
818843 }
819844
845+ /** Returns the builder with the settings used for calls to PingAndWarm. */
846+ public UnaryCallSettings .Builder <PingAndWarmRequest , Void > pingAndWarmSettings () {
847+ return pingAndWarmSettings ;
848+ }
849+
820850 @ SuppressWarnings ("unchecked" )
821851 public EnhancedBigtableStubSettings build () {
822852 Preconditions .checkState (projectId != null , "Project id must be set" );
@@ -864,6 +894,7 @@ public String toString() {
864894 .add ("bulkReadRowsSettings" , bulkReadRowsSettings )
865895 .add ("checkAndMutateRowSettings" , checkAndMutateRowSettings )
866896 .add ("readModifyWriteRowSettings" , readModifyWriteRowSettings )
897+ .add ("pingAndWarmSettings" , pingAndWarmSettings )
867898 .add ("parent" , super .toString ())
868899 .toString ();
869900 }
0 commit comments