Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 72996 invoked from network); 11 Sep 2009 08:47:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 11 Sep 2009 08:47:05 -0000 Received: (qmail 9036 invoked by uid 500); 11 Sep 2009 08:47:05 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 8981 invoked by uid 500); 11 Sep 2009 08:47:05 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 8972 invoked by uid 99); 11 Sep 2009 08:47:05 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Sep 2009 08:47:05 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Sep 2009 08:47:01 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 0909A2388892; Fri, 11 Sep 2009 08:46:41 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r813721 - /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/multicast/MulticastDiscoveryAgent.java Date: Fri, 11 Sep 2009 08:46:40 -0000 To: commits@activemq.apache.org From: gtully@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090911084641.0909A2388892@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: gtully Date: Fri Sep 11 08:46:40 2009 New Revision: 813721 URL: http://svn.apache.org/viewvc?rev=813721&view=rev Log: resolve https://issues.apache.org/activemq/browse/AMQ-2381 - patch applied with thanks Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/multicast/MulticastDiscoveryAgent.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=813721&r1=813720&r2=813721&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 Fri Sep 11 08:46:40 2009 @@ -21,6 +21,7 @@ import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.MulticastSocket; +import java.net.NetworkInterface; import java.net.SocketAddress; import java.net.SocketTimeoutException; import java.net.URI; @@ -52,8 +53,7 @@ public static final String DEFAULT_HOST_STR = "default"; public static final String DEFAULT_HOST_IP = System.getProperty("activemq.partition.discovery", "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."; @@ -69,6 +69,25 @@ private boolean useExponentialBackOff; private int maxReconnectAttempts; + private int timeToLive = 1; + private boolean loopBackMode; + private Map brokersByService = new ConcurrentHashMap(); + private String group = "default"; + private URI discoveryURI; + private InetAddress inetAddress; + private SocketAddress sockAddress; + private DiscoveryListener discoveryListener; + private String selfService; + private MulticastSocket mcast; + private Thread runner; + private long keepAliveInterval = DEFAULT_IDLE_TIME; + private String mcInterface; + private String mcNetworkInterface; + private long lastAdvertizeTime; + private AtomicBoolean started = new AtomicBoolean(false); + private boolean reportAdvertizeFailed = true; + private ExecutorService executor = null; + class RemoteBrokerData { final String brokerName; final String service; @@ -161,23 +180,6 @@ } } - private int timeToLive = 1; - private boolean loopBackMode; - private Map brokersByService = new ConcurrentHashMap(); - private String group = "default"; - private URI discoveryURI; - private InetAddress inetAddress; - private SocketAddress sockAddress; - private DiscoveryListener discoveryListener; - private String selfService; - private MulticastSocket mcast; - private Thread runner; - private long keepAliveInterval = DEFAULT_IDLE_TIME; - private long lastAdvertizeTime; - private AtomicBoolean started = new AtomicBoolean(false); - private boolean reportAdvertizeFailed = true; - private ExecutorService executor = null; - /** * Set the discovery listener * @@ -248,7 +250,15 @@ public void setKeepAliveInterval(long keepAliveInterval) { this.keepAliveInterval = keepAliveInterval; } - + + public void setInterface(String mcInterface) { + this.mcInterface = mcInterface; + } + + public void setNetworkInterface(String mcNetworkInterface) { + this.mcNetworkInterface = mcNetworkInterface; + } + /** * start the discovery agent * @@ -286,7 +296,9 @@ if (LOG.isTraceEnabled()) { LOG.trace("start - myHost = " + myHost); LOG.trace("start - myPort = " + myPort); - LOG.trace("start - group = " + group ); + LOG.trace("start - group = " + group ); + LOG.trace("start - interface = " + mcInterface ); + LOG.trace("start - network interface = " + mcNetworkInterface ); } this.inetAddress = InetAddress.getByName(myHost); @@ -296,6 +308,12 @@ mcast.setTimeToLive(getTimeToLive()); mcast.joinGroup(inetAddress); mcast.setSoTimeout((int)keepAliveInterval); + if (mcInterface != null) { + mcast.setInterface(InetAddress.getByName(mcInterface)); + } + if (mcNetworkInterface != null) { + mcast.setNetworkInterface(NetworkInterface.getByName(mcNetworkInterface)); + } runner = new Thread(this); runner.setName(this.toString() + ":" + runner.getName()); runner.setDaemon(true);