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

    https://github.com/apache/spark/pull/13620#discussion_r71997489
  
    --- Diff: core/src/main/scala/org/apache/spark/ui/jobs/AllJobsPage.scala ---
    @@ -210,64 +214,69 @@ private[ui] class AllJobsPage(parent: JobsTab) 
extends WebUIPage("") {
         </script>
       }
     
    -  private def jobsTable(jobs: Seq[JobUIData]): Seq[Node] = {
    +  private def jobsTable(
    +      request: HttpServletRequest,
    +      jobTag: String,
    +      jobs: Seq[JobUIData]): Seq[Node] = {
    +    val allParameters = request.getParameterMap.asScala.toMap
    +    val parameterOtherTable = 
allParameters.filterNot(_._1.startsWith(jobTag))
    +      .map(para => para._1 + "=" + para._2(0))
    +
         val someJobHasJobGroup = jobs.exists(_.jobGroup.isDefined)
    +    val jobIdTitle = if (someJobHasJobGroup) "Job Id (Job Group)" else 
"Job Id"
     
    -    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>
    -    }
    +    val parameterJobPage = request.getParameter(jobTag + ".page")
    +    val parameterJobSortColumn = request.getParameter(jobTag + ".sort")
    +    val parameterJobSortDesc = request.getParameter(jobTag + ".desc")
    +    val parameterJobPageSize = request.getParameter(jobTag + ".pageSize")
    +    val parameterJobPrevPageSize = request.getParameter(jobTag + 
".prevPageSize")
     
    -    def makeRow(job: JobUIData): Seq[Node] = {
    -      val (lastStageName, lastStageDescription) = 
getLastStageNameAndDescription(job)
    -      val duration: Option[Long] = {
    -        job.submissionTime.map { start =>
    -          val end = 
job.completionTime.getOrElse(System.currentTimeMillis())
    -          end - start
    -        }
    +    val jobPage = Option(parameterJobPage).map(_.toInt).getOrElse(1)
    +    val jobSortColumn = Option(parameterJobSortColumn).map { sortColumn =>
    +      UIUtils.decodeURLParameter(sortColumn)
    +    }.getOrElse(jobIdTitle)
    +    val jobSortDesc = 
Option(parameterJobSortDesc).map(_.toBoolean).getOrElse(
    +      // New jobs should be shown above old jobs by default.
    +      if (jobSortColumn == jobIdTitle) true else false
    +    )
    +    val jobPageSize = 
Option(parameterJobPageSize).map(_.toInt).getOrElse(100)
    +    val jobPrevPageSize = 
Option(parameterJobPrevPageSize).map(_.toInt).getOrElse(jobPageSize)
    +
    +    val page: Int = {
    +      // If the user has changed to a larger page size, then go to page 1 
in order to avoid
    +      // IndexOutOfBoundsException.
    +      if (jobPageSize <= jobPrevPageSize) {
    +        jobPage
    +      } else {
    +        1
           }
    -      val formattedDuration = duration.map(d => 
UIUtils.formatDuration(d)).getOrElse("Unknown")
    -      val formattedSubmissionTime = 
job.submissionTime.map(UIUtils.formatDate).getOrElse("Unknown")
    -      val basePathUri = UIUtils.prependBaseUri(parent.basePath)
    -      val jobDescription =
    -        UIUtils.makeDescription(lastStageDescription, basePathUri, 
plainText = false)
    -
    -      val detailUrl = "%s/jobs/job?id=%s".format(basePathUri, job.jobId)
    -      <tr id={"job-" + job.jobId}>
    -        <td sorttable_customkey={job.jobId.toString}>
    -          {job.jobId} {job.jobGroup.map(id => s"($id)").getOrElse("")}
    -        </td>
    -        <td>
    -          {jobDescription}
    -          <a href={detailUrl} class="name-link">{lastStageName}</a>
    -        </td>
    -        <td 
sorttable_customkey={job.submissionTime.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 - 
job.numSkippedStages}
    -          {if (job.numFailedStages > 0) s"(${job.numFailedStages} failed)"}
    -          {if (job.numSkippedStages > 0) s"(${job.numSkippedStages} 
skipped)"}
    -        </td>
    -        <td class="progress-cell">
    -          {UIUtils.makeProgressBar(started = job.numActiveTasks, completed 
= job.numCompletedTasks,
    -           failed = job.numFailedTasks, skipped = job.numSkippedTasks, 
killed = job.numKilledTasks,
    -           total = job.numTasks - job.numSkippedTasks)}
    -        </td>
    -      </tr>
         }
    +    val currentTime = System.currentTimeMillis()
     
    -    <table class="table table-bordered table-striped table-condensed 
sortable">
    -      <thead>{columns}</thead>
    -      <tbody>
    -        {jobs.map(makeRow)}
    -      </tbody>
    -    </table>
    +    try {
    +      new JobPagedTable(
    +        jobs,
    +        jobTag,
    +        UIUtils.prependBaseUri(parent.basePath),
    +        "jobs", // subPath
    +        parameterOtherTable,
    +        parent.jobProgresslistener.stageIdToInfo,
    +        parent.jobProgresslistener.stageIdToData,
    +        currentTime,
    +        jobIdTitle,
    +        pageSize = jobPageSize,
    +        sortColumn = jobSortColumn,
    +        desc = jobSortDesc
    +      ).table(page)
    +    } catch {
    +      case e @ (_ : IllegalArgumentException | _ : 
IndexOutOfBoundsException) =>
    --- End diff --
    
    When will this these two exceptions get triggered?


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