Skip to content

Commit 913a0a9

Browse files
committed
SPARK-1746: Support setting SPARK_JAVA_OPTS on executors for backwards compatibility
Author: Patrick Wendell <pwendell@gmail.com> 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
1 parent fdae095 commit 913a0a9

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

core/src/main/scala/org/apache/spark/deploy/worker/CommandUtils.scala

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,16 @@ object CommandUtils extends Logging {
4747
*/
4848
def buildJavaOpts(command: Command, memory: Int, sparkHome: String): Seq[String] = {
4949
val memoryOpts = Seq(s"-Xms${memory}M", s"-Xmx${memory}M")
50-
// Note, this will coalesce multiple options into a single command component
5150
val extraOpts = command.extraJavaOptions.map(Utils.splitCommandString).getOrElse(Seq())
5251

52+
// Exists for backwards compatibility with older Spark versions
53+
val workerLocalOpts = Option(getenv("SPARK_JAVA_OPTS")).map(Utils.splitCommandString)
54+
.getOrElse(Nil)
55+
if (workerLocalOpts.length > 0) {
56+
logWarning("SPARK_JAVA_OPTS was set on the worker. It is deprecated in Spark 1.0.")
57+
logWarning("Set SPARK_LOCAL_DIRS for node-specific storage locations.")
58+
}
59+
5360
val libraryOpts =
5461
if (command.libraryPathEntries.size > 0) {
5562
val joined = command.libraryPathEntries.mkString(File.pathSeparator)
@@ -66,7 +73,7 @@ object CommandUtils extends Logging {
6673
val userClassPath = command.classPathEntries ++ Seq(classPath)
6774

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

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

0 commit comments

Comments
 (0)