From a31bbd5f7d5aad49ddd01d00aa3a78083ea4c6a1 Mon Sep 17 00:00:00 2001 From: Sandeep Date: Fri, 11 Apr 2014 09:43:42 +0530 Subject: [PATCH] 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. --- .../org/apache/spark/scheduler/SchedulingMode.scala | 2 +- .../org/apache/spark/scheduler/TaskSchedulerImpl.scala | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/core/src/main/scala/org/apache/spark/scheduler/SchedulingMode.scala b/core/src/main/scala/org/apache/spark/scheduler/SchedulingMode.scala index 3832ee7ff6eef..75186b6ba4a41 100644 --- a/core/src/main/scala/org/apache/spark/scheduler/SchedulingMode.scala +++ b/core/src/main/scala/org/apache/spark/scheduler/SchedulingMode.scala @@ -25,5 +25,5 @@ package org.apache.spark.scheduler object SchedulingMode extends Enumeration { type SchedulingMode = Value - val FAIR,FIFO,NONE = Value + val FAIR, FIFO, NONE = Value } diff --git a/core/src/main/scala/org/apache/spark/scheduler/TaskSchedulerImpl.scala b/core/src/main/scala/org/apache/spark/scheduler/TaskSchedulerImpl.scala index acd152dda89d4..649ed1daaadda 100644 --- a/core/src/main/scala/org/apache/spark/scheduler/TaskSchedulerImpl.scala +++ b/core/src/main/scala/org/apache/spark/scheduler/TaskSchedulerImpl.scala @@ -98,8 +98,13 @@ private[spark] class TaskSchedulerImpl( var schedulableBuilder: SchedulableBuilder = null var rootPool: Pool = null // default scheduler is FIFO - val schedulingMode: SchedulingMode = SchedulingMode.withName( - conf.get("spark.scheduler.mode", "FIFO")) + private val schedulingModeConf = conf.get("spark.scheduler.mode", "FIFO") + val schedulingMode: SchedulingMode = try { + SchedulingMode.withName(schedulingModeConf.toUpperCase) + } catch { + case e: java.util.NoSuchElementException => + throw new SparkException(s"Urecognized spark.scheduler.mode: $schedulingModeConf") + } // This is a var so that we can reset it for testing purposes. private[spark] var taskResultGetter = new TaskResultGetter(sc.env, this)