You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by jb...@apache.org on 2017/07/17 14:34:33 UTC

[1/2] activemq-artemis git commit: This closes #1402

Repository: activemq-artemis
Updated Branches:
  refs/heads/master e513f0e68 -> 3f924777f


This closes #1402


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/3f924777
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/3f924777
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/3f924777

Branch: refs/heads/master
Commit: 3f924777fa744006ca18a8fcaf8a149d4105a905
Parents: e513f0e 28087ad
Author: Justin Bertram <jb...@apache.org>
Authored: Mon Jul 17 10:34:06 2017 -0400
Committer: Justin Bertram <jb...@apache.org>
Committed: Mon Jul 17 10:34:06 2017 -0400

----------------------------------------------------------------------
 .../artemis/core/server/NetworkHealthCheck.java | 24 +++---
 .../artemis/logs/ActiveMQUtilLogger.java        | 86 ++++++++++++++++++++
 .../apache/activemq/artemis/utils/Base64.java   |  7 +-
 .../apache/activemq/artemis/utils/FileUtil.java |  8 +-
 4 files changed, 105 insertions(+), 20 deletions(-)
----------------------------------------------------------------------



[2/2] activemq-artemis git commit: [ARTEMIS-1293] Log messages without prefixed id code in artemis-commons

Posted by jb...@apache.org.
[ARTEMIS-1293] Log messages without prefixed id code in artemis-commons


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/28087ad4
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/28087ad4
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/28087ad4

Branch: refs/heads/master
Commit: 28087ad4afe96e56d51b1851287b4529d7f745fc
Parents: e513f0e
Author: Dmitrii Tikhomirov <dt...@redhat.com>
Authored: Mon Jul 17 14:38:08 2017 +0200
Committer: Justin Bertram <jb...@apache.org>
Committed: Mon Jul 17 10:34:06 2017 -0400

----------------------------------------------------------------------
 .../artemis/core/server/NetworkHealthCheck.java | 24 +++---
 .../artemis/logs/ActiveMQUtilLogger.java        | 86 ++++++++++++++++++++
 .../apache/activemq/artemis/utils/Base64.java   |  7 +-
 .../apache/activemq/artemis/utils/FileUtil.java |  8 +-
 4 files changed, 105 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/28087ad4/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/NetworkHealthCheck.java
----------------------------------------------------------------------
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/NetworkHealthCheck.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/NetworkHealthCheck.java
index eef79a1..432c62a 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/NetworkHealthCheck.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/NetworkHealthCheck.java
@@ -84,7 +84,7 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
             netToUse = null;
          }
       } catch (Exception e) {
-         logger.warn(e.getMessage(), e);
+         ActiveMQUtilLogger.LOGGER.failedToSetNIC(e, nicName == null ? " " : nicName);
          netToUse = null;
       }
 
@@ -126,7 +126,7 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
                try {
                   this.addAddress(InetAddress.getByName(address.trim()));
                } catch (Exception e) {
-                  logger.warn(e.getMessage(), e);
+                  ActiveMQUtilLogger.LOGGER.failedToParseAddressList(e, addressList);
                }
             }
          }
@@ -144,7 +144,7 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
                try {
                   this.addURL(new URL(address.trim()));
                } catch (Exception e) {
-                  logger.warn(e.getMessage(), e);
+                  ActiveMQUtilLogger.LOGGER.failedToParseUrlList(e, addressList);
                }
             }
          }
@@ -203,7 +203,7 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
 
    public NetworkHealthCheck addAddress(InetAddress address) {
       if (!check(address)) {
-         logger.warn("Ping Address " + address + " wasn't reacheable");
+         ActiveMQUtilLogger.LOGGER.addressWasntReacheable(address.toString());
       }
 
       if (!ignoreLoopback && address.isLoopbackAddress()) {
@@ -227,7 +227,7 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
 
    public NetworkHealthCheck addURL(URL url) {
       if (!check(url)) {
-         logger.warn("Ping url " + url + " wasn't reacheable");
+         ActiveMQUtilLogger.LOGGER.urlWasntReacheable(url.toString());
       }
       urls.add(url);
       checkStart();
@@ -276,10 +276,10 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
          for (ActiveMQComponent component : componentList) {
             if (!component.isStarted()) {
                try {
-                  logger.info("Network is healthy, starting service " + component);
+                  ActiveMQUtilLogger.LOGGER.startingService(component.toString());
                   component.start();
                } catch (Exception e) {
-                  logger.warn("Error starting component " + component, e);
+                  ActiveMQUtilLogger.LOGGER.errorStartingComponent(e, component.toString());
                }
             }
          }
@@ -287,10 +287,10 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
          for (ActiveMQComponent component : componentList) {
             if (component.isStarted()) {
                try {
-                  logger.info("Network is unhealthy, stopping service " + component);
+                  ActiveMQUtilLogger.LOGGER.stoppingService(component.toString());
                   component.stop();
                } catch (Exception e) {
-                  logger.warn("Error stopping component " + component, e);
+                  ActiveMQUtilLogger.LOGGER.errorStoppingComponent(e, component.toString());
                }
             }
          }
@@ -332,7 +332,7 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
             return purePing(address);
          }
       } catch (Exception e) {
-         logger.warn(e.getMessage(), e);
+         ActiveMQUtilLogger.LOGGER.failedToCheckAddress(e, address == null ? " " : address.toString());
          return false;
       }
    }
@@ -378,7 +378,7 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
       String inputLine;
       while ((inputLine = reader.readLine()) != null) {
          if (error) {
-            logger.warn(inputLine);
+            ActiveMQUtilLogger.LOGGER.failedToReadFromStream(inputLine == null ? " " : inputLine);
          } else {
             logger.trace(inputLine);
          }
@@ -395,7 +395,7 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
          is.close();
          return true;
       } catch (Exception e) {
-         logger.warn(e.getMessage(), e);
+         ActiveMQUtilLogger.LOGGER.failedToCheckURL(e, url == null ? " " : url.toString());
          return false;
       }
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/28087ad4/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/ActiveMQUtilLogger.java
----------------------------------------------------------------------
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/ActiveMQUtilLogger.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/ActiveMQUtilLogger.java
index ab285f9..502daff 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/ActiveMQUtilLogger.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/logs/ActiveMQUtilLogger.java
@@ -18,6 +18,7 @@ package org.apache.activemq.artemis.logs;
 
 import org.jboss.logging.BasicLogger;
 import org.jboss.logging.Logger;
+import org.jboss.logging.annotations.Cause;
 import org.jboss.logging.annotations.LogMessage;
 import org.jboss.logging.annotations.Message;
 import org.jboss.logging.annotations.MessageLogger;
@@ -44,6 +45,16 @@ public interface ActiveMQUtilLogger extends BasicLogger {
     */
    ActiveMQUtilLogger LOGGER = Logger.getMessageLogger(ActiveMQUtilLogger.class, ActiveMQUtilLogger.class.getPackage().getName());
 
+   @LogMessage(level = Logger.Level.INFO)
+   @Message(id = 201000, value = "Network is healthy, starting service {0}",
+      format = Message.Format.MESSAGE_FORMAT)
+   void startingService(String component);
+
+   @LogMessage(level = Logger.Level.INFO)
+   @Message(id = 201001, value = "Network is unhealthy, stopping service {0}",
+      format = Message.Format.MESSAGE_FORMAT)
+   void stoppingService(String component);
+
    @LogMessage(level = Logger.Level.WARN)
    @Message(id = 202000, value = "Missing privileges to set Thread Context Class Loader on Thread Factory. Using current Thread Context Class Loader",
       format = Message.Format.MESSAGE_FORMAT)
@@ -53,4 +64,79 @@ public interface ActiveMQUtilLogger extends BasicLogger {
    @Message(id = 202001, value = "{0} is a loopback address and will be discarded.",
       format = Message.Format.MESSAGE_FORMAT)
    void addressloopback(String address);
+
+   @LogMessage(level = Logger.Level.WARN)
+   @Message(id = 202002, value = "Ping Address {0} wasn't reacheable.",
+      format = Message.Format.MESSAGE_FORMAT)
+   void addressWasntReacheable(String address);
+
+   @LogMessage(level = Logger.Level.WARN)
+   @Message(id = 202003, value = "Ping Url {0} wasn't reacheable.",
+      format = Message.Format.MESSAGE_FORMAT)
+   void urlWasntReacheable(String url);
+
+   @LogMessage(level = Logger.Level.WARN)
+   @Message(id = 202004, value = "Error starting component {0} ",
+      format = Message.Format.MESSAGE_FORMAT)
+   void errorStartingComponent(@Cause Exception e, String component);
+
+   @LogMessage(level = Logger.Level.WARN)
+   @Message(id = 202005, value = "Error stopping component {0} ",
+      format = Message.Format.MESSAGE_FORMAT)
+   void errorStoppingComponent(@Cause Exception e, String component);
+
+   @LogMessage(level = Logger.Level.WARN)
+   @Message(id = 202006, value = "Failed to check Url {0}.",
+      format = Message.Format.MESSAGE_FORMAT)
+   void failedToCheckURL(@Cause Exception e, String url);
+
+   @LogMessage(level = Logger.Level.WARN)
+   @Message(id = 202007, value = "Failed to check Address {0}.",
+      format = Message.Format.MESSAGE_FORMAT)
+   void failedToCheckAddress(@Cause Exception e, String address);
+
+   @LogMessage(level = Logger.Level.WARN)
+   @Message(id = 202008, value = "Failed to check Address list {0}.",
+      format = Message.Format.MESSAGE_FORMAT)
+   void failedToParseAddressList(@Cause Exception e, String addressList);
+
+   @LogMessage(level = Logger.Level.WARN)
+   @Message(id = 202009, value = "Failed to check Url list {0}.",
+      format = Message.Format.MESSAGE_FORMAT)
+   void failedToParseUrlList(@Cause Exception e, String urlList);
+
+   @LogMessage(level = Logger.Level.WARN)
+   @Message(id = 202010, value = "Failed to set NIC {0}.",
+      format = Message.Format.MESSAGE_FORMAT)
+   void failedToSetNIC(@Cause Exception e, String nic);
+
+   @LogMessage(level = Logger.Level.WARN)
+   @Message(id = 202011, value = "Failed to read from stream {0}.",
+      format = Message.Format.MESSAGE_FORMAT)
+   void failedToReadFromStream(String stream);
+
+   @LogMessage(level = Logger.Level.WARN)
+   @Message(id = 202012, value = "Object cannot be serialized.",
+      format = Message.Format.MESSAGE_FORMAT)
+   void failedToSerializeObject(@Cause Exception e);
+
+   @LogMessage(level = Logger.Level.WARN)
+   @Message(id = 202013, value = "Unable to deserialize object.",
+      format = Message.Format.MESSAGE_FORMAT)
+   void failedToDeserializeObject(@Cause Exception e);
+
+   @LogMessage(level = Logger.Level.WARN)
+   @Message(id = 202014, value = "Unable to encode byte array into Base64 notation.",
+      format = Message.Format.MESSAGE_FORMAT)
+   void failedToEncodeByteArrayToBase64Notation(@Cause Exception e);
+
+   @LogMessage(level = Logger.Level.WARN)
+   @Message(id = 202015, value = "Failed to clean up file {0}",
+      format = Message.Format.MESSAGE_FORMAT)
+   void failedToCleanupFile(String file);
+
+   @LogMessage(level = Logger.Level.WARN)
+   @Message(id = 202016, value = "Could not list files to clean up in {0}",
+      format = Message.Format.MESSAGE_FORMAT)
+   void failedListFilesToCleanup(String path);
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/28087ad4/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/Base64.java
----------------------------------------------------------------------
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/Base64.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/Base64.java
index 7b7cac4..75e9d98 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/Base64.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/Base64.java
@@ -10,6 +10,7 @@
  */
 package org.apache.activemq.artemis.utils;
 
+import org.apache.activemq.artemis.logs.ActiveMQUtilLogger;
 import org.jboss.logging.Logger;
 
 import java.nio.charset.Charset;
@@ -543,7 +544,7 @@ public class Base64 {
 
          oos.writeObject(serializableObject);
       } catch (java.io.IOException e) {
-         logger.warn("Object cannot be serialized", e.getMessage(), e);
+         ActiveMQUtilLogger.LOGGER.failedToSerializeObject(e);
          return null;
       } finally {
          try {
@@ -661,7 +662,7 @@ public class Base64 {
             gzos.write(source, off, len);
             gzos.close();
          } catch (java.io.IOException e) {
-            logger.warn("Unable to encode byte array into Base64 notation", e.getMessage(), e);
+            ActiveMQUtilLogger.LOGGER.failedToEncodeByteArrayToBase64Notation(e);
             return null;
          } finally {
             try {
@@ -950,7 +951,7 @@ public class Base64 {
 
          obj = ois.readObject();
       } catch (java.io.IOException | java.lang.ClassNotFoundException e) {
-         logger.warn("Unable to deserialize object", e.getMessage(), e);
+         ActiveMQUtilLogger.LOGGER.failedToDeserializeObject(e);
          obj = null;
       } finally {
          try {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/28087ad4/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/FileUtil.java
----------------------------------------------------------------------
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/FileUtil.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/FileUtil.java
index 00a0e30..62d8877 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/FileUtil.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/FileUtil.java
@@ -23,7 +23,7 @@ import java.nio.file.Files;
 import java.util.Arrays;
 import java.util.HashSet;
 
-import org.jboss.logging.Logger;
+import org.apache.activemq.artemis.logs.ActiveMQUtilLogger;
 
 import static java.nio.file.attribute.PosixFilePermission.GROUP_EXECUTE;
 import static java.nio.file.attribute.PosixFilePermission.GROUP_READ;
@@ -36,8 +36,6 @@ import static java.nio.file.attribute.PosixFilePermission.OWNER_WRITE;
 
 public class FileUtil {
 
-   private static final Logger logger = Logger.getLogger(FileUtil.class);
-
    public static void makeExec(File file) throws IOException {
       try {
          Files.setPosixFilePermissions(file.toPath(), new HashSet<>(Arrays.asList(OWNER_READ, OWNER_WRITE, OWNER_EXECUTE, GROUP_READ, GROUP_WRITE, GROUP_EXECUTE, OTHERS_READ, OTHERS_EXECUTE)));
@@ -61,12 +59,12 @@ public class FileUtil {
          }
 
          if (files == null) {
-            logger.warn("Could not list files to clean up in: " + directory.getAbsolutePath());
+            ActiveMQUtilLogger.LOGGER.failedListFilesToCleanup(directory.getAbsolutePath());
          } else {
             for (String file : files) {
                File f = new File(directory, file);
                if (!deleteDirectory(f)) {
-                  logger.warn("Failed to clean up file: " + f.getAbsolutePath());
+                  ActiveMQUtilLogger.LOGGER.failedToCleanupFile(f.getAbsolutePath());
                }
             }
          }