From 93ed8340e9ab7b771fe78992548e4ffc3d8e913b Mon Sep 17 00:00:00 2001 From: vgmartinez Date: Fri, 11 Nov 2016 14:59:45 +0100 Subject: [PATCH 1/6] rebase with master --- conf/zeppelin-site.xml.template | 55 ++++++++ docs/install/install.md | 54 +++++++ notebook/2A94M5J1Z/note.json | 123 +++++++++++----- .../org/apache/zeppelin/scheduler/Job.java | 6 +- .../src/app/notebook/notebook-actionBar.html | 45 +----- .../src/app/notebook/notebook.controller.js | 7 + .../scheduler/scheduler-dialog.html | 97 +++++++++++++ zeppelin-zengine/pom.xml | 12 ++ .../zeppelin/conf/ZeppelinConfiguration.java | 12 +- .../zeppelin/event/EventNotification.java | 133 ++++++++++++++++++ .../org/apache/zeppelin/notebook/Note.java | 2 +- .../apache/zeppelin/notebook/Notebook.java | 30 ++-- 12 files changed, 490 insertions(+), 86 deletions(-) create mode 100644 zeppelin-web/src/components/scheduler/scheduler-dialog.html create mode 100644 zeppelin-zengine/src/main/java/org/apache/zeppelin/event/EventNotification.java diff --git a/conf/zeppelin-site.xml.template b/conf/zeppelin-site.xml.template index 2edb0565307..0f3ed19d3f4 100755 --- a/conf/zeppelin-site.xml.template +++ b/conf/zeppelin-site.xml.template @@ -289,4 +289,59 @@ Size in characters of the maximum text message to be received by websocket. Defaults to 1024000 + diff --git a/docs/install/install.md b/docs/install/install.md index 2edecc6caed..ac399f60c3c 100644 --- a/docs/install/install.md +++ b/docs/install/install.md @@ -336,6 +336,60 @@ You can configure Apache Zeppelin with either **environment variables** in `conf 1024000 Size (in characters) of the maximum text message that can be received by websocket. + + ZEPPELIN_SMTP_USER + zeppelin.mail.smtp.user + + SMTP user. + + + ZEPPELIN_SMTP_PASS + zeppelin.mail.smtp.password + + Password for SMTP user. + + + ZEPPELIN_SMTP_HOST + zeppelin.mail.smtp.host + smtp.googlemail.com + The SMTP server to connect to. + + + ZEPPELIN_SMTP_PROTOCOL + zeppelin.mail.smtp.protocol + smtp + SMTP protocol. + + + ZEPPELIN_SMTP_PORT + zeppelin.mail.smtp.port + 465 + The SMTP server port to connect. + + + ZEPPELIN_SMTP_STARTTLSZEPPELIN_SMTP_AUTH + zeppelin.mail.smtp.starttls.enable + true + If true, enables the use of the STARTTLS command (if supported by the server) to switch the connection to a TLS-protected connection before issuing any login commands. + + + ZEPPELIN_SMTP_AUTH + zeppelin.mail.smtp.auth + true + If true, attempt to authenticate the user using the AUTH command. + + + ZEPPELIN_SMTP_SOCKETFACTORY + zeppelin.mail.smtp.socketFactory.port + 465 + Specifies the port to connect to when using the specified socket factory. + + + ZEPPELIN_SMTP_SOCKETFACTORY_CLASS + zeppelin.mail.smtp.socketFactory.class + javax.net.ssl.SSLSocketFactory + Specifies the name of a class that implements the javax.net.SocketFactory interface. This class will be used to create SMTP sockets. + diff --git a/notebook/2A94M5J1Z/note.json b/notebook/2A94M5J1Z/note.json index 31721db24fa..050b7d4e05d 100644 --- a/notebook/2A94M5J1Z/note.json +++ b/notebook/2A94M5J1Z/note.json @@ -2,6 +2,7 @@ "paragraphs": [ { "text": "%md\n## Welcome to Zeppelin.\n##### This is a live tutorial, you can run the code yourself. (Shift-Enter to Run)", + "user": "anonymous", "config": { "colWidth": 12.0, "graph": { @@ -19,6 +20,7 @@ "params": {}, "forms": {} }, + "apps": [], "jobName": "paragraph_1423836981412_-1007008116", "id": "20150213-231621_168813393", "result": { @@ -27,14 +29,15 @@ "msg": "\u003ch2\u003eWelcome to Zeppelin.\u003c/h2\u003e\n\u003ch5\u003eThis is a live tutorial, you can run the code yourself. (Shift-Enter to Run)\u003c/h5\u003e\n" }, "dateCreated": "Feb 13, 2015 11:16:21 PM", - "dateStarted": "Apr 1, 2015 9:11:09 PM", - "dateFinished": "Apr 1, 2015 9:11:10 PM", + "dateStarted": "Nov 11, 2016 12:55:00 PM", + "dateFinished": "Nov 11, 2016 12:55:00 PM", "status": "FINISHED", "progressUpdateIntervalMs": 500 }, { "title": "Load data into table", "text": "import org.apache.commons.io.IOUtils\nimport java.net.URL\nimport java.nio.charset.Charset\n\n// Zeppelin creates and injects sc (SparkContext) and sqlContext (HiveContext or SqlContext)\n// So you don\u0027t need create them manually\n\n// load bank data\nval bankText \u003d sc.parallelize(\n IOUtils.toString(\n new URL(\"https://s3.amazonaws.com/apache-zeppelin/tutorial/bank/bank.csv\"),\n Charset.forName(\"utf8\")).split(\"\\n\"))\n\ncase class Bank(age: Integer, job: String, marital: String, education: String, balance: Integer)\n\nval bank \u003d bankText.map(s \u003d\u003e s.split(\";\")).filter(s \u003d\u003e s(0) !\u003d \"\\\"age\\\"\").map(\n s \u003d\u003e Bank(s(0).toInt, \n s(1).replaceAll(\"\\\"\", \"\"),\n s(2).replaceAll(\"\\\"\", \"\"),\n s(3).replaceAll(\"\\\"\", \"\"),\n s(5).replaceAll(\"\\\"\", \"\").toInt\n )\n).toDF()\nbank.registerTempTable(\"bank\")", + "user": "anonymous", "dateUpdated": "Jan 14, 2016 7:58:56 PM", "config": { "colWidth": 12.0, @@ -55,21 +58,23 @@ "params": {}, "forms": {} }, + "apps": [], "jobName": "paragraph_1423500779206_-1502780787", "id": "20150210-015259_1403135953", "result": { - "code": "SUCCESS", + "code": "ERROR", "type": "TEXT", - "msg": "import org.apache.commons.io.IOUtils\nimport java.net.URL\nimport java.nio.charset.Charset\nbankText: org.apache.spark.rdd.RDD[String] \u003d ParallelCollectionRDD[32] at parallelize at \u003cconsole\u003e:65\ndefined class Bank\nbank: org.apache.spark.sql.DataFrame \u003d [age: int, job: string, marital: string, education: string, balance: int]\n" + "msg": "\nimport org.apache.commons.io.IOUtils\n\nimport java.net.URL\n\nimport java.nio.charset.Charset\n\nbankText: org.apache.spark.rdd.RDD[String] \u003d ParallelCollectionRDD[1] at parallelize at \u003cconsole\u003e:27\n\ndefined class Bank\n\n\n\n\n\u003cconsole\u003e:38: error: value toDF is not a member of org.apache.spark.rdd.RDD[Bank]\npossible cause: maybe a semicolon is missing before `value toDF\u0027?\n ).toDF()\n ^\n" }, "dateCreated": "Feb 10, 2015 1:52:59 AM", - "dateStarted": "Jul 3, 2015 1:43:40 PM", - "dateFinished": "Jul 3, 2015 1:43:45 PM", - "status": "FINISHED", + "dateStarted": "Nov 11, 2016 12:55:00 PM", + "dateFinished": "Nov 11, 2016 12:55:02 PM", + "status": "ERROR", "progressUpdateIntervalMs": 500 }, { "text": "%sql \nselect age, count(1) value\nfrom bank \nwhere age \u003c 30 \ngroup by age \norder by age", + "user": "anonymous", "config": { "colWidth": 4.0, "graph": { @@ -109,21 +114,23 @@ "params": {}, "forms": {} }, + "apps": [], "jobName": "paragraph_1423500782552_-1439281894", "id": "20150210-015302_1492795503", "result": { - "code": "SUCCESS", - "type": "TABLE", - "msg": "age\tvalue\n19\t4\n20\t3\n21\t7\n22\t9\n23\t20\n24\t24\n25\t44\n26\t77\n27\t94\n28\t103\n29\t97\n" + "code": "ERROR", + "type": "TEXT", + "msg": "Table or view not found: bank; line 2 pos 5\nset zeppelin.spark.sql.stacktrace \u003d true to see full stacktrace" }, "dateCreated": "Feb 10, 2015 1:53:02 AM", - "dateStarted": "Jul 3, 2015 1:43:17 PM", - "dateFinished": "Jul 3, 2015 1:43:23 PM", - "status": "FINISHED", + "dateStarted": "Nov 11, 2016 12:55:00 PM", + "dateFinished": "Nov 11, 2016 12:55:02 PM", + "status": "ERROR", "progressUpdateIntervalMs": 500 }, { "text": "%sql \nselect age, count(1) value \nfrom bank \nwhere age \u003c ${maxAge\u003d30} \ngroup by age \norder by age", + "user": "anonymous", "config": { "colWidth": 4.0, "graph": { @@ -171,21 +178,23 @@ } } }, + "apps": [], "jobName": "paragraph_1423720444030_-1424110477", "id": "20150212-145404_867439529", "result": { - "code": "SUCCESS", - "type": "TABLE", - "msg": "age\tvalue\n19\t4\n20\t3\n21\t7\n22\t9\n23\t20\n24\t24\n25\t44\n26\t77\n27\t94\n28\t103\n29\t97\n30\t150\n31\t199\n32\t224\n33\t186\n34\t231\n" + "code": "ERROR", + "type": "TEXT", + "msg": "Table or view not found: bank; line 2 pos 5\nset zeppelin.spark.sql.stacktrace \u003d true to see full stacktrace" }, "dateCreated": "Feb 12, 2015 2:54:04 PM", - "dateStarted": "Jul 3, 2015 1:43:28 PM", - "dateFinished": "Jul 3, 2015 1:43:29 PM", - "status": "FINISHED", + "dateStarted": "Nov 11, 2016 12:55:02 PM", + "dateFinished": "Nov 11, 2016 12:55:02 PM", + "status": "ERROR", "progressUpdateIntervalMs": 500 }, { "text": "%sql \nselect age, count(1) value \nfrom bank \nwhere marital\u003d\"${marital\u003dsingle,single|divorced|married}\" \ngroup by age \norder by age", + "user": "anonymous", "config": { "colWidth": 4.0, "graph": { @@ -244,21 +253,23 @@ } } }, + "apps": [], "jobName": "paragraph_1423836262027_-210588283", "id": "20150213-230422_1600658137", "result": { - "code": "SUCCESS", - "type": "TABLE", - "msg": "age\tvalue\n19\t4\n20\t3\n21\t7\n22\t9\n23\t17\n24\t13\n25\t33\n26\t56\n27\t64\n28\t78\n29\t56\n30\t92\n31\t86\n32\t105\n33\t61\n34\t75\n35\t46\n36\t50\n37\t43\n38\t44\n39\t30\n40\t25\n41\t19\n42\t23\n43\t21\n44\t20\n45\t15\n46\t14\n47\t12\n48\t12\n49\t11\n50\t8\n51\t6\n52\t9\n53\t4\n55\t3\n56\t3\n57\t2\n58\t7\n59\t2\n60\t5\n66\t2\n69\t1\n" + "code": "ERROR", + "type": "TEXT", + "msg": "Table or view not found: bank; line 2 pos 5\nset zeppelin.spark.sql.stacktrace \u003d true to see full stacktrace" }, "dateCreated": "Feb 13, 2015 11:04:22 PM", - "dateStarted": "Jul 3, 2015 1:43:33 PM", - "dateFinished": "Jul 3, 2015 1:43:34 PM", - "status": "FINISHED", + "dateStarted": "Nov 11, 2016 12:55:02 PM", + "dateFinished": "Nov 11, 2016 12:55:02 PM", + "status": "ERROR", "progressUpdateIntervalMs": 500 }, { "text": "%md\n## Congratulations, it\u0027s done.\n##### You can create your own notebook in \u0027Notebook\u0027 menu. Good luck!", + "user": "anonymous", "config": { "colWidth": 12.0, "graph": { @@ -276,6 +287,7 @@ "params": {}, "forms": {} }, + "apps": [], "jobName": "paragraph_1423836268492_216498320", "id": "20150213-230428_1231780373", "result": { @@ -284,13 +296,14 @@ "msg": "\u003ch2\u003eCongratulations, it\u0027s done.\u003c/h2\u003e\n\u003ch5\u003eYou can create your own notebook in \u0027Notebook\u0027 menu. Good luck!\u003c/h5\u003e\n" }, "dateCreated": "Feb 13, 2015 11:04:28 PM", - "dateStarted": "Apr 1, 2015 9:12:18 PM", - "dateFinished": "Apr 1, 2015 9:12:18 PM", + "dateStarted": "Nov 11, 2016 12:55:00 PM", + "dateFinished": "Nov 11, 2016 12:55:00 PM", "status": "FINISHED", "progressUpdateIntervalMs": 500 }, { "text": "%md\n\nAbout bank data\n\n```\nCitation Request:\n This dataset is public available for research. The details are described in [Moro et al., 2011]. \n Please include this citation if you plan to use this database:\n\n [Moro et al., 2011] S. Moro, R. Laureano and P. Cortez. Using Data Mining for Bank Direct Marketing: An Application of the CRISP-DM Methodology. \n In P. Novais et al. (Eds.), Proceedings of the European Simulation and Modelling Conference - ESM\u00272011, pp. 117-121, Guimarães, Portugal, October, 2011. EUROSIS.\n\n Available at: [pdf] http://hdl.handle.net/1822/14838\n [bib] http://www3.dsi.uminho.pt/pcortez/bib/2011-esm-1.txt\n```", + "user": "anonymous", "config": { "colWidth": 12.0, "graph": { @@ -308,6 +321,7 @@ "params": {}, "forms": {} }, + "apps": [], "jobName": "paragraph_1427420818407_872443482", "id": "20150326-214658_12335843", "result": { @@ -316,32 +330,73 @@ "msg": "\u003cp\u003eAbout bank data\u003c/p\u003e\n\u003cpre\u003e\u003ccode\u003eCitation Request:\n This dataset is public available for research. The details are described in [Moro et al., 2011]. \n Please include this citation if you plan to use this database:\n\n [Moro et al., 2011] S. Moro, R. Laureano and P. Cortez. Using Data Mining for Bank Direct Marketing: An Application of the CRISP-DM Methodology. \n In P. Novais et al. (Eds.), Proceedings of the European Simulation and Modelling Conference - ESM\u00272011, pp. 117-121, Guimarães, Portugal, October, 2011. EUROSIS.\n\n Available at: [pdf] http://hdl.handle.net/1822/14838\n [bib] http://www3.dsi.uminho.pt/pcortez/bib/2011-esm-1.txt\n\u003c/code\u003e\u003c/pre\u003e\n" }, "dateCreated": "Mar 26, 2015 9:46:58 PM", - "dateStarted": "Jul 3, 2015 1:44:56 PM", - "dateFinished": "Jul 3, 2015 1:44:56 PM", + "dateStarted": "Nov 11, 2016 12:55:00 PM", + "dateFinished": "Nov 11, 2016 12:55:00 PM", "status": "FINISHED", "progressUpdateIntervalMs": 500 }, { - "config": {}, + "text": "", + "user": "anonymous", + "dateUpdated": "Nov 11, 2016 12:46:45 PM", + "config": { + "colWidth": 12.0, + "graph": { + "mode": "table", + "height": 300.0, + "optionOpen": false, + "keys": [], + "values": [], + "groups": [], + "scatter": {} + }, + "enabled": true + }, "settings": { "params": {}, "forms": {} }, + "apps": [], "jobName": "paragraph_1435955447812_-158639899", "id": "20150703-133047_853701097", + "result": { + "code": "SUCCESS", + "type": "TEXT", + "msg": "" + }, "dateCreated": "Jul 3, 2015 1:30:47 PM", - "status": "READY", + "dateStarted": "Nov 11, 2016 12:55:02 PM", + "dateFinished": "Nov 11, 2016 12:55:02 PM", + "status": "FINISHED", "progressUpdateIntervalMs": 500 } ], "name": "Zeppelin Tutorial/Basic Features (Spark)", "id": "2A94M5J1Z", "angularObjects": { - "2B6FF8NNU": [], - "2B67PH63Z": [] + "2BKNGYUZW:shared_process": [], + "2BKGM2TZB:shared_process": [], + "2BJVQ8GJD:shared_process": [], + "2BJRG7YHR:shared_process": [], + "2BJCFPYCV:shared_process": [], + "2BGVR5GUU:shared_process": [], + "2BHVEXYH4:shared_process": [], + "2BKGC91NG:shared_process": [], + "2BGQD1Y23:shared_process": [], + "2BJDPPK44:shared_process": [], + "2BHHGVP7R:shared_process": [], + "2BHHTQNFV:shared_process": [], + "2BJJ48VXT:shared_process": [], + "2BHR5MFPB:shared_process": [], + "2BJ277JQB:shared_process": [] }, "config": { - "looknfeel": "default" + "looknfeel": "default", + "email": { + "start": "victor.garcia@beeva.com", + "success": "victor.garcia@beeva.com", + "error": "victor.garcia@beeva.com" + } }, "info": {} } diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/Job.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/Job.java index 2dc1719ebac..f31dc1b6c91 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/Job.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/Job.java @@ -68,6 +68,10 @@ public boolean isRunning() { public boolean isPending() { return this == PENDING; } + + public boolean isError() { + return this == ERROR; + } } private String jobName; @@ -166,7 +170,7 @@ public boolean isTerminated() { public boolean isRunning() { return this.status.isRunning(); } - + public void run() { JobProgressPoller progressUpdator = null; try { diff --git a/zeppelin-web/src/app/notebook/notebook-actionBar.html b/zeppelin-web/src/app/notebook/notebook-actionBar.html index 16f0e103cb8..cfe6d982b39 100644 --- a/zeppelin-web/src/app/notebook/notebook-actionBar.html +++ b/zeppelin-web/src/app/notebook/notebook-actionBar.html @@ -11,6 +11,7 @@ See the License for the specific language governing permissions and limitations under the License. --> +

- +

+ + +
+ + +
+ + + \ No newline at end of file diff --git a/zeppelin-zengine/pom.xml b/zeppelin-zengine/pom.xml index ba84f24c027..f02faa552e6 100644 --- a/zeppelin-zengine/pom.xml +++ b/zeppelin-zengine/pom.xml @@ -97,6 +97,18 @@ commons-vfs2 2.0 + + + org.apache.commons + commons-email + 1.4 + + + javax.activation + activation + + + org.apache.jackrabbit diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java index 2e48a1f24d9..9ee2f7695dd 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java @@ -591,7 +591,17 @@ public static enum ConfVars { ZEPPELIN_ALLOWED_ORIGINS("zeppelin.server.allowed.origins", "*"), ZEPPELIN_ANONYMOUS_ALLOWED("zeppelin.anonymous.allowed", true), ZEPPELIN_CREDENTIALS_PERSIST("zeppelin.credentials.persist", true), - ZEPPELIN_WEBSOCKET_MAX_TEXT_MESSAGE_SIZE("zeppelin.websocket.max.text.message.size", "1024000"); + ZEPPELIN_WEBSOCKET_MAX_TEXT_MESSAGE_SIZE("zeppelin.websocket.max.text.message.size", "1024000"), + ZEPPELIN_SMTP_USER("zeppelin.mail.smtp.user", "victor.garcia@beeva.com"), + ZEPPELIN_SMTP_PASS("zeppelin.mail.smtp.password", "crucero1989"), + ZEPPELIN_SMTP_HOST("zeppelin.mail.smtp.host", "smtp.googlemail.com"), + ZEPPELIN_SMTP_PROTOCOL("zeppelin.mail.smtp.protocol", "smtp"), + ZEPPELIN_SMTP_PORT("zeppelin.mail.smtp.port", "465"), + ZEPPELIN_SMTP_STARTTLS("zeppelin.mail.smtp.starttls.enable", "true"), + ZEPPELIN_SMTP_AUTH("zeppelin.mail.smtp.auth", "true"), + ZEPPELIN_SMTP_SOCKETFACTORY("zeppelin.mail.smtp.socketFactory.port", "465"), + ZEPPELIN_SMTP_SOCKETFACTORY_CLASS("zeppelin.mail.smtp.socketFactory.class", + "javax.net.ssl.SSLSocketFactory"); private String varName; @SuppressWarnings("rawtypes") diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/event/EventNotification.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/event/EventNotification.java new file mode 100644 index 00000000000..bef6fd548d8 --- /dev/null +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/event/EventNotification.java @@ -0,0 +1,133 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.zeppelin.event; + +import org.apache.commons.mail.DefaultAuthenticator; +import org.apache.commons.mail.Email; +import org.apache.commons.mail.EmailException; +import org.apache.commons.mail.SimpleEmail; +import org.apache.zeppelin.conf.ZeppelinConfiguration; +import org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars; +import org.apache.zeppelin.notebook.Note; +import org.apache.zeppelin.notebook.Notebook; +import org.apache.zeppelin.notebook.Paragraph; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.gson.internal.StringMap; + +/** + * Event notifications + */ +public class EventNotification { + static Logger logger = LoggerFactory.getLogger(EventNotification.class); + private static ZeppelinConfiguration conf; + + public EventNotification(ZeppelinConfiguration conf) { + this.conf = conf; + } + + public void schedulerEvent(Note note) { + StringMap email = (StringMap) note.getConfig().get("email"); + + String onStart = (String) email.get("start"); + String onSuccess = (String) email.get("success"); + String onError = (String) email.get("error"); + + if (!onStart.isEmpty()) { + //send email when start + sendEmail(onStart, "Start execute note " + note.getName()); + } + + while (!note.getLastParagraph().isTerminated()) { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + logger.error(e.toString(), e); + } + for (Paragraph para : note.paragraphs) { + if (para.getStatus().isError()) { + //improve mail messages + String msg = "Error in paragraphs "; + if (para.getTitle() != null) { + msg = msg + para.getTitle() + "\n" + + para.getResult().message(); + + } else { + msg = msg + para.getId() + "\n" + + para.getResult().message(); + } + if (!onError.isEmpty()){ + //send error email + sendEmail(onError, msg); + } + } + } + } + + if (!onSuccess.isEmpty()) { + //send email when finish + sendEmail(onSuccess, "Note " + note.getName() + " has finish."); + } + } + + public void paragraphsEvent() {} + + public void notebookEvent() {} + + public static void sendEmail(String email, String text) { + + Email sessionEmail = new SimpleEmail(); + + try { + sessionEmail.setSmtpPort(Integer.parseInt(conf.getString(ConfVars.ZEPPELIN_SMTP_PORT))); + sessionEmail.setAuthenticator(new DefaultAuthenticator( + conf.getString(ConfVars.ZEPPELIN_SMTP_USER), + conf.getString(ConfVars.ZEPPELIN_SMTP_PASS))); + sessionEmail.setHostName(conf.getString(ConfVars.ZEPPELIN_SMTP_HOST)); + + sessionEmail.getMailSession().getProperties().put("mail.smtp.host", + conf.getString(ConfVars.ZEPPELIN_SMTP_HOST)); + sessionEmail.getMailSession().getProperties().put("mail.smtp.protocol", + conf.getString(ConfVars.ZEPPELIN_SMTP_PROTOCOL)); + sessionEmail.getMailSession().getProperties().put("mail.smtp.port", + conf.getString(ConfVars.ZEPPELIN_SMTP_PORT)); + sessionEmail.getMailSession().getProperties().put("mail.smtp.starttls.enable", + conf.getString(ConfVars.ZEPPELIN_SMTP_STARTTLS)); + sessionEmail.getMailSession().getProperties().put("mail.smtp.auth", + conf.getString(ConfVars.ZEPPELIN_SMTP_AUTH)); + sessionEmail.getMailSession().getProperties().put("mail.smtp.socketFactory.port", + conf.getString(ConfVars.ZEPPELIN_SMTP_SOCKETFACTORY)); + sessionEmail.getMailSession().getProperties().put("mail.smtp.socketFactory.class", + conf.getString(ConfVars.ZEPPELIN_SMTP_SOCKETFACTORY_CLASS)); + + sessionEmail.setFrom(conf.getString(ConfVars.ZEPPELIN_SMTP_USER)); + for (String mail : email.split(",")) { + logger.info("Send email to " + mail); + sessionEmail.addTo(mail); + } + + sessionEmail.setSubject("Note scheduler in Zeppelin"); + sessionEmail.setMsg(text); + sessionEmail.send(); + + } catch (EmailException e) { + logger.error("Error: ", e); + } + } +} 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 aa08adf0f83..46d5da46035 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 @@ -73,7 +73,7 @@ public class Note implements Serializable, ParagraphJobListener { delayedPersistThreadPool.setRemoveOnCancelPolicy(true); } - final List paragraphs = new LinkedList<>(); + public final List paragraphs = new LinkedList<>(); private String name = ""; private String id; 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 c0932569af5..c39bb136787 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 @@ -31,7 +31,6 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; - import com.google.common.base.Preconditions; import com.google.common.base.Predicate; import com.google.common.collect.FluentIterable; @@ -51,11 +50,15 @@ import org.quartz.impl.StdSchedulerFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - +import org.apache.commons.mail.DefaultAuthenticator; +import org.apache.commons.mail.Email; +import org.apache.commons.mail.EmailException; +import org.apache.commons.mail.SimpleEmail; import org.apache.zeppelin.conf.ZeppelinConfiguration; import org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars; import org.apache.zeppelin.display.AngularObject; import org.apache.zeppelin.display.AngularObjectRegistry; +import org.apache.zeppelin.event.EventNotification; import org.apache.zeppelin.interpreter.InterpreterFactory; import org.apache.zeppelin.interpreter.InterpreterGroup; import org.apache.zeppelin.interpreter.InterpreterSetting; @@ -69,6 +72,7 @@ import org.apache.zeppelin.search.SearchService; import org.apache.zeppelin.user.AuthenticationInfo; import org.apache.zeppelin.user.Credentials; +import com.google.gson.internal.StringMap; /** * Collection of Notes. @@ -94,6 +98,7 @@ public class Notebook implements NoteEventListener { private final List notebookEventListeners = Collections.synchronizedList(new LinkedList()); private Credentials credentials; + private static EventNotification notification; /** * Main constructor \w manual Dependency Injection @@ -119,6 +124,7 @@ public Notebook(ZeppelinConfiguration conf, NotebookRepo notebookRepo, quartzSched = quertzSchedFact.getScheduler(); quartzSched.start(); CronJob.notebook = this; + CronJob.notification = new EventNotification(conf); AuthenticationInfo anonymous = AuthenticationInfo.ANONYMOUS; loadAllNotes(anonymous); @@ -775,6 +781,7 @@ public List> getJobListByUnixTime(boolean needsReload, */ public static class CronJob implements org.quartz.Job { public static Notebook notebook; + public static EventNotification notification; @Override public void execute(JobExecutionContext context) throws JobExecutionException { @@ -783,12 +790,19 @@ public void execute(JobExecutionContext context) throws JobExecutionException { Note note = notebook.getNote(noteId); note.runAll(); - while (!note.isTerminated()) { - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - logger.error(e.toString(), e); - } + @SuppressWarnings("rawtypes") + StringMap email = (StringMap) note.getConfig().get("email"); + + if (email != null) { + notification.schedulerEvent(note); + } else { + while (!note.getLastParagraph().isTerminated()) { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + logger.error(e.toString(), e); + } + } } boolean releaseResource = false; From 8fbabfb7435badc30cfd97b151718663f76a24c6 Mon Sep 17 00:00:00 2001 From: victor Date: Sun, 27 Nov 2016 22:49:43 +0100 Subject: [PATCH 2/6] rebase master --- .../java/org/apache/zeppelin/conf/ZeppelinConfiguration.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java index 9ee2f7695dd..0fe25171cf4 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java @@ -592,8 +592,8 @@ public static enum ConfVars { ZEPPELIN_ANONYMOUS_ALLOWED("zeppelin.anonymous.allowed", true), ZEPPELIN_CREDENTIALS_PERSIST("zeppelin.credentials.persist", true), ZEPPELIN_WEBSOCKET_MAX_TEXT_MESSAGE_SIZE("zeppelin.websocket.max.text.message.size", "1024000"), - ZEPPELIN_SMTP_USER("zeppelin.mail.smtp.user", "victor.garcia@beeva.com"), - ZEPPELIN_SMTP_PASS("zeppelin.mail.smtp.password", "crucero1989"), + ZEPPELIN_SMTP_USER("zeppelin.mail.smtp.user", "mail"), + ZEPPELIN_SMTP_PASS("zeppelin.mail.smtp.password", "passwod"), ZEPPELIN_SMTP_HOST("zeppelin.mail.smtp.host", "smtp.googlemail.com"), ZEPPELIN_SMTP_PROTOCOL("zeppelin.mail.smtp.protocol", "smtp"), ZEPPELIN_SMTP_PORT("zeppelin.mail.smtp.port", "465"), From adae5e7b7f0aebc970e7601f460cd44458f752e6 Mon Sep 17 00:00:00 2001 From: vgmartinez Date: Fri, 25 Nov 2016 14:45:52 +0100 Subject: [PATCH 3/6] fix bug in angular copy --- notebook/2A94M5J1Z/note.json | 50 ++++---- .../src/app/notebook/notebook.controller.js | 17 +-- .../scheduler/scheduler-dialog.html | 11 +- .../zeppelin/event/EmailNotification.java | 112 ++++++++++++++++++ .../zeppelin/event/EventNotification.java | 87 ++------------ .../apache/zeppelin/event/Notifications.java | 31 +++++ .../apache/zeppelin/notebook/Notebook.java | 5 +- 7 files changed, 196 insertions(+), 117 deletions(-) create mode 100644 zeppelin-zengine/src/main/java/org/apache/zeppelin/event/EmailNotification.java create mode 100644 zeppelin-zengine/src/main/java/org/apache/zeppelin/event/Notifications.java diff --git a/notebook/2A94M5J1Z/note.json b/notebook/2A94M5J1Z/note.json index 050b7d4e05d..f5e6c13b36f 100644 --- a/notebook/2A94M5J1Z/note.json +++ b/notebook/2A94M5J1Z/note.json @@ -29,8 +29,8 @@ "msg": "\u003ch2\u003eWelcome to Zeppelin.\u003c/h2\u003e\n\u003ch5\u003eThis is a live tutorial, you can run the code yourself. (Shift-Enter to Run)\u003c/h5\u003e\n" }, "dateCreated": "Feb 13, 2015 11:16:21 PM", - "dateStarted": "Nov 11, 2016 12:55:00 PM", - "dateFinished": "Nov 11, 2016 12:55:00 PM", + "dateStarted": "Nov 17, 2016 5:12:00 PM", + "dateFinished": "Nov 17, 2016 5:12:02 PM", "status": "FINISHED", "progressUpdateIntervalMs": 500 }, @@ -64,11 +64,11 @@ "result": { "code": "ERROR", "type": "TEXT", - "msg": "\nimport org.apache.commons.io.IOUtils\n\nimport java.net.URL\n\nimport java.nio.charset.Charset\n\nbankText: org.apache.spark.rdd.RDD[String] \u003d ParallelCollectionRDD[1] at parallelize at \u003cconsole\u003e:27\n\ndefined class Bank\n\n\n\n\n\u003cconsole\u003e:38: error: value toDF is not a member of org.apache.spark.rdd.RDD[Bank]\npossible cause: maybe a semicolon is missing before `value toDF\u0027?\n ).toDF()\n ^\n" + "msg": "\nimport org.apache.commons.io.IOUtils\n\nimport java.net.URL\n\nimport java.nio.charset.Charset\n\nbankText: org.apache.spark.rdd.RDD[String] \u003d ParallelCollectionRDD[0] at parallelize at \u003cconsole\u003e:23\n\ndefined class Bank\n\n\n\n\n\u003cconsole\u003e:34: error: value toDF is not a member of org.apache.spark.rdd.RDD[Bank]\npossible cause: maybe a semicolon is missing before `value toDF\u0027?\n ).toDF()\n ^\n" }, "dateCreated": "Feb 10, 2015 1:52:59 AM", - "dateStarted": "Nov 11, 2016 12:55:00 PM", - "dateFinished": "Nov 11, 2016 12:55:02 PM", + "dateStarted": "Nov 17, 2016 5:12:00 PM", + "dateFinished": "Nov 17, 2016 5:12:18 PM", "status": "ERROR", "progressUpdateIntervalMs": 500 }, @@ -123,8 +123,8 @@ "msg": "Table or view not found: bank; line 2 pos 5\nset zeppelin.spark.sql.stacktrace \u003d true to see full stacktrace" }, "dateCreated": "Feb 10, 2015 1:53:02 AM", - "dateStarted": "Nov 11, 2016 12:55:00 PM", - "dateFinished": "Nov 11, 2016 12:55:02 PM", + "dateStarted": "Nov 17, 2016 5:12:03 PM", + "dateFinished": "Nov 17, 2016 5:12:23 PM", "status": "ERROR", "progressUpdateIntervalMs": 500 }, @@ -187,8 +187,8 @@ "msg": "Table or view not found: bank; line 2 pos 5\nset zeppelin.spark.sql.stacktrace \u003d true to see full stacktrace" }, "dateCreated": "Feb 12, 2015 2:54:04 PM", - "dateStarted": "Nov 11, 2016 12:55:02 PM", - "dateFinished": "Nov 11, 2016 12:55:02 PM", + "dateStarted": "Nov 17, 2016 5:12:19 PM", + "dateFinished": "Nov 17, 2016 5:12:23 PM", "status": "ERROR", "progressUpdateIntervalMs": 500 }, @@ -262,8 +262,8 @@ "msg": "Table or view not found: bank; line 2 pos 5\nset zeppelin.spark.sql.stacktrace \u003d true to see full stacktrace" }, "dateCreated": "Feb 13, 2015 11:04:22 PM", - "dateStarted": "Nov 11, 2016 12:55:02 PM", - "dateFinished": "Nov 11, 2016 12:55:02 PM", + "dateStarted": "Nov 17, 2016 5:12:23 PM", + "dateFinished": "Nov 17, 2016 5:12:23 PM", "status": "ERROR", "progressUpdateIntervalMs": 500 }, @@ -296,8 +296,8 @@ "msg": "\u003ch2\u003eCongratulations, it\u0027s done.\u003c/h2\u003e\n\u003ch5\u003eYou can create your own notebook in \u0027Notebook\u0027 menu. Good luck!\u003c/h5\u003e\n" }, "dateCreated": "Feb 13, 2015 11:04:28 PM", - "dateStarted": "Nov 11, 2016 12:55:00 PM", - "dateFinished": "Nov 11, 2016 12:55:00 PM", + "dateStarted": "Nov 17, 2016 5:12:03 PM", + "dateFinished": "Nov 17, 2016 5:12:03 PM", "status": "FINISHED", "progressUpdateIntervalMs": 500 }, @@ -330,8 +330,8 @@ "msg": "\u003cp\u003eAbout bank data\u003c/p\u003e\n\u003cpre\u003e\u003ccode\u003eCitation Request:\n This dataset is public available for research. The details are described in [Moro et al., 2011]. \n Please include this citation if you plan to use this database:\n\n [Moro et al., 2011] S. Moro, R. Laureano and P. Cortez. Using Data Mining for Bank Direct Marketing: An Application of the CRISP-DM Methodology. \n In P. Novais et al. (Eds.), Proceedings of the European Simulation and Modelling Conference - ESM\u00272011, pp. 117-121, Guimarães, Portugal, October, 2011. EUROSIS.\n\n Available at: [pdf] http://hdl.handle.net/1822/14838\n [bib] http://www3.dsi.uminho.pt/pcortez/bib/2011-esm-1.txt\n\u003c/code\u003e\u003c/pre\u003e\n" }, "dateCreated": "Mar 26, 2015 9:46:58 PM", - "dateStarted": "Nov 11, 2016 12:55:00 PM", - "dateFinished": "Nov 11, 2016 12:55:00 PM", + "dateStarted": "Nov 17, 2016 5:12:03 PM", + "dateFinished": "Nov 17, 2016 5:12:03 PM", "status": "FINISHED", "progressUpdateIntervalMs": 500 }, @@ -365,8 +365,8 @@ "msg": "" }, "dateCreated": "Jul 3, 2015 1:30:47 PM", - "dateStarted": "Nov 11, 2016 12:55:02 PM", - "dateFinished": "Nov 11, 2016 12:55:02 PM", + "dateStarted": "Nov 17, 2016 5:12:23 PM", + "dateFinished": "Nov 17, 2016 5:12:23 PM", "status": "FINISHED", "progressUpdateIntervalMs": 500 } @@ -391,12 +391,14 @@ "2BJ277JQB:shared_process": [] }, "config": { - "looknfeel": "default", - "email": { - "start": "victor.garcia@beeva.com", - "success": "victor.garcia@beeva.com", - "error": "victor.garcia@beeva.com" - } + "notification": { + "email": { + "start": "victor.garcia@beeva.", + "finish": "victor.garcia@beeva.com", + "error": "victor.garcia@beeva.com" + } + }, + "looknfeel": "default" }, "info": {} -} +} \ No newline at end of file diff --git a/zeppelin-web/src/app/notebook/notebook.controller.js b/zeppelin-web/src/app/notebook/notebook.controller.js index d8732dd4e50..6b828823224 100644 --- a/zeppelin-web/src/app/notebook/notebook.controller.js +++ b/zeppelin-web/src/app/notebook/notebook.controller.js @@ -38,6 +38,7 @@ ngToast.dismiss(); $scope.note = null; + $scope.config = {}; $scope.moment = moment; $scope.editorToggled = false; $scope.tableToggled = false; @@ -291,22 +292,20 @@ $scope.saveNote(); }); - /** Set email for this note **/ - $scope.setEmail = function(email) { - console.log(email); - $scope.note.config.email = email; - $scope.setConfig(); - }; - $scope.setLookAndFeel = function(looknfeel) { $scope.note.config.looknfeel = looknfeel; $scope.setConfig(); }; + $scope.reset = function() { + console.log($scope.note.config); + console.log($scope.config); + $scope.note.config = angular.copy($scope.config); + }; + /** Set cron expression for this note **/ $scope.setCronScheduler = function(cronExpr) { $scope.note.config.cron = cronExpr; - $scope.setConfig(); }; /** Set the username of the user to be used to execute all notes in notebook **/ @@ -323,6 +322,7 @@ /** Update note config **/ $scope.setConfig = function(config) { + console.log(config); if (config) { $scope.note.config = config; } @@ -831,6 +831,7 @@ initializeLookAndFeel(); //open interpreter binding setting when there're none selected getInterpreterBindings(); + $scope.config = angular.copy($scope.note.config); }); $scope.$on('$destroy', function() { diff --git a/zeppelin-web/src/components/scheduler/scheduler-dialog.html b/zeppelin-web/src/components/scheduler/scheduler-dialog.html index 61f0a5ecbd5..e4bccde26c6 100644 --- a/zeppelin-web/src/components/scheduler/scheduler-dialog.html +++ b/zeppelin-web/src/components/scheduler/scheduler-dialog.html @@ -44,7 +44,6 @@

{{note.info.cron}} @@ -63,21 +62,21 @@

-
-
-
@@ -86,9 +85,9 @@ diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/event/EmailNotification.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/event/EmailNotification.java new file mode 100644 index 00000000000..3b41d17807c --- /dev/null +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/event/EmailNotification.java @@ -0,0 +1,112 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.zeppelin.event; + +import java.util.Map; +import org.apache.commons.mail.DefaultAuthenticator; +import org.apache.commons.mail.Email; +import org.apache.commons.mail.EmailException; +import org.apache.commons.mail.SimpleEmail; +import org.apache.zeppelin.conf.ZeppelinConfiguration; +import org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import com.google.gson.internal.StringMap; + +/** + * + * Send email notifications + * + */ + +public class EmailNotification implements Notifications { + static Logger logger = LoggerFactory.getLogger(EmailNotification.class); + private ZeppelinConfiguration conf; + + public EmailNotification(ZeppelinConfiguration conf) { + this.conf = conf; + } + + @Override + public void start(Map config, String msg) { + StringMap emailMap = (StringMap) config.get("email"); + String onStart = (String) emailMap.get("start"); + for (String email : onStart.split(",")) { + logger.info("Send email to " + email); + sendEmail(onStart, msg); + } + } + + @Override + public void finish(Map config, String msg) { + StringMap emailMap = (StringMap) config.get("email"); + String onSuccess = (String) emailMap.get("finish"); + for (String email : onSuccess.split(",")) { + logger.info("Send email to " + email); + sendEmail(email, msg); + } + } + + @Override + public void error(Map config, String msg) { + StringMap emailMap = (StringMap) config.get("email"); + String onError = (String) emailMap.get("error"); + for (String email : onError.split(",")) { + logger.info("Send email to " + email); + sendEmail(onError, msg); + } + } + + public void sendEmail(String email, String msg) { + Email sessionEmail = new SimpleEmail(); + + try { + sessionEmail.setSmtpPort(Integer.parseInt(conf.getString(ConfVars.ZEPPELIN_SMTP_PORT))); + sessionEmail.setAuthenticator(new DefaultAuthenticator( + conf.getString(ConfVars.ZEPPELIN_SMTP_USER), + conf.getString(ConfVars.ZEPPELIN_SMTP_PASS))); + sessionEmail.setHostName(conf.getString(ConfVars.ZEPPELIN_SMTP_HOST)); + + sessionEmail.getMailSession().getProperties().put("mail.smtp.host", + conf.getString(ConfVars.ZEPPELIN_SMTP_HOST)); + sessionEmail.getMailSession().getProperties().put("mail.smtp.protocol", + conf.getString(ConfVars.ZEPPELIN_SMTP_PROTOCOL)); + sessionEmail.getMailSession().getProperties().put("mail.smtp.port", + conf.getString(ConfVars.ZEPPELIN_SMTP_PORT)); + sessionEmail.getMailSession().getProperties().put("mail.smtp.starttls.enable", + conf.getString(ConfVars.ZEPPELIN_SMTP_STARTTLS)); + sessionEmail.getMailSession().getProperties().put("mail.smtp.auth", + conf.getString(ConfVars.ZEPPELIN_SMTP_AUTH)); + sessionEmail.getMailSession().getProperties().put("mail.smtp.socketFactory.port", + conf.getString(ConfVars.ZEPPELIN_SMTP_SOCKETFACTORY)); + sessionEmail.getMailSession().getProperties().put("mail.smtp.socketFactory.class", + conf.getString(ConfVars.ZEPPELIN_SMTP_SOCKETFACTORY_CLASS)); + + sessionEmail.setFrom(conf.getString(ConfVars.ZEPPELIN_SMTP_USER)); + sessionEmail.addTo(email); + sessionEmail.setSubject("Note scheduler in Zeppelin"); + sessionEmail.setMsg(msg); + sessionEmail.send(); + + } catch (EmailException e) { + logger.error("Error: ", e); + } + } + + +} diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/event/EventNotification.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/event/EventNotification.java index bef6fd548d8..9e6a93d552e 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/event/EventNotification.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/event/EventNotification.java @@ -17,43 +17,30 @@ package org.apache.zeppelin.event; -import org.apache.commons.mail.DefaultAuthenticator; -import org.apache.commons.mail.Email; -import org.apache.commons.mail.EmailException; -import org.apache.commons.mail.SimpleEmail; +import java.util.Map; import org.apache.zeppelin.conf.ZeppelinConfiguration; -import org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars; import org.apache.zeppelin.notebook.Note; -import org.apache.zeppelin.notebook.Notebook; import org.apache.zeppelin.notebook.Paragraph; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.gson.internal.StringMap; - /** * Event notifications */ public class EventNotification { static Logger logger = LoggerFactory.getLogger(EventNotification.class); private static ZeppelinConfiguration conf; - + Notifications emailNotification; + public EventNotification(ZeppelinConfiguration conf) { this.conf = conf; + emailNotification = new EmailNotification(conf); } - - public void schedulerEvent(Note note) { - StringMap email = (StringMap) note.getConfig().get("email"); - String onStart = (String) email.get("start"); - String onSuccess = (String) email.get("success"); - String onError = (String) email.get("error"); - - if (!onStart.isEmpty()) { - //send email when start - sendEmail(onStart, "Start execute note " + note.getName()); - } - + public void enabledNotification(Note note) { + Map config = note.getConfig(); + + emailNotification.start(config, "Start execute note " + note.getName()); while (!note.getLastParagraph().isTerminated()) { try { Thread.sleep(1000); @@ -67,67 +54,15 @@ public void schedulerEvent(Note note) { if (para.getTitle() != null) { msg = msg + para.getTitle() + "\n" + para.getResult().message(); - + } else { msg = msg + para.getId() + "\n" + para.getResult().message(); } - if (!onError.isEmpty()){ - //send error email - sendEmail(onError, msg); - } + emailNotification.error(config, msg); } } } - - if (!onSuccess.isEmpty()) { - //send email when finish - sendEmail(onSuccess, "Note " + note.getName() + " has finish."); - } - } - - public void paragraphsEvent() {} - - public void notebookEvent() {} - - public static void sendEmail(String email, String text) { - - Email sessionEmail = new SimpleEmail(); - - try { - sessionEmail.setSmtpPort(Integer.parseInt(conf.getString(ConfVars.ZEPPELIN_SMTP_PORT))); - sessionEmail.setAuthenticator(new DefaultAuthenticator( - conf.getString(ConfVars.ZEPPELIN_SMTP_USER), - conf.getString(ConfVars.ZEPPELIN_SMTP_PASS))); - sessionEmail.setHostName(conf.getString(ConfVars.ZEPPELIN_SMTP_HOST)); - - sessionEmail.getMailSession().getProperties().put("mail.smtp.host", - conf.getString(ConfVars.ZEPPELIN_SMTP_HOST)); - sessionEmail.getMailSession().getProperties().put("mail.smtp.protocol", - conf.getString(ConfVars.ZEPPELIN_SMTP_PROTOCOL)); - sessionEmail.getMailSession().getProperties().put("mail.smtp.port", - conf.getString(ConfVars.ZEPPELIN_SMTP_PORT)); - sessionEmail.getMailSession().getProperties().put("mail.smtp.starttls.enable", - conf.getString(ConfVars.ZEPPELIN_SMTP_STARTTLS)); - sessionEmail.getMailSession().getProperties().put("mail.smtp.auth", - conf.getString(ConfVars.ZEPPELIN_SMTP_AUTH)); - sessionEmail.getMailSession().getProperties().put("mail.smtp.socketFactory.port", - conf.getString(ConfVars.ZEPPELIN_SMTP_SOCKETFACTORY)); - sessionEmail.getMailSession().getProperties().put("mail.smtp.socketFactory.class", - conf.getString(ConfVars.ZEPPELIN_SMTP_SOCKETFACTORY_CLASS)); - - sessionEmail.setFrom(conf.getString(ConfVars.ZEPPELIN_SMTP_USER)); - for (String mail : email.split(",")) { - logger.info("Send email to " + mail); - sessionEmail.addTo(mail); - } - - sessionEmail.setSubject("Note scheduler in Zeppelin"); - sessionEmail.setMsg(text); - sessionEmail.send(); - - } catch (EmailException e) { - logger.error("Error: ", e); - } + emailNotification.finish(config, "Note " + note.getName() + " has finish."); } } diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/event/Notifications.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/event/Notifications.java new file mode 100644 index 00000000000..e6889adef60 --- /dev/null +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/event/Notifications.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.zeppelin.event; + +import java.util.Map; + +/** + * + * Notification interface + * + */ +public interface Notifications { + public void start(Map config, String msg); + public void finish(Map config, String msg); + public void error(Map config, String msg); +} 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 c39bb136787..300aa99880c 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 @@ -98,7 +98,6 @@ public class Notebook implements NoteEventListener { private final List notebookEventListeners = Collections.synchronizedList(new LinkedList()); private Credentials credentials; - private static EventNotification notification; /** * Main constructor \w manual Dependency Injection @@ -794,9 +793,9 @@ public void execute(JobExecutionContext context) throws JobExecutionException { StringMap email = (StringMap) note.getConfig().get("email"); if (email != null) { - notification.schedulerEvent(note); + notification.enabledNotification(note); } else { - while (!note.getLastParagraph().isTerminated()) { + while (!note.isTerminated()) { try { Thread.sleep(1000); } catch (InterruptedException e) { From 8d50f1ab3e8ba37dd9900f5d580e3ae438bcd062 Mon Sep 17 00:00:00 2001 From: victor Date: Sun, 27 Nov 2016 22:52:26 +0100 Subject: [PATCH 4/6] rebase with master --- .../src/app/notebook/notebook.controller.js | 3 -- .../scheduler/scheduler-dialog.html | 19 +++++++++--- .../zeppelin/event/EmailNotification.java | 15 ++++++---- .../zeppelin/event/EventNotification.java | 30 +++++++++---------- .../apache/zeppelin/event/Notifications.java | 6 ++-- .../org/apache/zeppelin/notebook/Note.java | 2 +- .../apache/zeppelin/notebook/Notebook.java | 6 ++-- 7 files changed, 45 insertions(+), 36 deletions(-) diff --git a/zeppelin-web/src/app/notebook/notebook.controller.js b/zeppelin-web/src/app/notebook/notebook.controller.js index 6b828823224..866c74b8f6d 100644 --- a/zeppelin-web/src/app/notebook/notebook.controller.js +++ b/zeppelin-web/src/app/notebook/notebook.controller.js @@ -298,8 +298,6 @@ }; $scope.reset = function() { - console.log($scope.note.config); - console.log($scope.config); $scope.note.config = angular.copy($scope.config); }; @@ -317,7 +315,6 @@ /** Set release resource for this note **/ $scope.setReleaseResource = function(value) { $scope.note.config.releaseresource = value; - $scope.setConfig(); }; /** Update note config **/ diff --git a/zeppelin-web/src/components/scheduler/scheduler-dialog.html b/zeppelin-web/src/components/scheduler/scheduler-dialog.html index e4bccde26c6..f97aacb883a 100644 --- a/zeppelin-web/src/components/scheduler/scheduler-dialog.html +++ b/zeppelin-web/src/components/scheduler/scheduler-dialog.html @@ -25,14 +25,16 @@
- Run note with cron scheduler. - Either choose from preset or write your own cron expression. +

+ Run note with cron scheduler. + Either choose from preset or write your own cron expression. +

+
+ + +
Scheduler note
- Enter a addresses to email when a run starts, success, or encounters an error. +

+ Enter a addresses to email when a run starts, success, or encounters an error. +

diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/event/EmailNotification.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/event/EmailNotification.java index 3b41d17807c..397c5bc3e44 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/event/EmailNotification.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/event/EmailNotification.java @@ -44,30 +44,33 @@ public EmailNotification(ZeppelinConfiguration conf) { @Override public void start(Map config, String msg) { - StringMap emailMap = (StringMap) config.get("email"); + Map notification = (Map) config.get("notification"); + Map emailMap = (Map) notification.get("email"); String onStart = (String) emailMap.get("start"); for (String email : onStart.split(",")) { - logger.info("Send email to " + email); + logger.info("Send email to: " + email); sendEmail(onStart, msg); } } @Override public void finish(Map config, String msg) { - StringMap emailMap = (StringMap) config.get("email"); + Map notification = (Map) config.get("notification"); + Map emailMap = (Map) notification.get("email"); String onSuccess = (String) emailMap.get("finish"); for (String email : onSuccess.split(",")) { - logger.info("Send email to " + email); + logger.info("Send email to: " + email); sendEmail(email, msg); } } @Override public void error(Map config, String msg) { - StringMap emailMap = (StringMap) config.get("email"); + Map notification = (Map) config.get("notification"); + Map emailMap = (Map) notification.get("email"); String onError = (String) emailMap.get("error"); for (String email : onError.split(",")) { - logger.info("Send email to " + email); + logger.info("Send email to: " + email); sendEmail(onError, msg); } } diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/event/EventNotification.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/event/EventNotification.java index 9e6a93d552e..03017327662 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/event/EventNotification.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/event/EventNotification.java @@ -29,11 +29,9 @@ */ public class EventNotification { static Logger logger = LoggerFactory.getLogger(EventNotification.class); - private static ZeppelinConfiguration conf; Notifications emailNotification; public EventNotification(ZeppelinConfiguration conf) { - this.conf = conf; emailNotification = new EmailNotification(conf); } @@ -41,26 +39,26 @@ public void enabledNotification(Note note) { Map config = note.getConfig(); emailNotification.start(config, "Start execute note " + note.getName()); - while (!note.getLastParagraph().isTerminated()) { + while (!note.isTerminated()) { try { Thread.sleep(1000); } catch (InterruptedException e) { logger.error(e.toString(), e); } - for (Paragraph para : note.paragraphs) { - if (para.getStatus().isError()) { - //improve mail messages - String msg = "Error in paragraphs "; - if (para.getTitle() != null) { - msg = msg + para.getTitle() + "\n" - + para.getResult().message(); - - } else { - msg = msg + para.getId() + "\n" - + para.getResult().message(); - } - emailNotification.error(config, msg); + } + for (Paragraph para : note.paragraphs) { + logger.info(para.getStatus() + ""); + if (para.getStatus().isError()) { + //improve mail messages + String msg = "Error in paragraphs "; + if (para.getTitle() != null) { + msg = msg + para.getTitle() + "\n" + + para.getResult().message(); + } else { + msg = msg + para.getId() + "\n" + + para.getResult().message(); } + emailNotification.error(config, msg); } } emailNotification.finish(config, "Note " + note.getName() + " has finish."); diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/event/Notifications.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/event/Notifications.java index e6889adef60..914f5480118 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/event/Notifications.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/event/Notifications.java @@ -25,7 +25,7 @@ * */ public interface Notifications { - public void start(Map config, String msg); - public void finish(Map config, String msg); - public void error(Map config, String msg); + void start(Map config, String msg); + void finish(Map config, String msg); + void error(Map config, String msg); } 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 46d5da46035..4177ddcce97 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 @@ -520,7 +520,7 @@ public void run(String paragraphId) { /** * Check whether all paragraphs belongs to this note has terminated */ - boolean isTerminated() { + public boolean isTerminated() { synchronized (paragraphs) { for (Paragraph p : paragraphs) { if (!p.isTerminated()) { 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 300aa99880c..4a399246e83 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 @@ -789,10 +789,10 @@ public void execute(JobExecutionContext context) throws JobExecutionException { Note note = notebook.getNote(noteId); note.runAll(); - @SuppressWarnings("rawtypes") - StringMap email = (StringMap) note.getConfig().get("email"); + Map notificationConf = (Map) note.getConfig() + .get("notification"); - if (email != null) { + if (notificationConf != null) { notification.enabledNotification(note); } else { while (!note.isTerminated()) { From 8fe4505096e77605939f400bf887d82887a4ad08 Mon Sep 17 00:00:00 2001 From: victor Date: Sun, 27 Nov 2016 23:02:35 +0100 Subject: [PATCH 5/6] back change in tutorial note --- notebook/2A94M5J1Z/note.json | 123 +++++------------- .../org/apache/zeppelin/scheduler/Job.java | 4 - 2 files changed, 33 insertions(+), 94 deletions(-) diff --git a/notebook/2A94M5J1Z/note.json b/notebook/2A94M5J1Z/note.json index f5e6c13b36f..331695f3d32 100644 --- a/notebook/2A94M5J1Z/note.json +++ b/notebook/2A94M5J1Z/note.json @@ -2,7 +2,6 @@ "paragraphs": [ { "text": "%md\n## Welcome to Zeppelin.\n##### This is a live tutorial, you can run the code yourself. (Shift-Enter to Run)", - "user": "anonymous", "config": { "colWidth": 12.0, "graph": { @@ -20,7 +19,6 @@ "params": {}, "forms": {} }, - "apps": [], "jobName": "paragraph_1423836981412_-1007008116", "id": "20150213-231621_168813393", "result": { @@ -29,15 +27,14 @@ "msg": "\u003ch2\u003eWelcome to Zeppelin.\u003c/h2\u003e\n\u003ch5\u003eThis is a live tutorial, you can run the code yourself. (Shift-Enter to Run)\u003c/h5\u003e\n" }, "dateCreated": "Feb 13, 2015 11:16:21 PM", - "dateStarted": "Nov 17, 2016 5:12:00 PM", - "dateFinished": "Nov 17, 2016 5:12:02 PM", + "dateStarted": "Apr 1, 2015 9:11:09 PM", + "dateFinished": "Apr 1, 2015 9:11:10 PM", "status": "FINISHED", "progressUpdateIntervalMs": 500 }, { "title": "Load data into table", "text": "import org.apache.commons.io.IOUtils\nimport java.net.URL\nimport java.nio.charset.Charset\n\n// Zeppelin creates and injects sc (SparkContext) and sqlContext (HiveContext or SqlContext)\n// So you don\u0027t need create them manually\n\n// load bank data\nval bankText \u003d sc.parallelize(\n IOUtils.toString(\n new URL(\"https://s3.amazonaws.com/apache-zeppelin/tutorial/bank/bank.csv\"),\n Charset.forName(\"utf8\")).split(\"\\n\"))\n\ncase class Bank(age: Integer, job: String, marital: String, education: String, balance: Integer)\n\nval bank \u003d bankText.map(s \u003d\u003e s.split(\";\")).filter(s \u003d\u003e s(0) !\u003d \"\\\"age\\\"\").map(\n s \u003d\u003e Bank(s(0).toInt, \n s(1).replaceAll(\"\\\"\", \"\"),\n s(2).replaceAll(\"\\\"\", \"\"),\n s(3).replaceAll(\"\\\"\", \"\"),\n s(5).replaceAll(\"\\\"\", \"\").toInt\n )\n).toDF()\nbank.registerTempTable(\"bank\")", - "user": "anonymous", "dateUpdated": "Jan 14, 2016 7:58:56 PM", "config": { "colWidth": 12.0, @@ -58,23 +55,21 @@ "params": {}, "forms": {} }, - "apps": [], "jobName": "paragraph_1423500779206_-1502780787", "id": "20150210-015259_1403135953", "result": { - "code": "ERROR", + "code": "SUCCESS", "type": "TEXT", - "msg": "\nimport org.apache.commons.io.IOUtils\n\nimport java.net.URL\n\nimport java.nio.charset.Charset\n\nbankText: org.apache.spark.rdd.RDD[String] \u003d ParallelCollectionRDD[0] at parallelize at \u003cconsole\u003e:23\n\ndefined class Bank\n\n\n\n\n\u003cconsole\u003e:34: error: value toDF is not a member of org.apache.spark.rdd.RDD[Bank]\npossible cause: maybe a semicolon is missing before `value toDF\u0027?\n ).toDF()\n ^\n" + "msg": "import org.apache.commons.io.IOUtils\nimport java.net.URL\nimport java.nio.charset.Charset\nbankText: org.apache.spark.rdd.RDD[String] \u003d ParallelCollectionRDD[32] at parallelize at \u003cconsole\u003e:65\ndefined class Bank\nbank: org.apache.spark.sql.DataFrame \u003d [age: int, job: string, marital: string, education: string, balance: int]\n" }, "dateCreated": "Feb 10, 2015 1:52:59 AM", - "dateStarted": "Nov 17, 2016 5:12:00 PM", - "dateFinished": "Nov 17, 2016 5:12:18 PM", - "status": "ERROR", + "dateStarted": "Jul 3, 2015 1:43:40 PM", + "dateFinished": "Jul 3, 2015 1:43:45 PM", + "status": "FINISHED", "progressUpdateIntervalMs": 500 }, { "text": "%sql \nselect age, count(1) value\nfrom bank \nwhere age \u003c 30 \ngroup by age \norder by age", - "user": "anonymous", "config": { "colWidth": 4.0, "graph": { @@ -114,23 +109,21 @@ "params": {}, "forms": {} }, - "apps": [], "jobName": "paragraph_1423500782552_-1439281894", "id": "20150210-015302_1492795503", "result": { - "code": "ERROR", - "type": "TEXT", - "msg": "Table or view not found: bank; line 2 pos 5\nset zeppelin.spark.sql.stacktrace \u003d true to see full stacktrace" + "code": "SUCCESS", + "type": "TABLE", + "msg": "age\tvalue\n19\t4\n20\t3\n21\t7\n22\t9\n23\t20\n24\t24\n25\t44\n26\t77\n27\t94\n28\t103\n29\t97\n" }, "dateCreated": "Feb 10, 2015 1:53:02 AM", - "dateStarted": "Nov 17, 2016 5:12:03 PM", - "dateFinished": "Nov 17, 2016 5:12:23 PM", - "status": "ERROR", + "dateStarted": "Jul 3, 2015 1:43:17 PM", + "dateFinished": "Jul 3, 2015 1:43:23 PM", + "status": "FINISHED", "progressUpdateIntervalMs": 500 }, { "text": "%sql \nselect age, count(1) value \nfrom bank \nwhere age \u003c ${maxAge\u003d30} \ngroup by age \norder by age", - "user": "anonymous", "config": { "colWidth": 4.0, "graph": { @@ -178,23 +171,21 @@ } } }, - "apps": [], "jobName": "paragraph_1423720444030_-1424110477", "id": "20150212-145404_867439529", "result": { - "code": "ERROR", - "type": "TEXT", - "msg": "Table or view not found: bank; line 2 pos 5\nset zeppelin.spark.sql.stacktrace \u003d true to see full stacktrace" + "code": "SUCCESS", + "type": "TABLE", + "msg": "age\tvalue\n19\t4\n20\t3\n21\t7\n22\t9\n23\t20\n24\t24\n25\t44\n26\t77\n27\t94\n28\t103\n29\t97\n30\t150\n31\t199\n32\t224\n33\t186\n34\t231\n" }, "dateCreated": "Feb 12, 2015 2:54:04 PM", - "dateStarted": "Nov 17, 2016 5:12:19 PM", - "dateFinished": "Nov 17, 2016 5:12:23 PM", - "status": "ERROR", + "dateStarted": "Jul 3, 2015 1:43:28 PM", + "dateFinished": "Jul 3, 2015 1:43:29 PM", + "status": "FINISHED", "progressUpdateIntervalMs": 500 }, { "text": "%sql \nselect age, count(1) value \nfrom bank \nwhere marital\u003d\"${marital\u003dsingle,single|divorced|married}\" \ngroup by age \norder by age", - "user": "anonymous", "config": { "colWidth": 4.0, "graph": { @@ -253,23 +244,21 @@ } } }, - "apps": [], "jobName": "paragraph_1423836262027_-210588283", "id": "20150213-230422_1600658137", "result": { - "code": "ERROR", - "type": "TEXT", - "msg": "Table or view not found: bank; line 2 pos 5\nset zeppelin.spark.sql.stacktrace \u003d true to see full stacktrace" + "code": "SUCCESS", + "type": "TABLE", + "msg": "age\tvalue\n19\t4\n20\t3\n21\t7\n22\t9\n23\t17\n24\t13\n25\t33\n26\t56\n27\t64\n28\t78\n29\t56\n30\t92\n31\t86\n32\t105\n33\t61\n34\t75\n35\t46\n36\t50\n37\t43\n38\t44\n39\t30\n40\t25\n41\t19\n42\t23\n43\t21\n44\t20\n45\t15\n46\t14\n47\t12\n48\t12\n49\t11\n50\t8\n51\t6\n52\t9\n53\t4\n55\t3\n56\t3\n57\t2\n58\t7\n59\t2\n60\t5\n66\t2\n69\t1\n" }, "dateCreated": "Feb 13, 2015 11:04:22 PM", - "dateStarted": "Nov 17, 2016 5:12:23 PM", - "dateFinished": "Nov 17, 2016 5:12:23 PM", - "status": "ERROR", + "dateStarted": "Jul 3, 2015 1:43:33 PM", + "dateFinished": "Jul 3, 2015 1:43:34 PM", + "status": "FINISHED", "progressUpdateIntervalMs": 500 }, { "text": "%md\n## Congratulations, it\u0027s done.\n##### You can create your own notebook in \u0027Notebook\u0027 menu. Good luck!", - "user": "anonymous", "config": { "colWidth": 12.0, "graph": { @@ -287,7 +276,6 @@ "params": {}, "forms": {} }, - "apps": [], "jobName": "paragraph_1423836268492_216498320", "id": "20150213-230428_1231780373", "result": { @@ -296,14 +284,13 @@ "msg": "\u003ch2\u003eCongratulations, it\u0027s done.\u003c/h2\u003e\n\u003ch5\u003eYou can create your own notebook in \u0027Notebook\u0027 menu. Good luck!\u003c/h5\u003e\n" }, "dateCreated": "Feb 13, 2015 11:04:28 PM", - "dateStarted": "Nov 17, 2016 5:12:03 PM", - "dateFinished": "Nov 17, 2016 5:12:03 PM", + "dateStarted": "Apr 1, 2015 9:12:18 PM", + "dateFinished": "Apr 1, 2015 9:12:18 PM", "status": "FINISHED", "progressUpdateIntervalMs": 500 }, { "text": "%md\n\nAbout bank data\n\n```\nCitation Request:\n This dataset is public available for research. The details are described in [Moro et al., 2011]. \n Please include this citation if you plan to use this database:\n\n [Moro et al., 2011] S. Moro, R. Laureano and P. Cortez. Using Data Mining for Bank Direct Marketing: An Application of the CRISP-DM Methodology. \n In P. Novais et al. (Eds.), Proceedings of the European Simulation and Modelling Conference - ESM\u00272011, pp. 117-121, Guimarães, Portugal, October, 2011. EUROSIS.\n\n Available at: [pdf] http://hdl.handle.net/1822/14838\n [bib] http://www3.dsi.uminho.pt/pcortez/bib/2011-esm-1.txt\n```", - "user": "anonymous", "config": { "colWidth": 12.0, "graph": { @@ -321,7 +308,6 @@ "params": {}, "forms": {} }, - "apps": [], "jobName": "paragraph_1427420818407_872443482", "id": "20150326-214658_12335843", "result": { @@ -330,74 +316,31 @@ "msg": "\u003cp\u003eAbout bank data\u003c/p\u003e\n\u003cpre\u003e\u003ccode\u003eCitation Request:\n This dataset is public available for research. The details are described in [Moro et al., 2011]. \n Please include this citation if you plan to use this database:\n\n [Moro et al., 2011] S. Moro, R. Laureano and P. Cortez. Using Data Mining for Bank Direct Marketing: An Application of the CRISP-DM Methodology. \n In P. Novais et al. (Eds.), Proceedings of the European Simulation and Modelling Conference - ESM\u00272011, pp. 117-121, Guimarães, Portugal, October, 2011. EUROSIS.\n\n Available at: [pdf] http://hdl.handle.net/1822/14838\n [bib] http://www3.dsi.uminho.pt/pcortez/bib/2011-esm-1.txt\n\u003c/code\u003e\u003c/pre\u003e\n" }, "dateCreated": "Mar 26, 2015 9:46:58 PM", - "dateStarted": "Nov 17, 2016 5:12:03 PM", - "dateFinished": "Nov 17, 2016 5:12:03 PM", + "dateStarted": "Jul 3, 2015 1:44:56 PM", + "dateFinished": "Jul 3, 2015 1:44:56 PM", "status": "FINISHED", "progressUpdateIntervalMs": 500 }, { - "text": "", - "user": "anonymous", - "dateUpdated": "Nov 11, 2016 12:46:45 PM", - "config": { - "colWidth": 12.0, - "graph": { - "mode": "table", - "height": 300.0, - "optionOpen": false, - "keys": [], - "values": [], - "groups": [], - "scatter": {} - }, - "enabled": true - }, + "config": {}, "settings": { "params": {}, "forms": {} }, - "apps": [], "jobName": "paragraph_1435955447812_-158639899", "id": "20150703-133047_853701097", - "result": { - "code": "SUCCESS", - "type": "TEXT", - "msg": "" - }, "dateCreated": "Jul 3, 2015 1:30:47 PM", - "dateStarted": "Nov 17, 2016 5:12:23 PM", - "dateFinished": "Nov 17, 2016 5:12:23 PM", - "status": "FINISHED", + "status": "READY", "progressUpdateIntervalMs": 500 } ], "name": "Zeppelin Tutorial/Basic Features (Spark)", "id": "2A94M5J1Z", "angularObjects": { - "2BKNGYUZW:shared_process": [], - "2BKGM2TZB:shared_process": [], - "2BJVQ8GJD:shared_process": [], - "2BJRG7YHR:shared_process": [], - "2BJCFPYCV:shared_process": [], - "2BGVR5GUU:shared_process": [], - "2BHVEXYH4:shared_process": [], - "2BKGC91NG:shared_process": [], - "2BGQD1Y23:shared_process": [], - "2BJDPPK44:shared_process": [], - "2BHHGVP7R:shared_process": [], - "2BHHTQNFV:shared_process": [], - "2BJJ48VXT:shared_process": [], - "2BHR5MFPB:shared_process": [], - "2BJ277JQB:shared_process": [] + "2B6FF8NNU": [], + "2B67PH63Z": [] }, "config": { - "notification": { - "email": { - "start": "victor.garcia@beeva.", - "finish": "victor.garcia@beeva.com", - "error": "victor.garcia@beeva.com" - } - }, "looknfeel": "default" }, "info": {} diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/Job.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/Job.java index f31dc1b6c91..e273a2a5159 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/Job.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/Job.java @@ -68,10 +68,6 @@ public boolean isRunning() { public boolean isPending() { return this == PENDING; } - - public boolean isError() { - return this == ERROR; - } } private String jobName; From 8bca02cfb57de0d61cacd893db6a96b83b826ff4 Mon Sep 17 00:00:00 2001 From: victor Date: Sun, 27 Nov 2016 23:11:04 +0100 Subject: [PATCH 6/6] fix end line and add isError funtions --- notebook/2A94M5J1Z/note.json | 2 +- .../src/main/java/org/apache/zeppelin/scheduler/Job.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/notebook/2A94M5J1Z/note.json b/notebook/2A94M5J1Z/note.json index 331695f3d32..31721db24fa 100644 --- a/notebook/2A94M5J1Z/note.json +++ b/notebook/2A94M5J1Z/note.json @@ -344,4 +344,4 @@ "looknfeel": "default" }, "info": {} -} \ No newline at end of file +} diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/Job.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/Job.java index e273a2a5159..eef947da9f0 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/Job.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/Job.java @@ -68,6 +68,10 @@ public boolean isRunning() { public boolean isPending() { return this == PENDING; } + + public boolean isError() { + return this == ERROR; + } } private String jobName; @@ -166,7 +170,7 @@ public boolean isTerminated() { public boolean isRunning() { return this.status.isRunning(); } - + public void run() { JobProgressPoller progressUpdator = null; try {