activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r1431369 - in /activemq/trunk: activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ activemq-core/src/test/java/org/apache/activemq/broker/jmx/
Date Thu, 10 Jan 2013 14:04:41 GMT
Author: gtully
Date: Thu Jan 10 14:04:40 2013
New Revision: 1431369

URL: http://svn.apache.org/viewvc?rev=1431369&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-3438 - keep both mbean names, by remoteaddress and
by clientid - as navigation between subs and connections uses the clientid but remote connection
info based on address has real value to opts. https://issues.apache.org/jira/browse/AMQ-4237
- partition both address types using connectionViewType=remoteAddress|clientId  and add clientId
to connetionView - now easier to see connections under a clientConnector

Modified:
    activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/BrokerMBeanSuppurt.java
    activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectionView.java
    activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectionViewMBean.java
    activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagedTransportConnection.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/jmx/TransportConnectorMBeanTest.java

Modified: activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/BrokerMBeanSuppurt.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/BrokerMBeanSuppurt.java?rev=1431369&r1=1431368&r2=1431369&view=diff
==============================================================================
--- activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/BrokerMBeanSuppurt.java
(original)
+++ activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/BrokerMBeanSuppurt.java
Thu Jan 10 14:04:40 2013
@@ -151,16 +151,10 @@ public class BrokerMBeanSuppurt {
         return objectName;
     }
 
-    public static ObjectName createConnectionViewByAddressName(ObjectName connectorName,
String type, String address) throws MalformedObjectNameException {
+    public static ObjectName createConnectionViewByType(ObjectName connectorName, String
type, String name) throws MalformedObjectNameException {
         String objectNameStr = connectorName.toString();
         objectNameStr += ",connectionViewType=" + JMXSupport.encodeObjectNamePart(type);
-        objectNameStr += ",connectionName="+ JMXSupport.encodeObjectNamePart(address);
-        return new ObjectName(objectNameStr);
-    }
-
-    public static ObjectName createConnectionViewByClientIdName(ObjectName connectorName,
String clientId) throws MalformedObjectNameException {
-        String objectNameStr = connectorName.toString();
-        objectNameStr += ",connectionName="+JMXSupport.encodeObjectNamePart(clientId);
+        objectNameStr += ",connectionName="+ JMXSupport.encodeObjectNamePart(name);
         return new ObjectName(objectNameStr);
     }
 
@@ -216,11 +210,11 @@ public class BrokerMBeanSuppurt {
 
     // MBean Query Creation
 
-    public static ObjectName createConnectionQuery(String jmxDomainName, String brokerName,
String clientId) throws MalformedObjectNameException {
+    public static ObjectName createConnectionQuery(String jmxDomainName, String brokerName,
String name) throws MalformedObjectNameException {
         return new ObjectName(jmxDomainName + ":type=Broker,brokerName="
                               + JMXSupport.encodeObjectNamePart(brokerName) + ","
-                              + "connector=*," + "connectorName=*,"
-                              + "connectionName=" + JMXSupport.encodeObjectNamePart(clientId));
+                              + "connector=*," + "connectorName=*," + "connectionViewType=*,"
+                              + "connectionName=" + JMXSupport.encodeObjectNamePart(name));
     }
 
     public static ObjectName createConsumerQueury(String jmxDomainName, String clientId)
throws MalformedObjectNameException {

Modified: activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectionView.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectionView.java?rev=1431369&r1=1431368&r2=1431369&view=diff
==============================================================================
--- activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectionView.java
(original)
+++ activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectionView.java
Thu Jan 10 14:04:40 2013
@@ -99,6 +99,11 @@ public class ConnectionView implements C
         return connection.getRemoteAddress();
     }
 
+    @Override
+    public String getClientId() {
+        return connection.getConnectionId();
+    }
+
     public String getConnectionId() {
         return connection.getConnectionId();
     }

Modified: activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectionViewMBean.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectionViewMBean.java?rev=1431369&r1=1431368&r2=1431369&view=diff
==============================================================================
--- activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectionViewMBean.java
(original)
+++ activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ConnectionViewMBean.java
Thu Jan 10 14:04:40 2013
@@ -56,10 +56,18 @@ public interface ConnectionViewMBean ext
      *
      * @return the source address for this connection
      */
-    @MBeanInfo("Source address for this connection")
+    @MBeanInfo("source address for this connection")
     String getRemoteAddress();
 
     /**
+     * Returns the client identifier for this connection
+     *
+     * @return the the client identifier for this connection
+     */
+    @MBeanInfo("client id for this connection")
+    String getClientId();
+
+    /**
      * Returns the number of messages to be dispatched to this connection
      * @return the  number of messages pending dispatch
      */

Modified: activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagedTransportConnection.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagedTransportConnection.java?rev=1431369&r1=1431368&r2=1431369&view=diff
==============================================================================
--- activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagedTransportConnection.java
(original)
+++ activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ManagedTransportConnection.java
Thu Jan 10 14:04:40 2013
@@ -56,7 +56,7 @@ public class ManagedTransportConnection 
         this.mbean = new ConnectionView(this, managementContext);
         this.populateUserName = broker.getBrokerService().isPopulateUserNameInMBeans();
         if (managementContext.isAllowRemoteAddressInMBeanNames()) {
-            byAddressName = createByAddressObjectName("address", transport.getRemoteAddress());
+            byAddressName = createObjectName("remoteAddress", transport.getRemoteAddress());
             registerMBean(byAddressName);
         }
     }
@@ -81,12 +81,10 @@ public class ManagedTransportConnection 
         if (populateUserName) {
             ((ConnectionView) mbean).setUserName(info.getUserName());
         }
-        if (!managementContext.isAllowRemoteAddressInMBeanNames()) {
-            if (clientId != null) {
-                if (byClientIdName == null) {
-                    byClientIdName = createByClientIdObjectName(clientId);
-                    registerMBean(byClientIdName);
-                }
+        if (clientId != null) {
+            if (byClientIdName == null) {
+                byClientIdName = createObjectName("clientId", clientId);
+                registerMBean(byClientIdName);
             }
         }
         return answer;
@@ -116,19 +114,12 @@ public class ManagedTransportConnection 
         }
     }
 
-    protected ObjectName createByAddressObjectName(String type, String value) throws IOException
{
+    protected ObjectName createObjectName(String type, String value) throws IOException {
         try {
-            return BrokerMBeanSuppurt.createConnectionViewByAddressName(connectorName, type,
value);
+            return BrokerMBeanSuppurt.createConnectionViewByType(connectorName, type, value);
         } catch (Throwable e) {
             throw IOExceptionSupport.create(e);
         }
     }
 
-    protected ObjectName createByClientIdObjectName(String value) throws IOException {
-        try {
-            return BrokerMBeanSuppurt.createConnectionViewByClientIdName(connectorName, value);
-        } catch (Throwable e) {
-            throw IOExceptionSupport.create(e);
-        }
-    }
 }

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java?rev=1431369&r1=1431368&r2=1431369&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java
Thu Jan 10 14:04:40 2013
@@ -678,7 +678,8 @@ public class MBeanTest extends EmbeddedB
         bindAddress = "tcp://localhost:0";
         useTopic = false;
         super.setUp();
-        mbeanServer = broker.getManagementContext().getMBeanServer();
+        ManagementContext managementContext = broker.getManagementContext();
+        mbeanServer = managementContext.getMBeanServer();
     }
 
     protected void tearDown() throws Exception {
@@ -953,6 +954,8 @@ public class MBeanTest extends EmbeddedB
         // Our consumer plus one advisory consumer.
         assertEquals(2, connectionView.getConsumers().length);
 
+        assertEquals("client id match", "MBeanTest", connectionView.getClientId());
+
         // Check that the subscription view we found earlier is in this list.
         boolean found = false;
         for (ObjectName name : connectionView.getConsumers()) {
@@ -1077,7 +1080,8 @@ public class MBeanTest extends EmbeddedB
                 assertNull(subscriberView.getUserName());
             }
         }
-        ObjectName query = new ObjectName(domain + ":type=Broker,brokerName=localhost,connector=*,"
+ "connectorName=*,connectionName=MBeanTest");
+        ObjectName query = //new ObjectName(domain + ":type=Broker,brokerName=localhost,connector=*,"
+ "connectorName=*,connectionName=MBeanTest");
+            BrokerMBeanSuppurt.createConnectionQuery(domain, "localhost", connection.getClientID());
 
         Set<ObjectName> names = mbeanServer.queryNames(query, null);
         boolean found = false;

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/jmx/TransportConnectorMBeanTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/jmx/TransportConnectorMBeanTest.java?rev=1431369&r1=1431368&r2=1431369&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/jmx/TransportConnectorMBeanTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/jmx/TransportConnectorMBeanTest.java
Thu Jan 10 14:04:40 2013
@@ -50,7 +50,7 @@ public class TransportConnectorMBeanTest
         createBroker(allowRemoteAddress);
         ActiveMQConnection connection = createConnection();
         Set<ObjectName> registeredMbeans = getRegisteredMbeans();
-        assertEquals("presence of mbean with clientId", !allowRemoteAddress, match(connection.getClientID(),
registeredMbeans));
+        assertEquals("presence of mbean with clientId", true, match(connection.getClientID(),
registeredMbeans));
         assertEquals("presence of mbean with local port", allowRemoteAddress, match(extractLocalPort(connection),
registeredMbeans));
     }
 



Mime
View raw message