Skip to content
Snippets Groups Projects
Commit e49bc8ca authored by Matei Zaharia's avatar Matei Zaharia
Browse files

Merge pull request #663 from stephenh/option_and_getenv

Be cute with Option and getenv.
parents 32370da4 d7011632
No related branches found
No related tags found
No related merge requests found
package spark.deploy.worker package spark.deploy.worker
import java.io._ import java.io._
import java.lang.System.getenv
import spark.deploy.{ExecutorState, ExecutorStateChanged, ApplicationDescription} import spark.deploy.{ExecutorState, ExecutorStateChanged, ApplicationDescription}
import akka.actor.ActorRef import akka.actor.ActorRef
import spark.{Utils, Logging} import spark.{Utils, Logging}
...@@ -77,11 +78,7 @@ private[spark] class ExecutorRunner( ...@@ -77,11 +78,7 @@ private[spark] class ExecutorRunner(
def buildCommandSeq(): Seq[String] = { def buildCommandSeq(): Seq[String] = {
val command = appDesc.command val command = appDesc.command
val runner = if (System.getenv("JAVA_HOME") == null) { val runner = Option(getenv("JAVA_HOME")).map(_ + "/bin/java").getOrElse("java")
"java"
} else {
System.getenv("JAVA_HOME") + "/bin/java"
}
// SPARK-698: do not call the run.cmd script, as process.destroy() // SPARK-698: do not call the run.cmd script, as process.destroy()
// fails to kill a process tree on Windows // fails to kill a process tree on Windows
Seq(runner) ++ buildJavaOpts() ++ Seq(command.mainClass) ++ Seq(runner) ++ buildJavaOpts() ++ Seq(command.mainClass) ++
...@@ -93,18 +90,10 @@ private[spark] class ExecutorRunner( ...@@ -93,18 +90,10 @@ private[spark] class ExecutorRunner(
* the way the JAVA_OPTS are assembled there. * the way the JAVA_OPTS are assembled there.
*/ */
def buildJavaOpts(): Seq[String] = { def buildJavaOpts(): Seq[String] = {
val libraryOpts = if (System.getenv("SPARK_LIBRARY_PATH") == null) { val libraryOpts = Option(getenv("SPARK_LIBRARY_PATH"))
Nil .map(p => List("-Djava.library.path=" + p))
} else { .getOrElse(Nil)
List("-Djava.library.path=" + System.getenv("SPARK_LIBRARY_PATH")) val userOpts = Option(getenv("SPARK_JAVA_OPTS")).map(Utils.splitCommandString).getOrElse(Nil)
}
val userOpts = if (System.getenv("SPARK_JAVA_OPTS") == null) {
Nil
} else {
Utils.splitCommandString(System.getenv("SPARK_JAVA_OPTS"))
}
val memoryOpts = Seq("-Xms" + memory + "M", "-Xmx" + memory + "M") val memoryOpts = Seq("-Xms" + memory + "M", "-Xmx" + memory + "M")
// Figure out our classpath with the external compute-classpath script // Figure out our classpath with the external compute-classpath script
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment