diff options
author | Robert Gemmell <robbie@apache.org> | 2009-08-09 21:06:47 +0000 |
---|---|---|
committer | Robert Gemmell <robbie@apache.org> | 2009-08-09 21:06:47 +0000 |
commit | a39a61e40226ee87f7040e9c6729f8beaf5764d2 (patch) | |
tree | 9c44b2db7a1a8c7fd711139398bb4ddf64f5c300 /java/management/common/src | |
parent | d6d15604657537f84654556b2c050c5274bd36b5 (diff) | |
download | qpid-python-a39a61e40226ee87f7040e9c6729f8beaf5764d2.tar.gz |
QPID-2015: Add 2 new methods to the VirtualHostManager to retrieve attribute names/values for every Queue in the vhost in a single call. Remove previous viewQueueNamesDepths() method. Add new ManagedQueue attribute names constants, and a test to ensure any attributes added to the Queue MBeans in future are also added to the constants.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@802601 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/management/common/src')
3 files changed, 130 insertions, 7 deletions
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 e376033bad..dcf77ca2ed 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,12 +22,10 @@ package org.apache.qpid.management.common.mbeans; import java.io.IOException; -import java.util.Map; +import java.util.List; 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; @@ -55,13 +53,23 @@ public interface ManagedBroker String[] getExchangeTypes() throws IOException; /** - * Returns a Map keyed by QueueName, detailing its associated QueueDepth in bytes. + * Returns a list containing the names of the attributes available for the Queue mbeans. * @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<String,Long> viewQueueNamesDepths() throws IOException; + @MBeanOperation(name = "retrieveQueueAttributeNames", description = "Retrieve the attribute names for queues in this virtualhost", + impact = MBeanOperationInfo.INFO) + List<String> retrieveQueueAttributeNames() throws IOException; + + /** + * Returns a List of Object Lists containing the requested attribute values (in the same sequence requested) for each queue in the virtualhost. + * If a particular attribute cant be found or raises an mbean/reflection exception whilst being gathered its value is substituted with the String "-". + * @since Qpid JMX API 1.3 + * @throws IOException + */ + @MBeanOperation(name = "retrieveQueueAttributeValues", description = "Retrieve the indicated attributes for queues in this virtualhost", + impact = MBeanOperationInfo.INFO) + List<List<Object>> retrieveQueueAttributeValues(@MBeanOperationParameter(name="attributes", description="Attributes to retrieve") String[] attributes) throws IOException; /** * Creates a new Exchange. diff --git a/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ManagedQueue.java b/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ManagedQueue.java index 9046d7fcb7..abcbaa8693 100644 --- a/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ManagedQueue.java +++ b/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ManagedQueue.java @@ -54,6 +54,37 @@ public interface ManagedQueue String[] VIEW_MSG_CONTENT_COMPOSITE_ITEM_NAMES = { "AMQ MessageId", "MimeType", "Encoding", "Content" }; String[] VIEW_MSG_CONTENT_COMPOSITE_ITEM_DESCRIPTIONS = { "AMQ MessageId", "MimeType", "Encoding", "Content" }; + //Individual attribute name constants + String ATTR_NAME = "Name"; + String ATTR_OWNER = "Owner"; + String ATTR_MAX_MSG_AGE = "MaximumMessageAge"; + String ATTR_MAX_MSG_COUNT = "MaximumMessageCount"; + String ATTR_MAX_QUEUE_DEPTH = "MaximumQueueDepth"; + String ATTR_MAX_MSG_SIZE = "MaximumMessageSize"; + String ATTR_DURABLE = "Durable"; + String ATTR_AUTODELETE = "AutoDelete"; + String ATTR_CONSUMER_COUNT = "ConsumerCount"; + String ATTR_ACTIVE_CONSUMER_COUNT = "ActiveConsumerCount"; + String ATTR_MSG_COUNT = "MessageCount"; + String ATTR_QUEUE_DEPTH = "QueueDepth"; + String ATTR_RCVD_MSG_COUNT = "ReceivedMessageCount"; + + //All attribute names constant + String[] QUEUE_ATTRIBUTES = new String[]{ + ATTR_NAME, + ATTR_OWNER, + ATTR_MAX_MSG_AGE, + ATTR_MAX_MSG_COUNT, + ATTR_MAX_QUEUE_DEPTH, + ATTR_MAX_MSG_SIZE, + ATTR_DURABLE, + ATTR_AUTODELETE, + ATTR_CONSUMER_COUNT, + ATTR_ACTIVE_CONSUMER_COUNT, + ATTR_MSG_COUNT, + ATTR_QUEUE_DEPTH, + ATTR_RCVD_MSG_COUNT + }; /** * Returns the Name of the ManagedQueue. diff --git a/java/management/common/src/test/java/org/apache/qpid/management/common/mbeans/ManagedQueueTest.java b/java/management/common/src/test/java/org/apache/qpid/management/common/mbeans/ManagedQueueTest.java new file mode 100644 index 0000000000..f449ecb7e5 --- /dev/null +++ b/java/management/common/src/test/java/org/apache/qpid/management/common/mbeans/ManagedQueueTest.java @@ -0,0 +1,84 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.qpid.management.common.mbeans; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.util.ArrayList; +import java.util.List; + +import javax.management.MBeanAttributeInfo; +import javax.management.NotCompliantMBeanException; +import javax.management.StandardMBean; + +import junit.framework.TestCase; + +public class ManagedQueueTest extends TestCase +{ + public void testAttributesContants() + { + //Construct a test MBeanInfo that matches what we would get from a real + //MBean using the ManagedQueue management interface. Use this to test + //that all attributes have a listing in the attribute array constant. + + StubInvocationHandler stubIH = new StubInvocationHandler(); + Class<ManagedQueue> mq = ManagedQueue.class; + + ManagedQueue impl = mq.cast(Proxy.newProxyInstance(mq.getClassLoader(), new Class<?>[] {mq}, stubIH)); + try + { + StandardMBean mbean = new StandardMBean(impl, ManagedQueue.class); + + List<String> attributeList = new ArrayList<String>(); + for(String attr : ManagedQueue.QUEUE_ATTRIBUTES) + { + attributeList.add(attr); + } + + //retrieve the attributes from the constructed MBeanInfo + MBeanAttributeInfo[] attributes = mbean.getMBeanInfo().getAttributes(); + + for(MBeanAttributeInfo info : attributes) + { + if(!attributeList.contains(info.getName())) + { + fail(mq.getSimpleName() + " attributes constant array does not include the attribute: " + info.getName()); + } + } + } + catch (NotCompliantMBeanException e) + { + fail("Unable to create the test proxy mbean to generate the MBeanInfo"); + } + + } + + private static class StubInvocationHandler implements InvocationHandler + { + //invocation handler used to present a stub implementation when generating the StandardMBean + public Object invoke(Object proxy, Method method, Object[] args) + { + return null; + } + } + +} |