Github user dragos commented on a diff in the pull request:
https://github.com/apache/spark/pull/8872#discussion_r42725607
--- Diff:
core/src/main/scala/org/apache/spark/scheduler/cluster/mesos/MesosClusterScheduler.scala
---
@@ -457,34 +462,37 @@ private[spark] class MesosClusterScheduler(
private def scheduleTasks(
candidates: Seq[MesosDriverDescription],
afterLaunchCallback: (String) => Boolean,
- currentOffers: List[ResourceOffer],
- tasks: mutable.HashMap[OfferID, ArrayBuffer[TaskInfo]]): Unit = {
+ currentOffers: JList[ResourceOffer],
+ tasks: mutable.HashMap[OfferID, ArrayBuffer[TaskInfo]]):
JList[ResourceOffer] = {
for (submission <- candidates) {
val driverCpu = submission.cores
val driverMem = submission.mem
logTrace(s"Finding offer to launch driver with cpu: $driverCpu, mem:
$driverMem")
- val offerOption = currentOffers.find { o =>
- o.cpu >= driverCpu && o.mem >= driverMem
+ val offerOption = currentOffers.asScala.find { o =>
+ getResource(o.resources, "cpus") >= driverCpu &&
+ getResource(o.resources, "mem") >= driverMem
}
if (offerOption.isEmpty) {
logDebug(s"Unable to find offer to launch driver id:
${submission.submissionId}, " +
s"cpu: $driverCpu, mem: $driverMem")
} else {
val offer = offerOption.get
- offer.cpu -= driverCpu
- offer.mem -= driverMem
+ offer.used = true
--- End diff --
What if the offer was already `used` here? One more reason to get rid of
the `used` field altogether. Make this method assume `currentOffers` are all
for the taking (as it does now), and returns all the remaining offers.
---
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]