You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by sh...@apache.org on 2019/02/13 18:39:53 UTC

[kylin] branch master updated: #KYLIN-3814, add pause interval before the job retry

This is an automated email from the ASF dual-hosted git repository.

shaofengshi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kylin.git


The following commit(s) were added to refs/heads/master by this push:
     new 2b759f9  #KYLIN-3814, add pause interval before the job retry
2b759f9 is described below

commit 2b759f9cfab369bcfbb4410730c55735412f6bfa
Author: ZhengshuaiPENG <co...@hotmail.com>
AuthorDate: Wed Feb 13 19:15:21 2019 +0800

    #KYLIN-3814, add pause interval before the job retry
---
 .../java/org/apache/kylin/common/KylinConfigBase.java    |  7 ++++++-
 .../apache/kylin/job/execution/AbstractExecutable.java   | 16 +++++++++++++++-
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/core-common/src/main/java/org/apache/kylin/common/KylinConfigBase.java b/core-common/src/main/java/org/apache/kylin/common/KylinConfigBase.java
index ecd663e..8f79058 100644
--- a/core-common/src/main/java/org/apache/kylin/common/KylinConfigBase.java
+++ b/core-common/src/main/java/org/apache/kylin/common/KylinConfigBase.java
@@ -753,7 +753,12 @@ abstract public class KylinConfigBase implements Serializable {
     }
 
     public int getJobRetry() {
-        return Integer.parseInt(this.getOptional("kylin.job.retry", "0"));
+        return Integer.parseInt(getOptional("kylin.job.retry", "0"));
+    }
+
+    // retry interval in milliseconds
+    public int getJobRetryInterval(){
+        return Integer.parseInt(getOptional("kylin.job.retry-interval", "30000"));
     }
 
     public String[] getJobRetryExceptions() {
diff --git a/core-job/src/main/java/org/apache/kylin/job/execution/AbstractExecutable.java b/core-job/src/main/java/org/apache/kylin/job/execution/AbstractExecutable.java
index e808084..b1d45ef 100644
--- a/core-job/src/main/java/org/apache/kylin/job/execution/AbstractExecutable.java
+++ b/core-job/src/main/java/org/apache/kylin/job/execution/AbstractExecutable.java
@@ -23,6 +23,7 @@ import java.io.StringWriter;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
 import java.util.regex.Matcher;
 
 import org.apache.commons.lang.StringUtils;
@@ -158,7 +159,8 @@ public abstract class AbstractExecutable implements Executable, Idempotent {
             Throwable realException;
             do {
                 if (retry > 0) {
-                    logger.info("Retry {}", retry);
+                    pauseOnRetry();
+                    logger.info("Begin to retry, retry time: {}", retry);
                 }
                 catchedException = null;
                 result = null;
@@ -501,6 +503,18 @@ public abstract class AbstractExecutable implements Executable, Idempotent {
         }
     }
 
+    // pauseOnRetry should only works when retry has been triggered
+    public void pauseOnRetry() {
+        int interval = KylinConfig.getInstanceFromEnv().getJobRetryInterval();
+        logger.info("Pause {} milliseconds before retry", interval);
+        try {
+            TimeUnit.MILLISECONDS.sleep(interval);
+        } catch (InterruptedException e) {
+            logger.error("Job retry was interrupted, details: {}", e);
+            Thread.currentThread().interrupt();
+        }
+    }
+
     private static boolean isRetryableException(String exceptionName) {
         String[] jobRetryExceptions = KylinConfig.getInstanceFromEnv().getJobRetryExceptions();
         return ArrayUtils.isEmpty(jobRetryExceptions) || ArrayUtils.contains(jobRetryExceptions, exceptionName);