Examples of ExponentialBackoffPolicy


Examples of com.google.api.client.http.ExponentialBackOffPolicy

          "bytes=" + bytesDownloaded + "-" + (bytesDownloaded + chunkSize - 1));

      if (backOffPolicyEnabled) {
        // Set ExponentialBackOffPolicy as the BackOffPolicy of the HTTP Request which will
        // retry the same request again if there is a server error.
        request.setBackOffPolicy(new ExponentialBackOffPolicy());
      }

      HttpResponse response = request.execute();
      AbstractInputStreamContent.copy(response.getContent(), outputStream);
View Full Code Here

Examples of com.google.api.client.http.ExponentialBackOffPolicy

      }
      request.getHeaders().setRange(rangeHeader.toString());
    }
    // use exponential backoff on server error
    if (backOffPolicyEnabled) {
      request.setBackOffPolicy(new ExponentialBackOffPolicy());
    }
    // execute the request and copy into the output stream
    HttpResponse response = request.execute();
    try {
      IOUtils.copy(response.getContent(), outputStream);
View Full Code Here

Examples of com.google.api.client.http.ExponentialBackOffPolicy

   */
  private HttpResponse executeCurrentRequestWithBackOffAndGZip(HttpRequest request)
      throws IOException {
    // use exponential backoff on server error
    if (backOffPolicyEnabled) {
      request.setBackOffPolicy(new ExponentialBackOffPolicy());
    }
    // enable GZip encoding if necessary
    if (!disableGZipContent && !(request.getContent() instanceof EmptyContent)) {
      request.setEncoding(new GZipEncoding());
    }
View Full Code Here

Examples of org.apache.hadoop.hbase.util.RetryCounter.ExponentialBackoffPolicy

    this(new RetryConfig(
      maxAttempts,
      sleepIntervalMillis,
      -1,
      TimeUnit.MILLISECONDS,
      new ExponentialBackoffPolicy()));
  }
View Full Code Here

Examples of org.apache.hadoop.hbase.util.RetryCounter.ExponentialBackoffPolicy

    this(new RetryConfig(
      maxAttempts,
      sleepIntervalMillis,
      -1,
      TimeUnit.MILLISECONDS,
      new ExponentialBackoffPolicy()));
  }
View Full Code Here

Examples of org.springframework.retry.backoff.ExponentialBackOffPolicy

   * @return this.
   */
  public RetryInterceptorBuilder<T> backOffOptions(long initialInterval, double multiplier, long maxInterval) {
    Assert.isNull(this.retryOperations, "cannot set the back off policy when a custom retryOperations has been set");
    Assert.isTrue(!this.backOffPolicySet, "cannot set the back off options when a back off policy has been set");
    ExponentialBackOffPolicy policy = new ExponentialBackOffPolicy();
    policy.setInitialInterval(initialInterval);
    policy.setMultiplier(multiplier);
    policy.setMaxInterval(maxInterval);
    this.retryTemplate.setBackOffPolicy(policy);
    this.backOffOptionsSet = true;
    this.templateAltered = true;
    return this;
  }
View Full Code Here

Examples of org.springframework.retry.backoff.ExponentialBackOffPolicy

  private BackOffPolicy getBackoffPolicy(Backoff backoff) {
    long min = backoff.delay() == 0 ? backoff.value() : backoff.delay();
    long max = backoff.maxDelay();
    if (backoff.multiplier() > 0) {
      ExponentialBackOffPolicy policy = new ExponentialBackOffPolicy();
      if (backoff.random()) {
        policy = new ExponentialRandomBackOffPolicy();
      }
      policy.setInitialInterval(min);
      policy.setMultiplier(backoff.multiplier());
      policy.setMaxInterval(max > min ? max : ExponentialBackOffPolicy.DEFAULT_MAX_INTERVAL);
      if (sleeper != null) {
        policy.setSleeper(sleeper);
      }
      return policy;
    }
    if (max > min) {
      UniformRandomBackOffPolicy policy = new UniformRandomBackOffPolicy();
      policy.setMinBackOffPeriod(min);
      policy.setMaxBackOffPeriod(max);
      if (sleeper != null) {
        policy.setSleeper(sleeper);
      }
      return policy;
    }
    FixedBackOffPolicy policy = new FixedBackOffPolicy();
    policy.setBackOffPeriod(min);
    if (sleeper != null) {
      policy.setSleeper(sleeper);
    }
    return policy;
  }
View Full Code Here

Examples of org.springframework.retry.backoff.ExponentialBackOffPolicy

    assertEquals("bar", result);
  }

  @Test
  public void testExponentialBackOffIsExponential() throws Throwable {
    ExponentialBackOffPolicy policy = new ExponentialBackOffPolicy();
    policy.setInitialInterval(100);
    policy.setMultiplier(1.5);
    RetryTemplate template = new RetryTemplate();
    template.setBackOffPolicy(policy);
    final List<Long> times = new ArrayList<Long>();
    RetryState retryState = new DefaultRetryState("bar");
    for (int i = 0; i < 3; i++) {
View Full Code Here

Examples of org.springframework.retry.backoff.ExponentialBackOffPolicy

    int maxAttempts = properties.getMaxAttempts(this.defaultMaxAttempts);
    if (maxAttempts > 1) {
      RetryTemplate template = new RetryTemplate();
      SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy();
      retryPolicy.setMaxAttempts(maxAttempts);
      ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy();
      backOffPolicy.setInitialInterval(properties.getBackOffInitialInterval(this.defaultBackOffInitialInterval));
      backOffPolicy.setMultiplier(properties.getBackOffMultiplier(this.defaultBackOffMultiplier));
      backOffPolicy.setMaxInterval(properties.getBackOffMaxInterval(this.defaultBackOffMaxInterval));
      template.setRetryPolicy(retryPolicy);
      template.setBackOffPolicy(backOffPolicy);
      return template;
    }
    else {
View Full Code Here

Examples of org.springframework.retry.backoff.ExponentialBackOffPolicy

  @Test
  public void testSimulatorExercisesExponentialBackoff() {
    SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy();
    retryPolicy.setMaxAttempts(5);

    ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy();
    backOffPolicy.setMultiplier(2);
    backOffPolicy.setMaxInterval(30000);
    backOffPolicy.setInitialInterval(100);

    RetrySimulator simulator = new RetrySimulator(backOffPolicy, retryPolicy);
    RetrySimulation simulation = simulator.executeSimulation(1000);
    System.out.println(backOffPolicy);
    System.out.println("Longest sequence  " + simulation.getLongestTotalSleepSequence());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.