Skip to content

Commit

Permalink
SPARK-1746: Support setting SPARK_JAVA_OPTS on executors for backward…
Browse files Browse the repository at this point in the history
…s compatibility

Author: Patrick Wendell <[email protected]>

Closes apache#676 from pwendell/worker-opts and squashes the following commits:

54456c4 [Patrick Wendell] SPARK-1746: Support setting SPARK_JAVA_OPTS on executors for backwards compatibility
  • Loading branch information
pwendell committed May 7, 2014
1 parent fdae095 commit 913a0a9
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,16 @@ object CommandUtils extends Logging {
*/
def buildJavaOpts(command: Command, memory: Int, sparkHome: String): Seq[String] = {
val memoryOpts = Seq(s"-Xms${memory}M", s"-Xmx${memory}M")
// Note, this will coalesce multiple options into a single command component
val extraOpts = command.extraJavaOptions.map(Utils.splitCommandString).getOrElse(Seq())

// Exists for backwards compatibility with older Spark versions
val workerLocalOpts = Option(getenv("SPARK_JAVA_OPTS")).map(Utils.splitCommandString)
.getOrElse(Nil)
if (workerLocalOpts.length > 0) {
logWarning("SPARK_JAVA_OPTS was set on the worker. It is deprecated in Spark 1.0.")
logWarning("Set SPARK_LOCAL_DIRS for node-specific storage locations.")
}

val libraryOpts =
if (command.libraryPathEntries.size > 0) {
val joined = command.libraryPathEntries.mkString(File.pathSeparator)
Expand All @@ -66,7 +73,7 @@ object CommandUtils extends Logging {
val userClassPath = command.classPathEntries ++ Seq(classPath)

Seq("-cp", userClassPath.filterNot(_.isEmpty).mkString(File.pathSeparator)) ++
libraryOpts ++ extraOpts ++ memoryOpts
libraryOpts ++ extraOpts ++ workerLocalOpts ++ memoryOpts
}

/** Spawn a thread that will redirect a given stream to a file */
Expand Down

0 comments on commit 913a0a9

Please sign in to comment.