Skip to content

Commit 89f9bc0

Browse files
committed
address matei's comments
1 parent 18cae02 commit 89f9bc0

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

core/src/main/scala/org/apache/spark/scheduler/TaskSchedulerImpl.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,14 +251,14 @@ private[spark] class TaskSchedulerImpl(
251251
// of locality levels so that it gets a chance to launch local tasks on all of them.
252252
// NOTE: the preferredLocality order: PROCESS_LOCAL, NODE_LOCAL, NO_PREF, RACK_LOCAL, ANY
253253
var launchedTask = false
254-
for (taskSet <- sortedTaskSets; preferredLocality <- taskSet.myLocalityLevels) {
254+
for (taskSet <- sortedTaskSets; maxLocality <- taskSet.myLocalityLevels) {
255255
do {
256256
launchedTask = false
257257
for (i <- 0 until shuffledOffers.size) {
258258
val execId = shuffledOffers(i).executorId
259259
val host = shuffledOffers(i).host
260260
if (availableCpus(i) >= CPUS_PER_TASK) {
261-
for (task <- taskSet.resourceOffer(execId, host, preferredLocality)) {
261+
for (task <- taskSet.resourceOffer(execId, host, maxLocality)) {
262262
tasks(i) += task
263263
val tid = task.taskId
264264
taskIdToTaskSetId(tid) = taskSet.taskSet.id

core/src/main/scala/org/apache/spark/scheduler/TaskSetManager.scala

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -180,20 +180,13 @@ private[spark] class TaskSetManager(
180180
}
181181
}
182182

183-
var hadAliveLocations = false
184183
for (loc <- tasks(index).preferredLocations) {
185184
for (execId <- loc.executorId) {
186185
addTo(pendingTasksForExecutor.getOrElseUpdate(execId, new ArrayBuffer))
187186
}
188-
if (sched.hasExecutorsAliveOnHost(loc.host)) {
189-
hadAliveLocations = true
190-
}
191187
addTo(pendingTasksForHost.getOrElseUpdate(loc.host, new ArrayBuffer))
192188
for (rack <- sched.getRackForHost(loc.host)) {
193189
addTo(pendingTasksForRack.getOrElseUpdate(rack, new ArrayBuffer))
194-
if(sched.hasHostAliveOnRack(rack)){
195-
hadAliveLocations = true
196-
}
197190
}
198191
}
199192

@@ -286,7 +279,7 @@ private[spark] class TaskSetManager(
286279
!hasAttemptOnHost(index, host) && !executorIsBlacklisted(execId, index)
287280

288281
if (!speculatableTasks.isEmpty) {
289-
// Check for process-local or preference-less tasks; note that tasks can be process-local
282+
// Check for process-local tasks; note that tasks can be process-local
290283
// on multiple nodes when we replicate cached blocks, as in Spark Streaming
291284
for (index <- speculatableTasks if canRunOnHost(index)) {
292285
val prefs = tasks(index).preferredLocations
@@ -308,6 +301,7 @@ private[spark] class TaskSetManager(
308301
}
309302
}
310303

304+
// Check for no-preference tasks
311305
if (TaskLocality.isAllowed(locality, TaskLocality.NO_PREF)) {
312306
for (index <- speculatableTasks if canRunOnHost(index)) {
313307
val locations = tasks(index).preferredLocations
@@ -350,7 +344,7 @@ private[spark] class TaskSetManager(
350344
* @return An option containing (task index within the task set, locality, is speculative?)
351345
*/
352346
private def findTask(execId: String, host: String, maxLocality: TaskLocality.Value)
353-
: Option[(Int, TaskLocality.Value, Boolean)] =
347+
: Option[(Int, TaskLocality.Value, Boolean)] =
354348
{
355349
for (index <- findTaskFromList(execId, getPendingTasksForExecutor(execId))) {
356350
return Some((index, TaskLocality.PROCESS_LOCAL, false))
@@ -392,7 +386,7 @@ private[spark] class TaskSetManager(
392386
/**
393387
* Respond to an offer of a single executor from the scheduler by finding a task
394388
*
395-
* NOTE: this function is either called with a real preferredLocality level which
389+
* NOTE: this function is either called with a maxLocality which
396390
* would be adjusted by delay scheduling algorithm or it will be with a special
397391
* NO_PREF locality which will be not modified
398392
*

core/src/test/scala/org/apache/spark/scheduler/TaskSchedulerImplSuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class FakeTaskSetManager(
8080
override def resourceOffer(
8181
execId: String,
8282
host: String,
83-
preferredLocality: TaskLocality.TaskLocality)
83+
maxLocality: TaskLocality.TaskLocality)
8484
: Option[TaskDescription] =
8585
{
8686
if (tasksSuccessful + numRunningTasks < numTasks) {

0 commit comments

Comments
 (0)