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);
}
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));
}
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());
}
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();
}
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);
}
Aggregations