activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r587927 - in /activemq/trunk/activemq-core/src/main/java/org/apache/activemq: broker/ network/ transport/discovery/ transport/discovery/multicast/ transport/discovery/rendezvous/ transport/discovery/simple/
Date Wed, 24 Oct 2007 16:53:57 GMT
Author: chirino
Date: Wed Oct 24 09:53:46 2007
New Revision: 587927

URL: http://svn.apache.org/viewvc?rev=587927&view=rev
Log:
Cleanup the leaky abstraction of the DiscoveryAgent.  see:
https://issues.apache.org/activemq/browse/AMQ-1477

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnector.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/DiscoveryNetworkConnector.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/DiscoveryAgent.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/multicast/MulticastDiscoveryAgent.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/rendezvous/RendezvousDiscoveryAgent.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/simple/SimpleDiscoveryAgent.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/simple/SimpleDiscoveryAgentFactory.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnector.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnector.java?rev=587927&r1=587926&r2=587927&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnector.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnector.java
Wed Oct 24 09:53:46 2007
@@ -229,7 +229,6 @@
         getServer().start();
         DiscoveryAgent da = getDiscoveryAgent();
         if (da != null) {
-            da.setBrokerName(getBrokerInfo().getBrokerName());
             da.registerService(getConnectUri().toString());
             da.start();
         }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/DiscoveryNetworkConnector.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/DiscoveryNetworkConnector.java?rev=587927&r1=587926&r2=587927&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/DiscoveryNetworkConnector.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/DiscoveryNetworkConnector.java
Wed Oct 24 09:53:46 2007
@@ -141,7 +141,6 @@
         this.discoveryAgent = discoveryAgent;
         if (discoveryAgent != null) {
             this.discoveryAgent.setDiscoveryListener(this);
-            this.discoveryAgent.setBrokerName(getBrokerName());
         }
     }
 

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/DiscoveryAgent.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/DiscoveryAgent.java?rev=587927&r1=587926&r2=587927&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/DiscoveryAgent.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/DiscoveryAgent.java
Wed Oct 24 09:53:46 2007
@@ -52,11 +52,5 @@
      * so that other listeners of this DiscoveryAgent can also be made aware of the failure.
      */
     void serviceFailed(DiscoveryEvent event) throws IOException;
-
-    String getGroup();    
-    
-    void setGroup(String group);
-
-    void setBrokerName(String brokerName);
     
 }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/multicast/MulticastDiscoveryAgent.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/multicast/MulticastDiscoveryAgent.java?rev=587927&r1=587926&r2=587927&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/multicast/MulticastDiscoveryAgent.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/multicast/MulticastDiscoveryAgent.java
Wed Oct 24 09:53:46 2007
@@ -160,7 +160,6 @@
     private boolean loopBackMode;
     private Map<String, RemoteBrokerData> brokersByService = new ConcurrentHashMap<String,
RemoteBrokerData>();
     private String group = "default";
-    private String brokerName;
     private URI discoveryURI;
     private InetAddress inetAddress;
     private SocketAddress sockAddress;
@@ -201,43 +200,6 @@
     }
 
     /**
-     * Get the group used for discovery
-     * 
-     * @return the group
-     */
-    public String getGroup() {
-        return group;
-    }
-
-    /**
-     * Set the group for discovery
-     * 
-     * @param group
-     */
-    public void setGroup(String group) {
-        this.group = group;
-    }
-
-    /**
-     * @return Returns the brokerName.
-     */
-    public String getBrokerName() {
-        return brokerName;
-    }
-
-    /**
-     * @param brokerName The brokerName to set.
-     */
-    public void setBrokerName(String brokerName) {
-        if (brokerName != null) {
-            brokerName = brokerName.replace('.', '-');
-            brokerName = brokerName.replace(':', '-');
-            brokerName = brokerName.replace('%', '-');
-            this.brokerName = brokerName;
-        }
-    }
-
-    /**
      * @return Returns the loopBackMode.
      */
     public boolean isLoopBackMode() {
@@ -299,9 +261,6 @@
             if (group == null || group.length() == 0) {
                 throw new IOException("You must specify a group to discover");
             }
-            if (brokerName == null || brokerName.length() == 0) {
-                LOG.warn("brokerName not set");
-            }
             String type = getType();
             if (!type.endsWith(".")) {
                 LOG.warn("The type '" + type + "' should end with '.' to be a valid Discovery
type");
@@ -369,15 +328,11 @@
                 if (payload.startsWith(ALIVE)) {
                     String brokerName = getBrokerName(payload.substring(ALIVE.length()));
                     String service = payload.substring(ALIVE.length() + brokerName.length()
+ 2);
-                    if (!brokerName.equals(this.brokerName)) {
-                        processAlive(brokerName, service);
-                    }
+                    processAlive(brokerName, service);
                 } else {
                     String brokerName = getBrokerName(payload.substring(DEAD.length()));
                     String service = payload.substring(DEAD.length() + brokerName.length()
+ 2);
-                    if (!brokerName.equals(this.brokerName)) {
-                        processDead(brokerName, service);
-                    }
+                    processDead(service);
                 }
             }
         }
@@ -398,7 +353,7 @@
         if (selfService != null) {
             String payload = getType();
             payload += started.get() ? ALIVE : DEAD;
-            payload += DELIMITER + brokerName + DELIMITER;
+            payload += DELIMITER + "localhost" + DELIMITER;
             payload += selfService;
             try {
                 byte[] data = payload.getBytes();
@@ -439,7 +394,7 @@
         }
     }
 
-    private void processDead(String brokerName, String service) {
+    private void processDead(String service) {
         if (!service.equals(selfService)) {
             RemoteBrokerData data = brokersByService.remove(service);
             if (data != null && !data.isFailed()) {
@@ -453,7 +408,7 @@
         for (Iterator<RemoteBrokerData> i = brokersByService.values().iterator(); i.hasNext();)
{
             RemoteBrokerData data = i.next();
             if (data.getLastHeartBeat() < expireTime) {
-                processDead(brokerName, data.service);
+                processDead(data.service);
             }
         }
     }
@@ -551,5 +506,9 @@
 
     public void setUseExponentialBackOff(boolean useExponentialBackOff) {
         this.useExponentialBackOff = useExponentialBackOff;
+    }
+
+    public void setGroup(String group) {
+        this.group = group;
     }
 }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/rendezvous/RendezvousDiscoveryAgent.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/rendezvous/RendezvousDiscoveryAgent.java?rev=587927&r1=587926&r2=587927&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/rendezvous/RendezvousDiscoveryAgent.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/rendezvous/RendezvousDiscoveryAgent.java
Wed Oct 24 09:53:46 2007
@@ -234,12 +234,4 @@
         // TODO: is there a way to notify the JmDNS that the service failed?
     }
 
-    /**
-     * @param brokerName
-     * @see org.apache.activemq.transport.discovery.DiscoveryAgent#setBrokerName(java.lang.String)
-     */
-    public void setBrokerName(String brokerName) {
-        // implementation of interface
-
-    }
 }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/simple/SimpleDiscoveryAgent.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/simple/SimpleDiscoveryAgent.java?rev=587927&r1=587926&r2=587927&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/simple/SimpleDiscoveryAgent.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/simple/SimpleDiscoveryAgent.java
Wed Oct 24 09:53:46 2007
@@ -41,7 +41,6 @@
     private long minConnectTime = 500;
     private DiscoveryListener listener;
     private String services[] = new String[] {};
-    private String group = "DEFAULT";
     private final AtomicBoolean running = new AtomicBoolean(false);
 
     class SimpleDiscoveryEvent extends DiscoveryEvent {
@@ -95,17 +94,6 @@
         for (int i = 0; i < services.length; i++) {
             this.services[i] = services[i].toString();
         }
-    }
-
-    public String getGroup() {
-        return group;
-    }
-
-    public void setGroup(String group) {
-        this.group = group;
-    }
-
-    public void setBrokerName(String brokerName) {
     }
 
     public void serviceFailed(DiscoveryEvent devent) throws IOException {

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/simple/SimpleDiscoveryAgentFactory.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/simple/SimpleDiscoveryAgentFactory.java?rev=587927&r1=587926&r2=587927&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/simple/SimpleDiscoveryAgentFactory.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/simple/SimpleDiscoveryAgentFactory.java
Wed Oct 24 09:53:46 2007
@@ -36,7 +36,6 @@
             Map options = data.getParameters();
 
             SimpleDiscoveryAgent rc = new SimpleDiscoveryAgent();
-            rc.setGroup(uri.getHost());
             IntrospectionSupport.setProperties(rc, options);
             rc.setServices(data.getComponents());
             



Mime
View raw message