kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lid...@apache.org
Subject kylin git commit: KYLIN-1741 Enhance diagnosis tool
Date Sun, 10 Jul 2016 08:32:21 GMT
Repository: kylin
Updated Branches:
  refs/heads/v1.5.3-release e0ffd22f8 -> 8735c28f4


KYLIN-1741 Enhance diagnosis tool


Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/8735c28f
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/8735c28f
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/8735c28f

Branch: refs/heads/v1.5.3-release
Commit: 8735c28f455a074f996d70abadd52c343dc3ae61
Parents: e0ffd22
Author: lidongsjtu <lidong@apache.org>
Authored: Sun Jul 10 16:25:23 2016 +0800
Committer: lidongsjtu <lidong@apache.org>
Committed: Sun Jul 10 16:32:12 2016 +0800

----------------------------------------------------------------------
 .../kylin/tool/AbstractInfoExtractor.java       |  1 +
 .../org/apache/kylin/tool/util/ToolUtil.java    | 25 ++++++++++++++++++++
 2 files changed, 26 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/8735c28f/tool/src/main/java/org/apache/kylin/tool/AbstractInfoExtractor.java
----------------------------------------------------------------------
diff --git a/tool/src/main/java/org/apache/kylin/tool/AbstractInfoExtractor.java b/tool/src/main/java/org/apache/kylin/tool/AbstractInfoExtractor.java
index cb2ebd0..a3bf24a 100644
--- a/tool/src/main/java/org/apache/kylin/tool/AbstractInfoExtractor.java
+++ b/tool/src/main/java/org/apache/kylin/tool/AbstractInfoExtractor.java
@@ -136,6 +136,7 @@ public abstract class AbstractInfoExtractor extends AbstractApplication
{
         StringBuilder basicSb = new StringBuilder();
         basicSb.append("MetaStoreID: ").append(ToolUtil.getHBaseMetaStoreId()).append("\n");
         basicSb.append("PackageType: ").append(packageType.toUpperCase()).append("\n");
+        basicSb.append("Host: ").append(ToolUtil.getHostName()).append("\n");
         FileUtils.writeStringToFile(new File(exportDir, "info"), basicSb.toString());
     }
 

http://git-wip-us.apache.org/repos/asf/kylin/blob/8735c28f/tool/src/main/java/org/apache/kylin/tool/util/ToolUtil.java
----------------------------------------------------------------------
diff --git a/tool/src/main/java/org/apache/kylin/tool/util/ToolUtil.java b/tool/src/main/java/org/apache/kylin/tool/util/ToolUtil.java
index 08f21e5..1312ca4 100644
--- a/tool/src/main/java/org/apache/kylin/tool/util/ToolUtil.java
+++ b/tool/src/main/java/org/apache/kylin/tool/util/ToolUtil.java
@@ -21,6 +21,8 @@ package org.apache.kylin.tool.util;
 
 import java.io.File;
 import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
 import java.util.Map;
 
 import org.apache.commons.lang.StringUtils;
@@ -70,4 +72,27 @@ public class ToolUtil {
         return null;
     }
 
+    public static String getHostName() {
+        String hostname = System.getenv("COMPUTERNAME");
+        if (StringUtils.isEmpty(hostname)) {
+            InetAddress address = null;
+            try {
+                address = InetAddress.getLocalHost();
+                hostname = address.getHostName();
+                if (StringUtils.isEmpty(hostname)) {
+                    hostname = address.getHostAddress();
+                }
+            } catch (UnknownHostException uhe) {
+                String host = uhe.getMessage(); // host = "hostname: hostname"
+                if (host != null) {
+                    int colon = host.indexOf(':');
+                    if (colon > 0) {
+                        return host.substring(0, colon);
+                    }
+                }
+                hostname = "Unknown";
+            }
+        }
+        return hostname;
+    }
 }


Mime
View raw message