Skip to content
Snippets Groups Projects
Commit 7e9f1ed0 authored by Patrick Wendell's avatar Patrick Wendell
Browse files

Some cleanup of styling

parent 3b7ebdee
No related branches found
No related tags found
No related merge requests found
...@@ -41,11 +41,25 @@ private[spark] object JettyUtils extends Logging { ...@@ -41,11 +41,25 @@ private[spark] object JettyUtils extends Logging {
response.setStatus(HttpServletResponse.SC_OK) response.setStatus(HttpServletResponse.SC_OK)
baseRequest.setHandled(true) baseRequest.setHandled(true)
val result = responder(request) val result = responder(request)
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate")
response.getWriter().println(extractFn(result)) response.getWriter().println(extractFn(result))
} }
} }
} }
def createRedirectHandler(newPath: String): Handler = {
new AbstractHandler {
def handle(target: String,
baseRequest: Request,
request: HttpServletRequest,
response: HttpServletResponse) {
response.setStatus(302)
response.setHeader("Location", baseRequest.getRootURL + newPath)
baseRequest.setHandled(true)
}
}
}
/** Creates a handler for serving files from a static directory. */ /** Creates a handler for serving files from a static directory. */
def createStaticHandler(resourceBase: String): ResourceHandler = { def createStaticHandler(resourceBase: String): ResourceHandler = {
val staticHandler = new ResourceHandler val staticHandler = new ResourceHandler
...@@ -66,13 +80,9 @@ private[spark] object JettyUtils extends Logging { ...@@ -66,13 +80,9 @@ private[spark] object JettyUtils extends Logging {
*/ */
def startJettyServer(ip: String, port: Int, handlers: Seq[(String, Handler)]): (Server, Int) = { def startJettyServer(ip: String, port: Int, handlers: Seq[(String, Handler)]): (Server, Int) = {
val handlersToRegister = handlers.map { case(path, handler) => val handlersToRegister = handlers.map { case(path, handler) =>
if (path == "*") { val contextHandler = new ContextHandler(path)
handler contextHandler.setHandler(handler)
} else { contextHandler.asInstanceOf[org.eclipse.jetty.server.Handler]
val contextHandler = new ContextHandler(path)
contextHandler.setHandler(handler)
contextHandler.asInstanceOf[org.eclipse.jetty.server.Handler]
}
} }
val handlerList = new HandlerList val handlerList = new HandlerList
...@@ -99,13 +109,21 @@ object UIUtils { ...@@ -99,13 +109,21 @@ object UIUtils {
/** Returns a page containing the supplied content and the spark web ui headers */ /** Returns a page containing the supplied content and the spark web ui headers */
def headerSparkPage(content: => Seq[Node], sc: SparkContext, title: String): Seq[Node] = { def headerSparkPage(content: => Seq[Node], sc: SparkContext, title: String): Seq[Node] = {
val newContent = val newContent =
<div class="row"> <div class="row" style="padding-top: 5px;">
<div class="span12"> <div class="span2">
<div style="padding-left: 10px">
<ul class="unstyled">
<li><a href="/storage">Storage</a></li>
<li><a href="/jobs">Jobs</a></li>
</ul>
</div>
</div>
<div class="span10">
<ul class="unstyled"> <ul class="unstyled">
<li><strong>Master:</strong> {sc.master}</li> <li><strong>Master:</strong> {sc.master}</li>
<li><strong>Application:</strong> {sc.appName}</li> <li><strong>Application:</strong> {sc.appName}</li>
<li><strong>Executors:</strong> {sc.getExecutorStorageStatus.size} </li>
</ul> </ul>
<h3><a href="/storage">Storage</a> | <a href="/stages">Jobs</a> </h3>
</div> </div>
</div> </div>
<hr/>; <hr/>;
...@@ -128,10 +146,11 @@ object UIUtils { ...@@ -128,10 +146,11 @@ object UIUtils {
<body> <body>
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="span12"> <div class="span2">
<img src="/static/spark_logo.png" /> <img src="/static/spark_logo.png" />
<h1 style="vertical-align: bottom; margin-bottom: 10px; </div>
margin-left: 30px; display: inline-block;"> <div class="span10">
<h1 style="vertical-align: bottom; margin-top: 40px; display: inline-block;">
{title} {title}
</h1> </h1>
</div> </div>
......
...@@ -12,13 +12,15 @@ import spark.ui.JettyUtils._ ...@@ -12,13 +12,15 @@ import spark.ui.JettyUtils._
/** Top level user interface for Spark */ /** Top level user interface for Spark */
private[spark] class SparkUI(sc: SparkContext) extends Logging { private[spark] class SparkUI(sc: SparkContext) extends Logging {
// TODO(pwendell): It would be nice to add a view that prints out environment information
val host = Utils.localHostName() val host = Utils.localHostName()
val port = Option(System.getProperty("spark.ui.port")).getOrElse(SparkUI.DEFAULT_PORT).toInt val port = Option(System.getProperty("spark.ui.port")).getOrElse(SparkUI.DEFAULT_PORT).toInt
var boundPort: Option[Int] = None var boundPort: Option[Int] = None
val handlers = Seq[(String, Handler)]( val handlers = Seq[(String, Handler)](
("/static", createStaticHandler(SparkUI.STATIC_RESOURCE_DIR)), ("/static", createStaticHandler(SparkUI.STATIC_RESOURCE_DIR)),
("*", (request: HttpServletRequest) => headerSparkPage(<h1>Test</h1>, sc, "Test page")) ("/", createRedirectHandler("/stages"))
) )
val storage = new BlockManagerUI(sc) val storage = new BlockManagerUI(sc)
val jobs = new JobProgressUI(sc) val jobs = new JobProgressUI(sc)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment