File tree Expand file tree Collapse file tree 3 files changed +43
-4
lines changed
google-cloud-bigtable/src/main/java/com/google/cloud/bigtable Expand file tree Collapse file tree 3 files changed +43
-4
lines changed Original file line number Diff line number Diff line change
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
+ * https://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
+ package com .google .cloud .bigtable .data .v2 .stub ;
17
+
18
+ import com .google .api .core .InternalApi ;
19
+ import com .google .api .gax .retrying .StreamResumptionStrategy ;
20
+
21
+ @ InternalApi
22
+ /** Expand StreamResumptionStrategy to also process the error. */
23
+ public abstract class BigtableStreamResumptionStrategy <RequestT , ResponseT >
24
+ implements StreamResumptionStrategy <RequestT , ResponseT > {
25
+
26
+ public abstract Throwable processError (Throwable throwable );
27
+ }
Original file line number Diff line number Diff line change 22
22
import com .google .bigtable .v2 .RowSet ;
23
23
import com .google .cloud .bigtable .data .v2 .internal .RowSetUtil ;
24
24
import com .google .cloud .bigtable .data .v2 .models .RowAdapter ;
25
+ import com .google .cloud .bigtable .data .v2 .stub .BigtableStreamResumptionStrategy ;
25
26
import com .google .common .base .Preconditions ;
26
27
import com .google .protobuf .ByteString ;
27
28
28
29
/**
29
- * An implementation of a {@link StreamResumptionStrategy } for merged rows. This class tracks the
30
- * last complete row seen and upon retry can build a request to resume the stream from where it left
31
- * off.
30
+ * An implementation of a {@link BigtableStreamResumptionStrategy } for merged rows. This class
31
+ * tracks the last complete row seen and upon retry can build a request to resume the stream from
32
+ * where it left off.
32
33
*
33
34
* <p>This class is considered an internal implementation detail and not meant to be used by
34
35
* applications.
35
36
*/
36
37
@ InternalApi
37
38
public class ReadRowsResumptionStrategy <RowT >
38
- implements StreamResumptionStrategy <ReadRowsRequest , RowT > {
39
+ extends BigtableStreamResumptionStrategy <ReadRowsRequest , RowT > {
39
40
private final RowAdapter <RowT > rowAdapter ;
40
41
private ByteString lastKey = ByteString .EMPTY ;
41
42
// Number of rows processed excluding Marker row.
@@ -69,6 +70,12 @@ public RowT processResponse(RowT response) {
69
70
return response ;
70
71
}
71
72
73
+ @ Override
74
+ public Throwable processError (Throwable throwable ) {
75
+ // Noop
76
+ return throwable ;
77
+ }
78
+
72
79
/**
73
80
* {@inheritDoc}
74
81
*
Original file line number Diff line number Diff line change 25
25
import com .google .api .gax .rpc .ServerStreamingCallable ;
26
26
import com .google .api .gax .rpc .StateCheckingResponseObserver ;
27
27
import com .google .api .gax .rpc .StreamController ;
28
+ import com .google .cloud .bigtable .data .v2 .stub .BigtableStreamResumptionStrategy ;
28
29
import com .google .common .base .Preconditions ;
29
30
import java .util .concurrent .Callable ;
30
31
import java .util .concurrent .CancellationException ;
@@ -345,6 +346,10 @@ private void onAttemptError(Throwable throwable) {
345
346
localCancellationCause = cancellationCause ;
346
347
}
347
348
349
+ if (resumptionStrategy instanceof BigtableStreamResumptionStrategy ) {
350
+ throwable = ((BigtableStreamResumptionStrategy ) resumptionStrategy ).processError (throwable );
351
+ }
352
+
348
353
if (localCancellationCause != null ) {
349
354
// Take special care to preserve the cancellation's stack trace.
350
355
innerAttemptFuture .setException (localCancellationCause );
You can’t perform that action at this time.
0 commit comments