@@ -43,6 +43,7 @@ private[spark] class ReplayListenerBus(
4343 def this (logDir : String ) = this (logDir, Utils .getHadoopFileSystem(logDir))
4444
4545 private var applicationComplete = false
46+ private var sparkVersion : Option [String ] = None
4647 private var compressionCodec : Option [CompressionCodec ] = None
4748 private var logPaths = Array [Path ]()
4849 private var started = false
@@ -52,25 +53,27 @@ private[spark] class ReplayListenerBus(
5253 * Prepare state for reading event logs.
5354 *
5455 * This gathers relevant files in the given directory and extracts meaning from each category.
55- * More specifically, this involves looking for event logs, the compression codec file
56- * (if event logs are compressed), and the application completion file (if the application
57- * has run to completion).
56+ * More specifically, this involves looking for event logs, the Spark version file, the
57+ * compression codec file (if event logs are compressed), and the application completion
58+ * file (if the application has run to completion).
5859 */
5960 def start () {
6061 val filePaths = getFilePaths(logDir, fileSystem)
61- logPaths = filePaths.filter { file => EventLoggingListener .isEventLogFile(file.getName) }
62- compressionCodec =
63- filePaths.find { file =>
64- EventLoggingListener .isCompressionCodecFile(file.getName)
65- }.map { file =>
62+ logPaths = filePaths
63+ .filter { file => EventLoggingListener .isEventLogFile(file.getName) }
64+ sparkVersion = filePaths
65+ .find { file => EventLoggingListener .isSparkVersionFile(file.getName) }
66+ .map { file => EventLoggingListener .parseSparkVersion(file.getName) }
67+ compressionCodec = filePaths
68+ .find { file => EventLoggingListener .isCompressionCodecFile(file.getName) }
69+ .map { file =>
6670 val codec = EventLoggingListener .parseCompressionCodec(file.getName)
6771 val conf = new SparkConf
6872 conf.set(" spark.io.compression.codec" , codec)
6973 CompressionCodec .createCodec(conf)
7074 }
71- applicationComplete = filePaths.exists { file =>
72- EventLoggingListener .isApplicationCompleteFile(file.getName)
73- }
75+ applicationComplete = filePaths
76+ .exists { file => EventLoggingListener .isApplicationCompleteFile(file.getName) }
7477 started = true
7578 }
7679
@@ -80,6 +83,12 @@ private[spark] class ReplayListenerBus(
8083 applicationComplete
8184 }
8285
86+ /** Return the version of Spark on which the given application was run. */
87+ def getSparkVersion : String = {
88+ assert(started, " ReplayListenerBus not started yet" )
89+ sparkVersion.getOrElse(" <Unknown>" )
90+ }
91+
8392 /**
8493 * Replay each event in the order maintained in the given logs. This should only be called
8594 * exactly once. Return whether event logs are actually found.
0 commit comments