Github user JoshRosen commented on a diff in the pull request:
https://github.com/apache/spark/pull/18083#discussion_r121031573
--- Diff:
core/src/test/scala/org/apache/spark/scheduler/SparkListenerSuite.scala ---
@@ -138,6 +162,44 @@ class SparkListenerSuite extends SparkFunSuite with
LocalSparkContext with Match
assert(drained)
}
+ test("metrics for dropped listener events") {
+ val bus = new LiveListenerBus(new
SparkConf().set(LISTENER_BUS_EVENT_QUEUE_CAPACITY, 1))
+
+ val listenerStarted = new Semaphore(0)
+ val listenerWait = new Semaphore(0)
+
+ bus.addListener(new SparkListener {
+ override def onJobEnd(jobEnd: SparkListenerJobEnd): Unit = {
+ listenerStarted.release()
+ listenerWait.acquire()
+ }
+ })
+
+ bus.start(mockSparkContext, mockMetricsSystem)
+
+ // Post a message to the listener bus and wait for processing to begin:
+ bus.post(SparkListenerJobEnd(0, jobCompletionTime, JobSucceeded))
+ listenerStarted.acquire()
--- End diff --
This should be fine:
- If this code runs before `listenerStarted.release()` then it will block
until `listenerStarted.release()` is hit.
- The listener will block in `listenerWait.acquire()` until we call
`listenerWait.release()` further down in this method.
This synchronization pattern is already used elsewhere in this suite in
https://github.com/JoshRosen/spark/blob/76b669ca6eb35a0cce4291702baa5d1f60adb467/core/src/test/scala/org/apache/spark/scheduler/SparkListenerSuite.scala#L113
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]