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

    https://github.com/apache/spark/pull/2002#discussion_r16398843
  
    --- Diff: core/src/main/scala/org/apache/spark/util/Utils.scala ---
    @@ -449,12 +449,66 @@ 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 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.
    --- End diff --
    
    Even though it's redundant - it might be good to explicitly say that this 
can return an empty list.


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