Github user tgravescs commented on a diff in the pull request:
https://github.com/apache/spark/pull/2002#discussion_r16412610
--- Diff: core/src/main/scala/org/apache/spark/util/Utils.scala ---
@@ -449,12 +449,68 @@ private[spark] object Utils extends Logging {
}
/**
- * Get a temporary directory using Spark's spark.local.dir property, if
set. This will always
- * return a single directory, even though the spark.local.dir property
might be a list of
- * multiple paths.
+ * Get the path of a temporary directory. Spark's local directories can
be configured through
+ * multiple settings, which are used with the following precedence:
+ *
+ * - If called from inside of a YARN container, this will return a
directory chosen by YARN.
+ * - If the SPARK_LOCAL_DIRS environment variable is set, this will
return a directory from it.
+ * - Otherwise, if the spark.local.dir is set, this will return a
directory from it.
+ * - Otherwise, this will return java.io.tmpdir.
+ *
+ * Some of these configuration options might be lists of multiple paths,
but this method will
+ * always return a single directory.
*/
def getLocalDir(conf: SparkConf): String = {
- conf.get("spark.local.dir",
System.getProperty("java.io.tmpdir")).split(',')(0)
+ getOrCreateLocalRootDirs(conf)(0)
+ }
+
+ private[spark] def isRunningInYarnContainer(conf: SparkConf): Boolean = {
+ conf.getenv("NM_HOST") != null || conf.getenv("CONTAINER_ID") != null
--- End diff --
can you reverse the checks and have CONTAINER_ID first. Also it might be
nice to add a small comment saying those env variables are set by yarn.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]