diff options
author | Chris Bannister <chris.bannister@swiftkey.com> | 2015-10-19 16:24:40 -0700 |
---|---|---|
committer | Andrew Or <andrew@databricks.com> | 2015-10-19 16:24:40 -0700 |
commit | fc26f32cf1bede8b9a1343dca0c0182107c9985e (patch) | |
tree | b78d7f66fc61fdace7dd30c4006871c32cbd3869 /core | |
parent | 232d7f8d42950431f1d9be2a6bb3591fb6ea20d6 (diff) | |
download | spark-fc26f32cf1bede8b9a1343dca0c0182107c9985e.tar.gz spark-fc26f32cf1bede8b9a1343dca0c0182107c9985e.tar.bz2 spark-fc26f32cf1bede8b9a1343dca0c0182107c9985e.zip |
[SPARK-9708][MESOS] Spark should create local temporary directories in Mesos sandbox when launched with Mesos
This is my own original work and I license this to the project under the project's open source license
Author: Chris Bannister <chris.bannister@swiftkey.com>
Author: Chris Bannister <chris.bannister@swiftkey.net>
Closes #8358 from Zariel/mesos-local-dir.
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/scala/org/apache/spark/util/Utils.scala | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/core/src/main/scala/org/apache/spark/util/Utils.scala b/core/src/main/scala/org/apache/spark/util/Utils.scala index 22c05a2479..55950405f0 100644 --- a/core/src/main/scala/org/apache/spark/util/Utils.scala +++ b/core/src/main/scala/org/apache/spark/util/Utils.scala @@ -649,6 +649,7 @@ private[spark] object Utils extends Logging { * logic of locating the local directories according to deployment mode. */ def getConfiguredLocalDirs(conf: SparkConf): Array[String] = { + val shuffleServiceEnabled = conf.getBoolean("spark.shuffle.service.enabled", false) if (isRunningInYarnContainer(conf)) { // If we are in yarn mode, systems can have different disk layouts so we must set it // to what Yarn on this system said was available. Note this assumes that Yarn has @@ -657,13 +658,23 @@ private[spark] object Utils extends Logging { getYarnLocalDirs(conf).split(",") } else if (conf.getenv("SPARK_EXECUTOR_DIRS") != null) { conf.getenv("SPARK_EXECUTOR_DIRS").split(File.pathSeparator) + } else if (conf.getenv("SPARK_LOCAL_DIRS") != null) { + conf.getenv("SPARK_LOCAL_DIRS").split(",") + } else if (conf.getenv("MESOS_DIRECTORY") != null && !shuffleServiceEnabled) { + // Mesos already creates a directory per Mesos task. Spark should use that directory + // instead so all temporary files are automatically cleaned up when the Mesos task ends. + // Note that we don't want this if the shuffle service is enabled because we want to + // continue to serve shuffle files after the executors that wrote them have already exited. + Array(conf.getenv("MESOS_DIRECTORY")) } else { + if (conf.getenv("MESOS_DIRECTORY") != null && shuffleServiceEnabled) { + logInfo("MESOS_DIRECTORY available but not using provided Mesos sandbox because " + + "spark.shuffle.service.enabled is enabled.") + } // In non-Yarn mode (or for the driver in yarn-client mode), we cannot trust the user // configuration to point to a secure directory. So create a subdirectory with restricted // permissions under each listed directory. - Option(conf.getenv("SPARK_LOCAL_DIRS")) - .getOrElse(conf.get("spark.local.dir", System.getProperty("java.io.tmpdir"))) - .split(",") + conf.get("spark.local.dir", System.getProperty("java.io.tmpdir")).split(",") } } |