-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-23888][CORE] correct the comment of hasAttemptOnHost() #20998
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3584a09
add task attempt running check in hasAttemptOnHost
Ngone51 2ed9584
address review comments
Ngone51 5901728
address comments
Ngone51 500cc77
correct the comment
Ngone51 0c6f305
remove UT
Ngone51 e44d80b
address comment
Ngone51 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -880,6 +880,59 @@ class TaskSetManagerSuite extends SparkFunSuite with LocalSparkContext with Logg | |
| assert(manager.resourceOffer("execB", "host2", ANY).get.index === 3) | ||
| } | ||
|
|
||
| test("speculative task should not run on a given host where another attempt " + | ||
| "is already running on") { | ||
| sc = new SparkContext("local", "test") | ||
| sched = new FakeTaskScheduler( | ||
| sc, ("execA", "host1"), ("execB", "host2")) | ||
| val taskSet = FakeTask.createTaskSet(1, | ||
| Seq(TaskLocation("host1", "execA"), TaskLocation("host2", "execB"))) | ||
| val clock = new ManualClock | ||
| val manager = new TaskSetManager(sched, taskSet, MAX_TASK_FAILURES, clock = clock) | ||
|
|
||
| // let task0.0 run on host1 | ||
| assert(manager.resourceOffer("execA", "host1", PROCESS_LOCAL).get.index == 0) | ||
| val info1 = manager.taskAttempts(0)(0) | ||
| assert(info1.running === true) | ||
| assert(info1.host === "host1") | ||
|
|
||
| // long time elapse, and task0.0 is still running, | ||
| // so we launch a speculative task0.1 on host2 | ||
| clock.advance(1000) | ||
| manager.speculatableTasks += 0 | ||
| assert(manager.resourceOffer("execB", "host2", PROCESS_LOCAL).get.index === 0) | ||
| val info2 = manager.taskAttempts(0)(0) | ||
| assert(info2.running === true) | ||
| assert(info2.host === "host2") | ||
| assert(manager.speculatableTasks.size === 0) | ||
|
|
||
| // now, task0 has two copies running on host1, host2 separately, | ||
| // so we can not launch a speculative task on any hosts. | ||
| manager.speculatableTasks += 0 | ||
| assert(manager.resourceOffer("execA", "host1", PROCESS_LOCAL) === None) | ||
| assert(manager.resourceOffer("execB", "host2", PROCESS_LOCAL) === None) | ||
| assert(manager.speculatableTasks.size === 1) | ||
|
|
||
| // after a long long time, task0.0 failed, and task0.0 can not re-run since | ||
| // there's already a running copy. | ||
| clock.advance(1000) | ||
| info1.finishTime = clock.getTimeMillis() | ||
| assert(info1.running === false) | ||
|
||
|
|
||
| // time goes on, and task0.1 is still running | ||
| clock.advance(1000) | ||
| // so we try to launch a new speculative task | ||
| // we can not run it on host2, because task0.1 is already running on | ||
| assert(manager.resourceOffer("execB", "host2", PROCESS_LOCAL) === None) | ||
| // we successfully launch a speculative task0.2 on host1, since there's | ||
| // no more running copy of task0 | ||
| assert(manager.resourceOffer("execA", "host1", PROCESS_LOCAL).get.index === 0) | ||
| val info3 = manager.taskAttempts(0)(0) | ||
| assert(info3.running === true) | ||
|
||
| assert(info3.host === "host1") | ||
| assert(manager.speculatableTasks.size === 0) | ||
| } | ||
|
|
||
| test("node-local tasks should be scheduled right away " + | ||
| "when there are only node-local and no-preference tasks") { | ||
| sc = new SparkContext("local", "test") | ||
|
|
||
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.
it would be better here for you to call
manager.handleFailedTask, to more accurately simulate the real behavior, and also makes the purpose of a test a little more clear.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.
nice suggestion.
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.
you shouldn't need to set
info.finishTimeanymore, that should be taken care of bymanager.handleFailedTask.