Skip to content

Commit 9b2b612

Browse files
committed
init commit
1 parent 5994cfe commit 9b2b612

File tree

1 file changed

+15
-7
lines changed
  • yarn/src/main/scala/org/apache/spark/deploy/yarn

1 file changed

+15
-7
lines changed

yarn/src/main/scala/org/apache/spark/deploy/yarn/Client.scala

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,7 @@ private[spark] class Client(
537537
val env = new HashMap[String, String]()
538538
val extraCp = sparkConf.getOption("spark.driver.extraClassPath")
539539
populateClasspath(args, yarnConf, sparkConf, env, true, extraCp)
540+
logInfo("Environment.CLASSPATH: " + env.get(Environment.CLASSPATH.name))
540541
env("SPARK_YARN_MODE") = "true"
541542
env("SPARK_YARN_STAGING_DIR") = stagingDir
542543
env("SPARK_USER") = UserGroupInformation.getCurrentUser().getShortUserName()
@@ -1164,7 +1165,7 @@ object Client extends Logging {
11641165
} else {
11651166
getMainJarUri(sparkConf.getOption(CONF_SPARK_USER_JAR))
11661167
}
1167-
mainJar.foreach(addFileToClasspath(sparkConf, _, APP_JAR, env))
1168+
mainJar.foreach(addFileToClasspath(sparkConf, conf, _, APP_JAR, env))
11681169

11691170
val secondaryJars =
11701171
if (args != null) {
@@ -1173,10 +1174,10 @@ object Client extends Logging {
11731174
getSecondaryJarUris(sparkConf.getOption(CONF_SPARK_YARN_SECONDARY_JARS))
11741175
}
11751176
secondaryJars.foreach { x =>
1176-
addFileToClasspath(sparkConf, x, null, env)
1177+
addFileToClasspath(sparkConf, conf, x, null, env)
11771178
}
11781179
}
1179-
addFileToClasspath(sparkConf, new URI(sparkJar(sparkConf)), SPARK_JAR, env)
1180+
addFileToClasspath(sparkConf, conf, new URI(sparkJar(sparkConf)), SPARK_JAR, env)
11801181
populateHadoopClasspath(conf, env)
11811182
sys.env.get(ENV_DIST_CLASSPATH).foreach { cp =>
11821183
addClasspathEntry(getClusterPath(sparkConf, cp), env)
@@ -1213,13 +1214,15 @@ object Client extends Logging {
12131214
*
12141215
* If not a "local:" file and no alternate name, the environment is not modified.
12151216
*
1216-
* @param conf Spark configuration.
1217-
* @param uri URI to add to classpath (optional).
1218-
* @param fileName Alternate name for the file (optional).
1219-
* @param env Map holding the environment variables.
1217+
* @param conf Spark configuration.
1218+
* @param hadoopConf Hadoop configuration.
1219+
* @param uri URI to add to classpath (optional).
1220+
* @param fileName Alternate name for the file (optional).
1221+
* @param env Map holding the environment variables.
12201222
*/
12211223
private def addFileToClasspath(
12221224
conf: SparkConf,
1225+
hadoopConf: Configuration,
12231226
uri: URI,
12241227
fileName: String,
12251228
env: HashMap[String, String]): Unit = {
@@ -1228,6 +1231,11 @@ object Client extends Logging {
12281231
} else if (fileName != null) {
12291232
addClasspathEntry(buildPath(
12301233
YarnSparkHadoopUtil.expandEnvironment(Environment.PWD), fileName), env)
1234+
} else {
1235+
val localPath = getQualifiedLocalPath(localURI, hadoopConf)
1236+
val linkName = Option(localURI.getFragment()).getOrElse(localPath.getName())
1237+
addClasspathEntry(buildPath(
1238+
YarnSparkHadoopUtil.expandEnvironment(Environment.PWD), linkName), env)
12311239
}
12321240
}
12331241

0 commit comments

Comments
 (0)