Author: ritchiem
Date: Mon Apr 13 13:46:13 2009
New Revision: 764460

URL: http://svn.apache.org/viewvc?rev=764460&view=rev
Log:
QPID-1492: make the broker return the current queue depth and maximum queue 
depth in bytes rather than kilbytes, matching their respective setter methods. 
Augment the management console's navigation queue selection list to show the 
appropriate numbers

merged from trunk r749149

Modified:
    qpid/branches/0.5-fix/qpid/   (props changed)
    
qpid/branches/0.5-fix/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueMBean.java
    
qpid/branches/0.5-fix/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/ManagedQueue.java
    
qpid/branches/0.5-fix/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueAlertTest.java
    
qpid/branches/0.5-fix/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java
    
qpid/branches/0.5-fix/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/QueueTypeTabControl.java

Propchange: qpid/branches/0.5-fix/qpid/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Apr 13 13:46:13 2009
@@ -1 +1 @@
-/qpid/trunk/qpid:742626,743015,743028-743029,743304,743306,743311,743357,744113,747363,747367,747369-747370,747376,747783,747868-747870,747875,748561,748591,748641,748680,748686
+/qpid/trunk/qpid:742626,743015,743028-743029,743304,743306,743311,743357,744113,747363,747367,747369-747370,747376,747783,747868-747870,747875,748561,748591,748641,748680,748686,749149

Modified: 
qpid/branches/0.5-fix/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueMBean.java
URL: 
http://svn.apache.org/viewvc/qpid/branches/0.5-fix/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueMBean.java?rev=764460&r1=764459&r2=764460&view=diff
==============================================================================
--- 
qpid/branches/0.5-fix/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueMBean.java
 (original)
+++ 
qpid/branches/0.5-fix/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueMBean.java
 Mon Apr 13 13:46:13 2009
@@ -221,11 +221,12 @@
         _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 @@
     }
 
     /**
-     * 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();
     }
 
     /**

Modified: 
qpid/branches/0.5-fix/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/ManagedQueue.java
URL: 
http://svn.apache.org/viewvc/qpid/branches/0.5-fix/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/ManagedQueue.java?rev=764460&r1=764459&r2=764460&view=diff
==============================================================================
--- 
qpid/branches/0.5-fix/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/ManagedQueue.java
 (original)
+++ 
qpid/branches/0.5-fix/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/ManagedQueue.java
 Mon Apr 13 13:46:13 2009
@@ -41,7 +41,7 @@
 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 @@
      * @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 @@
      * @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;
 
 

Modified: 
qpid/branches/0.5-fix/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueAlertTest.java
URL: 
http://svn.apache.org/viewvc/qpid/branches/0.5-fix/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueAlertTest.java?rev=764460&r1=764459&r2=764460&view=diff
==============================================================================
--- 
qpid/branches/0.5-fix/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueAlertTest.java
 (original)
+++ 
qpid/branches/0.5-fix/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueAlertTest.java
 Mon Apr 13 13:46:13 2009
@@ -202,7 +202,7 @@
 
         // 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

Modified: 
qpid/branches/0.5-fix/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java
URL: 
http://svn.apache.org/viewvc/qpid/branches/0.5-fix/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java?rev=764460&r1=764459&r2=764460&view=diff
==============================================================================
--- 
qpid/branches/0.5-fix/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java
 (original)
+++ 
qpid/branches/0.5-fix/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java
 Mon Apr 13 13:46:13 2009
@@ -73,7 +73,7 @@
         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 @@
         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 @@
 
         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"));

Modified: 
qpid/branches/0.5-fix/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/QueueTypeTabControl.java
URL: 
http://svn.apache.org/viewvc/qpid/branches/0.5-fix/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/QueueTypeTabControl.java?rev=764460&r1=764459&r2=764460&view=diff
==============================================================================
--- 
qpid/branches/0.5-fix/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/QueueTypeTabControl.java
 (original)
+++ 
qpid/branches/0.5-fix/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/QueueTypeTabControl.java
 Mon Apr 13 13:46:13 2009
@@ -271,12 +271,50 @@
         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());



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:[email protected]

Reply via email to