|
21 | 21 | import com.amazonaws.auth.AWSCredentialsProvider;
|
22 | 22 | import com.amazonaws.auth.EnvironmentVariableCredentialsProvider;
|
23 | 23 | import com.amazonaws.regions.Regions;
|
| 24 | +import com.amazonaws.retry.PredefinedRetryPolicies; |
24 | 25 | import io.streamthoughts.kafka.connect.filepulse.internal.StringUtils;
|
25 | 26 | import org.apache.kafka.common.config.AbstractConfig;
|
26 | 27 | import org.apache.kafka.common.config.ConfigDef;
|
@@ -68,6 +69,24 @@ public class AmazonS3ClientConfig extends AbstractConfig {
|
68 | 69 | private static final String AWS_CREDENTIALS_PROVIDER_DOC = "The AWSCredentialsProvider to use if no access key id and secret access key is configured";
|
69 | 70 | public static final String AWS_CREDENTIALS_PROVIDER_DEFAULT = EnvironmentVariableCredentialsProvider.class.getName();
|
70 | 71 |
|
| 72 | + public static final String AWS_S3_RETRY_BACKOFF_DELAY_MS_CONFIG = "aws.s3.backoff.delay.ms"; |
| 73 | + public static final String AWS_S3_RETRY_BACKOFF_DELAY_MS_DOC = "The base back-off time (milliseconds) before retrying a request."; |
| 74 | + // Default values from AWS SDK (see: PredefinedBackoffStrategies) |
| 75 | + public static final int AWS_S3_RETRY_BACKOFF_DELAY_MS_DEFAULT = 100; |
| 76 | + public static final String AWS_S3_RETRY_BACKOFF_MAX_DELAY_MS_CONFIG = "aws.s3.backoff.max.delay.ms"; |
| 77 | + public static final String AWS_S3_RETRY_BACKOFF_MAX_DELAY_MS_DOC = "The maximum back-off time (in milliseconds) before retrying a request."; |
| 78 | + // Default values from AWS SDK (see: PredefinedBackoffStrategies) |
| 79 | + public static final int AWS_S3_RETRY_BACKOFF_MAX_DELAY_MS_DEFAULT = 20_000; |
| 80 | + public static final String AWS_S3_RETRY_BACKOFF_MAX_RETRIES_CONFIG = "aws.s3.backoff.max.retries"; |
| 81 | + public static final String AWS_S3_RETRY_BACKOFF_MAX_RETRIES_DOC = "The maximum number of retry attempts for failed retryable requests."; |
| 82 | + // Default values from AWS SDK (see: PredefinedBackoffStrategies) |
| 83 | + |
| 84 | + // Maximum retry limit. Avoids integer overflow issues. |
| 85 | + // NOTE: If the value is greater than 30, there can be integer overflow issues during delay calculation. |
| 86 | + public static final int AWS_S3_RETRY_BACKOFF_MAX_RETRIES_MAX_VALUE = 30; |
| 87 | + |
| 88 | + public static final int AWS_S3_RETRY_BACKOFF_MAX_RETRIES_DEFAULT = PredefinedRetryPolicies.DEFAULT_MAX_ERROR_RETRY; |
| 89 | + |
71 | 90 | /**
|
72 | 91 | * Creates a new {@link AmazonS3ClientConfig} instance.
|
73 | 92 | *
|
@@ -113,6 +132,18 @@ public AWSCredentialsProvider getAwsCredentialsProvider() {
|
113 | 132 | return getConfiguredInstance(AWS_CREDENTIALS_PROVIDER_CLASS, AWSCredentialsProvider.class);
|
114 | 133 | }
|
115 | 134 |
|
| 135 | + public int getAwsS3RetryBackoffDelayMs() { |
| 136 | + return getInt(AWS_S3_RETRY_BACKOFF_DELAY_MS_CONFIG); |
| 137 | + } |
| 138 | + |
| 139 | + public int getAwsS3RetryBackoffMaxDelayMs() { |
| 140 | + return getInt(AWS_S3_RETRY_BACKOFF_MAX_DELAY_MS_CONFIG); |
| 141 | + } |
| 142 | + |
| 143 | + public int getAwsS3RetryBackoffMaxRetries() { |
| 144 | + return getInt(AWS_S3_RETRY_BACKOFF_MAX_RETRIES_CONFIG); |
| 145 | + } |
| 146 | + |
116 | 147 | /**
|
117 | 148 | * @return the {@link ConfigDef}.
|
118 | 149 | */
|
@@ -225,12 +256,48 @@ static ConfigDef getConf() {
|
225 | 256 | AWS_CREDENTIALS_PROVIDER_CLASS,
|
226 | 257 | ConfigDef.Type.CLASS,
|
227 | 258 | AWS_CREDENTIALS_PROVIDER_DEFAULT,
|
228 |
| - ConfigDef.Importance.HIGH, |
| 259 | + ConfigDef.Importance.MEDIUM, |
229 | 260 | AWS_CREDENTIALS_PROVIDER_DOC,
|
230 | 261 | GROUP_AWS,
|
231 | 262 | awsGroupCounter++,
|
232 | 263 | ConfigDef.Width.NONE,
|
233 | 264 | AWS_CREDENTIALS_PROVIDER_CLASS
|
| 265 | + ) |
| 266 | + .define( |
| 267 | + AWS_S3_RETRY_BACKOFF_DELAY_MS_CONFIG, |
| 268 | + ConfigDef.Type.INT, |
| 269 | + AWS_S3_RETRY_BACKOFF_DELAY_MS_DEFAULT, |
| 270 | + ConfigDef.Range.atLeast(1), |
| 271 | + ConfigDef.Importance.MEDIUM, |
| 272 | + AWS_S3_RETRY_BACKOFF_DELAY_MS_DOC, |
| 273 | + GROUP_AWS, |
| 274 | + awsGroupCounter++, |
| 275 | + ConfigDef.Width.NONE, |
| 276 | + AWS_S3_RETRY_BACKOFF_DELAY_MS_CONFIG |
| 277 | + ) |
| 278 | + .define( |
| 279 | + AWS_S3_RETRY_BACKOFF_MAX_DELAY_MS_CONFIG, |
| 280 | + ConfigDef.Type.INT, |
| 281 | + AWS_S3_RETRY_BACKOFF_MAX_DELAY_MS_DEFAULT, |
| 282 | + ConfigDef.Range.atLeast(1), |
| 283 | + ConfigDef.Importance.MEDIUM, |
| 284 | + AWS_S3_RETRY_BACKOFF_MAX_DELAY_MS_DOC, |
| 285 | + GROUP_AWS, |
| 286 | + awsGroupCounter++, |
| 287 | + ConfigDef.Width.NONE, |
| 288 | + AWS_S3_RETRY_BACKOFF_MAX_DELAY_MS_CONFIG |
| 289 | + ) |
| 290 | + .define( |
| 291 | + AWS_S3_RETRY_BACKOFF_MAX_RETRIES_CONFIG, |
| 292 | + ConfigDef.Type.INT, |
| 293 | + AWS_S3_RETRY_BACKOFF_MAX_RETRIES_DEFAULT, |
| 294 | + ConfigDef.Range.between(1, AWS_S3_RETRY_BACKOFF_MAX_RETRIES_MAX_VALUE), |
| 295 | + ConfigDef.Importance.MEDIUM, |
| 296 | + AWS_S3_RETRY_BACKOFF_MAX_RETRIES_DOC, |
| 297 | + GROUP_AWS, |
| 298 | + awsGroupCounter++, |
| 299 | + ConfigDef.Width.NONE, |
| 300 | + AWS_S3_RETRY_BACKOFF_MAX_RETRIES_CONFIG |
234 | 301 | );
|
235 | 302 | }
|
236 | 303 |
|
|
0 commit comments