SparkListener
is a mechanism in Spark to intercept events from the Spark scheduler that are emitted over the course of execution of a Spark application.
SparkListener
extends SparkListenerInterface with all the callback methods being no-op/do-nothing.
Spark relies on SparkListeners
internally to manage communication between internal components in the distributed environment for a Spark application, e.g. web UI, event persistence (for History Server), dynamic allocation of executors, keeping track of executors (using HeartbeatReceiver
) and others.
You can develop your own custom SparkListener
and register it using SparkContext.addSparkListener method or spark.extraListeners Spark property.
With SparkListener
you can focus on Spark events of your liking and process a subset of all scheduling events.
Tip
|
Developing a custom SparkListener is an excellent introduction to low-level details of Spark’s Execution Model. Check out the exercise Developing Custom SparkListener to monitor DAGScheduler in Scala. |
Tip
|
Enable
|
SparkListenerInterface
is an private[spark]
contract for Spark listeners to intercept events from the Spark scheduler.
Note
|
SparkListener and SparkFirehoseListener Spark listeners are direct implementations of SparkListenerInterface contract to help developing more sophisticated Spark listeners.
|
Method | Event | Reason |
---|---|---|
|
|
|
|
||
|
||
|
||
|
||
|
|
|
|
||
|
||
FIXME |
||
|
||
FIXME |
||
|
|
|
|
||
FIXME |
||
FIXME |
||
|
||
|
||
|
||
|
|
|
|
||
|
||
Catch-all callback that is often used in Spark SQL to handle custom events. |
Spark Listener | Description |
---|---|
Logs JSON-encoded events to a file that can later be read by History Server |
|
Allows users to receive all SparkListenerEvent events by overriding the single |
|
Prepares information for Executors tab in web UI |
|
StorageStatusListener, RDDOperationGraphListener, EnvironmentListener, BlockStatusListener and StorageListener |
For web UI |
|
|
|
|
Support for History Server |
|