Search in sources :

Example 1 with RetryPolicy

use of software.amazon.awssdk.core.retry.RetryPolicy in project flux-swf-client by awslabs.

the class FluxCapacitorImpl method create.

/**
 * Creates a FluxCapacitor object and does various bits of setup e.g. registering the swf domain.
 * Intentionally package-private, only the Factory should be using the constructor.
 *
 * @param metricsFactory - A factory that produces MetricRecorder objects for emitting workflow metrics.
 * @param credentials    - A provider for the AWS credentials that should be used to call SWF APIs
 * @param config         - Configuration data for FluxCapacitor to use to configure itself
 */
static FluxCapacitor create(MetricRecorderFactory metricsFactory, AwsCredentialsProvider credentials, FluxCapacitorConfig config) {
    // We do our own retry/backoff logic so we can get decent metrics, so here we disable the SDK's defaults.
    RetryPolicy retryPolicy = RetryPolicy.builder().retryCondition(RetryCondition.none()).numRetries(0).backoffStrategy(BackoffStrategy.none()).throttlingBackoffStrategy(BackoffStrategy.none()).build();
    // If an override config was provided, use it, and only use the above RetryPolicy
    // if the provided overrideConfig did not include its own RetryPolicy.
    ClientOverrideConfiguration overrideConfig = config.getClientOverrideConfiguration();
    if (overrideConfig == null) {
        overrideConfig = ClientOverrideConfiguration.builder().retryPolicy(retryPolicy).build();
    } else if (!overrideConfig.retryPolicy().isPresent()) {
        overrideConfig = overrideConfig.toBuilder().retryPolicy(retryPolicy).build();
    }
    SwfClientBuilder builder = SwfClient.builder().credentialsProvider(credentials).region(Region.of(config.getAwsRegion())).overrideConfiguration(overrideConfig);
    // otherwise the SDK will figure it out based on the region name.
    if (config.getSwfEndpoint() != null && !"".equals(config.getSwfEndpoint())) {
        builder.endpointOverride(URI.create(config.getSwfEndpoint()));
    }
    return new FluxCapacitorImpl(metricsFactory, builder.build(), config);
}
Also used : ClientOverrideConfiguration(software.amazon.awssdk.core.client.config.ClientOverrideConfiguration) SwfClientBuilder(software.amazon.awssdk.services.swf.SwfClientBuilder) RetryPolicy(software.amazon.awssdk.core.retry.RetryPolicy)

Example 2 with RetryPolicy

use of software.amazon.awssdk.core.retry.RetryPolicy in project synapse by otto-de.

the class KinesisAutoConfigurationTest method shouldRegisterRetryPolicyWithMaxRetries.

@Test
public void shouldRegisterRetryPolicyWithMaxRetries() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    context.register(KinesisAutoConfiguration.class);
    context.refresh();
    assertThat(context.containsBean("kinesisRetryPolicy"), is(true));
    RetryPolicy retryPolicy = context.getBean("kinesisRetryPolicy", RetryPolicy.class);
    assertThat(retryPolicy.numRetries(), is(Integer.MAX_VALUE));
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) RetryPolicy(software.amazon.awssdk.core.retry.RetryPolicy) Test(org.junit.Test)

Example 3 with RetryPolicy

use of software.amazon.awssdk.core.retry.RetryPolicy in project flux-swf-client by danielgmyers.

the class FluxCapacitorImpl method create.

/**
 * Creates a FluxCapacitor object and does various bits of setup e.g. registering the swf domain.
 * Intentionally package-private, only the Factory should be using the constructor.
 *
 * @param metricsFactory - A factory that produces MetricRecorder objects for emitting workflow metrics.
 * @param credentials    - A provider for the AWS credentials that should be used to call SWF APIs
 * @param config         - Configuration data for FluxCapacitor to use to configure itself
 */
static FluxCapacitor create(MetricRecorderFactory metricsFactory, AwsCredentialsProvider credentials, FluxCapacitorConfig config) {
    // We do our own retry/backoff logic so we can get decent metrics, so here we disable the SDK's defaults.
    RetryPolicy retryPolicy = RetryPolicy.builder().retryCondition(RetryCondition.none()).numRetries(0).backoffStrategy(BackoffStrategy.none()).throttlingBackoffStrategy(BackoffStrategy.none()).build();
    // If an override config was provided, use it, and only use the above RetryPolicy
    // if the provided overrideConfig did not include its own RetryPolicy.
    ClientOverrideConfiguration overrideConfig = config.getClientOverrideConfiguration();
    if (overrideConfig == null) {
        overrideConfig = ClientOverrideConfiguration.builder().retryPolicy(retryPolicy).build();
    } else if (!overrideConfig.retryPolicy().isPresent()) {
        overrideConfig = overrideConfig.toBuilder().retryPolicy(retryPolicy).build();
    }
    SwfClientBuilder builder = SwfClient.builder().credentialsProvider(credentials).region(Region.of(config.getAwsRegion())).overrideConfiguration(overrideConfig);
    // otherwise the SDK will figure it out based on the region name.
    if (config.getSwfEndpoint() != null && !"".equals(config.getSwfEndpoint())) {
        builder.endpointOverride(URI.create(config.getSwfEndpoint()));
    }
    return new FluxCapacitorImpl(metricsFactory, builder.build(), config, Clock.systemUTC());
}
Also used : ClientOverrideConfiguration(software.amazon.awssdk.core.client.config.ClientOverrideConfiguration) SwfClientBuilder(software.amazon.awssdk.services.swf.SwfClientBuilder) RetryPolicy(software.amazon.awssdk.core.retry.RetryPolicy)

Example 4 with RetryPolicy

use of software.amazon.awssdk.core.retry.RetryPolicy in project aws-sdk-java-v2 by aws.

the class DynamoDbRetryPolicy method resolveRetryPolicy.

public static RetryPolicy resolveRetryPolicy(SdkClientConfiguration config) {
    RetryPolicy configuredRetryPolicy = config.option(SdkClientOption.RETRY_POLICY);
    if (configuredRetryPolicy != null) {
        return configuredRetryPolicy;
    }
    RetryMode retryMode = RetryMode.resolver().profileFile(() -> config.option(SdkClientOption.PROFILE_FILE)).profileName(config.option(SdkClientOption.PROFILE_NAME)).defaultRetryMode(config.option(SdkClientOption.DEFAULT_RETRY_MODE)).resolve();
    return AwsRetryPolicy.forRetryMode(retryMode).toBuilder().additionalRetryConditionsAllowed(false).numRetries(MAX_ERROR_RETRY).backoffStrategy(BACKOFF_STRATEGY).build();
}
Also used : RetryMode(software.amazon.awssdk.core.retry.RetryMode) AwsRetryPolicy(software.amazon.awssdk.awscore.retry.AwsRetryPolicy) RetryPolicy(software.amazon.awssdk.core.retry.RetryPolicy)

Example 5 with RetryPolicy

use of software.amazon.awssdk.core.retry.RetryPolicy in project aws-sdk-java-v2 by aws.

the class DynamoDbRetryPolicyTest method test_numRetries_with_legacyRetryPolicy.

@Test
public void test_numRetries_with_legacyRetryPolicy() {
    environmentVariableHelper.set(SdkSystemSetting.AWS_RETRY_MODE.environmentVariable(), "legacy");
    final SdkClientConfiguration sdkClientConfiguration = SdkClientConfiguration.builder().build();
    final RetryPolicy retryPolicy = DynamoDbRetryPolicy.resolveRetryPolicy(sdkClientConfiguration);
    assertThat(retryPolicy.numRetries()).isEqualTo(8);
}
Also used : SdkClientConfiguration(software.amazon.awssdk.core.client.config.SdkClientConfiguration) RetryPolicy(software.amazon.awssdk.core.retry.RetryPolicy) Test(org.junit.jupiter.api.Test)

Aggregations

RetryPolicy (software.amazon.awssdk.core.retry.RetryPolicy)22 Test (org.junit.Test)7 Test (org.junit.jupiter.api.Test)7 RetryMode (software.amazon.awssdk.core.retry.RetryMode)6 SdkClientConfiguration (software.amazon.awssdk.core.client.config.SdkClientConfiguration)5 ClientOverrideConfiguration (software.amazon.awssdk.core.client.config.ClientOverrideConfiguration)4 URI (java.net.URI)3 AwsRetryPolicy (software.amazon.awssdk.awscore.retry.AwsRetryPolicy)3 SdkServiceException (software.amazon.awssdk.core.exception.SdkServiceException)3 RequestExecutionContext (software.amazon.awssdk.core.internal.http.RequestExecutionContext)3 SdkHttpFullRequest (software.amazon.awssdk.http.SdkHttpFullRequest)3 BeanInfo (java.beans.BeanInfo)2 Introspector (java.beans.Introspector)2 PropertyDescriptor (java.beans.PropertyDescriptor)2 Method (java.lang.reflect.Method)2 Duration (java.time.Duration)2 ArrayList (java.util.ArrayList)2 Arrays (java.util.Arrays)2 HashMap (java.util.HashMap)2 List (java.util.List)2