Skip to content

Commit

Permalink
Move app name to app info, more UI fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcelo Vanzin committed Apr 9, 2015
1 parent ce5ee5d commit c3e0a82
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import org.apache.spark.ui.SparkUI

private[history] case class ApplicationAttemptInfo(
attemptId: String,
name: String,
startTime: Long,
endTime: Long,
lastUpdated: Long,
Expand All @@ -30,6 +29,7 @@ private[history] case class ApplicationAttemptInfo(

private[history] case class ApplicationHistoryInfo(
id: String,
name: String,
attempts: List[ApplicationAttemptInfo])

private[history] abstract class ApplicationHistoryProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ private[history] class FsHistoryProvider(conf: SparkConf) extends ApplicationHis

override def getAppUI(appId: String, attemptId: String): Option[SparkUI] = {
try {
applications.get(appId).flatMap { info =>
val attempts = info.attempts.filter(_.attemptId == attemptId)
applications.get(appId).flatMap { appInfo =>
val attempts = appInfo.attempts.filter(_.attemptId == attemptId)
attempts.headOption.map { attempt =>
val replayBus = new ReplayListenerBus()
val ui = {
Expand All @@ -161,7 +161,7 @@ private[history] class FsHistoryProvider(conf: SparkConf) extends ApplicationHis
replayBus.addListener(appListener)
val appInfo = replay(fs.getFileStatus(new Path(logDir, attempt.logPath)), replayBus)

ui.setAppName(s"${attempt.name} ($appId)")
ui.setAppName(s"${appInfo.name} ($appId)")

val uiAclsEnabled = conf.getBoolean("spark.history.ui.acls.enable", false)
ui.getSecurityManager.setAcls(uiAclsEnabled)
Expand Down Expand Up @@ -256,9 +256,10 @@ private[history] class FsHistoryProvider(conf: SparkConf) extends ApplicationHis
.map { app =>
val attempts =
app.attempts.filter(_.attemptId != attempt.attemptId).toList ++ List(attempt)
new FsApplicationHistoryInfo(attempt.appId, attempts.sortWith(compareAttemptInfo))
new FsApplicationHistoryInfo(attempt.appId, attempt.name,
attempts.sortWith(compareAttemptInfo))
}
.getOrElse(new FsApplicationHistoryInfo(attempt.appId, List(attempt)))
.getOrElse(new FsApplicationHistoryInfo(attempt.appId, attempt.name, List(attempt)))
newAppMap(attempt.appId) = appInfo
}

Expand Down Expand Up @@ -363,9 +364,9 @@ private[history] class FsHistoryProvider(conf: SparkConf) extends ApplicationHis
bus.replay(logInput, logPath.toString)
new FsApplicationAttemptInfo(
logPath.getName(),
appListener.appName.getOrElse(NOT_STARTED),
appListener.appId.getOrElse(logPath.getName()),
appListener.appAttemptId.getOrElse(""),
appListener.appName.getOrElse(NOT_STARTED),
appListener.startTime.getOrElse(-1L),
appListener.endTime.getOrElse(-1L),
getModificationTime(eventLog).get,
Expand Down Expand Up @@ -459,18 +460,19 @@ private object FsHistoryProvider {

private class FsApplicationAttemptInfo(
val logPath: String,
val name: String,
val appId: String,
attemptId: String,
name: String,
startTime: Long,
endTime: Long,
lastUpdated: Long,
sparkUser: String,
completed: Boolean = true)
extends ApplicationAttemptInfo(
attemptId, name, startTime, endTime, lastUpdated, sparkUser, completed)
attemptId, startTime, endTime, lastUpdated, sparkUser, completed)

private class FsApplicationHistoryInfo(
id: String,
override val name: String,
override val attempts: List[FsApplicationAttemptInfo])
extends ApplicationHistoryInfo(id, attempts)
extends ApplicationHistoryInfo(id, name, attempts)
Original file line number Diff line number Diff line change
Expand Up @@ -164,26 +164,25 @@ private[history] class HistoryPage(parent: HistoryServer) extends WebUIPage("")
info: ApplicationHistoryInfo,
attempt: ApplicationAttemptInfo,
isFirst: Boolean): Seq[Node] = {
val attemptInfo = info.attempts.head
val uiAddress = HistoryServer.UI_PATH_PREFIX + s"/${info.id}"
val startTime = UIUtils.formatDate(attemptInfo.startTime)
val endTime = if (attemptInfo.endTime > 0) UIUtils.formatDate(attemptInfo.endTime) else "-"
val uiAddress = getAttemptURI(info.id, attempt)
val startTime = UIUtils.formatDate(attempt.startTime)
val endTime = if (attempt.endTime > 0) UIUtils.formatDate(attempt.endTime) else "-"
val duration =
if (attemptInfo.endTime > 0) {
UIUtils.formatDuration(attemptInfo.endTime - attemptInfo.startTime)
if (attempt.endTime > 0) {
UIUtils.formatDuration(attempt.endTime - attempt.startTime)
} else {
"-"
}
val lastUpdated = UIUtils.formatDate(attemptInfo.lastUpdated)
val lastUpdated = UIUtils.formatDate(attempt.lastUpdated)
<tr>
{
if (isFirst) {
if (info.attempts.size > 1) {
<td rowspan={info.attempts.size.toString}><a href={uiAddress}>{info.id}</a></td> ++
<td rowspan={info.attempts.size.toString}>{attempt.name}</td>
<td rowspan={info.attempts.size.toString}>{info.name}</td>
} else {
<td><a href={uiAddress}>{info.id}</a></td> ++
<td>{attempt.name}</td>
<td>{info.name}</td>
}
} else {
Nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ class FsHistoryProviderSuite extends FunSuite with BeforeAndAfter with Matchers

def makeAppInfo(id: String, name: String, start: Long, end: Long, lastMod: Long,
user: String, completed: Boolean): ApplicationHistoryInfo = {
ApplicationHistoryInfo(id,
List(ApplicationAttemptInfo("", name, start, end, lastMod, user, completed)))
ApplicationHistoryInfo(id, name,
List(ApplicationAttemptInfo("", start, end, lastMod, user, completed)))
}

list(0) should be (makeAppInfo(newAppComplete.getName(), "new-app-complete", 1L, 5L,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class HistoryServerSuite extends FunSuite with Matchers with MockitoSugar {
val request = mock[HttpServletRequest]
val ui = mock[SparkUI]
val link = "/history/app1"
val info = new ApplicationHistoryInfo("app1",
List(ApplicationAttemptInfo("attempt1", "app1", 0, 2, 1, "xxx", true)))
val info = new ApplicationHistoryInfo("app1", "app1",
List(ApplicationAttemptInfo("attempt1", 0, 2, 1, "xxx", true)))
when(historyServer.getApplicationList()).thenReturn(Seq(info))
when(ui.basePath).thenReturn(link)
when(historyServer.getProviderConfig()).thenReturn(Map[String, String]())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class ReplayListenerSuite extends FunSuite with BeforeAndAfter {
* log the events.
*/
private class EventMonster(conf: SparkConf)
extends EventLoggingListener("test", new URI("testdir"), conf) {
extends EventLoggingListener("test", "", new URI("testdir"), conf) {

override def start() { }

Expand Down

0 comments on commit c3e0a82

Please sign in to comment.