-
Notifications
You must be signed in to change notification settings - Fork 29k
SPARK-1407 drain event queue before stopping event logger #366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,7 @@ private[spark] class LiveListenerBus extends SparkListenerBus with Logging { | |
| private val eventQueue = new LinkedBlockingQueue[SparkListenerEvent](EVENT_QUEUE_CAPACITY) | ||
| private var queueFullErrorMessageLogged = false | ||
| private var started = false | ||
| private var sparkListenerBus: Option[Thread] = _ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't have to be an option, you can move the declaration of the thread up here, and do thread.start() in |
||
|
|
||
| /** | ||
| * Start sending events to attached listeners. | ||
|
|
@@ -49,7 +50,7 @@ private[spark] class LiveListenerBus extends SparkListenerBus with Logging { | |
| throw new IllegalStateException("Listener bus already started!") | ||
| } | ||
| started = true | ||
| new Thread("SparkListenerBus") { | ||
| sparkListenerBus = Some(new Thread("SparkListenerBus") { | ||
| setDaemon(true) | ||
| override def run() { | ||
| while (true) { | ||
|
|
@@ -61,7 +62,8 @@ private[spark] class LiveListenerBus extends SparkListenerBus with Logging { | |
| postToAll(event) | ||
| } | ||
| } | ||
| }.start() | ||
| }) | ||
| sparkListenerBus.foreach(_.start()) | ||
| } | ||
|
|
||
| def post(event: SparkListenerEvent) { | ||
|
|
@@ -97,5 +99,6 @@ private[spark] class LiveListenerBus extends SparkListenerBus with Logging { | |
| throw new IllegalStateException("Attempted to stop a listener bus that has not yet started!") | ||
| } | ||
| post(SparkListenerShutdown) | ||
| sparkListenerBus.foreach(_.join()) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,6 +73,7 @@ object SparkHdfsLR { | |
| } | ||
|
|
||
| println("Final w: " + w) | ||
| sc.stop() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good call, the lack of this is a cause for bugs in other places of Spark.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By the way, is the System.exit(0) that follows necessary? Can we just remove it? |
||
| System.exit(0) | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
listenerBus.stop()should be moved all the way to the end ofsc.stop(), in case there are listeners that block for a long time and prevent other components of Spark to stop. PerhapseventLogger.foreach(_.stop())should go right after the listener bus.