From d27e86bcd396d64a92d4742083235ee6768dc6b9 Mon Sep 17 00:00:00 2001 From: HÃ¥kon Hallingstad Date: Mon, 20 Feb 2017 17:13:18 +0100 Subject: Makes clustercontroller-core work on WiFi --- vespajlib/src/main/java/com/yahoo/net/HostName.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'vespajlib') diff --git a/vespajlib/src/main/java/com/yahoo/net/HostName.java b/vespajlib/src/main/java/com/yahoo/net/HostName.java index 3c87b6c112c..a2782b7a2b3 100644 --- a/vespajlib/src/main/java/com/yahoo/net/HostName.java +++ b/vespajlib/src/main/java/com/yahoo/net/HostName.java @@ -30,11 +30,9 @@ public class HostName { private static String cachedHostName = null; /** - * Return a fully qualified hostname that resolves to an IP address on a network interface. - * Normally this is the same as the 'hostname' command, but if that's not reachable a hostname - * for a reachable IP address is returned which is reachable , but on dev machines on WiFi, - * that IP isn't configured so we prefer a WiFi network interface IP address which is both reachable and - * has a DNS entry. + * Return a public and fully qualified hostname for localhost that resolves to an IP address on + * a network interface. Normally this is the same as the 'hostname' command, but on dev machines on WiFi + * that IP isn't configured, so we find the DNS entry corresponding to the WiFi IP address. * * @return the preferred name of localhost * @throws RuntimeException if accessing the network or the 'hostname' command fails @@ -93,7 +91,7 @@ public class HostName { return reachableNonLocalIp6Addresses.get(0).getHostName(); } - // Fall back to localhost. + // Fall back to InetAddress' localhost. return InetAddress.getLocalHost().getCanonicalHostName(); } @@ -116,8 +114,10 @@ public class HostName { return Optional.empty(); } - // public for testing purposes (all testing machines should have a hostname - public static String getSystemHostName() throws Exception { + /** + * DO NOT USE: Package-private for testing purposes (all testing machines should have a hostname) + */ + static String getSystemHostName() throws Exception { Process process = Runtime.getRuntime().exec("hostname"); BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream())); String hostname = in.readLine(); -- cgit v1.2.3