From 49974279a745604d1028a78426985d438fc3762c Mon Sep 17 00:00:00 2001 From: Jeff Genender Date: Thu, 18 Feb 2016 14:25:30 -0700 Subject: [PATCH] AMQ-6175 - Web console needs to only obtain lists of MBeans that are not suppressed. --- .../activemq/broker/jmx/BrokerView.java | 30 ++++---- .../broker/jmx/ManagedRegionBroker.java | 75 ++++++++++++++++++- .../broker/jmx/ManagementContext.java | 2 +- 3 files changed, 87 insertions(+), 20 deletions(-) diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java index d9bbcfea3d..55fb9bd50d 100755 --- a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java +++ b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java @@ -280,77 +280,77 @@ public class BrokerView implements BrokerViewMBean { @Override public ObjectName[] getTopics() { - return safeGetBroker().getTopics(); + return safeGetBroker().getTopicsNonSuppressed(); } @Override public ObjectName[] getQueues() { - return safeGetBroker().getQueues(); + return safeGetBroker().getQueuesNonSuppressed(); } @Override public ObjectName[] getTemporaryTopics() { - return safeGetBroker().getTemporaryTopics(); + return safeGetBroker().getTemporaryTopicsNonSuppressed(); } @Override public ObjectName[] getTemporaryQueues() { - return safeGetBroker().getTemporaryQueues(); + return safeGetBroker().getTemporaryQueuesNonSuppressed(); } @Override public ObjectName[] getTopicSubscribers() { - return safeGetBroker().getTopicSubscribers(); + return safeGetBroker().getTopicSubscribersNonSuppressed(); } @Override public ObjectName[] getDurableTopicSubscribers() { - return safeGetBroker().getDurableTopicSubscribers(); + return safeGetBroker().getDurableTopicSubscribersNonSuppressed(); } @Override public ObjectName[] getQueueSubscribers() { - return safeGetBroker().getQueueSubscribers(); + return safeGetBroker().getQueueSubscribersNonSuppressed(); } @Override public ObjectName[] getTemporaryTopicSubscribers() { - return safeGetBroker().getTemporaryTopicSubscribers(); + return safeGetBroker().getTemporaryTopicSubscribersNonSuppressed(); } @Override public ObjectName[] getTemporaryQueueSubscribers() { - return safeGetBroker().getTemporaryQueueSubscribers(); + return safeGetBroker().getTemporaryQueueSubscribersNonSuppressed(); } @Override public ObjectName[] getInactiveDurableTopicSubscribers() { - return safeGetBroker().getInactiveDurableTopicSubscribers(); + return safeGetBroker().getInactiveDurableTopicSubscribersNonSuppressed(); } @Override public ObjectName[] getTopicProducers() { - return safeGetBroker().getTopicProducers(); + return safeGetBroker().getTopicProducersNonSuppressed(); } @Override public ObjectName[] getQueueProducers() { - return safeGetBroker().getQueueProducers(); + return safeGetBroker().getQueueProducersNonSuppressed(); } @Override public ObjectName[] getTemporaryTopicProducers() { - return safeGetBroker().getTemporaryTopicProducers(); + return safeGetBroker().getTemporaryTopicProducersNonSuppressed(); } @Override public ObjectName[] getTemporaryQueueProducers() { - return safeGetBroker().getTemporaryQueueProducers(); + return safeGetBroker().getTemporaryQueueProducersNonSuppressed(); } @Override public ObjectName[] getDynamicDestinationProducers() { - return safeGetBroker().getDynamicDestinationProducers(); + return safeGetBroker().getDynamicDestinationProducersNonSuppressed(); } @Override diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java index 601fd15962..ddd1a1745f 100755 --- a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java +++ b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagedRegionBroker.java @@ -17,11 +17,8 @@ package org.apache.activemq.broker.jmx; import java.io.IOException; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; +import java.util.*; import java.util.Map.Entry; -import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.ExecutorService; @@ -607,81 +604,151 @@ public class ManagedRegionBroker extends RegionBroker { return destination; } + private ObjectName[] onlyNonSuppressed (Set set){ + List nonSuppressed = new ArrayList(); + for(ObjectName key : set){ + if (managementContext.isAllowedToRegister(key)){ + nonSuppressed.add(key); + } + } + return nonSuppressed.toArray(new ObjectName[nonSuppressed.size()]); + } + protected ObjectName[] getTopics() { Set set = topics.keySet(); return set.toArray(new ObjectName[set.size()]); } + protected ObjectName[] getTopicsNonSuppressed() { + return onlyNonSuppressed(topics.keySet()); + } + protected ObjectName[] getQueues() { Set set = queues.keySet(); return set.toArray(new ObjectName[set.size()]); } + protected ObjectName[] getQueuesNonSuppressed() { + return onlyNonSuppressed(queues.keySet()); + } + protected ObjectName[] getTemporaryTopics() { Set set = temporaryTopics.keySet(); return set.toArray(new ObjectName[set.size()]); } + protected ObjectName[] getTemporaryTopicsNonSuppressed() { + return onlyNonSuppressed(temporaryTopics.keySet()); + } + protected ObjectName[] getTemporaryQueues() { Set set = temporaryQueues.keySet(); return set.toArray(new ObjectName[set.size()]); } + protected ObjectName[] getTemporaryQueuesNonSuppressed() { + return onlyNonSuppressed(temporaryQueues.keySet()); + } + protected ObjectName[] getTopicSubscribers() { Set set = topicSubscribers.keySet(); return set.toArray(new ObjectName[set.size()]); } + protected ObjectName[] getTopicSubscribersNonSuppressed() { + return onlyNonSuppressed(topicSubscribers.keySet()); + } + protected ObjectName[] getDurableTopicSubscribers() { Set set = durableTopicSubscribers.keySet(); return set.toArray(new ObjectName[set.size()]); } + protected ObjectName[] getDurableTopicSubscribersNonSuppressed() { + return onlyNonSuppressed(durableTopicSubscribers.keySet()); + } + protected ObjectName[] getQueueSubscribers() { Set set = queueSubscribers.keySet(); return set.toArray(new ObjectName[set.size()]); } + protected ObjectName[] getQueueSubscribersNonSuppressed() { + return onlyNonSuppressed(queueSubscribers.keySet()); + } + protected ObjectName[] getTemporaryTopicSubscribers() { Set set = temporaryTopicSubscribers.keySet(); return set.toArray(new ObjectName[set.size()]); } + protected ObjectName[] getTemporaryTopicSubscribersNonSuppressed() { + return onlyNonSuppressed(temporaryTopicSubscribers.keySet()); + } + protected ObjectName[] getTemporaryQueueSubscribers() { Set set = temporaryQueueSubscribers.keySet(); return set.toArray(new ObjectName[set.size()]); } + protected ObjectName[] getTemporaryQueueSubscribersNonSuppressed() { + return onlyNonSuppressed(temporaryQueueSubscribers.keySet()); + } + protected ObjectName[] getInactiveDurableTopicSubscribers() { Set set = inactiveDurableTopicSubscribers.keySet(); return set.toArray(new ObjectName[set.size()]); } + protected ObjectName[] getInactiveDurableTopicSubscribersNonSuppressed() { + return onlyNonSuppressed(inactiveDurableTopicSubscribers.keySet()); + } + protected ObjectName[] getTopicProducers() { Set set = topicProducers.keySet(); return set.toArray(new ObjectName[set.size()]); } + protected ObjectName[] getTopicProducersNonSuppressed() { + return onlyNonSuppressed(topicProducers.keySet()); + } + protected ObjectName[] getQueueProducers() { Set set = queueProducers.keySet(); return set.toArray(new ObjectName[set.size()]); } + protected ObjectName[] getQueueProducersNonSuppressed() { + return onlyNonSuppressed(queueProducers.keySet()); + } + protected ObjectName[] getTemporaryTopicProducers() { Set set = temporaryTopicProducers.keySet(); return set.toArray(new ObjectName[set.size()]); } + protected ObjectName[] getTemporaryTopicProducersNonSuppressed() { + return onlyNonSuppressed(temporaryTopicProducers.keySet()); + } + protected ObjectName[] getTemporaryQueueProducers() { Set set = temporaryQueueProducers.keySet(); return set.toArray(new ObjectName[set.size()]); } + protected ObjectName[] getTemporaryQueueProducersNonSuppressed() { + return onlyNonSuppressed(temporaryQueueProducers.keySet()); + } + protected ObjectName[] getDynamicDestinationProducers() { Set set = dynamicDestinationProducers.keySet(); return set.toArray(new ObjectName[set.size()]); } + protected ObjectName[] getDynamicDestinationProducersNonSuppressed() { + return onlyNonSuppressed(dynamicDestinationProducers.keySet()); + } + public Broker getContextBroker() { return contextBroker; } diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagementContext.java b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagementContext.java index 907c0e6ccc..b83ec9b197 100644 --- a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagementContext.java +++ b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagementContext.java @@ -411,7 +411,7 @@ public class ManagementContext implements Service { return result; } - private boolean isAllowedToRegister(ObjectName name) { + protected boolean isAllowedToRegister(ObjectName name) { boolean result = true; if (suppressMBean != null && suppressMBeanList != null) { for (ObjectName attr : suppressMBeanList) {