Skip to content

Commit da5b6eb

Browse files
chore: Ignore gapic settings for all streaming RPCs (#79)
* chore: Ignore gapic settings for all streaming RPCs This is to prepare for upcoming changes that will move simple retries to gRPC. When this happens we want to retain retry settings at the client level, so they are copied into the manual settings wrapper. See cl/277568516 for more details * fix typo & remove noise from a test
1 parent 3c4154b commit da5b6eb

File tree

2 files changed

+27
-14
lines changed

2 files changed

+27
-14
lines changed

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStubSettings.java

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,25 @@ public class EnhancedBigtableStubSettings extends StubSettings<EnhancedBigtableS
102102
.setTotalTimeout(Duration.ofMinutes(10))
103103
.build();
104104

105+
// Allow retrying ABORTED statuses. These will be returned by the server when the client is
106+
// too slow to read the rows. This makes sense for the java client because retries happen
107+
// after the row merging logic. Which means that the retry will not be invoked until the
108+
// current buffered chunks are consumed.
109+
private static final Set<Code> READ_ROWS_RETRY_CODES =
110+
ImmutableSet.<Code>builder().addAll(IDEMPOTENT_RETRY_CODES).add(Code.ABORTED).build();
111+
112+
private static final RetrySettings READ_ROWS_RETRY_SETTINGS =
113+
RetrySettings.newBuilder()
114+
.setInitialRetryDelay(Duration.ofMillis(10))
115+
.setRetryDelayMultiplier(2.0)
116+
.setMaxRetryDelay(Duration.ofMinutes(1))
117+
.setJittered(true)
118+
.setInitialRpcTimeout(Duration.ofMinutes(5))
119+
.setRpcTimeoutMultiplier(2.0)
120+
.setMaxRpcTimeout(Duration.ofMinutes(5))
121+
.setTotalTimeout(Duration.ofHours(12))
122+
.build();
123+
105124
private static final RetrySettings MUTATE_ROWS_RETRY_SETTINGS =
106125
RetrySettings.newBuilder()
107126
.setInitialRetryDelay(Duration.ofMillis(10))
@@ -441,17 +460,9 @@ private Builder() {
441460
// Per-method settings using baseSettings for defaults.
442461
readRowsSettings = ServerStreamingCallSettings.newBuilder();
443462

444-
// Allow retrying ABORTED statuses. These will be returned by the server when the client is
445-
// too slow to read the rows. This makes sense for the java client because retries happen
446-
// after the row merging logic. Which means that the retry will not be invoked until the
447-
// current buffered chunks are consumed.
448463
readRowsSettings
449-
.setRetryableCodes(
450-
ImmutableSet.<Code>builder()
451-
.addAll(baseDefaults.readRowsSettings().getRetryableCodes())
452-
.add(Code.ABORTED)
453-
.build())
454-
.setRetrySettings(baseDefaults.readRowsSettings().getRetrySettings())
464+
.setRetryableCodes(READ_ROWS_RETRY_CODES)
465+
.setRetrySettings(READ_ROWS_RETRY_SETTINGS)
455466
.setIdleTimeout(Duration.ofMinutes(5));
456467

457468
// Point reads should use same defaults as streaming reads, but with a shorter timeout
@@ -468,8 +479,8 @@ private Builder() {
468479

469480
sampleRowKeysSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
470481
sampleRowKeysSettings
471-
.setRetryableCodes(baseDefaults.sampleRowKeysSettings().getRetryableCodes())
472-
.setRetrySettings(baseDefaults.sampleRowKeysSettings().getRetrySettings());
482+
.setRetryableCodes(IDEMPOTENT_RETRY_CODES)
483+
.setRetrySettings(IDEMPOTENT_RETRY_SETTINGS);
473484

474485
mutateRowSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
475486
copyRetrySettings(baseDefaults.mutateRowSettings(), mutateRowSettings);

google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/readrows/ReadRowsRetryTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,10 @@ public void setUp() throws IOException {
8383
}
8484

8585
@After
86-
public void tearDown() throws Exception {
87-
client.close();
86+
public void tearDown() {
87+
if (client != null) {
88+
client.close();
89+
}
8890
}
8991

9092
@Test

0 commit comments

Comments
 (0)