Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
spark
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cs525-sp18-g07
spark
Commits
a65aa549
Commit
a65aa549
authored
12 years ago
by
Stephen Haberman
Browse files
Options
Downloads
Patches
Plain Diff
Override DAGScheduler.runLocally so we can remove the Thread.sleep.
parent
a4adeb25
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/src/main/scala/spark/scheduler/DAGScheduler.scala
+21
-16
21 additions, 16 deletions
core/src/main/scala/spark/scheduler/DAGScheduler.scala
core/src/test/scala/spark/scheduler/DAGSchedulerSuite.scala
+6
-3
6 additions, 3 deletions
core/src/test/scala/spark/scheduler/DAGSchedulerSuite.scala
with
27 additions
and
19 deletions
core/src/main/scala/spark/scheduler/DAGScheduler.scala
+
21
−
16
View file @
a65aa549
...
...
@@ -379,29 +379,34 @@ class DAGScheduler(
* We run the operation in a separate thread just in case it takes a bunch of time, so that we
* don't block the DAGScheduler event loop or other concurrent jobs.
*/
pr
ivate
def
runLocally
(
job
:
ActiveJob
)
{
pr
otected
def
runLocally
(
job
:
ActiveJob
)
{
logInfo
(
"Computing the requested partition locally"
)
new
Thread
(
"Local computation of job "
+
job
.
runId
)
{
override
def
run
()
{
try
{
SparkEnv
.
set
(
env
)
val
rdd
=
job
.
finalStage
.
rdd
val
split
=
rdd
.
partitions
(
job
.
partitions
(
0
))
val
taskContext
=
new
TaskContext
(
job
.
finalStage
.
id
,
job
.
partitions
(
0
),
0
)
try
{
val
result
=
job
.
func
(
taskContext
,
rdd
.
iterator
(
split
,
taskContext
))
job
.
listener
.
taskSucceeded
(
0
,
result
)
}
finally
{
taskContext
.
executeOnCompleteCallbacks
()
}
}
catch
{
case
e
:
Exception
=>
job
.
listener
.
jobFailed
(
e
)
}
runLocallyWithinThread
(
job
)
}
}.
start
()
}
// Broken out for easier testing in DAGSchedulerSuite.
protected
def
runLocallyWithinThread
(
job
:
ActiveJob
)
{
try
{
SparkEnv
.
set
(
env
)
val
rdd
=
job
.
finalStage
.
rdd
val
split
=
rdd
.
partitions
(
job
.
partitions
(
0
))
val
taskContext
=
new
TaskContext
(
job
.
finalStage
.
id
,
job
.
partitions
(
0
),
0
)
try
{
val
result
=
job
.
func
(
taskContext
,
rdd
.
iterator
(
split
,
taskContext
))
job
.
listener
.
taskSucceeded
(
0
,
result
)
}
finally
{
taskContext
.
executeOnCompleteCallbacks
()
}
}
catch
{
case
e
:
Exception
=>
job
.
listener
.
jobFailed
(
e
)
}
}
/** Submits stage, but first recursively submits any missing parents. */
private
def
submitStage
(
stage
:
Stage
)
{
logDebug
(
"submitStage("
+
stage
+
")"
)
...
...
This diff is collapsed.
Click to expand it.
core/src/test/scala/spark/scheduler/DAGSchedulerSuite.scala
+
6
−
3
View file @
a65aa549
...
...
@@ -90,7 +90,12 @@ class DAGSchedulerSuite extends FunSuite with BeforeAndAfter {
cacheLocations
.
clear
()
results
.
clear
()
mapOutputTracker
=
new
MapOutputTracker
()
scheduler
=
new
DAGScheduler
(
taskScheduler
,
mapOutputTracker
,
blockManagerMaster
,
null
)
scheduler
=
new
DAGScheduler
(
taskScheduler
,
mapOutputTracker
,
blockManagerMaster
,
null
)
{
override
def
runLocally
(
job
:
ActiveJob
)
{
// don't bother with the thread while unit testing
runLocallyWithinThread
(
job
)
}
}
}
after
{
...
...
@@ -203,8 +208,6 @@ class DAGSchedulerSuite extends FunSuite with BeforeAndAfter {
override
def
toString
=
"DAGSchedulerSuite Local RDD"
}
runEvent
(
JobSubmitted
(
rdd
,
jobComputeFunc
,
Array
(
0
),
true
,
null
,
listener
))
// this shouldn't be needed, but i haven't stubbed out runLocally yet
Thread
.
sleep
(
500
)
assert
(
results
===
Map
(
0
->
42
))
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment