Skip to content

Commit

Permalink
For yarn-cluster and python, do not add primaryResource to spark.jar
Browse files Browse the repository at this point in the history
These scenarios already distribute the primary resource properly. See
code comments for more detail.
  • Loading branch information
andrewor14 committed May 9, 2014
1 parent c92c5bf commit c27bf6c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
17 changes: 12 additions & 5 deletions core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -114,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")
}
Expand Down Expand Up @@ -212,11 +215,15 @@ object SparkSubmit {
}

// Add the application jar automatically so the user doesn't have to call sc.addJar
var jars = sysProps.get("spark.jars").map(x => x.split(",").toSeq).getOrElse(Seq())
if (args.primaryResource != RESERVED_JAR_NAME) {
jars = jars ++ Seq(args.primaryResource)
// 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) {
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(","))
}
sysProps.put("spark.jars", jars.mkString(","))

// Standalone cluster specific configurations
if (deployOnCluster && clusterManager == STANDALONE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ class SparkSubmitSuite extends FunSuite with ShouldMatchers {
val clArgs = Seq(
"--name", "myApp",
"--class", "Foo",
"userjar.jar", "some",
"userjar.jar",
"some",
"--weird", "args")
val appArgs = new SparkSubmitArguments(clArgs)
appArgs.childArgs should be (Seq("some", "--weird", "args"))
Expand Down Expand Up @@ -138,7 +139,6 @@ class SparkSubmitSuite extends FunSuite with ShouldMatchers {
mainClass should be ("org.apache.spark.deploy.yarn.Client")
classpath should have length (0)
sysProps("spark.app.name") should be ("beauty")
sysProps("spark.jars") should be ("thejar.jar")
sysProps("SPARK_SUBMIT") should be ("true")
}

Expand Down

0 comments on commit c27bf6c

Please sign in to comment.