diff options
5 files changed, 53 insertions, 16 deletions
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueMBean.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueMBean.java index e6346b9f3b..c8ead67b1f 100644 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueMBean.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueMBean.java @@ -221,11 +221,12 @@ public class AMQQueueMBean extends AMQManagedObject implements ManagedQueue, Que _queue.setMaximumMessageCount(value); } + /** + * returns the maximum total size of messages(bytes) in the queue. + */ public Long getMaximumQueueDepth() { - long queueDepthInBytes = _queue.getMaximumQueueDepth(); - - return queueDepthInBytes >> 10; + return _queue.getMaximumQueueDepth(); } public void setMaximumQueueDepth(Long value) @@ -234,13 +235,11 @@ public class AMQQueueMBean extends AMQManagedObject implements ManagedQueue, Que } /** - * returns the size of messages(KB) in the queue. + * returns the total size of messages(bytes) in the queue. */ public Long getQueueDepth() throws JMException { - long queueBytesSize = _queue.getQueueDepth(); - - return queueBytesSize >> 10; + return _queue.getQueueDepth(); } /** diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/ManagedQueue.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/ManagedQueue.java index e0d131a5d9..84a3bdc1e8 100644 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/ManagedQueue.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/ManagedQueue.java @@ -41,7 +41,7 @@ import org.apache.qpid.server.management.MBeanOperationParameter; public interface ManagedQueue { static final String TYPE = "Queue"; - static final int VERSION = 1; + static final int VERSION = 2; /** * Returns the Name of the ManagedQueue. @@ -72,7 +72,7 @@ public interface ManagedQueue * @return * @throws IOException */ - @MBeanAttribute(name="QueueDepth", description="Size of messages(KB) in the queue") + @MBeanAttribute(name="QueueDepth", description="The total size(Bytes) of messages in the queue") Long getQueueDepth() throws IOException, JMException; /** @@ -181,7 +181,7 @@ public interface ManagedQueue * @param value * @throws IOException */ - @MBeanAttribute(name="MaximumQueueDepth", description="The threshold high value(KB) for Queue Depth") + @MBeanAttribute(name="MaximumQueueDepth", description="The threshold high value(Bytes) for Queue Depth") void setMaximumQueueDepth(Long value) throws IOException; diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueAlertTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueAlertTest.java index b9b68da579..6589f46c7b 100644 --- a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueAlertTest.java +++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueAlertTest.java @@ -202,7 +202,7 @@ public class AMQQueueAlertTest extends TestCase // Send messages(no of message to be little more than what can cause a Queue_Depth alert) int messageCount = Math.round(MAX_QUEUE_DEPTH / MAX_MESSAGE_SIZE) + 10; - long totalSize = (messageCount * MAX_MESSAGE_SIZE) >> 10; + long totalSize = (messageCount * MAX_MESSAGE_SIZE); sendMessages(messageCount, MAX_MESSAGE_SIZE); // Check queueDepth. There should be no messages on the queue and as the subscriber is listening diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java index eab8ad3e2e..ce986cf55b 100644 --- a/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java +++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java @@ -73,7 +73,7 @@ public class AMQQueueMBeanTest extends TestCase sendMessages(messageCount, false); assertTrue(_queueMBean.getMessageCount() == messageCount); assertTrue(_queueMBean.getReceivedMessageCount() == messageCount); - long queueDepth = (messageCount * MESSAGE_SIZE) >> 10; + long queueDepth = (messageCount * MESSAGE_SIZE); assertTrue(_queueMBean.getQueueDepth() == queueDepth); _queueMBean.deleteMessageFromTop(); @@ -94,7 +94,7 @@ public class AMQQueueMBeanTest extends TestCase sendMessages(messageCount, true); assertEquals("", messageCount, _queueMBean.getMessageCount().intValue()); assertTrue(_queueMBean.getReceivedMessageCount() == messageCount); - long queueDepth = (messageCount * MESSAGE_SIZE) >> 10; + long queueDepth = (messageCount * MESSAGE_SIZE); assertTrue(_queueMBean.getQueueDepth() == queueDepth); _queueMBean.deleteMessageFromTop(); @@ -175,7 +175,7 @@ public class AMQQueueMBeanTest extends TestCase assertTrue(_queueMBean.getMaximumMessageCount() == 50000); assertTrue(_queueMBean.getMaximumMessageSize() == 2000); - assertTrue(_queueMBean.getMaximumQueueDepth() == (maxQueueDepth >> 10)); + assertTrue(_queueMBean.getMaximumQueueDepth() == (maxQueueDepth)); assertTrue(_queueMBean.getName().equals("testQueue")); assertTrue(_queueMBean.getOwner().equals("AMQueueMBeanTest")); diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/QueueTypeTabControl.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/QueueTypeTabControl.java index 9fcf32abdd..6e37e96695 100644 --- a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/QueueTypeTabControl.java +++ b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/QueueTypeTabControl.java @@ -271,12 +271,50 @@ public class QueueTypeTabControl extends MBeanTypeTabControl for (AttributeData data : list) { ManagedBean mbean = _queueDepthMap.get(data); - String value = data.getValue().toString(); - items[i++] = mbean.getName() + " (" + value + " KB)"; + items[i++] = mbean.getName() + " (" + getQueueDepthString(mbean, data) + ")"; } getListWidget().setItems(items); } + private String getQueueDepthString(ManagedBean mbean, AttributeData data) + { + if (mbean.getVersion() == 1) //mbean returns KB + { + Long value = (Long)data.getValue(); + + Double mb = 1024.0; + + if(value > mb) //MB + { + return String.format("%.3f", (Double)(value / mb)) + " MB"; + } + else //KB + { + return data.getValue().toString() + " KB"; + } + } + else //mbean returns Bytes + { + Long value = (Long)data.getValue(); + + double mb = 1024.0 * 1024.0; + double kb = 1024.0; + + if(value >= mb) //MB + { + return String.format("%.3f", (Double)(value / mb)) + " MB"; + } + else if (value >= kb) //KB + { + return String.format("%.3f", (Double)(value / kb)) + " KB"; + } + else //Bytes + { + return data.getValue().toString() + " Bytes"; + } + } + } + private void sortQueuesByConsumerCount() { java.util.List<AttributeData> list = new ArrayList<AttributeData>(_queueConsumerCountMap.keySet()); |