[go: nahoru, domu]

Skip to content

Commit

Permalink
feat: add WarmAndPing request for channel priming (#1178)
Browse files Browse the repository at this point in the history
* feat: add WarmAndPing request for channel priming

PiperOrigin-RevId: 428795660

Source-Link: googleapis/googleapis@6cce671

Source-Link: googleapis/googleapis-gen@2282bc1
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMjI4MmJjMWIwODEzNjRlYTc4MzMwMGJlOTFhOGMxNGNiNGE3MThjNCJ9

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] committed Feb 16, 2022
1 parent 7ff5fa7 commit 385ab33
Show file tree
Hide file tree
Showing 13 changed files with 1,966 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
"MutateRows": {
"methods": ["mutateRowsCallable"]
},
"PingAndWarm": {
"methods": ["pingAndWarm", "pingAndWarm", "pingAndWarm", "pingAndWarm", "pingAndWarm", "pingAndWarmCallable"]
},
"ReadModifyWriteRow": {
"methods": ["readModifyWriteRow", "readModifyWriteRow", "readModifyWriteRow", "readModifyWriteRow", "readModifyWriteRow", "readModifyWriteRowCallable"]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import com.google.bigtable.v2.MutateRowResponse;
import com.google.bigtable.v2.MutateRowsRequest;
import com.google.bigtable.v2.MutateRowsResponse;
import com.google.bigtable.v2.PingAndWarmRequest;
import com.google.bigtable.v2.PingAndWarmResponse;
import com.google.bigtable.v2.ReadModifyWriteRowRequest;
import com.google.bigtable.v2.ReadModifyWriteRowResponse;
import com.google.bigtable.v2.ReadRowsRequest;
Expand Down Expand Up @@ -62,6 +64,10 @@ public ServerStreamingCallable<MutateRowsRequest, MutateRowsResponse> mutateRows
throw new UnsupportedOperationException("Not implemented: checkAndMutateRowCallable()");
}

public UnaryCallable<PingAndWarmRequest, PingAndWarmResponse> pingAndWarmCallable() {
throw new UnsupportedOperationException("Not implemented: pingAndWarmCallable()");
}

public UnaryCallable<ReadModifyWriteRowRequest, ReadModifyWriteRowResponse>
readModifyWriteRowCallable() {
throw new UnsupportedOperationException("Not implemented: readModifyWriteRowCallable()");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
import com.google.bigtable.v2.MutateRowResponse;
import com.google.bigtable.v2.MutateRowsRequest;
import com.google.bigtable.v2.MutateRowsResponse;
import com.google.bigtable.v2.PingAndWarmRequest;
import com.google.bigtable.v2.PingAndWarmResponse;
import com.google.bigtable.v2.ReadModifyWriteRowRequest;
import com.google.bigtable.v2.ReadModifyWriteRowResponse;
import com.google.bigtable.v2.ReadRowsRequest;
Expand Down Expand Up @@ -78,6 +80,7 @@ public class BigtableStubSettings extends StubSettings<BigtableStubSettings> {
mutateRowsSettings;
private final UnaryCallSettings<CheckAndMutateRowRequest, CheckAndMutateRowResponse>
checkAndMutateRowSettings;
private final UnaryCallSettings<PingAndWarmRequest, PingAndWarmResponse> pingAndWarmSettings;
private final UnaryCallSettings<ReadModifyWriteRowRequest, ReadModifyWriteRowResponse>
readModifyWriteRowSettings;

Expand Down Expand Up @@ -108,6 +111,11 @@ public ServerStreamingCallSettings<MutateRowsRequest, MutateRowsResponse> mutate
return checkAndMutateRowSettings;
}

/** Returns the object with the settings used for calls to pingAndWarm. */
public UnaryCallSettings<PingAndWarmRequest, PingAndWarmResponse> pingAndWarmSettings() {
return pingAndWarmSettings;
}

/** Returns the object with the settings used for calls to readModifyWriteRow. */
public UnaryCallSettings<ReadModifyWriteRowRequest, ReadModifyWriteRowResponse>
readModifyWriteRowSettings() {
Expand Down Expand Up @@ -194,6 +202,7 @@ protected BigtableStubSettings(Builder settingsBuilder) throws IOException {
mutateRowSettings = settingsBuilder.mutateRowSettings().build();
mutateRowsSettings = settingsBuilder.mutateRowsSettings().build();
checkAndMutateRowSettings = settingsBuilder.checkAndMutateRowSettings().build();
pingAndWarmSettings = settingsBuilder.pingAndWarmSettings().build();
readModifyWriteRowSettings = settingsBuilder.readModifyWriteRowSettings().build();
}

Expand All @@ -209,6 +218,8 @@ public static class Builder extends StubSettings.Builder<BigtableStubSettings, B
mutateRowsSettings;
private final UnaryCallSettings.Builder<CheckAndMutateRowRequest, CheckAndMutateRowResponse>
checkAndMutateRowSettings;
private final UnaryCallSettings.Builder<PingAndWarmRequest, PingAndWarmResponse>
pingAndWarmSettings;
private final UnaryCallSettings.Builder<ReadModifyWriteRowRequest, ReadModifyWriteRowResponse>
readModifyWriteRowSettings;
private static final ImmutableMap<String, ImmutableSet<StatusCode.Code>>
Expand All @@ -218,18 +229,19 @@ public static class Builder extends StubSettings.Builder<BigtableStubSettings, B
ImmutableMap.Builder<String, ImmutableSet<StatusCode.Code>> definitions =
ImmutableMap.builder();
definitions.put(
"retry_policy_3_codes", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList()));
"no_retry_3_codes", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList()));
definitions.put(
"retry_policy_1_codes", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList()));
"no_retry_1_codes", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList()));
definitions.put(
"retry_policy_4_codes",
ImmutableSet.copyOf(
Lists.<StatusCode.Code>newArrayList(
StatusCode.Code.UNAVAILABLE, StatusCode.Code.DEADLINE_EXCEEDED)));
definitions.put(
"retry_policy_2_codes", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList()));
"no_retry_2_codes", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList()));
definitions.put(
"retry_policy_0_codes", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList()));
"no_retry_0_codes", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList()));
definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList()));
RETRYABLE_CODE_DEFINITIONS = definitions.build();
}

Expand All @@ -240,26 +252,20 @@ public static class Builder extends StubSettings.Builder<BigtableStubSettings, B
RetrySettings settings = null;
settings =
RetrySettings.newBuilder()
.setInitialRetryDelay(Duration.ofMillis(10L))
.setRetryDelayMultiplier(2.0)
.setMaxRetryDelay(Duration.ofMillis(60000L))
.setInitialRpcTimeout(Duration.ofMillis(43200000L))
.setRpcTimeoutMultiplier(1.0)
.setMaxRpcTimeout(Duration.ofMillis(43200000L))
.setTotalTimeout(Duration.ofMillis(43200000L))
.build();
definitions.put("retry_policy_3_params", settings);
definitions.put("no_retry_3_params", settings);
settings =
RetrySettings.newBuilder()
.setInitialRetryDelay(Duration.ofMillis(10L))
.setRetryDelayMultiplier(2.0)
.setMaxRetryDelay(Duration.ofMillis(60000L))
.setInitialRpcTimeout(Duration.ofMillis(60000L))
.setRpcTimeoutMultiplier(1.0)
.setMaxRpcTimeout(Duration.ofMillis(60000L))
.setTotalTimeout(Duration.ofMillis(60000L))
.build();
definitions.put("retry_policy_1_params", settings);
definitions.put("no_retry_1_params", settings);
settings =
RetrySettings.newBuilder()
.setInitialRetryDelay(Duration.ofMillis(10L))
Expand All @@ -273,26 +279,22 @@ public static class Builder extends StubSettings.Builder<BigtableStubSettings, B
definitions.put("retry_policy_4_params", settings);
settings =
RetrySettings.newBuilder()
.setInitialRetryDelay(Duration.ofMillis(10L))
.setRetryDelayMultiplier(2.0)
.setMaxRetryDelay(Duration.ofMillis(60000L))
.setInitialRpcTimeout(Duration.ofMillis(600000L))
.setRpcTimeoutMultiplier(1.0)
.setMaxRpcTimeout(Duration.ofMillis(600000L))
.setTotalTimeout(Duration.ofMillis(600000L))
.build();
definitions.put("retry_policy_2_params", settings);
definitions.put("no_retry_2_params", settings);
settings =
RetrySettings.newBuilder()
.setInitialRetryDelay(Duration.ofMillis(10L))
.setRetryDelayMultiplier(2.0)
.setMaxRetryDelay(Duration.ofMillis(60000L))
.setInitialRpcTimeout(Duration.ofMillis(20000L))
.setRpcTimeoutMultiplier(1.0)
.setMaxRpcTimeout(Duration.ofMillis(20000L))
.setTotalTimeout(Duration.ofMillis(20000L))
.build();
definitions.put("retry_policy_0_params", settings);
definitions.put("no_retry_0_params", settings);
settings = RetrySettings.newBuilder().setRpcTimeoutMultiplier(1.0).build();
definitions.put("no_retry_params", settings);
RETRY_PARAM_DEFINITIONS = definitions.build();
}

Expand All @@ -308,11 +310,15 @@ protected Builder(ClientContext clientContext) {
mutateRowSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
mutateRowsSettings = ServerStreamingCallSettings.newBuilder();
checkAndMutateRowSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
pingAndWarmSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
readModifyWriteRowSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();

unaryMethodSettingsBuilders =
ImmutableList.<UnaryCallSettings.Builder<?, ?>>of(
mutateRowSettings, checkAndMutateRowSettings, readModifyWriteRowSettings);
mutateRowSettings,
checkAndMutateRowSettings,
pingAndWarmSettings,
readModifyWriteRowSettings);
initDefaults(this);
}

Expand All @@ -324,11 +330,15 @@ protected Builder(BigtableStubSettings settings) {
mutateRowSettings = settings.mutateRowSettings.toBuilder();
mutateRowsSettings = settings.mutateRowsSettings.toBuilder();
checkAndMutateRowSettings = settings.checkAndMutateRowSettings.toBuilder();
pingAndWarmSettings = settings.pingAndWarmSettings.toBuilder();
readModifyWriteRowSettings = settings.readModifyWriteRowSettings.toBuilder();

unaryMethodSettingsBuilders =
ImmutableList.<UnaryCallSettings.Builder<?, ?>>of(
mutateRowSettings, checkAndMutateRowSettings, readModifyWriteRowSettings);
mutateRowSettings,
checkAndMutateRowSettings,
pingAndWarmSettings,
readModifyWriteRowSettings);
}

private static Builder createDefault() {
Expand All @@ -347,13 +357,13 @@ private static Builder createDefault() {
private static Builder initDefaults(Builder builder) {
builder
.readRowsSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_3_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_3_params"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_3_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_3_params"));

builder
.sampleRowKeysSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params"));

builder
.mutateRowSettings()
Expand All @@ -362,18 +372,23 @@ private static Builder initDefaults(Builder builder) {

builder
.mutateRowsSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_2_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_2_params"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_2_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_2_params"));

builder
.checkAndMutateRowSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params"));

builder
.pingAndWarmSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params"));

builder
.readModifyWriteRowSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params"));

return builder;
}
Expand Down Expand Up @@ -422,6 +437,12 @@ public UnaryCallSettings.Builder<MutateRowRequest, MutateRowResponse> mutateRowS
return checkAndMutateRowSettings;
}

/** Returns the builder for the settings used for calls to pingAndWarm. */
public UnaryCallSettings.Builder<PingAndWarmRequest, PingAndWarmResponse>
pingAndWarmSettings() {
return pingAndWarmSettings;
}

/** Returns the builder for the settings used for calls to readModifyWriteRow. */
public UnaryCallSettings.Builder<ReadModifyWriteRowRequest, ReadModifyWriteRowResponse>
readModifyWriteRowSettings() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import com.google.bigtable.v2.MutateRowResponse;
import com.google.bigtable.v2.MutateRowsRequest;
import com.google.bigtable.v2.MutateRowsResponse;
import com.google.bigtable.v2.PingAndWarmRequest;
import com.google.bigtable.v2.PingAndWarmResponse;
import com.google.bigtable.v2.ReadModifyWriteRowRequest;
import com.google.bigtable.v2.ReadModifyWriteRowResponse;
import com.google.bigtable.v2.ReadRowsRequest;
Expand Down Expand Up @@ -99,6 +101,16 @@ public class GrpcBigtableStub extends BigtableStub {
ProtoUtils.marshaller(CheckAndMutateRowResponse.getDefaultInstance()))
.build();

private static final MethodDescriptor<PingAndWarmRequest, PingAndWarmResponse>
pingAndWarmMethodDescriptor =
MethodDescriptor.<PingAndWarmRequest, PingAndWarmResponse>newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.bigtable.v2.Bigtable/PingAndWarm")
.setRequestMarshaller(ProtoUtils.marshaller(PingAndWarmRequest.getDefaultInstance()))
.setResponseMarshaller(
ProtoUtils.marshaller(PingAndWarmResponse.getDefaultInstance()))
.build();

private static final MethodDescriptor<ReadModifyWriteRowRequest, ReadModifyWriteRowResponse>
readModifyWriteRowMethodDescriptor =
MethodDescriptor.<ReadModifyWriteRowRequest, ReadModifyWriteRowResponse>newBuilder()
Expand All @@ -117,6 +129,7 @@ public class GrpcBigtableStub extends BigtableStub {
private final ServerStreamingCallable<MutateRowsRequest, MutateRowsResponse> mutateRowsCallable;
private final UnaryCallable<CheckAndMutateRowRequest, CheckAndMutateRowResponse>
checkAndMutateRowCallable;
private final UnaryCallable<PingAndWarmRequest, PingAndWarmResponse> pingAndWarmCallable;
private final UnaryCallable<ReadModifyWriteRowRequest, ReadModifyWriteRowResponse>
readModifyWriteRowCallable;

Expand Down Expand Up @@ -144,6 +157,10 @@ public class GrpcBigtableStub extends BigtableStub {
PathTemplate.create("{table_name=projects/*/instances/*/tables/*}");
private static final PathTemplate CHECK_AND_MUTATE_ROW_1_PATH_TEMPLATE =
PathTemplate.create("{app_profile_id=**}");
private static final PathTemplate PING_AND_WARM_0_PATH_TEMPLATE =
PathTemplate.create("{name=projects/*/instances/*}");
private static final PathTemplate PING_AND_WARM_1_PATH_TEMPLATE =
PathTemplate.create("{app_profile_id=**}");
private static final PathTemplate READ_MODIFY_WRITE_ROW_0_PATH_TEMPLATE =
PathTemplate.create("{table_name=projects/*/instances/*/tables/*}");
private static final PathTemplate READ_MODIFY_WRITE_ROW_1_PATH_TEMPLATE =
Expand Down Expand Up @@ -251,6 +268,18 @@ protected GrpcBigtableStub(
return builder.build();
})
.build();
GrpcCallSettings<PingAndWarmRequest, PingAndWarmResponse> pingAndWarmTransportSettings =
GrpcCallSettings.<PingAndWarmRequest, PingAndWarmResponse>newBuilder()
.setMethodDescriptor(pingAndWarmMethodDescriptor)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add(request.getName(), "name", PING_AND_WARM_0_PATH_TEMPLATE);
builder.add(
request.getAppProfileId(), "app_profile_id", PING_AND_WARM_1_PATH_TEMPLATE);
return builder.build();
})
.build();
GrpcCallSettings<ReadModifyWriteRowRequest, ReadModifyWriteRowResponse>
readModifyWriteRowTransportSettings =
GrpcCallSettings.<ReadModifyWriteRowRequest, ReadModifyWriteRowResponse>newBuilder()
Expand Down Expand Up @@ -287,6 +316,9 @@ protected GrpcBigtableStub(
checkAndMutateRowTransportSettings,
settings.checkAndMutateRowSettings(),
clientContext);
this.pingAndWarmCallable =
callableFactory.createUnaryCallable(
pingAndWarmTransportSettings, settings.pingAndWarmSettings(), clientContext);
this.readModifyWriteRowCallable =
callableFactory.createUnaryCallable(
readModifyWriteRowTransportSettings,
Expand Down Expand Up @@ -328,6 +360,11 @@ public ServerStreamingCallable<MutateRowsRequest, MutateRowsResponse> mutateRows
return checkAndMutateRowCallable;
}

@Override
public UnaryCallable<PingAndWarmRequest, PingAndWarmResponse> pingAndWarmCallable() {
return pingAndWarmCallable;
}

@Override
public UnaryCallable<ReadModifyWriteRowRequest, ReadModifyWriteRowResponse>
readModifyWriteRowCallable() {
Expand Down
Loading

0 comments on commit 385ab33

Please sign in to comment.