aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/src/main/scala/spark/deploy/master/MasterWebUI.scala36
-rw-r--r--core/src/main/scala/spark/deploy/worker/WorkerWebUI.scala16
2 files changed, 25 insertions, 27 deletions
diff --git a/core/src/main/scala/spark/deploy/master/MasterWebUI.scala b/core/src/main/scala/spark/deploy/master/MasterWebUI.scala
index cb94174bcc..f03c0a0229 100644
--- a/core/src/main/scala/spark/deploy/master/MasterWebUI.scala
+++ b/core/src/main/scala/spark/deploy/master/MasterWebUI.scala
@@ -13,25 +13,32 @@ import spark.deploy._
class MasterWebUI(val actorSystem: ActorSystem, master: ActorRef) extends Directives {
val RESOURCE_DIR = "spark/deploy/master/webui"
val STATIC_RESOURCE_DIR = "spark/deploy/static"
-
+
+ implicit val timeout = Timeout(1 seconds)
+
val handler = {
get {
path("") {
completeWith {
- val masterState = getMasterState()
- // Render the HTML
- masterui.html.index.render(masterState)
+ val future = master ? RequestMasterState
+ future.map {
+ masterState => masterui.html.index.render(masterState.asInstanceOf[MasterState])
+ }
}
} ~
path("job") {
parameter("jobId") { jobId =>
completeWith {
- val masterState = getMasterState()
- // A bit ugly an inefficient, but we won't have a number of jobs
- // so large that it will make a significant difference.
- (masterState.activeJobs ::: masterState.completedJobs).find(_.id == jobId) match {
- case Some(job) => masterui.html.job_details.render(job)
- case _ => null
+ val future = master ? RequestMasterState
+ future.map { state =>
+ val masterState = state.asInstanceOf[MasterState]
+
+ // A bit ugly an inefficient, but we won't have a number of jobs
+ // so large that it will make a significant difference.
+ (masterState.activeJobs ::: masterState.completedJobs).find(_.id == jobId) match {
+ case Some(job) => masterui.html.job_details.render(job)
+ case _ => null
+ }
}
}
}
@@ -42,12 +49,5 @@ class MasterWebUI(val actorSystem: ActorSystem, master: ActorRef) extends Direct
getFromResourceDirectory(RESOURCE_DIR)
}
}
-
- // Requests the current state from the Master and waits for the response
- def getMasterState() : MasterState = {
- implicit val timeout = Timeout(1 seconds)
- val future = master ? RequestMasterState
- return Await.result(future, timeout.duration).asInstanceOf[MasterState]
- }
-
+
}
diff --git a/core/src/main/scala/spark/deploy/worker/WorkerWebUI.scala b/core/src/main/scala/spark/deploy/worker/WorkerWebUI.scala
index e66b33c2c2..58a05e1a38 100644
--- a/core/src/main/scala/spark/deploy/worker/WorkerWebUI.scala
+++ b/core/src/main/scala/spark/deploy/worker/WorkerWebUI.scala
@@ -12,12 +12,17 @@ import spark.deploy.{WorkerState, RequestWorkerState}
class WorkerWebUI(val actorSystem: ActorSystem, worker: ActorRef) extends Directives {
val RESOURCE_DIR = "spark/deploy/worker/webui"
val STATIC_RESOURCE_DIR = "spark/deploy/static"
-
+
+ implicit val timeout = Timeout(1 seconds)
+
val handler = {
get {
path("") {
completeWith{
- workerui.html.index(getWorkerState())
+ val future = worker ? RequestWorkerState
+ future.map { workerState =>
+ workerui.html.index(workerState.asInstanceOf[WorkerState])
+ }
}
} ~
path("log") {
@@ -34,11 +39,4 @@ class WorkerWebUI(val actorSystem: ActorSystem, worker: ActorRef) extends Direct
}
}
- // Requests the current state from the Master and waits for the response
- def getWorkerState() : WorkerState = {
- implicit val timeout = Timeout(1 seconds)
- val future = worker ? RequestWorkerState
- return Await.result(future, timeout.duration).asInstanceOf[WorkerState]
- }
-
}