summaryrefslogtreecommitdiffstats
path: root/messagebus
diff options
context:
space:
mode:
authorEirik Nygaard <eirik@yahoo-inc.com>2016-10-14 08:43:26 +0200
committerGitHub <noreply@github.com>2016-10-14 08:43:26 +0200
commit327fde0ff8a159ba142f23b5889c9ee8dcc3c29f (patch)
tree2d08b72b781aadf4044210955da5c17f5f631ca9 /messagebus
parentc09aadd28bed9cb485160a1cc046c6772d2db337 (diff)
Revert "Use HostName for message bus, but fix HostName to work with dev machines"
Diffstat (limited to 'messagebus')
-rw-r--r--messagebus/src/main/java/com/yahoo/messagebus/network/Identity.java11
1 files changed, 10 insertions, 1 deletions
diff --git a/messagebus/src/main/java/com/yahoo/messagebus/network/Identity.java b/messagebus/src/main/java/com/yahoo/messagebus/network/Identity.java
index a10cd4b8a63..45887b072ab 100644
--- a/messagebus/src/main/java/com/yahoo/messagebus/network/Identity.java
+++ b/messagebus/src/main/java/com/yahoo/messagebus/network/Identity.java
@@ -1,7 +1,12 @@
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.messagebus.network;
+import com.yahoo.log.LogLevel;
import com.yahoo.net.HostName;
+import com.yahoo.net.LinuxInetAddress;
+
+import java.net.Inet6Address;
+import java.net.InetAddress;
/**
* This class encapsulates the identity of the application that uses this instance of message bus. This identity
@@ -23,7 +28,11 @@ public class Identity {
* @param configId The config identifier for the application.
*/
public Identity(String configId) {
- hostname = HostName.getHostName(); // ... but fallback to hostname if we get an IPv6 address
+ InetAddress addr = LinuxInetAddress.getLocalHost(); // try hard to get a resolvable address
+ if (addr instanceof Inet6Address) //
+ hostname = HostName.getLocalhost(); // ... but fallback to hostname if we get an IPv6 address
+ else
+ hostname = addr.getCanonicalHostName();
servicePrefix = configId;
}