-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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
[SPARK-1774] Respect SparkSubmit --jars on YARN (client) #710
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3bb75e8
Allow SparkSubmit --jars to take effect in yarn-client mode
andrewor14 1407474
Merge branch 'master' of github.com:apache/spark into yarn-jars
andrewor14 013d840
Fix tests
andrewor14 269f9f3
Fix format
andrewor14 c92c5bf
Minor cleanups
andrewor14 c27bf6c
For yarn-cluster and python, do not add primaryResource to spark.jar
andrewor14 35d1928
Merge branch 'master' of github.com:apache/spark into yarn-jars
andrewor14 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,8 +67,7 @@ object SparkSubmit { | |
private[spark] def printWarning(str: String) = printStream.println("Warning: " + str) | ||
|
||
/** | ||
* @return | ||
* a tuple containing the arguments for the child, a list of classpath | ||
* @return a tuple containing the arguments for the child, a list of classpath | ||
* entries for the child, a list of system propertes, a list of env vars | ||
* and the main class for the child | ||
*/ | ||
|
@@ -115,13 +114,16 @@ object SparkSubmit { | |
val sysProps = new HashMap[String, String]() | ||
var childMainClass = "" | ||
|
||
val isPython = args.isPython | ||
val isYarnCluster = clusterManager == YARN && deployOnCluster | ||
|
||
if (clusterManager == MESOS && deployOnCluster) { | ||
printErrorAndExit("Cannot currently run driver on the cluster in Mesos") | ||
} | ||
|
||
// If we're running a Python app, set the Java class to run to be our PythonRunner, add | ||
// Python files to deployment list, and pass the main file and Python path to PythonRunner | ||
if (args.isPython) { | ||
if (isPython) { | ||
if (deployOnCluster) { | ||
printErrorAndExit("Cannot currently run Python driver programs on cluster") | ||
} | ||
|
@@ -161,35 +163,35 @@ object SparkSubmit { | |
val options = List[OptionAssigner]( | ||
OptionAssigner(args.master, ALL_CLUSTER_MGRS, false, sysProp = "spark.master"), | ||
OptionAssigner(args.name, ALL_CLUSTER_MGRS, false, sysProp = "spark.app.name"), | ||
OptionAssigner(args.name, YARN, true, clOption = "--name", sysProp = "spark.app.name"), | ||
OptionAssigner(args.driverExtraClassPath, STANDALONE | YARN, true, | ||
sysProp = "spark.driver.extraClassPath"), | ||
OptionAssigner(args.driverExtraJavaOptions, STANDALONE | YARN, true, | ||
sysProp = "spark.driver.extraJavaOptions"), | ||
OptionAssigner(args.driverExtraLibraryPath, STANDALONE | YARN, true, | ||
sysProp = "spark.driver.extraLibraryPath"), | ||
OptionAssigner(args.driverMemory, YARN, true, clOption = "--driver-memory"), | ||
OptionAssigner(args.name, YARN, true, clOption = "--name", sysProp = "spark.app.name"), | ||
OptionAssigner(args.driverMemory, STANDALONE, true, clOption = "--memory"), | ||
OptionAssigner(args.driverCores, STANDALONE, true, clOption = "--cores"), | ||
OptionAssigner(args.queue, YARN, true, clOption = "--queue"), | ||
OptionAssigner(args.queue, YARN, false, sysProp = "spark.yarn.queue"), | ||
OptionAssigner(args.numExecutors, YARN, true, clOption = "--num-executors"), | ||
OptionAssigner(args.numExecutors, YARN, false, sysProp = "spark.executor.instances"), | ||
OptionAssigner(args.executorMemory, YARN, true, clOption = "--executor-memory"), | ||
OptionAssigner(args.executorMemory, STANDALONE | MESOS | YARN, false, | ||
sysProp = "spark.executor.memory"), | ||
OptionAssigner(args.driverMemory, STANDALONE, true, clOption = "--memory"), | ||
OptionAssigner(args.driverCores, STANDALONE, true, clOption = "--cores"), | ||
OptionAssigner(args.executorCores, YARN, true, clOption = "--executor-cores"), | ||
OptionAssigner(args.executorCores, YARN, false, sysProp = "spark.executor.cores"), | ||
OptionAssigner(args.totalExecutorCores, STANDALONE | MESOS, false, | ||
sysProp = "spark.cores.max"), | ||
OptionAssigner(args.files, YARN, false, sysProp = "spark.yarn.dist.files"), | ||
OptionAssigner(args.files, YARN, true, clOption = "--files"), | ||
OptionAssigner(args.files, LOCAL | STANDALONE | MESOS, false, sysProp = "spark.files"), | ||
OptionAssigner(args.files, LOCAL | STANDALONE | MESOS, true, sysProp = "spark.files"), | ||
OptionAssigner(args.archives, YARN, false, sysProp = "spark.yarn.dist.archives"), | ||
OptionAssigner(args.archives, YARN, true, clOption = "--archives"), | ||
OptionAssigner(args.jars, YARN, true, clOption = "--addJars"), | ||
OptionAssigner(args.files, LOCAL | STANDALONE | MESOS, false, sysProp = "spark.files"), | ||
OptionAssigner(args.files, LOCAL | STANDALONE | MESOS, true, sysProp = "spark.files"), | ||
OptionAssigner(args.jars, LOCAL | STANDALONE | MESOS, false, sysProp = "spark.jars") | ||
OptionAssigner(args.jars, ALL_CLUSTER_MGRS, false, sysProp = "spark.jars") | ||
) | ||
|
||
// For client mode make any added jars immediately visible on the classpath | ||
|
@@ -212,21 +214,22 @@ object SparkSubmit { | |
} | ||
} | ||
|
||
// For standalone mode, add the application jar automatically so the user doesn't have to | ||
// call sc.addJar. TODO: Standalone mode in the cluster | ||
if (clusterManager == STANDALONE) { | ||
// Add the application jar automatically so the user doesn't have to call sc.addJar | ||
// For YARN cluster mode, the jar is already distributed on each node as "app.jar" | ||
// For python files, the primary resource is already distributed as a regular file | ||
if (!isYarnCluster && !isPython) { | ||
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 is the line that adds the application jar automatically for all modes, except for yarn-cluster and python. (Previously, this was done only for standalone) |
||
var jars = sysProps.get("spark.jars").map(x => x.split(",").toSeq).getOrElse(Seq()) | ||
if (args.primaryResource != RESERVED_JAR_NAME) { | ||
jars = jars ++ Seq(args.primaryResource) | ||
} | ||
sysProps.put("spark.jars", jars.mkString(",")) | ||
} | ||
|
||
// Standalone cluster specific configurations | ||
if (deployOnCluster && clusterManager == STANDALONE) { | ||
if (args.supervise) { | ||
childArgs += "--supervise" | ||
} | ||
|
||
childMainClass = "org.apache.spark.deploy.Client" | ||
childArgs += "launch" | ||
childArgs += (args.master, args.primaryResource, args.mainClass) | ||
|
@@ -243,16 +246,20 @@ object SparkSubmit { | |
} | ||
} | ||
|
||
// Read from default spark properties, if any | ||
for ((k, v) <- args.getDefaultSparkProperties) { | ||
if (!sysProps.contains(k)) sysProps(k) = v | ||
} | ||
|
||
(childArgs, childClasspath, sysProps, childMainClass) | ||
} | ||
|
||
private def launch(childArgs: ArrayBuffer[String], childClasspath: ArrayBuffer[String], | ||
sysProps: Map[String, String], childMainClass: String, verbose: Boolean = false) | ||
{ | ||
private def launch( | ||
childArgs: ArrayBuffer[String], | ||
childClasspath: ArrayBuffer[String], | ||
sysProps: Map[String, String], | ||
childMainClass: String, | ||
verbose: Boolean = false) { | ||
if (verbose) { | ||
printStream.println(s"Main class:\n$childMainClass") | ||
printStream.println(s"Arguments:\n${childArgs.mkString("\n")}") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is the line that makes SparkSubmit respect
--jars
for yarn-client mode