kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kangkai...@apache.org
Subject [10/50] [abbrv] kylin git commit: KYLIN-2528 refine job email notification to support starttls and customized port
Date Thu, 13 Apr 2017 11:21:36 GMT
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/f6ee76c8
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/f6ee76c8
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/f6ee76c8

Branch: refs/heads/KYLIN-2506
Commit: f6ee76c85a86971e71f998b2dd096b035bc7613c
Parents: 19d5b3d
Author: Hongbin Ma <mahongbin@apache.org>
Authored: Fri Mar 31 18:12:22 2017 +0800
Committer: Hongbin Ma <mahongbin@apache.org>
Committed: Fri Mar 31 18:12:22 2017 +0800

----------------------------------------------------------------------
 build/conf/kylin.properties                          | 12 +++++++-----
 .../org/apache/kylin/common/KylinConfigBase.java     |  8 ++++++++
 .../org/apache/kylin/common/util/MailService.java    | 15 +++++++++++++--
 examples/test_case_data/localmeta/kylin.properties   | 15 +++++++++------
 examples/test_case_data/sandbox/kylin.properties     |  8 +++++++-
 5 files changed, 44 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/f6ee76c8/build/conf/kylin.properties
----------------------------------------------------------------------
diff --git a/build/conf/kylin.properties b/build/conf/kylin.properties
index 1a55c94..0a77093 100644
--- a/build/conf/kylin.properties
+++ b/build/conf/kylin.properties
@@ -117,11 +117,13 @@ 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/f6ee76c8/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 02349ad..36c2b16 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
@@ -392,6 +392,14 @@ abstract public class KylinConfigBase implements Serializable {
         return Boolean.parseBoolean(getOptional("kylin.job.notification-enabled", "false"));
     }
 
+    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/f6ee76c8/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..25bc03c 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/f6ee76c8/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 eb4f35d..9f7b24c 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.engine.provider.2=org.apache.kylin.engine.mr.MRBatchCubingEngine2
\ No newline at end of file
+kylin.engine.provider.2=org.apache.kylin.engine.mr.MRBatchCubingEngine2

http://git-wip-us.apache.org/repos/asf/kylin/blob/f6ee76c8/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 6e360a3..1674d82 100644
--- a/examples/test_case_data/sandbox/kylin.properties
+++ b/examples/test_case_data/sandbox/kylin.properties
@@ -139,7 +139,13 @@ 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 ###
 


Mime
View raw message