Skip to content

Commit ffe3e98

Browse files
committed
Adding back in DriverPage.scala
1 parent 630854a commit ffe3e98

File tree

1 file changed

+181
-0
lines changed

1 file changed

+181
-0
lines changed
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.spark.deploy.mesos.ui
19+
20+
import javax.servlet.http.HttpServletRequest
21+
22+
import scala.xml.Node
23+
24+
import org.apache.spark.deploy.Command
25+
import org.apache.spark.deploy.mesos.MesosDriverDescription
26+
import org.apache.spark.scheduler.cluster.mesos.{MesosClusterSubmissionState, MesosClusterRetryState}
27+
import org.apache.spark.ui.{UIUtils, WebUIPage}
28+
29+
30+
private[ui] class DriverPage(parent: MesosClusterUI) extends WebUIPage("driver") {
31+
32+
override def render(request: HttpServletRequest): Seq[Node] = {
33+
// stripXSS is called first to remove suspicious characters used in XSS attacks
34+
val driverId = UIUtils.stripXSS(request.getParameter("id"))
35+
require(driverId != null && driverId.nonEmpty, "Missing id parameter")
36+
37+
val state = parent.scheduler.getDriverState(driverId)
38+
if (state.isEmpty) {
39+
val content =
40+
<div>
41+
<p>Cannot find driver {driverId}</p>
42+
</div>
43+
return UIUtils.basicSparkPage(content, s"Details for Job $driverId")
44+
}
45+
val driverState = state.get
46+
val driverHeaders = Seq("Driver property", "Value")
47+
val schedulerHeaders = Seq("Scheduler property", "Value")
48+
val commandEnvHeaders = Seq("Command environment variable", "Value")
49+
val launchedHeaders = Seq("Launched property", "Value")
50+
val commandHeaders = Seq("Command property", "Value")
51+
val retryHeaders = Seq("Last failed status", "Next retry time", "Retry count")
52+
val driverDescription = Iterable.apply(driverState.description)
53+
val submissionState = Iterable.apply(driverState.submissionState)
54+
val command = Iterable.apply(driverState.description.command)
55+
val schedulerProperties = Iterable.apply(driverState.description.schedulerProperties)
56+
val commandEnv = Iterable.apply(driverState.description.command.environment)
57+
val driverTable =
58+
UIUtils.listingTable(driverHeaders, driverRow, driverDescription)
59+
val commandTable =
60+
UIUtils.listingTable(commandHeaders, commandRow, command)
61+
val commandEnvTable =
62+
UIUtils.listingTable(commandEnvHeaders, propertiesRow, commandEnv)
63+
val schedulerTable =
64+
UIUtils.listingTable(schedulerHeaders, propertiesRow, schedulerProperties)
65+
val launchedTable =
66+
UIUtils.listingTable(launchedHeaders, launchedRow, submissionState)
67+
val retryTable =
68+
UIUtils.listingTable(
69+
retryHeaders, retryRow, Iterable.apply(driverState.description.retryState))
70+
val content =
71+
<p>Driver state information for driver id {driverId}</p>
72+
<a href={UIUtils.prependBaseUri("/")}>Back to Drivers</a>
73+
<div class="row-fluid">
74+
<div class="span12">
75+
<h4>Driver state: {driverState.state}</h4>
76+
<h4>Driver properties</h4>
77+
{driverTable}
78+
<h4>Driver command</h4>
79+
{commandTable}
80+
<h4>Driver command environment</h4>
81+
{commandEnvTable}
82+
<h4>Scheduler properties</h4>
83+
{schedulerTable}
84+
<h4>Launched state</h4>
85+
{launchedTable}
86+
<h4>Retry state</h4>
87+
{retryTable}
88+
</div>
89+
</div>;
90+
91+
UIUtils.basicSparkPage(content, s"Details for Job $driverId")
92+
}
93+
94+
private def launchedRow(submissionState: Option[MesosClusterSubmissionState]): Seq[Node] = {
95+
submissionState.map { state =>
96+
<tr>
97+
<td>Mesos Slave ID</td>
98+
<td>{state.slaveId.getValue}</td>
99+
</tr>
100+
<tr>
101+
<td>Mesos Task ID</td>
102+
<td>{state.taskId.getValue}</td>
103+
</tr>
104+
<tr>
105+
<td>Launch Time</td>
106+
<td>{state.startDate}</td>
107+
</tr>
108+
<tr>
109+
<td>Finish Time</td>
110+
<td>{state.finishDate.map(_.toString).getOrElse("")}</td>
111+
</tr>
112+
<tr>
113+
<td>Last Task Status</td>
114+
<td>{state.mesosTaskStatus.map(_.toString).getOrElse("")}</td>
115+
</tr>
116+
}.getOrElse(Seq[Node]())
117+
}
118+
119+
private def propertiesRow(properties: collection.Map[String, String]): Seq[Node] = {
120+
properties.map { case (k, v) =>
121+
<tr>
122+
<td>{k}</td><td>{v}</td>
123+
</tr>
124+
}.toSeq
125+
}
126+
127+
private def commandRow(command: Command): Seq[Node] = {
128+
<tr>
129+
<td>Main class</td><td>{command.mainClass}</td>
130+
</tr>
131+
<tr>
132+
<td>Arguments</td><td>{command.arguments.mkString(" ")}</td>
133+
</tr>
134+
<tr>
135+
<td>Class path entries</td><td>{command.classPathEntries.mkString(" ")}</td>
136+
</tr>
137+
<tr>
138+
<td>Java options</td><td>{command.javaOpts.mkString((" "))}</td>
139+
</tr>
140+
<tr>
141+
<td>Library path entries</td><td>{command.libraryPathEntries.mkString((" "))}</td>
142+
</tr>
143+
}
144+
145+
private def driverRow(driver: MesosDriverDescription): Seq[Node] = {
146+
<tr>
147+
<td>Name</td><td>{driver.name}</td>
148+
</tr>
149+
<tr>
150+
<td>Id</td><td>{driver.submissionId}</td>
151+
</tr>
152+
<tr>
153+
<td>Cores</td><td>{driver.cores}</td>
154+
</tr>
155+
<tr>
156+
<td>Memory</td><td>{driver.mem}</td>
157+
</tr>
158+
<tr>
159+
<td>Submitted</td><td>{driver.submissionDate}</td>
160+
</tr>
161+
<tr>
162+
<td>Supervise</td><td>{driver.supervise}</td>
163+
</tr>
164+
}
165+
166+
private def retryRow(retryState: Option[MesosClusterRetryState]): Seq[Node] = {
167+
retryState.map { state =>
168+
<tr>
169+
<td>
170+
{state.lastFailureStatus}
171+
</td>
172+
<td>
173+
{state.nextRetry}
174+
</td>
175+
<td>
176+
{state.retries}
177+
</td>
178+
</tr>
179+
}.getOrElse(Seq[Node]())
180+
}
181+
}

0 commit comments

Comments
 (0)