Skip to content

Commit

Permalink
Change Utils.getSparkOrYarnConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyum committed Mar 10, 2018
1 parent 9745ec3 commit 0034a58
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -490,13 +490,9 @@ object SparkHadoopUtil {
}

private def appendSparkHadoopConfigs(conf: SparkConf, hadoopConf: Configuration): Unit = {
for ((key, value) <- conf.getAll if key.startsWith("spark.")) {
if (key.startsWith("spark.hadoop.")) {
// Copy any "spark.hadoop.foo=bar" system properties into conf as "foo=bar"
hadoopConf.set(key.substring("spark.hadoop.".length), value)
} else {
hadoopConf.set(key, value)
}
// Copy any "spark.hadoop.foo=bar" spark properties into conf as "foo=bar"
for ((key, value) <- conf.getAll if key.startsWith("spark.hadoop.")) {
hadoopConf.set(key.substring("spark.hadoop.".length), value)
}
}
}
3 changes: 2 additions & 1 deletion core/src/main/scala/org/apache/spark/util/Utils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2434,7 +2434,8 @@ private[spark] object Utils extends Logging {
*/
def getSparkOrYarnConfig(conf: SparkConf, key: String, default: String): String = {
val sparkValue = conf.get(key, default)
if (conf.get(SparkLauncher.SPARK_MASTER, null) == "yarn") {
if (conf.get(SparkLauncher.SPARK_MASTER, null) == "yarn"
&& (key.startsWith("spark.hadoop.") || !key.startsWith("spark."))) {
new YarnConfiguration(SparkHadoopUtil.get.newConfiguration(conf)).get(key, sparkValue)
} else {
sparkValue
Expand Down

0 comments on commit 0034a58

Please sign in to comment.