Repository: zeppelin
Updated Branches:
  refs/heads/branch-0.6 16d1648b6 -> e5171786c


[ZEPPELIN-960] When there is no interpreter, paragraph runJobapi  modified.

Among Zeppelin API Fixed runNote.
According to whether the interpreter specified,
was added to an exception processing for a result and operation.

run success (HTTP STATUS : 200)
```
{
  "status": "OK"
}
```

can't not found note id (HTTP STATUS : 404)
```
{
  "status": "NOT_FOUND",
  "message": "note not found."
}
```

interpter not found or not bind (HTTP STATUS : 412 -  PRECONDITION FAILED)
```
{
  "status": "PRECONDITION_FAILED",
  "message": "paragraph_1469771130099_-278315611 Not selected or Invalid 
Interpreter bind"
}
```

Bug Fix

- [x] runNote api can apply by jdbc alias naming.
- [x] The results are recorded in the paragraph.
- [x] Binding fails when the interpreter 'HTTP STATUS CODE (412: PRECONDITION 
FAILED) and returns a message.
- [x] modification docs.

https://issues.apache.org/jira/browse/ZEPPELIN-960

execute to curl command line.
1. curl -XPOST http://(your zeppelin ip):(port)/api/notebook/job/2A94M5J1Z 
-H'Content-Type:application/json'
```
curl -XPOST http://127.0.0.1:8080/api/notebook/job/2A94M5J1Z 
-H'Content-Type:application/json'
```
2.
if correct for execution then
```
{"status":"OK"}
```
if invalid notebook id then
```
{
  "status": "NOT_FOUND",
  "message": "note not found."
}
```

if not binding interpreters
![notebind](https://cloud.githubusercontent.com/assets/10525473/17242167/a2db8ba8-55b0-11e6-89ec-aca49fefbfde.png)

```
{
  "status": "PRECONDITION_FAILED",
  "message": "paragraph_(paragraphid) Not selected or Invalid Interpreter bind"
}
```

* Does the licenses files need update? no
* Is there breaking changes for older versions? no
* Does this needs documentation? yes

Author: CloverHearts <cloverhearts...@gmail.com>
Author: CloverHearts <cloverheartsdev+git...@gmail.com>

Closes #1242 from cloverhearts/ZEPPELIN-960 and squashes the following commits:

92c8a10 [CloverHearts] remove empty try-catch brace
33b0732 [CloverHearts] Merge branch 'master' into ZEPPELIN-960
9b42898 [CloverHearts] to short msg and removed confusion code.
b9e197c [CloverHearts] Merge branch 'master' into ZEPPELIN-960
a672cf3 [CloverHearts] reimplement run.eachParagraph to run.all method
1428795 [CloverHearts] Merge branch 'master' into ZEPPELIN-960
7b71ced [CloverHearts] Merge branch 'master' into ZEPPELIN-960
ff0f213 [CloverHearts] Merge branch 'master' into ZEPPELIN-960
8446513 [CloverHearts] add docs for runNoteJobs restful api
251bb52 [CloverHearts] fixed api method for runNoteJob in notebook rest api

(cherry picked from commit 42e3a141dea606427e60410537db29f92913463c)
Signed-off-by: Mina Lee <mina...@apache.org>

Conflicts:
        
zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java
        zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Note.java


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

Branch: refs/heads/branch-0.6
Commit: e5171786cd1f919993b010d745a95513656306ab
Parents: 16d1648
Author: CloverHearts <cloverhearts...@gmail.com>
Authored: Wed Aug 24 00:31:12 2016 +0900
Committer: Mina Lee <mina...@apache.org>
Committed: Mon Aug 29 17:20:39 2016 +0200

----------------------------------------------------------------------
 docs/rest-api/rest-notebook.md                  | 24 ++++++++++++++++++--
 .../apache/zeppelin/rest/NotebookRestApi.java   | 11 +++++++--
 .../java/org/apache/zeppelin/notebook/Note.java | 17 ++++++++++----
 3 files changed, 44 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e5171786/docs/rest-api/rest-notebook.md
----------------------------------------------------------------------
diff --git a/docs/rest-api/rest-notebook.md b/docs/rest-api/rest-notebook.md
index edbb595..b9fe721 100644
--- a/docs/rest-api/rest-notebook.md
+++ b/docs/rest-api/rest-notebook.md
@@ -298,7 +298,10 @@ If you work with Apache Zeppelin and find a need for an 
additional REST API, ple
     <col width="200">
     <tr>
       <td>Description</td>
-      <td>This ```POST``` method runs all paragraphs in the given notebook id.
+      <td>
+      This ```POST``` method runs all paragraphs in the given notebook id. <br 
/>
+      If you can not find Notebook id 404 returns.
+      If there is a problem with the interpreter returns a 412 error.
       </td>
     </tr>
     <tr>
@@ -311,12 +314,29 @@ If you work with Apache Zeppelin and find a need for an 
additional REST API, ple
     </tr>
     <tr>
       <td> Fail code</td>
-      <td> 500 </td>
+      <td> 404 or 412</td>
     </tr>
     <tr>
       <td> sample JSON response </td>
       <td><pre>{"status": "OK"}</pre></td>
     </tr>
+    <tr>
+       <td> sample JSON error response </td>
+       <td>
+         <pre>
+           {
+             "status": "NOT_FOUND",
+             "message": "note not found."
+           }
+         </pre><br />
+         <pre>
+           {
+             "status": "PRECONDITION_FAILED",
+             "message": "paragraph_1469771130099_-278315611 Not selected or 
Invalid Interpreter bind"
+           }
+         </pre>
+       </td>
+    </tr>
   </table>
 
 <br/>

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e5171786/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java
----------------------------------------------------------------------
diff --git 
a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java 
b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java
index 87e7cce..fdb6eb4 100644
--- 
a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java
+++ 
b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java
@@ -501,8 +501,15 @@ public class NotebookRestApi {
     if (note == null) {
       return new JsonResponse<>(Status.NOT_FOUND, "note not found.").build();
     }
-    
-    note.runAll();
+
+    try {
+      note.runAll();
+    } catch (Exception ex) {
+      LOG.error("Exception from run", ex);
+      return new JsonResponse<>(Status.PRECONDITION_FAILED,
+          ex.getMessage() + "- Not selected or Invalid Interpreter 
bind").build();
+    }
+
     return new JsonResponse<>(Status.OK).build();
   }
 

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e5171786/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Note.java
----------------------------------------------------------------------
diff --git 
a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Note.java 
b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Note.java
index ad6e92d..b556204 100644
--- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Note.java
+++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Note.java
@@ -401,9 +401,7 @@ public class Note implements Serializable, JobListener {
         authenticationInfo.setUser(cronExecutingUser);
         p.setAuthenticationInfo(authenticationInfo);
         p.setNoteReplLoader(replLoader);
-        p.setListener(jobListenerFactory.getParagraphJobListener(this));
-        Interpreter intp = replLoader.get(p.getRequiredReplName());
-        intp.getScheduler().submit(p);
+        run(p.getId());
       }
     }
   }
@@ -426,7 +424,18 @@ public class Note implements Serializable, JobListener {
         logger.debug("New paragraph: {}", pText);
         p.setEffectiveText(pText);
       } else {
-        throw new InterpreterException("Interpreter " + requiredReplName + " 
not found");
+        String intpExceptionMsg = String.format("%s",
+          p.getJobName()
+          + "'s Interpreter "
+          + requiredReplName + " not found"
+        );
+        InterpreterException intpException = new 
InterpreterException(intpExceptionMsg);
+        InterpreterResult intpResult = new InterpreterResult(
+          InterpreterResult.Code.ERROR, intpException.getMessage()
+        );
+        p.setReturn(intpResult, intpException);
+        p.setStatus(Job.Status.ERROR);
+        throw intpException;
       }
     }
     if (p.getConfig().get("enabled") == null || (Boolean) 
p.getConfig().get("enabled")) {

Reply via email to