Github user andrewor14 commented on a diff in the pull request:
https://github.com/apache/spark/pull/299#discussion_r11720118
--- Diff:
yarn/common/src/main/scala/org/apache/spark/deploy/yarn/ClientBase.scala ---
@@ -424,29 +431,29 @@ object ClientBase {
}
}
- def populateClasspath(conf: Configuration, sparkConf: SparkConf,
addLog4j: Boolean, env: HashMap[String, String]) {
- Apps.addToEnvironment(env, Environment.CLASSPATH.name,
Environment.PWD.$())
+ def populateClasspath(conf: Configuration, sparkConf: SparkConf,
addLog4j: Boolean, env: HashMap[String, String],
+ extraClassPath: Option[String] = None) {
+
+ /** Add entry to the classpath. */
+ def addClasspathEntry(path: String) = Apps.addToEnvironment(env,
Environment.CLASSPATH.name, path)
+ /** Add entry to the classpath. Interpreted as a path relative to the
working directory. */
+ def addPwdClasspathEntry(entry: String) =
addClasspathEntry(Environment.PWD.$() + Path.SEPARATOR + entry)
+
+ extraClassPath.foreach(addClasspathEntry)
+
+ addClasspathEntry(Environment.PWD.$())
// If log4j present, ensure ours overrides all others
- if (addLog4j) {
- Apps.addToEnvironment(env, Environment.CLASSPATH.name,
Environment.PWD.$() +
- Path.SEPARATOR + LOG4J_PROP)
- }
+ if (addLog4j) addPwdClasspathEntry(LOG4J_PROP)
// Normally the users app.jar is last in case conflicts with spark jars
- val userClasspathFirst =
sparkConf.get("spark.yarn.user.classpath.first", "false")
- .toBoolean
- if (userClasspathFirst) {
- Apps.addToEnvironment(env, Environment.CLASSPATH.name,
Environment.PWD.$() +
- Path.SEPARATOR + APP_JAR)
- }
- Apps.addToEnvironment(env, Environment.CLASSPATH.name,
Environment.PWD.$() +
- Path.SEPARATOR + SPARK_JAR)
- ClientBase.populateHadoopClasspath(conf, env)
-
- if (!userClasspathFirst) {
- Apps.addToEnvironment(env, Environment.CLASSPATH.name,
Environment.PWD.$() +
- Path.SEPARATOR + APP_JAR)
+ if (sparkConf.get("spark.yarn.user.classpath.first",
"false").toBoolean) {
+ addPwdClasspathEntry(APP_JAR)
+ addPwdClasspathEntry(SPARK_JAR)
+ ClientBase.populateHadoopClasspath(conf, env)
+ } else {
+ addPwdClasspathEntry(SPARK_JAR)
+ ClientBase.populateHadoopClasspath(conf, env)
+ addPwdClasspathEntry(APP_JAR)
--- End diff --
Nice, the old code here really bugged me.
---
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.
---