From bef3864c722d346cc8698417a13a7c40eac0c2ef Mon Sep 17 00:00:00 2001 From: Dmitrii Tikhomirov Date: Thu, 27 Jul 2017 14:12:31 +0200 Subject: [PATCH] [ARTEMIS-1311] Log messages without prefixed id code in artemis-core-client --- .../api/core/UDPBroadcastEndpointFactory.java | 6 +- .../api/core/client/ActiveMQClient.java | 4 +- .../core/client/ActiveMQClientLogger.java | 82 +++++++++++++++++++ .../core/client/impl/ClientConsumerImpl.java | 4 +- .../client/impl/ClientSessionFactoryImpl.java | 4 +- .../artemis/core/cluster/DiscoveryGroup.java | 4 +- .../core/impl/RemotingConnectionImpl.java | 2 +- .../core/remoting/impl/netty/Epoll.java | 5 +- .../remoting/impl/netty/NettyConnection.java | 4 +- .../remoting/impl/netty/NettyConnector.java | 2 +- .../activemq/artemis/utils/VersionLoader.java | 4 +- 11 files changed, 100 insertions(+), 21 deletions(-) diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/UDPBroadcastEndpointFactory.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/UDPBroadcastEndpointFactory.java index c257ade482..c447a8dfc3 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/UDPBroadcastEndpointFactory.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/UDPBroadcastEndpointFactory.java @@ -155,7 +155,7 @@ public final class UDPBroadcastEndpointFactory implements BroadcastEndpointFacto continue; } catch (IOException e) { if (open) { - ActiveMQClientLogger.LOGGER.warn(this + " getting exception when receiving broadcasting.", e); + ActiveMQClientLogger.LOGGER.unableToReceiveBroadcast(e, this.toString()); } } break; @@ -262,7 +262,7 @@ public final class UDPBroadcastEndpointFactory implements BroadcastEndpointFacto } return tmp; } catch (Throwable t) { - ActiveMQClientLogger.LOGGER.warn(t); + ActiveMQClientLogger.LOGGER.unableToGetProperty(t); return defaultValue; } } @@ -273,7 +273,7 @@ public final class UDPBroadcastEndpointFactory implements BroadcastEndpointFacto try { return Integer.parseInt(value); } catch (Throwable t) { - ActiveMQClientLogger.LOGGER.warn(t.getMessage(), t); + ActiveMQClientLogger.LOGGER.unableToParseValue(t); return Integer.parseInt(defaultValue); } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/ActiveMQClient.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/ActiveMQClient.java index bfb86d0a3c..8fba7475e0 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/ActiveMQClient.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/ActiveMQClient.java @@ -165,7 +165,7 @@ public final class ActiveMQClient { try { if (!globalThreadPool.awaitTermination(time, unit)) { globalThreadPool.shutdownNow(); - ActiveMQClientLogger.LOGGER.warn("Couldn't finish the client globalThreadPool in less than 10 seconds, interrupting it now"); + ActiveMQClientLogger.LOGGER.unableToProcessGlobalThreadPoolIn10Sec(); } } catch (InterruptedException e) { throw new ActiveMQInterruptedException(e); @@ -179,7 +179,7 @@ public final class ActiveMQClient { try { if (!globalScheduledThreadPool.awaitTermination(time, unit)) { globalScheduledThreadPool.shutdownNow(); - ActiveMQClientLogger.LOGGER.warn("Couldn't finish the client scheduled in less than 10 seconds, interrupting it now"); + ActiveMQClientLogger.LOGGER.unableToProcessScheduledlIn10Sec(); } } catch (InterruptedException e) { throw new ActiveMQInterruptedException(e); diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientLogger.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientLogger.java index 405ed07a93..6fbb911fa1 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientLogger.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientLogger.java @@ -27,6 +27,8 @@ import org.jboss.logging.annotations.Message; import org.jboss.logging.annotations.MessageLogger; import org.w3c.dom.Node; +import java.net.UnknownHostException; + /** * Logger Code 21 *

@@ -320,6 +322,76 @@ public interface ActiveMQClientLogger extends BasicLogger { format = Message.Format.MESSAGE_FORMAT) void unableToGetMessage(@Cause Exception e); + @LogMessage(level = Logger.Level.WARN) + @Message(id = 212059, value = "Failed to clean up: {0} ", + format = Message.Format.MESSAGE_FORMAT) + void failedCleaningUp(String target); + + @LogMessage(level = Logger.Level.WARN) + @Message(id = 212060, value = "Unexpected null data received from DiscoveryEndpoint ", + format = Message.Format.MESSAGE_FORMAT) + void unexpectedNullDataReceived(); + + @LogMessage(level = Logger.Level.WARN) + @Message(id = 212061, value = "Failed to perform force close ", + format = Message.Format.MESSAGE_FORMAT) + void failedForceClose(@Cause Throwable e); + + @LogMessage(level = Logger.Level.WARN) + @Message(id = 212062, value = "Failed to perform post actions on message processing ", + format = Message.Format.MESSAGE_FORMAT) + void failedPerformPostActionsOnMessage(@Cause Exception e); + + @LogMessage(level = Logger.Level.WARN) + @Message(id = 212063, value = "Unable to handle connection failure ", + format = Message.Format.MESSAGE_FORMAT) + void unableToHandleConnectionFailure(@Cause Throwable e); + + @LogMessage(level = Logger.Level.WARN) + @Message(id = 212064, value = "Unable to receive cluster topology ", + format = Message.Format.MESSAGE_FORMAT) + void unableToReceiveClusterTopology(@Cause Throwable e); + + @LogMessage(level = Logger.Level.WARN) + @Message(id = 212065, value = "{0} getting exception when receiving broadcasting ", + format = Message.Format.MESSAGE_FORMAT) + void unableToReceiveBroadcast(@Cause Exception e, String target); + + @LogMessage(level = Logger.Level.WARN) + @Message(id = 212066, value = "failed to parse int property ", + format = Message.Format.MESSAGE_FORMAT) + void unableToParseValue(@Cause Throwable e); + + @LogMessage(level = Logger.Level.WARN) + @Message(id = 212067, value = "failed to get system property ", + format = Message.Format.MESSAGE_FORMAT) + void unableToGetProperty(@Cause Throwable e); + + @LogMessage(level = Logger.Level.WARN) + @Message(id = 212068, value = "Couldn't finish the client globalThreadPool in less than 10 seconds, interrupting it now ", + format = Message.Format.MESSAGE_FORMAT) + void unableToProcessGlobalThreadPoolIn10Sec(); + + @LogMessage(level = Logger.Level.WARN) + @Message(id = 212069, value = "Couldn't finish the client scheduled in less than 10 seconds, interrupting it now ", + format = Message.Format.MESSAGE_FORMAT) + void unableToProcessScheduledlIn10Sec(); + + @LogMessage(level = Logger.Level.WARN) + @Message(id = 212070, value = "Unable to initialize VersionLoader ", + format = Message.Format.MESSAGE_FORMAT) + void unableToInitVersionLoader(@Cause Throwable e); + + @LogMessage(level = Logger.Level.WARN) + @Message(id = 212071, value = "Unable to check Epoll availability ", + format = Message.Format.MESSAGE_FORMAT) + void unableToCheckEpollAvailability(@Cause Throwable e); + + @LogMessage(level = Logger.Level.WARN) + @Message(id = 212072, value = "Failed to change channel state to ReadyForWriting ", + format = Message.Format.MESSAGE_FORMAT) + void failedToSetChannelReadyForWriting(@Cause Throwable e); + @LogMessage(level = Logger.Level.ERROR) @Message(id = 214000, value = "Failed to call onMessage", format = Message.Format.MESSAGE_FORMAT) void onMessageError(@Cause Throwable e); @@ -454,4 +526,14 @@ public interface ActiveMQClientLogger extends BasicLogger { @LogMessage(level = Logger.Level.ERROR) @Message(id = 214031, value = "Failed to decode buffer, disconnect immediately.", format = Message.Format.MESSAGE_FORMAT) void disconnectOnErrorDecoding(@Cause Throwable cause); + + @LogMessage(level = Logger.Level.ERROR) + @Message(id = 214032, value = "Unable to initialize VersionLoader ", + format = Message.Format.MESSAGE_FORMAT) + void unableToInitVersionLoaderError(@Cause Throwable e); + + @LogMessage(level = Logger.Level.ERROR) + @Message(id = 214033, value = "Cannot resolve host ", + format = Message.Format.MESSAGE_FORMAT) + void unableToResolveHost(@Cause UnknownHostException e); } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientConsumerImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientConsumerImpl.java index 0ff971dcaa..4b48caac43 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientConsumerImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientConsumerImpl.java @@ -470,7 +470,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { try { doCleanUp(false); } catch (ActiveMQException e) { - ActiveMQClientLogger.LOGGER.warn("problem cleaning up: " + this); + ActiveMQClientLogger.LOGGER.failedCleaningUp(this.toString()); } } @@ -1005,7 +1005,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { } }); } catch (Exception e) { - ActiveMQClientLogger.LOGGER.warn(e.getMessage(), e); + ActiveMQClientLogger.LOGGER.failedPerformPostActionsOnMessage(e); } onMessageThread = null; diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionFactoryImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionFactoryImpl.java index cc26b7d281..e8ac8f8d46 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionFactoryImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionFactoryImpl.java @@ -474,7 +474,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C return latchFinalTopology.await(timeout, unit); } catch (InterruptedException e) { Thread.currentThread().interrupt(); - ActiveMQClientLogger.LOGGER.warn(e.getMessage(), e); + ActiveMQClientLogger.LOGGER.unableToReceiveClusterTopology(e); return false; } } @@ -506,7 +506,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C // this is just a debug, since an interrupt is an expected event (in case of a shutdown) logger.debug(e1.getMessage(), e1); } catch (Throwable t) { - logger.warn(t.getMessage(), t); + ActiveMQClientLogger.LOGGER.unableToHandleConnectionFailure(t); //for anything else just close so clients are un blocked close(); throw t; diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/cluster/DiscoveryGroup.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/cluster/DiscoveryGroup.java index 282932dbad..07e26b09eb 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/cluster/DiscoveryGroup.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/cluster/DiscoveryGroup.java @@ -255,9 +255,7 @@ public final class DiscoveryGroup implements ActiveMQComponent { data = endpoint.receiveBroadcast(); if (data == null) { if (started) { - // This is totally unexpected, so I'm not even bothering on creating - // a log entry for that - ActiveMQClientLogger.LOGGER.warn("Unexpected null data received from DiscoveryEndpoint"); + ActiveMQClientLogger.LOGGER.unexpectedNullDataReceived(); } break; } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/RemotingConnectionImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/RemotingConnectionImpl.java index e0837e9ef8..28bd2f696d 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/RemotingConnectionImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/RemotingConnectionImpl.java @@ -201,7 +201,7 @@ public class RemotingConnectionImpl extends AbstractRemotingConnection implement try { transportConnection.forceClose(); } catch (Throwable e) { - ActiveMQClientLogger.LOGGER.warn(e.getMessage(), e); + ActiveMQClientLogger.LOGGER.failedForceClose(e); } // Then call the listeners diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/Epoll.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/Epoll.java index 40612d40f6..8553d7f8b6 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/Epoll.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/Epoll.java @@ -17,15 +17,14 @@ package org.apache.activemq.artemis.core.remoting.impl.netty; +import org.apache.activemq.artemis.core.client.ActiveMQClientLogger; import org.apache.activemq.artemis.utils.Env; -import org.jboss.logging.Logger; /** * Tells if {@code netty-transport-native-epoll} is supported. */ public final class Epoll { - private static final Logger logger = Logger.getLogger(Epoll.class); private static final boolean IS_AVAILABLE_EPOLL = isIsAvailableEpoll(); private static boolean isIsAvailableEpoll() { @@ -36,7 +35,7 @@ public final class Epoll { return false; } } catch (Throwable e) { - logger.warn(e.getMessage(), e); + ActiveMQClientLogger.LOGGER.unableToCheckEpollAvailability(e); return false; } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java index 384ca5e863..10dc553413 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java @@ -194,7 +194,7 @@ public class NettyConnection implements Connection { final ReadyListener readyListener = readyToCall.get(i); readyListener.readyForWriting(); } catch (Throwable logOnly) { - ActiveMQClientLogger.LOGGER.warn(logOnly.getMessage(), logOnly); + ActiveMQClientLogger.LOGGER.failedToSetChannelReadyForWriting(logOnly); } } } finally { @@ -208,7 +208,7 @@ public class NettyConnection implements Connection { try { channel.close(); } catch (Throwable e) { - ActiveMQClientLogger.LOGGER.warn(e.getMessage(), e); + ActiveMQClientLogger.LOGGER.failedForceClose(e); } } } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java index 20431f012c..18824907fb 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java @@ -1111,7 +1111,7 @@ public class NettyConnector extends AbstractConnector { result = ip1.equals(ip2); } catch (UnknownHostException e) { - ActiveMQClientLogger.LOGGER.error("Cannot resolve host", e); + ActiveMQClientLogger.LOGGER.unableToResolveHost(e); } return result; diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/VersionLoader.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/VersionLoader.java index 22d274d84f..39509a340b 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/VersionLoader.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/VersionLoader.java @@ -57,7 +57,7 @@ public final class VersionLoader { } }); } catch (Throwable e) { - ActiveMQClientLogger.LOGGER.warn(e.getMessage(), e); + ActiveMQClientLogger.LOGGER.unableToInitVersionLoader(e); PROP_FILE_NAME = null; } @@ -68,7 +68,7 @@ public final class VersionLoader { VersionLoader.versions = VersionLoader.load(); } catch (Throwable e) { VersionLoader.versions = null; - ActiveMQClientLogger.LOGGER.error(e.getMessage(), e); + ActiveMQClientLogger.LOGGER.unableToInitVersionLoaderError(e); } }