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

    https://github.com/apache/spark/pull/2002#discussion_r16415449
  
    --- 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 --
    
    Sorry for changing but after thinking about this some more could you change 
the NM_HOST to be YARN_LOCAL_DIRS (for hadoop 0.23).  We are already relying on 
that below so one less dependency.  Then for hadoop 2.x we use CONTAINER_ID 
which I think is better to rely on.
    
    I tested that out (using YARN_LOCAL_DIRS) on hadoop 0.23 and it works fine. 


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