-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-31688][WEBUI] Refactor Pagination framework #28512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,6 @@ import java.nio.charset.StandardCharsets.UTF_8 | |
| import java.util.Date | ||
| import javax.servlet.http.HttpServletRequest | ||
|
|
||
| import scala.collection.JavaConverters._ | ||
| import scala.collection.mutable.ListBuffer | ||
| import scala.xml._ | ||
|
|
||
|
|
@@ -211,45 +210,24 @@ private[ui] class AllJobsPage(parent: JobsTab, store: AppStatusStore) extends We | |
| jobTag: String, | ||
| jobs: Seq[v1.JobData], | ||
| killEnabled: Boolean): Seq[Node] = { | ||
| val parameterOtherTable = request.getParameterMap().asScala | ||
| .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 parameterJobPage = request.getParameter(jobTag + ".page") | ||
| val parameterJobSortColumn = request.getParameter(jobTag + ".sort") | ||
| val parameterJobSortDesc = request.getParameter(jobTag + ".desc") | ||
| val parameterJobPageSize = request.getParameter(jobTag + ".pageSize") | ||
|
|
||
| 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. | ||
| jobSortColumn == jobIdTitle | ||
| ) | ||
| val jobPageSize = Option(parameterJobPageSize).map(_.toInt).getOrElse(100) | ||
|
|
||
| val jobPage = Option(request.getParameter(jobTag + ".page")).map(_.toInt).getOrElse(1) | ||
| val currentTime = System.currentTimeMillis() | ||
|
|
||
| try { | ||
| new JobPagedTable( | ||
| request, | ||
| store, | ||
| jobs, | ||
| tableHeaderId, | ||
| jobTag, | ||
| UIUtils.prependBaseUri(request, parent.basePath), | ||
| "jobs", // subPath | ||
| parameterOtherTable, | ||
| killEnabled, | ||
| currentTime, | ||
| jobIdTitle, | ||
| pageSize = jobPageSize, | ||
| sortColumn = jobSortColumn, | ||
| desc = jobSortDesc | ||
| jobIdTitle | ||
| ).table(jobPage) | ||
| } catch { | ||
| case e @ (_ : IllegalArgumentException | _ : IndexOutOfBoundsException) => | ||
|
|
@@ -493,21 +471,19 @@ private[ui] class JobDataSource( | |
| } | ||
|
|
||
| private[ui] class JobPagedTable( | ||
| request: HttpServletRequest, | ||
| store: AppStatusStore, | ||
| data: Seq[v1.JobData], | ||
| tableHeaderId: String, | ||
| jobTag: String, | ||
| basePath: String, | ||
| subPath: String, | ||
| parameterOtherTable: Iterable[String], | ||
| killEnabled: Boolean, | ||
| currentTime: Long, | ||
| jobIdTitle: String, | ||
| pageSize: Int, | ||
| sortColumn: String, | ||
| desc: Boolean | ||
| jobIdTitle: String | ||
| ) extends PagedTable[JobTableRowData] { | ||
| val parameterPath = basePath + s"/$subPath/?" + parameterOtherTable.mkString("&") | ||
| private val (sortColumn, desc, pageSize) = getTableParameters(request, jobTag, jobIdTitle) | ||
| private val parameterPath = basePath + s"/$subPath/?" + getParameterOtherTable(request, jobTag) | ||
|
|
||
| override def tableId: String = jobTag + "-table" | ||
|
|
||
|
|
@@ -544,90 +520,22 @@ private[ui] class JobPagedTable( | |
| } | ||
|
|
||
| override def headers: Seq[Node] = { | ||
| // Information for each header: title, cssClass, and sortable | ||
| val jobHeadersAndCssClasses: Seq[(String, String, Boolean, Option[String])] = | ||
| // Information for each header: title, sortable, tooltip | ||
| val jobHeadersAndCssClasses: Seq[(String, Boolean, Option[String])] = | ||
| Seq( | ||
| (jobIdTitle, "", true, None), | ||
| ("Description", "", true, None), | ||
| ("Submitted", "", true, None), | ||
| ("Duration", "", true, Some("Elapsed time since the job was submitted " + | ||
| (jobIdTitle, true, None), | ||
| ("Description", true, None), | ||
| ("Submitted", true, None), | ||
| ("Duration", true, Some("Elapsed time since the job was submitted " + | ||
| "until execution completion of all its stages.")), | ||
| ("Stages: Succeeded/Total", "", false, None), | ||
| ("Tasks (for all stages): Succeeded/Total", "", false, None) | ||
| ("Stages: Succeeded/Total", false, None), | ||
| ("Tasks (for all stages): Succeeded/Total", false, None) | ||
| ) | ||
|
|
||
| if (!jobHeadersAndCssClasses.filter(_._3).map(_._1).contains(sortColumn)) { | ||
| throw new IllegalArgumentException(s"Unknown column: $sortColumn") | ||
| } | ||
| isSortColumnValid(jobHeadersAndCssClasses, sortColumn) | ||
|
|
||
| val headerRow: Seq[Node] = { | ||
| jobHeadersAndCssClasses.map { case (header, cssClass, sortable, tooltip) => | ||
| if (header == sortColumn) { | ||
| val headerLink = Unparsed( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| parameterPath + | ||
| s"&$jobTag.sort=${URLEncoder.encode(header, UTF_8.name())}" + | ||
| s"&$jobTag.desc=${!desc}" + | ||
| s"&$jobTag.pageSize=$pageSize" + | ||
| s"#$tableHeaderId") | ||
| val arrow = if (desc) "▾" else "▴" // UP or DOWN | ||
|
|
||
| <th class={cssClass}> | ||
| <a href={headerLink}> | ||
| { | ||
| if (tooltip.nonEmpty) { | ||
| <span data-toggle="tooltip" data-placement="top" title={tooltip.get}> | ||
| {header} {Unparsed(arrow)} | ||
| </span> | ||
| } else { | ||
| <span> | ||
| {header} {Unparsed(arrow)} | ||
| </span> | ||
| } | ||
| } | ||
| </a> | ||
| </th> | ||
| } else { | ||
| if (sortable) { | ||
| val headerLink = Unparsed( | ||
| parameterPath + | ||
| s"&$jobTag.sort=${URLEncoder.encode(header, UTF_8.name())}" + | ||
| s"&$jobTag.pageSize=$pageSize" + | ||
| s"#$tableHeaderId") | ||
|
|
||
| <th class={cssClass}> | ||
| <a href={headerLink}> | ||
| { | ||
| if (tooltip.nonEmpty) { | ||
| <span data-toggle="tooltip" data-placement="top" title={tooltip.get}> | ||
| {header} | ||
| </span> | ||
| } else { | ||
| <span> | ||
| {header} | ||
| </span> | ||
| } | ||
| } | ||
| </a> | ||
| </th> | ||
| } else { | ||
| <th class={cssClass}> | ||
| { | ||
| if (tooltip.nonEmpty) { | ||
| <span data-toggle="tooltip" data-placement="top" title={tooltip.get}> | ||
| {header} | ||
| </span> | ||
| } else { | ||
| <span> | ||
| {header} | ||
| </span> | ||
| } | ||
| } | ||
| </th> | ||
| } | ||
| } | ||
| } | ||
| } | ||
| <thead><tr>{headerRow}</tr></thead> | ||
| headerRow(jobHeadersAndCssClasses, desc, pageSize, sortColumn, parameterPath, | ||
| jobTag, tableHeaderId) | ||
| } | ||
|
|
||
| override def row(jobTableRow: JobTableRowData): Seq[Node] = { | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as here.