Github user liancheng commented on a diff in the pull request:
https://github.com/apache/spark/pull/2103#discussion_r16692779
--- Diff:
core/src/main/scala/org/apache/spark/scheduler/cluster/mesos/CoarseMesosSchedulerBackend.scala
---
@@ -111,48 +113,39 @@ private[spark] class CoarseMesosSchedulerBackend(
def createCommand(offer: Offer, numCores: Int): CommandInfo = {
val environment = Environment.newBuilder()
- val extraClassPath = conf.getOption("spark.executor.extraClassPath")
- extraClassPath.foreach { cp =>
- environment.addVariables(
-
Environment.Variable.newBuilder().setName("SPARK_CLASSPATH").setValue(cp).build())
- }
+ val mesosCommand = CommandInfo.newBuilder()
+ .setEnvironment(environment)
+
+ val driverUrl = "akka.tcp://spark@%s:%s/user/%s".format(
+ conf.get("spark.driver.host"), conf.get("spark.driver.port"),
+ CoarseGrainedSchedulerBackend.ACTOR_NAME)
+ val args = Seq(driverUrl, offer.getSlaveId.getValue,
offer.getHostname, numCores.toString)
val extraJavaOpts = conf.getOption("spark.executor.extraJavaOptions")
+ .map(Utils.splitCommandString).getOrElse(Seq.empty)
- val libraryPathOption = "spark.executor.extraLibraryPath"
- val extraLibraryPath = conf.getOption(libraryPathOption).map(p =>
s"-Djava.library.path=$p")
- val extraOpts = Seq(extraJavaOpts,
extraLibraryPath).flatten.mkString(" ")
+ // Start executors with a few necessary configs for registering with
the scheduler
+ val sparkJavaOpts = Utils.sparkJavaOpts(conf,
SparkConf.isExecutorStartupConf)
+ val javaOpts = sparkJavaOpts ++ extraJavaOpts
- sc.executorEnvs.foreach { case (key, value) =>
- environment.addVariables(Environment.Variable.newBuilder()
- .setName(key)
- .setValue(value)
- .build())
+ val classPathEntries =
conf.getOption("spark.executor.extraClassPath").toSeq.flatMap { cp =>
+ cp.split(java.io.File.pathSeparator)
}
- val command = CommandInfo.newBuilder()
- .setEnvironment(environment)
- val driverUrl = "akka.tcp://spark@%s:%s/user/%s".format(
- conf.get("spark.driver.host"),
- conf.get("spark.driver.port"),
- CoarseGrainedSchedulerBackend.ACTOR_NAME)
+ val libraryPathEntries =
+ conf.getOption("spark.executor.extraLibraryPath").toSeq.flatMap { cp
=>
+ cp.split(java.io.File.pathSeparator)
+ }
+
+ val command = Command(
+ "org.apache.spark.executor.CoarseGrainedExecutorBackend", args,
sc.executorEnvs,
+ classPathEntries, libraryPathEntries, javaOpts)
val uri = conf.get("spark.executor.uri", null)
- if (uri == null) {
- val runScript = new File(sparkHome,
"./bin/spark-class").getCanonicalPath
- command.setValue(
- "\"%s\" org.apache.spark.executor.CoarseGrainedExecutorBackend %s
%s %s %s %d".format(
- runScript, extraOpts, driverUrl, offer.getSlaveId.getValue,
offer.getHostname, numCores))
- } else {
- // Grab everything to the first '.'. We'll use that and '*' to
- // glob the directory "correctly".
- val basename = uri.split('/').last.split('.').head
- command.setValue(
- ("cd %s*; " +
- "./bin/spark-class
org.apache.spark.executor.CoarseGrainedExecutorBackend %s %s %s %s %d")
- .format(basename, extraOpts, driverUrl,
offer.getSlaveId.getValue,
- offer.getHostname, numCores))
- command.addUris(CommandInfo.URI.newBuilder().setValue(uri))
+ mesosCommand.setValue(CommandUtils.buildCommandSeq(command,
sc.executorMemory,
+ sparkHome).mkString("\"", "\" \"", "\""))
--- End diff --
I don't think `sparkHome` works for the `uri != null` branch. Since
executors inherit their `spark.home` property from the driver, but in case of
Mesos, each executor has it's own Spark home in its own sandbox directory.
That's why `basename` and the `cd %s*` trick is used here.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]