activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject activemq git commit: https://issues.apache.org/jira/browse/AMQ-5656 - add support for selective mbean suppression; refactor a bit so we can support patterns and wildcards
Date Fri, 26 Jun 2015 10:56:46 GMT
Repository: activemq
Updated Branches:
  refs/heads/master 2c53dbcc6 -> 13c471cc1


https://issues.apache.org/jira/browse/AMQ-5656 - add support for selective mbean suppression;
refactor a bit so we can support patterns and wildcards


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/13c471cc
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/13c471cc
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/13c471cc

Branch: refs/heads/master
Commit: 13c471cc11f61a7589315c82597e01228874dfc3
Parents: 2c53dbc
Author: Dejan Bosanac <dejan@nighttale.net>
Authored: Fri Jun 26 12:56:27 2015 +0200
Committer: Dejan Bosanac <dejan@nighttale.net>
Committed: Fri Jun 26 12:56:37 2015 +0200

----------------------------------------------------------------------
 .../activemq/broker/jmx/ManagementContext.java  | 30 +++++---------------
 .../jmx/SelectiveMBeanRegistrationTest.java     |  5 +++-
 2 files changed, 11 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/13c471cc/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagementContext.java
----------------------------------------------------------------------
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 089e1df..b08d53c 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
@@ -95,7 +95,7 @@ public class ManagementContext implements Service {
     private boolean allowRemoteAddressInMBeanNames = true;
     private String brokerName;
     private String suppressMBean;
-    private List<Map.Entry<String,String>> suppressMBeanList;
+    private List<ObjectName> suppressMBeanList;
 
     public ManagementContext() {
         this(null);
@@ -106,7 +106,7 @@ public class ManagementContext implements Service {
     }
 
     @Override
-    public void start() throws IOException {
+    public void start() throws Exception {
         // lets force the MBeanServer to be created if needed
         if (started.compareAndSet(false, true)) {
 
@@ -168,27 +168,11 @@ public class ManagementContext implements Service {
         }
     }
 
-    private void populateMBeanSuppressionMap() {
+    private void populateMBeanSuppressionMap() throws Exception {
         if (suppressMBean != null) {
             suppressMBeanList = new LinkedList<>();
             for (String pair : suppressMBean.split(",")) {
-                final String[] keyValue = pair.split("=");
-                suppressMBeanList.add(new Map.Entry<String, String>() {
-                    @Override
-                    public String getKey() {
-                        return keyValue[0];
-                    }
-
-                    @Override
-                    public String getValue() {
-                        return keyValue[1];
-                    }
-
-                    @Override
-                    public String setValue(String value) {
-                        return null;
-                    }
-                });
+                suppressMBeanList.add(new ObjectName(jmxDomainName + ":*," + pair));
             }
         }
     }
@@ -293,7 +277,7 @@ public class ManagementContext implements Service {
      *
      * @return the MBeanServer
      */
-    protected MBeanServer getMBeanServer() {
+    public MBeanServer getMBeanServer() {
         if (this.beanServer == null) {
             this.beanServer = findMBeanServer();
         }
@@ -430,8 +414,8 @@ public class ManagementContext implements Service {
     private boolean isAllowedToRegister(ObjectName name) {
         boolean result = true;
         if (suppressMBean != null && suppressMBeanList != null) {
-            for (Map.Entry<String,String> attr : suppressMBeanList) {
-                if (attr.getValue().equals(name.getKeyProperty(attr.getKey()))) {
+            for (ObjectName attr : suppressMBeanList) {
+                if (attr.apply(name)) {
                     result = false;
                     break;
                 }

http://git-wip-us.apache.org/repos/asf/activemq/blob/13c471cc/activemq-unit-tests/src/test/java/org/apache/activemq/broker/jmx/SelectiveMBeanRegistrationTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/jmx/SelectiveMBeanRegistrationTest.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/jmx/SelectiveMBeanRegistrationTest.java
index 0f936a3..834e60c 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/jmx/SelectiveMBeanRegistrationTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/jmx/SelectiveMBeanRegistrationTest.java
@@ -61,7 +61,7 @@ public class SelectiveMBeanRegistrationTest  {
 
         ManagementContext managementContext = new ManagementContext();
         managementContext.setCreateConnector(false);
-        managementContext.setSuppressMBean("endpoint=dynamicProducer,endpoint=Consumer");
+        managementContext.setSuppressMBean("endpoint=dynamicProducer,endpoint=Consumer,destinationName=ActiveMQ.Advisory.*");
         brokerService.setManagementContext(managementContext);
 
         brokerService.start();
@@ -111,6 +111,9 @@ public class SelectiveMBeanRegistrationTest  {
         Set<ObjectInstance> mbeans = mbeanServer.queryMBeans(query, null);
         assertEquals(0, mbeans.size());
 
+        query = new ObjectName(domain + ":type=Broker,brokerName=localhost,destinationName=ActiveMQ.Advisory.*,*");
+        mbeans = mbeanServer.queryMBeans(query, null);
+        assertEquals(0, mbeans.size());
     }
 
 


Mime
View raw message