-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-4329][WebUI] HistoryPage pagenation #3194
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
8 commits
Select commit
Hold shift + click to select a range
cfa242b
Added index to HistoryPage
sarutak 755a004
Merge branch 'master' of git://git.apache.org/spark into history-page…
sarutak ec7922e
Simplified code
sarutak b2240f8
Fixed style
sarutak 76b05e3
Merge branch 'master' of git://git.apache.org/spark into history-page…
sarutak 1c2f605
Merge branch 'master' of git://git.apache.org/spark into history-page…
sarutak c93932e
Merge branch 'master' of git://git.apache.org/spark into history-page…
sarutak 15d3d2d
Simplified code
sarutak 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,7 @@ import org.apache.spark.ui.{WebUIPage, UIUtils} | |
| private[spark] class HistoryPage(parent: HistoryServer) extends WebUIPage("") { | ||
|
|
||
| private val pageSize = 20 | ||
| private val plusOrMinus = 2 | ||
|
|
||
| def render(request: HttpServletRequest): Seq[Node] = { | ||
| val requestedPage = Option(request.getParameter("page")).getOrElse("1").toInt | ||
|
|
@@ -39,6 +40,9 @@ private[spark] class HistoryPage(parent: HistoryServer) extends WebUIPage("") { | |
| val last = Math.min(actualFirst + pageSize, allApps.size) - 1 | ||
| val pageCount = allApps.size / pageSize + (if (allApps.size % pageSize > 0) 1 else 0) | ||
|
|
||
| val secondPageFromLeft = 2 | ||
| val secondPageFromRight = pageCount - 1 | ||
|
|
||
| val appTable = UIUtils.listingTable(appHeader, appRow, apps) | ||
| val providerConfig = parent.getProviderConfig() | ||
| val content = | ||
|
|
@@ -48,13 +52,40 @@ private[spark] class HistoryPage(parent: HistoryServer) extends WebUIPage("") { | |
| {providerConfig.map { case (k, v) => <li><strong>{k}:</strong> {v}</li> }} | ||
| </ul> | ||
| { | ||
| // This displays the indices of pages that are within | ||
| // `plusOrMinus` pages of the current page. | ||
| // Regardless of where the current page is, | ||
| // this also links to the first and last page. | ||
| // If the current page +/- `plusOrMinux` is greater than the 2nd page | ||
| // from the first page or littler than the 2nd page from the last page, | ||
|
Contributor
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. or less than |
||
| // `...` will be displayed. | ||
| if (allApps.size > 0) { | ||
| val leftSideIndices = | ||
| rangeIndices(actualPage - plusOrMinus until actualPage, 1 < _) | ||
| val rightSideIndices = | ||
| rangeIndices(actualPage + 1 to actualPage + plusOrMinus, _ < pageCount) | ||
|
|
||
| <h4> | ||
| Showing {actualFirst + 1}-{last + 1} of {allApps.size} | ||
| <span style="float: right"> | ||
| {if (actualPage > 1) <a href={"/?page=" + (actualPage - 1)}><</a>} | ||
| {if (actualPage < pageCount) <a href={"/?page=" + (actualPage + 1)}>></a>} | ||
| </span> | ||
| <span style="float: right"> | ||
| { | ||
| if (actualPage > 1) { | ||
| <a href={"/?page=" + (actualPage - 1)}>< </a> | ||
| <a href={"/?page=1"}>1</a> | ||
| } | ||
| } | ||
| {if (actualPage - plusOrMinus > secondPageFromLeft) " ... "} | ||
| {leftSideIndices} | ||
| {actualPage} | ||
| {rightSideIndices} | ||
| {if (actualPage + plusOrMinus < secondPageFromRight) " ... "} | ||
| { | ||
| if (actualPage < pageCount) { | ||
| <a href={"/?page=" + pageCount}>{pageCount}</a> | ||
| <a href={"/?page=" + (actualPage + 1)}> ></a> | ||
| } | ||
| } | ||
| </span> | ||
| </h4> ++ | ||
| appTable | ||
| } else { | ||
|
|
@@ -81,6 +112,10 @@ private[spark] class HistoryPage(parent: HistoryServer) extends WebUIPage("") { | |
| "Spark User", | ||
| "Last Updated") | ||
|
|
||
| private def rangeIndices(range: Seq[Int], condition: Int => Boolean): Seq[Node] = { | ||
| range.filter(condition).map(nextPage => <a href={"/?page=" + nextPage}> {nextPage} </a>) | ||
| } | ||
|
|
||
| private def appRow(info: ApplicationHistoryInfo): Seq[Node] = { | ||
| val uiAddress = HistoryServer.UI_PATH_PREFIX + s"/${info.id}" | ||
| val startTime = UIUtils.formatDate(info.startTime) | ||
|
|
||
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.
plusOrMinux, I'll fix this when I merge don't worry