Check out SparkFirehoseListener, an adapter which forwards all events to a single `onEvent` method in order to let you do pattern-matching as you have described: https://github.com/apache/spark/blob/master/core/src/main/java/org/apache/spark/SparkFirehoseListener.java
On Tue, Oct 13, 2015 at 4:29 PM, Jakob Odersky <joder...@gmail.com> wrote: > Hi, > I came across the spark listener API while checking out possible UI > extensions recently. I noticed that all events inherit from a sealed trait > `SparkListenerEvent` and that a SparkListener has a corresponding > `onEventXXX(event)` method for every possible event. > > Considering that events inherit from a sealed trait and thus all events > are known during compile-time, what is the rationale of using specific > methods for every event rather than a single method that would let a client > pattern match on the type of event? > > I don't know the internals of the pattern matcher, but again, considering > events are sealed, I reckon that matching performance should not be an > issue. > > thanks, > --Jakob >