Repository: zeppelin
Updated Branches:
refs/heads/master e2d0ca344 -> 42e3a141d
[ZEPPELIN-960] When there is no interpreter, paragraph runJobapi modified.
### What is this PR for?
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"
}
```
### What type of PR is it?
Bug Fix
### Todos
- [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.
### What is the Jira issue?
https://issues.apache.org/jira/browse/ZEPPELIN-960
### How should this be tested?
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

```
{
"status": "PRECONDITION_FAILED",
"message": "paragraph_(paragraphid) Not selected or Invalid Interpreter bind"
}
```
### Questions:
* Does the licenses files need update? no
* Is there breaking changes for older versions? no
* Does this needs documentation? yes
Author: CloverHearts <[email protected]>
Author: CloverHearts <[email protected]>
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
Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/42e3a141
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/42e3a141
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/42e3a141
Branch: refs/heads/master
Commit: 42e3a141dea606427e60410537db29f92913463c
Parents: e2d0ca3
Author: CloverHearts <[email protected]>
Authored: Wed Aug 24 00:31:12 2016 +0900
Committer: Alexander Bezzubov <[email protected]>
Committed: Fri Aug 26 10:16:39 2016 +0900
----------------------------------------------------------------------
docs/rest-api/rest-notebook.md | 24 ++++++++++++++++++--
.../apache/zeppelin/rest/NotebookRestApi.java | 11 ++++++++-
.../java/org/apache/zeppelin/notebook/Note.java | 19 +++++++++++-----
3 files changed, 45 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/42e3a141/docs/rest-api/rest-notebook.md
----------------------------------------------------------------------
diff --git a/docs/rest-api/rest-notebook.md b/docs/rest-api/rest-notebook.md
index fa96b6e..c7e17ea 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/42e3a141/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 2f0a825..6a286a4 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
@@ -38,6 +38,8 @@ import com.google.common.collect.Sets;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import org.apache.commons.lang3.StringUtils;
+import org.apache.zeppelin.interpreter.InterpreterResult;
+import org.apache.zeppelin.scheduler.Job;
import org.apache.zeppelin.utils.InterpreterBindingUtils;
import org.quartz.CronExpression;
import org.slf4j.Logger;
@@ -477,7 +479,14 @@ public class NotebookRestApi {
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/42e3a141/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 d9a3f96..e2194fd 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
@@ -461,11 +461,7 @@ public class Note implements Serializable,
ParagraphJobListener {
AuthenticationInfo authenticationInfo = new AuthenticationInfo();
authenticationInfo.setUser(cronExecutingUser);
p.setAuthenticationInfo(authenticationInfo);
-
- p.setListener(jobListenerFactory.getParagraphJobListener(this));
- Interpreter intp = factory.getInterpreter(getId(),
p.getRequiredReplName());
-
- intp.getScheduler().submit(p);
+ run(p.getId());
}
}
}
@@ -488,7 +484,18 @@ public class Note implements Serializable,
ParagraphJobListener {
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")) {