Skip to content

Commit b17177f

Browse files
yoshi-automationhengfengli
authored andcommitted
fix: migrate spanner/v1 to grpc_service_config
PiperOrigin-RevId: 320114059 Source-Author: Google APIs <[email protected]> Source-Date: Tue Jul 7 20:27:48 2020 -0700 Source-Repo: googleapis/googleapis Source-Sha: c29c4c519667a51c0e2cfddda9c3a66be77bdf38 Source-Link: googleapis/googleapis@c29c4c5
1 parent b7c1182 commit b17177f

File tree

2 files changed

+56
-41
lines changed

2 files changed

+56
-41
lines changed

google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/stub/SpannerStubSettings.java

Lines changed: 54 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -386,12 +386,17 @@ public static class Builder extends StubSettings.Builder<SpannerStubSettings, Bu
386386
ImmutableMap.Builder<String, ImmutableSet<StatusCode.Code>> definitions =
387387
ImmutableMap.builder();
388388
definitions.put(
389-
"idempotent",
389+
"retry_policy_1_codes",
390390
ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList(StatusCode.Code.UNAVAILABLE)));
391-
definitions.put("non_idempotent", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList()));
391+
definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList()));
392392
definitions.put(
393-
"long_running",
393+
"retry_policy_3_codes",
394394
ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList(StatusCode.Code.UNAVAILABLE)));
395+
definitions.put(
396+
"retry_policy_2_codes",
397+
ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList(StatusCode.Code.UNAVAILABLE)));
398+
definitions.put(
399+
"no_retry_1_codes", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList()));
395400
RETRYABLE_CODE_DEFINITIONS = definitions.build();
396401
}
397402

@@ -410,29 +415,39 @@ public static class Builder extends StubSettings.Builder<SpannerStubSettings, Bu
410415
.setMaxRpcTimeout(Duration.ofMillis(3600000L))
411416
.setTotalTimeout(Duration.ofMillis(3600000L))
412417
.build();
413-
definitions.put("default", settings);
418+
definitions.put("retry_policy_1_params", settings);
414419
settings =
415420
RetrySettings.newBuilder()
416421
.setInitialRetryDelay(Duration.ofMillis(250L))
417422
.setRetryDelayMultiplier(1.3)
418423
.setMaxRetryDelay(Duration.ofMillis(32000L))
419-
.setInitialRpcTimeout(Duration.ofMillis(3600000L))
424+
.setInitialRpcTimeout(Duration.ofMillis(30000L))
420425
.setRpcTimeoutMultiplier(1.0)
421-
.setMaxRpcTimeout(Duration.ofMillis(3600000L))
422-
.setTotalTimeout(Duration.ofMillis(3600000L))
426+
.setMaxRpcTimeout(Duration.ofMillis(30000L))
427+
.setTotalTimeout(Duration.ofMillis(30000L))
423428
.build();
424-
definitions.put("streaming", settings);
429+
definitions.put("retry_policy_3_params", settings);
425430
settings =
426431
RetrySettings.newBuilder()
427432
.setInitialRetryDelay(Duration.ofMillis(250L))
428433
.setRetryDelayMultiplier(1.3)
429434
.setMaxRetryDelay(Duration.ofMillis(32000L))
435+
.setInitialRpcTimeout(Duration.ofMillis(60000L))
436+
.setRpcTimeoutMultiplier(1.0)
437+
.setMaxRpcTimeout(Duration.ofMillis(60000L))
438+
.setTotalTimeout(Duration.ofMillis(60000L))
439+
.build();
440+
definitions.put("retry_policy_2_params", settings);
441+
settings = RetrySettings.newBuilder().setRpcTimeoutMultiplier(1.0).build();
442+
definitions.put("no_retry_params", settings);
443+
settings =
444+
RetrySettings.newBuilder()
430445
.setInitialRpcTimeout(Duration.ofMillis(3600000L))
431446
.setRpcTimeoutMultiplier(1.0)
432447
.setMaxRpcTimeout(Duration.ofMillis(3600000L))
433448
.setTotalTimeout(Duration.ofMillis(3600000L))
434449
.build();
435-
definitions.put("long_running", settings);
450+
definitions.put("no_retry_1_params", settings);
436451
RETRY_PARAM_DEFINITIONS = definitions.build();
437452
}
438453

@@ -505,78 +520,78 @@ private static Builder initDefaults(Builder builder) {
505520

506521
builder
507522
.createSessionSettings()
508-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
509-
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
523+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_3_codes"))
524+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_3_params"));
510525

511526
builder
512527
.batchCreateSessionsSettings()
513-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
514-
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
528+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_2_codes"))
529+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_2_params"));
515530

516531
builder
517532
.getSessionSettings()
518-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
519-
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
533+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_3_codes"))
534+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_3_params"));
520535

521536
builder
522537
.listSessionsSettings()
523-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
524-
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
538+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
539+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));
525540

526541
builder
527542
.deleteSessionSettings()
528-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
529-
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
543+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_3_codes"))
544+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_3_params"));
530545

531546
builder
532547
.executeSqlSettings()
533-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
534-
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
548+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_3_codes"))
549+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_3_params"));
535550

536551
builder
537552
.executeStreamingSqlSettings()
538-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
539-
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("streaming"));
553+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes"))
554+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params"));
540555

541556
builder
542557
.executeBatchDmlSettings()
543-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
544-
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
558+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_3_codes"))
559+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_3_params"));
545560

546561
builder
547562
.readSettings()
548-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
549-
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
563+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_3_codes"))
564+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_3_params"));
550565

551566
builder
552567
.streamingReadSettings()
553-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
554-
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("streaming"));
568+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes"))
569+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params"));
555570

556571
builder
557572
.beginTransactionSettings()
558-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
559-
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
573+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_3_codes"))
574+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_3_params"));
560575

561576
builder
562577
.commitSettings()
563-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("long_running"))
564-
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("long_running"));
578+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
579+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));
565580

566581
builder
567582
.rollbackSettings()
568-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
569-
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
583+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_3_codes"))
584+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_3_params"));
570585

571586
builder
572587
.partitionQuerySettings()
573-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
574-
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
588+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_3_codes"))
589+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_3_params"));
575590

576591
builder
577592
.partitionReadSettings()
578-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
579-
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
593+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_3_codes"))
594+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_3_params"));
580595

581596
return builder;
582597
}

synth.metadata

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
"git": {
1212
"name": "googleapis",
1313
"remote": "https://github.com/googleapis/googleapis.git",
14-
"sha": "8bbefeffb4c91fd34e1729bbc51dfc136557d88d",
15-
"internalRef": "320114042"
14+
"sha": "c29c4c519667a51c0e2cfddda9c3a66be77bdf38",
15+
"internalRef": "320114059"
1616
}
1717
},
1818
{

0 commit comments

Comments
 (0)