@@ -513,7 +513,7 @@ class CoarseGrainedSchedulerBackend(scheduler: TaskSchedulerImpl, val rpcEnv: Rp
513513 * @return the ids of the executors acknowledged by the cluster manager to be removed.
514514 */
515515 override def decommissionExecutors (
516- executorsAndDecomInfo : Seq [(String , ExecutorDecommissionInfo )],
516+ executorsAndDecomInfo : Array [(String , ExecutorDecommissionInfo )],
517517 adjustTargetNumExecutors : Boolean ): Seq [String ] = {
518518
519519 val executorsToDecommission = executorsAndDecomInfo.filter { case (executorId, _) =>
@@ -530,21 +530,7 @@ class CoarseGrainedSchedulerBackend(scheduler: TaskSchedulerImpl, val rpcEnv: Rp
530530
531531 // If we don't want to replace the executors we are decommissioning
532532 if (adjustTargetNumExecutors) {
533- executorsToDecommission.foreach { case (exec, _) =>
534- val rpId = withLock {
535- executorDataMap(exec).resourceProfileId
536- }
537- val rp = scheduler.sc.resourceProfileManager.resourceProfileFromId(rpId)
538- if (requestedTotalExecutorsPerResourceProfile.isEmpty) {
539- // Assume that we are killing an executor that was started by default and
540- // not through the request api
541- requestedTotalExecutorsPerResourceProfile(rp) = 0
542- } else {
543- val requestedTotalForRp = requestedTotalExecutorsPerResourceProfile(rp)
544- requestedTotalExecutorsPerResourceProfile(rp) = math.max(requestedTotalForRp - 1 , 0 )
545- }
546- }
547- doRequestTotalExecutors(requestedTotalExecutorsPerResourceProfile.toMap)
533+ adjustExecutors(executorsToDecommission.map(_._1))
548534 }
549535
550536 val decommissioned = executorsToDecommission.filter { case (executorId, decomInfo) =>
@@ -846,6 +832,27 @@ class CoarseGrainedSchedulerBackend(scheduler: TaskSchedulerImpl, val rpcEnv: Rp
846832 resourceProfileToTotalExecs : Map [ResourceProfile , Int ]): Future [Boolean ] =
847833 Future .successful(false )
848834
835+ /**
836+ * Adjust the number of executors being requested to no longer include the provided executors.
837+ */
838+ private def adjustExecutors (executorIds : Seq [String ]) = {
839+ executorIds.foreach { exec =>
840+ withLock {
841+ val rpId = executorDataMap(exec).resourceProfileId
842+ val rp = scheduler.sc.resourceProfileManager.resourceProfileFromId(rpId)
843+ if (requestedTotalExecutorsPerResourceProfile.isEmpty) {
844+ // Assume that we are killing an executor that was started by default and
845+ // not through the request api
846+ requestedTotalExecutorsPerResourceProfile(rp) = 0
847+ } else {
848+ val requestedTotalForRp = requestedTotalExecutorsPerResourceProfile(rp)
849+ requestedTotalExecutorsPerResourceProfile(rp) = math.max(requestedTotalForRp - 1 , 0 )
850+ }
851+ }
852+ }
853+ doRequestTotalExecutors(requestedTotalExecutorsPerResourceProfile.toMap)
854+ }
855+
849856 /**
850857 * Request that the cluster manager kill the specified executors.
851858 *
@@ -884,19 +891,7 @@ class CoarseGrainedSchedulerBackend(scheduler: TaskSchedulerImpl, val rpcEnv: Rp
884891 // take into account executors that are pending to be added or removed.
885892 val adjustTotalExecutors =
886893 if (adjustTargetNumExecutors) {
887- executorsToKill.foreach { exec =>
888- val rpId = executorDataMap(exec).resourceProfileId
889- val rp = scheduler.sc.resourceProfileManager.resourceProfileFromId(rpId)
890- if (requestedTotalExecutorsPerResourceProfile.isEmpty) {
891- // Assume that we are killing an executor that was started by default and
892- // not through the request api
893- requestedTotalExecutorsPerResourceProfile(rp) = 0
894- } else {
895- val requestedTotalForRp = requestedTotalExecutorsPerResourceProfile(rp)
896- requestedTotalExecutorsPerResourceProfile(rp) = math.max(requestedTotalForRp - 1 , 0 )
897- }
898- }
899- doRequestTotalExecutors(requestedTotalExecutorsPerResourceProfile.toMap)
894+ adjustExecutors(executorsToKill)
900895 } else {
901896 Future .successful(true )
902897 }
0 commit comments