Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ private[spark] class MesosClusterScheduler(
private val queuedDriversState = engineFactory.createEngine("driverQueue")
private val launchedDriversState = engineFactory.createEngine("launchedDrivers")
private val pendingRetryDriversState = engineFactory.createEngine("retryList")
// dispactcher constraints

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a typo there. I think the comment isn't necessary though, the name of the variable is clear enough.

val driverOfferConstraints = parseConstraintString(conf.get("spark.mesos.constraints", ""))
// Flag to mark if the scheduler is ready to be called, which is until the scheduler
// is registered with Mesos master.
@volatile protected var ready = false
Expand Down Expand Up @@ -518,6 +520,20 @@ private[spark] class MesosClusterScheduler(
val tasks = new mutable.HashMap[OfferID, ArrayBuffer[TaskInfo]]()
val currentTime = new Date()

stateLock.synchronized {
var it = offers.iterator()
while (it.hasNext) {
val offer = it.next()
val offerAttributes = toAttributeMap(offer.getAttributesList)
val meetsConstraints = matchesAttributeRequirements(driverOfferConstraints, offerAttributes)

if (!meetsConstraints) {
driver.declineOffer(offer.getId)
it.remove()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather not mutate the underlying collection. Anyhow, this has no effect because the code below is using currentOffers, which is a copy of the original resources made earlier. I suggest you insert this filter at the earlier point a few lines above, where currentOffers is created.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, it's true. I modify code base in 1.5.2 previously, and test ok in practice. in 1.6.0 version the code is change. I will revise it soon.thanks for your review.

}
}
}

stateLock.synchronized {
// We first schedule all the supervised drivers that are ready to retry.
// This list will be empty if none of the drivers are marked as supervise.
Expand Down