Repository: ambari
Updated Branches:
  refs/heads/trunk c150f0ded -> 9207fa3c4


AMBARI-16420. LogFeeder not using fully qualified domain name (Bosco Durai via 
oleewere)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/9207fa3c
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9207fa3c
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9207fa3c

Branch: refs/heads/trunk
Commit: 9207fa3c45b923bfc6b796ba358af1de54b22685
Parents: c150f0d
Author: oleewere <[email protected]>
Authored: Wed May 11 11:39:44 2016 +0200
Committer: oleewere <[email protected]>
Committed: Wed May 11 11:40:22 2016 +0200

----------------------------------------------------------------------
 .../main/java/org/apache/ambari/logfeeder/OutputMgr.java | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/9207fa3c/ambari-logsearch/ambari-logsearch-logfeeder/src/main/java/org/apache/ambari/logfeeder/OutputMgr.java
----------------------------------------------------------------------
diff --git 
a/ambari-logsearch/ambari-logsearch-logfeeder/src/main/java/org/apache/ambari/logfeeder/OutputMgr.java
 
b/ambari-logsearch/ambari-logsearch-logfeeder/src/main/java/org/apache/ambari/logfeeder/OutputMgr.java
index 5b70bca..8413878 100644
--- 
a/ambari-logsearch/ambari-logsearch-logfeeder/src/main/java/org/apache/ambari/logfeeder/OutputMgr.java
+++ 
b/ambari-logsearch/ambari-logsearch-logfeeder/src/main/java/org/apache/ambari/logfeeder/OutputMgr.java
@@ -53,7 +53,16 @@ public class OutputMgr {
     try {
       InetAddress ip = InetAddress.getLocalHost();
       ipAddress = ip.getHostAddress();
-      hostName = ip.getHostName();
+      String getHostName = ip.getHostName();
+      String getCanonicalHostName = ip.getCanonicalHostName();
+      if (!getCanonicalHostName.equalsIgnoreCase(ipAddress)) {
+        logger.info("Using getCanonicalHostName()=" + getCanonicalHostName);
+        hostName = getCanonicalHostName;
+      } else {
+        logger.info("Using getHostName()=" + getHostName);
+        hostName = getHostName;
+      }
+      logger.info("ipAddress=" + ipAddress + ", getHostName=" + getHostName + 
", getCanonicalHostName=" + getCanonicalHostName + ", hostName=" + hostName);
     } catch (UnknownHostException e) {
       logger.error("Error getting hostname.", e);
     }

Reply via email to