sv2000 commented on a change in pull request #2909: [GOBBLIN-1071] Retry task initialization URL: https://github.com/apache/incubator-gobblin/pull/2909#discussion_r389205881
########## File path: gobblin-runtime/src/main/java/org/apache/gobblin/runtime/GobblinMultiTaskAttempt.java ########## @@ -456,6 +464,33 @@ private Task createTaskRunnable(WorkUnitState workUnitState, CountDownLatch coun } } + /** + * As the initialization of {@link Task} could have unstable external connection which could be healed through + * retry, adding retry-wrapper here for the sake of fault-tolerance. + */ + private Task createTaskWithRetry(WorkUnitState workUnitState, CountDownLatch countDownLatch) { + Config config = ConfigUtils.propertiesToConfig(this.jobState.getProperties()) + .withValue(RETRY_TIME_OUT_MS, ConfigValueFactory.fromAnyRef(TimeUnit.MINUTES.toMillis(1L))) + .withValue(RETRY_INTERVAL_MS, ConfigValueFactory.fromAnyRef(TimeUnit.SECONDS.toMillis(2L))); + Retryer<Task> retryer = RetryerFactory.newInstance(config); + // An "effectively final" variable for counting how many retried has been done, mostly for logging purpose. + final AtomicInteger counter = new AtomicInteger(0); + + try { + return retryer.call(new Callable<Task>() { + @Override + public Task call() + throws Exception { + counter.incrementAndGet(); + log.info(String.format("The %s time that trying create Task object", counter.get())); + return createTaskRunnable(workUnitState, countDownLatch); + } + }); + } catch (Exception e) { + throw new RuntimeException("Execution in creating a Task-with-retry failed", e); Review comment: "Exception creating Task after k retries"? ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services