mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
HCOLL-134 ( release draft cut of the code so that I can test it across my network )
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user