trait SchedulerBackend {
  def applicationId(): String
  def applicationAttemptId(): Option[String]
  def defaultParallelism(): Int
  def getDriverLogUrls: Option[Map[String, String]]
  def isReady(): Boolean
  def killTask(taskId: Long, executorId: String, interruptThread: Boolean): Unit
  def reviveOffers(): Unit
  def start(): Unit
  def stop(): Unit
}
SchedulerBackend — Pluggable Scheduler Backends
SchedulerBackend is a pluggable interface to support various cluster managers, e.g. Apache Mesos, Hadoop YARN or Spark’s own Spark Standalone and Spark local.
As the cluster managers differ by their custom task scheduling modes and resource offers mechanisms Spark abstracts the differences in SchedulerBackend contract.
| Cluster Environment | SchedulerBackends | 
|---|---|
Local mode  | 
|
(base for custom SchedulerBackends)  | 
|
Spark Standalone  | 
|
Spark on YARN  | 
  | 
Spark on Mesos  | 
  | 
A scheduler backend is created and started as part of SparkContext’s initialization (when TaskSchedulerImpl is started - see Creating Scheduler Backend and Task Scheduler).
| 
 Caution 
 | 
FIXME Image how it gets created with SparkContext in play here or in SparkContext doc. | 
Scheduler backends are started and stopped as part of TaskSchedulerImpl’s initialization and stopping.
Being a scheduler backend in Spark assumes a Apache Mesos-like model in which "an application" gets resource offers as machines become available and can launch tasks on them. Once a scheduler backend obtains the resource allocation, it can start executors.
| 
 Tip 
 | 
Understanding how Apache Mesos works can greatly improve understanding Spark. | 
SchedulerBackend Contract
| 
 Note 
 | 
org.apache.spark.scheduler.SchedulerBackend is a private[spark] Scala trait in Spark.
 | 
| Method | Description | 
|---|---|
Unique identifier of Spark Application Used when   | 
|
Attempt id of a Spark application Only supported by YARN cluster scheduler backend as the YARN cluster manager supports multiple application attempts. Used when… NOTE:   | 
|
Used when   | 
|
Returns no URLs by default and only supported by YarnClusterSchedulerBackend  | 
|
Controls whether  Used when   | 
|
Reports a  Used when: 
  | 
|
Starts  Used when   | 
|
Stops  Used when   |