com.amazonaws.waiters.PollingStrategyContext Java Examples

The following examples show how to use com.amazonaws.waiters.PollingStrategyContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TimeOutRetryStrategyTests.java    From pipeline-aws-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * the aws-sdk-java (currently as of 7/12/2018) does not have a publicly available constructor to create a PollingStrategyContext.
 */
private PollingStrategyContext pollingStrategyContext(AmazonWebServiceRequest request, int retriesAttempted) {
	try {
		Constructor<PollingStrategyContext> constructor = PollingStrategyContext.class.getDeclaredConstructor(AmazonWebServiceRequest.class, int.class);
		constructor.setAccessible(true);
		return constructor.newInstance(request, retriesAttempted);
	} catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) {
		throw new IllegalStateException("Could not create a PollingStrategyContext", e);
	}
}
 
Example #2
Source File: MaxAttempCancellablePetryStrategy.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@Override
public boolean shouldRetry(PollingStrategyContext pollingStrategyContext) {
    if (cancellationCheck != null && cancellationCheck.isCancelled()) {
        throw new CancellationException("Task was cancelled.");
    }
    return pollingStrategyContext.getRetriesAttempted() < defaultMaxAttempts;
}
 
Example #3
Source File: TimeOutRetryStrategy.java    From pipeline-aws-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public boolean shouldRetry(PollingStrategyContext pollingStrategyContext) {
	Duration difference = Duration.between(this.start, OffsetDateTime.now());
	return difference.compareTo(this.maxTime) < 0;
}
 
Example #4
Source File: BackoffDelayStrategy.java    From cloudbreak with Apache License 2.0 4 votes vote down vote up
@Override
public void delayBeforeNextRetry(PollingStrategyContext pollingStrategyContext) throws InterruptedException {
    int requestAttempted = pollingStrategyContext.getRetriesAttempted();
    Double secondToWait = Math.min(POLLING_INTERVAL * Math.pow(2, requestAttempted) + RANDOM.nextInt(POLLING_INTERVAL), MAX_POLLING_INTERVAL);
    Thread.sleep(secondToWait.longValue() * THOUSAND);
}
 
Example #5
Source File: MaxTimeRetryStrategy.java    From amazon-ecs-plugin with MIT License 2 votes vote down vote up
/**
 * Default way of checking if polling should be retried or fast failed
 *
 * @param pollingStrategyContext Provides the polling context required to make the retry decision
 * @return false if we're passed our allowed time
 */
@Override
public boolean shouldRetry(PollingStrategyContext pollingStrategyContext) {
    return System.currentTimeMillis() < EndTime;
}