Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

use copy idiom to reconstruct the workerOffers

  • Loading branch information...
commit 19c2bb4143bd964b3cae810817b9feef6be7a441 1 parent 43c13e9
@CodingCat CodingCat authored
View
9 core/src/main/scala/org/apache/spark/scheduler/cluster/CoarseGrainedSchedulerBackend.scala
@@ -127,15 +127,16 @@ class CoarseGrainedSchedulerBackend(scheduler: TaskSchedulerImpl, actorSystem: A
// Make fake resource offers on all executors
def makeOffers() {
// reconstruct workerOffers
- workerOffers.foreach(o => workerOffers(o._1) =
- new WorkerOffer(o._1, o._2.host, freeCores(o._1)))
+ workerOffers.keys.foreach { executorId =>
+ workerOffers(executorId) = workerOffers(executorId).copy(cores = freeCores(executorId))
+ }
launchTasks(scheduler.resourceOffers(workerOffers.values.toSeq))
}
// Make fake resource offers on just one executor
def makeOffers(executorId: String) {
- val oldOffer = workerOffers(executorId)
- workerOffers(executorId) = new WorkerOffer(executorId, oldOffer.host, freeCores(executorId))
+ // update the workerOffer
+ workerOffers(executorId) = workerOffers(executorId).copy(cores = freeCores(executorId))
launchTasks(scheduler.resourceOffers(Seq(workerOffers(executorId))))
}
Please sign in to comment.
Something went wrong with that request. Please try again.