qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rob...@apache.org
Subject [2/2] qpid-jms git commit: QPIDJMS-77: improve logging of default interface selection process, update usage order of found interfaces for consistency with the brokers doing the announcing
Date Wed, 24 Jun 2015 13:51:23 GMT
QPIDJMS-77: improve logging of default interface selection process, update usage order of found
interfaces for consistency with the brokers doing the announcing


Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/49b66746
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/49b66746
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/49b66746

Branch: refs/heads/master
Commit: 49b6674648ed87a9dcacb6839690706b43914563
Parents: 71716b8
Author: Robert Gemmell <robbie@apache.org>
Authored: Wed Jun 24 14:31:16 2015 +0100
Committer: Robert Gemmell <robbie@apache.org>
Committed: Wed Jun 24 14:51:05 2015 +0100

----------------------------------------------------------------------
 .../multicast/MulticastDiscoveryAgent.java          | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/49b66746/qpid-jms-discovery/src/main/java/org/apache/qpid/jms/provider/discovery/multicast/MulticastDiscoveryAgent.java
----------------------------------------------------------------------
diff --git a/qpid-jms-discovery/src/main/java/org/apache/qpid/jms/provider/discovery/multicast/MulticastDiscoveryAgent.java
b/qpid-jms-discovery/src/main/java/org/apache/qpid/jms/provider/discovery/multicast/MulticastDiscoveryAgent.java
index 1c5e2c1..4576678 100644
--- a/qpid-jms-discovery/src/main/java/org/apache/qpid/jms/provider/discovery/multicast/MulticastDiscoveryAgent.java
+++ b/qpid-jms-discovery/src/main/java/org/apache/qpid/jms/provider/discovery/multicast/MulticastDiscoveryAgent.java
@@ -29,7 +29,6 @@ import java.net.SocketTimeoutException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.Enumeration;
 import java.util.Iterator;
 import java.util.List;
@@ -397,7 +396,7 @@ public class MulticastDiscoveryAgent implements DiscoveryAgent, Runnable
{
     }
 
     public static void trySetNetworkInterface(MulticastSocket mcastSock) throws SocketException
{
-        List<NetworkInterface> interfaces = findNetworkInterface();
+        List<NetworkInterface> interfaces = findNetworkInterfaces();
         SocketException lastError = null;
         boolean found = false;
 
@@ -421,23 +420,30 @@ public class MulticastDiscoveryAgent implements DiscoveryAgent, Runnable
{
         }
     }
 
-    private static List<NetworkInterface> findNetworkInterface() throws SocketException
{
+    private static List<NetworkInterface> findNetworkInterfaces() throws SocketException
{
         Enumeration<NetworkInterface> ifcs = NetworkInterface.getNetworkInterfaces();
         List<NetworkInterface> interfaces = new ArrayList<NetworkInterface>();
         while (ifcs.hasMoreElements()) {
             NetworkInterface ni = ifcs.nextElement();
+            LOG.trace("findNetworkInterfaces checking interface: {}", ni);
+
             if (ni.supportsMulticast() && ni.isUp()) {
                 for (InterfaceAddress ia : ni.getInterfaceAddresses()) {
                     if (ia.getAddress() instanceof java.net.Inet4Address &&
                         !ia.getAddress().isLoopbackAddress() &&
                         !DEFAULT_EXCLUSIONS.contains(ni.getName())) {
-                        interfaces.add(ni);
+                        // Add at the start, make usage order consistent with the
+                        // existing ActiveMQ releases discovery will be used with.
+                        interfaces.add(0, ni);
+                        break;
                     }
                 }
             }
         }
 
-        return interfaces.isEmpty() ? Collections.<NetworkInterface>emptyList() : interfaces;
+        LOG.trace("findNetworkInterfaces returning: {}", interfaces);
+
+        return interfaces;
     }
 
     // ---------- Discovered Peer Bookkeeping Class ---------------------------//


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message