Skip to content

Commit 158b6b9

Browse files
author
Paul Mackles
committed
[SPARK-19606] Support constraints in spark-dispatcher; applied recommended changes from PR
1 parent 8e7eed8 commit 158b6b9

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

docs/running-on-mesos.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,9 @@ See the [configuration page](configuration.html) for information on Spark config
450450
<td><code>spark.mesos.constraints</code></td>
451451
<td>(none)</td>
452452
<td>
453-
Attribute based constraints on mesos resource offers. By default, all resource offers will be accepted. Refer to <a href="http://mesos.apache.org/documentation/attributes-resources/">Mesos Attributes & Resources</a> for more information on attributes.
453+
Attribute based constraints on mesos resource offers. By default, all resource offers will be accepted. This setting
454+
applies only to executors. Refer to <a href="http://mesos.apache.org/documentation/attributes-resources/">Mesos
455+
Attributes & Resources</a> for more information on attributes.
454456
<ul>
455457
<li>Scalar constraints are matched with "less than equal" semantics i.e. value in the constraint must be less than or equal to the value in the resource offer.</li>
456458
<li>Range constraints are matched with "contains" semantics i.e. value in the constraint must be within the resource offer's value.</li>
@@ -465,7 +467,7 @@ See the [configuration page](configuration.html) for information on Spark config
465467
<td>(none)</td>
466468
<td>
467469
Same as <code>spark.mesos.constraints</code> except applied to drivers when launched through the dispatcher. By default,
468-
all resource offers will be accepted.
470+
all offers with sufficient resources will be accepted.
469471
</td>
470472
</tr>
471473
<tr>

resource-managers/mesos/src/main/scala/org/apache/spark/deploy/mesos/config.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,11 @@ package object config {
122122
"Example: key1:val1,key2:val2")
123123
.stringConf
124124
.createOptional
125+
126+
private[spark] val DRIVER_CONSTRAINTS =
127+
ConfigBuilder("spark.mesos.driver.constraints")
128+
.doc("Attribute based constraints on mesos resource offers. Applied by the dispatcher " +
129+
"when launching drivers. Default is to accept all offers with sufficient resources.")
130+
.stringConf
131+
.createWithDefault("")
125132
}

resource-managers/mesos/src/main/scala/org/apache/spark/scheduler/cluster/mesos/MesosClusterScheduler.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ private[spark] class MesosClusterScheduler(
559559
var remainingResources: JList[Resource],
560560
var attributes: JList[Attribute]) {
561561
override def toString(): String = {
562-
s"Offer id: ${offer.getId}, resources: ${remainingResources}"
562+
s"Offer id: ${offer.getId}, resources: ${remainingResources}, attributes: ${attributes}"
563563
}
564564
}
565565

@@ -603,7 +603,7 @@ private[spark] class MesosClusterScheduler(
603603
val driverCpu = submission.cores
604604
val driverMem = submission.mem
605605
val driverConstraints =
606-
parseConstraintString(submission.conf.get("spark.mesos.driver.constraints", ""))
606+
parseConstraintString(submission.conf.get(config.DRIVER_CONSTRAINTS))
607607
logTrace(s"Finding offer to launch driver with cpu: $driverCpu, mem: $driverMem, " +
608608
s"driverConstraints: $driverConstraints")
609609
val offerOption = currentOffers.find { offer =>

resource-managers/mesos/src/test/scala/org/apache/spark/scheduler/cluster/mesos/MesosClusterSchedulerSuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ class MesosClusterSchedulerSuite extends SparkFunSuite with LocalSparkContext wi
274274
command,
275275
Map("spark.mesos.executor.home" -> "test",
276276
"spark.app.name" -> "test",
277-
"spark.mesos.driver.constraints" -> driverConstraints),
277+
config.DRIVER_CONSTRAINTS.key -> driverConstraints),
278278
"s1",
279279
new Date()))
280280
assert(response.success)

0 commit comments

Comments
 (0)