@Test public void exponentialBase() { WriteOptions options = WriteOptions.builder() .retryInterval(5_000) .exponentialBase(5) .maxRetryDelay(Integer.MAX_VALUE) .build(); RetryAttempt retry = new RetryAttempt(new HttpException(errorResponse(429)), 1, options); Assertions.assertThat(retry.getRetryInterval()).isEqualTo(5000L); retry = new RetryAttempt(new HttpException(errorResponse(429)), 2, options); Assertions.assertThat(retry.getRetryInterval()).isEqualTo(25000L); retry = new RetryAttempt(new HttpException(errorResponse(429)), 3, options); Assertions.assertThat(retry.getRetryInterval()).isEqualTo(125000L); retry = new RetryAttempt(new HttpException(errorResponse(429)), 4, options); Assertions.assertThat(retry.getRetryInterval()).isEqualTo(625000L); retry = new RetryAttempt(new HttpException(errorResponse(429)), 5, options); Assertions.assertThat(retry.getRetryInterval()).isEqualTo(3125000L); retry = new RetryAttempt(new HttpException(errorResponse(429)), 6, options); Assertions.assertThat(retry.getRetryInterval()).isEqualTo(15625000L); retry = new RetryAttempt(new HttpException(errorResponse(429, 3)), 7, options); Assertions.assertThat(retry.getRetryInterval()).isEqualTo(3000L); }
long getRetryInterval() { long retryInterval; String retryAfter = getRetryAfter(); if (retryAfter != null) { retryInterval = TimeUnit.MILLISECONDS.convert(Integer.parseInt(retryAfter), TimeUnit.SECONDS); } else { retryInterval = writeOptions.getRetryInterval() * (long) (Math.pow(writeOptions.getExponentialBase(), count - 1)); retryInterval = Math.min(retryInterval, writeOptions.getMaxRetryDelay()); String msg = "The InfluxDB does not specify \"Retry-After\". Use the default retryInterval: {0}"; LOG.log(Level.FINEST, msg, retryInterval); } retryInterval = retryInterval + jitterDelay(writeOptions.getJitterInterval()); return retryInterval; }
RetryAttempt { long getRetryInterval() { long retryInterval; String retryAfter = getRetryAfter(); if (retryAfter != null) { retryInterval = TimeUnit.MILLISECONDS.convert(Integer.parseInt(retryAfter), TimeUnit.SECONDS); } else { retryInterval = writeOptions.getRetryInterval() * (long) (Math.pow(writeOptions.getExponentialBase(), count - 1)); retryInterval = Math.min(retryInterval, writeOptions.getMaxRetryDelay()); String msg = "The InfluxDB does not specify \"Retry-After\". Use the default retryInterval: {0}"; LOG.log(Level.FINEST, msg, retryInterval); } retryInterval = retryInterval + jitterDelay(writeOptions.getJitterInterval()); return retryInterval; } }
RetryAttempt { long getRetryInterval() { long retryInterval; String retryAfter = getRetryAfter(); if (retryAfter != null) { retryInterval = TimeUnit.MILLISECONDS.convert(Integer.parseInt(retryAfter), TimeUnit.SECONDS); } else { retryInterval = writeOptions.getRetryInterval() * (long) (Math.pow(writeOptions.getExponentialBase(), count - 1)); retryInterval = Math.min(retryInterval, writeOptions.getMaxRetryDelay()); String msg = "The InfluxDB does not specify \"Retry-After\". Use the default retryInterval: {0}"; LOG.log(Level.FINEST, msg, retryInterval); } retryInterval = retryInterval + jitterDelay(writeOptions.getJitterInterval()); return retryInterval; } RetryAttempt(final Throwable throwable, final int count, final WriteOptions writeOptions); }
RetryAttempt { long getRetryInterval() { long retryInterval; String retryAfter = getRetryAfter(); if (retryAfter != null) { retryInterval = TimeUnit.MILLISECONDS.convert(Integer.parseInt(retryAfter), TimeUnit.SECONDS); } else { retryInterval = writeOptions.getRetryInterval() * (long) (Math.pow(writeOptions.getExponentialBase(), count - 1)); retryInterval = Math.min(retryInterval, writeOptions.getMaxRetryDelay()); String msg = "The InfluxDB does not specify \"Retry-After\". Use the default retryInterval: {0}"; LOG.log(Level.FINEST, msg, retryInterval); } retryInterval = retryInterval + jitterDelay(writeOptions.getJitterInterval()); return retryInterval; } RetryAttempt(final Throwable throwable, final int count, final WriteOptions writeOptions);  }
RetryAttempt { long getRetryInterval() { long retryInterval; String retryAfter = getRetryAfter(); if (retryAfter != null) { retryInterval = TimeUnit.MILLISECONDS.convert(Integer.parseInt(retryAfter), TimeUnit.SECONDS); } else { retryInterval = writeOptions.getRetryInterval() * (long) (Math.pow(writeOptions.getExponentialBase(), count - 1)); retryInterval = Math.min(retryInterval, writeOptions.getMaxRetryDelay()); String msg = "The InfluxDB does not specify \"Retry-After\". Use the default retryInterval: {0}"; LOG.log(Level.FINEST, msg, retryInterval); } retryInterval = retryInterval + jitterDelay(writeOptions.getJitterInterval()); return retryInterval; } RetryAttempt(final Throwable throwable, final int count, final WriteOptions writeOptions);   }