[ 
https://issues.apache.org/jira/browse/GOBBLIN-1071?focusedWorklogId=399470&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-399470
 ]

ASF GitHub Bot logged work on GOBBLIN-1071:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 07/Mar/20 00:41
            Start Date: 07/Mar/20 00:41
    Worklog Time Spent: 10m 
      Work Description: sv2000 commented on 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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 399470)
    Time Spent: 1h 20m  (was: 1h 10m)

> Retry Task Initialization
> -------------------------
>
>                 Key: GOBBLIN-1071
>                 URL: https://issues.apache.org/jira/browse/GOBBLIN-1071
>             Project: Apache Gobblin
>          Issue Type: Improvement
>            Reporter: Lei Sun
>            Priority: Major
>          Time Spent: 1h 20m
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to