-
Notifications
You must be signed in to change notification settings - Fork 28.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SPARK-1171: when executor is removed, we should minus totalCores instead of just freeCores on that executor #63
Closed
CodingCat
wants to merge
5
commits into
apache:master
from
CodingCat:simplify_CoarseGrainedSchedulerBackend
Closed
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0c0e409
simplify the implementation of CoarseGrainedSchedulerBackend
CodingCat af470d3
style fix
CodingCat 43c13e9
keep WorkerOffer immutable
CodingCat 19c2bb4
use copy idiom to reconstruct the workerOffers
CodingCat f6bf93f
code clean
CodingCat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,9 +51,9 @@ class CoarseGrainedSchedulerBackend(scheduler: TaskSchedulerImpl, actorSystem: A | |
|
||
class DriverActor(sparkProperties: Seq[(String, String)]) extends Actor { | ||
private val executorActor = new HashMap[String, ActorRef] | ||
private val executorAddress = new HashMap[String, Address] | ||
private val executorHost = new HashMap[String, String] | ||
private val workerOffers = new HashMap[String, WorkerOffer] | ||
private val freeCores = new HashMap[String, Int] | ||
private val totalCores = new HashMap[String, Int] | ||
private val addressToExecutorId = new HashMap[Address, String] | ||
|
||
override def preStart() { | ||
|
@@ -75,9 +75,10 @@ class CoarseGrainedSchedulerBackend(scheduler: TaskSchedulerImpl, actorSystem: A | |
logInfo("Registered executor: " + sender + " with ID " + executorId) | ||
sender ! RegisteredExecutor(sparkProperties) | ||
executorActor(executorId) = sender | ||
executorHost(executorId) = Utils.parseHostPort(hostPort)._1 | ||
freeCores(executorId) = cores | ||
executorAddress(executorId) = sender.path.address | ||
workerOffers += (executorId -> | ||
new WorkerOffer(executorId, Utils.parseHostPort(hostPort)._1, cores)) | ||
totalCores += (executorId -> cores) | ||
freeCores += (executorId -> cores) | ||
addressToExecutorId(sender.path.address) = executorId | ||
totalCoreCount.addAndGet(cores) | ||
makeOffers() | ||
|
@@ -125,14 +126,17 @@ class CoarseGrainedSchedulerBackend(scheduler: TaskSchedulerImpl, actorSystem: A | |
|
||
// Make fake resource offers on all executors | ||
def makeOffers() { | ||
launchTasks(scheduler.resourceOffers( | ||
executorHost.toArray.map {case (id, host) => new WorkerOffer(id, host, freeCores(id))})) | ||
// reconstruct workerOffers | ||
workerOffers.foreach(o => workerOffers(o._1) = | ||
new WorkerOffer(o._1, o._2.host, freeCores(o._1))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that WorkerOffer is a case class, you can do this and the one in makeOffers with the copy idiom: 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) { | ||
launchTasks(scheduler.resourceOffers( | ||
Seq(new WorkerOffer(executorId, executorHost(executorId), freeCores(executorId))))) | ||
val oldOffer = workerOffers(executorId) | ||
workerOffers(executorId) = new WorkerOffer(executorId, oldOffer.host, freeCores(executorId)) | ||
launchTasks(scheduler.resourceOffers(Seq(workerOffers(executorId)))) | ||
} | ||
|
||
// Launch tasks returned by a set of resource offers | ||
|
@@ -147,10 +151,10 @@ class CoarseGrainedSchedulerBackend(scheduler: TaskSchedulerImpl, actorSystem: A | |
def removeExecutor(executorId: String, reason: String) { | ||
if (executorActor.contains(executorId)) { | ||
logInfo("Executor " + executorId + " disconnected, so removing it") | ||
val numCores = freeCores(executorId) | ||
addressToExecutorId -= executorAddress(executorId) | ||
val numCores = totalCores(executorId) | ||
executorActor -= executorId | ||
executorHost -= executorId | ||
workerOffers -= executorId | ||
totalCores -= executorId | ||
freeCores -= executorId | ||
totalCoreCount.addAndGet(-numCores) | ||
scheduler.executorLost(executorId, SlaveLost(reason)) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
superfluous ';'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, sorry, fixed