diff options
author | Patrick Wendell <pwendell@gmail.com> | 2013-07-01 14:40:53 -0700 |
---|---|---|
committer | Patrick Wendell <pwendell@gmail.com> | 2013-07-01 14:40:53 -0700 |
commit | 1025d7d1efb20e3683a604259c92eeef400cc3fa (patch) | |
tree | 29c7b4ddd9e692b64692781f62de50148a79f938 | |
parent | 30b90342410a196d99d25113fbc1e37ce2a8200f (diff) | |
download | spark-1025d7d1efb20e3683a604259c92eeef400cc3fa.tar.gz spark-1025d7d1efb20e3683a604259c92eeef400cc3fa.tar.bz2 spark-1025d7d1efb20e3683a604259c92eeef400cc3fa.zip |
Package refactoring
-rw-r--r-- | core/src/main/scala/spark/ui/JettyUtils.scala | 116 | ||||
-rw-r--r-- | core/src/main/scala/spark/ui/Page.scala | 3 | ||||
-rw-r--r-- | core/src/main/scala/spark/ui/UIUtils.scala | 113 |
3 files changed, 118 insertions, 114 deletions
diff --git a/core/src/main/scala/spark/ui/JettyUtils.scala b/core/src/main/scala/spark/ui/JettyUtils.scala index 9e4b884379..57f85bafd2 100644 --- a/core/src/main/scala/spark/ui/JettyUtils.scala +++ b/core/src/main/scala/spark/ui/JettyUtils.scala @@ -8,13 +8,12 @@ import net.liftweb.json.{JValue, pretty, render} import org.eclipse.jetty.server.{Server, Request, Handler} import org.eclipse.jetty.server.handler.{ResourceHandler, HandlerList, ContextHandler, AbstractHandler} +import org.eclipse.jetty.util.thread.QueuedThreadPool import scala.util.{Try, Success, Failure} import scala.xml.Node -import spark.{SparkContext, Logging} -import org.eclipse.jetty.util.log.Log -import org.eclipse.jetty.util.thread.QueuedThreadPool +import spark.Logging /** Utilities for launching a web server using Jetty's HTTP Server class */ private[spark] object JettyUtils extends Logging { @@ -111,117 +110,6 @@ private[spark] object JettyUtils extends Logging { } } - connect(port) } } - -object Page extends Enumeration { val Storage, Jobs = Value } - -/** Utility functions for generating XML pages with spark content. */ -private[spark] object UIUtils { - import Page._ - - /** Returns a spark page with correctly formatted headers */ - def headerSparkPage(content: => Seq[Node], sc: SparkContext, title: String, page: Page.Value) - : Seq[Node] = { - val storage = page match { - case Storage => <li class="active"><a href="/storage">Storage</a></li> - case _ => <li><a href="/storage">Storage</a></li> - } - val jobs = page match { - case Jobs => <li class="active"><a href="/stages">Jobs</a></li> - case _ => <li><a href="/stages">Jobs</a></li> - } - - <html> - <head> - <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> - <link rel="stylesheet" href="/static/bootstrap.min.css" type="text/css" /> - <link rel="stylesheet" href="/static/webui.css" type="text/css" /> - <link rel="stylesheet" href="/static/bootstrap-responsive.min.css" type="text/css" /> - <script src="/static/sorttable.js"></script> - <title>{title}</title> - <style type="text/css"> - table.sortable thead {{ cursor: pointer; }} - </style> - </head> - <body> - <div class="container"> - - <div class="row"> - <div class="span12"> - <div class="navbar"> - <div class="navbar-inner"> - <div class="container"> - <div class="brand"><img src="/static/spark-logo-77x50px-hd.png" /></div> - <ul class="nav"> - {storage} - {jobs} - </ul> - <ul id="infolist"> - <li>Application: <strong>{sc.appName}</strong></li> - <li>Master: <strong>{sc.master}</strong></li> - <li>Executors: <strong>{sc.getExecutorStorageStatus.size}</strong></li> - </ul> - </div> - </div> - </div> - </div> - </div> - - <div class="row" style="padding-top: 5px;"> - <div class="span12"> - <h1 style="vertical-align: bottom; display: inline-block;"> - {title} - </h1> - </div> - </div> - <hr/> - {content} - </div> - </body> - </html> - } - - /** Returns a page with the spark css/js and a simple format. Used for scheduler UI. */ - def basicSparkPage(content: => Seq[Node], title: String): Seq[Node] = { - <html> - <head> - <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> - <link rel="stylesheet" href="/static/bootstrap.min.css" type="text/css" /> - <link rel="stylesheet" href="/static/bootstrap-responsive.min.css" type="text/css" /> - <script src="/static/sorttable.js"></script> - <title>{title}</title> - <style type="text/css"> - table.sortable thead {{ cursor: pointer; }} - </style> - </head> - <body> - <div class="container"> - <div class="row"> - <div class="span2"> - <img src="/static/spark_logo.png" /> - </div> - <div class="span10"> - <h1 style="vertical-align: bottom; margin-top: 40px; display: inline-block;"> - {title} - </h1> - </div> - </div> - {content} - </div> - </body> - </html> - } - - /** Returns an HTML table constructed by generating a row for each object in a sequence. */ - def listingTable[T](headers: Seq[String], makeRow: T => Seq[Node], rows: Seq[T]): Seq[Node] = { - <table class="table table-bordered table-striped table-condensed sortable"> - <thead>{headers.map(h => <th>{h}</th>)}</thead> - <tbody> - {rows.map(r => makeRow(r))} - </tbody> - </table> - } -} diff --git a/core/src/main/scala/spark/ui/Page.scala b/core/src/main/scala/spark/ui/Page.scala new file mode 100644 index 0000000000..c853b44b76 --- /dev/null +++ b/core/src/main/scala/spark/ui/Page.scala @@ -0,0 +1,3 @@ +package spark.ui + +private[spark] object Page extends Enumeration { val Storage, Jobs = Value }
\ No newline at end of file diff --git a/core/src/main/scala/spark/ui/UIUtils.scala b/core/src/main/scala/spark/ui/UIUtils.scala new file mode 100644 index 0000000000..7b79290d1b --- /dev/null +++ b/core/src/main/scala/spark/ui/UIUtils.scala @@ -0,0 +1,113 @@ +package spark.ui + +import scala.xml.Node + +import spark.SparkContext + +/** Utility functions for generating XML pages with spark content. */ +private[spark] object UIUtils { + import Page._ + + /** Returns a spark page with correctly formatted headers */ + def headerSparkPage(content: => Seq[Node], sc: SparkContext, title: String, page: Page.Value) + : Seq[Node] = { + val storage = page match { + case Storage => <li class="active"><a href="/storage">Storage</a></li> + case _ => <li><a href="/storage">Storage</a></li> + } + val jobs = page match { + case Jobs => <li class="active"><a href="/stages">Jobs</a></li> + case _ => <li><a href="/stages">Jobs</a></li> + } + + <html> + <head> + <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> + <link rel="stylesheet" href="/static/bootstrap.min.css" type="text/css" /> + <link rel="stylesheet" href="/static/webui.css" type="text/css" /> + <link rel="stylesheet" href="/static/bootstrap-responsive.min.css" type="text/css" /> + <script src="/static/sorttable.js"></script> + <title>{title}</title> + <style type="text/css"> + table.sortable thead {{ cursor: pointer; }} + </style> + </head> + <body> + <div class="container"> + + <div class="row"> + <div class="span12"> + <div class="navbar"> + <div class="navbar-inner"> + <div class="container"> + <div class="brand"><img src="/static/spark-logo-77x50px-hd.png" /></div> + <ul class="nav"> + {storage} + {jobs} + </ul> + <ul id="infolist"> + <li>Application: <strong>{sc.appName}</strong></li> + <li>Master: <strong>{sc.master}</strong></li> + <li>Executors: <strong>{sc.getExecutorStorageStatus.size}</strong></li> + </ul> + </div> + </div> + </div> + </div> + </div> + + <div class="row" style="padding-top: 5px;"> + <div class="span12"> + <h1 style="vertical-align: bottom; display: inline-block;"> + {title} + </h1> + </div> + </div> + <hr/> + {content} + </div> + </body> + </html> + } + + /** Returns a page with the spark css/js and a simple format. Used for scheduler UI. */ + def basicSparkPage(content: => Seq[Node], title: String): Seq[Node] = { + <html> + <head> + <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> + <link rel="stylesheet" href="/static/bootstrap.min.css" type="text/css" /> + <link rel="stylesheet" href="/static/bootstrap-responsive.min.css" type="text/css" /> + <script src="/static/sorttable.js"></script> + <title>{title}</title> + <style type="text/css"> + table.sortable thead {{ cursor: pointer; }} + </style> + </head> + <body> + <div class="container"> + <div class="row"> + <div class="span2"> + <img src="/static/spark_logo.png" /> + </div> + <div class="span10"> + <h1 style="vertical-align: bottom; margin-top: 40px; display: inline-block;"> + {title} + </h1> + </div> + </div> + {content} + </div> + </body> + </html> + } + + /** Returns an HTML table constructed by generating a row for each object in a sequence. */ + def listingTable[T](headers: Seq[String], makeRow: T => Seq[Node], rows: Seq[T]): Seq[Node] = { + <table class="table table-bordered table-striped table-condensed sortable"> + <thead>{headers.map(h => <th>{h}</th>)}</thead> + <tbody> + {rows.map(r => makeRow(r))} + </tbody> + </table> + } +}
\ No newline at end of file |