Skip to content

Commit 62b6248

Browse files
committed
chore: merge in new APIs
BEGIN_COMMIT_OVERRIDE BEGIN_NESTED_COMMIT feat: add @BetaApi Storage#blobReadSession for gRPC Transport Add new BlobReadSession API to allow multiple reads from a single object version using the new BidiReadObject API. There are two projections available publicly at this time: SeekableByteChannel and ScatteringByteChannel. This new API is classified as a pre-GA feature and have breaking changes. END_NESTED_COMMIT BEGIN_NESTED_COMMIT feat: add @BetaApi Storage#blobAppendableUpload for gRPC Transport Add new BlobAppendableUpload API to allow appendable uploads using the new AppendableUploadSpec in BidiWriteObject API. This new API is classified as a pre-GA feature and have breaking changes. END_NESTED_COMMIT BEGIN_NESTED_COMMIT feat: implement improved retry context information Prior to this change, retries were always wired into the request path, but no information about retries was included. With this change all exceptions which lead to a terminal failure will be included as suppressed exceptions on the final exception. ``` com.google.cloud.storage.RetryContextTest$Invocation at com.google.cloud.storage.RetryContextTest.similarToRetryingHelper(RetryContextTest.java:377) ... 29 more Suppressed: com.google.cloud.storage.RetryContext$RetryBudgetExhaustedComment: Operation failed to complete within attempt budget (attempts: 6, maxAttempts: 6, elapsed: PT0.39231668S, nextBackoff: PT0.4S, timeout: PT3.125S) previous failures follow in order of occurrence Suppressed: com.google.cloud.storage.RetryContextTest$Invocation ... 29 more Suppressed: com.google.cloud.storage.RetryContext$BackoffComment: backing off PT0.0125S before next attempt Suppressed: com.google.cloud.storage.RetryContextTest$Invocation ... 29 more Suppressed: com.google.cloud.storage.RetryContext$BackoffComment: backing off PT0.025S before next attempt Suppressed: com.google.cloud.storage.RetryContextTest$Invocation ... 29 more Suppressed: com.google.cloud.storage.RetryContext$BackoffComment: backing off PT0.05S before next attempt Suppressed: com.google.cloud.storage.RetryContextTest$Invocation ... 29 more Suppressed: com.google.cloud.storage.RetryContext$BackoffComment: backing off PT0.1S before next attempt Suppressed: com.google.cloud.storage.RetryContextTest$Invocation ... 29 more Suppressed: com.google.cloud.storage.RetryContext$BackoffComment: backing off PT0.2S before next attempt ``` END_NESTED_COMMIT END_COMMIT_OVERRIDE
2 parents 7fe7b99 + c3a0aaa commit 62b6248

File tree

123 files changed

+16708
-883
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+16708
-883
lines changed

google-cloud-storage/clirr-ignored-differences.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,23 @@
120120
<method>* moveObject(*)</method>
121121
</difference>
122122

123+
<!-- Not breaking, new method has a default implementation -->
124+
<difference>
125+
<differenceType>7012</differenceType>
126+
<className>com/google/cloud/storage/Storage</className>
127+
<method>com.google.api.core.ApiFuture blobReadSession(com.google.cloud.storage.BlobId, com.google.cloud.storage.Storage$BlobSourceOption[])</method>
128+
</difference>
129+
130+
<difference>
131+
<differenceType>7012</differenceType>
132+
<className>com/google/cloud/storage/Storage</className>
133+
<method>com.google.cloud.storage.BlobAppendableUpload blobAppendableUpload(com.google.cloud.storage.BlobInfo, com.google.cloud.storage.BlobAppendableUploadConfig, com.google.cloud.storage.Storage$BlobWriteOption[])</method>
134+
</difference>
135+
<difference>
136+
<differenceType>7005</differenceType>
137+
<className>com/google/cloud/storage/Hasher$*</className>
138+
<method>* validate(*)</method>
139+
<to>* validate(*)</to>
140+
</difference>
141+
123142
</differences>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.cloud.storage;
18+
19+
import com.google.common.base.MoreObjects;
20+
import java.util.Objects;
21+
import org.checkerframework.checker.nullness.qual.Nullable;
22+
23+
final class AndThenRangeSpecFunction extends RangeSpecFunction {
24+
25+
private final RangeSpecFunction first;
26+
private final RangeSpecFunction second;
27+
28+
AndThenRangeSpecFunction(RangeSpecFunction first, RangeSpecFunction second) {
29+
this.first = first;
30+
this.second = second;
31+
}
32+
33+
@Override
34+
public RangeSpec apply(long offset, @Nullable RangeSpec prev) {
35+
return second.apply(offset, first.apply(offset, prev));
36+
}
37+
38+
@Override
39+
public boolean equals(Object o) {
40+
if (this == o) {
41+
return true;
42+
}
43+
if (!(o instanceof AndThenRangeSpecFunction)) {
44+
return false;
45+
}
46+
AndThenRangeSpecFunction that = (AndThenRangeSpecFunction) o;
47+
return Objects.equals(first, that.first) && Objects.equals(second, that.second);
48+
}
49+
50+
@Override
51+
public int hashCode() {
52+
return Objects.hash(first, second);
53+
}
54+
55+
@Override
56+
public String toString() {
57+
return MoreObjects.toStringHelper(this).add("first", first).add("second", second).toString();
58+
}
59+
}

google-cloud-storage/src/main/java/com/google/cloud/storage/ApiaryUnbufferedReadableByteChannel.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
import com.google.api.services.storage.Storage.Objects;
3030
import com.google.api.services.storage.Storage.Objects.Get;
3131
import com.google.api.services.storage.model.StorageObject;
32+
import com.google.cloud.storage.Conversions.Decoder;
33+
import com.google.cloud.storage.Retrying.Retrier;
3234
import com.google.cloud.storage.UnbufferedReadableByteChannelSession.UnbufferedReadableByteChannel;
3335
import com.google.cloud.storage.spi.v1.StorageRpc;
3436
import com.google.common.annotations.VisibleForTesting;
@@ -55,7 +57,6 @@
5557
import java.util.Locale;
5658
import java.util.Map;
5759
import java.util.Map.Entry;
58-
import java.util.function.Function;
5960
import javax.annotation.concurrent.Immutable;
6061
import org.checkerframework.checker.nullness.qual.NonNull;
6162
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -65,8 +66,8 @@ class ApiaryUnbufferedReadableByteChannel implements UnbufferedReadableByteChann
6566
private final ApiaryReadRequest apiaryReadRequest;
6667
private final Storage storage;
6768
private final SettableApiFuture<StorageObject> result;
68-
private final HttpStorageOptions options;
6969
private final ResultRetryAlgorithm<?> resultRetryAlgorithm;
70+
private final Retrier retrier;
7071

7172
private long position;
7273
private ScatteringByteChannel sbc;
@@ -80,12 +81,12 @@ class ApiaryUnbufferedReadableByteChannel implements UnbufferedReadableByteChann
8081
ApiaryReadRequest apiaryReadRequest,
8182
Storage storage,
8283
SettableApiFuture<StorageObject> result,
83-
HttpStorageOptions options,
84+
Retrier retrier,
8485
ResultRetryAlgorithm<?> resultRetryAlgorithm) {
8586
this.apiaryReadRequest = apiaryReadRequest;
8687
this.storage = storage;
8788
this.result = result;
88-
this.options = options;
89+
this.retrier = retrier;
8990
this.resultRetryAlgorithm =
9091
new BasicResultRetryAlgorithm<Object>() {
9192
@Override
@@ -113,7 +114,7 @@ public long read(ByteBuffer[] dsts, int offset, int length) throws IOException {
113114
long totalRead = 0;
114115
do {
115116
if (sbc == null) {
116-
sbc = Retrying.run(options, resultRetryAlgorithm, this::open, Function.identity());
117+
sbc = retrier.run(resultRetryAlgorithm, this::open, Decoder.identity());
117118
}
118119

119120
long totalRemaining = Buffers.totalRemaining(dsts, offset, length);

google-cloud-storage/src/main/java/com/google/cloud/storage/ApiaryUnbufferedWritableByteChannel.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717
package com.google.cloud.storage;
1818

1919
import com.google.api.core.SettableApiFuture;
20-
import com.google.api.gax.retrying.ResultRetryAlgorithm;
2120
import com.google.api.services.storage.model.StorageObject;
22-
import com.google.cloud.storage.Retrying.RetryingDependencies;
21+
import com.google.cloud.storage.Retrying.RetrierWithAlg;
2322
import com.google.cloud.storage.UnbufferedWritableByteChannelSession.UnbufferedWritableByteChannel;
2423
import java.io.IOException;
2524
import java.nio.ByteBuffer;
@@ -42,12 +41,11 @@ final class ApiaryUnbufferedWritableByteChannel implements UnbufferedWritableByt
4241

4342
ApiaryUnbufferedWritableByteChannel(
4443
HttpClientContext httpClientContext,
45-
RetryingDependencies deps,
46-
ResultRetryAlgorithm<?> alg,
44+
RetrierWithAlg retrier,
4745
JsonResumableWrite resumableWrite,
4846
SettableApiFuture<StorageObject> result,
4947
LongConsumer committedBytesCallback) {
50-
this.session = ResumableSession.json(httpClientContext, deps, alg, resumableWrite);
48+
this.session = ResumableSession.json(httpClientContext, retrier, resumableWrite);
5149
this.result = result;
5250
this.committedBytesCallback = committedBytesCallback;
5351
this.open = true;

0 commit comments

Comments
 (0)