Skip to content

Commit

Permalink
Update based on review comments. Change function to prependBaseUri an…
Browse files Browse the repository at this point in the history
…d fix formatting.
  • Loading branch information
Y.CORP.YAHOO.COM\tgraves committed Sep 3, 2013
1 parent c8cc276 commit 41c1b5b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 24 deletions.
39 changes: 19 additions & 20 deletions core/src/main/scala/org/apache/spark/ui/UIUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,44 +27,43 @@ private[spark] object UIUtils {

// Yarn has to go through a proxy so the base uri is provided and has to be on all links
private[spark] val uiRoot : String = Option(System.getenv("APPLICATION_WEB_PROXY_BASE")).
getOrElse("")
getOrElse("")

def addBaseUri(resource: String = ""): String = {
return uiRoot + resource
}
def prependBaseUri(resource: String = "") = uiRoot + resource

/** Returns a spark page with correctly formatted headers */
def headerSparkPage(content: => Seq[Node], sc: SparkContext, title: String, page: Page.Value)
: Seq[Node] = {
val jobs = page match {
case Stages => <li class="active"><a href={"%s/stages".format(UIUtils.addBaseUri())}>Stages</a></li>
case _ => <li><a href={"%s/stages".format(UIUtils.addBaseUri())}>Stages</a></li>
case Stages => <li class="active"><a href={prependBaseUri("/stages")}>Stages</a></li>
case _ => <li><a href={prependBaseUri("/stages")}>Stages</a></li>
}
val storage = page match {
case Storage => <li class="active"><a href={"%s/storage".format(UIUtils.addBaseUri())}>Storage</a></li>
case _ => <li><a href={"%s/storage".format(UIUtils.addBaseUri())}>Storage</a></li>
case Storage => <li class="active"><a href={prependBaseUri("/storage")}>Storage</a></li>
case _ => <li><a href={prependBaseUri("/storage")}>Storage</a></li>
}
val environment = page match {
case Environment => <li class="active"><a href={"%s/environment".format(UIUtils.addBaseUri())}>Environment</a></li>
case _ => <li><a href={"%s/environment".format(UIUtils.addBaseUri())}>Environment</a></li>
case Environment =>
<li class="active"><a href={prependBaseUri("/environment")}>Environment</a></li>
case _ => <li><a href={prependBaseUri("/environment")}>Environment</a></li>
}
val executors = page match {
case Executors => <li class="active"><a href={"%s/executors".format(UIUtils.addBaseUri())}>Executors</a></li>
case _ => <li><a href={"%s/executors".format(UIUtils.addBaseUri())}>Executors</a></li>
case Executors => <li class="active"><a href={prependBaseUri("/executors")}>Executors</a></li>
case _ => <li><a href={prependBaseUri("/executors")}>Executors</a></li>
}

<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href={"%s/static/bootstrap.min.css".format(UIUtils.addBaseUri())} type="text/css" />
<link rel="stylesheet" href={"%s/static/webui.css".format(UIUtils.addBaseUri())} type="text/css" />
<script src={"%s/static/sorttable.js".format(UIUtils.addBaseUri())} ></script>
<link rel="stylesheet" href={prependBaseUri("/static/bootstrap.min.css")} type="text/css" />
<link rel="stylesheet" href={prependBaseUri("/static/webui.css")} type="text/css" />
<script src={prependBaseUri("/static/sorttable.js")} ></script>
<title>{sc.appName} - {title}</title>
</head>
<body>
<div class="navbar navbar-static-top">
<div class="navbar-inner">
<a href={"%s/".format(UIUtils.addBaseUri())} class="brand"><img src={"%s/static/spark-logo-77x50px-hd.png".format(UIUtils.addBaseUri())} /></a>
<a href={prependBaseUri("/")} class="brand"><img src={prependBaseUri("/static/spark-logo-77x50px-hd.png")} /></a>
<ul class="nav">
{jobs}
{storage}
Expand Down Expand Up @@ -94,17 +93,17 @@ private[spark] object UIUtils {
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href={"%s/static/bootstrap.min.css".format(UIUtils.addBaseUri())} type="text/css" />
<link rel="stylesheet" href={"%s/static/webui.css".format(UIUtils.addBaseUri())} type="text/css" />
<script src={"%s/static/sorttable.js".format(UIUtils.addBaseUri())} ></script>
<link rel="stylesheet" href={prependBaseUri("/static/bootstrap.min.css")} type="text/css" />
<link rel="stylesheet" href={prependBaseUri("/static/webui.css")} type="text/css" />
<script src={prependBaseUri("/static/sorttable.js")} ></script>
<title>{title}</title>
</head>
<body>
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
<h3 style="vertical-align: middle; display: inline-block;">
<img src={"%s/static/spark-logo-77x50px-hd.png".format(UIUtils.addBaseUri())} style="margin-right: 15px;" />
<img src={prependBaseUri("/static/spark-logo-77x50px-hd.png")} style="margin-right: 15px;" />
{title}
</h3>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private[spark] class PoolTable(pools: Seq[Schedulable], listener: JobProgressLis
case None => 0
}
<tr>
<td><a href={"%s/stages/pool?poolname=%s".format(UIUtils.addBaseUri(),p.name)}>{p.name}</a></td>
<td><a href={"%s/stages/pool?poolname=%s".format(UIUtils.prependBaseUri(),p.name)}>{p.name}</a></td>
<td>{p.minShare}</td>
<td>{p.weight}</td>
<td>{activeStages}</td>
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/org/apache/spark/ui/jobs/StageTable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private[spark] class StageTable(val stages: Seq[Stage], val parent: JobProgressU

val poolName = listener.stageToPool.get(s)

val nameLink = <a href={"%s/stages/stage?id=%s".format(UIUtils.addBaseUri(),s.id)}>{s.name}</a>
val nameLink = <a href={"%s/stages/stage?id=%s".format(UIUtils.prependBaseUri(),s.id)}>{s.name}</a>
val description = listener.stageToDescription.get(s)
.map(d => <div><em>{d}</em></div><div>{nameLink}</div>).getOrElse(nameLink)
val finishTime = s.completionTime.getOrElse(System.currentTimeMillis())
Expand All @@ -108,7 +108,7 @@ private[spark] class StageTable(val stages: Seq[Stage], val parent: JobProgressU
<tr>
<td>{s.id}</td>
{if (isFairScheduler) {
<td><a href={"%s/stages/pool?poolname=%s".format(UIUtils.addBaseUri(),poolName.get)}>{poolName.get}</a></td>}
<td><a href={"%s/stages/pool?poolname=%s".format(UIUtils.prependBaseUri(),poolName.get)}>{poolName.get}</a></td>}
}
<td>{description}</td>
<td valign="middle">{submissionTime}</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private[spark] class IndexPage(parent: BlockManagerUI) {
def rddRow(rdd: RDDInfo): Seq[Node] = {
<tr>
<td>
<a href={"%s/storage/rdd?id=%s".format(addBaseUri(),rdd.id)}>
<a href={"%s/storage/rdd?id=%s".format(prependBaseUri(),rdd.id)}>
{rdd.name}
</a>
</td>
Expand Down

0 comments on commit 41c1b5b

Please sign in to comment.