Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Cross Region backup proto changes #1754

Merged
merged 4 commits into from
Mar 24, 2022
Merged
Show file tree
Hide file tree
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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
import com.google.longrunning.Operation;
import com.google.protobuf.Empty;
import com.google.spanner.admin.database.v1.Backup;
import com.google.spanner.admin.database.v1.CopyBackupMetadata;
import com.google.spanner.admin.database.v1.CopyBackupRequest;
import com.google.spanner.admin.database.v1.CreateBackupMetadata;
import com.google.spanner.admin.database.v1.CreateBackupRequest;
import com.google.spanner.admin.database.v1.CreateDatabaseMetadata;
Expand Down Expand Up @@ -174,6 +176,17 @@ public UnaryCallSettings<CreateBackupRequest, Operation> createBackupSettings()
return ((DatabaseAdminStubSettings) getStubSettings()).createBackupOperationSettings();
}

/** Returns the object with the settings used for calls to copyBackup. */
public UnaryCallSettings<CopyBackupRequest, Operation> copyBackupSettings() {
return ((DatabaseAdminStubSettings) getStubSettings()).copyBackupSettings();
}

/** Returns the object with the settings used for calls to copyBackup. */
public OperationCallSettings<CopyBackupRequest, Backup, CopyBackupMetadata>
copyBackupOperationSettings() {
return ((DatabaseAdminStubSettings) getStubSettings()).copyBackupOperationSettings();
}

/** Returns the object with the settings used for calls to getBackup. */
public UnaryCallSettings<GetBackupRequest, Backup> getBackupSettings() {
return ((DatabaseAdminStubSettings) getStubSettings()).getBackupSettings();
Expand Down Expand Up @@ -394,6 +407,17 @@ public UnaryCallSettings.Builder<CreateBackupRequest, Operation> createBackupSet
return getStubSettingsBuilder().createBackupOperationSettings();
}

/** Returns the builder for the settings used for calls to copyBackup. */
public UnaryCallSettings.Builder<CopyBackupRequest, Operation> copyBackupSettings() {
return getStubSettingsBuilder().copyBackupSettings();
}

/** Returns the builder for the settings used for calls to copyBackup. */
public OperationCallSettings.Builder<CopyBackupRequest, Backup, CopyBackupMetadata>
copyBackupOperationSettings() {
return getStubSettingsBuilder().copyBackupOperationSettings();
}

/** Returns the builder for the settings used for calls to getBackup. */
public UnaryCallSettings.Builder<GetBackupRequest, Backup> getBackupSettings() {
return getStubSettingsBuilder().getBackupSettings();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"grpc": {
"libraryClient": "DatabaseAdminClient",
"rpcs": {
"CopyBackup": {
"methods": ["copyBackupAsync", "copyBackupAsync", "copyBackupAsync", "copyBackupAsync", "copyBackupAsync", "copyBackupOperationCallable", "copyBackupCallable"]
},
"CreateBackup": {
"methods": ["createBackupAsync", "createBackupAsync", "createBackupAsync", "createBackupOperationCallable", "createBackupCallable"]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import com.google.longrunning.stub.OperationsStub;
import com.google.protobuf.Empty;
import com.google.spanner.admin.database.v1.Backup;
import com.google.spanner.admin.database.v1.CopyBackupMetadata;
import com.google.spanner.admin.database.v1.CopyBackupRequest;
import com.google.spanner.admin.database.v1.CreateBackupMetadata;
import com.google.spanner.admin.database.v1.CreateBackupRequest;
import com.google.spanner.admin.database.v1.CreateDatabaseMetadata;
Expand Down Expand Up @@ -134,6 +136,15 @@ public UnaryCallable<CreateBackupRequest, Operation> createBackupCallable() {
throw new UnsupportedOperationException("Not implemented: createBackupCallable()");
}

public OperationCallable<CopyBackupRequest, Backup, CopyBackupMetadata>
copyBackupOperationCallable() {
throw new UnsupportedOperationException("Not implemented: copyBackupOperationCallable()");
}

public UnaryCallable<CopyBackupRequest, Operation> copyBackupCallable() {
throw new UnsupportedOperationException("Not implemented: copyBackupCallable()");
}

public UnaryCallable<GetBackupRequest, Backup> getBackupCallable() {
throw new UnsupportedOperationException("Not implemented: getBackupCallable()");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
import com.google.longrunning.Operation;
import com.google.protobuf.Empty;
import com.google.spanner.admin.database.v1.Backup;
import com.google.spanner.admin.database.v1.CopyBackupMetadata;
import com.google.spanner.admin.database.v1.CopyBackupRequest;
import com.google.spanner.admin.database.v1.CreateBackupMetadata;
import com.google.spanner.admin.database.v1.CreateBackupRequest;
import com.google.spanner.admin.database.v1.CreateDatabaseMetadata;
Expand Down Expand Up @@ -149,6 +151,9 @@ public class DatabaseAdminStubSettings extends StubSettings<DatabaseAdminStubSet
private final UnaryCallSettings<CreateBackupRequest, Operation> createBackupSettings;
private final OperationCallSettings<CreateBackupRequest, Backup, CreateBackupMetadata>
createBackupOperationSettings;
private final UnaryCallSettings<CopyBackupRequest, Operation> copyBackupSettings;
private final OperationCallSettings<CopyBackupRequest, Backup, CopyBackupMetadata>
copyBackupOperationSettings;
private final UnaryCallSettings<GetBackupRequest, Backup> getBackupSettings;
private final UnaryCallSettings<UpdateBackupRequest, Backup> updateBackupSettings;
private final UnaryCallSettings<DeleteBackupRequest, Empty> deleteBackupSettings;
Expand Down Expand Up @@ -473,6 +478,17 @@ public UnaryCallSettings<CreateBackupRequest, Operation> createBackupSettings()
return createBackupOperationSettings;
}

/** Returns the object with the settings used for calls to copyBackup. */
public UnaryCallSettings<CopyBackupRequest, Operation> copyBackupSettings() {
return copyBackupSettings;
}

/** Returns the object with the settings used for calls to copyBackup. */
public OperationCallSettings<CopyBackupRequest, Backup, CopyBackupMetadata>
copyBackupOperationSettings() {
return copyBackupOperationSettings;
}

/** Returns the object with the settings used for calls to getBackup. */
public UnaryCallSettings<GetBackupRequest, Backup> getBackupSettings() {
return getBackupSettings;
Expand Down Expand Up @@ -613,6 +629,8 @@ protected DatabaseAdminStubSettings(Builder settingsBuilder) throws IOException
testIamPermissionsSettings = settingsBuilder.testIamPermissionsSettings().build();
createBackupSettings = settingsBuilder.createBackupSettings().build();
createBackupOperationSettings = settingsBuilder.createBackupOperationSettings().build();
copyBackupSettings = settingsBuilder.copyBackupSettings().build();
copyBackupOperationSettings = settingsBuilder.copyBackupOperationSettings().build();
getBackupSettings = settingsBuilder.getBackupSettings().build();
updateBackupSettings = settingsBuilder.updateBackupSettings().build();
deleteBackupSettings = settingsBuilder.deleteBackupSettings().build();
Expand Down Expand Up @@ -650,6 +668,9 @@ public static class Builder extends StubSettings.Builder<DatabaseAdminStubSettin
private final UnaryCallSettings.Builder<CreateBackupRequest, Operation> createBackupSettings;
private final OperationCallSettings.Builder<CreateBackupRequest, Backup, CreateBackupMetadata>
createBackupOperationSettings;
private final UnaryCallSettings.Builder<CopyBackupRequest, Operation> copyBackupSettings;
private final OperationCallSettings.Builder<CopyBackupRequest, Backup, CopyBackupMetadata>
copyBackupOperationSettings;
private final UnaryCallSettings.Builder<GetBackupRequest, Backup> getBackupSettings;
private final UnaryCallSettings.Builder<UpdateBackupRequest, Backup> updateBackupSettings;
private final UnaryCallSettings.Builder<DeleteBackupRequest, Empty> deleteBackupSettings;
Expand Down Expand Up @@ -760,6 +781,8 @@ protected Builder(ClientContext clientContext) {
testIamPermissionsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
createBackupSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
createBackupOperationSettings = OperationCallSettings.newBuilder();
copyBackupSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
copyBackupOperationSettings = OperationCallSettings.newBuilder();
getBackupSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
updateBackupSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
deleteBackupSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
Expand All @@ -783,6 +806,7 @@ protected Builder(ClientContext clientContext) {
getIamPolicySettings,
testIamPermissionsSettings,
createBackupSettings,
copyBackupSettings,
getBackupSettings,
updateBackupSettings,
deleteBackupSettings,
Expand All @@ -809,6 +833,8 @@ protected Builder(DatabaseAdminStubSettings settings) {
testIamPermissionsSettings = settings.testIamPermissionsSettings.toBuilder();
createBackupSettings = settings.createBackupSettings.toBuilder();
createBackupOperationSettings = settings.createBackupOperationSettings.toBuilder();
copyBackupSettings = settings.copyBackupSettings.toBuilder();
copyBackupOperationSettings = settings.copyBackupOperationSettings.toBuilder();
getBackupSettings = settings.getBackupSettings.toBuilder();
updateBackupSettings = settings.updateBackupSettings.toBuilder();
deleteBackupSettings = settings.deleteBackupSettings.toBuilder();
Expand All @@ -830,6 +856,7 @@ protected Builder(DatabaseAdminStubSettings settings) {
getIamPolicySettings,
testIamPermissionsSettings,
createBackupSettings,
copyBackupSettings,
getBackupSettings,
updateBackupSettings,
deleteBackupSettings,
Expand Down Expand Up @@ -903,6 +930,11 @@ private static Builder initDefaults(Builder builder) {
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_2_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_2_params"));

builder
.copyBackupSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_2_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_2_params"));

builder
.getBackupSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
Expand Down Expand Up @@ -1011,6 +1043,29 @@ private static Builder initDefaults(Builder builder) {
.setTotalTimeout(Duration.ofMillis(172800000L))
.build()));

builder
.copyBackupOperationSettings()
.setInitialCallSettings(
UnaryCallSettings.<CopyBackupRequest, OperationSnapshot>newUnaryCallSettingsBuilder()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_2_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_2_params"))
.build())
.setResponseTransformer(
ProtoOperationTransformers.ResponseTransformer.create(Backup.class))
.setMetadataTransformer(
ProtoOperationTransformers.MetadataTransformer.create(CopyBackupMetadata.class))
.setPollingAlgorithm(
OperationTimedPollAlgorithm.create(
RetrySettings.newBuilder()
.setInitialRetryDelay(Duration.ofMillis(5000L))
.setRetryDelayMultiplier(1.5)
.setMaxRetryDelay(Duration.ofMillis(45000L))
.setInitialRpcTimeout(Duration.ZERO)
.setRpcTimeoutMultiplier(1.0)
.setMaxRpcTimeout(Duration.ZERO)
.setTotalTimeout(Duration.ofMillis(300000L))
.build()));

builder
.restoreDatabaseOperationSettings()
.setInitialCallSettings(
Expand Down Expand Up @@ -1132,6 +1187,19 @@ public UnaryCallSettings.Builder<CreateBackupRequest, Operation> createBackupSet
return createBackupOperationSettings;
}

/** Returns the builder for the settings used for calls to copyBackup. */
public UnaryCallSettings.Builder<CopyBackupRequest, Operation> copyBackupSettings() {
return copyBackupSettings;
}

/** Returns the builder for the settings used for calls to copyBackup. */
@BetaApi(
"The surface for use by generated code is not stable yet and may change in the future.")
public OperationCallSettings.Builder<CopyBackupRequest, Backup, CopyBackupMetadata>
copyBackupOperationSettings() {
return copyBackupOperationSettings;
}

/** Returns the builder for the settings used for calls to getBackup. */
public UnaryCallSettings.Builder<GetBackupRequest, Backup> getBackupSettings() {
return getBackupSettings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
import com.google.longrunning.stub.GrpcOperationsStub;
import com.google.protobuf.Empty;
import com.google.spanner.admin.database.v1.Backup;
import com.google.spanner.admin.database.v1.CopyBackupMetadata;
import com.google.spanner.admin.database.v1.CopyBackupRequest;
import com.google.spanner.admin.database.v1.CreateBackupMetadata;
import com.google.spanner.admin.database.v1.CreateBackupRequest;
import com.google.spanner.admin.database.v1.CreateDatabaseMetadata;
Expand Down Expand Up @@ -171,6 +173,14 @@ public class GrpcDatabaseAdminStub extends DatabaseAdminStub {
.setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
.build();

private static final MethodDescriptor<CopyBackupRequest, Operation> copyBackupMethodDescriptor =
MethodDescriptor.<CopyBackupRequest, Operation>newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
.setFullMethodName("google.spanner.admin.database.v1.DatabaseAdmin/CopyBackup")
.setRequestMarshaller(ProtoUtils.marshaller(CopyBackupRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
.build();

private static final MethodDescriptor<GetBackupRequest, Backup> getBackupMethodDescriptor =
MethodDescriptor.<GetBackupRequest, Backup>newBuilder()
.setType(MethodDescriptor.MethodType.UNARY)
Expand Down Expand Up @@ -260,6 +270,9 @@ public class GrpcDatabaseAdminStub extends DatabaseAdminStub {
private final UnaryCallable<CreateBackupRequest, Operation> createBackupCallable;
private final OperationCallable<CreateBackupRequest, Backup, CreateBackupMetadata>
createBackupOperationCallable;
private final UnaryCallable<CopyBackupRequest, Operation> copyBackupCallable;
private final OperationCallable<CopyBackupRequest, Backup, CopyBackupMetadata>
copyBackupOperationCallable;
private final UnaryCallable<GetBackupRequest, Backup> getBackupCallable;
private final UnaryCallable<UpdateBackupRequest, Backup> updateBackupCallable;
private final UnaryCallable<DeleteBackupRequest, Empty> deleteBackupCallable;
Expand Down Expand Up @@ -422,6 +435,16 @@ protected GrpcDatabaseAdminStub(
return params.build();
})
.build();
GrpcCallSettings<CopyBackupRequest, Operation> copyBackupTransportSettings =
GrpcCallSettings.<CopyBackupRequest, Operation>newBuilder()
.setMethodDescriptor(copyBackupMethodDescriptor)
.setParamsExtractor(
request -> {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("parent", String.valueOf(request.getParent()));
return params.build();
})
.build();
GrpcCallSettings<GetBackupRequest, Backup> getBackupTransportSettings =
GrpcCallSettings.<GetBackupRequest, Backup>newBuilder()
.setMethodDescriptor(getBackupMethodDescriptor)
Expand Down Expand Up @@ -551,6 +574,15 @@ protected GrpcDatabaseAdminStub(
settings.createBackupOperationSettings(),
clientContext,
operationsStub);
this.copyBackupCallable =
callableFactory.createUnaryCallable(
copyBackupTransportSettings, settings.copyBackupSettings(), clientContext);
this.copyBackupOperationCallable =
callableFactory.createOperationCallable(
copyBackupTransportSettings,
settings.copyBackupOperationSettings(),
clientContext,
operationsStub);
this.getBackupCallable =
callableFactory.createUnaryCallable(
getBackupTransportSettings, settings.getBackupSettings(), clientContext);
Expand Down Expand Up @@ -679,6 +711,17 @@ public UnaryCallable<CreateBackupRequest, Operation> createBackupCallable() {
return createBackupOperationCallable;
}

@Override
public UnaryCallable<CopyBackupRequest, Operation> copyBackupCallable() {
return copyBackupCallable;
}

@Override
public OperationCallable<CopyBackupRequest, Backup, CopyBackupMetadata>
copyBackupOperationCallable() {
return copyBackupOperationCallable;
}

@Override
public UnaryCallable<GetBackupRequest, Backup> getBackupCallable() {
return getBackupCallable;
Expand Down
Loading