Skip to content

Commit c89bb6e

Browse files
committed
Add table for removed executors in MasterWebUI
1 parent fe47402 commit c89bb6e

File tree

2 files changed

+54
-40
lines changed

2 files changed

+54
-40
lines changed

core/src/main/scala/org/apache/spark/deploy/master/ApplicationInfo.scala

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ private[spark] class ApplicationInfo(
3737

3838
@transient var state: ApplicationState.Value = _
3939
@transient var executors: mutable.HashMap[Int, ExecutorInfo] = _
40+
@transient var removedExecutors: ArrayBuffer[ExecutorInfo] = _
4041
@transient var coresGranted: Int = _
4142
@transient var endTime: Long = _
4243
@transient var appSource: ApplicationSource = _
4344

4445
@transient private var nextExecutorId: Int = _
45-
@transient private var exitedExecutors: ArrayBuffer[ExecutorInfo] = _
4646

4747
init()
4848

@@ -53,7 +53,7 @@ private[spark] class ApplicationInfo(
5353
endTime = -1L
5454
appSource = new ApplicationSource(this)
5555
nextExecutorId = 0
56-
exitedExecutors = new ArrayBuffer[ExecutorInfo]
56+
removedExecutors = new ArrayBuffer[ExecutorInfo]
5757
}
5858

5959
private def newExecutorId(useID: Option[Int] = None): Int = {
@@ -77,16 +77,15 @@ private[spark] class ApplicationInfo(
7777

7878
def removeExecutor(exec: ExecutorInfo) {
7979
if (executors.contains(exec.id)) {
80-
if (exec.state == ExecutorState.EXITED) {
81-
exitedExecutors += executors(exec.id)
82-
}
80+
removedExecutors += executors(exec.id)
8381
executors -= exec.id
8482
coresGranted -= exec.cores
8583
}
8684
}
8785

88-
/** Return the information for all live and exited executors. */
89-
def executorInfo: Seq[ExecutorInfo] = (executors.values ++ exitedExecutors).toSet.toSeq
86+
def exitedExecutors: Seq[ExecutorInfo] = {
87+
removedExecutors.filter(_.state == ExecutorState.EXITED)
88+
}
9089

9190
private val myMaxCores = desc.maxCores.getOrElse(defaultCores)
9291

core/src/main/scala/org/apache/spark/deploy/master/ui/ApplicationPage.scala

Lines changed: 48 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import scala.xml.Node
2525
import akka.pattern.ask
2626
import org.json4s.JValue
2727

28-
import org.apache.spark.deploy.JsonProtocol
28+
import org.apache.spark.deploy.{ExecutorState, JsonProtocol}
2929
import org.apache.spark.deploy.DeployMessages.{MasterStateResponse, RequestMasterState}
3030
import org.apache.spark.deploy.master.ExecutorInfo
3131
import org.apache.spark.ui.{WebUIPage, UIUtils}
@@ -57,43 +57,58 @@ private[spark] class ApplicationPage(parent: MasterWebUI) extends WebUIPage("app
5757
})
5858

5959
val executorHeaders = Seq("ExecutorID", "Worker", "Cores", "Memory", "State", "Logs")
60-
val executors = app.executorInfo
61-
val executorTable = UIUtils.listingTable(executorHeaders, executorRow, executors)
60+
val allExecutors = (app.executors.values ++ app.removedExecutors).toSet.toSeq
61+
val executors = allExecutors.filter { exec =>
62+
!ExecutorState.isFinished(exec.state) || exec.state == ExecutorState.EXITED
63+
}
64+
val removedExecutors = allExecutors.diff(executors)
65+
val executorsTable = UIUtils.listingTable(executorHeaders, executorRow, executors)
66+
val removedExecutorsTable = UIUtils.listingTable(executorHeaders, executorRow, removedExecutors)
6267

6368
val content =
64-
<div class="row-fluid">
65-
<div class="span12">
66-
<ul class="unstyled">
67-
<li><strong>ID:</strong> {app.id}</li>
68-
<li><strong>Name:</strong> {app.desc.name}</li>
69-
<li><strong>User:</strong> {app.desc.user}</li>
70-
<li><strong>Cores:</strong>
71-
{
72-
if (app.desc.maxCores.isEmpty) {
73-
"Unlimited (%s granted)".format(app.coresGranted)
74-
} else {
75-
"%s (%s granted, %s left)".format(
76-
app.desc.maxCores.get, app.coresGranted, app.coresLeft)
77-
}
69+
<div class="row-fluid">
70+
<div class="span12">
71+
<ul class="unstyled">
72+
<li><strong>ID:</strong> {app.id}</li>
73+
<li><strong>Name:</strong> {app.desc.name}</li>
74+
<li><strong>User:</strong> {app.desc.user}</li>
75+
<li><strong>Cores:</strong>
76+
{
77+
if (app.desc.maxCores.isEmpty) {
78+
"Unlimited (%s granted)".format(app.coresGranted)
79+
} else {
80+
"%s (%s granted, %s left)".format(
81+
app.desc.maxCores.get, app.coresGranted, app.coresLeft)
7882
}
79-
</li>
80-
<li>
81-
<strong>Executor Memory:</strong>
82-
{Utils.megabytesToString(app.desc.memoryPerSlave)}
83-
</li>
84-
<li><strong>Submit Date:</strong> {app.submitDate}</li>
85-
<li><strong>State:</strong> {app.state}</li>
86-
<li><strong><a href={app.desc.appUiUrl}>Application Detail UI</a></strong></li>
87-
</ul>
88-
</div>
83+
}
84+
</li>
85+
<li>
86+
<strong>Executor Memory:</strong>
87+
{Utils.megabytesToString(app.desc.memoryPerSlave)}
88+
</li>
89+
<li><strong>Submit Date:</strong> {app.submitDate}</li>
90+
<li><strong>State:</strong> {app.state}</li>
91+
<li><strong><a href={app.desc.appUiUrl}>Application Detail UI</a></strong></li>
92+
</ul>
8993
</div>
94+
</div>
9095

91-
<div class="row-fluid"> <!-- Executors -->
92-
<div class="span12">
93-
<h4> Executor Summary </h4>
94-
{executorTable}
95-
</div>
96-
</div>;
96+
<div class="row-fluid"> <!-- Executors -->
97+
<div class="span12">
98+
<h4> Executor Summary </h4>
99+
{
100+
executorsTable ++
101+
{
102+
if (removedExecutors.nonEmpty) {
103+
<h4> Removed Executors </h4> ++
104+
removedExecutorsTable
105+
} else {
106+
Seq.empty[Node]
107+
}
108+
}
109+
}
110+
</div>
111+
</div>;
97112
UIUtils.basicSparkPage(content, "Application: " + app.desc.name)
98113
}
99114

0 commit comments

Comments
 (0)