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
6f0d2c1c
Commit
6f0d2c1c
authored
14 years ago
by
Justin Ma
Browse files
Options
Downloads
Patches
Plain Diff
round robin scheduling of tasks has been added
parent
e9ffe6ca
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/scala/spark/HdfsFile.scala
+1
-1
1 addition, 1 deletion
src/scala/spark/HdfsFile.scala
src/scala/spark/MesosScheduler.scala
+23
-11
23 additions, 11 deletions
src/scala/spark/MesosScheduler.scala
src/scala/spark/SparkContext.scala
+1
-1
1 addition, 1 deletion
src/scala/spark/SparkContext.scala
with
25 additions
and
13 deletions
src/scala/spark/HdfsFile.scala
+
1
−
1
View file @
6f0d2c1c
...
...
@@ -25,7 +25,7 @@ extends RDD[String](sc) {
ConfigureLock
.
synchronized
{
inputFormat
.
configure
(
conf
)
}
@transient
val
splits_
=
inputFormat
.
getSplits
(
conf
,
2
).
map
(
new
HdfsSplit
(
_
)).
toArray
inputFormat
.
getSplits
(
conf
,
sc
.
scheduler
.
numCores
).
map
(
new
HdfsSplit
(
_
)).
toArray
override
def
splits
=
splits_
.
asInstanceOf
[
Array
[
Split
]]
...
...
This diff is collapsed.
Click to expand it.
src/scala/spark/MesosScheduler.scala
+
23
−
11
View file @
6f0d2c1c
...
...
@@ -3,6 +3,7 @@ package spark
import
java.io.File
import
scala.collection.mutable.Map
import
scala.collection.JavaConversions._
import
mesos.
{
Scheduler
=>
NScheduler
}
import
mesos._
...
...
@@ -105,10 +106,20 @@ extends NScheduler with spark.Scheduler
val
tasks
=
new
java
.
util
.
ArrayList
[
TaskDescription
]
if
(
activeOp
!=
null
)
{
try
{
for
(
i
<-
0
until
offers
.
size
.
toInt
)
{
activeOp
.
slaveOffer
(
offers
.
get
(
i
))
match
{
case
Some
(
task
)
=>
tasks
.
add
(
task
)
case
None
=>
{}
val
availableCpus
=
offers
.
map
(
_
.
getParams
.
get
(
"cpus"
).
toInt
)
val
availableMem
=
offers
.
map
(
_
.
getParams
.
get
(
"mem"
).
toInt
)
var
resourcesAvailable
=
true
while
(
resourcesAvailable
)
{
resourcesAvailable
=
false
for
(
i
<-
0
until
offers
.
size
.
toInt
)
{
activeOp
.
slaveOffer
(
offers
.
get
(
i
),
availableCpus
(
i
),
availableMem
(
i
))
match
{
case
Some
(
task
)
=>
tasks
.
add
(
task
)
availableCpus
(
i
)
-=
task
.
getParams
.
get
(
"cpus"
).
toInt
availableMem
(
i
)
-=
task
.
getParams
.
get
(
"mem"
).
toInt
resourcesAvailable
=
resourcesAvailable
||
true
case
None
=>
{}
}
}
}
}
catch
{
...
...
@@ -162,7 +173,7 @@ extends NScheduler with spark.Scheduler
// Trait representing an object that manages a parallel operation by
// implementing various scheduler callbacks.
trait
ParallelOperation
{
def
slaveOffer
(
s
:
SlaveOffer
)
:
Option
[
TaskDescription
]
def
slaveOffer
(
s
:
SlaveOffer
,
availableCpus
:
Int
,
availableMem
:
Int
)
:
Option
[
TaskDescription
]
def
statusUpdate
(
t
:
TaskStatus
)
:
Unit
def
error
(
code
:
Int
,
message
:
String
)
:
Unit
}
...
...
@@ -207,7 +218,7 @@ extends ParallelOperation
}
}
def
slaveOffer
(
offer
:
SlaveOffer
)
:
Option
[
TaskDescription
]
=
{
def
slaveOffer
(
offer
:
SlaveOffer
,
availableCpus
:
Int
,
availableMem
:
Int
)
:
Option
[
TaskDescription
]
=
{
if
(
tasksLaunched
<
numTasks
)
{
var
checkPrefVals
:
Array
[
Boolean
]
=
Array
(
true
)
val
time
=
System
.
currentTimeMillis
...
...
@@ -215,9 +226,8 @@ extends ParallelOperation
checkPrefVals
=
Array
(
true
,
false
)
// Allow non-preferred tasks
// TODO: Make desiredCpus and desiredMem configurable
val
desiredCpus
=
1
val
desiredMem
=
750
if
(
offer
.
getParams
.
get
(
"cpus"
).
toInt
<
desiredCpus
||
offer
.
getParams
.
get
(
"mem"
).
toInt
<
desiredMem
)
val
desiredMem
=
500
if
((
availableCpus
<
desiredCpus
)
||
(
availableMem
<
desiredMem
))
return
None
for
(
checkPref
<-
checkPrefVals
;
i
<-
0
until
numTasks
)
{
if
(!
launched
(
i
)
&&
(!
checkPref
||
...
...
@@ -264,7 +274,7 @@ extends ParallelOperation
def
taskFinished
(
status
:
TaskStatus
)
{
val
tid
=
status
.
getTaskId
print
ln
(
"Finished TID "
+
tid
)
print
(
"Finished TID "
+
tid
)
if
(!
finished
(
tidToIndex
(
tid
)))
{
// Deserialize task result
val
result
=
Utils
.
deserialize
[
TaskResult
[
T
]](
status
.
getData
)
...
...
@@ -274,10 +284,12 @@ extends ParallelOperation
// Mark finished and stop if we've finished all the tasks
finished
(
tidToIndex
(
tid
))
=
true
tasksFinished
+=
1
println
(
", finished "
+
tasksFinished
+
"/"
+
numTasks
)
if
(
tasksFinished
==
numTasks
)
setAllFinished
()
}
else
{
printf
(
"Task %s had already finished, so ignoring it\n"
,
tidToIndex
(
tid
))
printf
(
"
...
Task %s had already finished, so ignoring it\n"
,
tidToIndex
(
tid
))
}
}
...
...
This diff is collapsed.
Click to expand it.
src/scala/spark/SparkContext.scala
+
1
−
1
View file @
6f0d2c1c
...
...
@@ -25,7 +25,7 @@ class SparkContext(master: String, frameworkName: String) {
val
LOCAL_REGEX
=
"""local\[([0-9]+)\]"""
.
r
private
var
scheduler
:
Scheduler
=
master
match
{
private
[
spark
]
var
scheduler
:
Scheduler
=
master
match
{
case
"local"
=>
new
LocalScheduler
(
1
)
case
LOCAL_REGEX
(
threads
)
=>
new
LocalScheduler
(
threads
.
toInt
)
case
_
=>
{
System
.
loadLibrary
(
"mesos"
);
...
...
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