Skip to content

Commit

Permalink
[SPARK-24680][DEPLOY] Support spark.executorEnv.JAVA_HOME in Standalo…
Browse files Browse the repository at this point in the history
…ne mode

## What changes were proposed in this pull request?

spark.executorEnv.JAVA_HOME does not take effect when a Worker starting an Executor process in Standalone mode.

This PR fixed this.

## How was this patch tested?

Manual tests.

Closes apache#21663 from stanzhai/fix-executor-env-java-home.

Lead-authored-by: Stan Zhai <[email protected]>
Co-authored-by: Stan Zhai <[email protected]>
Signed-off-by: Sean Owen <[email protected]>
  • Loading branch information
2 people authored and srowen committed Dec 18, 2018
1 parent 218341c commit 4d693ac
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,18 @@ abstract List<String> buildCommand(Map<String, String> env)
*/
List<String> buildJavaCommand(String extraClassPath) throws IOException {
List<String> cmd = new ArrayList<>();
String envJavaHome;

if (javaHome != null) {
cmd.add(join(File.separator, javaHome, "bin", "java"));
} else if ((envJavaHome = System.getenv("JAVA_HOME")) != null) {
cmd.add(join(File.separator, envJavaHome, "bin", "java"));
} else {
cmd.add(join(File.separator, System.getProperty("java.home"), "bin", "java"));
String[] candidateJavaHomes = new String[] {
javaHome,
childEnv.get("JAVA_HOME"),
System.getenv("JAVA_HOME"),
System.getProperty("java.home")
};
for (String javaHome : candidateJavaHomes) {
if (javaHome != null) {
cmd.add(join(File.separator, javaHome, "bin", "java"));
break;
}
}

// Load extra JAVA_OPTS from conf/java-opts, if it exists.
Expand Down

0 comments on commit 4d693ac

Please sign in to comment.