Updated Branches:
  refs/heads/4.2 db880381d -> 16301ddaa

CLOUDSTACK-4909: Added global configuration parameters for SMTP timeout


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/16301dda
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/16301dda
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/16301dda

Branch: refs/heads/4.2
Commit: 16301ddaadc325c1eaff819276c5130268b6f179
Parents: db88038
Author: Anshul Gangwar <anshul.gang...@citrix.com>
Authored: Tue Oct 22 12:16:35 2013 +0530
Committer: Likitha Shetty <likitha.she...@citrix.com>
Committed: Thu Oct 24 20:09:10 2013 +0530

----------------------------------------------------------------------
 server/src/com/cloud/alert/AlertManagerImpl.java | 19 +++++++++++++------
 server/src/com/cloud/configuration/Config.java   |  5 ++++-
 2 files changed, 17 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/16301dda/server/src/com/cloud/alert/AlertManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/alert/AlertManagerImpl.java 
b/server/src/com/cloud/alert/AlertManagerImpl.java
index 3aa9695..b49a280 100755
--- a/server/src/com/cloud/alert/AlertManagerImpl.java
+++ b/server/src/com/cloud/alert/AlertManagerImpl.java
@@ -153,12 +153,14 @@ public class AlertManagerImpl extends ManagerBase 
implements AlertManager {
         String smtpPassword = configs.get("alert.smtp.password");
         String emailSender = configs.get("alert.email.sender");
         String smtpDebugStr = configs.get("alert.smtp.debug");
+        int smtpTimeout = 
NumbersUtil.parseInt(configs.get("alert.smtp.timeout"), 30000);
+        int smtpConnectionTimeout = 
NumbersUtil.parseInt(configs.get("alert.smtp.connectiontimeout"), 30000);
         boolean smtpDebug = false;
         if (smtpDebugStr != null) {
             smtpDebug = Boolean.parseBoolean(smtpDebugStr);
         }
 
-        _emailAlert = new EmailAlert(emailAddresses, smtpHost, smtpPort, 
useAuth, smtpUsername, smtpPassword, emailSender, smtpDebug);
+        _emailAlert = new EmailAlert(emailAddresses, smtpHost, smtpPort, 
smtpConnectionTimeout, smtpTimeout, useAuth, smtpUsername, smtpPassword, 
emailSender, smtpDebug);
 
 
         String storageCapacityThreshold = 
_configDao.getValue(Config.StorageCapacityThreshold.key());
@@ -775,8 +777,11 @@ public class AlertManagerImpl extends ManagerBase 
implements AlertManager {
         private final String _smtpUsername;
         private final String _smtpPassword;
         private final String _emailSender;
+        private int _smtpTimeout;
+        private int _smtpConnectionTimeout;
 
-        public EmailAlert(String[] recipientList, String smtpHost, int 
smtpPort, boolean smtpUseAuth, final String smtpUsername, final String 
smtpPassword, String emailSender, boolean smtpDebug) {
+        public EmailAlert(String[] recipientList, String smtpHost, int 
smtpPort, int smtpConnectionTimeout, int smtpTimeout, boolean smtpUseAuth, 
final String smtpUsername,
+                final String smtpPassword, String emailSender, boolean 
smtpDebug) {
             if (recipientList != null) {
                 _recipientList = new InternetAddress[recipientList.length];
                 for (int i = 0; i < recipientList.length; i++) {
@@ -794,14 +799,16 @@ public class AlertManagerImpl extends ManagerBase 
implements AlertManager {
             _smtpUsername = smtpUsername;
             _smtpPassword = smtpPassword;
             _emailSender = emailSender;
+            _smtpTimeout = smtpTimeout;
+            _smtpConnectionTimeout = smtpConnectionTimeout;
 
             if (_smtpHost != null) {
                 Properties smtpProps = new Properties();
                 smtpProps.put("mail.smtp.host", smtpHost);
                 smtpProps.put("mail.smtp.port", smtpPort);
                 smtpProps.put("mail.smtp.auth", ""+smtpUseAuth);
-                smtpProps.put("mail.smtp.timeout", 30000);
-                smtpProps.put("mail.smtp.connectiontimeout", 30000);
+                smtpProps.put("mail.smtp.timeout", _smtpTimeout);
+                smtpProps.put("mail.smtp.connectiontimeout", 
_smtpConnectionTimeout);
                 if (smtpUsername != null) {
                     smtpProps.put("mail.smtp.user", smtpUsername);
                 }
@@ -809,8 +816,8 @@ public class AlertManagerImpl extends ManagerBase 
implements AlertManager {
                 smtpProps.put("mail.smtps.host", smtpHost);
                 smtpProps.put("mail.smtps.port", smtpPort);
                 smtpProps.put("mail.smtps.auth", ""+smtpUseAuth);
-                smtpProps.put("mail.smtps.timeout", 30000);
-                smtpProps.put("mail.smtps.connectiontimeout", 30000);
+                smtpProps.put("mail.smtps.timeout", _smtpTimeout);
+                smtpProps.put("mail.smtps.connectiontimeout", 
_smtpConnectionTimeout);
                 if (smtpUsername != null) {
                     smtpProps.put("mail.smtps.user", smtpUsername);
                 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/16301dda/server/src/com/cloud/configuration/Config.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/Config.java 
b/server/src/com/cloud/configuration/Config.java
index cefcdd5..0c78c53 100755
--- a/server/src/com/cloud/configuration/Config.java
+++ b/server/src/com/cloud/configuration/Config.java
@@ -47,6 +47,9 @@ public enum Config {
        AlertSMTPHost("Alert", ManagementServer.class, String.class, 
"alert.smtp.host", null, "SMTP hostname used for sending out email alerts.", 
null),
        AlertSMTPPassword("Secure", ManagementServer.class, String.class, 
"alert.smtp.password", null, "Password for SMTP authentication (applies only if 
alert.smtp.useAuth is true).", null),
        AlertSMTPPort("Alert", ManagementServer.class, Integer.class, 
"alert.smtp.port", "465", "Port the SMTP server is listening on.", null),
+    AlertSMTPConnectionTimeout("Alert", ManagementServer.class, Integer.class, 
"alert.smtp.connectiontimeout", "30000",
+            "Socket connection timeout value in milliseconds. -1 for infinite 
timeout.", null),
+    AlertSMTPTimeout("Alert", ManagementServer.class, Integer.class, 
"alert.smtp.timeout", "30000", "Socket I/O timeout value in milliseconds. -1 
for infinite timeout.", null),
        AlertSMTPUseAuth("Alert", ManagementServer.class, String.class, 
"alert.smtp.useAuth", null, "If true, use SMTP authentication when sending 
emails.", null),
        AlertSMTPUsername("Alert", ManagementServer.class, String.class, 
"alert.smtp.username", null, "Username for SMTP authentication (applies only if 
alert.smtp.useAuth is true).", null),
        AlertWait("Alert", AgentManager.class, Integer.class, "alert.wait", 
null, "Seconds to wait before alerting on a disconnected agent", null),
@@ -86,7 +89,7 @@ public enum Config {
        CreatePrivateTemplateFromSnapshotWait("Storage", UserVmManager.class, 
Integer.class, "create.private.template.from.snapshot.wait", "10800", "In 
second, timeout for CreatePrivateTemplateFromSnapshotCommand", null),
        BackupSnapshotWait(
             "Storage", StorageManager.class, Integer.class, 
"backup.snapshot.wait", "21600", "In second, timeout for 
BackupSnapshotCommand", null),
-    HAStorageMigration("Storage", ManagementServer.class, Boolean.class, 
"enable.ha.storage.migration", "true", "Enable/disable storage migration across 
primary storage during HA", null), 
+    HAStorageMigration("Storage", ManagementServer.class, Boolean.class, 
"enable.ha.storage.migration", "true", "Enable/disable storage migration across 
primary storage during HA", null),
             
        // Network
        NetworkLBHaproxyStatsVisbility("Network", ManagementServer.class, 
String.class, "network.loadbalancer.haproxy.stats.visibility", "global", "Load 
Balancer(haproxy) stats visibilty, the value can be one of the following six 
parameters : global,guest-network,link-local,disabled,all,default", null),

Reply via email to