@@ -150,8 +150,7 @@ private[spark] class TaskSetManager(
150
150
// of task index so that tasks with low indices get launched first.
151
151
val delaySchedule = conf.getBoolean(" spark.schedule.delaySchedule" , true )
152
152
for (i <- (0 until numTasks).reverse) {
153
- // if delay schedule is set, we shouldn't enforce check since executors may haven't registered yet
154
- addPendingTask(i, enforceCheck = ! delaySchedule)
153
+ addPendingTask(i)
155
154
}
156
155
157
156
// Figure out which locality levels we have in our TaskSet, so we can do delay scheduling
@@ -171,10 +170,8 @@ private[spark] class TaskSetManager(
171
170
/**
172
171
* Add a task to all the pending-task lists that it should be on. If readding is set, we are
173
172
* re-adding the task so only include it in each list if it's not already there.
174
- * If enforceCheck is set, we'll check the availability of executors/hosts before adding a task
175
- * to the pending list, otherwise, we simply add the task according to its preference.
176
173
*/
177
- private def addPendingTask (index : Int , readding : Boolean = false , enforceCheck : Boolean = true ) {
174
+ private def addPendingTask (index : Int , readding : Boolean = false ) {
178
175
// Utility method that adds `index` to a list only if readding=false or it's not already there
179
176
def addTo (list : ArrayBuffer [Int ]) {
180
177
if (! readding || ! list.contains(index)) {
@@ -185,12 +182,12 @@ private[spark] class TaskSetManager(
185
182
var hadAliveLocations = false
186
183
for (loc <- tasks(index).preferredLocations) {
187
184
for (execId <- loc.executorId) {
188
- if (! enforceCheck || sched.isExecutorAlive(execId)) {
185
+ if (sched.isExecutorAlive(execId)) {
189
186
addTo(pendingTasksForExecutor.getOrElseUpdate(execId, new ArrayBuffer ))
190
187
hadAliveLocations = true
191
188
}
192
189
}
193
- if (! enforceCheck || sched.hasExecutorsAliveOnHost(loc.host)) {
190
+ if (sched.hasExecutorsAliveOnHost(loc.host)) {
194
191
addTo(pendingTasksForHost.getOrElseUpdate(loc.host, new ArrayBuffer ))
195
192
for (rack <- sched.getRackForHost(loc.host)) {
196
193
addTo(pendingTasksForRack.getOrElseUpdate(rack, new ArrayBuffer ))
@@ -199,7 +196,8 @@ private[spark] class TaskSetManager(
199
196
}
200
197
}
201
198
202
- if (! hadAliveLocations) {
199
+ if (tasks(index).preferredLocations.isEmpty ||
200
+ (! delaySchedule && ! hadAliveLocations)) {
203
201
// Even though the task might've had preferred locations, all of those hosts or executors
204
202
// are dead; put it in the no-prefs list so we can schedule it elsewhere right away.
205
203
addTo(pendingTasksWithNoPrefs)
@@ -742,4 +740,12 @@ private[spark] class TaskSetManager(
742
740
logDebug(" Valid locality levels for " + taskSet + " : " + levels.mkString(" , " ))
743
741
levels.toArray
744
742
}
743
+
744
+ // Re-compute the pending lists. This should be called when new executor is added
745
+ def reAddPendingTasks () {
746
+ logInfo(" Re-computing pending task lists." )
747
+ for (i <- (0 until numTasks).reverse.filter(index => copiesRunning(index) == 0 && ! successful(index))) {
748
+ addPendingTask(i, readding = true )
749
+ }
750
+ }
745
751
}
0 commit comments