activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [1/2] activemq-artemis git commit: ARTEMIS-953 Refactor JMX ObjectNames
Date Wed, 08 Feb 2017 23:12:27 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/master ede37f5cd -> 53673702f


ARTEMIS-953 Refactor JMX ObjectNames


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

Branch: refs/heads/master
Commit: 2bda3b2b4fca2e08d83234a6ded3c35c288d2b00
Parents: ede37f5
Author: Justin Bertram <jbertram@apache.org>
Authored: Wed Feb 8 13:40:04 2017 -0600
Committer: Justin Bertram <jbertram@apache.org>
Committed: Wed Feb 8 15:00:20 2017 -0600

----------------------------------------------------------------------
 .../api/core/management/ObjectNameBuilder.java  | 73 +++-----------------
 .../api/core/management/ResourceNames.java      |  2 -
 .../management/ActiveMQServerControlTest.java   | 16 ++---
 3 files changed, 18 insertions(+), 73 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bda3b2b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ObjectNameBuilder.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ObjectNameBuilder.java
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ObjectNameBuilder.java
index 00a95e1..3ebf564 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ObjectNameBuilder.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ObjectNameBuilder.java
@@ -82,7 +82,7 @@ public final class ObjectNameBuilder {
     * Returns the ObjectName used by the single {@link ActiveMQServerControl}.
     */
    public ObjectName getActiveMQServerObjectName() throws Exception {
-      return ObjectName.getInstance(domain + ":" + getBrokerProperties() + getObjectType()
+ "=Broker");
+      return ObjectName.getInstance(domain + ":" + getBrokerProperties());
    }
 
    /**
@@ -91,7 +91,7 @@ public final class ObjectNameBuilder {
     * @see AddressControl
     */
    public ObjectName getAddressObjectName(final SimpleString address) throws Exception {
-      return createObjectName("Address", address.toString());
+      return ObjectName.getInstance(String.format("%s:broker=%s,component=addresses,address=%s",
domain, ObjectName.quote(brokerName), ObjectName.quote(address.toString())));
    }
 
    /**
@@ -100,16 +100,7 @@ public final class ObjectNameBuilder {
     * @see QueueControl
     */
    public ObjectName getQueueObjectName(final SimpleString address, final SimpleString name,
RoutingType routingType) throws Exception {
-      return ObjectName.getInstance(String.format("%s:" + getBrokerProperties() + "parentType=%s,parentName=%s,"
+ getObjectType() + "=%s, routingType=%s,name=%s", domain, "Address", ObjectName.quote(address.toString()),
"Queue", routingType.toString(), ObjectName.quote(name.toString())));
-   }
-
-   /**
-    * Returns the ObjectName used by QueueControl.
-    *
-    * @see QueueControl
-    */
-   public ObjectName getQueueObjectName(final SimpleString address, final SimpleString name)
throws Exception {
-      return ObjectName.getInstance(String.format("%s:" + getBrokerProperties() + "parentType=%s,parentName=%s,"
+ getObjectType() + "=%s, routingType=%s,name=%s", domain, "Address", ObjectName.quote(address.toString()),
"Queue", ActiveMQDefaultConfiguration.getDefaultRoutingType(), ObjectName.quote(name.toString())));
+      return ObjectName.getInstance(String.format("%s:broker=%s,component=addresses,address=%s,subcomponent=queues,routingType=%s,queue=%s",
domain, ObjectName.quote(brokerName), ObjectName.quote(address.toString()), ObjectName.quote(routingType.toString().toLowerCase()),
ObjectName.quote(name.toString())));
    }
 
 
@@ -119,7 +110,7 @@ public final class ObjectNameBuilder {
     * @see DivertControl
     */
    public ObjectName getDivertObjectName(final String name, String address) throws Exception
{
-      return ObjectName.getInstance(String.format("%s:" + getBrokerProperties() + "parentType=%s,parentName=%s,"
+ getObjectType() + "=%s,name=%s", domain, "Address", ObjectName.quote(address.toString()),
"Divert", ObjectName.quote(name.toString())));
+      return ObjectName.getInstance(String.format("%s:broker=%s,component=addresses,address=%s,subcomponent=diverts,divert=%s",
domain, ObjectName.quote(brokerName), ObjectName.quote(address.toString()), ObjectName.quote(name.toString())));
    }
 
    /**
@@ -128,7 +119,7 @@ public final class ObjectNameBuilder {
     * @see AcceptorControl
     */
    public ObjectName getAcceptorObjectName(final String name) throws Exception {
-      return createObjectName("Acceptor", name);
+      return createObjectName("acceptor", name);
    }
 
    /**
@@ -137,7 +128,7 @@ public final class ObjectNameBuilder {
     * @see BroadcastGroupControl
     */
    public ObjectName getBroadcastGroupObjectName(final String name) throws Exception {
-      return createObjectName("BroadcastGroup", name);
+      return createObjectName("broadcast-group", name);
    }
 
    /**
@@ -146,7 +137,7 @@ public final class ObjectNameBuilder {
     * @see BridgeControl
     */
    public ObjectName getBridgeObjectName(final String name) throws Exception {
-      return createObjectName("Bridge", name);
+      return createObjectName("bridge", name);
    }
 
    /**
@@ -155,62 +146,18 @@ public final class ObjectNameBuilder {
     * @see ClusterConnectionControl
     */
    public ObjectName getClusterConnectionObjectName(final String name) throws Exception {
-      return createObjectName("ClusterConnection", name);
-   }
-
-   /**
-    * Returns the ObjectName used by DiscoveryGroupControl.
-    */
-   public ObjectName getDiscoveryGroupObjectName(final String name) throws Exception {
-      return createObjectName("DiscoveryGroup", name);
-   }
-
-   /**
-    * Returns the ObjectName used by JMSServerControl.
-    */
-   public ObjectName getJMSServerObjectName() throws Exception {
-      return ObjectName.getInstance(domain + ":" + getBrokerProperties() + "module=JMS,"
+ getObjectType() + "=Server");
-   }
-
-   /**
-    * Returns the ObjectName used by JMSQueueControl.
-    */
-   public ObjectName getJMSQueueObjectName(final String name) throws Exception {
-      return getQueueObjectName(SimpleString.toSimpleString(name), SimpleString.toSimpleString(name),
RoutingType.ANYCAST);
-   }
-
-   /**
-    * Returns the ObjectName used by TopicControl.
-    */
-   public ObjectName getJMSTopicObjectName(final String name) throws Exception {
-      return createObjectName("Topic", name);
-   }
-
-   /**
-    * Returns the ObjectName used by ConnectionFactoryControl.
-    */
-   public ObjectName getConnectionFactoryObjectName(final String name) throws Exception {
-      return createObjectName("ConnectionFactory", name);
+      return createObjectName("cluster-connection", name);
    }
 
    private ObjectName createObjectName(final String type, final String name) throws Exception
{
-      String format = String.format("%s:" + getBrokerProperties() + getObjectType() + "=%s,name=%s",
domain, type, ObjectName.quote(name));
-      return ObjectName.getInstance(format);
+      return ObjectName.getInstance(String.format("%s:broker=%s,component=%ss,name=%s", domain,
ObjectName.quote(brokerName), type, ObjectName.quote(name)));
    }
 
    private String getBrokerProperties() {
       if (jmxUseBrokerName && brokerName != null) {
-         return String.format("type=Broker,brokerName=%s,", ObjectName.quote(brokerName));
+         return String.format("broker=%s", ObjectName.quote(brokerName));
       } else {
          return "";
       }
    }
-
-   private String getObjectType() {
-      if (jmxUseBrokerName && brokerName != null) {
-         return "serviceType";
-      } else {
-         return "type";
-      }
-   }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bda3b2b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ResourceNames.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ResourceNames.java
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ResourceNames.java
index 574cada..377c234 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ResourceNames.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ResourceNames.java
@@ -39,8 +39,6 @@ public final class ResourceNames {
 
    public static final String BROADCAST_GROUP = "broadcastgroup.";
 
-   public static final String DISCOVERY_GROUP = "discovery.";
-
    private ResourceNames() {
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2bda3b2b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java
index 2b09cad..ebdd80e 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java
@@ -200,7 +200,7 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
 
       serverControl.destroyQueue(name.toString());
 
-      checkNoResource(ObjectNameBuilder.DEFAULT.getQueueObjectName(address, name));
+      checkNoResource(ObjectNameBuilder.DEFAULT.getQueueObjectName(address, name, RoutingType.ANYCAST));
    }
 
    @Test
@@ -226,7 +226,7 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
 
       serverControl.destroyQueue(name.toString());
 
-      checkNoResource(ObjectNameBuilder.DEFAULT.getQueueObjectName(address, name));
+      checkNoResource(ObjectNameBuilder.DEFAULT.getQueueObjectName(address, name, RoutingType.ANYCAST));
    }
 
    @Test
@@ -251,7 +251,7 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
 
       serverControl.destroyQueue(name.toString());
 
-      checkNoResource(ObjectNameBuilder.DEFAULT.getQueueObjectName(address, name));
+      checkNoResource(ObjectNameBuilder.DEFAULT.getQueueObjectName(address, name, RoutingType.ANYCAST));
    }
 
    @Test
@@ -285,7 +285,7 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
 
       serverControl.destroyQueue(name.toString(), true, true);
 
-      checkNoResource(ObjectNameBuilder.DEFAULT.getQueueObjectName(address, name));
+      checkNoResource(ObjectNameBuilder.DEFAULT.getQueueObjectName(address, name, RoutingType.ANYCAST));
       checkNoResource(ObjectNameBuilder.DEFAULT.getAddressObjectName(address));
    }
 
@@ -297,7 +297,7 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
 
       ActiveMQServerControl serverControl = createManagementControl();
 
-      checkNoResource(ObjectNameBuilder.DEFAULT.getQueueObjectName(address, name));
+      checkNoResource(ObjectNameBuilder.DEFAULT.getQueueObjectName(address, name, RoutingType.ANYCAST));
       serverControl.createAddress(address.toString(), "ANYCAST");
       serverControl.createQueue(address.toString(), "ANYCAST", name.toString(), null, durable,
-1, false, false);
 
@@ -318,7 +318,7 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
       }, 1000, 100);
       Assert.assertTrue(consumer.isClosed());
 
-      checkNoResource(ObjectNameBuilder.DEFAULT.getQueueObjectName(address, name));
+      checkNoResource(ObjectNameBuilder.DEFAULT.getQueueObjectName(address, name, RoutingType.ANYCAST));
    }
 
    @Test
@@ -344,7 +344,7 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
 
       serverControl.destroyQueue(name.toString());
 
-      checkNoResource(ObjectNameBuilder.DEFAULT.getQueueObjectName(address, name));
+      checkNoResource(ObjectNameBuilder.DEFAULT.getQueueObjectName(address, name, RoutingType.ANYCAST));
    }
 
    @Test
@@ -370,7 +370,7 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
 
       serverControl.destroyQueue(name.toString());
 
-      checkNoResource(ObjectNameBuilder.DEFAULT.getQueueObjectName(address, name));
+      checkNoResource(ObjectNameBuilder.DEFAULT.getQueueObjectName(address, name, RoutingType.ANYCAST));
    }
 
    @Test


Mime
View raw message