kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From liy...@apache.org
Subject kylin git commit: minor, stablize DefaultSchedulerTest
Date Fri, 03 Feb 2017 05:44:07 GMT
Repository: kylin
Updated Branches:
  refs/heads/master 546f88f38 -> a058bfb8b


minor, stablize DefaultSchedulerTest


Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/a058bfb8
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/a058bfb8
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/a058bfb8

Branch: refs/heads/master
Commit: a058bfb8b0490fe36b7fe4da026028411ed208a5
Parents: 546f88f
Author: Li Yang <liyang@apache.org>
Authored: Fri Feb 3 13:43:56 2017 +0800
Committer: Li Yang <liyang@apache.org>
Committed: Fri Feb 3 13:43:56 2017 +0800

----------------------------------------------------------------------
 .../job/impl/threadpool/BaseSchedulerTest.java  | 36 ++++++++++++++------
 1 file changed, 26 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/a058bfb8/core-job/src/test/java/org/apache/kylin/job/impl/threadpool/BaseSchedulerTest.java
----------------------------------------------------------------------
diff --git a/core-job/src/test/java/org/apache/kylin/job/impl/threadpool/BaseSchedulerTest.java
b/core-job/src/test/java/org/apache/kylin/job/impl/threadpool/BaseSchedulerTest.java
index fdf5252..1ada9a1 100644
--- a/core-job/src/test/java/org/apache/kylin/job/impl/threadpool/BaseSchedulerTest.java
+++ b/core-job/src/test/java/org/apache/kylin/job/impl/threadpool/BaseSchedulerTest.java
@@ -31,11 +31,15 @@ import org.apache.kylin.job.execution.ExecutableState;
 import org.apache.kylin.job.lock.MockJobLock;
 import org.junit.After;
 import org.junit.Before;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  */
 public abstract class BaseSchedulerTest extends LocalFileMetadataTestCase {
 
+    private static final Logger logger = LoggerFactory.getLogger(BaseSchedulerTest.class);
+    
     private DefaultScheduler scheduler;
 
     protected ExecutableManager jobService;
@@ -70,19 +74,31 @@ public abstract class BaseSchedulerTest extends LocalFileMetadataTestCase
{
     }
 
     protected void waitForJobFinish(String jobId) {
-        while (true) {
-            AbstractExecutable job = jobService.getJob(jobId);
-            final ExecutableState status = job.getStatus();
-            if (status == ExecutableState.SUCCEED || status == ExecutableState.ERROR || status
== ExecutableState.STOPPED || status == ExecutableState.DISCARDED) {
-                break;
-            } else {
-                try {
-                    Thread.sleep(5000);
-                } catch (InterruptedException e) {
-                    e.printStackTrace();
+        int error = 0;
+        final int errorLimit = 3;
+        
+        while (error < errorLimit) {
+            try {
+                Thread.sleep(2000);
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+
+            try {
+                AbstractExecutable job = jobService.getJob(jobId);
+                ExecutableState status = job.getStatus();
+                if (status == ExecutableState.SUCCEED || status == ExecutableState.ERROR
|| status == ExecutableState.STOPPED || status == ExecutableState.DISCARDED) {
+                    break;
                 }
+            } catch (Exception ex) {
+                logger.error("", ex);
+                error++;
             }
         }
+        
+        if (error >= errorLimit) {
+            throw new RuntimeException("waitForJobFinish() encounters exceptions, see logs
above");
+        }
     }
 
     protected void waitForJobStatus(String jobId, ExecutableState state, long interval) {


Mime
View raw message