Skip to content

Commit e85e9aa

Browse files
committed
Cleanup: Added TimelineViewUtils.scala
1 parent a76e569 commit e85e9aa

File tree

4 files changed

+75
-57
lines changed

4 files changed

+75
-57
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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.ui
19+
20+
import scala.xml.Node
21+
22+
object TimelineViewUtils {
23+
24+
def executorsLegend: Seq[Node] = {
25+
<div class="legend-area"><svg width="200px" height="55px">
26+
<rect x="5px" y="5px" width="20px" height="15px"
27+
rx="2px" ry="2px" stroke="#97B0F8" fill="#D5DDF6"></rect>
28+
<text x="35px" y="17px">Executor Added</text>
29+
<rect x="5px" y="35px" width="20px" height="15px"
30+
rx="2px" ry="2px" stroke="#97B0F8" fill="#EBCA59"></rect>
31+
<text x="35px" y="47px">Executor Removed</text>
32+
</svg></div>
33+
}
34+
35+
def jobsLegend: Seq[Node] = {
36+
<div class="legend-area"><svg width="200px" height="85px">
37+
<rect x="5px" y="5px" width="20px" height="15px"
38+
rx="2px" ry="2px" stroke="#97B0F8" fill="#D5DDF6"></rect>
39+
<text x="35px" y="17px">Succeeded Job</text>
40+
<rect x="5px" y="35px" width="20px" height="15px"
41+
rx="2px" ry="2px" stroke="#97B0F8" fill="#FF5475"></rect>
42+
<text x="35px" y="47px">Failed Job</text>
43+
<rect x="5px" y="65px" width="20px" height="15px"
44+
rx="2px" ry="2px" stroke="#97B0F8" fill="#FDFFCA"></rect>
45+
<text x="35px" y="77px">Running Job</text>
46+
</svg></div>
47+
}
48+
49+
def stagesLegend: Seq[Node] = {
50+
<div class="legend-area"><svg width="200px" height="85px">
51+
<rect x="5px" y="5px" width="20px" height="15px"
52+
rx="2px" ry="2px" stroke="#97B0F8" fill="#D5DDF6"></rect>
53+
<text x="35px" y="17px">Completed Stage </text>
54+
<rect x="5px" y="35px" width="20px" height="15px"
55+
rx="2px" ry="2px" stroke="#97B0F8" fill="#FF5475"></rect>
56+
<text x="35px" y="47px">Failed Stage</text>
57+
<rect x="5px" y="65px" width="20px" height="15px"
58+
rx="2px" ry="2px" stroke="#97B0F8" fill="#FDFFCA"></rect>
59+
<text x="35px" y="77px">Active Stage</text>
60+
</svg></div>
61+
}
62+
63+
def nodesToFlatString(nodes: Seq[Node]): String = {
64+
nodes.toString.filter(_ != '\n')
65+
}
66+
}

core/src/main/scala/org/apache/spark/ui/UIUtils.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,15 @@ private[spark] object UIUtils extends Logging {
161161
type="text/css" />
162162
<link rel="stylesheet" href={prependBaseUri("/static/vis.min.css")}
163163
typ="text/css" />
164-
<link rel="stylesheet" href={prependBaseUri("/static/debug-tools.css")}></link>
164+
<link rel="stylesheet" href={prependBaseUri("/static/timeline-view.css")}></link>
165165
<script src={prependBaseUri("/static/sorttable.js")} ></script>
166166
<script src={prependBaseUri("/static/jquery-1.11.1.min.js")}></script>
167167
<script src={prependBaseUri("/static/vis.min.js")}></script>
168168
<script src={prependBaseUri("/static/bootstrap-tooltip.js")}></script>
169169
<script src={prependBaseUri("/static/initialize-tooltips.js")}></script>
170170
<script src={prependBaseUri("/static/table.js")}></script>
171171
<script src={prependBaseUri("/static/additional-metrics.js")}></script>
172-
<script src={prependBaseUri("/static/debug-tools.js")}></script>
172+
<script src={prependBaseUri("/static/timeline-view.js")}></script>
173173
}
174174

175175
/** Returns a spark page with correctly formatted headers */

core/src/main/scala/org/apache/spark/ui/jobs/AllJobsPage.scala

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ import scala.xml.{Node, NodeSeq, Unparsed}
2222
import java.util.Date
2323
import javax.servlet.http.HttpServletRequest
2424

25-
import org.apache.spark.ui.{WebUIPage, UIUtils}
25+
import org.apache.spark.ui.{UIUtils, WebUIPage}
26+
import org.apache.spark.ui.TimelineViewUtils._
2627
import org.apache.spark.ui.jobs.UIData.JobUIData
2728
import org.apache.spark.JobExecutionStatus
2829

@@ -105,31 +106,6 @@ private[ui] class AllJobsPage(parent: JobsTab) extends WebUIPage("") {
105106
</div>
106107
}
107108

108-
private val executorsLegend: Seq[Node] = {
109-
<div class="legend-area"><svg width="200px" height="55px">
110-
<rect x="5px" y="5px" width="20px" height="15px"
111-
rx="2px" ry="2px" stroke="#97B0F8" fill="#D5DDF6"></rect>
112-
<text x="35px" y="17px">Executor Added</text>
113-
<rect x="5px" y="35px" width="20px" height="15px"
114-
rx="2px" ry="2px" stroke="#97B0F8" fill="#EBCA59"></rect>
115-
<text x="35px" y="47px">Executor Removed</text>
116-
</svg></div>
117-
}
118-
119-
private val jobsLegend: Seq[Node] = {
120-
<div class="legend-area"><svg width="200px" height="85px">
121-
<rect x="5px" y="5px" width="20px" height="15px"
122-
rx="2px" ry="2px" stroke="#97B0F8" fill="#D5DDF6"></rect>
123-
<text x="35px" y="17px">Succeeded Job</text>
124-
<rect x="5px" y="35px" width="20px" height="15px"
125-
rx="2px" ry="2px" stroke="#97B0F8" fill="#FF5475"></rect>
126-
<text x="35px" y="47px">Failed Job</text>
127-
<rect x="5px" y="65px" width="20px" height="15px"
128-
rx="2px" ry="2px" stroke="#97B0F8" fill="#FDFFCA"></rect>
129-
<text x="35px" y="77px">Running Job</text>
130-
</svg></div>
131-
}
132-
133109
def render(request: HttpServletRequest): Seq[Node] = {
134110
listener.synchronized {
135111
val activeJobs = listener.activeJobs.values.toSeq
@@ -196,11 +172,11 @@ private[ui] class AllJobsPage(parent: JobsTab) extends WebUIPage("") {
196172
|[
197173
| {
198174
| 'id': 'executors',
199-
| 'content': '<div>Executors</div>${executorsLegend.toString().filter(_ != '\n')}',
175+
| 'content': '<div>Executors</div>${nodesToFlatString(executorsLegend)}',
200176
| },
201177
| {
202178
| 'id': 'jobs',
203-
| 'content': '<div>Jobs</div>${jobsLegend.toString().filter(_ != '\n')}',
179+
| 'content': '<div>Jobs</div>${nodesToFlatString(jobsLegend)}',
204180
| }
205181
|]
206182
""".stripMargin

core/src/main/scala/org/apache/spark/ui/jobs/JobPage.scala

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import javax.servlet.http.HttpServletRequest
2727
import org.apache.spark.JobExecutionStatus
2828
import org.apache.spark.scheduler.StageInfo
2929
import org.apache.spark.ui.{UIUtils, WebUIPage}
30+
import org.apache.spark.ui.TimelineViewUtils._
3031

3132
/** Page showing statistics and stage list for a given job */
3233
private[ui] class JobPage(parent: JobsTab) extends WebUIPage("job") {
@@ -41,31 +42,6 @@ private[ui] class JobPage(parent: JobsTab) extends WebUIPage("job") {
4142
</div>
4243
}
4344

44-
private val executorsLegend: Seq[Node] = {
45-
<div class="legend-area"><svg width="200px" height="55px">
46-
<rect x="5px" y="5px" width="20px" height="15px"
47-
rx="2px" ry="2px" stroke="#97B0F8" fill="#D5DDF6"></rect>
48-
<text x="35px" y="17px">Executor Added</text>
49-
<rect x="5px" y="35px" width="20px" height="15px"
50-
rx="2px" ry="2px" stroke="#97B0F8" fill="#EBCA59"></rect>
51-
<text x="35px" y="47px">Executor Removed</text>
52-
</svg></div>
53-
}
54-
55-
private val stagesLegend: Seq[Node] = {
56-
<div class="legend-area"><svg width="200px" height="85px">
57-
<rect x="5px" y="5px" width="20px" height="15px"
58-
rx="2px" ry="2px" stroke="#97B0F8" fill="#D5DDF6"></rect>
59-
<text x="35px" y="17px">Completed Stage </text>
60-
<rect x="5px" y="35px" width="20px" height="15px"
61-
rx="2px" ry="2px" stroke="#97B0F8" fill="#FF5475"></rect>
62-
<text x="35px" y="47px">Failed Stage</text>
63-
<rect x="5px" y="65px" width="20px" height="15px"
64-
rx="2px" ry="2px" stroke="#97B0F8" fill="#FDFFCA"></rect>
65-
<text x="35px" y="77px">Active Stage</text>
66-
</svg></div>
67-
}
68-
6945
def render(request: HttpServletRequest): Seq[Node] = {
7046
listener.synchronized {
7147
val parameterId = request.getParameter("id")
@@ -195,11 +171,11 @@ private[ui] class JobPage(parent: JobsTab) extends WebUIPage("job") {
195171
|[
196172
| {
197173
| 'id': 'executors',
198-
| 'content': '<div>Executors</div>${executorsLegend.toString().filter(_ != '\n')}',
174+
| 'content': '<div>Executors</div>${nodesToFlatString(executorsLegend)}',
199175
| },
200176
| {
201177
| 'id': 'stages',
202-
| 'content': '<div>Stages</div>${stagesLegend.toString().filter(_ != '\n')}',
178+
| 'content': '<div>Stages</div>${nodesToFlatString(stagesLegend)}',
203179
| }
204180
|]
205181
""".stripMargin

0 commit comments

Comments
 (0)