tpalfy commented on a change in pull request #3612: NIFI-6486 Add option to use
built-in retry mechanism in AWS processors
URL: https://github.com/apache/nifi/pull/3612#discussion_r319980239
##########
File path:
nifi-nar-bundles/nifi-aws-bundle/nifi-aws-abstract-processors/src/main/java/org/apache/nifi/processors/aws/AbstractAWSProcessor.java
##########
@@ -262,6 +350,81 @@ protected ClientConfiguration createConfiguration(final
ProcessContext context)
return config;
}
+ private void setRetryPolicy(ClientConfiguration config, ProcessContext
context) {
+ PropertyValue property = context.getProperty(AWS_RETRY_POLICY);
+ if (property.isSet()) {
+ switch (property.getValue()){
+ case RETRY_POLICY_CUSTOM:
+ config.setRetryPolicy(new RetryPolicy(
+ getRetryCondition(context),
+ getBackoffStrategy(context),
+ getMaxErrorRetry(context),
+ true
+ ));
+ break;
+ case RETRY_POLICY_DYNAMODB_DEFAULT:
+
config.setRetryPolicy(PredefinedRetryPolicies.DYNAMODB_DEFAULT);
+ break;
+ case RETRY_POLICY_DEFAULT:
+ default:
+ break;
+ }
+ }
+ }
+
+ private RetryCondition getRetryCondition(ProcessContext context) {
+ PropertyValue property = context.getProperty(AWS_RETRY_CONDITION);
+
+ if (!property.isSet()) {
+ return DEFAULT_RETRY_CONDITION;
+ }
+
+ switch (property.getValue()) {
+ case RETRY_CONDITION_COMPLETE_MULTIPART_UPLOAD:
+ return new CompleteMultipartUploadRetryCondition();
+ case RETRY_CONDITION_NO_RETRY:
+ return RetryCondition.NO_RETRY_CONDITION;
+ case RETRY_CONDITION_SDKDEFAULT:
+ default:
+ return DEFAULT_RETRY_CONDITION;
+ }
+ }
+
+ private BackoffStrategy getBackoffStrategy(ProcessContext context) {
+ PropertyValue property = context.getProperty(AWS_BACKOFF_STRATEGY);
+ if (property.isSet()) {
+ int baseDelay = getPropertyValueOrDefault(context,
AWS_BACKOFF_BASE_DELAY, 100);
Review comment:
These magic numbers could move to constants and referenced by the property
descriptors as well.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services