-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-1870] Made deployment with --jars work in yarn-standalone mode. #1013
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
0956af9
ab94aa1
3cc1085
b085f10
c5696f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,8 +21,7 @@ import java.net.{InetAddress, UnknownHostException, URI} | |
| import java.nio.ByteBuffer | ||
|
|
||
| import scala.collection.JavaConversions._ | ||
| import scala.collection.mutable.HashMap | ||
| import scala.collection.mutable.Map | ||
| import scala.collection.mutable.{ListBuffer, HashMap, Map} | ||
|
|
||
| import org.apache.hadoop.conf.Configuration | ||
| import org.apache.hadoop.fs.{FileContext, FileStatus, FileSystem, Path, FileUtil} | ||
|
|
@@ -281,18 +280,19 @@ class Client(args: ClientArguments, conf: Configuration, sparkConf: SparkConf) | |
| } | ||
|
|
||
| // Handle jars local to the ApplicationMaster. | ||
| var cachedSecondaryJarLinks = ListBuffer.empty[String] | ||
| if ((args.addJars != null) && (!args.addJars.isEmpty())){ | ||
| args.addJars.split(',').foreach { case file: String => | ||
| val localURI = new URI(file.trim()) | ||
| val localPath = new Path(localURI) | ||
| val linkname = Option(localURI.getFragment()).getOrElse(localPath.getName()) | ||
| val destPath = copyRemoteFile(dst, localPath, replication) | ||
| // Only add the resource to the Spark ApplicationMaster. | ||
| val appMasterOnly = true | ||
| distCacheMgr.addResource(fs, conf, destPath, localResources, LocalResourceType.FILE, | ||
| linkname, statCache, appMasterOnly) | ||
| linkname, statCache) | ||
| cachedSecondaryJarLinks += linkname | ||
| } | ||
| } | ||
| sparkConf.set(Client.CONF_SPARK_YARN_SECONDARY_JARS, cachedSecondaryJarLinks.mkString(",")) | ||
|
|
||
| // Handle any distributed cache files | ||
| if ((args.files != null) && (!args.files.isEmpty())){ | ||
|
|
@@ -478,9 +478,10 @@ class Client(args: ClientArguments, conf: Configuration, sparkConf: SparkConf) | |
| } | ||
|
|
||
| object Client { | ||
| val SPARK_JAR: String = "spark.jar" | ||
| val APP_JAR: String = "app.jar" | ||
| val SPARK_JAR: String = "__spark__.jar" | ||
| val APP_JAR: String = "__app__.jar" | ||
| val LOG4J_PROP: String = "log4j.properties" | ||
| val CONF_SPARK_YARN_SECONDARY_JARS = "spark.yarn.secondary.jars" | ||
|
|
||
| def main(argStrings: Array[String]) { | ||
| // Set an env variable indicating we are running in YARN mode. | ||
|
|
@@ -507,12 +508,19 @@ object Client { | |
| Apps.addToEnvironment(env, Environment.CLASSPATH.name, Environment.PWD.$() + | ||
| Path.SEPARATOR + LOG4J_PROP) | ||
| } | ||
|
|
||
| val cachedSecondaryJarLinks = | ||
| sparkConf.getOption(CONF_SPARK_YARN_SECONDARY_JARS).getOrElse("").split(",") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This actually returns a one element
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. You are right. It will add empty string to array, and then add the folder without file into classpath. Will fix in master as well. |
||
|
|
||
| // Normally the users app.jar is last in case conflicts with spark jars | ||
| val userClasspathFirst = sparkConf.get("spark.yarn.user.classpath.first", "false") | ||
| .toBoolean | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. minor: Not your code, but could you bump |
||
| if (userClasspathFirst) { | ||
| Apps.addToEnvironment(env, Environment.CLASSPATH.name, Environment.PWD.$() + | ||
| Path.SEPARATOR + APP_JAR) | ||
| cachedSecondaryJarLinks.foreach(jarLink => | ||
| Apps.addToEnvironment(env, Environment.CLASSPATH.name, Environment.PWD.$() + | ||
| Path.SEPARATOR + jarLink)) | ||
| } | ||
| Apps.addToEnvironment(env, Environment.CLASSPATH.name, Environment.PWD.$() + | ||
| Path.SEPARATOR + SPARK_JAR) | ||
|
|
@@ -521,6 +529,9 @@ object Client { | |
| if (!userClasspathFirst) { | ||
| Apps.addToEnvironment(env, Environment.CLASSPATH.name, Environment.PWD.$() + | ||
| Path.SEPARATOR + APP_JAR) | ||
| cachedSecondaryJarLinks.foreach(jarLink => | ||
| Apps.addToEnvironment(env, Environment.CLASSPATH.name, Environment.PWD.$() + | ||
| Path.SEPARATOR + jarLink)) | ||
| } | ||
| Apps.addToEnvironment(env, Environment.CLASSPATH.name, Environment.PWD.$() + | ||
| Path.SEPARATOR + "*") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be a val
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thks.