Github user pwendell commented on a diff in the pull request: https://github.com/apache/spark/pull/2342#discussion_r28726383 --- Diff: core/src/main/scala/org/apache/spark/ui/jobs/AllJobsPage.scala --- @@ -17,18 +17,137 @@ package org.apache.spark.ui.jobs -import scala.xml.{Node, NodeSeq} +import scala.xml.{Node, NodeSeq, Unparsed} +import java.util.Date import javax.servlet.http.HttpServletRequest -import org.apache.spark.ui.{WebUIPage, UIUtils} +import org.apache.spark.ui.{UIUtils, WebUIPage} import org.apache.spark.ui.jobs.UIData.JobUIData +import org.apache.spark.JobExecutionStatus /** Page showing list of all ongoing and recently finished jobs */ private[ui] class AllJobsPage(parent: JobsTab) extends WebUIPage("") { private val startTime: Option[Long] = parent.sc.map(_.startTime) private val listener = parent.listener + private def applicationTimelineView(jobs: Seq[JobUIData], now: Long): Seq[Node] = { + val jobEventJsonAsStrSeq = jobs.flatMap { jobUIData => + val jobId = jobUIData.jobId + val status = jobUIData.status + val submissionTimeOpt = jobUIData.submissionTime + val completionTimeOpt = jobUIData.completionTime + + if (status == JobExecutionStatus.UNKNOWN || submissionTimeOpt.isEmpty || + completionTimeOpt.isEmpty && status != JobExecutionStatus.RUNNING) { + None + } + + val submissionTime = submissionTimeOpt.get + val completionTime = completionTimeOpt.getOrElse(now) + val classNameByStatus = status match { + case JobExecutionStatus.SUCCEEDED => "succeeded" + case JobExecutionStatus.FAILED => "failed" + case JobExecutionStatus.RUNNING => "running" + } + + val jobEventJsonAsStr = + s""" + |{ + | 'className': 'job application-timeline-object ${classNameByStatus}', + | 'group': 'jobs', + | 'start': new Date(${submissionTime}), + | 'end': new Date(${completionTime}), + | 'content': '<div class="application-timeline-content">Job ${jobId}</div>', + | 'title': 'Job ${jobId}\\nStatus: ${status}\\n' + + | 'Submission Time: ${UIUtils.formatDate(new Date(submissionTime))}' + + | '${ + if (status != JobExecutionStatus.RUNNING) { + s"""\\nCompletion Time: ${UIUtils.formatDate(new Date(completionTime))}""" + } else { + "" + } + }' + |} + """.stripMargin + Option(jobEventJsonAsStr) --- End diff -- Why is this an `Option`? Can you just return jobEventJsonAsStr?
--- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org