[jboss-cvs] JBoss Messaging SVN: r5289 - in trunk/src/main/org/jboss/messaging: core/management/impl and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Nov 6 09:05:14 EST 2008
Author: jmesnil
Date: 2008-11-06 09:05:14 -0500 (Thu, 06 Nov 2008)
New Revision: 5289
Modified:
trunk/src/main/org/jboss/messaging/core/management/MessageCounterInfo.java
trunk/src/main/org/jboss/messaging/core/management/impl/QueueControl.java
trunk/src/main/org/jboss/messaging/core/messagecounter/MessageCounter.java
trunk/src/main/org/jboss/messaging/core/messagecounter/impl/MessageCounterHelper.java
trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSQueueControl.java
Log:
JBMESSAGING-1122: MessageCountersAsHTML LastAdd uses wrong value
- added MessageCounter.getLastAddedMessageTime()
- added the field to MessageCounterInfo
- display it in MessageCounterHelper.listMessageCounterAsHTML()
Modified: trunk/src/main/org/jboss/messaging/core/management/MessageCounterInfo.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/MessageCounterInfo.java 2008-11-06 13:00:31 UTC (rev 5288)
+++ trunk/src/main/org/jboss/messaging/core/management/MessageCounterInfo.java 2008-11-06 14:05:14 UTC (rev 5289)
@@ -26,6 +26,9 @@
import static javax.management.openmbean.SimpleType.INTEGER;
import static javax.management.openmbean.SimpleType.STRING;
+import java.text.DateFormat;
+import java.util.Date;
+
import javax.management.openmbean.CompositeData;
import javax.management.openmbean.CompositeDataSupport;
import javax.management.openmbean.CompositeType;
@@ -34,6 +37,7 @@
import javax.management.openmbean.TabularType;
import org.jboss.logging.Logger;
+import org.jboss.messaging.core.messagecounter.MessageCounter;
/**
* @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
@@ -47,16 +51,19 @@
private static final Logger log = Logger.getLogger(MessageCounterInfo.class);
+ private static final DateFormat DATE_FORMAT = DateFormat.getDateTimeInstance(DateFormat.SHORT,
+ DateFormat.MEDIUM);
+
public static final CompositeType TYPE;
private static final String MESSAGE_TYPE_NAME = "MessageCounterInfo";
private static final String MESSAGE_TABULAR_TYPE_NAME = "TabularMessageCounterInfo";
private static final String[] ITEM_NAMES = new String[] { "name",
"subscription", "durable", "count", "countDelta", "depth",
- "depthDelta", "timestamp" };
+ "depthDelta", "lastAddTimestamp", "updateTimestamp" };
private static final String[] ITEM_DESCRIPTIONS = new String[] {
"Name of the Queue", "Name of the subscription",
"Is the queue durable?", "Message count", "Message count delta",
- "Depth", "Depth delta", "Timestamp of the last increment" };
+ "Depth", "Depth delta", "Timestamp of the last added messagg", "Timestamp of the last update" };
private static final OpenType[] TYPES;
private static final TabularType TABULAR_TYPE;
@@ -65,7 +72,7 @@
try
{
TYPES = new OpenType[] { STRING, STRING, BOOLEAN, INTEGER, INTEGER,
- INTEGER, INTEGER, STRING };
+ INTEGER, INTEGER, STRING, STRING };
TYPE = new CompositeType(MESSAGE_TYPE_NAME,
"Information for a MessageCounter", ITEM_NAMES,
ITEM_DESCRIPTIONS, TYPES);
@@ -88,15 +95,28 @@
private final int countDelta;
private final int depth;
private final int depthDelta;
- private final String timestamp;
+ private final String lastAddTimestamp;
+ private final String udpateTimestamp;
// Static --------------------------------------------------------
+ public static CompositeData toCompositeData(MessageCounter counter)
+ {
+ String lassAddTimestamp = DATE_FORMAT.format(new Date(counter.getLastAddedMessageTime()));
+ String updateTimestamp = DATE_FORMAT.format(new Date(counter.getLastUpdate()));
+ MessageCounterInfo info = new MessageCounterInfo(counter
+ .getDestinationName(), counter.getDestinationSubscription(),
+ counter.isDestinationDurable(), counter.getCount(), counter
+ .getCountDelta(), counter.getMessageCount(), counter
+ .getMessageCountDelta(), lassAddTimestamp, updateTimestamp);
+ return info.toCompositeData();
+ }
+
// Constructors --------------------------------------------------
public MessageCounterInfo(final String name, final String subscription,
final boolean durable, final int count, final int countDelta,
- final int depth, final int depthDelta, final String timestamp)
+ final int depth, final int depthDelta, final String lastAddTimestamp, final String udpateTimestamp)
{
this.name = name;
this.subscription = subscription;
@@ -105,7 +125,8 @@
this.countDelta = countDelta;
this.depth = depth;
this.depthDelta = depthDelta;
- this.timestamp = timestamp;
+ this.lastAddTimestamp = lastAddTimestamp;
+ this.udpateTimestamp = udpateTimestamp;
}
// Public --------------------------------------------------------
@@ -117,7 +138,7 @@
return new CompositeDataSupport(TYPE, ITEM_NAMES, new Object[] { name,
subscription, durable, count, countDelta, depth, depthDelta,
- timestamp });
+ lastAddTimestamp, udpateTimestamp });
} catch (OpenDataException e)
{
log.error("Unable to create a CompositeData from a MessageCounter", e);
Modified: trunk/src/main/org/jboss/messaging/core/management/impl/QueueControl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/impl/QueueControl.java 2008-11-06 13:00:31 UTC (rev 5288)
+++ trunk/src/main/org/jboss/messaging/core/management/impl/QueueControl.java 2008-11-06 14:05:14 UTC (rev 5289)
@@ -314,15 +314,7 @@
public CompositeData listMessageCounter()
{
- DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT,
- DateFormat.MEDIUM);
- String timestamp = dateFormat.format(new Date(counter.getLastUpdate()));
- MessageCounterInfo info = new MessageCounterInfo(counter
- .getDestinationName(), counter.getDestinationSubscription(),
- counter.isDestinationDurable(), counter.getCount(), counter
- .getCountDelta(), counter.getMessageCount(), counter
- .getMessageCountDelta(), timestamp);
- return info.toCompositeData();
+ return MessageCounterInfo.toCompositeData(counter);
}
public String listMessageCounterAsHTML()
Modified: trunk/src/main/org/jboss/messaging/core/messagecounter/MessageCounter.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/messagecounter/MessageCounter.java 2008-11-06 13:00:31 UTC (rev 5288)
+++ trunk/src/main/org/jboss/messaging/core/messagecounter/MessageCounter.java 2008-11-06 14:05:14 UTC (rev 5289)
@@ -71,6 +71,8 @@
private long timeLastUpdate;
+ private long timeLastAdd;
+
// per hour day counter history
private int dayCounterMax;
@@ -125,6 +127,11 @@
lastMessagesAdded = latestMessagesAdded;
+ if(newMessagesAdded > 0)
+ {
+ timeLastAdd = System.currentTimeMillis();
+ }
+
// update timestamp
timeLastUpdate = System.currentTimeMillis();
@@ -201,12 +208,18 @@
return timeLastUpdate;
}
+ public long getLastAddedMessageTime()
+ {
+ return timeLastAdd;
+ }
+
public void resetCounter()
{
countTotal = 0;
countTotalLast = 0;
depthLast = 0;
timeLastUpdate = 0;
+ timeLastAdd = 0;
}
private void setHistoryLimit(int daycountmax)
Modified: trunk/src/main/org/jboss/messaging/core/messagecounter/impl/MessageCounterHelper.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/messagecounter/impl/MessageCounterHelper.java 2008-11-06 13:00:31 UTC (rev 5288)
+++ trunk/src/main/org/jboss/messaging/core/messagecounter/impl/MessageCounterHelper.java 2008-11-06 14:05:14 UTC (rev 5289)
@@ -60,6 +60,7 @@
+ "<th>Depth</th>"
+ "<th>DepthDelta</th>"
+ "<th>Last Add</th>"
+ + "<th>Last Update</th>"
+ "</tr>\n";
for (int i = 0; i < counters.length; i++)
@@ -86,8 +87,9 @@
ret += "<td>" + prettify(counter.getCountDelta()) + "</td>";
ret += "<td>" + prettify(counter.getMessageCount()) + "</td>";
ret += "<td>" + prettify(counter.getMessageCountDelta()) + "</td>";
- ret += "<td>" + asDate(counter.getLastUpdate()) + "</td>"; // date last add
-
+ ret += "<td>" + asDate(counter.getLastAddedMessageTime()) + "</td>";
+ ret += "<td>" + asDate(counter.getLastUpdate()) + "</td>";
+
ret += "</tr>\n";
}
Modified: trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSQueueControl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSQueueControl.java 2008-11-06 13:00:31 UTC (rev 5288)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSQueueControl.java 2008-11-06 14:05:14 UTC (rev 5289)
@@ -24,7 +24,6 @@
import java.text.DateFormat;
import java.util.ArrayList;
-import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
@@ -317,15 +316,7 @@
public CompositeData listMessageCounter()
{
- DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT,
- DateFormat.MEDIUM);
- String timestamp = dateFormat.format(new Date(counter.getLastUpdate()));
- MessageCounterInfo info = new MessageCounterInfo(counter
- .getDestinationName(), counter.getDestinationSubscription(),
- counter.isDestinationDurable(), counter.getCount(), counter
- .getCountDelta(), counter.getMessageCount(), counter
- .getMessageCountDelta(), timestamp);
- return info.toCompositeData();
+ return MessageCounterInfo.toCompositeData(counter);
}
public String listMessageCounterAsHTML()
More information about the jboss-cvs-commits
mailing list