You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by mo...@apache.org on 2015/12/30 03:26:38 UTC
incubator-zeppelin git commit: Auto-restart interpreters on cron
execution.
Repository: incubator-zeppelin
Updated Branches:
refs/heads/master 4f186733d -> 45ce8a288
Auto-restart interpreters on cron execution.
### What is this PR for?
Release resource after cron schedule job.
### What type of PR is it?
Improvement
### Todos
* [x] - add check-box for release resource to the zeppelin-web.
* [x] - add release resource(interpreter restart) function to notebook.
### Is there a relevant Jira issue?
https://issues.apache.org/jira/browse/ZEPPELIN-524.
### How should this be tested?
please refer to the screenshots.
### Screenshots (if appropriate)
![release_resource](https://cloud.githubusercontent.com/assets/3348133/11922205/9ef86684-a749-11e5-9f88-13a40b7a0b02.png)
### Questions:
* Does the licenses files need update? no
* Is there breaking changes for older versions? no
* Does this needs documentation? no
Author: astroshim <hs...@nflabs.com>
Closes #557 from astroshim/ZEPPELIN-524 and squashes the following commits:
c27b9db [astroshim] remove unused class
8b0178e [astroshim] change sentence and add testcase
ef510c7 [astroshim] release resource after cron job.
Project: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/commit/45ce8a28
Tree: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/tree/45ce8a28
Diff: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/diff/45ce8a28
Branch: refs/heads/master
Commit: 45ce8a288b0faac54b588c82c2406eee0b5eb3db
Parents: 4f18673
Author: astroshim <hs...@nflabs.com>
Authored: Sat Dec 26 04:19:41 2015 +0900
Committer: Lee moon soo <mo...@apache.org>
Committed: Tue Dec 29 18:28:20 2015 -0800
----------------------------------------------------------------------
.../src/app/notebook/notebook-actionBar.html | 6 +++
.../src/app/notebook/notebook.controller.js | 6 +++
.../org/apache/zeppelin/notebook/Notebook.java | 20 ++++++++++
.../apache/zeppelin/notebook/NotebookTest.java | 42 ++++++++++++++++++++
4 files changed, 74 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/45ce8a28/zeppelin-web/src/app/notebook/notebook-actionBar.html
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/notebook/notebook-actionBar.html b/zeppelin-web/src/app/notebook/notebook-actionBar.html
index dc99e1d..360b8f7 100644
--- a/zeppelin-web/src/app/notebook/notebook-actionBar.html
+++ b/zeppelin-web/src/app/notebook/notebook-actionBar.html
@@ -100,6 +100,12 @@ limitations under the License.
{{note.info.cron}}
</p>
</div>
+ <div>
+ <span>- auto-restart interpreter on cron execution </span>
+ <input type="checkbox"
+ ng-model="note.config.releaseresource"
+ ng-click="setReleaseResource(note.config.releaseresource)">
+ </div>
</div>
</li>
</ul>
http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/45ce8a28/zeppelin-web/src/app/notebook/notebook.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/notebook/notebook.controller.js b/zeppelin-web/src/app/notebook/notebook.controller.js
index 89d7d7d..9030a49 100644
--- a/zeppelin-web/src/app/notebook/notebook.controller.js
+++ b/zeppelin-web/src/app/notebook/notebook.controller.js
@@ -282,6 +282,12 @@ angular.module('zeppelinWebApp').controller('NotebookCtrl',
$scope.setConfig();
};
+ /** Set release resource for this note **/
+ $scope.setReleaseResource = function(value) {
+ $scope.note.config.releaseresource = value;
+ $scope.setConfig();
+ };
+
/** Update note config **/
$scope.setConfig = function(config) {
if(config) {
http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/45ce8a28/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Notebook.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Notebook.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Notebook.java
index dcde50f..79d0a0d 100644
--- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Notebook.java
+++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Notebook.java
@@ -413,6 +413,26 @@ public class Notebook {
String noteId = context.getJobDetail().getJobDataMap().getString("noteId");
Note note = notebook.getNote(noteId);
note.runAll();
+
+ while (!note.getLastParagraph().isTerminated()) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ boolean releaseResource = false;
+ try {
+ releaseResource = (boolean) note.getConfig().get("releaseresource");
+ } catch (java.lang.ClassCastException e) {
+ e.printStackTrace();
+ }
+ if (releaseResource) {
+ for (InterpreterSetting setting : note.getNoteReplLoader().getInterpreterSettings()) {
+ notebook.getInterpreterFactory().restart(setting.id());
+ }
+ }
}
}
http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/45ce8a28/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java
index e2d1aac..a9cd30f 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java
@@ -38,6 +38,7 @@ import org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars;
import org.apache.zeppelin.display.AngularObjectRegistry;
import org.apache.zeppelin.interpreter.InterpreterFactory;
import org.apache.zeppelin.interpreter.InterpreterOption;
+import org.apache.zeppelin.interpreter.InterpreterSetting;
import org.apache.zeppelin.interpreter.mock.MockInterpreter1;
import org.apache.zeppelin.interpreter.mock.MockInterpreter2;
import org.apache.zeppelin.notebook.repo.NotebookRepo;
@@ -250,6 +251,47 @@ public class NotebookTest implements JobListenerFactory{
}
@Test
+ public void testAutoRestartInterpreterAfterSchedule() throws InterruptedException, IOException{
+ // create a note and a paragraph
+ Note note = notebook.createNote();
+ note.getNoteReplLoader().setInterpreters(factory.getDefaultInterpreterSettingList());
+
+ Paragraph p = note.addParagraph();
+ Map config = new HashMap<String, Object>();
+ p.setConfig(config);
+ p.setText("p1");
+
+ // set cron scheduler, once a second
+ config = note.getConfig();
+ config.put("enabled", true);
+ config.put("cron", "* * * * * ?");
+ config.put("releaseresource", "true");
+ note.setConfig(config);
+ notebook.refreshCron(note.id());
+ while (p.getStatus() != Status.FINISHED) {
+ Thread.sleep(100);
+ }
+ Date dateFinished = p.getDateFinished();
+ assertNotNull(dateFinished);
+
+ // restart interpreter
+ for (InterpreterSetting setting : note.getNoteReplLoader().getInterpreterSettings()) {
+ notebook.getInterpreterFactory().restart(setting.id());
+ }
+
+ Thread.sleep(1000);
+ while (p.getStatus() != Status.FINISHED) {
+ Thread.sleep(100);
+ }
+ assertNotEquals(dateFinished, p.getDateFinished());
+
+ // remove cron scheduler.
+ config.put("cron", null);
+ note.setConfig(config);
+ notebook.refreshCron(note.id());
+ }
+
+ @Test
public void testCloneNote() throws IOException, CloneNotSupportedException,
InterruptedException {
Note note = notebook.createNote();