Skip to content

Commit dd077ab

Browse files
guliangliangsrowen
authored andcommitted
[SPARK-5771] Number of Cores in Completed Applications of Standalone Master Web Page always be 0 if sc.stop() is called
In Standalone mode, the number of cores in Completed Applications of the Master Web Page will always be zero, if sc.stop() is called. But the number will always be right, if sc.stop() is not called. The reason maybe: after sc.stop() is called, the function removeExecutor of class ApplicationInfo will be called, thus reduce the variable coresGranted to zero. The variable coresGranted is used to display the number of Cores on the Web Page. Author: guliangliang <[email protected]> Closes #4567 from marsishandsome/Spark5771 and squashes the following commits: 694796e [guliangliang] remove duplicate code a20e390 [guliangliang] change to Cores Using & Requested 0c19c95 [guliangliang] change Cores to Cores (max) cfbd97d [guliangliang] [SPARK-5771] Number of Cores in Completed Applications of Standalone Master Web Page always be 0 if sc.stop() is called
1 parent 5b8480e commit dd077ab

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ private[spark] class ApplicationInfo(
9090
}
9191
}
9292

93-
private val myMaxCores = desc.maxCores.getOrElse(defaultCores)
93+
val requestedCores = desc.maxCores.getOrElse(defaultCores)
9494

95-
def coresLeft: Int = myMaxCores - coresGranted
95+
def coresLeft: Int = requestedCores - coresGranted
9696

9797
private var _retryCount = 0
9898

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

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,16 @@ private[spark] class MasterPage(parent: MasterWebUI) extends WebUIPage("") {
5050
val workers = state.workers.sortBy(_.id)
5151
val workerTable = UIUtils.listingTable(workerHeaders, workerRow, workers)
5252

53-
val appHeaders = Seq("Application ID", "Name", "Cores", "Memory per Node", "Submitted Time",
54-
"User", "State", "Duration")
53+
val activeAppHeaders = Seq("Application ID", "Name", "Cores in Use",
54+
"Cores Requested", "Memory per Node", "Submitted Time", "User", "State", "Duration")
5555
val activeApps = state.activeApps.sortBy(_.startTime).reverse
56-
val activeAppsTable = UIUtils.listingTable(appHeaders, appRow, activeApps)
56+
val activeAppsTable = UIUtils.listingTable(activeAppHeaders, activeAppRow, activeApps)
57+
58+
val completedAppHeaders = Seq("Application ID", "Name", "Cores Requested", "Memory per Node",
59+
"Submitted Time", "User", "State", "Duration")
5760
val completedApps = state.completedApps.sortBy(_.endTime).reverse
58-
val completedAppsTable = UIUtils.listingTable(appHeaders, appRow, completedApps)
61+
val completedAppsTable = UIUtils.listingTable(completedAppHeaders, completeAppRow,
62+
completedApps)
5963

6064
val driverHeaders = Seq("Submission ID", "Submitted Time", "Worker", "State", "Cores",
6165
"Memory", "Main Class")
@@ -162,16 +166,23 @@ private[spark] class MasterPage(parent: MasterWebUI) extends WebUIPage("") {
162166
</tr>
163167
}
164168

165-
private def appRow(app: ApplicationInfo): Seq[Node] = {
169+
private def appRow(app: ApplicationInfo, active: Boolean): Seq[Node] = {
166170
<tr>
167171
<td>
168172
<a href={"app?appId=" + app.id}>{app.id}</a>
169173
</td>
170174
<td>
171175
<a href={app.desc.appUiUrl}>{app.desc.name}</a>
172176
</td>
177+
{
178+
if (active) {
179+
<td>
180+
{app.coresGranted}
181+
</td>
182+
}
183+
}
173184
<td>
174-
{app.coresGranted}
185+
{app.requestedCores}
175186
</td>
176187
<td sorttable_customkey={app.desc.memoryPerSlave.toString}>
177188
{Utils.megabytesToString(app.desc.memoryPerSlave)}
@@ -183,6 +194,14 @@ private[spark] class MasterPage(parent: MasterWebUI) extends WebUIPage("") {
183194
</tr>
184195
}
185196

197+
private def activeAppRow(app: ApplicationInfo): Seq[Node] = {
198+
appRow(app, active = true)
199+
}
200+
201+
private def completeAppRow(app: ApplicationInfo): Seq[Node] = {
202+
appRow(app, active = false)
203+
}
204+
186205
private def driverRow(driver: DriverInfo): Seq[Node] = {
187206
<tr>
188207
<td>{driver.id} </td>

0 commit comments

Comments
 (0)