Github user andrewor14 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/10924#discussion_r62104725
  
    --- Diff: 
core/src/main/scala/org/apache/spark/scheduler/cluster/mesos/CoarseMesosSchedulerBackend.scala
 ---
    @@ -279,18 +283,28 @@ private[spark] class CoarseMesosSchedulerBackend(
       }
     
       private def declineUnmatchedOffers(d: SchedulerDriver, offers: 
Buffer[Offer]): Unit = {
    -    for (offer <- offers) {
    -      val id = offer.getId.getValue
    -      val offerAttributes = toAttributeMap(offer.getAttributesList)
    -      val mem = getResource(offer.getResourcesList, "mem")
    -      val cpus = getResource(offer.getResourcesList, "cpus")
    -      val filters = Filters.newBuilder()
    -        .setRefuseSeconds(rejectOfferDurationForUnmetConstraints).build()
    +    offers.foreach { offer =>
    +      declineOffer(d, offer, Some("unmet constraints"),
    +        Some(rejectOfferDurationForUnmetConstraints))
    +    }
    +  }
    +
    +  private def declineOffer(d: SchedulerDriver, offer: Offer, reason: 
Option[String] = None,
    +      refuseSeconds: Option[Long] = None): Unit = {
     
    -      logDebug(s"Declining offer: $id with attributes: $offerAttributes 
mem: $mem cpu: $cpus"
    -        + s" for $rejectOfferDurationForUnmetConstraints seconds")
    +    val id = offer.getId.getValue
    +    val offerAttributes = toAttributeMap(offer.getAttributesList)
    +    val mem = getResource(offer.getResourcesList, "mem")
    +    val cpus = getResource(offer.getResourcesList, "cpus")
     
    -      d.declineOffer(offer.getId, filters)
    +    logDebug(s"Declining offer: $id with attributes: $offerAttributes mem: 
$mem"
    +      + s" cpu: $cpus for $refuseSeconds seconds" + reason.fold("")(r => 
s" (reason: $r)"))
    --- End diff --
    
    just use `map` `getOrElse` here. It's easier to understand than fold.


---
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]

Reply via email to