Skip to content

Commit ab65fa1

Browse files
committed
History Server: some attempt completed to work with showIncomplete
1 parent 0be142d commit ab65fa1

File tree

1 file changed

+39
-16
lines changed

1 file changed

+39
-16
lines changed

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

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ private[history] class HistoryPage(parent: HistoryServer) extends WebUIPage("")
3535
Option(request.getParameter("showIncomplete")).getOrElse("false").toBoolean
3636

3737
val allApps = parent.getApplicationList()
38-
.filter(_.attempts.head.completed != requestedIncomplete)
3938
val allAppsSize = allApps.size
4039

4140
val actualFirst = if (requestedFirst < allAppsSize) requestedFirst else 0
@@ -51,9 +50,15 @@ private[history] class HistoryPage(parent: HistoryServer) extends WebUIPage("")
5150
val hasMultipleAttempts = appsToShow.exists(_.attempts.size > 1)
5251
val appTable =
5352
if (hasMultipleAttempts) {
54-
UIUtils.listingTable(appWithAttemptHeader, appWithAttemptRow, appsToShow)
53+
UIUtils.listingTable(
54+
appWithAttemptHeader,
55+
appWithAttemptRow(_, requestedIncomplete),
56+
appsToShow)
5557
} else {
56-
UIUtils.listingTable(appHeader, appRow, appsToShow)
58+
UIUtils.listingTable(
59+
appHeader,
60+
appRow(_, requestedIncomplete),
61+
appsToShow)
5762
}
5863

5964
val providerConfig = parent.getProviderConfig()
@@ -157,7 +162,8 @@ private[history] class HistoryPage(parent: HistoryServer) extends WebUIPage("")
157162
renderAttemptIdColumn: Boolean,
158163
info: ApplicationHistoryInfo,
159164
attempt: ApplicationAttemptInfo,
160-
isFirst: Boolean): Seq[Node] = {
165+
isFirst: Boolean,
166+
requestedIncomplete: Boolean): Seq[Node] = {
161167
val uiAddress = HistoryServer.getAttemptURI(info.id, attempt.attemptId)
162168
val startTime = UIUtils.formatDate(attempt.startTime)
163169
val endTime = if (attempt.endTime > 0) UIUtils.formatDate(attempt.endTime) else "-"
@@ -168,6 +174,10 @@ private[history] class HistoryPage(parent: HistoryServer) extends WebUIPage("")
168174
"-"
169175
}
170176
val lastUpdated = UIUtils.formatDate(attempt.lastUpdated)
177+
var someAttemptCompleted = false
178+
info.attempts.foreach{ attempt =>
179+
if (attempt.completed) someAttemptCompleted = true
180+
}
171181
<tr>
172182
{
173183
if (isFirst) {
@@ -185,7 +195,8 @@ private[history] class HistoryPage(parent: HistoryServer) extends WebUIPage("")
185195
}
186196
}
187197
{
188-
if (renderAttemptIdColumn) {
198+
if (renderAttemptIdColumn &&
199+
(requestedIncomplete || (!requestedIncomplete && someAttemptCompleted))) {
189200
if (info.attempts.size > 1 && attempt.attemptId.isDefined) {
190201
<td><a href={HistoryServer.getAttemptURI(info.id, attempt.attemptId)}>
191202
{attempt.attemptId.get}</a></td>
@@ -196,22 +207,34 @@ private[history] class HistoryPage(parent: HistoryServer) extends WebUIPage("")
196207
Nil
197208
}
198209
}
199-
<td sorttable_customkey={attempt.startTime.toString}>{startTime}</td>
200-
<td sorttable_customkey={attempt.endTime.toString}>{endTime}</td>
201-
<td sorttable_customkey={(attempt.endTime - attempt.startTime).toString}>
202-
{duration}</td>
203-
<td>{attempt.sparkUser}</td>
204-
<td sorttable_customkey={attempt.lastUpdated.toString}>{lastUpdated}</td>
210+
{
211+
if (requestedIncomplete || (!requestedIncomplete && someAttemptCompleted)) {
212+
<td sorttable_customkey={attempt.startTime.toString}>{startTime}</td>
213+
<td sorttable_customkey={attempt.endTime.toString}>{endTime}</td>
214+
<td sorttable_customkey={(attempt.endTime - attempt.startTime).toString}>
215+
{duration}</td>
216+
<td>{attempt.sparkUser}</td>
217+
<td sorttable_customkey={attempt.lastUpdated.toString}>{lastUpdated}</td>
218+
} else {
219+
Nil
220+
}
221+
}
205222
</tr>
206223
}
207224

208-
private def appRow(info: ApplicationHistoryInfo): Seq[Node] = {
209-
attemptRow(false, info, info.attempts.head, true)
225+
226+
227+
private def appRow(
228+
info: ApplicationHistoryInfo,
229+
requestedIncomplete: Boolean): Seq[Node] = {
230+
attemptRow(false, info, info.attempts.head, true, requestedIncomplete)
210231
}
211232

212-
private def appWithAttemptRow(info: ApplicationHistoryInfo): Seq[Node] = {
213-
attemptRow(true, info, info.attempts.head, true) ++
214-
info.attempts.drop(1).flatMap(attemptRow(true, info, _, false))
233+
private def appWithAttemptRow(
234+
info: ApplicationHistoryInfo,
235+
requestedIncomplete: Boolean): Seq[Node] = {
236+
attemptRow(true, info, info.attempts.head, true, requestedIncomplete) ++
237+
info.attempts.drop(1).flatMap(attemptRow(true, info, _, false, requestedIncomplete))
215238
}
216239

217240
private def makePageLink(linkPage: Int, showIncomplete: Boolean): String = {

0 commit comments

Comments
 (0)