Skip to content

Commit

Permalink
[SPARK-22836][UI] Show driver logs in UI when available.
Browse files Browse the repository at this point in the history
Port code from the old executors listener to the new one, so that
the driver logs present in the application start event are kept.

Author: Marcelo Vanzin <vanzin@cloudera.com>

Closes #20038 from vanzin/SPARK-22836.
  • Loading branch information
Marcelo Vanzin authored and squito committed Dec 28, 2017
1 parent 8f6d573 commit 9c21ece
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,17 @@ private[spark] class AppStatusListener(

kvstore.write(new ApplicationInfoWrapper(appInfo))
kvstore.write(appSummary)

// Update the driver block manager with logs from this event. The SparkContext initialization
// code registers the driver before this event is sent.
event.driverLogs.foreach { logs =>
val driver = liveExecutors.get(SparkContext.DRIVER_IDENTIFIER)
.orElse(liveExecutors.get(SparkContext.LEGACY_DRIVER_IDENTIFIER))
driver.foreach { d =>
d.executorLogs = logs.toMap
update(d, System.nanoTime())
}
}
}

override def onEnvironmentUpdate(event: SparkListenerEnvironmentUpdate): Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,24 @@ class AppStatusListenerSuite extends SparkFunSuite with BeforeAndAfter {
}
}

test("driver logs") {
val listener = new AppStatusListener(store, conf, true)

val driver = BlockManagerId(SparkContext.DRIVER_IDENTIFIER, "localhost", 42)
listener.onBlockManagerAdded(SparkListenerBlockManagerAdded(time, driver, 42L))
listener.onApplicationStart(SparkListenerApplicationStart(
"name",
Some("id"),
time,
"user",
Some("attempt"),
Some(Map("stdout" -> "file.txt"))))

check[ExecutorSummaryWrapper](SparkContext.DRIVER_IDENTIFIER) { d =>
assert(d.info.executorLogs("stdout") === "file.txt")
}
}

private def key(stage: StageInfo): Array[Int] = Array(stage.stageId, stage.attemptId)

private def check[T: ClassTag](key: Any)(fn: T => Unit): Unit = {
Expand Down

0 comments on commit 9c21ece

Please sign in to comment.