activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r692340 - in /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/multicast: MulticastDiscoveryAgent.java MulticastDiscoveryAgentFactory.java
Date Fri, 05 Sep 2008 05:47:40 GMT
Author: rajdavies
Date: Thu Sep  4 22:47:40 2008
New Revision: 692340

URL: http://svn.apache.org/viewvc?rev=692340&view=rev
Log:
Apply patch for https://issues.apache.org/activemq/browse/AMQ-1489

Modified:
    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/multicast/MulticastDiscoveryAgentFactory.java

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=692340&r1=692339&r2=692340&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
Thu Sep  4 22:47:40 2008
@@ -49,6 +49,11 @@
 public class MulticastDiscoveryAgent implements DiscoveryAgent, Runnable {
 
     public static final String DEFAULT_DISCOVERY_URI_STRING = "multicast://239.255.2.3:6155";
+    public static final String DEFAULT_HOST_STR = "default"; 
+    public static final String DEFAULT_HOST_IP  = "239.255.2.3"; 
+    public static final int    DEFAULT_PORT  = 6155; 
+    
+    
     private static final Log LOG = LogFactory.getLog(MulticastDiscoveryAgent.class);
     private static final String TYPE_SUFFIX = "ActiveMQ-4.";
     private static final String ALIVE = "alive.";
@@ -257,7 +262,9 @@
      * @throws Exception
      */
     public void start() throws Exception {
-        if (started.compareAndSet(false, true)) {
+    	
+        if (started.compareAndSet(false, true)) {        	
+        	         	
             if (group == null || group.length() == 0) {
                 throw new IOException("You must specify a group to discover");
             }
@@ -266,12 +273,33 @@
                 LOG.warn("The type '" + type + "' should end with '.' to be a valid Discovery
type");
                 type += ".";
             }
+            
             if (discoveryURI == null) {
                 discoveryURI = new URI(DEFAULT_DISCOVERY_URI_STRING);
             }
-            this.inetAddress = InetAddress.getByName(discoveryURI.getHost());
-            this.sockAddress = new InetSocketAddress(this.inetAddress, discoveryURI.getPort());
-            mcast = new MulticastSocket(discoveryURI.getPort());
+            
+            if (LOG.isTraceEnabled()) 
+        	  	LOG.trace("start - discoveryURI = " + discoveryURI);        	  	        	  
+        	  
+        	  String myHost = discoveryURI.getHost();
+        	  int    myPort = discoveryURI.getPort(); 
+        	     
+        	  if( DEFAULT_HOST_STR.equals(myHost) ) 
+        	  	myHost = DEFAULT_HOST_IP;       	      	  
+        	  
+        	  if(myPort < 0 )
+        	    myPort = DEFAULT_PORT;        	    
+        	  
+        	  if (LOG.isTraceEnabled()) {
+        	  	LOG.trace("start - myHost = " + myHost); 
+        	  	LOG.trace("start - myPort = " + myPort);   	
+        	  	LOG.trace("start - myHost = " + myHost); 
+        	  	LOG.trace("start - group  = " + group );   		       	  	
+        	  }	
+        	  
+            this.inetAddress = InetAddress.getByName(myHost);
+            this.sockAddress = new InetSocketAddress(this.inetAddress, myPort);
+            mcast = new MulticastSocket(myPort);
             mcast.setLoopbackMode(loopBackMode);
             mcast.setTimeToLive(getTimeToLive());
             mcast.joinGroup(inetAddress);

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/multicast/MulticastDiscoveryAgentFactory.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/multicast/MulticastDiscoveryAgentFactory.java?rev=692340&r1=692339&r2=692340&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/multicast/MulticastDiscoveryAgentFactory.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/multicast/MulticastDiscoveryAgentFactory.java
Thu Sep  4 22:47:40 2008
@@ -25,25 +25,31 @@
 import org.apache.activemq.util.IOExceptionSupport;
 import org.apache.activemq.util.IntrospectionSupport;
 import org.apache.activemq.util.URISupport;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 public class MulticastDiscoveryAgentFactory extends DiscoveryAgentFactory {
+	
+	  private static final Log LOG = LogFactory.getLog(MulticastDiscoveryAgentFactory.class);

 
-    //See AMQ-1489. There's something wrong here but it is difficult to tell what.
-    //It looks like to actually set the discovery URI you have to use something like
-    //<transportConnector uri="..." discoveryUri="multicast://239.3.7.0:37000?discoveryURI=multicast://239.3.7.0:37000"
/>
-    // or
-    //<networkConnector name="..." uri="multicast://239.3.7.0:37000?discoveryURI=multicast://239.3.7.0:37000">
+    
     protected DiscoveryAgent doCreateDiscoveryAgent(URI uri) throws IOException {
         try {
+        	
+        	  if (LOG.isTraceEnabled()) {      
+               LOG.trace("doCreateDiscoveryAgent: uri = " + uri.toString());            
  
+            }
             
-            Map options = URISupport.parseParamters(uri);
-            MulticastDiscoveryAgent rc = new MulticastDiscoveryAgent();
-            rc.setGroup(uri.getHost());
-
-            // allow the discoveryURI to be set via a query argument on the URI
-            // ?discoveryURI=someURI
-            IntrospectionSupport.setProperties(rc, options);
-            return rc;
+            MulticastDiscoveryAgent mda = new MulticastDiscoveryAgent();          
+            
+            mda.setDiscoveryURI(uri);            
+                        
+            // allow MDA's params to be set via query arguments  
+            // (e.g., multicast://default?group=foo             
+            Map options = URISupport.parseParamters(uri);         
+            IntrospectionSupport.setProperties(mda, options);
+            
+            return mda;
             
         } catch (Throwable e) {
             throw IOExceptionSupport.create("Could not create discovery agent: " + uri, e);



Mime
View raw message