Skip to content

Commit 249bcea

Browse files
author
Marcelo Vanzin
committed
Remove offset / count from provider interface.
1 parent ca5d320 commit 249bcea

File tree

3 files changed

+18
-26
lines changed

3 files changed

+18
-26
lines changed

core/src/main/scala/org/apache/spark/deploy/history/FsHistoryProvider.scala

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,7 @@ private[history] class FsHistoryProvider(conf: SparkConf) extends ApplicationHis
8686
logCheckingThread.start()
8787
}
8888

89-
override def getListing(offset: Int, count: Int) = {
90-
val list = appList
91-
val theOffset = if (offset < list.size) offset else 0
92-
(list.slice(theOffset, Math.min(theOffset + count, list.size)), theOffset, list.size)
93-
}
89+
override def getListing() = appList
9490

9591
override def getAppInfo(appId: String): ApplicationHistoryInfo = {
9692
try {
@@ -137,7 +133,7 @@ private[history] class FsHistoryProvider(conf: SparkConf) extends ApplicationHis
137133
}
138134
}
139135

140-
appList = newApps.sortBy { info => -info.lastUpdated }
136+
appList = newApps.sortBy { info => -info.endTime }
141137
} catch {
142138
case t: Throwable => logError("Exception in checking for event log updates", t)
143139
}

core/src/main/scala/org/apache/spark/deploy/history/HistoryPage.scala

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,23 @@ private[spark] class HistoryPage(parent: HistoryServer) extends WebUIPage("") {
3030
def render(request: HttpServletRequest): Seq[Node] = {
3131
val requestedPage = Option(request.getParameter("page")).getOrElse("1").toInt
3232
val requestedFirst = (requestedPage - 1) * pageSize
33-
val (apps, actualFirst, totalCount) = parent.getApplicationList(requestedFirst, pageSize)
33+
34+
val allApps = parent.getApplicationList()
35+
val actualFirst = if (requestedFirst < allApps.size) requestedFirst else 0
36+
val apps = allApps.slice(actualFirst, Math.min(pageSize, allApps.size))
37+
3438
val actualPage = (actualFirst / pageSize) + 1
35-
val last = Math.min(actualFirst + pageSize, totalCount) - 1
36-
val pageCount = totalCount / pageSize + (if (totalCount % pageSize > 0) 1 else 0)
39+
val last = Math.min(actualFirst + pageSize, allApps.size) - 1
40+
val pageCount = allApps.size / pageSize + (if (allApps.size % pageSize > 0) 1 else 0)
3741

3842
val appTable = UIUtils.listingTable(appHeader, appRow, apps)
3943
val content =
4044
<div class="row-fluid">
4145
<div class="span12">
4246
{
43-
if (totalCount > 0) {
47+
if (allApps.size > 0) {
4448
<h4>
45-
Showing {actualFirst + 1}-{last + 1} of {totalCount}
49+
Showing {actualFirst + 1}-{last + 1} of {allApps.size}
4650
<span style="float: right">
4751
{if (actualPage > 1) <a href={"/?page=" + (actualPage - 1)}>&lt;</a>}
4852
{if (actualPage < pageCount) <a href={"/?page=" + (actualPage + 1)}>&gt;</a>}

core/src/main/scala/org/apache/spark/deploy/history/HistoryServer.scala

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,11 @@ class HistoryServer(
151151
}
152152

153153
/**
154-
* Returns a list of available applications, in descending order according to their last
155-
* updated time.
154+
* Returns a list of available applications, in descending order according to their end time.
156155
*
157-
* @param offset Starting offset for returned objects.
158-
* @param count Max number of objects to return.
159-
* @return 3-tuple (requested app list, adjusted offset, count of all available apps)
156+
* @return List of all known applications.
160157
*/
161-
def getApplicationList(offset: Int, count: Int) = {
162-
provider.getListing(offset, count)
163-
}
158+
def getApplicationList() = provider.getListing()
164159

165160
}
166161

@@ -272,16 +267,13 @@ private[spark] abstract class ApplicationHistoryProvider {
272267

273268
/**
274269
* This method should return a list of applications available for the history server to
275-
* show. The listing is assumed to be in descending time order.
270+
* show.
276271
*
277-
* An adjusted offset should be returned if the app list has changed and the request
278-
* references an invalid start offset. Otherwise, the provided offset should be returned.
272+
* The listing is assumed to be in descending end time order.
279273
*
280-
* @param offset Starting offset for returned objects.
281-
* @param count Max number of objects to return.
282-
* @return 3-tuple (requested app list, adjusted offset, count of all available apps)
274+
* @return List of all know applications.
283275
*/
284-
def getListing(offset: Int, count: Int): (Seq[ApplicationHistoryInfo], Int, Int)
276+
def getListing(): Seq[ApplicationHistoryInfo]
285277

286278
/**
287279
* This method should return the application information, including a rendered SparkUI.

0 commit comments

Comments
 (0)