Author: kwall Date: Thu Jan 26 21:37:43 2012 New Revision: 1236397 URL: http://svn.apache.org/viewvc?rev=1236397&view=rev Log: QPID-3559: AMQQueueMBean: Switched timestamp formatting to static FastDateFormat instance to avoid the need for synchronisation or the generation of lots of SDF and Date instance garbage.
Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueMBean.java Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueMBean.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueMBean.java?rev=1236397&r1=1236396&r2=1236397&view=diff ============================================================================== --- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueMBean.java (original) +++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueMBean.java Thu Jan 26 21:37:43 2012 @@ -20,6 +20,11 @@ */ package org.apache.qpid.server.queue; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import org.apache.commons.lang.time.FastDateFormat; import org.apache.log4j.Logger; import org.apache.qpid.AMQException; @@ -57,8 +62,6 @@ import javax.management.openmbean.Tabula import javax.management.openmbean.TabularDataSupport; import javax.management.openmbean.TabularType; -import java.text.SimpleDateFormat; -import java.util.*; /** * AMQQueueMBean is the management bean for an {@link AMQQueue}. @@ -72,11 +75,13 @@ public class AMQQueueMBean extends AMQMa { /** Used for debugging purposes. */ - private static final Logger _logger = Logger.getLogger(AMQQueueMBean.class); + private static final Logger LOGGER = Logger.getLogger(AMQQueueMBean.class); /** Date/time format used for message expiration and message timestamp formatting */ public static final String JMSTIMESTAMP_DATETIME_FORMAT = "MM-dd-yy HH:mm:ss.SSS z"; + private static final FastDateFormat FAST_DATE_FORMAT = FastDateFormat.getInstance(JMSTIMESTAMP_DATETIME_FORMAT); + private final AMQQueue _queue; private final String _queueName; // OpenMBean data types for viewMessages method @@ -347,7 +352,7 @@ public class AMQQueueMBean extends AMQMa public void notifyClients(NotificationCheck notification, AMQQueue queue, String notificationMsg) { // important : add log to the log file - monitoring tools may be looking for this - _logger.info(notification.name() + " On Queue " + queue.getNameShortString() + " - " + notificationMsg); + LOGGER.info(notification.name() + " On Queue " + queue.getNameShortString() + " - " + notificationMsg); notificationMsg = notification.name() + " " + notificationMsg; _lastNotification = @@ -589,18 +594,8 @@ public class AMQQueueMBean extends AMQMa private void addStringifiedJMSTimestamoAndJMSExpiration(final List<String> list, final long expirationDate, final long timestampDate) { - final SimpleDateFormat dateFormat; - if (expirationDate != 0 || timestampDate != 0) - { - dateFormat = new SimpleDateFormat(JMSTIMESTAMP_DATETIME_FORMAT); - } - else - { - dateFormat = null; - } - - final String formattedExpirationDate = (expirationDate != 0) ? dateFormat.format(new Date(expirationDate)) : null; - final String formattedTimestampDate = (timestampDate != 0) ? dateFormat.format(new Date(timestampDate)) : null; + final String formattedExpirationDate = (expirationDate != 0) ? FAST_DATE_FORMAT.format(expirationDate) : null; + final String formattedTimestampDate = (timestampDate != 0) ? FAST_DATE_FORMAT.format(timestampDate) : null; list.add("JMSExpiration = " + formattedExpirationDate); list.add("JMSTimestamp = " + formattedTimestampDate); } @@ -659,8 +654,6 @@ public class AMQQueueMBean extends AMQMa _queue.copyMessagesToAnotherQueue(fromMessageId, toMessageId, toQueueName, txn); txn.commit(); - - } /** --------------------------------------------------------------------- Apache Qpid - AMQP Messaging Implementation Project: http://qpid.apache.org Use/Interact: mailto:commits-subscr...@qpid.apache.org