public FullJitterBackoffStrategy(final int baseDelay, final int maxBackoffTime) { this.baseDelay = ValidationUtils.assertIsPositive(baseDelay, "Base delay"); this.maxBackoffTime = ValidationUtils.assertIsPositive(maxBackoffTime, "Max backoff"); }
public EqualJitterBackoffStrategy(final int baseDelay, final int maxBackoffTime) { this.baseDelay = ValidationUtils.assertIsPositive(baseDelay, "Base delay"); this.maxBackoffTime = ValidationUtils.assertIsPositive(maxBackoffTime, "Max backoff"); }
public ExponentialBackoffStrategy(final int baseDelay, final int maxBackoffTime) { this.baseDelay = ValidationUtils.assertIsPositive(baseDelay, "Base delay"); this.maxBackoffTime = ValidationUtils.assertIsPositive(maxBackoffTime, "Max backoff"); }
public MaxNumberOfRetriesCondition(int maxNumberOfRetries) { this.maxNumberOfRetries = assertIsPositive(maxNumberOfRetries, "maxNumberOfRetries"); }
public FixedDelayBackoffStrategy(int fixedBackoff) { this.fixedBackoff = assertIsPositive(fixedBackoff, "fixedBackoff"); }
/** * Set the maximum number of consecutive failed retries that the client will permit before * throttling all subsequent retries of failed requests. * <p> * Note: This does not guarantee that each failed request will be retried up to this many times. * Depending on the configured {@link RetryPolicy} and the number of past failed and successful * requests, the actual number of retries attempted may be less. * <p> * This has a default value of {@link #DEFAULT_MAX_CONSECUTIVE_RETRIES_BEFORE_THROTTLING}. * * @param maxConsecutiveRetriesBeforeThrottling The maximum number of consecutive retries. */ public void setMaxConsecutiveRetriesBeforeThrottling(int maxConsecutiveRetriesBeforeThrottling) { this.maxConsecutiveRetriesBeforeThrottling = ValidationUtils.assertIsPositive(maxConsecutiveRetriesBeforeThrottling, "maxConsecutiveRetriesBeforeThrottling"); } /**
public GetIamAuthTokenRequest(String hostname, int port, String userName) { this.hostname = assertStringNotEmpty(hostname, "hostname"); this.port = assertIsPositive(port, "port"); this.userName = assertStringNotEmpty(userName, "userName"); }
/** * Static method to repeatedly call action until it succeeds or the max allowed attempts is * reached. * * @param callable Callable implementing assertion logic * @param params Retry related parameters * @return Successful result */ public static <T> T doRetryableAction(Callable<T> callable, RetryableParams params) throws Exception { ValidationUtils.assertIsPositive(params.getMaxAttempts(), "maxAttempts"); return new RetryableAction<T>(callable, params).call(); } }
public EqualJitterBackoffStrategy(final int baseDelay, final int maxBackoffTime) { this.baseDelay = ValidationUtils.assertIsPositive(baseDelay, "Base delay"); this.maxBackoffTime = ValidationUtils.assertIsPositive(maxBackoffTime, "Max backoff"); }
public FullJitterBackoffStrategy(final int baseDelay, final int maxBackoffTime) { this.baseDelay = ValidationUtils.assertIsPositive(baseDelay, "Base delay"); this.maxBackoffTime = ValidationUtils.assertIsPositive(maxBackoffTime, "Max backoff"); }
public ExponentialBackoffStrategy(final int baseDelay, final int maxBackoffTime) { this.baseDelay = ValidationUtils.assertIsPositive(baseDelay, "Base delay"); this.maxBackoffTime = ValidationUtils.assertIsPositive(maxBackoffTime, "Max backoff"); }
public MaxNumberOfRetriesCondition(int maxNumberOfRetries) { this.maxNumberOfRetries = assertIsPositive(maxNumberOfRetries, "maxNumberOfRetries"); }
public FixedDelayBackoffStrategy(int fixedBackoff) { this.fixedBackoff = assertIsPositive(fixedBackoff, "fixedBackoff"); }
/** * Set the maximum number of consecutive failed retries that the client will permit before * throttling all subsequent retries of failed requests. * <p> * Note: This does not guarantee that each failed request will be retried up to this many times. * Depending on the configured {@link RetryPolicy} and the number of past failed and successful * requests, the actual number of retries attempted may be less. * <p> * This has a default value of {@link #DEFAULT_MAX_CONSECUTIVE_RETRIES_BEFORE_THROTTLING}. * * @param maxConsecutiveRetriesBeforeThrottling The maximum number of consecutive retries. */ public void setMaxConsecutiveRetriesBeforeThrottling(int maxConsecutiveRetriesBeforeThrottling) { this.maxConsecutiveRetriesBeforeThrottling = ValidationUtils.assertIsPositive(maxConsecutiveRetriesBeforeThrottling, "maxConsecutiveRetriesBeforeThrottling"); } /**
@Test(expected = IllegalArgumentException.class) public void assertIsPositive_NegativeNumber_ThrowsException() { ValidationUtils.assertIsPositive(-9001, "num"); }
@Test(expected = IllegalArgumentException.class) public void assertIsPositive_Zero_ThrowsException() { ValidationUtils.assertIsPositive(0, "num"); }
@Test public void assertIsPositive_PositiveNumber_ReturnsSameNumber() { assertEquals(42, ValidationUtils.assertIsPositive(42, "num")); }
public ExponentialBackoffStrategy(final int baseDelay, final int maxBackoffTime) { this.baseDelay = ValidationUtils.assertIsPositive(baseDelay, "Base delay"); this.maxBackoffTime = ValidationUtils.assertIsPositive(maxBackoffTime, "Max backoff"); }
public FullJitterBackoffStrategy(final int baseDelay, final int maxBackoffTime) { this.baseDelay = ValidationUtils.assertIsPositive(baseDelay, "Base delay"); this.maxBackoffTime = ValidationUtils.assertIsPositive(maxBackoffTime, "Max backoff"); }
public GetIamAuthTokenRequest(String hostname, int port, String userName) { this.hostname = assertStringNotEmpty(hostname, "hostname"); this.port = assertIsPositive(port, "port"); this.userName = assertStringNotEmpty(userName, "userName"); }