From e8b237252fe4b5f738f6daaf3d0e05a3e98282ce Mon Sep 17 00:00:00 2001 From: fwang12 Date: Fri, 9 Apr 2021 22:04:55 +0800 Subject: [PATCH] involve KYUUBI_FRONTEND_BIND_HOST --- conf/kyuubi-env.sh.template | 46 ++++++++++--------- .../kyuubi/service/FrontendService.scala | 12 ++++- 2 files changed, 34 insertions(+), 24 deletions(-) diff --git a/conf/kyuubi-env.sh.template b/conf/kyuubi-env.sh.template index 90fe102877d..c5065b13e3a 100755 --- a/conf/kyuubi-env.sh.template +++ b/conf/kyuubi-env.sh.template @@ -16,28 +16,30 @@ # limitations under the License. # # -# - JAVA_HOME Java runtime to use. By default use "java" from PATH. -# -# -# - KYUUBI_CONF_DIR Directory containing the Kyuubi configurations to use. -# (Default: $KYUUBI_HOME/conf) -# - KYUUBI_LOG_DIR Directory for Kyuubi server-side logs. -# (Default: $KYUUBI_HOME/logs) -# - KYUUBI_PID_DIR Directory stores the Kyuubi instance pid file. -# (Default: $KYUUBI_HOME/pid) -# - KYUUBI_MAX_LOG_FILES Maximum number of Kyuubi server logs can rotate to. -# (Default: 5) -# - KYUUBI_JAVA_OPTS JVM options for the Kyuubi server itself in the form "-Dx=y". -# (Default: none). -# - KYUUBI_NICENESS The scheduling priority for Kyuubi server. -# (Default: 0) -# - KYUUBI_WORK_DIR_ROOT Root directory for launching sql engine applications. -# (Default: $KYUUBI_HOME/work) -# - HADOOP_CONF_DIR Directory containing the Hadoop / YARN configuration to use. -# -# - SPARK_HOME Spark distribution which you would like to use in Kyuubi. -# - SPARK_CONF_DIR Optional directory where the Spark configuration lives. -# (Default: $SPARK_HOME/conf) +# - JAVA_HOME Java runtime to use. By default use "java" from PATH. +# +# +# - KYUUBI_CONF_DIR Directory containing the Kyuubi configurations to use. +# (Default: $KYUUBI_HOME/conf) +# - KYUUBI_LOG_DIR Directory for Kyuubi server-side logs. +# (Default: $KYUUBI_HOME/logs) +# - KYUUBI_PID_DIR Directory stores the Kyuubi instance pid file. +# (Default: $KYUUBI_HOME/pid) +# - KYUUBI_MAX_LOG_FILES Maximum number of Kyuubi server logs can rotate to. +# (Default: 5) +# - KYUUBI_JAVA_OPTS JVM options for the Kyuubi server itself in the form "-Dx=y". +# (Default: none). +# - KYUUBI_NICENESS The scheduling priority for Kyuubi server. +# (Default: 0) +# - KYUUBI_WORK_DIR_ROOT Root directory for launching sql engine applications. +# (Default: $KYUUBI_HOME/work) +# - HADOOP_CONF_DIR Directory containing the Hadoop / YARN configuration to use. +# +# - SPARK_HOME Spark distribution which you would like to use in Kyuubi. +# - SPARK_CONF_DIR Optional directory where the Spark configuration lives. +# (Default: $SPARK_HOME/conf) +# +# - KYUUBI_FRONTEND_BIND_HOST IP address for the frontend server to bind to. # diff --git a/kyuubi-common/src/main/scala/org/apache/kyuubi/service/FrontendService.scala b/kyuubi-common/src/main/scala/org/apache/kyuubi/service/FrontendService.scala index a47be78c407..2d45873668f 100644 --- a/kyuubi-common/src/main/scala/org/apache/kyuubi/service/FrontendService.scala +++ b/kyuubi-common/src/main/scala/org/apache/kyuubi/service/FrontendService.scala @@ -59,8 +59,7 @@ class FrontendService private (name: String, be: BackendService, oomHook: Runnab this.conf = conf try { hadoopConf = KyuubiHadoopUtils.newHadoopConf(conf) - val serverHost = conf.get(FRONTEND_BIND_HOST) - serverAddr = serverHost.map(InetAddress.getByName).getOrElse(InetAddress.getLocalHost) + serverAddr = findFrontendServerHost() portNum = conf.get(FRONTEND_BIND_PORT) val minThreads = conf.get(FRONTEND_MIN_WORKER_THREADS) val maxThreads = conf.get(FRONTEND_MAX_WORKER_THREADS) @@ -104,6 +103,15 @@ class FrontendService private (name: String, be: BackendService, oomHook: Runnab super.initialize(conf) } + private def findFrontendServerHost(): InetAddress = { + val serverHostOverride = System.getenv("KYUUBI_FRONTEND_BIND_HOST") + if (serverHostOverride != null) { + InetAddress.getByName(serverHostOverride) + } else { + conf.get(FRONTEND_BIND_HOST).map(InetAddress.getByName).getOrElse(InetAddress.getLocalHost) + } + } + def connectionUrl: String = { getServiceState match { case s @ ServiceState.LATENT => throw new IllegalStateException(s"Illegal Service State: $s")