Github user pwendell commented on a diff in the pull request:

    https://github.com/apache/spark/pull/2342#discussion_r28729612
  
    --- 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] = {
    --- End diff --
    
    Could you do a few things to make this cleaner and easier to follow?
    1. Remove the `val listener` field of the `AllJobsPage` class, then instead 
just access `parent.listener` directly in the `render` function.
    2. Refactor the timeline generation code to be more modular. I'd recommend 
the following functions:
    ```
    # These can be constants at the top level
    val EXECUTORS_LEGEND
    val JOBS_LEGEND
    
    def makeJobEvent(job: JobUIData): Seq[Node]
    // TODO: Consider pushing this into JobProgressListener
    case class ExecutorDataUI(startTime: Long, status: String, finishTime: 
Option[Long], finishReason: Option[String])
    def makeExecutorEvent(executor: ExecutorUIData): Seq[Node]
    def makeTimeline(jobs: Seq[JobUIData], executors: seq[ExecutorUIData])
    ```
    
    Then in the `render` function you can access the listener and create all 
the necessary inputs to those functions.


---
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

Reply via email to