Skip to content

Commit f7958b0

Browse files
committed
Implemented renderJson for JobProgressPage
1 parent 5556856 commit f7958b0

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

core/src/main/scala/org/apache/spark/ui/jobs/JobProgressPage.scala

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,14 @@ package org.apache.spark.ui.jobs
1919

2020
import javax.servlet.http.HttpServletRequest
2121

22+
import org.apache.spark.util.JsonProtocol
23+
import org.json4s.JValue
24+
import org.json4s.JsonAST.JNothing
25+
import org.json4s.JsonDSL._
26+
2227
import scala.xml.{Node, NodeSeq}
2328

24-
import org.apache.spark.scheduler.Schedulable
29+
import org.apache.spark.scheduler.{StageInfo, Schedulable}
2530
import org.apache.spark.ui.{WebUIPage, UIUtils}
2631

2732
/** Page showing list of all ongoing and recently finished stages and pools */
@@ -31,6 +36,34 @@ private[ui] class JobProgressPage(parent: JobProgressTab) extends WebUIPage("")
3136
private val listener = parent.listener
3237
private lazy val isFairScheduler = parent.isFairScheduler
3338

39+
override def renderJson(request: HttpServletRequest): JValue = {
40+
listener.synchronized {
41+
val activeStageList = listener.activeStages.values.map {
42+
case info: StageInfo =>
43+
JsonProtocol.stageInfoToJson(info)
44+
}
45+
val activeStageJson = ("Active Stages" -> activeStageList)
46+
47+
val completedStageList = listener.completedStages.reverse.map {
48+
case info: StageInfo =>
49+
JsonProtocol.stageInfoToJson(info)
50+
}
51+
val completedStageJson = ("Completed Stages" -> completedStageList)
52+
53+
val failedStageList = listener.failedStages.reverse.map {
54+
case info: StageInfo =>
55+
JsonProtocol.stageInfoToJson(info)
56+
}
57+
val failedStageJson = ("Failed Stages" -> failedStageList)
58+
59+
("Stages" ->
60+
activeStageJson ~
61+
completedStageJson ~
62+
failedStageJson)
63+
64+
}
65+
}
66+
3467
def render(request: HttpServletRequest): Seq[Node] = {
3568
listener.synchronized {
3669
val activeStages = listener.activeStages.values.toSeq

0 commit comments

Comments
 (0)