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

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

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

RetrySettings.getInitialRpcTimeout介绍

[英]InitialRpcTimeout controls the timeout for the initial RPC. Subsequent calls will use this value adjusted according to the RpcTimeoutMultiplier. The default value is Duration.ZERO.
[中]InitialRpcTimeout控制初始RPC的超时。后续调用将使用根据rpctimeOut乘数调整的该值。默认值为持续时间。零

代码示例

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

/** Configures the Publisher's retry parameters. */
public Builder setRetrySettings(RetrySettings retrySettings) {
 Preconditions.checkArgument(
   retrySettings.getTotalTimeout().compareTo(MIN_TOTAL_TIMEOUT) >= 0);
 Preconditions.checkArgument(
   retrySettings.getInitialRpcTimeout().compareTo(MIN_RPC_TIMEOUT) >= 0);
 this.retrySettings = retrySettings;
 return this;
}

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

private void verifyRetrySettingAreSane(Set<Code> retryCodes, RetrySettings retrySettings) {
  assertThat(retryCodes).containsAllOf(Code.DEADLINE_EXCEEDED, Code.UNAVAILABLE);

  assertThat(retrySettings.getTotalTimeout()).isGreaterThan(Duration.ZERO);

  assertThat(retrySettings.getInitialRetryDelay()).isGreaterThan(Duration.ZERO);
  assertThat(retrySettings.getRetryDelayMultiplier()).isAtLeast(1.0);
  assertThat(retrySettings.getMaxRetryDelay()).isGreaterThan(Duration.ZERO);

  assertThat(retrySettings.getInitialRpcTimeout()).isGreaterThan(Duration.ZERO);
  assertThat(retrySettings.getRpcTimeoutMultiplier()).isAtLeast(1.0);
  assertThat(retrySettings.getMaxRpcTimeout()).isGreaterThan(Duration.ZERO);
 }
}

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

private void verifyRetrySettings(Set<Code> retryCodes, RetrySettings retrySettings) {
  assertThat(retryCodes).containsAllOf(Code.DEADLINE_EXCEEDED, Code.UNAVAILABLE);
  assertThat(retrySettings.getTotalTimeout()).isGreaterThan(Duration.ZERO);
  assertThat(retrySettings.getInitialRetryDelay()).isGreaterThan(Duration.ZERO);
  assertThat(retrySettings.getRetryDelayMultiplier()).isAtLeast(1.0);
  assertThat(retrySettings.getMaxRetryDelay()).isGreaterThan(Duration.ZERO);
  assertThat(retrySettings.getInitialRpcTimeout()).isGreaterThan(Duration.ZERO);
  assertThat(retrySettings.getRpcTimeoutMultiplier()).isAtLeast(1.0);
  assertThat(retrySettings.getMaxRpcTimeout()).isGreaterThan(Duration.ZERO);
 }
}

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

@Test
public void testReadRowsSettings() {
 ServerStreamingCallSettings.Builder<ReadRowsRequest, ReadRowsResponse> builder =
   EnhancedBigQueryStorageStubSettings.newBuilder().readRowsSettings();
 assertThat(builder.getRetryableCodes()).containsAllOf(Code.DEADLINE_EXCEEDED, Code.UNAVAILABLE);
 RetrySettings retrySettings = builder.getRetrySettings();
 assertThat(retrySettings.getInitialRetryDelay()).isEqualTo(Duration.ofMillis(100L));
 assertThat(retrySettings.getRetryDelayMultiplier()).isWithin(1e-6).of(1.3);
 assertThat(retrySettings.getMaxRetryDelay()).isEqualTo(Duration.ofMinutes(1L));
 assertThat(retrySettings.getInitialRpcTimeout()).isEqualTo(Duration.ofDays(1L));
 assertThat(retrySettings.getRpcTimeoutMultiplier()).isWithin(1e-6).of(1.0);
 assertThat(retrySettings.getMaxRpcTimeout()).isEqualTo(Duration.ofDays(1L));
 assertThat(retrySettings.getTotalTimeout()).isEqualTo(Duration.ofDays(1L));
 assertThat(builder.getIdleTimeout()).isEqualTo(Duration.ZERO);
}

代码示例来源:origin: com.google.api/gax

public RetrySettings build() {
 RetrySettings params = autoBuild();
 if (params.getTotalTimeout().toMillis() < 0) {
  throw new IllegalStateException("total timeout must not be negative");
 }
 if (params.getInitialRetryDelay().toMillis() < 0) {
  throw new IllegalStateException("initial retry delay must not be negative");
 }
 if (params.getRetryDelayMultiplier() < 1.0) {
  throw new IllegalStateException("retry delay multiplier must be at least 1");
 }
 if (params.getMaxRetryDelay().compareTo(params.getInitialRetryDelay()) < 0) {
  throw new IllegalStateException("max retry delay must not be shorter than initial delay");
 }
 if (params.getMaxAttempts() < 0) {
  throw new IllegalStateException("max attempts must be non-negative");
 }
 if (params.getInitialRpcTimeout().toMillis() < 0) {
  throw new IllegalStateException("initial rpc timeout must not be negative");
 }
 if (params.getMaxRpcTimeout().compareTo(params.getInitialRpcTimeout()) < 0) {
  throw new IllegalStateException("max rpc timeout must not be shorter than initial timeout");
 }
 if (params.getRpcTimeoutMultiplier() < 1.0) {
  throw new IllegalStateException("rpc timeout multiplier must be at least 1");
 }
 return params;
}

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

public RetrySettings build() {
 RetrySettings params = autoBuild();
 if (params.getTotalTimeout().toMillis() < 0) {
  throw new IllegalStateException("total timeout must not be negative");
 }
 if (params.getInitialRetryDelay().toMillis() < 0) {
  throw new IllegalStateException("initial retry delay must not be negative");
 }
 if (params.getRetryDelayMultiplier() < 1.0) {
  throw new IllegalStateException("retry delay multiplier must be at least 1");
 }
 if (params.getMaxRetryDelay().compareTo(params.getInitialRetryDelay()) < 0) {
  throw new IllegalStateException("max retry delay must not be shorter than initial delay");
 }
 if (params.getMaxAttempts() < 0) {
  throw new IllegalStateException("max attempts must be non-negative");
 }
 if (params.getInitialRpcTimeout().toMillis() < 0) {
  throw new IllegalStateException("initial rpc timeout must not be negative");
 }
 if (params.getMaxRpcTimeout().compareTo(params.getInitialRpcTimeout()) < 0) {
  throw new IllegalStateException("max rpc timeout must not be shorter than initial timeout");
 }
 if (params.getRpcTimeoutMultiplier() < 1.0) {
  throw new IllegalStateException("rpc timeout multiplier must be at least 1");
 }
 return params;
}

代码示例来源:origin: com.google.api/gax

/**
 * Creates a first attempt {@link TimedAttemptSettings}. The first attempt is configured to be
 * executed immediately.
 *
 * @return first attempt settings
 */
@Override
public TimedAttemptSettings createFirstAttempt() {
 return TimedAttemptSettings.newBuilder()
   .setGlobalSettings(globalSettings)
   .setRetryDelay(Duration.ZERO)
   .setRpcTimeout(globalSettings.getInitialRpcTimeout())
   .setRandomizedRetryDelay(Duration.ZERO)
   .setAttemptCount(0)
   .setOverallAttemptCount(0)
   .setFirstAttemptStartTimeNanos(clock.nanoTime())
   .build();
}

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

/**
 * Creates a first attempt {@link TimedAttemptSettings}. The first attempt is configured to be
 * executed immediately.
 *
 * @return first attempt settings
 */
@Override
public TimedAttemptSettings createFirstAttempt() {
 return TimedAttemptSettings.newBuilder()
   .setGlobalSettings(globalSettings)
   .setRetryDelay(Duration.ZERO)
   .setRpcTimeout(globalSettings.getInitialRpcTimeout())
   .setRandomizedRetryDelay(Duration.ZERO)
   .setAttemptCount(0)
   .setOverallAttemptCount(0)
   .setFirstAttemptStartTimeNanos(clock.nanoTime())
   .build();
}

相关文章