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

Merge pull request #696 from woggle/executor-env

Pass executor env vars (e.g. SPARK_CLASSPATH) to compute-classpath.sh
parents 90fc3f30 531a7e55
No related branches found
No related tags found
No related merge requests found
...@@ -6,6 +6,7 @@ import java.util.{Locale, Random, UUID} ...@@ -6,6 +6,7 @@ import java.util.{Locale, Random, UUID}
import java.util.concurrent.{ConcurrentHashMap, Executors, ThreadFactory, ThreadPoolExecutor} import java.util.concurrent.{ConcurrentHashMap, Executors, ThreadFactory, ThreadPoolExecutor}
import java.util.regex.Pattern import java.util.regex.Pattern
import scala.collection.Map
import scala.collection.mutable.{ArrayBuffer, HashMap} import scala.collection.mutable.{ArrayBuffer, HashMap}
import scala.collection.JavaConversions._ import scala.collection.JavaConversions._
import scala.io.Source import scala.io.Source
...@@ -545,10 +546,15 @@ private object Utils extends Logging { ...@@ -545,10 +546,15 @@ private object Utils extends Logging {
/** /**
* Execute a command and get its output, throwing an exception if it yields a code other than 0. * Execute a command and get its output, throwing an exception if it yields a code other than 0.
*/ */
def executeAndGetOutput(command: Seq[String], workingDir: File = new File(".")): String = { def executeAndGetOutput(command: Seq[String], workingDir: File = new File("."),
val process = new ProcessBuilder(command: _*) extraEnvironment: Map[String, String] = Map.empty): String = {
val builder = new ProcessBuilder(command: _*)
.directory(workingDir) .directory(workingDir)
.start() val environment = builder.environment()
for ((key, value) <- extraEnvironment) {
environment.put(key, value)
}
val process = builder.start()
new Thread("read stderr for " + command(0)) { new Thread("read stderr for " + command(0)) {
override def run() { override def run() {
for (line <- Source.fromInputStream(process.getErrorStream).getLines) { for (line <- Source.fromInputStream(process.getErrorStream).getLines) {
......
...@@ -98,7 +98,9 @@ private[spark] class ExecutorRunner( ...@@ -98,7 +98,9 @@ private[spark] class ExecutorRunner(
// Figure out our classpath with the external compute-classpath script // Figure out our classpath with the external compute-classpath script
val ext = if (System.getProperty("os.name").startsWith("Windows")) ".cmd" else ".sh" val ext = if (System.getProperty("os.name").startsWith("Windows")) ".cmd" else ".sh"
val classPath = Utils.executeAndGetOutput(Seq(sparkHome + "/bin/compute-classpath" + ext)) val classPath = Utils.executeAndGetOutput(
Seq(sparkHome + "/bin/compute-classpath" + ext),
extraEnvironment=appDesc.command.environment)
Seq("-cp", classPath) ++ libraryOpts ++ userOpts ++ memoryOpts Seq("-cp", classPath) ++ libraryOpts ++ userOpts ++ memoryOpts
} }
......
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