Skip to content

Commit 7179495

Browse files
committed
Change Driver page output and add logging
1 parent 880bc27 commit 7179495

File tree

2 files changed

+46
-24
lines changed

2 files changed

+46
-24
lines changed

core/src/main/scala/org/apache/spark/deploy/mesos/MesosClusterDispatcher.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ private [spark] class MesosClusterDispatcher(
185185
}
186186

187187
case DriverStateChanged(driverId, state, exception) => {
188+
logDriverChange(driverId, state, exception)
188189
state match {
189190
case DriverState.ERROR | DriverState.FINISHED | DriverState.KILLED | DriverState.FAILED =>
190191
removeDriver(driverId, state, exception)
@@ -198,6 +199,21 @@ private [spark] class MesosClusterDispatcher(
198199
}
199200
}
200201

202+
def logDriverChange(driverId: String, state: DriverState, exception: Option[Exception]) {
203+
state match {
204+
case DriverState.ERROR =>
205+
logWarning(s"Driver $driverId failed with unrecoverable exception: ${exception.get}")
206+
case DriverState.FAILED =>
207+
logWarning(s"Driver $driverId exited with failure")
208+
case DriverState.FINISHED =>
209+
logInfo(s"Driver $driverId exited successfully")
210+
case DriverState.KILLED =>
211+
logInfo(s"Driver $driverId was killed by user")
212+
case _ =>
213+
logDebug(s"Driver $driverId changed state to $state")
214+
}
215+
}
216+
201217
def removeDriver(driverId: String, state: DriverState, exception: Option[Exception]) {
202218
if (completedDrivers.size >= RETAINED_DRIVERS) {
203219
val toRemove = math.max(RETAINED_DRIVERS / 10, 1)

core/src/main/scala/org/apache/spark/deploy/mesos/ui/DriverOutputPage.scala

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,45 +31,51 @@ class DriverOutputPage(parent: MesosClusterUI) extends WebUIPage("") {
3131
def render(request: HttpServletRequest): Seq[Node] = {
3232
val stateFuture = (dispatcher ? RequestDispatcherState)(timeout).mapTo[DispatcherStateResponse]
3333
val state = Await.result(stateFuture, timeout)
34+
35+
val driverHeaders = Seq("DriverID", "Submit Date", "Start Date", "Logs")
36+
val completedDriverHeaders = driverHeaders ++ Seq("State", "Exception")
37+
val driverTable = UIUtils.listingTable(driverHeaders, driverRow, state.activeDrivers)
38+
val completedDriverTable =
39+
UIUtils.listingTable(completedDriverHeaders, completedDriverRow, state.completedDrivers)
3440
val content =
3541
<div class="row-fluid">
3642
<div class="span12">
37-
<h3>Active drivers</h3>
38-
{state.activeDrivers.map(d => driverContent(d)).flatten}
39-
<h3>Completed drivers</h3>
40-
{state.completedDrivers.map(d => completedDriverContent(d)).flatten}
43+
<h4>Running Drivers</h4>
44+
{driverTable}
45+
<h4>Finished Drivers</h4>
46+
{completedDriverTable}
4147
</div>
4248
</div>;
4349
UIUtils.basicSparkPage(content, "Spark Drivers for Mesos cluster")
4450
}
4551

46-
def driverContent(info: DriverInfo): Seq[Node] = {
47-
<ul class="unstyled">
48-
<li><strong>ID:</strong> {info.id}</li>
49-
<li><strong>Submit Date:</strong> {info.submitDate}</li>
50-
<li><strong>Start Date:</strong> {info.startTime}</li>
51-
<li><strong>Output:</strong>
52+
def driverRow(info: DriverInfo): Seq[Node] = {
53+
<tr>
54+
<td>{info.id}</td>
55+
<td>{info.submitDate}</td>
56+
<td>{info.startTime}</td>
57+
<td>
5258
<a href={"logPage?driverId=%s&logType=stdout"
53-
.format(info.id)}>stdout</a>
59+
.format(info.id)}>stdout</a>,
5460
<a href={"logPage?driverId=%s&logType=stderr"
5561
.format(info.id)}>stderr</a>
56-
</li>
57-
</ul>
62+
</td>
63+
</tr>
5864
}
5965

60-
def completedDriverContent(info: DriverInfo): Seq[Node] = {
61-
<ul class="unstyled">
62-
<li><strong>ID:</strong> {info.id}</li>
63-
<li><strong>Submit Date:</strong> {info.submitDate}</li>
64-
<li><strong>Start Date:</strong> {info.startTime}</li>
65-
<li><strong>Output:</strong>
66+
def completedDriverRow(info: DriverInfo): Seq[Node] = {
67+
<tr>
68+
<td>{info.id}</td>
69+
<td>{info.submitDate}</td>
70+
<td>{info.startTime}</td>
71+
<td>
6672
<a href={"logPage?driverId=%s&logType=stdout"
67-
.format(info.id)}>stdout</a>
73+
.format(info.id)}>stdout</a>,
6874
<a href={"logPage?driverId=%s&logType=stderr"
6975
.format(info.id)}>stderr</a>
70-
</li>
71-
<li><strong>State:</strong>{info.state}</li>
72-
<li><strong>Exception:</strong>{info.exception}</li>
73-
</ul>
76+
</td>
77+
<td>{info.state}</td>
78+
<td>{info.exception}</td>
79+
</tr>
7480
}
7581
}

0 commit comments

Comments
 (0)