Skip to content

Commit 83306a8

Browse files
committed
History Server: updated order for multiple attempts(descending start time)
1 parent b0fc922 commit 83306a8

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,8 @@ private[history] class FsHistoryProvider(conf: SparkConf, clock: Clock)
413413

414414
/**
415415
* Comparison function that defines the sort order for application attempts within the same
416-
* application. Order is: completed attempts before running attempts, running attempts sorted
417-
* by ascending start time,completed attempts sorted by ascending end time.
416+
* application. Order is: completed attempts before running attempts, if both completed
417+
* or both running attempts sorted by descending start time.
418418
*
419419
* Normally applications should have a single running attempt; but failure to call sc.stop()
420420
* may cause multiple running attempts to show up.
@@ -425,7 +425,7 @@ private[history] class FsHistoryProvider(conf: SparkConf, clock: Clock)
425425
a1: FsApplicationAttemptInfo,
426426
a2: FsApplicationAttemptInfo): Boolean = {
427427
if (a1.completed == a2.completed) {
428-
if (a1.completed) a1.endTime <= a2.endTime else a1.startTime <= a2.startTime
428+
a1.startTime >= a2.startTime
429429
} else {
430430
a1.completed
431431
}

core/src/test/scala/org/apache/spark/deploy/history/FsHistoryProviderSuite.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ class FsHistoryProviderSuite extends SparkFunSuite with BeforeAndAfter with Matc
272272
updateAndCheck(provider) { list =>
273273
list.size should be (1)
274274
list.head.attempts.size should be (2)
275-
list.head.attempts.head.attemptId should be (Some("attempt1"))
275+
list.head.attempts.head.attemptId should be (Some("attempt2"))
276276
}
277277

278278
val attempt3 = newLogFile("app1", Some("attempt3"), inProgress = false)
@@ -289,7 +289,7 @@ class FsHistoryProviderSuite extends SparkFunSuite with BeforeAndAfter with Matc
289289
}
290290

291291
val app2Attempt1 = newLogFile("app2", Some("attempt1"), inProgress = false)
292-
writeFile(attempt2, true, None,
292+
writeFile(attempt1, true, None,
293293
SparkListenerApplicationStart("app2", Some("app2"), 5L, "test", Some("attempt1")),
294294
SparkListenerApplicationEnd(6L)
295295
)

0 commit comments

Comments
 (0)