activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1429064 - in /activemq/trunk: activemq-broker/src/main/java/org/apache/activemq/network/MBeanNetworkListener.java activemq-core/src/test/java/org/apache/activemq/network/FailoverStaticNetworkTest.java
Date Fri, 04 Jan 2013 19:53:47 GMT
Author: tabish
Date: Fri Jan  4 19:53:47 2013
New Revision: 1429064

URL: http://svn.apache.org/viewvc?rev=1429064&view=rev
Log:
code fix and test fix for: https://issues.apache.org/jira/browse/AMQ-4225

NetworkBridge MBeans weren't getting registered because of changes in the Broker MBean naming.

Modified:
    activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/network/MBeanNetworkListener.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/network/FailoverStaticNetworkTest.java

Modified: activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/network/MBeanNetworkListener.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/network/MBeanNetworkListener.java?rev=1429064&r1=1429063&r2=1429064&view=diff
==============================================================================
--- activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/network/MBeanNetworkListener.java
(original)
+++ activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/network/MBeanNetworkListener.java
Fri Jan  4 19:53:47 2013
@@ -83,9 +83,17 @@ public class MBeanNetworkListener implem
 
     protected ObjectName createNetworkBridgeObjectName(NetworkBridge bridge) throws MalformedObjectNameException
{
         Map<String, String> map = new HashMap<String, String>(connectorName.getKeyPropertyList());
-        return new ObjectName(connectorName.getDomain() + ":" + "BrokerName=" + JMXSupport.encodeObjectNamePart((String)
map.get("BrokerName")) + "," + "Type=NetworkBridge,"
-                              + "NetworkConnectorName=" + JMXSupport.encodeObjectNamePart((String)map.get("NetworkConnectorName"))
+ "," + "Name="
-                              + JMXSupport.encodeObjectNamePart(JMXSupport.encodeObjectNamePart(bridge.getRemoteAddress())));
+
+        StringBuilder objectNameStr = new StringBuilder();
+
+        objectNameStr.append(connectorName.getDomain()).append(":");
+        objectNameStr.append("type=Broker").append(",");
+        objectNameStr.append("brokerName=" + JMXSupport.encodeObjectNamePart(map.get("brokerName"))).append(",");
+        objectNameStr.append("service=NetworkBridge").append(",");
+        objectNameStr.append("networkConnectorName=" + JMXSupport.encodeObjectNamePart(map.get("networkConnectorName"))).append(",");
+        objectNameStr.append("networkBridgeName=" + JMXSupport.encodeObjectNamePart(bridge.getRemoteAddress()));
+
+        return new ObjectName(objectNameStr.toString());
     }
 
     public void setCreatedByDuplex(boolean createdByDuplex) {

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/network/FailoverStaticNetworkTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/network/FailoverStaticNetworkTest.java?rev=1429064&r1=1429063&r2=1429064&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/network/FailoverStaticNetworkTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/network/FailoverStaticNetworkTest.java
Fri Jan  4 19:53:47 2013
@@ -16,6 +16,9 @@
  */
 package org.apache.activemq.network;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -27,10 +30,6 @@ import java.util.concurrent.ExecutorServ
 import java.util.concurrent.Executors;
 import java.util.concurrent.atomic.AtomicBoolean;
 
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
 import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
 import javax.jms.JMSException;
@@ -51,17 +50,17 @@ import org.apache.activemq.transport.tcp
 import org.apache.activemq.util.IntrospectionSupport;
 import org.apache.activemq.util.JMXSupport;
 import org.apache.activemq.util.Wait;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class FailoverStaticNetworkTest {
     protected static final Logger LOG = LoggerFactory.getLogger(FailoverStaticNetworkTest.class);
 
-	private final static String DESTINATION_NAME = "testQ";
-	protected BrokerService brokerA;
+    private final static String DESTINATION_NAME = "testQ";
+    protected BrokerService brokerA;
     protected BrokerService brokerA1;
     protected BrokerService brokerB;
     protected BrokerService brokerC;
@@ -122,12 +121,12 @@ public class FailoverStaticNetworkTest {
         TrustManager[] tm = SslBrokerServiceTest.getTrustManager();
         sslContext = new SslContext(km, tm, null);
     }
-    
+
     @After
     public void tearDown() throws Exception {
         brokerB.stop();
         brokerB.waitUntilStopped();
-        
+
         brokerA.stop();
         brokerA.waitUntilStopped();
 
@@ -192,8 +191,8 @@ public class FailoverStaticNetworkTest {
     private Set<String> getNetworkBridgeMBeanName(BrokerService brokerB) throws Exception
{
         Set<String> names = new HashSet<String>();
         for (ObjectName objectName : brokerB.getManagementContext().queryNames(null, null))
{
-            if ("NetworkBridge".equals(objectName.getKeyProperty("Type"))) {
-                names.add(objectName.getKeyProperty("Name"));
+            if ("NetworkBridge".equals(objectName.getKeyProperty("service"))) {
+                names.add(objectName.getKeyProperty("networkBridgeName"));
             }
         }
         return names;
@@ -210,6 +209,7 @@ public class FailoverStaticNetworkTest {
         brokerA1 = slave;
         ExecutorService executor = Executors.newCachedThreadPool();
         executor.execute(new Runnable() {
+            @Override
             public void run() {
                 try {
                     slave.start();
@@ -253,6 +253,7 @@ public class FailoverStaticNetworkTest {
         brokerA1 = slave;
         ExecutorService executor = Executors.newCachedThreadPool();
         executor.execute(new Runnable() {
+            @Override
             public void run() {
                 try {
                     slave.start();
@@ -298,23 +299,23 @@ public class FailoverStaticNetworkTest {
      */
     @Test
     public void testSendReceive() throws Exception {
-              
+
         brokerA = createBroker("tcp", "61617", null);
-        brokerA.start();        
+        brokerA.start();
         brokerB = createBroker("tcp", "62617", new String[]{"61617","1111"});
         brokerB.start();
-  
+
         doTestNetworkSendReceive();
     }
 
     @Test
     public void testSendReceiveSsl() throws Exception {
-              
+
         brokerA = createBroker("ssl", "61617", null);
-        brokerA.start();        
+        brokerA.start();
         brokerB = createBroker("ssl", "62617", new String[]{"61617", "1111"});
         brokerB.start();
-  
+
         doTestNetworkSendReceive();
     }
 
@@ -415,7 +416,7 @@ public class FailoverStaticNetworkTest {
     private void doTestNetworkSendReceive(final BrokerService to, final BrokerService from)
throws Exception, JMSException {
 
         LOG.info("Creating Consumer on the networked broker ..." + from);
-        
+
         SslContext.setCurrentSslContext(sslContext);
         // Create a consumer on brokerA
         ConnectionFactory consFactory = createConnectionFactory(from);
@@ -428,13 +429,14 @@ public class FailoverStaticNetworkTest {
         LOG.info("publishing to " + to);
 
         sendMessageTo(destination, to);
-        
+
         boolean gotMessage = Wait.waitFor(new Wait.Condition() {
+            @Override
             public boolean isSatisified() throws Exception {
                 Message message = consumer.receive(5000);
                 LOG.info("from:  " + from.getBrokerObjectName().getKeyProperty("BrokerName")
+  ", received: " + message);
                 return message != null;
-            }      
+            }
         });
         try {
             consConn.close();
@@ -451,9 +453,9 @@ public class FailoverStaticNetworkTest {
         session.createProducer(destination).send(session.createTextMessage("Hi"));
         conn.close();
     }
-    
-    protected ConnectionFactory createConnectionFactory(final BrokerService broker) throws
Exception {    
-        String url = ((TransportConnector) broker.getTransportConnectors().get(0)).getServer().getConnectURI().toString();
+
+    protected ConnectionFactory createConnectionFactory(final BrokerService broker) throws
Exception {
+        String url = broker.getTransportConnectors().get(0).getServer().getConnectURI().toString();
         ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
         connectionFactory.setOptimizedMessageDispatch(true);
         connectionFactory.setDispatchAsync(false);



Mime
View raw message