prateekm commented on code in PR #1650:
URL: https://github.com/apache/samza/pull/1650#discussion_r1092645895
##########
samza-core/src/main/java/org/apache/samza/util/FutureUtil.java:
##########
@@ -144,31 +141,21 @@ public static <K, V> CompletableFuture<Map<K, V>>
toFutureOfMap(
public static <T> CompletableFuture<T> executeAsyncWithRetries(String opName,
Supplier<? extends CompletionStage<T>> action, Predicate<? extends
Throwable> abortRetries,
- ExecutorService executor) {
- Duration maxDuration = Duration.ofMinutes(10);
+ ExecutorService executor, RetryPolicyConfig retryPolicyConfig) {
RetryPolicy<Object> retryPolicy = new RetryPolicy<>()
- .withMaxRetries(-1) // Sets maximum retry to unlimited from default of
3 attempts. Retries are now limited by max duration and not retry counts.
- .withBackoff(100, 312500, ChronoUnit.MILLIS, 5) // 100 ms, 500 ms,
2500 ms, 12.5 s, 1.05 min, 5.20 min, 5.20 min
- .withMaxDuration(maxDuration)
- .withJitter(Duration.ofMillis(100))
- .abortOn(abortRetries) // stop retrying if predicate returns true
- .onRetry(e -> LOG.warn("Action: {} attempt: {} completed with error {}
ms after start. Retrying up to {} ms.",
- opName, e.getAttemptCount(), e.getElapsedTime().toMillis(),
maxDuration.toMillis(), e.getLastFailure()));
-
- return executeAsyncWithRetries(opName, action, abortRetries, executor,
retryPolicy);
- }
-
- public static <T> CompletableFuture<T> executeAsyncWithRetries(String opName,
- Supplier<? extends CompletionStage<T>> action, Predicate<? extends
Throwable> abortRetries,
- ExecutorService executor, RetryPolicy<Object> retryPolicy) {
-
- RetryPolicy<Object> retryPolicyWithLog = retryPolicy.abortOn(abortRetries)
+ .withMaxRetries(retryPolicyConfig.getMaxRetries())
Review Comment:
Doesn't seem right. If RetryPolicyConfig exists, is there a better way to
build the RetryPolicy than copy-setting every property? E.g. with a constructor
that takes the config, or a builder that accepts the config?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]