Skip to content

Commit c0abb1d

Browse files
Marcelo Vanzincloud-fan
authored andcommitted
[SPARK-22854][UI] Read Spark version from event logs.
The code was ignoring SparkListenerLogStart, which was added somewhat recently to record the Spark version used to generate an event log. Author: Marcelo Vanzin <[email protected]> Closes #20049 from vanzin/SPARK-22854.
1 parent 7ab165b commit c0abb1d

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

core/src/main/scala/org/apache/spark/status/AppStatusListener.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ private[spark] class AppStatusListener(
4848

4949
import config._
5050

51-
private val sparkVersion = SPARK_VERSION
51+
private var sparkVersion = SPARK_VERSION
5252
private var appInfo: v1.ApplicationInfo = null
5353
private var appSummary = new AppSummary(0, 0)
5454
private var coresPerTask: Int = 1
@@ -90,6 +90,11 @@ private[spark] class AppStatusListener(
9090
}
9191
}
9292

93+
override def onOtherEvent(event: SparkListenerEvent): Unit = event match {
94+
case SparkListenerLogStart(version) => sparkVersion = version
95+
case _ =>
96+
}
97+
9398
override def onApplicationStart(event: SparkListenerApplicationStart): Unit = {
9499
assert(event.appId.isDefined, "Application without IDs are not supported.")
95100

core/src/test/scala/org/apache/spark/status/AppStatusListenerSuite.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ class AppStatusListenerSuite extends SparkFunSuite with BeforeAndAfter {
103103
test("scheduler events") {
104104
val listener = new AppStatusListener(store, conf, true)
105105

106+
listener.onOtherEvent(SparkListenerLogStart("TestSparkVersion"))
107+
106108
// Start the application.
107109
time += 1
108110
listener.onApplicationStart(SparkListenerApplicationStart(
@@ -125,6 +127,7 @@ class AppStatusListenerSuite extends SparkFunSuite with BeforeAndAfter {
125127
assert(attempt.endTime.getTime() === -1L)
126128
assert(attempt.sparkUser === "user")
127129
assert(!attempt.completed)
130+
assert(attempt.appSparkVersion === "TestSparkVersion")
128131
}
129132

130133
// Start a couple of executors.

0 commit comments

Comments
 (0)