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

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

                Author: ASF GitHub Bot
            Created on: 04/Mar/20 23:31
            Start Date: 04/Mar/20 23:31
    Worklog Time Spent: 10m 
      Work Description: sv2000 commented on pull request #2907: 
[GOBBLIN-1068]Clean up cyclic logic in task cancellation
URL: https://github.com/apache/incubator-gobblin/pull/2907#discussion_r387990181
 
 

 ##########
 File path: 
gobblin-runtime/src/main/java/org/apache/gobblin/runtime/GobblinMultiTaskAttempt.java
 ##########
 @@ -160,25 +163,40 @@ public void run()
       }
     } catch (InterruptedException interrupt) {
       log.info("Job interrupted by InterrupedException.");
-      interruptTaskExecution(countDownLatch);
+      interruptTaskExecution(Optional.of(countDownLatch));
     }
     log.info("All assigned tasks of job {} have completed in container {}", 
jobId, containerIdOptional.or(""));
   }
 
-  private void interruptTaskExecution(CountDownLatch countDownLatch)
-      throws InterruptedException {
+  /**
+   * A helper function that shutting down all outstanding tasks and destroy 
taskExecutor if timeout on waiting for
+   * certain tasks' termination.
+   */
+  private void interruptTaskExecution(Optional<CountDownLatch> countDownLatch) 
throws InterruptedException {
     log.info("Job interrupted. Attempting a graceful shutdown of the job.");
-    this.tasks.forEach(Task::shutdown);
-    if (!countDownLatch.await(5, TimeUnit.SECONDS)) {
-      log.warn("Graceful shutdown of job timed out. Killing all outstanding 
tasks.");
-      try {
+    this.shutdownTasks();
+    try {
+      if (countDownLatch.isPresent()) {
+        if (!countDownLatch.get().await(5, TimeUnit.SECONDS)) {
+          log.warn("Graceful shutdown of job timed out. Killing all 
outstanding tasks.");
+          this.taskExecutor.shutDown();
 
 Review comment:
   Can this line be refactored outside the else {..} block to avoid it being 
called in both if and the else?
 
----------------------------------------------------------------
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: 397973)
    Time Spent: 1h 10m  (was: 1h)

> Clean cyclic logic in task cancellation in Gobblin Task
> -------------------------------------------------------
>
>                 Key: GOBBLIN-1068
>                 URL: https://issues.apache.org/jira/browse/GOBBLIN-1068
>             Project: Apache Gobblin
>          Issue Type: Bug
>            Reporter: Lei Sun
>            Priority: Major
>          Time Spent: 1h 10m
>  Remaining Estimate: 0h
>




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

Reply via email to