Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZEPPELIN-885 Add option to send email in scheduler execution #918

Closed
wants to merge 6 commits into from

Conversation

vgmartinez
Copy link
Contributor

@vgmartinez vgmartinez commented May 25, 2016

What is this PR for?

Add the option to send email when a note is runing using the scheduler.
The option to send an email when you finish executing a note or when an error occurs in one paragraph is a good utility for the user.

What type of PR is it?

Improvement

Todos

What is the Jira issue?

How should this be tested?

  • Configure smtp properties in zeppelin-site.xml
  • Set email in scheduler and add cron expresion to execute note.

Screenshots (if appropriate)

image

Questions:

  • Does the licenses files need update? No
  • Is there breaking changes for older versions? No
  • Does this needs documentation? No

@cloverhearts
Copy link
Member

Thank you for good feature.
I like this feature.

but, i got following problem.

Zeppelin Server log.

ERROR [2016-05-26 11:27:01,752] ({DefaultQuartzScheduler_Worker-2} Notebook.java[sendEmail]:594) - Error: 
org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.googlemail.com:465
    at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1421)
    at org.apache.commons.mail.Email.send(Email.java:1448)
    at org.apache.zeppelin.notebook.Notebook.sendEmail(Notebook.java:591)
    at org.apache.zeppelin.notebook.Notebook$CronJob.execute(Notebook.java:513)
    at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: javax.mail.SendFailedException: Send failure (javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8  https://support.google.com/mail/answer/14257 z12sm1446736pfj.1 - gsmtp
)
    at javax.mail.Transport.send(Transport.java:163)
    at javax.mail.Transport.send(Transport.java:48)
    at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1411)
    ... 5 more
Caused by: javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8  https://support.google.com/mail/answer/14257 z12sm1446736pfj.1 - gsmtp

    at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:892)
    at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:814)
    at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:728)
    at javax.mail.Service.connect(Service.java:274)
    at javax.mail.Service.connect(Service.java:91)
    at javax.mail.Service.connect(Service.java:76)
    at javax.mail.Transport.send(Transport.java:94)
    ... 7 more
ERROR [2016-05-26 11:27:03,392] ({DefaultQuartzScheduler_Worker-2} Notebook.java[sendEmail]:594) - Error: 
org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.googlemail.com:465
    at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1421)
    at org.apache.commons.mail.Email.send(Email.java:1448)
    at org.apache.zeppelin.notebook.Notebook.sendEmail(Notebook.java:591)
    at org.apache.zeppelin.notebook.Notebook$CronJob.execute(Notebook.java:539)
    at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: javax.mail.SendFailedException: Send failure (javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8  https://support.google.com/mail/answer/14257 f9sm1425655pfd.56 - gsmtp
)
    at javax.mail.Transport.send(Transport.java:163)
    at javax.mail.Transport.send(Transport.java:48)
    at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1411)
    ... 5 more
Caused by: javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8  https://support.google.com/mail/answer/14257 f9sm1425655pfd.56 - gsmtp

    at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:892)
    at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:814)
    at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:728)
    at javax.mail.Service.connect(Service.java:274)
    at javax.mail.Service.connect(Service.java:91)
    at javax.mail.Service.connect(Service.java:76)
    at javax.mail.Transport.send(Transport.java:94)
    ... 7 more

My Environment : Mac OS elcapitan, chrome lastests.
my note context : "println("hellow");

cron time 1m;

email : onStart : myemail@gmail.com
email : onError : myemail@gmail.com
email : onSuccess : myemail@gmail.com

@astroshim
Copy link
Contributor

astroshim commented May 26, 2016

I tested and working well.
@cloverhearts maybe you need to set up the smtp informations. you can set the variables in the "conf/zeppelin-site.xml".

@felixcheung
Copy link
Member

cool - should we have the info in documentation?

@cloverhearts
Copy link
Member

@astroshim Oh, I see. Thank you!

@bzz
Copy link
Member

bzz commented May 26, 2016

@vgmartinez Thank you for contribution!

Before a deep dive into the code, I have a question - could you pelase explain the use-case you have in mind for this feature?

I'm trying to understand in particular what is the benefit of introducing complexity of SNTP support in the Zeppelin codebase (not sure that Notebook.java is the best place for it either), versus just scheduling a notebook using existing scheduller, that just loads the SNTP library (using %dep) and then sends any template out.

See #8 from this notebook for an example of the data product, that uses this approach for sending out email notifications.

@vgmartinez
Copy link
Contributor Author

@cloverhearts @astroshim @felixcheung thks, add more info and doc ASAP.

hi @bzz, I think having the option to send an email when you finish executing a note or when an error occurs in one paragraph is a good utility for the user.
e.g if you have cron expression to run every monday is useful to receive an email when it starts, when finished or when there is an error.
what do you think?

@Leemoonsoo
Copy link
Member

@vgmartinez Thanks for contribution.

@vgmartinez and folks, how about having generalized event hook instead of just handling email after scheduler execution?

Zeppelin can generate events,

  • Scheduler execution (start, success, fail)
  • Paragraph execution (CRUD, status change)
  • Notebook (CRUD)
  • etc

And if there're some extensible mechanism that allow user plugin custom event handler. So possibly not only sending email, but also execute shell script or any other action will be possible for all type of events.

What do you think?

@vgmartinez
Copy link
Contributor Author

Hi @Leemoonsoo, I totally agree with you. I'll think a bit about this topic, if you already have some idea we can debate.

thanks for the suggestion.

@bzz
Copy link
Member

bzz commented May 31, 2016

@vgmartinez thank you for explaining the use case, it makes perfect sense and is not covered by the case I was referring to. May it's worth putting it in JIRA\PR description as well, how do you think?

@Leemoonsoo suggestion sounds really nice indeed. Even something simpler and less general with just an email would work as a first step, but email facilities better be placed outside of the Notebook.java. I presume it may very well be some kind of 'client' of the Notebook.java API inside zengine.

@Leemoonsoo
Copy link
Member

@vgmartinez I think move email facilities from Notebook.java to new class, like @bzz mentioned, would be the first step to generalize it. Doesn't need to generalize everything from the beginning, but i think it worth to show possibilities of implementing more events and more actions. And taking code out from Notebook.java will help.

@vgmartinez
Copy link
Contributor Author

@bzz @Leemoonsoo thks for review.
@bzz I'm sorry I have not explained well. I've added more description to JIRA/PR
I created a new class for events outside notebook, to use for other types of event notifications. Please take a look.

private StdSchedulerFactory quertzSchedFact;
private org.quartz.Scheduler quartzSched;
private JobListenerFactory jobListenerFactory;
private NotebookRepo notebookRepo;
private SearchService notebookIndex;
private NotebookAuthorization notebookAuthorization;
private static EventNotification notification;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are there any special reasons making notification and conf static?

@Leemoonsoo
Copy link
Member

@vgmartinez
Copy link
Contributor Author

@Leemoonsoo sorry for delay. I added the configurations in the file install.md and delete the static modifier.

@Leemoonsoo
Copy link
Member

@vgmartinez No worries. CI build fails with error

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:30 min
[INFO] Finished at: 2016-06-06T22:47:47+00:00
[INFO] Final Memory: 38M/471M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.rat:apache-rat-plugin:0.11:check (verify.rat) on project zeppelin-zengine: Too many files with unapproved license: 1 See RAT report in: /home/travis/build/apache/incubator-zeppelin/zeppelin-zengine/target/rat.txt -> [Help 1]

Could you take a look?

@vgmartinez vgmartinez force-pushed the email_option branch 2 times, most recently from 92edccf to 8ab7fe6 Compare June 13, 2016 19:28
@vgmartinez
Copy link
Contributor Author

vgmartinez commented Jun 13, 2016

@Leemoonsoo CI pass...

@Leemoonsoo
Copy link
Member

@vgmartinez Thanks for update.

I tried and found 'Cancel' button is not actually discarding chances in dialog. Check following screenshot
scheduler

@vgmartinez
Copy link
Contributor Author

Hi @Leemoonsoo,
I have refactored the code to be able to add more channels of notifications, e.g slack, SNS (in the next PR)...
Please take a look...

thks

@asfgit asfgit closed this in c38a0a0 May 9, 2018
asfgit pushed a commit that referenced this pull request May 9, 2018
close #83
close #86
close #125
close #133
close #139
close #146
close #193
close #203
close #246
close #262
close #264
close #273
close #291
close #299
close #320
close #347
close #389
close #413
close #423
close #543
close #560
close #658
close #670
close #728
close #765
close #777
close #782
close #783
close #812
close #822
close #841
close #843
close #878
close #884
close #918
close #989
close #1076
close #1135
close #1187
close #1231
close #1304
close #1316
close #1361
close #1385
close #1390
close #1414
close #1422
close #1425
close #1447
close #1458
close #1466
close #1485
close #1492
close #1495
close #1497
close #1536
close #1545
close #1561
close #1577
close #1600
close #1603
close #1678
close #1695
close #1739
close #1748
close #1765
close #1767
close #1776
close #1783
close #1799
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants