You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by xx...@apache.org on 2021/03/05 06:34:42 UTC

[kylin] branch kylin-on-parquet-v2 updated: KYLIN-4910 Return hostname as Sparder URL address when spark master is set to local

This is an automated email from the ASF dual-hosted git repository.

xxyu pushed a commit to branch kylin-on-parquet-v2
in repository https://gitbox.apache.org/repos/asf/kylin.git


The following commit(s) were added to refs/heads/kylin-on-parquet-v2 by this push:
     new 41ebf45  KYLIN-4910 Return hostname as Sparder URL address when spark master is set to local
41ebf45 is described below

commit 41ebf457858a76e4ab005b2f37f9b8fdb1d303ae
Author: zhengshengjun <sh...@sina.com>
AuthorDate: Mon Mar 1 15:35:37 2021 +0800

    KYLIN-4910 Return hostname as Sparder URL address when spark master is set to local
---
 .../src/main/scala/org/apache/spark/sql/SparderContext.scala       | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/kylin-spark-project/kylin-spark-query/src/main/scala/org/apache/spark/sql/SparderContext.scala b/kylin-spark-project/kylin-spark-query/src/main/scala/org/apache/spark/sql/SparderContext.scala
index aaec4d5..530cbae 100644
--- a/kylin-spark-project/kylin-spark-query/src/main/scala/org/apache/spark/sql/SparderContext.scala
+++ b/kylin-spark-project/kylin-spark-query/src/main/scala/org/apache/spark/sql/SparderContext.scala
@@ -33,6 +33,7 @@ import java.util.concurrent.atomic.AtomicReference
 
 import org.apache.commons.io.FileUtils
 import org.apache.kylin.common.KylinConfig
+import org.apache.kylin.common.util.ToolUtil
 import org.apache.kylin.query.monitor.SparderContextCanary
 import org.apache.kylin.spark.classloader.ClassLoaderUtils
 import org.apache.spark.{SparkConf, SparkContext, SparkEnv}
@@ -174,7 +175,11 @@ object SparderContext extends Logging {
               initMonitorEnv()
               master match {
                 case mode: String if mode.startsWith("local") =>
-                  master_app_url = "http://localhost:" + sparkSession.sparkContext.getConf
+                  var hostName = ToolUtil.getHostName
+                  if (hostName.equals("Unknown")) {
+                    hostName = "localhost"
+                  }
+                  master_app_url = "http://" + hostName + ":" + sparkSession.sparkContext.getConf
                     .get("spark.ui.port", "4040")
                 case _ =>
                   master_app_url = YarnInfoFetcherUtils.getTrackingUrl(appid)