From 1d27ca894bda47ca3e400ffd20cf626ebc7c5dec Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Mon, 6 Oct 2014 15:21:35 +0100 Subject: [PATCH] HCOLL-134 ( release draft cut of the code so that I can test it across my network ) --- .../openhft/chronicle/map/NodeDiscovery.java | 39 ++++++++++++++++++- .../chronicle/map/NodeDiscoveryTest.java | 7 +++- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/openhft/chronicle/map/NodeDiscovery.java b/src/main/java/net/openhft/chronicle/map/NodeDiscovery.java index c35fa92bc..b8e82e9aa 100644 --- a/src/main/java/net/openhft/chronicle/map/NodeDiscovery.java +++ b/src/main/java/net/openhft/chronicle/map/NodeDiscovery.java @@ -978,7 +978,7 @@ class ConcurrentExpiryMap interfaces = NetworkInterface.getNetworkInterfaces(); @@ -998,5 +998,40 @@ class ConcurrentExpiryMap networkInterfaces = NetworkInterface.getNetworkInterfaces(); + if (networkInterfaces == null || !networkInterfaces.hasMoreElements()) + return null; + + return networkInterfaces.nextElement(); + + + } } diff --git a/src/test/java/net/openhft/chronicle/map/NodeDiscoveryTest.java b/src/test/java/net/openhft/chronicle/map/NodeDiscoveryTest.java index 48a07b236..c590203e2 100644 --- a/src/test/java/net/openhft/chronicle/map/NodeDiscoveryTest.java +++ b/src/test/java/net/openhft/chronicle/map/NodeDiscoveryTest.java @@ -14,8 +14,9 @@ public class NodeDiscoveryTest { public void testDiscoverMap() throws Exception { final NodeDiscovery nodeDiscovery = new NodeDiscovery(); - NetworkInterface en0 = NetworkInterface.getByName("en0"); - Enumeration inetAddresses = en0.getInetAddresses(); + + NetworkInterface networkInterface = ConcurrentExpiryMap.defaultNetworkInterface(); + Enumeration inetAddresses = networkInterface.getInetAddresses(); AddressAndPort ourAddressAndPort1 = new AddressAndPort(inetAddresses.nextElement().getAddress(), (short) 1237); @@ -24,4 +25,6 @@ public class NodeDiscoveryTest { Thread.sleep(1000000); } + + } \ No newline at end of file