Skip to content

Commit

Permalink
Automatically add user jar
Browse files Browse the repository at this point in the history
  • Loading branch information
pwendell committed Apr 18, 2014
1 parent a56b125 commit af0adf7
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ object SparkSubmit {
val file = new File(filename)
getDefaultProperties(file).foreach { case (k, v) =>
if (k.startsWith("spark")) {
if (k == "spark.master")
throw new Exception("Setting spark.master in spark-defaults.properties is not " +
"supported. Use MASTER environment variable or --master.")
sysProps(k) = v
if (appArgs.verbose) printStream.println(s"Adding default property: $k=$v")
}
Expand Down Expand Up @@ -165,10 +168,11 @@ object SparkSubmit {
new OptionAssigner(appArgs.files, YARN, true, clOption = "--files"),
new OptionAssigner(appArgs.archives, YARN, false, sysProp = "spark.yarn.dist.archives"),
new OptionAssigner(appArgs.archives, YARN, true, clOption = "--archives"),
new OptionAssigner(appArgs.jars, YARN, true, clOption = "--addJars")
new OptionAssigner(appArgs.jars, YARN, true, clOption = "--addJars"),
new OptionAssigner(appArgs.jars, STANDALONE | YARN | MESOS, true, sysProp = "spark.jars")
)

// more jars
// For client mode make any added jars immediately visible on the classpath
if (appArgs.jars != null && !deployOnCluster) {
for (jar <- appArgs.jars.split(",")) {
childClasspath += jar
Expand All @@ -186,6 +190,14 @@ 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) {
val existingJars = sysProps.get("spark.jars").map(x => x.split(",").toSeq).getOrElse(Seq())
sysProps.put("spark.jars", (existingJars ++ Seq(appArgs.primaryResource)).mkString(","))
println("SPARK JARS" + sysProps.get("spark.jars"))
}

if (deployOnCluster && clusterManager == STANDALONE) {
if (appArgs.supervise) {
childArgs += "--supervise"
Expand All @@ -196,7 +208,7 @@ object SparkSubmit {
childArgs += (appArgs.master, appArgs.primaryResource, appArgs.mainClass)
}

// args
// Arguments to be passed to user program
if (appArgs.childArgs != null) {
if (!deployOnCluster || clusterManager == STANDALONE) {
childArgs ++= appArgs.childArgs
Expand Down

0 comments on commit af0adf7

Please sign in to comment.