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
bf21bb28
Commit
bf21bb28
authored
14 years ago
by
Matei Zaharia
Browse files
Options
Downloads
Patches
Plain Diff
Further clarified some code
parent
c21f840a
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
src/scala/spark/MesosScheduler.scala
+21
-6
21 additions, 6 deletions
src/scala/spark/MesosScheduler.scala
src/scala/spark/SimpleJob.scala
+1
-4
1 addition, 4 deletions
src/scala/spark/SimpleJob.scala
with
22 additions
and
10 deletions
src/scala/spark/MesosScheduler.scala
+
21
−
6
View file @
bf21bb28
...
...
@@ -29,13 +29,13 @@ extends MScheduler with spark.Scheduler with Logging
)
// Lock used to wait for scheduler to be registered
var
isRegistered
=
false
val
registeredLock
=
new
Object
()
private
var
isRegistered
=
false
private
val
registeredLock
=
new
Object
()
var
activeJobs
=
new
HashMap
[
Int
,
Job
]
var
activeJobsQueue
=
new
Queue
[
Job
]
private
var
activeJobs
=
new
HashMap
[
Int
,
Job
]
private
var
activeJobsQueue
=
new
Queue
[
Job
]
private
[
spark
]
var
taskIdToJobId
=
new
HashMap
[
Int
,
Int
]
private
var
taskIdToJobId
=
new
HashMap
[
Int
,
Int
]
private
var
nextJobId
=
0
...
...
@@ -126,6 +126,11 @@ extends MScheduler with spark.Scheduler with Logging
}
}
/**
* Method called by Mesos to offer resources on slaves. We resond by asking
* our active jobs for tasks in FIFO order. We fill each node with tasks in
* a round-robin manner so that tasks are balanced across the cluster.
*/
override
def
resourceOffer
(
d
:
SchedulerDriver
,
oid
:
String
,
offers
:
JList
[
SlaveOffer
])
{
synchronized
{
...
...
@@ -159,6 +164,14 @@ extends MScheduler with spark.Scheduler with Logging
}
}
// Check whether a Mesos task state represents a finished task
def
isFinished
(
state
:
TaskState
)
=
{
state
==
TaskState
.
TASK_FINISHED
||
state
==
TaskState
.
TASK_FAILED
||
state
==
TaskState
.
TASK_KILLED
||
state
==
TaskState
.
TASK_LOST
}
override
def
statusUpdate
(
d
:
SchedulerDriver
,
status
:
TaskStatus
)
{
synchronized
{
try
{
...
...
@@ -167,10 +180,12 @@ extends MScheduler with spark.Scheduler with Logging
if
(
activeJobs
.
contains
(
jobId
))
{
activeJobs
(
jobId
).
statusUpdate
(
status
)
}
if
(
isFinished
(
status
.
getState
))
{
taskIdToJobId
.
remove
(
status
.
getTaskId
)
}
case
None
=>
logInfo
(
"TID "
+
status
.
getTaskId
+
" already finished"
)
}
}
catch
{
case
e
:
Exception
=>
logError
(
"Exception in statusUpdate"
,
e
)
}
...
...
This diff is collapsed.
Click to expand it.
src/scala/spark/SimpleJob.scala
+
1
−
4
View file @
bf21bb28
...
...
@@ -9,7 +9,7 @@ import mesos._
/**
* A
simple implementation of Job that just runs each task in an array
.
* A
Job that runs a set of tasks with no interdependencies
.
*/
class
SimpleJob
[
T:
ClassManifest
](
sched
:
MesosScheduler
,
tasks
:
Array
[
Task
[
T
]],
val
jobId
:
Int
)
...
...
@@ -204,8 +204,6 @@ extends Job(jobId) with Logging
Accumulators
.
add
(
callingThread
,
result
.
accumUpdates
)
// Mark finished and stop if we've finished all the tasks
finished
(
index
)
=
true
// Remove TID -> jobId mapping from sched
sched
.
taskIdToJobId
.
remove
(
tid
)
if
(
tasksFinished
==
numTasks
)
setAllFinished
()
}
else
{
...
...
@@ -220,7 +218,6 @@ extends Job(jobId) with Logging
if
(!
finished
(
index
))
{
logInfo
(
"Lost TID %d (task %d:%d)"
.
format
(
tid
,
jobId
,
index
))
launched
(
index
)
=
false
sched
.
taskIdToJobId
.
remove
(
tid
)
tasksLaunched
-=
1
// Re-enqueue the task as pending
addPendingTask
(
index
)
...
...
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