You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by andrewor14 <gi...@git.apache.org> on 2015/02/06 00:28:40 UTC

[GitHub] spark pull request: SPARK-4337. [YARN] Add ability to cancel pendi...

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

    https://github.com/apache/spark/pull/4141#discussion_r24210327
  
    --- Diff: yarn/src/main/scala/org/apache/spark/deploy/yarn/YarnAllocator.scala ---
    @@ -192,15 +186,32 @@ private[yarn] class YarnAllocator(
       }
     
       /**
    -   * Request numExecutors additional containers from YARN. Visible for testing.
    +   * Update the set of container requests that we will sync with the RM based on the number of
    +   * executors we have currently running and our target number of executors.
    +   *
    +   * Visible for testing.
        */
    -  def addResourceRequests(numExecutors: Int): Unit = {
    -    for (i <- 0 until numExecutors) {
    -      val request = new ContainerRequest(resource, null, null, RM_REQUEST_PRIORITY)
    -      amClient.addContainerRequest(request)
    -      val nodes = request.getNodes
    -      val hostStr = if (nodes == null || nodes.isEmpty) "Any" else nodes.last
    -      logInfo("Container request (host: %s, capability: %s".format(hostStr, resource))
    +  def updateResourceRequests(): Unit = {
    +    val numPendingAllocate = getNumPendingAllocate
    +    val missing = targetNumExecutors - numPendingAllocate - numExecutorsRunning
    +
    +    if (missing > 0) {
    +      logInfo(s"Will request $missing executor containers, each with ${resource.getVirtualCores} " +
    +        s"cores and ${resource.getMemory} MB memory including $memoryOverhead MB overhead")
    +
    +      for (i <- 0 until missing) {
    +        val request = new ContainerRequest(resource, null, null, RM_REQUEST_PRIORITY)
    +        amClient.addContainerRequest(request)
    +        val nodes = request.getNodes
    +        val hostStr = if (nodes == null || nodes.isEmpty) "Any" else nodes.last
    +        logInfo("Container request (host: %s, capability: %s)".format(hostStr, resource))
    +      }
    +    } else if (missing < 0) {
    +      val numToCancel = math.min(numPendingAllocate, -missing)
    +      logInfo(s"Canceling requests for ${numToCancel} executor containers")
    --- End diff --
    
    you can just make this `$numToCancel`


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