@@ -93,19 +93,16 @@ class TaskSetManagerSuite extends FunSuite with LocalSparkContext with Logging {
93
93
val taskSet = FakeTask .createTaskSet(1 )
94
94
val manager = new TaskSetManager (sched, taskSet, MAX_TASK_FAILURES )
95
95
96
- // Offer a host with no CPUs
97
- assert(manager.resourceOffer(" exec1" , " host1" , 0 , ANY ) === None )
98
-
99
96
// Offer a host with process-local as the constraint; this should work because the TaskSet
100
97
// above won't have any locality preferences
101
- val taskOption = manager.resourceOffer(" exec1" , " host1" , 2 , TaskLocality .PROCESS_LOCAL )
98
+ val taskOption = manager.resourceOffer(" exec1" , " host1" , TaskLocality .PROCESS_LOCAL )
102
99
assert(taskOption.isDefined)
103
100
val task = taskOption.get
104
101
assert(task.executorId === " exec1" )
105
102
assert(sched.startedTasks.contains(0 ))
106
103
107
104
// Re-offer the host -- now we should get no more tasks
108
- assert(manager.resourceOffer(" exec1" , " host1" , 2 , PROCESS_LOCAL ) === None )
105
+ assert(manager.resourceOffer(" exec1" , " host1" , PROCESS_LOCAL ) === None )
109
106
110
107
// Tell it the task has finished
111
108
manager.handleSuccessfulTask(0 , createTaskResult(0 ))
@@ -121,15 +118,15 @@ class TaskSetManagerSuite extends FunSuite with LocalSparkContext with Logging {
121
118
122
119
// First three offers should all find tasks
123
120
for (i <- 0 until 3 ) {
124
- val taskOption = manager.resourceOffer(" exec1" , " host1" , 1 , PROCESS_LOCAL )
121
+ val taskOption = manager.resourceOffer(" exec1" , " host1" , PROCESS_LOCAL )
125
122
assert(taskOption.isDefined)
126
123
val task = taskOption.get
127
124
assert(task.executorId === " exec1" )
128
125
}
129
126
assert(sched.startedTasks.toSet === Set (0 , 1 , 2 ))
130
127
131
128
// Re-offer the host -- now we should get no more tasks
132
- assert(manager.resourceOffer(" exec1" , " host1" , 1 , PROCESS_LOCAL ) === None )
129
+ assert(manager.resourceOffer(" exec1" , " host1" , PROCESS_LOCAL ) === None )
133
130
134
131
// Finish the first two tasks
135
132
manager.handleSuccessfulTask(0 , createTaskResult(0 ))
@@ -157,35 +154,35 @@ class TaskSetManagerSuite extends FunSuite with LocalSparkContext with Logging {
157
154
val manager = new TaskSetManager (sched, taskSet, MAX_TASK_FAILURES , clock)
158
155
159
156
// First offer host1, exec1: first task should be chosen
160
- assert(manager.resourceOffer(" exec1" , " host1" , 1 , ANY ).get.index === 0 )
157
+ assert(manager.resourceOffer(" exec1" , " host1" , ANY ).get.index === 0 )
161
158
162
159
// Offer host1, exec1 again: the last task, which has no prefs, should be chosen
163
- assert(manager.resourceOffer(" exec1" , " host1" , 1 , ANY ).get.index === 3 )
160
+ assert(manager.resourceOffer(" exec1" , " host1" , ANY ).get.index === 3 )
164
161
165
162
// Offer host1, exec1 again, at PROCESS_LOCAL level: nothing should get chosen
166
- assert(manager.resourceOffer(" exec1" , " host1" , 1 , PROCESS_LOCAL ) === None )
163
+ assert(manager.resourceOffer(" exec1" , " host1" , PROCESS_LOCAL ) === None )
167
164
168
165
clock.advance(LOCALITY_WAIT )
169
166
170
167
// Offer host1, exec1 again, at PROCESS_LOCAL level: nothing should get chosen
171
- assert(manager.resourceOffer(" exec1" , " host1" , 1 , PROCESS_LOCAL ) === None )
168
+ assert(manager.resourceOffer(" exec1" , " host1" , PROCESS_LOCAL ) === None )
172
169
173
170
// Offer host1, exec1 again, at NODE_LOCAL level: we should choose task 2
174
- assert(manager.resourceOffer(" exec1" , " host1" , 1 , NODE_LOCAL ).get.index == 2 )
171
+ assert(manager.resourceOffer(" exec1" , " host1" , NODE_LOCAL ).get.index == 2 )
175
172
176
173
// Offer host1, exec1 again, at NODE_LOCAL level: nothing should get chosen
177
- assert(manager.resourceOffer(" exec1" , " host1" , 1 , NODE_LOCAL ) === None )
174
+ assert(manager.resourceOffer(" exec1" , " host1" , NODE_LOCAL ) === None )
178
175
179
176
// Offer host1, exec1 again, at ANY level: nothing should get chosen
180
- assert(manager.resourceOffer(" exec1" , " host1" , 1 , ANY ) === None )
177
+ assert(manager.resourceOffer(" exec1" , " host1" , ANY ) === None )
181
178
182
179
clock.advance(LOCALITY_WAIT )
183
180
184
181
// Offer host1, exec1 again, at ANY level: task 1 should get chosen
185
- assert(manager.resourceOffer(" exec1" , " host1" , 1 , ANY ).get.index === 1 )
182
+ assert(manager.resourceOffer(" exec1" , " host1" , ANY ).get.index === 1 )
186
183
187
184
// Offer host1, exec1 again, at ANY level: nothing should be chosen as we've launched all tasks
188
- assert(manager.resourceOffer(" exec1" , " host1" , 1 , ANY ) === None )
185
+ assert(manager.resourceOffer(" exec1" , " host1" , ANY ) === None )
189
186
}
190
187
191
188
test(" delay scheduling with fallback" ) {
@@ -203,29 +200,29 @@ class TaskSetManagerSuite extends FunSuite with LocalSparkContext with Logging {
203
200
val manager = new TaskSetManager (sched, taskSet, MAX_TASK_FAILURES , clock)
204
201
205
202
// First offer host1: first task should be chosen
206
- assert(manager.resourceOffer(" exec1" , " host1" , 1 , ANY ).get.index === 0 )
203
+ assert(manager.resourceOffer(" exec1" , " host1" , ANY ).get.index === 0 )
207
204
208
205
// Offer host1 again: nothing should get chosen
209
- assert(manager.resourceOffer(" exec1" , " host1" , 1 , ANY ) === None )
206
+ assert(manager.resourceOffer(" exec1" , " host1" , ANY ) === None )
210
207
211
208
clock.advance(LOCALITY_WAIT )
212
209
213
210
// Offer host1 again: second task (on host2) should get chosen
214
- assert(manager.resourceOffer(" exec1" , " host1" , 1 , ANY ).get.index === 1 )
211
+ assert(manager.resourceOffer(" exec1" , " host1" , ANY ).get.index === 1 )
215
212
216
213
// Offer host1 again: third task (on host2) should get chosen
217
- assert(manager.resourceOffer(" exec1" , " host1" , 1 , ANY ).get.index === 2 )
214
+ assert(manager.resourceOffer(" exec1" , " host1" , ANY ).get.index === 2 )
218
215
219
216
// Offer host2: fifth task (also on host2) should get chosen
220
- assert(manager.resourceOffer(" exec2" , " host2" , 1 , ANY ).get.index === 4 )
217
+ assert(manager.resourceOffer(" exec2" , " host2" , ANY ).get.index === 4 )
221
218
222
219
// Now that we've launched a local task, we should no longer launch the task for host3
223
- assert(manager.resourceOffer(" exec2" , " host2" , 1 , ANY ) === None )
220
+ assert(manager.resourceOffer(" exec2" , " host2" , ANY ) === None )
224
221
225
222
clock.advance(LOCALITY_WAIT )
226
223
227
224
// After another delay, we can go ahead and launch that task non-locally
228
- assert(manager.resourceOffer(" exec2" , " host2" , 1 , ANY ).get.index === 3 )
225
+ assert(manager.resourceOffer(" exec2" , " host2" , ANY ).get.index === 3 )
229
226
}
230
227
231
228
test(" delay scheduling with failed hosts" ) {
@@ -240,24 +237,24 @@ class TaskSetManagerSuite extends FunSuite with LocalSparkContext with Logging {
240
237
val manager = new TaskSetManager (sched, taskSet, MAX_TASK_FAILURES , clock)
241
238
242
239
// First offer host1: first task should be chosen
243
- assert(manager.resourceOffer(" exec1" , " host1" , 1 , ANY ).get.index === 0 )
240
+ assert(manager.resourceOffer(" exec1" , " host1" , ANY ).get.index === 0 )
244
241
245
242
// Offer host1 again: third task should be chosen immediately because host3 is not up
246
- assert(manager.resourceOffer(" exec1" , " host1" , 1 , ANY ).get.index === 2 )
243
+ assert(manager.resourceOffer(" exec1" , " host1" , ANY ).get.index === 2 )
247
244
248
245
// After this, nothing should get chosen
249
- assert(manager.resourceOffer(" exec1" , " host1" , 1 , ANY ) === None )
246
+ assert(manager.resourceOffer(" exec1" , " host1" , ANY ) === None )
250
247
251
248
// Now mark host2 as dead
252
249
sched.removeExecutor(" exec2" )
253
250
manager.executorLost(" exec2" , " host2" )
254
251
255
252
// Task 1 should immediately be launched on host1 because its original host is gone
256
- assert(manager.resourceOffer(" exec1" , " host1" , 1 , ANY ).get.index === 1 )
253
+ assert(manager.resourceOffer(" exec1" , " host1" , ANY ).get.index === 1 )
257
254
258
255
// Now that all tasks have launched, nothing new should be launched anywhere else
259
- assert(manager.resourceOffer(" exec1" , " host1" , 1 , ANY ) === None )
260
- assert(manager.resourceOffer(" exec2" , " host2" , 1 , ANY ) === None )
256
+ assert(manager.resourceOffer(" exec1" , " host1" , ANY ) === None )
257
+ assert(manager.resourceOffer(" exec2" , " host2" , ANY ) === None )
261
258
}
262
259
263
260
test(" task result lost" ) {
@@ -267,14 +264,14 @@ class TaskSetManagerSuite extends FunSuite with LocalSparkContext with Logging {
267
264
val clock = new FakeClock
268
265
val manager = new TaskSetManager (sched, taskSet, MAX_TASK_FAILURES , clock)
269
266
270
- assert(manager.resourceOffer(" exec1" , " host1" , 1 , ANY ).get.index === 0 )
267
+ assert(manager.resourceOffer(" exec1" , " host1" , ANY ).get.index === 0 )
271
268
272
269
// Tell it the task has finished but the result was lost.
273
270
manager.handleFailedTask(0 , TaskState .FINISHED , TaskResultLost )
274
271
assert(sched.endedTasks(0 ) === TaskResultLost )
275
272
276
273
// Re-offer the host -- now we should get task 0 again.
277
- assert(manager.resourceOffer(" exec1" , " host1" , 1 , ANY ).get.index === 0 )
274
+ assert(manager.resourceOffer(" exec1" , " host1" , ANY ).get.index === 0 )
278
275
}
279
276
280
277
test(" repeated failures lead to task set abortion" ) {
@@ -287,7 +284,7 @@ class TaskSetManagerSuite extends FunSuite with LocalSparkContext with Logging {
287
284
// Fail the task MAX_TASK_FAILURES times, and check that the task set is aborted
288
285
// after the last failure.
289
286
(1 to manager.maxTaskFailures).foreach { index =>
290
- val offerResult = manager.resourceOffer(" exec1" , " host1" , 1 , ANY )
287
+ val offerResult = manager.resourceOffer(" exec1" , " host1" , ANY )
291
288
assert(offerResult.isDefined,
292
289
" Expect resource offer on iteration %s to return a task" .format(index))
293
290
assert(offerResult.get.index === 0 )
@@ -317,7 +314,7 @@ class TaskSetManagerSuite extends FunSuite with LocalSparkContext with Logging {
317
314
val manager = new TaskSetManager (sched, taskSet, 4 , clock)
318
315
319
316
{
320
- val offerResult = manager.resourceOffer(" exec1" , " host1" , 1 , TaskLocality .PROCESS_LOCAL )
317
+ val offerResult = manager.resourceOffer(" exec1" , " host1" , TaskLocality .PROCESS_LOCAL )
321
318
assert(offerResult.isDefined, " Expect resource offer to return a task" )
322
319
323
320
assert(offerResult.get.index === 0 )
@@ -328,15 +325,15 @@ class TaskSetManagerSuite extends FunSuite with LocalSparkContext with Logging {
328
325
assert(! sched.taskSetsFailed.contains(taskSet.id))
329
326
330
327
// Ensure scheduling on exec1 fails after failure 1 due to blacklist
331
- assert(manager.resourceOffer(" exec1" , " host1" , 1 , TaskLocality .PROCESS_LOCAL ).isEmpty)
332
- assert(manager.resourceOffer(" exec1" , " host1" , 1 , TaskLocality .NODE_LOCAL ).isEmpty)
333
- assert(manager.resourceOffer(" exec1" , " host1" , 1 , TaskLocality .RACK_LOCAL ).isEmpty)
334
- assert(manager.resourceOffer(" exec1" , " host1" , 1 , TaskLocality .ANY ).isEmpty)
328
+ assert(manager.resourceOffer(" exec1" , " host1" , TaskLocality .PROCESS_LOCAL ).isEmpty)
329
+ assert(manager.resourceOffer(" exec1" , " host1" , TaskLocality .NODE_LOCAL ).isEmpty)
330
+ assert(manager.resourceOffer(" exec1" , " host1" , TaskLocality .RACK_LOCAL ).isEmpty)
331
+ assert(manager.resourceOffer(" exec1" , " host1" , TaskLocality .ANY ).isEmpty)
335
332
}
336
333
337
334
// Run the task on exec1.1 - should work, and then fail it on exec1.1
338
335
{
339
- val offerResult = manager.resourceOffer(" exec1.1" , " host1" , 1 , TaskLocality .NODE_LOCAL )
336
+ val offerResult = manager.resourceOffer(" exec1.1" , " host1" , TaskLocality .NODE_LOCAL )
340
337
assert(offerResult.isDefined,
341
338
" Expect resource offer to return a task for exec1.1, offerResult = " + offerResult)
342
339
@@ -348,12 +345,12 @@ class TaskSetManagerSuite extends FunSuite with LocalSparkContext with Logging {
348
345
assert(! sched.taskSetsFailed.contains(taskSet.id))
349
346
350
347
// Ensure scheduling on exec1.1 fails after failure 2 due to blacklist
351
- assert(manager.resourceOffer(" exec1.1" , " host1" , 1 , TaskLocality .NODE_LOCAL ).isEmpty)
348
+ assert(manager.resourceOffer(" exec1.1" , " host1" , TaskLocality .NODE_LOCAL ).isEmpty)
352
349
}
353
350
354
351
// Run the task on exec2 - should work, and then fail it on exec2
355
352
{
356
- val offerResult = manager.resourceOffer(" exec2" , " host2" , 1 , TaskLocality .ANY )
353
+ val offerResult = manager.resourceOffer(" exec2" , " host2" , TaskLocality .ANY )
357
354
assert(offerResult.isDefined, " Expect resource offer to return a task" )
358
355
359
356
assert(offerResult.get.index === 0 )
@@ -364,20 +361,20 @@ class TaskSetManagerSuite extends FunSuite with LocalSparkContext with Logging {
364
361
assert(! sched.taskSetsFailed.contains(taskSet.id))
365
362
366
363
// Ensure scheduling on exec2 fails after failure 3 due to blacklist
367
- assert(manager.resourceOffer(" exec2" , " host2" , 1 , TaskLocality .ANY ).isEmpty)
364
+ assert(manager.resourceOffer(" exec2" , " host2" , TaskLocality .ANY ).isEmpty)
368
365
}
369
366
370
367
// After reschedule delay, scheduling on exec1 should be possible.
371
368
clock.advance(rescheduleDelay)
372
369
373
370
{
374
- val offerResult = manager.resourceOffer(" exec1" , " host1" , 1 , TaskLocality .PROCESS_LOCAL )
371
+ val offerResult = manager.resourceOffer(" exec1" , " host1" , TaskLocality .PROCESS_LOCAL )
375
372
assert(offerResult.isDefined, " Expect resource offer to return a task" )
376
373
377
374
assert(offerResult.get.index === 0 )
378
375
assert(offerResult.get.executorId === " exec1" )
379
376
380
- assert(manager.resourceOffer(" exec1" , " host1" , 1 , TaskLocality .PROCESS_LOCAL ).isEmpty)
377
+ assert(manager.resourceOffer(" exec1" , " host1" , TaskLocality .PROCESS_LOCAL ).isEmpty)
381
378
382
379
// Cause exec1 to fail : failure 4
383
380
manager.handleFailedTask(offerResult.get.taskId, TaskState .FINISHED , TaskResultLost )
0 commit comments