Skip to content

Commit 27d2702

Browse files
techaddictpdeyhim
authored andcommitted
SPARK-1469: Scheduler mode should accept lower-case definitions and have...
... nicer error messages There are two improvements to Scheduler Mode: 1. Made the built in ones case insensitive (fair/FAIR, fifo/FIFO). 2. If an invalid mode is given we should print a better error message. Author: Sandeep <sandeep@techaddict.me> Closes apache#388 from techaddict/1469 and squashes the following commits: a31bbd5 [Sandeep] SPARK-1469: Scheduler mode should accept lower-case definitions and have nicer error messages There are two improvements to Scheduler Mode: 1. Made the built in ones case insensitive (fair/FAIR, fifo/FIFO). 2. If an invalid mode is given we should print a better error message.
1 parent 21ab52b commit 27d2702

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

core/src/main/scala/org/apache/spark/scheduler/SchedulingMode.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ package org.apache.spark.scheduler
2525
object SchedulingMode extends Enumeration {
2626

2727
type SchedulingMode = Value
28-
val FAIR,FIFO,NONE = Value
28+
val FAIR, FIFO, NONE = Value
2929
}

core/src/main/scala/org/apache/spark/scheduler/TaskSchedulerImpl.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,13 @@ private[spark] class TaskSchedulerImpl(
9999
var schedulableBuilder: SchedulableBuilder = null
100100
var rootPool: Pool = null
101101
// default scheduler is FIFO
102-
val schedulingMode: SchedulingMode = SchedulingMode.withName(
103-
conf.get("spark.scheduler.mode", "FIFO"))
102+
private val schedulingModeConf = conf.get("spark.scheduler.mode", "FIFO")
103+
val schedulingMode: SchedulingMode = try {
104+
SchedulingMode.withName(schedulingModeConf.toUpperCase)
105+
} catch {
106+
case e: java.util.NoSuchElementException =>
107+
throw new SparkException(s"Urecognized spark.scheduler.mode: $schedulingModeConf")
108+
}
104109

105110
// This is a var so that we can reset it for testing purposes.
106111
private[spark] var taskResultGetter = new TaskResultGetter(sc.env, this)

0 commit comments

Comments
 (0)