Add JSON path to master index page

This commit is contained in:
Patrick Wendell 2013-07-31 09:47:53 -07:00
parent f3cf09491a
commit 89da9d94b3
2 changed files with 9 additions and 1 deletions

View file

@ -25,15 +25,22 @@ import javax.servlet.http.HttpServletRequest
import scala.xml.Node
import spark.deploy.{RequestMasterState, DeployWebUI, MasterState}
import spark.deploy.{JsonProtocol, RequestMasterState, DeployWebUI, MasterState}
import spark.Utils
import spark.ui.UIUtils
import spark.deploy.master.{ApplicationInfo, WorkerInfo}
import net.liftweb.json.JsonAST.JValue
private[spark] class IndexPage(parent: MasterWebUI) {
val master = parent.master
implicit val timeout = parent.timeout
def renderJson(request: HttpServletRequest): JValue = {
val stateFuture = (master ? RequestMasterState)(timeout).mapTo[MasterState]
val state = Await.result(stateFuture, 30 seconds)
JsonProtocol.writeMasterState(state)
}
/** Index view listing applications and executors */
def render(request: HttpServletRequest): Seq[Node] = {
val stateFuture = (master ? RequestMasterState)(timeout).mapTo[MasterState]

View file

@ -61,6 +61,7 @@ class MasterWebUI(val master: ActorRef, requestedPort: Int) extends Logging {
("/static", createStaticHandler(MasterWebUI.STATIC_RESOURCE_DIR)),
("/app/json", (request: HttpServletRequest) => applicationPage.renderJson(request)),
("/app", (request: HttpServletRequest) => applicationPage.render(request)),
("/json", (request: HttpServletRequest) => indexPage.renderJson(request)),
("*", (request: HttpServletRequest) => indexPage.render(request))
)