summaryrefslogtreecommitdiffstats
path: root/vespajlib/src/main/java/com/yahoo/net
diff options
context:
space:
mode:
authorHåkon Hallingstad <hakon@yahoo-inc.com>2017-02-20 17:13:18 +0100
committerHåkon Hallingstad <hakon@yahoo-inc.com>2017-02-20 17:13:18 +0100
commitd27e86bcd396d64a92d4742083235ee6768dc6b9 (patch)
treef2daf9230f2575792e58f8abe76aeeeb8f8a0d86 /vespajlib/src/main/java/com/yahoo/net
parent24eab4fe4b661526f327fcb32a045dfbc7f3c998 (diff)
Makes clustercontroller-core work on WiFi
Diffstat (limited to 'vespajlib/src/main/java/com/yahoo/net')
-rw-r--r--vespajlib/src/main/java/com/yahoo/net/HostName.java16
1 files changed, 8 insertions, 8 deletions
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();