[
https://issues.apache.org/jira/browse/GOBBLIN-2110?focusedWorklogId=926218&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-926218
]
ASF GitHub Bot logged work on GOBBLIN-2110:
-------------------------------------------
Author: ASF GitHub Bot
Created on: 16/Jul/24 19:44
Start Date: 16/Jul/24 19:44
Worklog Time Spent: 10m
Work Description: arjun4084346 commented on code in PR #4001:
URL: https://github.com/apache/gobblin/pull/4001#discussion_r1679984788
##########
gobblin-utility/src/main/java/org/apache/gobblin/util/retry/RetryerFactory.java:
##########
@@ -104,32 +117,75 @@ public static <T> Retryer<T> newInstance(Config config,
Optional<RetryListener>
return builder.build();
}
+ /**
+ Retrieves a retry predicate based on the configuration provided. If the
configuration
+ does not specify any exceptions, a default retry predicate is returned.
+ *
+ @param config the configuration object containing the list of exception
class names
+ @return a Predicate that evaluates to true if the throwable should be
retried, false otherwise
+ */
+ @VisibleForTesting
+ public static Predicate<Throwable>
getRetryPredicateFromConfigOrDefault(Config config) {
+ // Retrieve the list of exception class names from the configuration
+ List<String> exceptionList = ConfigUtils.getStringList(config,
EXCEPTION_LIST_FOR_RETRY_CONFIG_KEY);
+
+ // If the exception list is null or empty, return the default retry
predicate
+ if (exceptionList == null || exceptionList.isEmpty()) {
+ return RETRY_EXCEPTION_PREDICATE_DEFAULT;
+ }
+
+ // Create a retry predicate by mapping each exception class name to a
Predicate
+ Predicate<Throwable> retryPredicate =
exceptionList.stream().map(exceptionClassName -> {
+ try {
+ Class<?> clazz = Class.forName(exceptionClassName);
+ if (Exception.class.isAssignableFrom(clazz)) {
+ // Return a Predicate that checks if a Throwable is an instance
of the class
+ return (Predicate<Throwable>) clazz::isInstance;
+ } else {
+ LOG.error("{} is not an exception.", exceptionClassName);
+ }
+ } catch (ClassNotFoundException exception) {
+ LOG.error("Class not found for the given exception className {}",
exceptionClassName, exception);
+ } catch (Exception exception) {
+ LOG.error("Failed to instantiate exception {}",
exceptionClassName, exception);
+ }
+ return null;
+ }).filter(Objects::nonNull) // Filter out any null values
+ .reduce(com.google.common.base.Predicates::or) // Combine all
predicates using logical OR
+ .orElse(RETRY_EXCEPTION_PREDICATE_DEFAULT); // Default to
retryExceptionPredicate if no valid predicates are found
+
+ return retryPredicate;
Review Comment:
you can return retryPredicate inline
Issue Time Tracking
-------------------
Worklog Id: (was: 926218)
Time Spent: 1h 40m (was: 1.5h)
> Make retry_exception_predicate configurable in RetryerFactory
> -------------------------------------------------------------
>
> Key: GOBBLIN-2110
> URL: https://issues.apache.org/jira/browse/GOBBLIN-2110
> Project: Apache Gobblin
> Issue Type: Bug
> Reporter: Aditya Pratap Singh
> Priority: Minor
> Time Spent: 1h 40m
> Remaining Estimate: 0h
>
> Make retry_exception_predicate configurable in RetryerFactory
--
This message was sent by Atlassian Jira
(v8.20.10#820010)