From 6abfd1795522bc41d281ba3218df1f4979a55546 Mon Sep 17 00:00:00 2001 From: Robert Gemmell Date: Fri, 24 Jul 2009 14:21:06 +0000 Subject: QPID-2000: add a method to the VirtualHostManager MBean to retrieve a Map keyed by Queue names in the vhost, with values indicating their respective depths in bytes git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@797473 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/qpid/server/AMQBrokerManagerMBean.java | 27 +++++++++++++++++++++- .../management/common/mbeans/ManagedBroker.java | 12 ++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) (limited to 'java') diff --git a/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java b/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java index d7583d9c59..306dce1057 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java +++ b/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java @@ -39,6 +39,8 @@ package org.apache.qpid.server; import java.io.IOException; import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; import javax.management.JMException; import javax.management.MBeanException; @@ -75,7 +77,7 @@ public class AMQBrokerManagerMBean extends AMQManagedObject implements ManagedBr private final MessageStore _messageStore; private final VirtualHost.VirtualHostMBean _virtualHostMBean; - + @MBeanConstructor("Creates the Broker Manager MBean") public AMQBrokerManagerMBean(VirtualHost.VirtualHostMBean virtualHostMBean) throws JMException { @@ -111,6 +113,29 @@ public class AMQBrokerManagerMBean extends AMQManagedObject implements ManagedBr return exchangeTypes.toArray(new String[0]); } + /** + * Returns a Map keyed by QueueName, detailing its associated QueueDepth in bytes. + * @since Qpid JMX API 1.3 + * @throws IOException + */ + public Map viewQueueNamesDepths() throws IOException + { + Map queueDepthMap = new HashMap(_queueRegistry.getQueues().size()); + + String queueName; + Long queueDepth; + + for(AMQQueue queue : _queueRegistry.getQueues()) + { + queueName = queue.getName().toString(); + queueDepth = queue.getQueueDepth(); + + queueDepthMap.put(queueName,queueDepth); + } + + return queueDepthMap; + } + /** * Creates new exchange and registers it with the registry. * diff --git a/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ManagedBroker.java b/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ManagedBroker.java index 224bf8de2c..e376033bad 100644 --- a/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ManagedBroker.java +++ b/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ManagedBroker.java @@ -22,9 +22,12 @@ package org.apache.qpid.management.common.mbeans; import java.io.IOException; +import java.util.Map; import javax.management.JMException; import javax.management.MBeanOperationInfo; +import javax.management.openmbean.OpenDataException; +import javax.management.openmbean.TabularData; import org.apache.qpid.management.common.mbeans.annotations.MBeanAttribute; import org.apache.qpid.management.common.mbeans.annotations.MBeanOperation; @@ -51,6 +54,15 @@ public interface ManagedBroker @MBeanAttribute(name="ExchangeTypes", description = "The types of Exchange available for creation.") String[] getExchangeTypes() throws IOException; + /** + * Returns a Map keyed by QueueName, detailing its associated QueueDepth in bytes. + * @since Qpid JMX API 1.3 + * @throws IOException + */ + @MBeanOperation(name = "viewQueueNamesDepths", description = "View the queue names and depths in this virtualhost", + impact = MBeanOperationInfo.INFO) + Map viewQueueNamesDepths() throws IOException; + /** * Creates a new Exchange. * @param name -- cgit v1.2.1