Skip to content
Snippets Groups Projects
Commit 069ecfef authored by Andrew Or's avatar Andrew Or
Browse files

[SPARK-3264] Allow users to set executor Spark home in Mesos


The executors and the driver may not share the same Spark home. There is currently one way to set the executor side Spark home in Mesos, through setting `spark.home`. However, this is neither documented nor intuitive. This PR adds a more specific config `spark.mesos.executor.home` and exposes this to the user.

liancheng tnachen

Author: Andrew Or <andrewor14@gmail.com>

Closes #2166 from andrewor14/mesos-spark-home and squashes the following commits:

b87965e [Andrew Or] Merge branch 'master' of github.com:apache/spark into mesos-spark-home
f6abb2e [Andrew Or] Document spark.mesos.executor.home
ca7846d [Andrew Or] Add more specific configuration for executor Spark home in Mesos

(cherry picked from commit 41dc5987)
Signed-off-by: default avatarAndrew Or <andrewor14@gmail.com>
parent fd98020a
No related branches found
No related tags found
No related merge requests found
...@@ -71,9 +71,11 @@ private[spark] class CoarseMesosSchedulerBackend( ...@@ -71,9 +71,11 @@ private[spark] class CoarseMesosSchedulerBackend(
val taskIdToSlaveId = new HashMap[Int, String] val taskIdToSlaveId = new HashMap[Int, String]
val failuresBySlaveId = new HashMap[String, Int] // How many times tasks on each slave failed val failuresBySlaveId = new HashMap[String, Int] // How many times tasks on each slave failed
val sparkHome = sc.getSparkHome().getOrElse(throw new SparkException( val executorSparkHome = conf.getOption("spark.mesos.executor.home")
"Spark home is not set; set it through the spark.home system " + .orElse(sc.getSparkHome())
"property, the SPARK_HOME environment variable or the SparkContext constructor")) .getOrElse {
throw new SparkException("Executor Spark home `spark.mesos.executor.home` is not set!")
}
val extraCoresPerSlave = conf.getInt("spark.mesos.extra.cores", 0) val extraCoresPerSlave = conf.getInt("spark.mesos.extra.cores", 0)
...@@ -144,7 +146,7 @@ private[spark] class CoarseMesosSchedulerBackend( ...@@ -144,7 +146,7 @@ private[spark] class CoarseMesosSchedulerBackend(
val uri = conf.get("spark.executor.uri", null) val uri = conf.get("spark.executor.uri", null)
if (uri == null) { if (uri == null) {
val runScript = new File(sparkHome, "./bin/spark-class").getCanonicalPath val runScript = new File(executorSparkHome, "./bin/spark-class").getCanonicalPath
command.setValue( command.setValue(
"\"%s\" org.apache.spark.executor.CoarseGrainedExecutorBackend %s %s %s %d".format( "\"%s\" org.apache.spark.executor.CoarseGrainedExecutorBackend %s %s %s %d".format(
runScript, driverUrl, offer.getSlaveId.getValue, offer.getHostname, numCores)) runScript, driverUrl, offer.getSlaveId.getValue, offer.getHostname, numCores))
......
...@@ -86,9 +86,11 @@ private[spark] class MesosSchedulerBackend( ...@@ -86,9 +86,11 @@ private[spark] class MesosSchedulerBackend(
} }
def createExecutorInfo(execId: String): ExecutorInfo = { def createExecutorInfo(execId: String): ExecutorInfo = {
val sparkHome = sc.getSparkHome().getOrElse(throw new SparkException( val executorSparkHome = sc.conf.getOption("spark.mesos.executor.home")
"Spark home is not set; set it through the spark.home system " + .orElse(sc.getSparkHome()) // Fall back to driver Spark home for backward compatibility
"property, the SPARK_HOME environment variable or the SparkContext constructor")) .getOrElse {
throw new SparkException("Executor Spark home `spark.mesos.executor.home` is not set!")
}
val environment = Environment.newBuilder() val environment = Environment.newBuilder()
sc.conf.getOption("spark.executor.extraClassPath").foreach { cp => sc.conf.getOption("spark.executor.extraClassPath").foreach { cp =>
environment.addVariables( environment.addVariables(
...@@ -114,7 +116,7 @@ private[spark] class MesosSchedulerBackend( ...@@ -114,7 +116,7 @@ private[spark] class MesosSchedulerBackend(
.setEnvironment(environment) .setEnvironment(environment)
val uri = sc.conf.get("spark.executor.uri", null) val uri = sc.conf.get("spark.executor.uri", null)
if (uri == null) { if (uri == null) {
command.setValue(new File(sparkHome, "/sbin/spark-executor").getCanonicalPath) command.setValue(new File(executorSparkHome, "/sbin/spark-executor").getCanonicalPath)
} else { } else {
// Grab everything to the first '.'. We'll use that and '*' to // Grab everything to the first '.'. We'll use that and '*' to
// glob the directory "correctly". // glob the directory "correctly".
......
...@@ -214,6 +214,16 @@ Apart from these, the following properties are also available, and may be useful ...@@ -214,6 +214,16 @@ Apart from these, the following properties are also available, and may be useful
process. The user can specify multiple of these and to set multiple environment variables. process. The user can specify multiple of these and to set multiple environment variables.
</td> </td>
</tr> </tr>
<tr>
<td><code>spark.mesos.executor.home</code></td>
<td>driver side <code>SPARK_HOME</code></td>
<td>
Set the directory in which Spark is installed on the executors in Mesos. By default, the
executors will simply use the driver's Spark home directory, which may not be visible to
them. Note that this is only relevant if a Spark binary package is not specified through
<code>spark.executor.uri</code>.
</td>
</tr>
</table> </table>
#### Shuffle Behavior #### Shuffle Behavior
......
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