summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorKeith Wall <kwall@apache.org>2012-01-26 21:37:43 +0000
committerKeith Wall <kwall@apache.org>2012-01-26 21:37:43 +0000
commit8cd2da84fb300ab46d88778bc0f43e2016dfab98 (patch)
tree294c4a555d346069e680616800b0b990fe34055d /java
parentf398588aa0249e635f172be47659d2c09ee06ef2 (diff)
downloadqpid-python-8cd2da84fb300ab46d88778bc0f43e2016dfab98.tar.gz
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. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1236397 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
-rw-r--r--java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueMBean.java29
1 files changed, 11 insertions, 18 deletions
diff --git a/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueMBean.java b/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueMBean.java
index 143a6ae8ca..7ed007ecd6 100644
--- a/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueMBean.java
+++ b/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueMBean.java
@@ -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.TabularData;
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 AMQManagedObject implements ManagedQueue, Que
{
/** 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 AMQManagedObject implements ManagedQueue, Que
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 AMQManagedObject implements ManagedQueue, Que
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 AMQManagedObject implements ManagedQueue, Que
_queue.copyMessagesToAnotherQueue(fromMessageId, toMessageId, toQueueName, txn);
txn.commit();
-
-
}
/**