1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
package spark.deploy.worker.ui
import scala.concurrent.duration._
import scala.concurrent.Await
import akka.pattern.ask
import javax.servlet.http.HttpServletRequest
import net.liftweb.json.JsonAST.JValue
import scala.xml.Node
import spark.deploy.{RequestWorkerState, JsonProtocol, WorkerState}
import spark.deploy.worker.ExecutorRunner
import spark.Utils
import spark.ui.UIUtils
private[spark] class IndexPage(parent: WorkerWebUI) {
val worker = parent.worker
val timeout = parent.timeout
def renderJson(request: HttpServletRequest): JValue = {
val stateFuture = (worker ? RequestWorkerState)(timeout).mapTo[WorkerState]
val workerState = Await.result(stateFuture, 30 seconds)
JsonProtocol.writeWorkerState(workerState)
}
def render(request: HttpServletRequest): Seq[Node] = {
val stateFuture = (worker ? RequestWorkerState)(timeout).mapTo[WorkerState]
val workerState = Await.result(stateFuture, 30 seconds)
val executorHeaders = Seq("ExecutorID", "Cores", "Memory", "Job Details", "Logs")
val runningExecutorTable =
UIUtils.listingTable(executorHeaders, executorRow, workerState.executors)
val finishedExecutorTable =
UIUtils.listingTable(executorHeaders, executorRow, workerState.finishedExecutors)
val content =
<hr />
<div class="row"> <!-- Worker Details -->
<div class="span12">
<ul class="unstyled">
<li><strong>ID:</strong> {workerState.workerId}</li>
<li><strong>
Master URL:</strong> {workerState.masterUrl}
</li>
<li><strong>Cores:</strong> {workerState.cores} ({workerState.coresUsed} Used)</li>
<li><strong>Memory:</strong> {Utils.memoryMegabytesToString(workerState.memory)}
({Utils.memoryMegabytesToString(workerState.memoryUsed)} Used)</li>
</ul>
<p><a href={workerState.masterWebUiUrl}>Back to Master</a></p>
</div>
</div>
<hr/>
<div class="row"> <!-- Running Executors -->
<div class="span12">
<h3> Running Executors {workerState.executors.size} </h3>
<br/>
{runningExecutorTable}
</div>
</div>
<hr/>
<div class="row"> <!-- Finished Executors -->
<div class="span12">
<h3> Finished Executors </h3>
<br/>
{finishedExecutorTable}
</div>
</div>;
UIUtils.basicSparkPage(content, "Spark Worker on %s:%s".format(workerState.host, workerState.port))
}
def executorRow(executor: ExecutorRunner): Seq[Node] = {
<tr>
<td>{executor.execId}</td>
<td>{executor.cores}</td>
<td sorttable_customkey={executor.memory.toString}>
{Utils.memoryMegabytesToString(executor.memory)}
</td>
<td>
<ul class="unstyled">
<li><strong>ID:</strong> {executor.appId}</li>
<li><strong>Name:</strong> {executor.appDesc.name}</li>
<li><strong>User:</strong> {executor.appDesc.user}</li>
</ul>
</td>
<td>
<a href={"log?appId=%s&executorId=%s&logType=stdout"
.format(executor.appId, executor.execId)}>stdout</a>
<a href={"log?appId=%s&executorId=%s&logType=stderr"
.format(executor.appId, executor.execId)}>stderr</a>
</td>
</tr>
}
}
|