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

    https://github.com/apache/spark/pull/14926#discussion_r79036171
  
    --- Diff: 
core/src/main/scala/org/apache/spark/ExecutorAllocationManager.scala ---
    @@ -392,10 +397,70 @@ private[spark] class ExecutorAllocationManager(
       }
     
       /**
    +   * Request the cluster manager to remove the given executors.
    +   * Return whether the request is acknowledged. Ideally we should be 
returning the list of
    +   * executors which were removed as the requested executors and the one's 
actually removed can be
    +   * different (CoarseGrainedSchedulerBackend can filter some executors). 
To avoid breaking the API
    +   * we continue to return a Boolean.
    +   */
    +  private def removeExecutors(executors: Seq[String]): Boolean = 
synchronized {
    +
    +    val executorIdsToBeRemoved = new ArrayBuffer[String]
    +
    +    logInfo("Request to remove executorIds: " + executors.mkString(", "))
    +    val numExistingExecutors = executorIds.size - 
executorsPendingToRemove.size
    +    for(executorId <- executors) {
    +      // Do not kill the executor if we have already reached the lower 
bound
    +      val newExecutorTotal = numExistingExecutors - 
executorIdsToBeRemoved.size
    +      if (newExecutorTotal - 1 < minNumExecutors) {
    +        logDebug(s"Not removing idle executor $executorId because there 
are only " +
    +          s"$numExistingExecutors executor(s) left (limit 
$minNumExecutors)")
    +      } else if (canBeKilled(executorId)) {
    +        executorIdsToBeRemoved += executorId
    +      }
    +    }
    +
    +    if (executorIdsToBeRemoved.isEmpty) {
    +      return false
    +    }
    +
    +    // Send a request to the backend to kill this executor(s)
    +    val executorsRemoved = if (testing) {
    +      executorIdsToBeRemoved
    +    } else {
    +      client.killExecutors(executorIdsToBeRemoved)
    +    }
    +
    +    if (testing || executorsRemoved.nonEmpty) {
    +      val numExistingExecutors = allocationManager.executorIds.size - 
executorsPendingToRemove.size
    +      var index = 0
    +      for(index <- 0 until executorsRemoved.size) {
    +        val removedExecutorId = executorsRemoved(index)
    +        val newExecutorTotal = numExistingExecutors - (index + 1)
    +        logInfo(s"Removing executor $removedExecutorId because it has been 
idle for " +
    +          s"$executorIdleTimeoutS seconds (new desired total will be 
$newExecutorTotal)")
    +        executorsPendingToRemove.add(removedExecutorId)
    +      }
    +      true
    +    } else {
    +      logWarning(s"Unable to reach the cluster manager to kill executor/s 
" +
    +        executorIdsToBeRemoved.mkString(",") + "or no executor eligible to 
kill!")
    --- End diff --
    
    You can use interpolation here to; at the very least you need a space 
before "or", otherwise the message will read funny.


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