Hello mooli tayer,

I'd like you to do a code review.  Please visit

    http://gerrit.ovirt.org/24704

to review the following change.

Change subject: tools: notifier: extract MAIL_RETRIES to configuration
......................................................................

tools: notifier: extract MAIL_RETRIES to configuration

Change-Id: I72d4f48c44d0dff70963394b2657a833449812bb
Signed-off-by: Mooli Tayer <[email protected]>
---
M 
backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/transport/smtp/Smtp.java
M packaging/services/ovirt-engine-notifier/ovirt-engine-notifier.conf.in
2 files changed, 9 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/04/24704/1

diff --git 
a/backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/transport/smtp/Smtp.java
 
b/backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/transport/smtp/Smtp.java
index bd6ba09..2fb49aa 100644
--- 
a/backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/transport/smtp/Smtp.java
+++ 
b/backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/transport/smtp/Smtp.java
@@ -49,9 +49,11 @@
     private static final String MAIL_SMTP_ENCRYPTION_NONE = "none";
     private static final String MAIL_SMTP_ENCRYPTION_SSL = "ssl";
     private static final String MAIL_SMTP_ENCRYPTION_TLS = "tls";
+    private static final String MAIL_RETRIES = "MAIL_RETRIES";
     private static final String GENERIC_VALIDATION_MESSAGE = "Check 
configuration file, ";
 
     private static final Logger log = Logger.getLogger(Smtp.class);
+    private int retries;
     private String hostName;
     private boolean isBodyHtml = false;
     private Session session = null;
@@ -70,6 +72,7 @@
             hostName = "localhost";
         }
 
+        retries = props.validateNonNegetive(MAIL_RETRIES);
         isBodyHtml = props.getBoolean(HTML_MESSAGE_FORMAT, false);
         from = props.validateEmail(MAIL_FROM);
         replyTo = props.validateEmail(MAIL_REPLY_TO);
@@ -108,7 +111,8 @@
         // validate mandatory and non empty properties
         props.requireOne(MAIL_SERVER);
         // validate MAIL_PORT
-        props.requireAll(MAIL_PORT);
+        props.requireAll(MAIL_PORT, MAIL_RETRIES);
+        props.validateNonNegetive(MAIL_RETRIES);
         props.validatePort(MAIL_PORT);
 
         // validate MAIL_USER value
@@ -174,7 +178,7 @@
         }
 
         // Attempt additional 3 retries in case of failure
-        for (int i = 0; i < 3 && shouldRetry; ++i) {
+        for (int i = 0; i < retries && shouldRetry; ++i) {
             shouldRetry = false;
             try {
                 // hold the next send attempt for 30 seconds in case of a busy 
mail server
diff --git 
a/packaging/services/ovirt-engine-notifier/ovirt-engine-notifier.conf.in 
b/packaging/services/ovirt-engine-notifier/ovirt-engine-notifier.conf.in
index 202054d..bde9be3 100644
--- a/packaging/services/ovirt-engine-notifier/ovirt-engine-notifier.conf.in
+++ b/packaging/services/ovirt-engine-notifier/ovirt-engine-notifier.conf.in
@@ -100,6 +100,9 @@
 # Specifies 'reply-to' address on sent mail in RFC822 format.
 MAIL_REPLY_TO=
 
+# Amount of times to attempt sending an email before failing.
+MAIL_RETRIES=4
+
 #----------------------------------#
 # Engine Monitoring Configuration: #
 #----------------------------------#


-- 
To view, visit http://gerrit.ovirt.org/24704
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I72d4f48c44d0dff70963394b2657a833449812bb
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.4
Gerrit-Owner: Alon Bar-Lev <[email protected]>
Gerrit-Reviewer: mooli tayer <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to