Github user JoshRosen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/3710#discussion_r21932115
  
    --- Diff: 
streaming/src/main/scala/org/apache/spark/streaming/scheduler/StreamingListenerBus.scala
 ---
    @@ -64,36 +69,32 @@ private[spark] class StreamingListenerBus() extends 
Logging {
       }
     
       def addListener(listener: StreamingListener) {
    -    listeners += listener
    +    listeners.add(listener)
       }
     
       def post(event: StreamingListenerEvent) {
         val eventAdded = eventQueue.offer(event)
    -    if (!eventAdded && !queueFullErrorMessageLogged) {
    +    if (!eventAdded && queueFullErrorMessageLogged.compareAndSet(false, 
true)) {
           logError("Dropping StreamingListenerEvent because no remaining room 
in event queue. " +
             "This likely means one of the StreamingListeners is too slow and 
cannot keep up with the " +
             "rate at which events are being started by the scheduler.")
    -      queueFullErrorMessageLogged = true
         }
       }
     
    -  /**
    -   * Waits until there are no more events in the queue, or until the 
specified time has elapsed.
    -   * Used for testing only. Returns true if the queue has emptied and 
false is the specified time
    -   * elapsed before the queue emptied.
    -   */
    -  def waitUntilEmpty(timeoutMillis: Int): Boolean = {
    -    val finishTime = System.currentTimeMillis + timeoutMillis
    -    while (!eventQueue.isEmpty) {
    -      if (System.currentTimeMillis > finishTime) {
    -        return false
    +  def stop(): Unit = {
    +    // Should not call `post`, or `StreamingListenerShutdown` may be 
dropped.
    +    eventQueue.offer(StreamingListenerShutdown)
    +    listenerThread.join()
    +  }
    +
    +  private def foreachListener(f: StreamingListener => Unit): Unit = {
    --- End diff --
    
    This looks like a good change to me, especially since we already use this 
error-handling strategy in 
[SparkListenerBus](https://github.com/apache/spark/blob/master/core/src/main/scala/org/apache/spark/scheduler/SparkListenerBus.scala)
 (added in #759).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to