From 616a02d3cb90d92712ee6de9647a0ccc81200d2a Mon Sep 17 00:00:00 2001 From: LantaoJin Date: Sat, 9 Dec 2017 17:05:10 +0800 Subject: [PATCH] [SPARK-22744][CORE] Add a configuration to show the application submit hostname --- .../org/apache/spark/deploy/SparkSubmit.scala | 5 +++++ .../spark/deploy/SparkSubmitSuite.scala | 21 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala b/core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala index cfcdce648d330..d12f2233599db 100644 --- a/core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala +++ b/core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala @@ -743,6 +743,11 @@ object SparkSubmit extends CommandLineUtils with Logging { sparkConf.set("spark.submit.pyFiles", formattedPyFiles) } + // [SPARK-22744]. Add a configuration to show the application submit hostname + if (sparkConf.getOption("spark.submit.hostname").isEmpty) { + sparkConf.set("spark.submit.hostname", Utils.localHostName) + } + (childArgs, childClasspath, sparkConf, childMainClass) } diff --git a/core/src/test/scala/org/apache/spark/deploy/SparkSubmitSuite.scala b/core/src/test/scala/org/apache/spark/deploy/SparkSubmitSuite.scala index e200755e639e1..a596aa52040bf 100644 --- a/core/src/test/scala/org/apache/spark/deploy/SparkSubmitSuite.scala +++ b/core/src/test/scala/org/apache/spark/deploy/SparkSubmitSuite.scala @@ -171,6 +171,27 @@ class SparkSubmitSuite appArgs.toString should include ("thequeue") } + test("check the default application submit hostname") { + val clArgs = Seq( + "--name", "myApp", + "--class", "Foo", + "userjar.jar") + val appArgs = new SparkSubmitArguments(clArgs) + val (_, _, conf, _) = prepareSubmitEnvironment(appArgs) + conf.get("spark.submit.hostname") should be (Utils.localHostName()) + } + + test("check the user defined application submit hostname") { + val clArgs = Seq( + "--name", "myApp", + "--class", "Foo", + "--conf", "spark.submit.hostname=host1", + "userjar.jar") + val appArgs = new SparkSubmitArguments(clArgs) + val (_, _, conf, _) = prepareSubmitEnvironment(appArgs) + conf.get("spark.submit.hostname") should be ("host1") + } + test("specify deploy mode through configuration") { val clArgs = Seq( "--master", "yarn",