com.google.api.gax.retrying.RetrySettings.newBuilder()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(14.8k)|赞(0)|评价(0)|浏览(161)

本文整理了Java中com.google.api.gax.retrying.RetrySettings.newBuilder方法的一些代码示例,展示了RetrySettings.newBuilder的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RetrySettings.newBuilder方法的具体详情如下:
包路径:com.google.api.gax.retrying.RetrySettings
类名称:RetrySettings
方法名:newBuilder

RetrySettings.newBuilder介绍

暂无

代码示例

代码示例来源:origin: apache/nifi

@Override
protected BigQueryOptions getServiceOptions(ProcessContext context, GoogleCredentials credentials) {
  final String projectId = context.getProperty(PROJECT_ID).evaluateAttributeExpressions().getValue();
  final Integer retryCount = Integer.valueOf(context.getProperty(RETRY_COUNT).getValue());
  final BigQueryOptions.Builder builder = BigQueryOptions.newBuilder();
  if (!StringUtils.isBlank(projectId)) {
    builder.setProjectId(projectId);
  }
  return builder.setCredentials(credentials)
      .setRetrySettings(RetrySettings.newBuilder().setMaxAttempts(retryCount).build())
      .setTransportOptions(getTransportOptions(context))
      .build();
}

代码示例来源:origin: apache/nifi

@Override
  protected StorageOptions getServiceOptions(ProcessContext context, GoogleCredentials credentials) {
    final String projectId = context.getProperty(PROJECT_ID).evaluateAttributeExpressions().getValue();
    final Integer retryCount = context.getProperty(RETRY_COUNT).asInteger();

    StorageOptions.Builder storageOptionsBuilder = StorageOptions.newBuilder()
        .setCredentials(credentials)
        .setRetrySettings(RetrySettings.newBuilder()
            .setMaxAttempts(retryCount)
            .build());

    if (!projectId.isEmpty()) {
      storageOptionsBuilder.setProjectId(projectId);
    }

    return  storageOptionsBuilder.setTransportOptions(getTransportOptions(context)).build();
  }
}

代码示例来源:origin: googleapis/google-cloud-java

.setPollingAlgorithm(
  OperationTimedPollAlgorithm.create(
    RetrySettings.newBuilder()
      .setInitialRetryDelay(Duration.ofMillis(20000L))
      .setRetryDelayMultiplier(1.5)

代码示例来源:origin: googleapis/google-cloud-java

private static RetrySettings retrySettings() {
 return RetrySettings.newBuilder()
   .setMaxRetryDelay(Duration.ofMillis(30000L))
   .setTotalTimeout(Duration.ofMillis(120000L))
   .setInitialRetryDelay(Duration.ofMillis(250L))
   .setRetryDelayMultiplier(1.0)
   .setInitialRpcTimeout(Duration.ofMillis(120000L))
   .setRpcTimeoutMultiplier(1.0)
   .setMaxRpcTimeout(Duration.ofMillis(120000L))
   .build();
}

代码示例来源:origin: googleapis/google-cloud-java

private static Builder initDefaults(Builder builder) {
 builder
   .annotateVideoSettings()
   .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
   .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
 builder
   .annotateVideoOperationSettings()
   .setInitialCallSettings(
     UnaryCallSettings
       .<AnnotateVideoRequest, OperationSnapshot>newUnaryCallSettingsBuilder()
       .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
       .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"))
       .build())
   .setResponseTransformer(
     ProtoOperationTransformers.ResponseTransformer.create(AnnotateVideoResponse.class))
   .setMetadataTransformer(
     ProtoOperationTransformers.MetadataTransformer.create(AnnotateVideoProgress.class))
   .setPollingAlgorithm(
     OperationTimedPollAlgorithm.create(
       RetrySettings.newBuilder()
         .setInitialRetryDelay(Duration.ofMillis(20000L))
         .setRetryDelayMultiplier(1.5)
         .setMaxRetryDelay(Duration.ofMillis(45000L))
         .setInitialRpcTimeout(Duration.ZERO) // ignored
         .setRpcTimeoutMultiplier(1.0) // ignored
         .setMaxRpcTimeout(Duration.ZERO) // ignored
         .setTotalTimeout(Duration.ofMillis(86400000L))
         .build()));
 return builder;
}

代码示例来源:origin: googleapis/google-cloud-java

private static Builder initDefaults(Builder builder) {
 builder
   .annotateVideoSettings()
   .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
   .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
 builder
   .annotateVideoOperationSettings()
   .setInitialCallSettings(
     UnaryCallSettings
       .<AnnotateVideoRequest, OperationSnapshot>newUnaryCallSettingsBuilder()
       .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
       .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"))
       .build())
   .setResponseTransformer(
     ProtoOperationTransformers.ResponseTransformer.create(AnnotateVideoResponse.class))
   .setMetadataTransformer(
     ProtoOperationTransformers.MetadataTransformer.create(AnnotateVideoProgress.class))
   .setPollingAlgorithm(
     OperationTimedPollAlgorithm.create(
       RetrySettings.newBuilder()
         .setInitialRetryDelay(Duration.ofMillis(20000L))
         .setRetryDelayMultiplier(1.5)
         .setMaxRetryDelay(Duration.ofMillis(45000L))
         .setInitialRpcTimeout(Duration.ZERO) // ignored
         .setRpcTimeoutMultiplier(1.0) // ignored
         .setMaxRpcTimeout(Duration.ZERO) // ignored
         .setTotalTimeout(Duration.ofMillis(86400000L))
         .build()));
 return builder;
}

代码示例来源:origin: googleapis/google-cloud-java

private static Builder initDefaults(Builder builder) {
 builder
   .annotateVideoSettings()
   .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
   .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
 builder
   .annotateVideoOperationSettings()
   .setInitialCallSettings(
     UnaryCallSettings
       .<AnnotateVideoRequest, OperationSnapshot>newUnaryCallSettingsBuilder()
       .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
       .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"))
       .build())
   .setResponseTransformer(
     ProtoOperationTransformers.ResponseTransformer.create(AnnotateVideoResponse.class))
   .setMetadataTransformer(
     ProtoOperationTransformers.MetadataTransformer.create(AnnotateVideoProgress.class))
   .setPollingAlgorithm(
     OperationTimedPollAlgorithm.create(
       RetrySettings.newBuilder()
         .setInitialRetryDelay(Duration.ofMillis(20000L))
         .setRetryDelayMultiplier(1.5)
         .setMaxRetryDelay(Duration.ofMillis(45000L))
         .setInitialRpcTimeout(Duration.ZERO) // ignored
         .setRpcTimeoutMultiplier(1.0) // ignored
         .setMaxRpcTimeout(Duration.ZERO) // ignored
         .setTotalTimeout(Duration.ofMillis(86400000L))
         .build()));
 return builder;
}

代码示例来源:origin: googleapis/google-cloud-java

private static Builder initDefaults(Builder builder) {
 builder
   .annotateVideoSettings()
   .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
   .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
 builder
   .annotateVideoOperationSettings()
   .setInitialCallSettings(
     UnaryCallSettings
       .<AnnotateVideoRequest, OperationSnapshot>newUnaryCallSettingsBuilder()
       .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
       .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"))
       .build())
   .setResponseTransformer(
     ProtoOperationTransformers.ResponseTransformer.create(AnnotateVideoResponse.class))
   .setMetadataTransformer(
     ProtoOperationTransformers.MetadataTransformer.create(AnnotateVideoProgress.class))
   .setPollingAlgorithm(
     OperationTimedPollAlgorithm.create(
       RetrySettings.newBuilder()
         .setInitialRetryDelay(Duration.ofMillis(20000L))
         .setRetryDelayMultiplier(1.5)
         .setMaxRetryDelay(Duration.ofMillis(45000L))
         .setInitialRpcTimeout(Duration.ZERO) // ignored
         .setRpcTimeoutMultiplier(1.0) // ignored
         .setMaxRpcTimeout(Duration.ZERO) // ignored
         .setTotalTimeout(Duration.ofMillis(86400000L))
         .build()));
 return builder;
}

代码示例来源:origin: googleapis/google-cloud-java

private static Builder initDefaults(Builder builder) {
 builder
   .annotateVideoSettings()
   .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
   .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
 builder
   .annotateVideoOperationSettings()
   .setInitialCallSettings(
     UnaryCallSettings
       .<AnnotateVideoRequest, OperationSnapshot>newUnaryCallSettingsBuilder()
       .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
       .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"))
       .build())
   .setResponseTransformer(
     ProtoOperationTransformers.ResponseTransformer.create(AnnotateVideoResponse.class))
   .setMetadataTransformer(
     ProtoOperationTransformers.MetadataTransformer.create(AnnotateVideoProgress.class))
   .setPollingAlgorithm(
     OperationTimedPollAlgorithm.create(
       RetrySettings.newBuilder()
         .setInitialRetryDelay(Duration.ofMillis(20000L))
         .setRetryDelayMultiplier(1.5)
         .setMaxRetryDelay(Duration.ofMillis(45000L))
         .setInitialRpcTimeout(Duration.ZERO) // ignored
         .setRpcTimeoutMultiplier(1.0) // ignored
         .setMaxRpcTimeout(Duration.ZERO) // ignored
         .setTotalTimeout(Duration.ofMillis(86400000L))
         .build()));
 return builder;
}

代码示例来源:origin: googleapis/google-cloud-java

private static RetrySettings retrySettings() {
 return RetrySettings.newBuilder()
   .setMaxAttempts(10)
   .setMaxRetryDelay(Duration.ofMillis(30000L))
   .setTotalTimeout(Duration.ofMillis(120000L))
   .setInitialRetryDelay(Duration.ofMillis(250L))
   .setRetryDelayMultiplier(1.0)
   .setInitialRpcTimeout(Duration.ofMillis(120000L))
   .setRpcTimeoutMultiplier(1.0)
   .setMaxRpcTimeout(Duration.ofMillis(120000L))
   .build();
}

代码示例来源:origin: googleapis/google-cloud-java

private static RetrySettings retryParams() {
 return RetrySettings.newBuilder()
   .setMaxAttempts(10)
   .setMaxRetryDelay(Duration.ofMillis(30000L))
   .setTotalTimeout(Duration.ofMillis(120000L))
   .setInitialRetryDelay(Duration.ofMillis(250L))
   .setRetryDelayMultiplier(1.0)
   .setInitialRpcTimeout(Duration.ofMillis(120000L))
   .setRpcTimeoutMultiplier(1.0)
   .setMaxRpcTimeout(Duration.ofMillis(120000L))
   .build();
}

代码示例来源:origin: googleapis/google-cloud-java

private static RetrySettings retrySettings() {
 return RetrySettings.newBuilder()
   .setMaxAttempts(10)
   .setMaxRetryDelay(Duration.ofMillis(30000L))
   .setTotalTimeout(Duration.ofMillis(120000L))
   .setInitialRetryDelay(Duration.ofMillis(250L))
   .setRetryDelayMultiplier(1.0)
   .setInitialRpcTimeout(Duration.ofMillis(120000L))
   .setRpcTimeoutMultiplier(1.0)
   .setMaxRpcTimeout(Duration.ofMillis(120000L))
   .build();
}

代码示例来源:origin: googleapis/google-cloud-java

private static RetrySettings retrySettings() {
  return RetrySettings.newBuilder()
    .setMaxAttempts(10)
    .setMaxRetryDelay(Duration.ofMillis(30000L))
    .setTotalTimeout(Duration.ofMillis(120000L))
    .setInitialRetryDelay(Duration.ofMillis(250L))
    .setRetryDelayMultiplier(1.0)
    .setInitialRpcTimeout(Duration.ofMillis(120000L))
    .setRpcTimeoutMultiplier(1.0)
    .setMaxRpcTimeout(Duration.ofMillis(120000L))
    .build();
 }
}

代码示例来源:origin: googleapis/google-cloud-java

private static RetrySettings retrySettings() {
 double retryDelayMultiplier = 1.0;
 int maxAttempts = 10;
 long initialRetryDelay = 250L;
 long maxRetryDelay = 30000L;
 long totalTimeOut = 120000L;
 return RetrySettings.newBuilder()
   .setMaxAttempts(maxAttempts)
   .setMaxRetryDelay(Duration.ofMillis(maxRetryDelay))
   .setTotalTimeout(Duration.ofMillis(totalTimeOut))
   .setInitialRetryDelay(Duration.ofMillis(initialRetryDelay))
   .setRetryDelayMultiplier(retryDelayMultiplier)
   .setInitialRpcTimeout(Duration.ofMillis(totalTimeOut))
   .setRpcTimeoutMultiplier(retryDelayMultiplier)
   .setMaxRpcTimeout(Duration.ofMillis(totalTimeOut))
   .build();
}

代码示例来源:origin: googleapis/google-cloud-java

public Publisher getPublisherWithCustomRetrySettings(ProjectTopicName topicName)
  throws Exception {
 // [START pubsub_publisher_retry_settings]
 // Retry settings control how the publisher handles retryable failures
 Duration retryDelay = Duration.ofMillis(100); // default : 1 ms
 double retryDelayMultiplier = 2.0; // back off for repeated failures
 Duration maxRetryDelay = Duration.ofSeconds(5); // default : 10 seconds
 Duration totalTimeout = Duration.ofSeconds(1); // default: 0
 Duration initialRpcTimeout = Duration.ofSeconds(1); // default: 0
 Duration maxRpcTimeout = Duration.ofSeconds(10); // default: 0
 RetrySettings retrySettings =
   RetrySettings.newBuilder()
     .setInitialRetryDelay(retryDelay)
     .setRetryDelayMultiplier(retryDelayMultiplier)
     .setMaxRetryDelay(maxRetryDelay)
     .setTotalTimeout(totalTimeout)
     .setInitialRpcTimeout(initialRpcTimeout)
     .setMaxRpcTimeout(maxRpcTimeout)
     .build();
 Publisher publisher = Publisher.newBuilder(topicName).setRetrySettings(retrySettings).build();
 // [END pubsub_publisher_retry_settings]
 return publisher;
}

代码示例来源:origin: googleapis/google-cloud-java

private AwaitReplicationCallable createAwaitReplicationCallable() {
 // TODO(igorbernstein2): expose polling settings
 RetrySettings pollingSettings =
   RetrySettings.newBuilder()
     // use overall timeout from checkConsistencyCallable
     // NOTE: The overall timeout might exceed this value due to underlying retries
     .setTotalTimeout(
       settings.checkConsistencySettings().getRetrySettings().getTotalTimeout())
     // Use constant polling with jitter
     .setInitialRetryDelay(Duration.ofSeconds(10))
     .setRetryDelayMultiplier(1.0)
     .setMaxRetryDelay(Duration.ofSeconds(10))
     .setJittered(true)
     // These rpc timeouts are ignored, instead the rpc timeouts defined for
     // generateConsistencyToken and checkConsistency callables will be used.
     .setInitialRpcTimeout(Duration.ZERO)
     .setMaxRpcTimeout(Duration.ZERO)
     .setRpcTimeoutMultiplier(1.0)
     .build();
 return AwaitReplicationCallable.create(
   generateConsistencyTokenCallable(),
   checkConsistencyCallable(),
   clientContext,
   pollingSettings);
}

代码示例来源:origin: googleapis/google-cloud-java

MockRetryingFuture(Duration totalTimeout) {
 this.timedAttemptSettings =
   TimedAttemptSettings.newBuilder()
     .setRpcTimeout(Duration.ofSeconds(1))
     .setRetryDelay(Duration.ZERO)
     .setRandomizedRetryDelay(Duration.ZERO)
     .setAttemptCount(0)
     .setFirstAttemptStartTimeNanos(0)
     .setGlobalSettings(RetrySettings.newBuilder().setTotalTimeout(totalTimeout).build())
     .build();
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void checkAndMutateRowSettingsAreNotLostTest() {
 String dummyProjectId = "my-project";
 String dummyInstanceId = "my-instance";
 EnhancedBigtableStubSettings.Builder builder =
   EnhancedBigtableStubSettings.newBuilder()
     .setProjectId(dummyProjectId)
     .setInstanceId(dummyInstanceId);
 RetrySettings retrySettings = RetrySettings.newBuilder().build();
 builder
   .checkAndMutateRowSettings()
   .setRetryableCodes(Code.ABORTED, Code.DEADLINE_EXCEEDED)
   .setRetrySettings(retrySettings)
   .build();
 assertThat(builder.checkAndMutateRowSettings().getRetryableCodes())
   .containsAllOf(Code.ABORTED, Code.DEADLINE_EXCEEDED);
 assertThat(builder.checkAndMutateRowSettings().getRetrySettings()).isSameAs(retrySettings);
 assertThat(builder.build().checkAndMutateRowSettings().getRetryableCodes())
   .containsAllOf(Code.ABORTED, Code.DEADLINE_EXCEEDED);
 assertThat(builder.build().checkAndMutateRowSettings().getRetrySettings())
   .isSameAs(retrySettings);
 assertThat(builder.build().toBuilder().checkAndMutateRowSettings().getRetryableCodes())
   .containsAllOf(Code.ABORTED, Code.DEADLINE_EXCEEDED);
 assertThat(builder.build().toBuilder().checkAndMutateRowSettings().getRetrySettings())
   .isSameAs(retrySettings);
}

代码示例来源:origin: googleapis/google-cloud-java

RetrySettings.newBuilder()
  .setMaxAttempts(10)
  .setTotalTimeout(Duration.ofHours(1))

代码示例来源:origin: googleapis/google-cloud-java

@Before
public void setUp() {
 ClientContext clientContext =
   ClientContext.newBuilder().setDefaultCallContext(CALL_CONTEXT).build();
 RetrySettings retrySettings =
   RetrySettings.newBuilder()
     .setTotalTimeout(Duration.ofMillis(100))
     // Delay settings: 1 ms const
     .setInitialRetryDelay(Duration.ofMillis(1))
     .setMaxRetryDelay(Duration.ofMillis(1))
     .setRetryDelayMultiplier(1.0)
     // RPC timeout: ignored const 1 s
     .setInitialRpcTimeout(Duration.ofSeconds(1))
     .setMaxRpcTimeout(Duration.ofSeconds(1))
     .setRpcTimeoutMultiplier(1.0)
     .build();
 callable =
   AwaitReplicationCallable.create(
     mockGenerateConsistencyTokenCallable,
     mockCheckConsistencyCallable,
     clientContext,
     retrySettings);
}

相关文章