Github user andrewor14 commented on a diff in the pull request:
https://github.com/apache/spark/pull/4168#discussion_r24366884
--- Diff:
core/src/main/scala/org/apache/spark/ExecutorAllocationManager.scala ---
@@ -224,54 +241,75 @@ private[spark] class ExecutorAllocationManager(
}
/**
+ * Check to see whether our existing allocation and the requests we've
made previously exceed our
+ * current needs. If so, let the cluster manager know so that it can
cancel pending requests that
+ * are unneeded.
+ *
+ * If not, and the add time has expired, see if we can request new
executors and refresh the add
+ * time.
+ *
+ * @return the delta in the target number of executors.
+ */
+ private def adjustRequestedExecutors(now: Long): Int = synchronized {
+ val currentTarget = targetNumExecutors
+ val maxNeeded = maxNumExecutorsNeeded
+
+ if (maxNeeded < currentTarget) {
+ // The target number exceeds the number we actually need, so stop
adding new
+ // executors and inform the cluster manager to cancel the extra
pending requests.
+ client.requestTotalExecutors(maxNeeded)
+ val delta = math.min(maxNeeded - currentTarget, 0)
+ numExecutorsPending += delta
+ numExecutorsToAdd = 1
+ delta
+ } else if (addTime != NOT_SET && now >= addTime) {
+ val delta = addExecutors(maxNeeded)
+ logDebug(s"Starting timer to add more executors (to " +
+ s"expire in $sustainedSchedulerBacklogTimeout seconds)")
+ addTime += sustainedSchedulerBacklogTimeout * 1000
+ delta
+ } else {
+ 0
+ }
+ }
--- End diff --
I see, otherwise it's hard to test it. Maybe we should just rename this
then to `maybeAddExecutors` or something. The current name sounds more like
it's updating a few local variables rather than actually sending the request.
Then in the javadoc we can explain why it's "maybe"
---
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]