You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by bi...@apache.org on 2017/04/10 10:42:55 UTC
[3/9] kylin git commit: KYLIN-2528 refine job email notification to
support starttls and customized port
KYLIN-2528 refine job email notification to support starttls and customized port
Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/6617955b
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/6617955b
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/6617955b
Branch: refs/heads/yang22-cdh5.7
Commit: 6617955b4fe065af9da46b2a9bc665a466e03333
Parents: 0c6441c
Author: Hongbin Ma <ma...@apache.org>
Authored: Fri Mar 31 21:15:00 2017 +0800
Committer: Hongbin Ma <ma...@apache.org>
Committed: Fri Mar 31 21:15:00 2017 +0800
----------------------------------------------------------------------
build/conf/kylin.properties | 13 ++++++++-----
.../org/apache/kylin/common/KylinConfigBase.java | 9 +++++++++
.../org/apache/kylin/common/util/MailService.java | 15 +++++++++++++--
examples/test_case_data/localmeta/kylin.properties | 15 +++++++++------
examples/test_case_data/sandbox/kylin.properties | 9 ++++++++-
5 files changed, 47 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kylin/blob/6617955b/build/conf/kylin.properties
----------------------------------------------------------------------
diff --git a/build/conf/kylin.properties b/build/conf/kylin.properties
index 5e7d235..7b93c94 100644
--- a/build/conf/kylin.properties
+++ b/build/conf/kylin.properties
@@ -109,11 +109,14 @@ kylin.job.status.with.kerberos=false
kylin.job.step.timeout=7200
# If true, will send email notification on job complete
-kylin.job.notification-enabled=false
-kylin.job.notification-mail-host=
-kylin.job.notification-mail-username=
-kylin.job.notification-mail-password=
-kylin.job.notification-mail-sender=
+#kylin.job.notification-enabled=true
+#kylin.job.notification-mail-enable-starttls=true
+#kylin.job.notification-mail-host=smtp.office365.com
+#kylin.job.notification-mail-port=587
+#kylin.job.notification-mail-username=kylin@example.com
+#kylin.job.notification-mail-password=mypassword
+#kylin.job.notification-mail-sender=kylin@example.com
+
### ENGINE ###
http://git-wip-us.apache.org/repos/asf/kylin/blob/6617955b/core-common/src/main/java/org/apache/kylin/common/KylinConfigBase.java
----------------------------------------------------------------------
diff --git a/core-common/src/main/java/org/apache/kylin/common/KylinConfigBase.java b/core-common/src/main/java/org/apache/kylin/common/KylinConfigBase.java
index 5b7c734..ac9ed04 100644
--- a/core-common/src/main/java/org/apache/kylin/common/KylinConfigBase.java
+++ b/core-common/src/main/java/org/apache/kylin/common/KylinConfigBase.java
@@ -402,6 +402,15 @@ abstract public class KylinConfigBase implements Serializable {
setProperty("kylin.job.notification-enabled", "" + enable);
}
+ public boolean isStarttlsEnabled() {
+ return Boolean.parseBoolean(getOptional("kylin.job.notification-mail-enable-starttls", "false"));
+ }
+
+ public String getSmtpPort() {
+ return getOptional("kylin.job.notification-mail-port", "25");
+ }
+
+
public String getMailHost() {
return getOptional("kylin.job.notification-mail-host", "");
}
http://git-wip-us.apache.org/repos/asf/kylin/blob/6617955b/core-common/src/main/java/org/apache/kylin/common/util/MailService.java
----------------------------------------------------------------------
diff --git a/core-common/src/main/java/org/apache/kylin/common/util/MailService.java b/core-common/src/main/java/org/apache/kylin/common/util/MailService.java
index 5793967..3bccd8f 100644
--- a/core-common/src/main/java/org/apache/kylin/common/util/MailService.java
+++ b/core-common/src/main/java/org/apache/kylin/common/util/MailService.java
@@ -34,18 +34,22 @@ public class MailService {
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(MailService.class);
private Boolean enabled = Boolean.TRUE;
+ private Boolean starttlsEnabled = Boolean.FALSE;
private String host;
+ private String port;
private String username;
private String password;
private String sender;
public MailService(KylinConfig config) {
- this(config.isMailEnabled(), config.getMailHost(), config.getMailUsername(), config.getMailPassword(), config.getMailSender());
+ this(config.isMailEnabled(), config.isStarttlsEnabled(), config.getMailHost(), config.getSmtpPort(), config.getMailUsername(), config.getMailPassword(), config.getMailSender());
}
- private MailService(boolean enabled, String host, String username, String password, String sender) {
+ private MailService(boolean enabled, boolean starttlsEnabled, String host, String port, String username, String password, String sender) {
this.enabled = enabled;
+ this.starttlsEnabled = starttlsEnabled;
this.host = host;
+ this.port = port;
this.username = username;
this.password = password;
this.sender = sender;
@@ -85,6 +89,13 @@ public class MailService {
Email email = new HtmlEmail();
email.setHostName(host);
+ email.setStartTLSEnabled(starttlsEnabled);
+ if (starttlsEnabled) {
+ email.setSslSmtpPort(port);
+ } else {
+ email.setSmtpPort(Integer.valueOf(port));
+ }
+
if (username != null && username.trim().length() > 0) {
email.setAuthentication(username, password);
}
http://git-wip-us.apache.org/repos/asf/kylin/blob/6617955b/examples/test_case_data/localmeta/kylin.properties
----------------------------------------------------------------------
diff --git a/examples/test_case_data/localmeta/kylin.properties b/examples/test_case_data/localmeta/kylin.properties
index f4c6772..79fe352 100644
--- a/examples/test_case_data/localmeta/kylin.properties
+++ b/examples/test_case_data/localmeta/kylin.properties
@@ -118,11 +118,14 @@ kylin.security.saml.context-path=/kylin
### MAIL ###
# If true, will send email notification;
-kylin.job.notification-enabled=false
-kylin.job.notification-mail-host=mail.com
-kylin.job.notification-mail-username=
-kylin.job.notification-mail-password=need_reset
-kylin.job.notification-mail-sender=
+#kylin.job.notification-enabled=true
+#kylin.job.notification-mail-enable-starttls=true
+#kylin.job.notification-mail-host=smtp.office365.com
+#kylin.job.notification-mail-port=587
+#kylin.job.notification-mail-username=kylin@example.com
+#kylin.job.notification-mail-password=mypassword
+#kylin.job.notification-mail-sender=kylin@example.com
+
### OTHER ###
@@ -133,4 +136,4 @@ kylin.engine.mr.config-override.test2=test2
kylin.job.lock=org.apache.kylin.job.lock.MockJobLock
kylin.engine.provider.0=org.apache.kylin.engine.mr.MRBatchCubingEngine
-kylin.cube.engine.2=org.apache.kylin.engine.mr.MRBatchCubingEngine2
\ No newline at end of file
+kylin.cube.engine.2=org.apache.kylin.engine.mr.MRBatchCubingEngine2
http://git-wip-us.apache.org/repos/asf/kylin/blob/6617955b/examples/test_case_data/sandbox/kylin.properties
----------------------------------------------------------------------
diff --git a/examples/test_case_data/sandbox/kylin.properties b/examples/test_case_data/sandbox/kylin.properties
index 1724619..a77a061 100644
--- a/examples/test_case_data/sandbox/kylin.properties
+++ b/examples/test_case_data/sandbox/kylin.properties
@@ -135,7 +135,14 @@ kylin.security.acl.admin-role=ROLE_ADMIN
### MAIL ###
# If true, will send email notification;
-kylin.job.notification-enabled=false
+#kylin.job.notification-enabled=true
+#kylin.job.notification-mail-enable-starttls=true
+#kylin.job.notification-mail-host=smtp.office365.com
+#kylin.job.notification-mail-port=587
+#kylin.job.notification-mail-username=kylin@example.com
+#kylin.job.notification-mail-password=mypassword
+#kylin.job.notification-mail-sender=kylin@example.com
+
### WEB ###