public class LiveListenerBus extends Object implements SparkListenerBus, Logging
Until start() is called, all posted events are only buffered. Only after this listener bus has started will events be actually propagated to all attached listeners. This listener bus is stopped when it receives a SparkListenerShutdown event, which is posted using stop().
Constructor and Description |
---|
LiveListenerBus() |
Modifier and Type | Method and Description |
---|---|
boolean |
listenerThreadIsAlive()
For testing only.
|
void |
post(SparkListenerEvent event) |
boolean |
queueIsEmpty()
Return whether the event queue is empty.
|
void |
start()
Start sending events to attached listeners.
|
void |
stop() |
boolean |
waitUntilEmpty(int timeoutMillis)
For testing only.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addListener, foreachListener, postToAll, sparkListeners
initializeIfNecessary, initializeLogging, isTraceEnabled, log_, log, logDebug, logDebug, logError, logError, logInfo, logInfo, logName, logTrace, logTrace, logWarning, logWarning
public void start()
This first sends out all buffered events posted before this listener bus has started, then listens for any additional events asynchronously while the listener bus is still running. This should only be called once.
public void post(SparkListenerEvent event)
public boolean waitUntilEmpty(int timeoutMillis)
public boolean listenerThreadIsAlive()
public boolean queueIsEmpty()
The use of synchronized here guarantees that all events that once belonged to this queue have already been processed by all attached listeners, if this returns true.
public void stop()