Github user pwendell commented on a diff in the pull request:
https://github.com/apache/spark/pull/42#discussion_r10597228
--- Diff: core/src/main/scala/org/apache/spark/ui/SparkUI.scala ---
@@ -68,19 +105,53 @@ private[spark] class SparkUI(sc: SparkContext) extends
Logging {
/** Initialize all components of the server */
def start() {
- // NOTE: This is decoupled from bind() because of the following
dependency cycle:
- // DAGScheduler() requires that the port of this server is known
- // This server must register all handlers, including JobProgressUI,
before binding
- // JobProgressUI registers a listener with SparkContext, which
requires sc to initialize
+ storage.start()
jobs.start()
+ env.start()
exec.start()
+
+ // Listen for events from the SparkContext if it exists, otherwise
from persisted storage
+ val eventBus = if (live) {
+ val loggingEnabled = conf.getBoolean("spark.eventLog.enabled", false)
+ if (loggingEnabled) {
+ val logger = new EventLoggingListener(appName, conf)
+ eventLogger = Some(logger)
+ sc.listenerBus.addListener(logger)
+ }
+ sc.listenerBus
+ } else {
+ replayerBus = Some(new SparkReplayerBus(conf))
+ replayerBus.get
+ }
+
+ // Storage status listener must receive events first, as other
listeners depend on its state
+ eventBus.addListener(storageStatusListener)
+ eventBus.addListener(storage.listener)
+ eventBus.addListener(jobs.listener)
+ eventBus.addListener(env.listener)
+ eventBus.addListener(exec.listener)
+ started = true
+ }
+
+ /**
+ * Reconstruct a previously persisted SparkUI from logs residing in the
given directory.
+ *
+ * This method must be invoked after the SparkUI has started. Return
true if log files
+ * are found and processed.
+ */
+ def renderFromPersistedStorage(logDir: String): Boolean = {
--- End diff --
This also might be nice to take out of the SparkUI and make a utility
function associated with a ReplayBus. For instance the ReplayBus could have an
associated object and that has a utility function like:
```
object ReplayBus {
def replayFromPersistentStorage(logDir: String, bus: ReplayBus)
}
```
The concept of replay is sort of distinct from the UI and might be useful
for other listener implementations.
---
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.
---