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

    https://github.com/apache/spark/pull/3009#discussion_r20665799
  
    --- Diff: core/src/main/scala/org/apache/spark/ui/jobs/AllJobsPage.scala ---
    @@ -0,0 +1,149 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.ui.jobs
    +
    +import scala.xml.{Node, NodeSeq}
    +
    +import javax.servlet.http.HttpServletRequest
    +
    +import org.apache.spark.ui.{WebUIPage, UIUtils}
    +import org.apache.spark.ui.jobs.UIData.JobUIData
    +
    +
    +/** 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 jobsTable(jobs: Seq[JobUIData]): Seq[Node] = {
    +    val someJobHasJobGroup = jobs.exists(_.jobGroup.isDefined)
    +
    +    val columns: Seq[Node] = {
    +      <th>{if (someJobHasJobGroup) "Job Id (Job Group)" else "Job Id"}</th>
    +      <th>Description</th>
    +      <th>Submitted</th>
    +      <th>Duration</th>
    +      <th class="sorttable_nosort">Stages: Succeeded/Total</th>
    +      <th class="sorttable_nosort">Tasks (for all stages): 
Succeeded/Total</th>
    +    }
    +
    +    def makeRow(job: JobUIData): Seq[Node] = {
    +      val lastStageInfo = listener.stageIdToInfo.get(job.stageIds.max)
    +      val lastStageData = lastStageInfo.flatMap { s =>
    +        listener.stageIdToData.get((s.stageId, s.attemptId))
    +      }
    +      val lastStageName = lastStageInfo.map(_.name).getOrElse("(Unknown 
Stage Name)")
    +      val lastStageDescription = 
lastStageData.flatMap(_.description).getOrElse("")
    +      val duration: Option[Long] = {
    +        job.startTime.map { start =>
    +          val end = job.endTime.getOrElse(System.currentTimeMillis())
    +          end - start
    +        }
    +      }
    +      val formattedDuration = duration.map(d => 
UIUtils.formatDuration(d)).getOrElse("Unknown")
    +      val formattedSubmissionTime = 
job.startTime.map(UIUtils.formatDate).getOrElse("Unknown")
    +      val detailUrl =
    +        
"%s/jobs/job?id=%s".format(UIUtils.prependBaseUri(parent.basePath), job.jobId)
    +
    +      <tr>
    +        <td sorttable_customkey={job.jobId.toString}>
    +          {job.jobId} {job.jobGroup.map(id => s"($id)").getOrElse("")}
    +        </td>
    +        <td>
    +          <div><em>{lastStageDescription}</em></div>
    +          <a href={detailUrl}>{lastStageName}</a>
    +        </td>
    +        <td sorttable_customkey={job.startTime.getOrElse(-1).toString}>
    +          {formattedSubmissionTime}
    +        </td>
    +        <td 
sorttable_customkey={duration.getOrElse(-1).toString}>{formattedDuration}</td>
    +        <td class="stage-progress-cell">
    +          {job.completedStageIndices.size}/{job.stageIds.size}
    +          {if (job.numFailedStages > 0) s"(${job.numFailedStages} failed)" 
else ""}
    +        </td>
    +        <td class="progress-cell">
    +          {UIUtils.makeProgressBar(job.numActiveTasks, 
job.numCompletedTasks,
    +          job.numFailedTasks, job.numTasks)}
    +        </td>
    +      </tr>
    +    }
    +
    +    <table class="table table-bordered table-striped table-condensed 
sortable">
    +      <thead>{columns}</thead>
    +      <tbody>
    +        {jobs.map(makeRow)}
    +      </tbody>
    +    </table>
    +  }
    +
    +  def render(request: HttpServletRequest): Seq[Node] = {
    +    listener.synchronized {
    +      val activeJobs = listener.activeJobs.values.toSeq
    +      val completedJobs = listener.completedJobs.reverse.toSeq
    +      val failedJobs = listener.failedJobs.reverse.toSeq
    +      val now = System.currentTimeMillis
    +
    +      val activeJobsTable =
    +        jobsTable(activeJobs.sortBy(_.startTime.getOrElse(-1L)).reverse)
    +      val completedJobsTable =
    +        jobsTable(completedJobs.sortBy(_.endTime.getOrElse(-1L)).reverse)
    +      val failedJobsTable =
    +        jobsTable(failedJobs.sortBy(_.endTime.getOrElse(-1L)).reverse)
    +
    +      val summary: NodeSeq =
    +        <div>
    +          <ul class="unstyled">
    +            {if (startTime.isDefined) {
    +              // Total duration is not meaningful unless the UI is live
    +              <li>
    +                <strong>Total Duration: </strong>
    +                {UIUtils.formatDuration(now - startTime.get)}
    +              </li>
    +            }}
    +            <li>
    +              <strong>Scheduling Mode: </strong>
    +              
{listener.schedulingMode.map(_.toString).getOrElse("Unknown")}
    +            </li>
    +            <li>
    +              <a href="#active"><strong>Active Jobs:</strong></a>
    +              {activeJobs.size}
    +            </li>
    +            <li>
    +              <a href="#completed"><strong>Completed Jobs:</strong></a>
    +              {completedJobs.size}
    +            </li>
    +            <li>
    +              <a href="#failed"><strong>Failed Jobs:</strong></a>
    +              {failedJobs.size}
    +            </li>
    +          </ul>
    +        </div>
    +
    +      val content = summary ++
    +        <h4 id="active">Active Jobs ({activeJobs.size})</h4> ++ 
activeJobsTable ++
    +        <h4 id="completed">Completed Jobs ({completedJobs.size})</h4> ++ 
completedJobsTable ++
    +        <h4 id ="failed">Failed Jobs ({failedJobs.size})</h4> ++ 
failedJobsTable
    +
    +      val helpText = """A job is triggered by a action, like "count()" or 
"saveAsTextFile()".""" +
    --- End diff --
    
    minor: why not just escape the `"`s?


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