HCOLL-134 ( release draft cut of the code so that I can test it across my network )

This commit is contained in:
Rob Austin
2014-10-06 15:21:35 +01:00
parent 6c0ec26911
commit 1d27ca894b
2 changed files with 42 additions and 4 deletions
@@ -978,7 +978,7 @@ class ConcurrentExpiryMap<K extends BytesMarshallable, V extends BytesMarshallab
}
/*public static void main(String... args) {
public static void main(String... args) {
String ip;
try {
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
@@ -998,5 +998,40 @@ class ConcurrentExpiryMap<K extends BytesMarshallable, V extends BytesMarshallab
} catch (SocketException e) {
throw new RuntimeException(e);
}
}*/
}
/**
* private NetworkInterface defaultNetworkInterface() throws SocketException { NetworkInterface
* networkInterface = null
*
* for (String suggestedName : new String[]{"en0", "eth0"}) { networkInterface =
* NetworkInterface.getByName(suggestedName); if (networkInterface != null) break; } return
* networkInterface; }
*
* /**
*
* @return the default network interface, or
* @throws SocketException
*/
public static NetworkInterface defaultNetworkInterface() throws SocketException {
NetworkInterface networkInterface = null;
for (String suggestedName : new String[]{"en0", "eth0"}) {
networkInterface = NetworkInterface.getByName(suggestedName);
if (networkInterface != null)
break;
}
if (networkInterface != null)
return networkInterface;
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
if (networkInterfaces == null || !networkInterfaces.hasMoreElements())
return null;
return networkInterfaces.nextElement();
}
}
@@ -14,8 +14,9 @@ public class NodeDiscoveryTest {
public void testDiscoverMap() throws Exception {
final NodeDiscovery nodeDiscovery = new NodeDiscovery();
NetworkInterface en0 = NetworkInterface.getByName("en0");
Enumeration<InetAddress> inetAddresses = en0.getInetAddresses();
NetworkInterface networkInterface = ConcurrentExpiryMap.defaultNetworkInterface();
Enumeration<InetAddress> inetAddresses = networkInterface.getInetAddresses();
AddressAndPort ourAddressAndPort1 = new AddressAndPort(inetAddresses.nextElement().getAddress(),
(short) 1237);
@@ -24,4 +25,6 @@ public class NodeDiscoveryTest {
Thread.sleep(1000000);
}
}