activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r383972 - in /incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq: broker/ broker/ft/ network/ network/jms/ proxy/
Date Tue, 07 Mar 2006 19:25:06 GMT
Author: chirino
Date: Tue Mar  7 11:25:05 2006
New Revision: 383972

URL: http://svn.apache.org/viewcvs?rev=383972&view=rev
Log:
Support naming all the connectors so that JMX object names are easier to view.

Modified:
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnector.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterConnector.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/DemandSubscription.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/ForwardingBridge.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/NetworkConnector.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/JmsConnector.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/proxy/ProxyConnector.java

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java?rev=383972&r1=383971&r2=383972&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java
Tue Mar  7 11:25:05 2006
@@ -775,7 +775,8 @@
         	ObjectName objectName = new ObjectName(
             		managementContext.getJmxDomainName()+":"+
             		"BrokerName="+JMXSupport.encodeObjectNamePart(getBrokerName())+","+
-            		"Type=NetworkConnector"
+            		"Type=NetworkConnector,"+
+                    "NetworkConnectorName="+JMXSupport.encodeObjectNamePart(connector.getName())
             		);
             mbeanServer.registerMBean(view, objectName);
             registeredMBeanNames.add(objectName);
@@ -792,7 +793,8 @@
         	ObjectName objectName = new ObjectName(
             		managementContext.getJmxDomainName()+":"+
             		"BrokerName="+JMXSupport.encodeObjectNamePart(getBrokerName())+","+
-            		"Type=ProxyConnector"
+            		"Type=ProxyConnector,"+
+                    "ProxyConnectorName="+JMXSupport.encodeObjectNamePart(connector.getName())
             		);
             mbeanServer.registerMBean(view, objectName);
             registeredMBeanNames.add(objectName);
@@ -826,7 +828,8 @@
         	ObjectName objectName = new ObjectName(
             		managementContext.getJmxDomainName()+":"+
             		"BrokerName="+JMXSupport.encodeObjectNamePart(getBrokerName())+","+
-            		"Type=JmsConnector"
+            		"Type=JmsConnector,"+
+                    "JmsConnectorName="+JMXSupport.encodeObjectNamePart(connector.getName())
             		);
             mbeanServer.registerMBean(view, objectName);
             registeredMBeanNames.add(objectName);

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnector.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnector.java?rev=383972&r1=383971&r2=383972&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnector.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnector.java
Tue Mar  7 11:25:05 2006
@@ -63,6 +63,7 @@
     private ConnectorStatistics statistics = new ConnectorStatistics();
     private URI discoveryUri;
     private URI connectUri;
+    private String name;
 
 
     /**
@@ -86,12 +87,13 @@
      * Factory method to create a JMX managed version of this transport connector
      */
     public ManagedTransportConnector asManagedConnector(MBeanServer mbeanServer, ObjectName
connectorName) throws IOException, URISyntaxException {
-        ManagedTransportConnector rc = new ManagedTransportConnector(mbeanServer,connectorName,
 getBroker(), getServer());
+        ManagedTransportConnector rc = new ManagedTransportConnector(mbeanServer, connectorName,
 getBroker(), getServer());
         rc.setTaskRunnerFactory(getTaskRunnerFactory());
         rc.setUri(uri);
         rc.setConnectUri(connectUri);
         rc.setDiscoveryAgent(discoveryAgent);
         rc.setDiscoveryUri(discoveryUri);
+        rc.setName(name);
         return rc;
     }
     
@@ -110,10 +112,6 @@
         return server;
     }
 
-    public String getName() throws IOException, URISyntaxException {
-        return getServer().getConnectURI().toString();
-    }
-
     public Broker getBroker() {
         return broker;
     }
@@ -195,15 +193,13 @@
 
     public void start() throws Exception {
         getServer().start();
-        log.info("Accepting connection on: "+getServer().getConnectURI());
-
         DiscoveryAgent da = getDiscoveryAgent();
         if( da!=null ) {
             da.registerService(getConnectUri().toString());
             da.start();
         }
-
         this.statusDector.start();
+        log.info("Connector "+getName()+" Started");
     }
 
     public void stop() throws Exception {
@@ -220,6 +216,7 @@
             ss.stop(c);
         }
         ss.throwFirstException();
+        log.info("Connector "+getName()+" Stopped");
     }
 
     // Implementation methods
@@ -286,6 +283,16 @@
 
     public void onStopped(TransportConnection connection) {
         connections.remove(connection);
+    }
+
+    public String getName() {
+        if( name == null ) {
+            name = server.getConnectURI().toString();
+        }
+        return name;
+    }
+    public void setName(String name) {
+        this.name = name;
     }
 
 }

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterConnector.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterConnector.java?rev=383972&r1=383971&r2=383972&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterConnector.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterConnector.java
Tue Mar  7 11:25:05 2006
@@ -57,7 +57,7 @@
     private TransportConnector connector;
     private AtomicBoolean masterActive=new AtomicBoolean(false);
     private AtomicBoolean started=new AtomicBoolean(false);
-    IdGenerator idGenerator=new IdGenerator();
+    private final IdGenerator idGenerator=new IdGenerator();
 
     ConnectionInfo connectionInfo;
     SessionInfo sessionInfo;

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/DemandSubscription.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/DemandSubscription.java?rev=383972&r1=383971&r2=383972&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/DemandSubscription.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/DemandSubscription.java
Tue Mar  7 11:25:05 2006
@@ -17,13 +17,12 @@
 package org.apache.activemq.network;
 
 import java.util.Set;
-import org.apache.activemq.command.ActiveMQDestination;
+
 import org.apache.activemq.command.ConsumerId;
 import org.apache.activemq.command.ConsumerInfo;
+
 import edu.emory.mathcs.backport.java.util.concurrent.CopyOnWriteArraySet;
 import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicInteger;
-
-
 
 /**
  * Represents a network bridge interface

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/ForwardingBridge.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/ForwardingBridge.java?rev=383972&r1=383971&r2=383972&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/ForwardingBridge.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/ForwardingBridge.java
Tue Mar  7 11:25:05 2006
@@ -34,7 +34,6 @@
 import org.apache.activemq.command.ShutdownInfo;
 import org.apache.activemq.transport.DefaultTransportListener;
 import org.apache.activemq.transport.Transport;
-import org.apache.activemq.transport.TransportListener;
 import org.apache.activemq.util.IdGenerator;
 import org.apache.activemq.util.ServiceStopper;
 import org.apache.activemq.util.ServiceSupport;

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/NetworkConnector.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/NetworkConnector.java?rev=383972&r1=383971&r2=383972&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/NetworkConnector.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/NetworkConnector.java
Tue Mar  7 11:25:05 2006
@@ -81,6 +81,7 @@
             throw new IllegalStateException("You must configure the 'localURI' property");
         }
         this.discoveryAgent.start();
+        log.info("Network Connector "+getName()+" Started");
     }
 
     public void stop() throws Exception {
@@ -89,6 +90,7 @@
             Bridge bridge = (Bridge)i.next();
             bridge.stop();
         }
+        log.info("Network Connector "+getName()+" Stopped");
     }
 
     public void onServiceAdd(DiscoveryEvent event) {
@@ -228,6 +230,9 @@
      * @return Returns the name.
      */
     public String getName(){
+        if( name == null ) {
+            name = discoveryAgent.toString();
+        }
         return name;
     }
 
@@ -373,7 +378,7 @@
         if (conduitSubscriptions){
             if (dynamicOnly){
                 result = new ConduitBridge(localTransport, remoteTransport) {
-                    protected void serviceRemoteException(IOException error) {
+                    protected void serviceRemoteException(Exception error) {
                         super.serviceRemoteException(error);
                         try {
                             // Notify the discovery agent that the remote broker failed.
@@ -384,7 +389,7 @@
                 };
             }else {
                 result = new DurableConduitBridge(localTransport, remoteTransport) {
-                    protected void serviceRemoteException(IOException error) {
+                    protected void serviceRemoteException(Exception error) {
                         super.serviceRemoteException(error);
                         try {
                             // Notify the discovery agent that the remote broker failed.
@@ -396,7 +401,7 @@
             }
         }else {
          result = new DemandForwardingBridge(localTransport, remoteTransport) {
-            protected void serviceRemoteException(IOException error) {
+            protected void serviceRemoteException(Exception error) {
                 super.serviceRemoteException(error);
                 try {
                     // Notify the discovery agent that the remote broker failed.

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/JmsConnector.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/JmsConnector.java?rev=383972&r1=383971&r2=383972&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/JmsConnector.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/JmsConnector.java
Tue Mar  7 11:25:05 2006
@@ -19,10 +19,9 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+
 import javax.jms.Connection;
 import javax.jms.Destination;
-import javax.jms.Queue;
-import javax.jms.QueueConnection;
 
 import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.activemq.Service;
@@ -31,6 +30,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.springframework.jndi.JndiTemplate;
+
 import edu.emory.mathcs.backport.java.util.concurrent.CopyOnWriteArrayList;
 import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean;
 
@@ -41,6 +41,7 @@
  * @version $Revision: 1.1.1.1 $
  */
 public abstract class JmsConnector implements Service{
+    
     private static final Log log=LogFactory.getLog(JmsConnector.class);
     protected JndiTemplate jndiLocalTemplate;
     protected JndiTemplate jndiOutboundTemplate;
@@ -52,11 +53,18 @@
     protected AtomicBoolean started = new AtomicBoolean(false);
     protected ActiveMQConnectionFactory  embeddedConnectionFactory;
     protected int replyToDestinationCacheSize=10000;
-    protected  String outboundUsername;
+    protected String outboundUsername;
     protected String outboundPassword;
     protected String localUsername;
-    protected  String localPassword;
+    protected String localPassword;
+    private String name;
+    
     protected LRUCache replyToBridges=new LRUCache(){
+        /**
+         * 
+         */
+        private static final long serialVersionUID = -7446792754185879286L;
+
         protected boolean removeEldestEntry(Map.Entry enty){
             if(size()>maxCacheSize){
                 Iterator iter=entrySet().iterator();
@@ -97,14 +105,15 @@
     public void start() throws Exception{
         init();
         if (started.compareAndSet(false, true)){
-        for(int i=0;i<inboundBridges.size();i++){
-            DestinationBridge bridge=(DestinationBridge) inboundBridges.get(i);
-            bridge.start();
-        }
-        for(int i=0;i<outboundBridges.size();i++){
-            DestinationBridge bridge=(DestinationBridge) outboundBridges.get(i);
-            bridge.start();
-        }
+            for(int i=0;i<inboundBridges.size();i++){
+                DestinationBridge bridge=(DestinationBridge) inboundBridges.get(i);
+                bridge.start();
+            }
+            for(int i=0;i<outboundBridges.size();i++){
+                DestinationBridge bridge=(DestinationBridge) outboundBridges.get(i);
+                bridge.start();
+            }
+            log.info("JMS Connector "+getName()+" Started");
         }
     }
 
@@ -118,6 +127,7 @@
                 DestinationBridge bridge=(DestinationBridge) outboundBridges.get(i);
                 bridge.stop();
             }
+            log.info("JMS Connector "+getName()+" Stopped");
         }
     }
     
@@ -275,5 +285,21 @@
     
     protected void removeOutboundBridge(DestinationBridge bridge){
         outboundBridges.add(bridge);
+    }
+
+    public String getName() {
+        if( name == null ) {
+            name = "Connector:"+getNextId();
+        }
+        return name;
+    }
+    
+    static int nextId;
+    static private synchronized int getNextId() {
+        return nextId;
+    }
+
+    public void setName(String name) {
+        this.name = name;
     }
 }

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/proxy/ProxyConnector.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/proxy/ProxyConnector.java?rev=383972&r1=383971&r2=383972&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/proxy/ProxyConnector.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/proxy/ProxyConnector.java
Tue Mar  7 11:25:05 2006
@@ -46,6 +46,7 @@
     private URI bind;
     private URI remote;
     private URI localUri;
+    private String name;
     
     CopyOnWriteArrayList connections = new CopyOnWriteArrayList();
        
@@ -69,6 +70,7 @@
             }
         });
         getServer().start();
+        log.info("Proxy Connector "+getName()+" Started");
 
     }
 
@@ -82,6 +84,7 @@
 		   ss.stop((Service) iter.next());
 		}
         ss.throwFirstException();
+        log.info("Proxy Connector "+getName()+" Stopped");
     }
     
     // Properties
@@ -145,6 +148,17 @@
         	}
         };
         return transport;
+    }
+
+    public String getName() {
+        if( name == null ) {
+            name = server.getConnectURI().toString();
+        }
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
     }
 
 }



Mime
View raw message