iron-spi-aws/src/main/java/io/axway/iron/spi/aws/AwsUtils.java
public static <T> Optional<T> tryAmazonAction(String actionLabel, Supplier<T> action, AtomicLong durationBetweenRequests) {
        try {
            return of(action.get());
        } catch (LimitExceededException | ProvisionedThroughputExceededException | KMSThrottlingException e) {
            int durationRandomModifier = 1 + RANDOM.nextInt(64);// random duration to make readers out of sync, avoiding simultaneous readings
            long updatedDuration = durationBetweenRequests.updateAndGet(duration -> duration * 2 // twice the duration
                    + duration * 2 / durationRandomModifier);// add random duration to avoid simultaneous reads
            LOG.debug("Update of minimal duration between two get shard iterator requests",
                      args -> args.add("actionLabel", actionLabel).add("new minimalDurationBetweenTwoGetShardIteratorRequests", updatedDuration));
        }
        return empty();
    }
public static <T> Optional<T> tryAmazonAction(String actionLabel, Supplier<T> action, AtomicLong durationBetweenRequests) {
        try {
            return of(action.get());
        } catch (LimitExceededException | ProvisionedThroughputExceededException | KMSThrottlingException e) {
            int durationRandomModifier = 1 + RANDOM.nextInt(64);// random duration to make readers out of sync, avoiding simultaneous readings
            long updatedDuration = durationBetweenRequests.updateAndGet(duration -> duration * 2 // twice the duration
                    + duration * 2 / durationRandomModifier);// add random duration to avoid simultaneous reads
            LOG.debug("Update of minimal duration between two get shard iterator requests",
                      args -> args.add("actionLabel", actionLabel).add("new minimalDurationBetweenTwoGetShardIteratorRequests", updatedDuration));
        }
        return empty();
    }
Try to perform an Amazon action and increase the duration between requests if some exception is exceeding resource usage exception is thrown.

@param <T> the action return type
@param actionLabel action label used for logging purpose only
@param action the action to retry
@param durationBetweenRequests duration between each retry
@return the action result