diff --git a/core/src/main/scala/org/apache/spark/deploy/history/HistoryPage.scala b/core/src/main/scala/org/apache/spark/deploy/history/HistoryPage.scala index 642d71b18c9e2..9249b40440529 100644 --- a/core/src/main/scala/org/apache/spark/deploy/history/HistoryPage.scala +++ b/core/src/main/scala/org/apache/spark/deploy/history/HistoryPage.scala @@ -33,9 +33,14 @@ private[history] class HistoryPage(parent: HistoryServer) extends WebUIPage("") val requestedFirst = (requestedPage - 1) * pageSize val requestedIncomplete = Option(request.getParameter("showIncomplete")).getOrElse("false").toBoolean + val requestedQuery = Option(request.getParameter("query")).getOrElse("") - val allApps = parent.getApplicationList() + var allApps = parent.getApplicationList() .filter(_.attempts.head.completed != requestedIncomplete) + if (!requestedQuery.equals("")) { + val query = requestedQuery.toLowerCase + allApps = allApps.filter(app => app.name.toLowerCase.contains(query)) + } val allAppsSize = allApps.size val actualFirst = if (requestedFirst < allAppsSize) requestedFirst else 0 @@ -74,19 +79,27 @@ private[history] class HistoryPage(parent: HistoryServer) extends WebUIPage("") // page, `...` will be displayed. if (allAppsSize > 0) { val leftSideIndices = - rangeIndices(actualPage - plusOrMinus until actualPage, 1 < _, requestedIncomplete) + rangeIndices(actualPage - plusOrMinus until actualPage, 1 < _, requestedIncomplete, + requestedQuery) val rightSideIndices = rangeIndices(actualPage + 1 to actualPage + plusOrMinus, _ < pageCount, - requestedIncomplete) + requestedIncomplete, requestedQuery)

+
+ Application Name: + + +
Showing {actualFirst + 1}-{last + 1} of {allAppsSize} {if (requestedIncomplete) "(Incomplete applications)"} { if (actualPage > 1) { - < - 1 + + < + + 1 } } {if (actualPage - plusOrMinus > secondPageFromLeft) " ... "} @@ -96,8 +109,12 @@ private[history] class HistoryPage(parent: HistoryServer) extends WebUIPage("") {if (actualPage + plusOrMinus < secondPageFromRight) " ... "} { if (actualPage < pageCount) { - {pageCount} - > + + {pageCount} + + + > + } } @@ -115,7 +132,7 @@ private[history] class HistoryPage(parent: HistoryServer) extends WebUIPage("")

} } - + { if (requestedIncomplete) { "Back to completed applications" @@ -151,9 +168,10 @@ private[history] class HistoryPage(parent: HistoryServer) extends WebUIPage("") private def rangeIndices( range: Seq[Int], condition: Int => Boolean, - showIncomplete: Boolean): Seq[Node] = { + showIncomplete: Boolean, + showQuery: String): Seq[Node] = { range.filter(condition).map(nextPage => - {nextPage} ) + {nextPage} ) } private def attemptRow( @@ -216,10 +234,11 @@ private[history] class HistoryPage(parent: HistoryServer) extends WebUIPage("") info.attempts.drop(1).flatMap(attemptRow(true, info, _, false)) } - private def makePageLink(linkPage: Int, showIncomplete: Boolean): String = { + private def makePageLink(linkPage: Int, showIncomplete: Boolean, showQuery: String): String = { UIUtils.prependBaseUri("/?" + Array( "page=" + linkPage, - "showIncomplete=" + showIncomplete + "showIncomplete=" + showIncomplete, + "query=" + showQuery ).mkString("&")) } }