From b0a40cb7bd18a1826cf7e141f305b499b7b67002 Mon Sep 17 00:00:00 2001 From: LiuXiaoYang Date: Mon, 18 Jul 2022 16:20:57 +0800 Subject: [PATCH 1/4] Because some commercial EMR servers in China will disable the common mail port, and when using smtp, the common socket class will access the timeout, so it needs to be accessed through the sslsocket class, but oozie is created by default with the net.socket class , so it is recommended to increase the corresponding configuration reading and parameter parsing for adaptation --- .../apache/oozie/action/email/EmailActionExecutor.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/src/main/java/org/apache/oozie/action/email/EmailActionExecutor.java b/core/src/main/java/org/apache/oozie/action/email/EmailActionExecutor.java index f28dd34a3..584330af8 100644 --- a/core/src/main/java/org/apache/oozie/action/email/EmailActionExecutor.java +++ b/core/src/main/java/org/apache/oozie/action/email/EmailActionExecutor.java @@ -69,6 +69,9 @@ public class EmailActionExecutor extends ActionExecutor { public static final String CONF_PREFIX = "oozie.email."; public static final String EMAIL_SMTP_HOST = CONF_PREFIX + "smtp.host"; + public static final String EMAIL_SMTP_SOCKET = CONF_PREFIX + "smtp.socketFactory.class"; + public static final String EMAIL_SMTP_SOCKET_PORT = CONF_PREFIX + "smtp.socketFactory.port"; + public static final String EMAIL_SMTP_SOCKET_FALLBACK = CONF_PREFIX + "smtp.socketFactory.fallback"; public static final String EMAIL_SMTP_PORT = CONF_PREFIX + "smtp.port"; public static final String EMAIL_SMTP_AUTH = CONF_PREFIX + "smtp.auth"; public static final String EMAIL_SMTP_USER = CONF_PREFIX + "smtp.username"; @@ -183,10 +186,13 @@ public void email(String[] to, String[] cc, String[] bcc, String subject, String // Get mailing server details. String smtpHost = ConfigurationService.get(EMAIL_SMTP_HOST); Integer smtpPortInt = ConfigurationService.getInt(EMAIL_SMTP_PORT); + Integer smtpSocketPortInt = ConfigurationService.getInt(EMAIL_SMTP_SOCKET_PORT); Boolean smtpAuthBool = ConfigurationService.getBoolean(EMAIL_SMTP_AUTH); String smtpUser = ConfigurationService.get(EMAIL_SMTP_USER); String smtpPassword = ConfigurationService.getPassword(EMAIL_SMTP_PASS, ""); Boolean smtpStarttlsBool = ConfigurationService.getBoolean(EMAIL_SMTP_STARTTLS); + String smtpSocketClass = ConfigurationService.get(EMAIL_SMTP_SOCKET); + Boolean smtpSocketFallbackBool = ConfigurationService.getBoolean(EMAIL_SMTP_SOCKET_FALLBACK); String fromAddr = ConfigurationService.get(EMAIL_SMTP_FROM); Integer timeoutMillisInt = ConfigurationService.getInt(EMAIL_SMTP_SOCKET_TIMEOUT_MS); @@ -195,6 +201,9 @@ public void email(String[] to, String[] cc, String[] bcc, String subject, String properties.setProperty("mail.smtp.port", smtpPortInt.toString()); properties.setProperty("mail.smtp.auth", smtpAuthBool.toString()); properties.setProperty("mail.smtp.starttls.enable", smtpStarttlsBool.toString()); + properties.setProperty("mail.smtp.socketFactory.class", smtpSocketClass); + properties.setProperty("mail.smtp.socketFactory.port", smtpSocketPortInt.toString()); + properties.setProperty("mail.smtp.socketFactory.fallback", smtpSocketFallbackBool.toString()); // Apply sensible timeouts, as defaults are infinite. See https://s.apache.org/javax-mail-timeouts properties.setProperty("mail.smtp.connectiontimeout", timeoutMillisInt.toString()); From 5003f4964b3e956ef25719b5ab759adbd98d31b9 Mon Sep 17 00:00:00 2001 From: LiuXiaoYang Date: Tue, 19 Jul 2022 12:14:01 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../oozie/action/email/EmailActionExecutor.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/org/apache/oozie/action/email/EmailActionExecutor.java b/core/src/main/java/org/apache/oozie/action/email/EmailActionExecutor.java index 584330af8..76aca413d 100644 --- a/core/src/main/java/org/apache/oozie/action/email/EmailActionExecutor.java +++ b/core/src/main/java/org/apache/oozie/action/email/EmailActionExecutor.java @@ -69,9 +69,9 @@ public class EmailActionExecutor extends ActionExecutor { public static final String CONF_PREFIX = "oozie.email."; public static final String EMAIL_SMTP_HOST = CONF_PREFIX + "smtp.host"; - public static final String EMAIL_SMTP_SOCKET = CONF_PREFIX + "smtp.socketFactory.class"; - public static final String EMAIL_SMTP_SOCKET_PORT = CONF_PREFIX + "smtp.socketFactory.port"; - public static final String EMAIL_SMTP_SOCKET_FALLBACK = CONF_PREFIX + "smtp.socketFactory.fallback"; + public static final String SMTP_SOCKET_FACTORY_CLASS = CONF_PREFIX + "smtp.socketFactory.class"; + public static final String EMAIL_SMTP_FACTORY_SOCKET_PORT = CONF_PREFIX + "smtp.socketFactory.port"; + public static final String EMAIL_SMTP_FACTORY_SOCKET_FALLBACK = CONF_PREFIX + "smtp.socketFactory.fallback"; public static final String EMAIL_SMTP_PORT = CONF_PREFIX + "smtp.port"; public static final String EMAIL_SMTP_AUTH = CONF_PREFIX + "smtp.auth"; public static final String EMAIL_SMTP_USER = CONF_PREFIX + "smtp.username"; @@ -186,13 +186,13 @@ public void email(String[] to, String[] cc, String[] bcc, String subject, String // Get mailing server details. String smtpHost = ConfigurationService.get(EMAIL_SMTP_HOST); Integer smtpPortInt = ConfigurationService.getInt(EMAIL_SMTP_PORT); - Integer smtpSocketPortInt = ConfigurationService.getInt(EMAIL_SMTP_SOCKET_PORT); + Integer smtpSocketPortInt = ConfigurationService.getInt(EMAIL_SMTP_FACTORY_SOCKET_PORT); Boolean smtpAuthBool = ConfigurationService.getBoolean(EMAIL_SMTP_AUTH); String smtpUser = ConfigurationService.get(EMAIL_SMTP_USER); String smtpPassword = ConfigurationService.getPassword(EMAIL_SMTP_PASS, ""); Boolean smtpStarttlsBool = ConfigurationService.getBoolean(EMAIL_SMTP_STARTTLS); - String smtpSocketClass = ConfigurationService.get(EMAIL_SMTP_SOCKET); - Boolean smtpSocketFallbackBool = ConfigurationService.getBoolean(EMAIL_SMTP_SOCKET_FALLBACK); + String smtpSocketClass = ConfigurationService.get(SMTP_SOCKET_FACTORY_CLASS); + Boolean smtpSocketFallbackBool = ConfigurationService.getBoolean(EMAIL_SMTP_FACTORY_SOCKET_FALLBACK); String fromAddr = ConfigurationService.get(EMAIL_SMTP_FROM); Integer timeoutMillisInt = ConfigurationService.getInt(EMAIL_SMTP_SOCKET_TIMEOUT_MS); @@ -201,6 +201,7 @@ public void email(String[] to, String[] cc, String[] bcc, String subject, String properties.setProperty("mail.smtp.port", smtpPortInt.toString()); properties.setProperty("mail.smtp.auth", smtpAuthBool.toString()); properties.setProperty("mail.smtp.starttls.enable", smtpStarttlsBool.toString()); + properties.setProperty("mail.smtp.socketFactory.class", smtpSocketClass); properties.setProperty("mail.smtp.socketFactory.port", smtpSocketPortInt.toString()); properties.setProperty("mail.smtp.socketFactory.fallback", smtpSocketFallbackBool.toString()); From 90ca85cb1275b5a900a682c0ad894ab6c691d3fe Mon Sep 17 00:00:00 2001 From: LiuXiaoYang Date: Tue, 19 Jul 2022 12:14:40 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/apache/oozie/action/email/EmailActionExecutor.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/apache/oozie/action/email/EmailActionExecutor.java b/core/src/main/java/org/apache/oozie/action/email/EmailActionExecutor.java index 76aca413d..0750b4930 100644 --- a/core/src/main/java/org/apache/oozie/action/email/EmailActionExecutor.java +++ b/core/src/main/java/org/apache/oozie/action/email/EmailActionExecutor.java @@ -71,7 +71,7 @@ public class EmailActionExecutor extends ActionExecutor { public static final String EMAIL_SMTP_HOST = CONF_PREFIX + "smtp.host"; public static final String SMTP_SOCKET_FACTORY_CLASS = CONF_PREFIX + "smtp.socketFactory.class"; public static final String EMAIL_SMTP_FACTORY_SOCKET_PORT = CONF_PREFIX + "smtp.socketFactory.port"; - public static final String EMAIL_SMTP_FACTORY_SOCKET_FALLBACK = CONF_PREFIX + "smtp.socketFactory.fallback"; + public static final String EMAIL_SMTP_SOCKET_FACTORY_FALLBACK = CONF_PREFIX + "smtp.socketFactory.fallback"; public static final String EMAIL_SMTP_PORT = CONF_PREFIX + "smtp.port"; public static final String EMAIL_SMTP_AUTH = CONF_PREFIX + "smtp.auth"; public static final String EMAIL_SMTP_USER = CONF_PREFIX + "smtp.username"; @@ -192,7 +192,7 @@ public void email(String[] to, String[] cc, String[] bcc, String subject, String String smtpPassword = ConfigurationService.getPassword(EMAIL_SMTP_PASS, ""); Boolean smtpStarttlsBool = ConfigurationService.getBoolean(EMAIL_SMTP_STARTTLS); String smtpSocketClass = ConfigurationService.get(SMTP_SOCKET_FACTORY_CLASS); - Boolean smtpSocketFallbackBool = ConfigurationService.getBoolean(EMAIL_SMTP_FACTORY_SOCKET_FALLBACK); + Boolean smtpSocketFallbackBool = ConfigurationService.getBoolean(EMAIL_SMTP_SOCKET_FACTORY_FALLBACK); String fromAddr = ConfigurationService.get(EMAIL_SMTP_FROM); Integer timeoutMillisInt = ConfigurationService.getInt(EMAIL_SMTP_SOCKET_TIMEOUT_MS); From d29c5a07851117353b4da5383b0b1a75aed1247c Mon Sep 17 00:00:00 2001 From: LiuXiaoYang Date: Fri, 19 Aug 2022 14:13:51 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/apache/oozie/action/email/EmailActionExecutor.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/apache/oozie/action/email/EmailActionExecutor.java b/core/src/main/java/org/apache/oozie/action/email/EmailActionExecutor.java index 0750b4930..e196c14ea 100644 --- a/core/src/main/java/org/apache/oozie/action/email/EmailActionExecutor.java +++ b/core/src/main/java/org/apache/oozie/action/email/EmailActionExecutor.java @@ -186,15 +186,15 @@ public void email(String[] to, String[] cc, String[] bcc, String subject, String // Get mailing server details. String smtpHost = ConfigurationService.get(EMAIL_SMTP_HOST); Integer smtpPortInt = ConfigurationService.getInt(EMAIL_SMTP_PORT); - Integer smtpSocketPortInt = ConfigurationService.getInt(EMAIL_SMTP_FACTORY_SOCKET_PORT); Boolean smtpAuthBool = ConfigurationService.getBoolean(EMAIL_SMTP_AUTH); String smtpUser = ConfigurationService.get(EMAIL_SMTP_USER); String smtpPassword = ConfigurationService.getPassword(EMAIL_SMTP_PASS, ""); Boolean smtpStarttlsBool = ConfigurationService.getBoolean(EMAIL_SMTP_STARTTLS); - String smtpSocketClass = ConfigurationService.get(SMTP_SOCKET_FACTORY_CLASS); - Boolean smtpSocketFallbackBool = ConfigurationService.getBoolean(EMAIL_SMTP_SOCKET_FACTORY_FALLBACK); String fromAddr = ConfigurationService.get(EMAIL_SMTP_FROM); Integer timeoutMillisInt = ConfigurationService.getInt(EMAIL_SMTP_SOCKET_TIMEOUT_MS); + Integer smtpSocketPortInt = ConfigurationService.getInt(EMAIL_SMTP_FACTORY_SOCKET_PORT); + String smtpSocketClass = ConfigurationService.get(SMTP_SOCKET_FACTORY_CLASS); + Boolean smtpSocketFallbackBool = ConfigurationService.getBoolean(EMAIL_SMTP_SOCKET_FACTORY_FALLBACK); Properties properties = new Properties(); properties.setProperty("mail.smtp.host", smtpHost);