use of software.amazon.awssdk.core.retry.backoff.BackoffStrategy in project aws-sdk-java-v2 by aws.
the class EcsWaiterTest method waitUntilServicesStableWorks.
@Test(timeout = 30_000)
@SuppressWarnings("unchecked")
public void waitUntilServicesStableWorks() {
DescribeServicesRequest request = DescribeServicesRequest.builder().build();
DescribeServicesResponse response1 = DescribeServicesResponse.builder().services(s -> s.deployments(Deployment.builder().build()).desiredCount(2).runningCount(1)).build();
DescribeServicesResponse response2 = DescribeServicesResponse.builder().services(s -> s.deployments(Deployment.builder().build()).desiredCount(2).runningCount(2)).build();
when(client.describeServices(any(DescribeServicesRequest.class))).thenReturn(response1, response2);
EcsWaiter waiter = EcsWaiter.builder().overrideConfiguration(WaiterOverrideConfiguration.builder().maxAttempts(3).backoffStrategy(BackoffStrategy.none()).build()).client(client).build();
WaiterResponse<DescribeServicesResponse> response = waiter.waitUntilServicesStable(request);
assertThat(response.attemptsExecuted()).isEqualTo(2);
assertThat(response.matched().response()).hasValueSatisfying(r -> assertThat(r).isEqualTo(response2));
}
use of software.amazon.awssdk.core.retry.backoff.BackoffStrategy in project aws-sdk-java-v2 by aws.
the class DynamoDbRetryPolicyTest method test_backoffBaseDelay_with_standardRetryPolicy.
@Test
public void test_backoffBaseDelay_with_standardRetryPolicy() {
environmentVariableHelper.set(SdkSystemSetting.AWS_RETRY_MODE.environmentVariable(), "standard");
SdkClientConfiguration sdkClientConfiguration = SdkClientConfiguration.builder().build();
RetryPolicy retryPolicy = DynamoDbRetryPolicy.resolveRetryPolicy(sdkClientConfiguration);
BackoffStrategy backoffStrategy = retryPolicy.backoffStrategy();
assertThat(backoffStrategy).isInstanceOfSatisfying(FullJitterBackoffStrategy.class, fjbs -> {
assertThat(fjbs.toBuilder().baseDelay()).isEqualTo(Duration.ofMillis(25));
});
}
use of software.amazon.awssdk.core.retry.backoff.BackoffStrategy in project aws-sdk-java-v2 by aws.
the class DefaultQueryAsyncWaiter method postOperationSuccessWaiterConfig.
private static WaiterOverrideConfiguration postOperationSuccessWaiterConfig(WaiterOverrideConfiguration overrideConfig) {
Optional<WaiterOverrideConfiguration> optionalOverrideConfig = Optional.ofNullable(overrideConfig);
int maxAttempts = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::maxAttempts).orElse(40);
BackoffStrategy backoffStrategy = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::backoffStrategy).orElse(FixedDelayBackoffStrategy.create(Duration.ofSeconds(1)));
Duration waitTimeout = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::waitTimeout).orElse(null);
return WaiterOverrideConfiguration.builder().maxAttempts(maxAttempts).backoffStrategy(backoffStrategy).waitTimeout(waitTimeout).build();
}
use of software.amazon.awssdk.core.retry.backoff.BackoffStrategy in project aws-sdk-java-v2 by aws.
the class DefaultQueryWaiter method postOperationSuccessWaiterConfig.
private static WaiterOverrideConfiguration postOperationSuccessWaiterConfig(WaiterOverrideConfiguration overrideConfig) {
Optional<WaiterOverrideConfiguration> optionalOverrideConfig = Optional.ofNullable(overrideConfig);
int maxAttempts = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::maxAttempts).orElse(40);
BackoffStrategy backoffStrategy = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::backoffStrategy).orElse(FixedDelayBackoffStrategy.create(Duration.ofSeconds(1)));
Duration waitTimeout = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::waitTimeout).orElse(null);
return WaiterOverrideConfiguration.builder().maxAttempts(maxAttempts).backoffStrategy(backoffStrategy).waitTimeout(waitTimeout).build();
}
use of software.amazon.awssdk.core.retry.backoff.BackoffStrategy in project aws-sdk-java-v2 by aws.
the class AutoScalingWaiterTest method waitUntilGroupInServiceWorks.
@Test(timeout = 30_000)
@SuppressWarnings("unchecked")
public void waitUntilGroupInServiceWorks() {
DescribeAutoScalingGroupsRequest request = DescribeAutoScalingGroupsRequest.builder().build();
DescribeAutoScalingGroupsResponse response1 = DescribeAutoScalingGroupsResponse.builder().autoScalingGroups(asg -> asg.minSize(2).instances(i -> i.lifecycleState(PENDING), i -> i.lifecycleState(IN_SERVICE), i -> i.lifecycleState(IN_SERVICE)), asg -> asg.minSize(2).instances(i -> i.lifecycleState(PENDING), i -> i.lifecycleState(PENDING), i -> i.lifecycleState(IN_SERVICE))).build();
DescribeAutoScalingGroupsResponse response2 = DescribeAutoScalingGroupsResponse.builder().autoScalingGroups(asg -> asg.minSize(2).instances(i -> i.lifecycleState(PENDING), i -> i.lifecycleState(IN_SERVICE), i -> i.lifecycleState(IN_SERVICE)), asg -> asg.minSize(2).instances(i -> i.lifecycleState(IN_SERVICE), i -> i.lifecycleState(IN_SERVICE), i -> i.lifecycleState(IN_SERVICE))).build();
when(client.describeAutoScalingGroups(any(DescribeAutoScalingGroupsRequest.class))).thenReturn(response1, response2);
AutoScalingWaiter waiter = AutoScalingWaiter.builder().overrideConfiguration(WaiterOverrideConfiguration.builder().maxAttempts(3).backoffStrategy(BackoffStrategy.none()).build()).client(client).build();
WaiterResponse<DescribeAutoScalingGroupsResponse> response = waiter.waitUntilGroupInService(request);
assertThat(response.attemptsExecuted()).isEqualTo(2);
assertThat(response.matched().response()).hasValueSatisfying(r -> assertThat(r).isEqualTo(response2));
}
Aggregations