Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c525e9a

Browse files
gguptphlteoh37
authored andcommitted
[FLINK-36329][Connectors/DynamoDB] Changing retry strategy to use SDK retries to catch all retryable exceptions
1 parent 4d4f04b commit c525e9a

File tree

1 file changed

+5
-27
lines changed

1 file changed

+5
-27
lines changed

flink-connector-aws/flink-connector-dynamodb/src/main/java/org/apache/flink/connector/dynamodb/source/DynamoDbStreamsSource.java

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,8 @@
4949
import org.apache.flink.util.Preconditions;
5050
import org.apache.flink.util.UserCodeClassLoader;
5151

52-
import software.amazon.awssdk.awscore.exception.AwsServiceException;
53-
import software.amazon.awssdk.awscore.internal.AwsErrorCode;
5452
import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration;
53+
import software.amazon.awssdk.core.internal.retry.SdkDefaultRetryStrategy;
5554
import software.amazon.awssdk.http.SdkHttpClient;
5655
import software.amazon.awssdk.http.apache.ApacheHttpClient;
5756
import software.amazon.awssdk.retries.AdaptiveRetryStrategy;
@@ -202,40 +201,19 @@ private DynamoDbStreamsProxy createDynamoDbStreamsProxy(Configuration consumerCo
202201
consumerConfig.addAllToProperties(dynamoDbStreamsClientProperties);
203202

204203
AWSGeneralUtil.validateAwsCredentials(dynamoDbStreamsClientProperties);
205-
int maxDescribeStreamCallAttempts = sourceConfig.get(DYNAMODB_STREAMS_RETRY_COUNT);
204+
int maxApiCallAttempts = sourceConfig.get(DYNAMODB_STREAMS_RETRY_COUNT);
206205
Duration minDescribeStreamDelay =
207206
sourceConfig.get(DYNAMODB_STREAMS_EXPONENTIAL_BACKOFF_MIN_DELAY);
208207
Duration maxDescribeStreamDelay =
209208
sourceConfig.get(DYNAMODB_STREAMS_EXPONENTIAL_BACKOFF_MAX_DELAY);
210209
BackoffStrategy backoffStrategy =
211210
BackoffStrategy.exponentialDelay(minDescribeStreamDelay, maxDescribeStreamDelay);
212211
AdaptiveRetryStrategy adaptiveRetryStrategy =
213-
AdaptiveRetryStrategy.builder()
214-
.maxAttempts(maxDescribeStreamCallAttempts)
212+
SdkDefaultRetryStrategy.adaptiveRetryStrategy()
213+
.toBuilder()
214+
.maxAttempts(maxApiCallAttempts)
215215
.backoffStrategy(backoffStrategy)
216216
.throttlingBackoffStrategy(backoffStrategy)
217-
.retryOnException(
218-
throwable -> {
219-
if (throwable instanceof AwsServiceException) {
220-
AwsServiceException exception =
221-
(AwsServiceException) throwable;
222-
return (AwsErrorCode.RETRYABLE_ERROR_CODES.contains(
223-
exception.awsErrorDetails().errorCode()))
224-
|| (AwsErrorCode.THROTTLING_ERROR_CODES.contains(
225-
exception.awsErrorDetails().errorCode()));
226-
}
227-
return false;
228-
})
229-
.treatAsThrottling(
230-
throwable -> {
231-
if (throwable instanceof AwsServiceException) {
232-
AwsServiceException exception =
233-
(AwsServiceException) throwable;
234-
return AwsErrorCode.THROTTLING_ERROR_CODES.contains(
235-
exception.awsErrorDetails().errorCode());
236-
}
237-
return false;
238-
})
239217
.build();
240218
DynamoDbStreamsClient dynamoDbStreamsClient =
241219
AWSClientUtil.createAwsSyncClient(

0 commit comments

Comments
 (0)