1616package com .google .cloud .bigtable .data .v2 .stub ;
1717
1818import com .google .api .core .BetaApi ;
19+ import com .google .api .core .InternalApi ;
1920import com .google .api .gax .batching .BatchingCallSettings ;
2021import com .google .api .gax .batching .BatchingDescriptor ;
2122import com .google .api .gax .batching .BatchingSettings ;
@@ -66,6 +67,8 @@ public final class BigtableBatchingCallSettings extends UnaryCallSettings<BulkMu
6667 private final Long targetRpcLatencyMs ;
6768 private final DynamicFlowControlSettings dynamicFlowControlSettings ;
6869
70+ private final boolean isServerInitiatedFlowControlEnabled ;
71+
6972 private BigtableBatchingCallSettings (Builder builder ) {
7073 super (builder );
7174 batchingCallSettings =
@@ -77,6 +80,7 @@ private BigtableBatchingCallSettings(Builder builder) {
7780 this .isLatencyBasedThrottlingEnabled = builder .isLatencyBasedThrottlingEnabled ;
7881 this .targetRpcLatencyMs = builder .targetRpcLatencyMs ;
7982 this .dynamicFlowControlSettings = builder .dynamicFlowControlSettings ;
83+ this .isServerInitiatedFlowControlEnabled = builder .isServerInitiatedFlowControlEnabled ;
8084 }
8185
8286 /** Returns batching settings which contains multiple batch threshold levels. */
@@ -109,6 +113,12 @@ DynamicFlowControlSettings getDynamicFlowControlSettings() {
109113 return dynamicFlowControlSettings ;
110114 }
111115
116+ /** Gets if flow control is enabled. */
117+ @ InternalApi ("Intended for use by the Bigtable dataflow connectors only" )
118+ public boolean isServerInitiatedFlowControlEnabled () {
119+ return isServerInitiatedFlowControlEnabled ;
120+ }
121+
112122 static Builder newBuilder (
113123 BatchingDescriptor <RowMutationEntry , Void , BulkMutation , Void > batchingDescriptor ) {
114124 return new Builder (batchingDescriptor );
@@ -130,6 +140,7 @@ public String toString() {
130140 .add ("isLatencyBasedThrottlingEnabled" , isLatencyBasedThrottlingEnabled )
131141 .add ("targetRpcLatency" , targetRpcLatencyMs )
132142 .add ("dynamicFlowControlSettings" , dynamicFlowControlSettings )
143+ .add ("isServerInitiatedFlowControlEnabled" , isServerInitiatedFlowControlEnabled )
133144 .toString ();
134145 }
135146
@@ -145,6 +156,8 @@ public static class Builder extends UnaryCallSettings.Builder<BulkMutation, Void
145156 private Long targetRpcLatencyMs ;
146157 private DynamicFlowControlSettings dynamicFlowControlSettings ;
147158
159+ private boolean isServerInitiatedFlowControlEnabled ;
160+
148161 private Builder (
149162 @ Nonnull
150163 BatchingDescriptor <RowMutationEntry , Void , BulkMutation , Void > batchingDescriptor ) {
@@ -159,6 +172,7 @@ private Builder(@Nonnull BigtableBatchingCallSettings settings) {
159172 this .isLatencyBasedThrottlingEnabled = settings .isLatencyBasedThrottlingEnabled ();
160173 this .targetRpcLatencyMs = settings .getTargetRpcLatencyMs ();
161174 this .dynamicFlowControlSettings = settings .getDynamicFlowControlSettings ();
175+ this .isServerInitiatedFlowControlEnabled = settings .isServerInitiatedFlowControlEnabled ();
162176 }
163177
164178 /** Sets the batching settings with various thresholds. */
@@ -263,6 +277,19 @@ DynamicFlowControlSettings getDynamicFlowControlSettings() {
263277 return this .dynamicFlowControlSettings ;
264278 }
265279
280+ /** Configure flow control based on the current load of the Bigtable server. */
281+ @ InternalApi ("Intended for use by the Bigtable dataflow connectors only" )
282+ public Builder setServerInitiatedFlowControl (boolean isEnable ) {
283+ this .isServerInitiatedFlowControlEnabled = isEnable ;
284+ return this ;
285+ }
286+
287+ /** Gets if flow control is enabled based on the load of the Bigtable server. */
288+ @ InternalApi ("Intended for use by the Bigtable dataflow connectors only" )
289+ public boolean isServerInitiatedFlowControlEnabled () {
290+ return this .isServerInitiatedFlowControlEnabled ;
291+ }
292+
266293 /** Builds the {@link BigtableBatchingCallSettings} object with provided configuration. */
267294 @ Override
268295 public BigtableBatchingCallSettings build () {
0 commit comments