You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by vanzin <gi...@git.apache.org> on 2015/11/01 02:14:10 UTC

[GitHub] spark pull request: [SPARK-9817][YARN] Improve the locality calcul...

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

    https://github.com/apache/spark/pull/8100#discussion_r43577930
  
    --- Diff: yarn/src/main/scala/org/apache/spark/deploy/yarn/YarnAllocator.scala ---
    @@ -534,6 +549,40 @@ private[yarn] class YarnAllocator(
     
       private[yarn] def getNumUnexpectedContainerRelease = numUnexpectedContainerRelease
     
    +  /**
    +   * Split the pending container requests into 3 groups based on current localities of pending
    +   * tasks.
    +   * @param hostToLocalTaskCount a map of preferred hostname to possible task counts to be used as
    +   *                             container placement hint.
    +   * @param pendingAllocations A sequence of pending allocation container request.
    +   * @return A tuple of 3 sequences, first is a sequence of locality matched container
    +   *         requests, second is a sequence of locality unmatched container requests, and third is a
    +   *         sequence of locality free container requests.
    +   */
    +  private def splitPendingAllocationsByLocality(
    +      hostToLocalTaskCount: Map[String, Int],
    +      pendingAllocations: Seq[ContainerRequest]
    +    ): (Seq[ContainerRequest], Seq[ContainerRequest], Seq[ContainerRequest]) = {
    +    val localityMatched = ArrayBuffer[ContainerRequest]()
    +    val localityUnMatched = ArrayBuffer[ContainerRequest]()
    +    val localityFree = ArrayBuffer[ContainerRequest]()
    +
    +    val preferredHosts = hostToLocalTaskCount.keySet
    +    pendingAllocations.foreach { cr =>
    +      val nodes = cr.getNodes
    +      if (nodes == null) {
    +        localityFree += cr
    +      } else {
    --- End diff --
    
    minor: cleaner if you use `} else if (...) {`


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org