Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/2002#discussion_r16415486
  
    --- 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
    +  }
    +
    +  /**
    +   * Gets or creates the directories listed in spark.local.dir or 
SPARK_LOCAL_DIRS,
    +   * and returns only the directories that exist / could be created.
    +   *
    +   * If no directories could be created, this will return an empty list.
    +   */
    +  private[spark] def getOrCreateLocalRootDirs(conf: SparkConf): 
Array[String] = {
    +    val confValue = 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.
    +      getYarnLocalDirs(conf)
    +    } else {
    +      Option(conf.getenv("SPARK_LOCAL_DIRS")).getOrElse(
    +        conf.get("spark.local.dir", System.getProperty("java.io.tmpdir")))
    +    }
    +    val rootDirs = confValue.split(',')
    +    logDebug(s"Getting/creating local root dirs at '$rootDirs'")
    --- End diff --
    
    this debug doesn't really print anything useful:
    
    14/08/19 13:58:21 DEBUG Utils: Getting/creating local root dirs at 
[Ljava.lang.String;@1952333



---
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]

Reply via email to