-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-2608] fix executor backend launch commond over mesos mode #1986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 14 commits
5b150a4
fdc3cb1
4290c71
bc92bdb
bb5ada5
a954c5c
14578b2
7192f6f
d80e455
4f701b5
e515fc8
80d99b0
4f694c0
0e65083
3e73513
3b8a276
2fe459a
c2fe5b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,6 @@ | |
|
|
||
| package org.apache.spark.scheduler.cluster.mesos | ||
|
|
||
| import java.io.File | ||
| import java.util.{ArrayList => JArrayList, List => JList} | ||
| import java.util.Collections | ||
|
|
||
|
|
@@ -29,9 +28,12 @@ import org.apache.mesos.{Scheduler => MScheduler} | |
| import org.apache.mesos._ | ||
| import org.apache.mesos.Protos.{TaskInfo => MesosTaskInfo, TaskState => MesosTaskState, _} | ||
|
|
||
| import org.apache.spark.{Logging, SparkContext, SparkException, TaskState} | ||
| import org.apache.spark.{SparkConf, Logging, SparkContext, TaskState, SparkException} | ||
| import org.apache.spark.scheduler.{ExecutorExited, ExecutorLossReason, SchedulerBackend, SlaveLost, TaskDescription, TaskSchedulerImpl, WorkerOffer} | ||
| import org.apache.spark.util.Utils | ||
| import org.apache.spark.deploy.Command | ||
| import org.apache.spark.deploy.worker.CommandUtils | ||
| import org.apache.spark.util.Utils | ||
|
|
||
| /** | ||
| * A SchedulerBackend for running fine-grained tasks on Mesos. Each Spark task is mapped to a | ||
|
|
@@ -56,6 +58,7 @@ private[spark] class MesosSchedulerBackend( | |
| // Which slave IDs we have executors on | ||
| val slaveIdsWithExecutors = new HashSet[String] | ||
| val taskIdToSlaveId = new HashMap[Long, String] | ||
| val conf = sc.conf | ||
|
|
||
| // An ExecutorInfo for our tasks | ||
| var execArgs: Array[Byte] = null | ||
|
|
@@ -96,26 +99,47 @@ private[spark] class MesosSchedulerBackend( | |
| .setValue(value) | ||
| .build()) | ||
| } | ||
| val command = CommandInfo.newBuilder() | ||
| val mesosCommand = CommandInfo.newBuilder() | ||
| .setEnvironment(environment) | ||
| val uri = sc.conf.get("spark.executor.uri", null) | ||
| if (uri == null) { | ||
| command.setValue(new File(sparkHome, "/sbin/spark-executor").getCanonicalPath) | ||
|
|
||
| val extraJavaOpts = conf.getOption("spark.executor.extraJavaOptions") | ||
| .map(Utils.splitCommandString).getOrElse(Seq.empty) | ||
|
|
||
| // Start executors with a few necessary configs for registering with the scheduler | ||
| val sparkJavaOpts = Utils.sparkJavaOpts(conf, SparkConf.isExecutorStartupConf) | ||
| val javaOpts = sparkJavaOpts ++ extraJavaOpts | ||
|
|
||
| val classPathEntries = conf.getOption("spark.executor.extraClassPath").toSeq.flatMap { cp => | ||
| cp.split(java.io.File.pathSeparator) | ||
| } | ||
| val libraryPathEntries = | ||
| conf.getOption("spark.executor.extraLibraryPath").toSeq.flatMap { cp => | ||
| cp.split(java.io.File.pathSeparator) | ||
| } | ||
|
|
||
| val command = Command( | ||
| "org.apache.spark.executor.MesosExecutorBackend", Nil, sc.executorEnvs, | ||
| classPathEntries, libraryPathEntries, javaOpts) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should set
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i am wondering it will be ok if set val environment = Environment.newBuilder()
sc.executorEnvs.foreach { case (key, value) =>
environment.addVariables(Environment.Variable.newBuilder()
.setName(key)
.setValue(value)
.build())
}
environment.addVariables(Environment.Variable.newBuilder()
.setName("PYTHONPATH")
.setValue(sys.env.getOrElse("PYTHONPATH", ""))
.build())in this way maybe we can not get the |
||
|
|
||
| val uri = conf.get("spark.executor.uri", null) | ||
| if ( uri == null ) { | ||
| mesosCommand.setValue(CommandUtils.buildCommandSeq(command, sc.executorMemory, | ||
| sparkHome).mkString("\"", "\" \"", "\"")) | ||
| } 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*; ./sbin/spark-executor".format(basename)) | ||
| command.addUris(CommandInfo.URI.newBuilder().setValue(uri)) | ||
| mesosCommand.setValue(CommandUtils.buildCommandSeq(command, sc.executorMemory, | ||
| basename).mkString("\"", "\" \"", "\"")) | ||
| mesosCommand.addUris(CommandInfo.URI.newBuilder().setValue(uri)) | ||
| } | ||
|
|
||
| val memory = Resource.newBuilder() | ||
| .setName("mem") | ||
| .setType(Value.Type.SCALAR) | ||
| .setScalar(Value.Scalar.newBuilder().setValue(sc.executorMemory).build()) | ||
| .build() | ||
| ExecutorInfo.newBuilder() | ||
| .setExecutorId(ExecutorID.newBuilder().setValue(execId).build()) | ||
| .setCommand(command) | ||
| .setCommand(mesosCommand) | ||
| .setData(ByteString.copyFrom(createExecArg())) | ||
| .addResources(memory) | ||
| .build() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only passing
sc.executorEnvshere to thecommandobject here is not enough. Because we only usecommandwithCommandUtils.buildCommandSeqbelow to generate the command line string, and in this case,command.environmentis only used to runbin/compute-classpath(see here), not propagated to the target executor process.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, here i should set env to CommandInfo to propagate to the target executor process.