From 2f6dd634c169a34811738a3c230cce4462612748 Mon Sep 17 00:00:00 2001 From: vundela Date: Tue, 20 Oct 2015 11:12:28 -0700 Subject: [SPARK-11105] [YARN] Distribute log4j.properties to executors Currently log4j.properties file is not uploaded to executor's which is leading them to use the default values. This fix will make sure that file is always uploaded to distributed cache so that executor will use the latest settings. If user specifies log configurations through --files then executors will be picking configs from --files instead of $SPARK_CONF_DIR/log4j.properties Author: vundela Author: Srinivasa Reddy Vundela Closes #9118 from vundela/master. --- .../main/scala/org/apache/spark/deploy/yarn/Client.scala | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'yarn/src') diff --git a/yarn/src/main/scala/org/apache/spark/deploy/yarn/Client.scala b/yarn/src/main/scala/org/apache/spark/deploy/yarn/Client.scala index 754215db2a..4954b61809 100644 --- a/yarn/src/main/scala/org/apache/spark/deploy/yarn/Client.scala +++ b/yarn/src/main/scala/org/apache/spark/deploy/yarn/Client.scala @@ -497,6 +497,19 @@ private[spark] class Client( */ private def createConfArchive(): File = { val hadoopConfFiles = new HashMap[String, File]() + + // Uploading $SPARK_CONF_DIR/log4j.properties file to the distributed cache to make sure that + // the executors will use the latest configurations instead of the default values. This is + // required when user changes log4j.properties directly to set the log configurations. If + // configuration file is provided through --files then executors will be taking configurations + // from --files instead of $SPARK_CONF_DIR/log4j.properties. + val log4jFileName = "log4j.properties" + Option(Utils.getContextOrSparkClassLoader.getResource(log4jFileName)).foreach { url => + if (url.getProtocol == "file") { + hadoopConfFiles(log4jFileName) = new File(url.getPath) + } + } + Seq("HADOOP_CONF_DIR", "YARN_CONF_DIR").foreach { envKey => sys.env.get(envKey).foreach { path => val dir = new File(path) -- cgit v1.2.3