@@ -1212,7 +1212,7 @@ object Client extends Logging {
12121212 } else {
12131213 getMainJarUri(sparkConf.getOption(CONF_SPARK_USER_JAR ))
12141214 }
1215- mainJar.foreach(addFileToClasspath(sparkConf, _, APP_JAR , env))
1215+ mainJar.foreach(addFileToClasspath(sparkConf, conf, _, APP_JAR , env))
12161216
12171217 val secondaryJars =
12181218 if (args != null ) {
@@ -1221,10 +1221,10 @@ object Client extends Logging {
12211221 getSecondaryJarUris(sparkConf.getOption(CONF_SPARK_YARN_SECONDARY_JARS ))
12221222 }
12231223 secondaryJars.foreach { x =>
1224- addFileToClasspath(sparkConf, x, null , env)
1224+ addFileToClasspath(sparkConf, conf, x, null , env)
12251225 }
12261226 }
1227- addFileToClasspath(sparkConf, new URI (sparkJar(sparkConf)), SPARK_JAR , env)
1227+ addFileToClasspath(sparkConf, conf, new URI (sparkJar(sparkConf)), SPARK_JAR , env)
12281228 populateHadoopClasspath(conf, env)
12291229 sys.env.get(ENV_DIST_CLASSPATH ).foreach { cp =>
12301230 addClasspathEntry(getClusterPath(sparkConf, cp), env)
@@ -1259,15 +1259,17 @@ object Client extends Logging {
12591259 * If an alternate name for the file is given, and it's not a "local:" file, the alternate
12601260 * name will be added to the classpath (relative to the job's work directory).
12611261 *
1262- * If not a "local:" file and no alternate name, the environment is not modified .
1262+ * If not a "local:" file and no alternate name, the linkName will be added to the classpath .
12631263 *
1264- * @param conf Spark configuration.
1265- * @param uri URI to add to classpath (optional).
1266- * @param fileName Alternate name for the file (optional).
1267- * @param env Map holding the environment variables.
1264+ * @param conf Spark configuration.
1265+ * @param hadoopConf Hadoop configuration.
1266+ * @param uri URI to add to classpath (optional).
1267+ * @param fileName Alternate name for the file (optional).
1268+ * @param env Map holding the environment variables.
12681269 */
12691270 private def addFileToClasspath (
12701271 conf : SparkConf ,
1272+ hadoopConf : Configuration ,
12711273 uri : URI ,
12721274 fileName : String ,
12731275 env : HashMap [String , String ]): Unit = {
@@ -1276,6 +1278,11 @@ object Client extends Logging {
12761278 } else if (fileName != null ) {
12771279 addClasspathEntry(buildPath(
12781280 YarnSparkHadoopUtil .expandEnvironment(Environment .PWD ), fileName), env)
1281+ } else if (uri != null ) {
1282+ val localPath = getQualifiedLocalPath(uri, hadoopConf)
1283+ val linkName = Option (uri.getFragment()).getOrElse(localPath.getName())
1284+ addClasspathEntry(buildPath(
1285+ YarnSparkHadoopUtil .expandEnvironment(Environment .PWD ), linkName), env)
12791286 }
12801287 }
12811288
0 commit comments