SparkListenerBus — Internal Contract for Spark Event Buses
SparkListenerBus
is a private[spark]
ListenerBus for SparkListenerInterface listeners that process SparkListenerEvent events.
SparkListenerBus
comes with a custom doPostEvent
method that simply relays SparkListenerEvent
events to appropriate SparkListenerInterface
methods.
Note
|
There are two custom SparkListenerBus listeners: LiveListenerBus and ReplayListenerBus.
|
SparkListenerEvent | SparkListenerInterface’s Method |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
event ignored |
other event types |
|
ListenerBus
Event Bus Contract
1 2 3 4 5 |
ListenerBus[L <: AnyRef, E] |
ListenerBus
is an event bus that post events (of type E
) to all registered listeners (of type L
).
It manages listeners
of type L
, i.e. it can add to and remove listeners from an internal listeners
collection.
1 2 3 4 5 6 |
addListener(listener: L): Unit removeListener(listener: L): Unit |
It can post events of type E
to all registered listeners (using postToAll
method). It simply iterates over the internal listeners
collection and executes the abstract doPostEvent
method.
1 2 3 4 5 |
doPostEvent(listener: L, event: E): Unit |
Note
|
doPostEvent is provided by more specialized ListenerBus event buses.
|
In case of exception while posting an event to a listener you should see the following ERROR message in the logs and the exception.
1 2 3 4 5 |
ERROR Listener [listener] threw an exception |
Note
|
There are three custom ListenerBus listeners: SparkListenerBus, StreamingQueryListenerBus, and StreamingListenerBus.
|
Tip
|
Enable Add the following line to
Refer to Logging. |