File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
core/src/main/scala/org/apache/spark/deploy/master Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -481,12 +481,16 @@ private[spark] class Master(
481481 if (state != RecoveryState .ALIVE ) { return }
482482
483483 // First schedule drivers, they take strict precedence over applications
484- val shuffledWorkers = Random .shuffle(workers) // Randomization helps balance drivers
485- for (worker <- shuffledWorkers if worker.state == WorkerState .ALIVE ) {
486- for (driver <- List (waitingDrivers : _* )) { // iterate over a copy of waitingDrivers
487- if (worker.memoryFree >= driver.desc.mem && worker.coresFree >= driver.desc.cores) {
484+ for (driver <- List (waitingDrivers : _* )) {
485+ val shuffledWorkers = Random .shuffle(workers) // Randomization helps balance drivers
486+ val shuffledWorkersIter = shuffledWorkers.iterator
487+ var launched = false
488+ while (shuffledWorkersIter.hasNext && ! launched) {
489+ val worker = shuffledWorkersIter.next()
490+ if (worker.state == WorkerState .ALIVE && worker.memoryFree >= driver.desc.mem && worker.coresFree >= driver.desc.cores) {
488491 launchDriver(worker, driver)
489492 waitingDrivers -= driver
493+ launched = true
490494 }
491495 }
492496 }
You can’t perform that action at this time.
0 commit comments