Repository: zeppelin
Updated Branches:
  refs/heads/master aa3ea6869 -> 0e82a5712


ZEPPELIN-3391. Incorrect status shown for '%livy2.conf' and %spark2.conf' 
interpreters

### What is this PR for?
The root cause of this bug is that the final status of paragraph is not only 
determined by interpreter, but also by its scheduler. Here the bug is in 
FIFOScheduler. I just fix it as a quick solution in this PR. But for a long 
term solution, I think we may need to do code refactoring in the scheduler 
component.

### What type of PR is it?
[Bug Fix]

### Todos
* [ ] - Task

### What is the Jira issue?
* https://issues.apache.org/jira/browse/ZEPPELIN-3391

### How should this be tested?
* Manually tested

### Screenshots (if appropriate)

### Questions:
* Does the licenses files need update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? No

Author: Jeff Zhang <zjf...@apache.org>

Closes #2926 from zjffdu/ZEPPELIN-3391 and squashes the following commits:

09441ad [Jeff Zhang] ZEPPELIN-3391. Incorrect status shown for '%livy2.conf' 
and %spark2.conf' interpreters


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

Branch: refs/heads/master
Commit: 0e82a5712ea6229925b7b9663d492b54d3c29b59
Parents: aa3ea68
Author: Jeff Zhang <zjf...@apache.org>
Authored: Wed Apr 11 22:53:48 2018 +0800
Committer: Jeff Zhang <zjf...@apache.org>
Committed: Tue Apr 17 10:11:42 2018 +0800

----------------------------------------------------------------------
 .../remote/RemoteInterpreterServer.java         | 14 ++++---------
 .../zeppelin/scheduler/FIFOScheduler.java       | 22 +++++++++++++++-----
 2 files changed, 21 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0e82a571/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterServer.java
----------------------------------------------------------------------
diff --git 
a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterServer.java
 
b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterServer.java
index b5c7aef..401be36 100644
--- 
a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterServer.java
+++ 
b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterServer.java
@@ -453,16 +453,10 @@ public class RemoteInterpreterServer extends Thread
 
     progressMap.remove(interpreterContext.getParagraphId());
 
-    InterpreterResult result;
-    if (job.getStatus() == Status.ERROR) {
-      result = new InterpreterResult(Code.ERROR, 
Job.getStack(job.getException()));
-    } else {
-      result = (InterpreterResult) job.getReturn();
-
-      // in case of job abort in PENDING status, result can be null
-      if (result == null) {
-        result = new InterpreterResult(Code.KEEP_PREVIOUS_RESULT);
-      }
+    InterpreterResult  result = (InterpreterResult) job.getReturn();
+    // in case of job abort in PENDING status, result can be null
+    if (result == null) {
+      result = new InterpreterResult(Code.KEEP_PREVIOUS_RESULT);
     }
     return convert(result,
         context.getConfig(),

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0e82a571/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/FIFOScheduler.java
----------------------------------------------------------------------
diff --git 
a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/FIFOScheduler.java
 
b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/FIFOScheduler.java
index 7ca4a0e..fd467b6 100644
--- 
a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/FIFOScheduler.java
+++ 
b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/FIFOScheduler.java
@@ -23,6 +23,7 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.concurrent.ExecutorService;
 
+import org.apache.zeppelin.interpreter.InterpreterResult;
 import org.apache.zeppelin.scheduler.Job.Status;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -137,15 +138,26 @@ public class FIFOScheduler implements Scheduler {
               listener.jobStarted(scheduler, runningJob);
             }
             runningJob.run();
+            Object jobResult = runningJob.getReturn();
             if (runningJob.isAborted()) {
               runningJob.setStatus(Status.ABORT);
+              LOGGER.debug("Job Aborted, " + runningJob.getId() + ", " +
+                  runningJob.getErrorMessage());
+            } else if (runningJob.getException() != null) {
+              LOGGER.debug("Job Error, " + runningJob.getId() + ", " +
+                  runningJob.getReturn());
+              runningJob.setStatus(Status.ERROR);
+            } else if (jobResult != null && jobResult instanceof 
InterpreterResult
+                && ((InterpreterResult) jobResult).code() == 
InterpreterResult.Code.ERROR) {
+              LOGGER.debug("Job Error, " + runningJob.getId() + ", " +
+                  runningJob.getReturn());
+              runningJob.setStatus(Status.ERROR);
             } else {
-              if (runningJob.getException() != null) {
-                runningJob.setStatus(Status.ERROR);
-              } else {
-                runningJob.setStatus(Status.FINISHED);
-              }
+              LOGGER.debug("Job Finished, " + runningJob.getId() + ", Result: 
" +
+                  runningJob.getReturn());
+              runningJob.setStatus(Status.FINISHED);
             }
+
             if (listener != null) {
               listener.jobFinished(scheduler, runningJob);
             }

Reply via email to