From ddb90a4423bffd0f268b37fa22e9f574ebb3334c Mon Sep 17 00:00:00 2001 From: Rajith Muditha Attapattu Date: Thu, 8 Mar 2012 20:09:40 +0000 Subject: QPID-3885 Applying a patch by Kevin Conner. For the most part it reduces noise by downgrading most log messages from info to debug. It also adds a if(logger.isDebugEnabled()) to save on any unnecessary (and potentially expensive) string concatenations. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1298555 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/qpid/client/AMQConnection.java | 19 +++++--- .../java/org/apache/qpid/client/AMQSession.java | 52 ++++++++++++---------- .../apache/qpid/client/BasicMessageConsumer.java | 9 ++-- .../apache/qpid/client/BasicMessageProducer.java | 17 ++++--- .../qpid/client/BasicMessageProducer_0_10.java | 2 +- .../qpid/client/BasicMessageProducer_0_8.java | 6 ++- .../client/handler/ClientMethodDispatcherImpl.java | 4 +- .../qpid/client/protocol/AMQProtocolSession.java | 15 +++++-- 8 files changed, 81 insertions(+), 43 deletions(-) (limited to 'qpid/java/client/src') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java index b5a4300bd7..1f61e0d218 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java @@ -308,9 +308,9 @@ public class AMQConnection extends Closeable implements Connection, QueueConnect _delegate = new AMQConnectionDelegate_0_10(this); } - if (_logger.isInfoEnabled()) + if (_logger.isDebugEnabled()) { - _logger.info("Connection:" + connectionURL); + _logger.debug("Connection:" + connectionURL); } _connectionURL = connectionURL; @@ -343,7 +343,10 @@ public class AMQConnection extends Closeable implements Connection, QueueConnect _protocolHandler = new AMQProtocolHandler(this); - _logger.info("Connecting with ProtocolHandler Version:"+_protocolHandler.getProtocolVersion()); + if (_logger.isDebugEnabled()) + { + _logger.debug("Connecting with ProtocolHandler Version:"+_protocolHandler.getProtocolVersion()); + } // We are not currently connected setConnected(false); @@ -435,7 +438,10 @@ public class AMQConnection extends Closeable implements Connection, QueueConnect throw new AMQConnectionFailureException(message, connectionException); } - _logger.info("Connected with ProtocolHandler Version:"+_protocolHandler.getProtocolVersion()); + if (_logger.isDebugEnabled()) + { + _logger.debug("Connected with ProtocolHandler Version:"+_protocolHandler.getProtocolVersion()); + } _sessions.setMaxChannelID(_delegate.getMaxChannelID()); _sessions.setMinChannelID(_delegate.getMinChannelID()); @@ -462,7 +468,10 @@ public class AMQConnection extends Closeable implements Connection, QueueConnect String delegateClassName = String.format ("org.apache.qpid.client.AMQConnectionDelegate_%s_%s", pe.getMajorVersion(), pe.getMinorVersion()); - _logger.info("Looking up delegate '" + delegateClassName + "' Based on PE:" + pe); + if (_logger.isDebugEnabled()) + { + _logger.debug("Looking up delegate '" + delegateClassName + "' Based on PE:" + pe); + } Class c = Class.forName(delegateClassName); Class partypes[] = new Class[1]; partypes[0] = AMQConnection.class; diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java index 9f3060e2d3..8fb4da550d 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java @@ -530,9 +530,9 @@ public abstract class AMQSession extends Closeable implements Messa throw new javax.jms.IllegalStateException("Attempt to alter listener while session is started."); } - _logger.debug("Message listener set for destination " + _destination); + if (_logger.isDebugEnabled()) + { + _logger.debug("Message listener set for destination " + _destination); + } if (messageListener != null) { @@ -557,9 +560,9 @@ public abstract class BasicMessageConsumer extends Closeable implements Messa public void close(boolean sendClose) throws JMSException { - if (_logger.isInfoEnabled()) + if (_logger.isDebugEnabled()) { - _logger.info("Closing consumer:" + debugIdentity()); + _logger.debug("Closing consumer:" + debugIdentity()); } if (!setClosed()) diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java b/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java index 56739f17f9..9b3b2ce0e9 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java @@ -47,7 +47,7 @@ public abstract class BasicMessageProducer extends Closeable implements org.apac { enum PublishMode { ASYNC_PUBLISH_ALL, SYNC_PUBLISH_PERSISTENT, SYNC_PUBLISH_ALL }; - private final Logger _logger = LoggerFactory.getLogger(getClass()); + private final Logger _logger ; private AMQConnection _connection; @@ -134,11 +134,12 @@ public abstract class BasicMessageProducer extends Closeable implements org.apac private PublishMode publishMode = PublishMode.ASYNC_PUBLISH_ALL; - protected BasicMessageProducer(AMQConnection connection, AMQDestination destination, boolean transacted, int channelId, + protected BasicMessageProducer(Logger logger,AMQConnection connection, AMQDestination destination, boolean transacted, int channelId, AMQSession session, AMQProtocolHandler protocolHandler, long producerId, Boolean immediate, Boolean mandatory) throws AMQException { - _connection = connection; + _logger = logger; + _connection = connection; _destination = destination; _transacted = transacted; _protocolHandler = protocolHandler; @@ -178,7 +179,10 @@ public abstract class BasicMessageProducer extends Closeable implements org.apac publishMode = PublishMode.SYNC_PUBLISH_ALL; } - _logger.info("MessageProducer " + toString() + " using publish mode : " + publishMode); + if (_logger.isDebugEnabled()) + { + _logger.debug("MessageProducer " + toString() + " using publish mode : " + publishMode); + } } void resubscribe() throws AMQException @@ -516,7 +520,10 @@ public abstract class BasicMessageProducer extends Closeable implements org.apac _logger.debug("Updating original message"); origMessage.setJMSPriority(message.getJMSPriority()); origMessage.setJMSTimestamp(message.getJMSTimestamp()); - _logger.debug("Setting JMSExpiration:" + message.getJMSExpiration()); + if (_logger.isDebugEnabled()) + { + _logger.debug("Setting JMSExpiration:" + message.getJMSExpiration()); + } origMessage.setJMSExpiration(message.getJMSExpiration()); origMessage.setJMSMessageID(message.getJMSMessageID()); } diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java index db5baed586..a3a1e9c28b 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java @@ -63,7 +63,7 @@ public class BasicMessageProducer_0_10 extends BasicMessageProducer AMQSession session, AMQProtocolHandler protocolHandler, long producerId, Boolean immediate, Boolean mandatory) throws AMQException { - super(connection, destination, transacted, channelId, session, protocolHandler, producerId, immediate, mandatory); + super(_logger, connection, destination, transacted, channelId, session, protocolHandler, producerId, immediate, mandatory); userIDBytes = Strings.toUTF8(getUserID()); } diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_8.java b/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_8.java index 7fd8feef54..21ff6c877a 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_8.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_8.java @@ -33,6 +33,9 @@ import org.apache.qpid.framing.ContentHeaderBody; import org.apache.qpid.framing.ExchangeDeclareBody; import org.apache.qpid.framing.MethodRegistry; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import javax.jms.JMSException; import javax.jms.Message; import javax.jms.Queue; @@ -42,11 +45,12 @@ import java.util.UUID; public class BasicMessageProducer_0_8 extends BasicMessageProducer { + private static final Logger _logger = LoggerFactory.getLogger(BasicMessageProducer_0_8.class); BasicMessageProducer_0_8(AMQConnection connection, AMQDestination destination, boolean transacted, int channelId, AMQSession session, AMQProtocolHandler protocolHandler, long producerId, Boolean immediate, Boolean mandatory) throws AMQException { - super(connection, destination,transacted,channelId,session, protocolHandler, producerId, immediate, mandatory); + super(_logger,connection, destination,transacted,channelId,session, protocolHandler, producerId, immediate, mandatory); } void declareDestination(AMQDestination destination) diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ClientMethodDispatcherImpl.java b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ClientMethodDispatcherImpl.java index 558d93538b..e1a0e18262 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ClientMethodDispatcherImpl.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ClientMethodDispatcherImpl.java @@ -95,9 +95,9 @@ public class ClientMethodDispatcherImpl implements MethodDispatcher public static ClientMethodDispatcherImpl newMethodDispatcher(ProtocolVersion version, AMQProtocolSession session) { - if (_logger.isInfoEnabled()) + if (_logger.isDebugEnabled()) { - _logger.info("New Method Dispatcher:" + session); + _logger.debug("New Method Dispatcher:" + session); } DispatcherFactory factory = _dispatcherFactories.get(version); diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolSession.java b/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolSession.java index ced734f70f..af57fd98fc 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolSession.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolSession.java @@ -108,7 +108,10 @@ public class AMQProtocolSession implements AMQVersionAwareProtocolSession { _protocolHandler = protocolHandler; _protocolVersion = connection.getProtocolVersion(); - _logger.info("Using ProtocolVersion for Session:" + _protocolVersion); + if (_logger.isDebugEnabled()) + { + _logger.debug("Using ProtocolVersion for Session:" + _protocolVersion); + } _methodDispatcher = ClientMethodDispatcherImpl.newMethodDispatcher(ProtocolVersion.getLatestSupportedVersion(), this); _connection = connection; @@ -302,7 +305,10 @@ public class AMQProtocolSession implements AMQVersionAwareProtocolSession */ public void closeSession(AMQSession session) { - _logger.debug("closeSession called on protocol session for session " + session.getChannelId()); + if (_logger.isDebugEnabled()) + { + _logger.debug("closeSession called on protocol session for session " + session.getChannelId()); + } final int channelId = session.getChannelId(); if (channelId <= 0) { @@ -393,7 +399,10 @@ public class AMQProtocolSession implements AMQVersionAwareProtocolSession public void setProtocolVersion(final ProtocolVersion pv) { - _logger.info("Setting ProtocolVersion to :" + pv); + if (_logger.isDebugEnabled()) + { + _logger.debug("Setting ProtocolVersion to :" + pv); + } _protocolVersion = pv; _methodRegistry = MethodRegistry.getMethodRegistry(pv); _methodDispatcher = ClientMethodDispatcherImpl.newMethodDispatcher(pv, this); -- cgit v1.2.1