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
834686b1
Commit
834686b1
authored
11 years ago
by
Reynold Xin
Browse files
Options
Downloads
Plain Diff
Merge pull request #928 from jerryshao/fairscheduler-refactor
Refactor FairSchedulableBuilder
parents
a2ea069a
77e9da1f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/src/main/scala/org/apache/spark/scheduler/cluster/SchedulableBuilder.scala
+56
-43
56 additions, 43 deletions
...g/apache/spark/scheduler/cluster/SchedulableBuilder.scala
with
56 additions
and
43 deletions
core/src/main/scala/org/apache/spark/scheduler/cluster/SchedulableBuilder.scala
+
56
−
43
View file @
834686b1
...
...
@@ -17,14 +17,12 @@
package
org.apache.spark.scheduler.cluster
import
java.io.
{
File
,
FileInputStream
,
FileOutputStream
,
FileNotFoundException
}
import
java.util.Properties
import
scala.xml.XML
import
java.io.
{
FileInputStream
,
InputStream
}
import
java.util.
{
NoSuchElementException
,
Properties
}
import
org.apache.spark.Logging
import
org.apache.spark.scheduler.cluster.SchedulingMode.SchedulingMode
import
scala.xml.XML
/**
* An interface to build Schedulable tree
...
...
@@ -51,7 +49,8 @@ private[spark] class FIFOSchedulableBuilder(val rootPool: Pool)
private
[
spark
]
class
FairSchedulableBuilder
(
val
rootPool
:
Pool
)
extends
SchedulableBuilder
with
Logging
{
val
schedulerAllocFile
=
System
.
getProperty
(
"spark.scheduler.allocation.file"
)
val
schedulerAllocFile
=
Option
(
System
.
getProperty
(
"spark.scheduler.allocation.file"
))
val
DEFAULT_SCHEDULER_FILE
=
"fairscheduler.xml"
val
FAIR_SCHEDULER_PROPERTIES
=
"spark.scheduler.pool"
val
DEFAULT_POOL_NAME
=
"default"
val
MINIMUM_SHARES_PROPERTY
=
"minShare"
...
...
@@ -64,48 +63,26 @@ private[spark] class FairSchedulableBuilder(val rootPool: Pool)
val
DEFAULT_WEIGHT
=
1
override
def
buildPools
()
{
if
(
schedulerAllocFile
!=
null
)
{
val
file
=
new
File
(
schedulerAllocFile
)
if
(
file
.
exists
())
{
val
xml
=
XML
.
loadFile
(
file
)
for
(
poolNode
<-
(
xml
\\
POOLS_PROPERTY
))
{
val
poolName
=
(
poolNode
\
POOL_NAME_PROPERTY
).
text
var
schedulingMode
=
DEFAULT_SCHEDULING_MODE
var
minShare
=
DEFAULT_MINIMUM_SHARE
var
weight
=
DEFAULT_WEIGHT
val
xmlSchedulingMode
=
(
poolNode
\
SCHEDULING_MODE_PROPERTY
).
text
if
(
xmlSchedulingMode
!=
""
)
{
try
{
schedulingMode
=
SchedulingMode
.
withName
(
xmlSchedulingMode
)
}
catch
{
case
e
:
Exception
=>
logInfo
(
"Error xml schedulingMode, using default schedulingMode"
)
}
}
val
xmlMinShare
=
(
poolNode
\
MINIMUM_SHARES_PROPERTY
).
text
if
(
xmlMinShare
!=
""
)
{
minShare
=
xmlMinShare
.
toInt
}
val
xmlWeight
=
(
poolNode
\
WEIGHT_PROPERTY
).
text
if
(
xmlWeight
!=
""
)
{
weight
=
xmlWeight
.
toInt
}
val
pool
=
new
Pool
(
poolName
,
schedulingMode
,
minShare
,
weight
)
rootPool
.
addSchedulable
(
pool
)
logInfo
(
"Created pool %s, schedulingMode: %s, minShare: %d, weight: %d"
.
format
(
poolName
,
schedulingMode
,
minShare
,
weight
))
var
is
:
Option
[
InputStream
]
=
None
try
{
is
=
Option
{
schedulerAllocFile
.
map
{
f
=>
new
FileInputStream
(
f
)
}.
getOrElse
{
getClass
.
getClassLoader
.
getResourceAsStream
(
DEFAULT_SCHEDULER_FILE
)
}
}
else
{
throw
new
java
.
io
.
FileNotFoundException
(
"Fair scheduler allocation file not found: "
+
schedulerAllocFile
)
}
is
.
foreach
{
i
=>
buildFairSchedulerPool
(
i
)
}
}
finally
{
is
.
foreach
(
_
.
close
())
}
// finally create "default" pool
buildDefaultPool
()
}
private
def
buildDefaultPool
()
{
if
(
rootPool
.
getSchedulableByName
(
DEFAULT_POOL_NAME
)
==
null
)
{
val
pool
=
new
Pool
(
DEFAULT_POOL_NAME
,
DEFAULT_SCHEDULING_MODE
,
DEFAULT_MINIMUM_SHARE
,
DEFAULT_WEIGHT
)
...
...
@@ -115,6 +92,42 @@ private[spark] class FairSchedulableBuilder(val rootPool: Pool)
}
}
private
def
buildFairSchedulerPool
(
is
:
InputStream
)
{
val
xml
=
XML
.
load
(
is
)
for
(
poolNode
<-
(
xml
\\
POOLS_PROPERTY
))
{
val
poolName
=
(
poolNode
\
POOL_NAME_PROPERTY
).
text
var
schedulingMode
=
DEFAULT_SCHEDULING_MODE
var
minShare
=
DEFAULT_MINIMUM_SHARE
var
weight
=
DEFAULT_WEIGHT
val
xmlSchedulingMode
=
(
poolNode
\
SCHEDULING_MODE_PROPERTY
).
text
if
(
xmlSchedulingMode
!=
""
)
{
try
{
schedulingMode
=
SchedulingMode
.
withName
(
xmlSchedulingMode
)
}
catch
{
case
e
:
NoSuchElementException
=>
logWarning
(
"Error xml schedulingMode, using default schedulingMode"
)
}
}
val
xmlMinShare
=
(
poolNode
\
MINIMUM_SHARES_PROPERTY
).
text
if
(
xmlMinShare
!=
""
)
{
minShare
=
xmlMinShare
.
toInt
}
val
xmlWeight
=
(
poolNode
\
WEIGHT_PROPERTY
).
text
if
(
xmlWeight
!=
""
)
{
weight
=
xmlWeight
.
toInt
}
val
pool
=
new
Pool
(
poolName
,
schedulingMode
,
minShare
,
weight
)
rootPool
.
addSchedulable
(
pool
)
logInfo
(
"Created pool %s, schedulingMode: %s, minShare: %d, weight: %d"
.
format
(
poolName
,
schedulingMode
,
minShare
,
weight
))
}
}
override
def
addTaskSetManager
(
manager
:
Schedulable
,
properties
:
Properties
)
{
var
poolName
=
DEFAULT_POOL_NAME
var
parentPool
=
rootPool
.
getSchedulableByName
(
poolName
)
...
...
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