Repository: oozie
Updated Branches:
  refs/heads/master 471659fa0 -> 8cf8a78d1


OOZIE-3397 Improve logging in NotificationXCommand (kmarton)


Project: http://git-wip-us.apache.org/repos/asf/oozie/repo
Commit: http://git-wip-us.apache.org/repos/asf/oozie/commit/8cf8a78d
Tree: http://git-wip-us.apache.org/repos/asf/oozie/tree/8cf8a78d
Diff: http://git-wip-us.apache.org/repos/asf/oozie/diff/8cf8a78d

Branch: refs/heads/master
Commit: 8cf8a78d14e579b091a95c510fe8c61db5c46876
Parents: 471659f
Author: Julia Kinga Marton <[email protected]>
Authored: Thu Dec 6 10:07:02 2018 +0100
Committer: Julia Kinga Marton <[email protected]>
Committed: Thu Dec 6 10:07:02 2018 +0100

----------------------------------------------------------------------
 .../oozie/command/NotificationXCommand.java      | 19 +++++++++++++++----
 release-log.txt                                  |  1 +
 2 files changed, 16 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/oozie/blob/8cf8a78d/core/src/main/java/org/apache/oozie/command/NotificationXCommand.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/oozie/command/NotificationXCommand.java 
b/core/src/main/java/org/apache/oozie/command/NotificationXCommand.java
index 68359aa..1258e38 100644
--- a/core/src/main/java/org/apache/oozie/command/NotificationXCommand.java
+++ b/core/src/main/java/org/apache/oozie/command/NotificationXCommand.java
@@ -30,6 +30,7 @@ public abstract class NotificationXCommand extends 
XCommand<Void> {
 
     public static final String NOTIFICATION_URL_CONNECTION_TIMEOUT_KEY = 
"oozie.notification.url.connection.timeout";
     public static final String NOTIFICATION_PROXY_KEY = 
"oozie.notification.proxy";
+    private static final int MAX_RETRIES = 3;
 
     protected int retries = 0;
     protected String jobId;
@@ -92,7 +93,7 @@ public abstract class NotificationXCommand extends 
XCommand<Void> {
     }
 
     protected void handleRetry() {
-        if (retries < 3) {
+        if (retries < MAX_RETRIES) {
             retries++;
             this.resetUsed();
             queue(this, 60 * 1000);
@@ -106,15 +107,25 @@ public abstract class NotificationXCommand extends 
XCommand<Void> {
         if (url != null) {
             Proxy proxy = getProxy(proxyConf);
             try {
+                LOG.debug("Trying to send notification to [{0}] for the [{1}] 
time out of total [{2}]",
+                        url, retries, MAX_RETRIES);
                 URL url = new URL(this.url);
                 HttpURLConnection urlConn = (HttpURLConnection) 
url.openConnection(proxy);
-                urlConn.setConnectTimeout(getTimeOut());
-                urlConn.setReadTimeout(getTimeOut());
-                if (urlConn.getResponseCode() != HttpURLConnection.HTTP_OK) {
+                int timeout = getTimeOut();
+                urlConn.setConnectTimeout(timeout);
+                urlConn.setReadTimeout(timeout);
+                LOG.debug("Setting connection timeout and read timeout to 
[{0}] ms", timeout);
+                int responseCode = urlConn.getResponseCode();
+                if (responseCode != HttpURLConnection.HTTP_OK) {
+                    LOG.warn("Notification sending to URL [{0}] failed. 
response code: [{1}], response message: [{2}]",
+                            this.url, responseCode, 
urlConn.getResponseMessage());
                     handleRetry();
+                } else {
+                    LOG.debug("Notification sent to [{0}]", this.url);
                 }
             }
             catch (IOException ex) {
+                LOG.warn("Notification sending to URL [{0}] failed with 
exception [{1}]", url, ex.getMessage());
                 handleRetry();
             }
         }

http://git-wip-us.apache.org/repos/asf/oozie/blob/8cf8a78d/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index eb00eb4..8d738b5 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -1,5 +1,6 @@
 -- Oozie 5.2.0 release (trunk - unreleased)
 
+OOZIE-3397 Improve logging in NotificationXCommand (kmarton)
 OOZIE-3382 [SSH action] [SSH action] Optimize process streams draining 
(asalamon74 via andras.piros)
 OOZIE-3384 [tests] 
TestWorkflowActionRetryInfoXCommand#testRetryConsoleUrlForked() is flaky 
(asalamon74 via kmarton)
 OOZIE-3120 Upgrade maven-assembly plugin to v.3.1.0 (dionusos via kmarton)

Reply via email to