-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: update the accounting of partial batch mutations (#2149)
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [x] Make sure to open an issue as a [bug/issue](https://togithub.com/googleapis/java-bigtable/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [x] Ensure the tests and linter pass - [x] Code coverage does not decrease (if any source code was changed) - [x] Appropriate docs were updated (if necessary) - [x] Rollback plan is reviewed and LGTMed - [x] All new data plane features have a completed end to end testing plan Fixes #1494 ☕️ If you write sample code, please follow the [samples format]( https://togithub.com/GoogleCloudPlatform/java-docs-samples/blob/main/SAMPLE_FORMAT.md).
- Loading branch information
Showing
17 changed files
with
631 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...in/java/com/google/cloud/bigtable/data/v2/stub/MutateRowsErrorConverterUnaryCallable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.google.cloud.bigtable.data.v2.stub; | ||
|
||
import com.google.api.core.ApiFuture; | ||
import com.google.api.core.ApiFutures; | ||
import com.google.api.core.InternalApi; | ||
import com.google.api.gax.grpc.GrpcStatusCode; | ||
import com.google.api.gax.rpc.ApiCallContext; | ||
import com.google.api.gax.rpc.UnaryCallable; | ||
import com.google.cloud.bigtable.data.v2.models.BulkMutation; | ||
import com.google.cloud.bigtable.data.v2.models.MutateRowsException; | ||
import com.google.cloud.bigtable.data.v2.stub.mutaterows.MutateRowsAttemptResult; | ||
import com.google.common.util.concurrent.MoreExecutors; | ||
import io.grpc.Status; | ||
|
||
/** | ||
* This callable converts partial batch failures into an exception. This is necessary to make sure | ||
* that the caller properly handles issues and avoids possible data loss on partial failures | ||
*/ | ||
@InternalApi | ||
public class MutateRowsErrorConverterUnaryCallable extends UnaryCallable<BulkMutation, Void> { | ||
|
||
private final UnaryCallable<BulkMutation, MutateRowsAttemptResult> innerCallable; | ||
|
||
public MutateRowsErrorConverterUnaryCallable( | ||
UnaryCallable<BulkMutation, MutateRowsAttemptResult> callable) { | ||
this.innerCallable = callable; | ||
} | ||
|
||
@Override | ||
public ApiFuture<Void> futureCall(BulkMutation request, ApiCallContext context) { | ||
ApiFuture<MutateRowsAttemptResult> future = innerCallable.futureCall(request, context); | ||
return ApiFutures.transform( | ||
future, | ||
result -> { | ||
if (!result.getFailedMutations().isEmpty()) { | ||
throw MutateRowsException.create( | ||
null, | ||
GrpcStatusCode.of(Status.Code.OK), | ||
result.getFailedMutations(), | ||
result.getIsRetryable()); | ||
} | ||
return null; | ||
}, | ||
MoreExecutors.directExecutor()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.