You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by an...@apache.org on 2015/05/15 08:51:47 UTC
spark git commit: [SPARK-7650] [STREAMING] [WEBUI] Move streaming css
and js files to the streaming project
Repository: spark
Updated Branches:
refs/heads/master daf4ae72f -> cf842d42a
[SPARK-7650] [STREAMING] [WEBUI] Move streaming css and js files to the streaming project
cc tdas
Author: zsxwing <zs...@gmail.com>
Closes #6160 from zsxwing/SPARK-7650 and squashes the following commits:
fe6ae15 [zsxwing] Fix the import order
a4ffd99 [zsxwing] Merge branch 'master' into SPARK-7650
dc402b6 [zsxwing] Move streaming css and js files to the streaming project
Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/cf842d42
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/cf842d42
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/cf842d42
Branch: refs/heads/master
Commit: cf842d42a70398671c4bc5ebfa70f6fdb8c57c7f
Parents: daf4ae7
Author: zsxwing <zs...@gmail.com>
Authored: Thu May 14 23:51:41 2015 -0700
Committer: Andrew Or <an...@databricks.com>
Committed: Thu May 14 23:51:41 2015 -0700
----------------------------------------------------------------------
.../apache/spark/ui/static/streaming-page.css | 62 ----
.../apache/spark/ui/static/streaming-page.js | 281 -------------------
.../main/scala/org/apache/spark/ui/WebUI.scala | 2 +-
.../streaming/ui/static/streaming-page.css | 62 ++++
.../spark/streaming/ui/static/streaming-page.js | 281 +++++++++++++++++++
.../spark/streaming/ui/StreamingPage.scala | 4 +-
.../spark/streaming/ui/StreamingTab.scala | 12 +-
7 files changed, 357 insertions(+), 347 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/spark/blob/cf842d42/core/src/main/resources/org/apache/spark/ui/static/streaming-page.css
----------------------------------------------------------------------
diff --git a/core/src/main/resources/org/apache/spark/ui/static/streaming-page.css b/core/src/main/resources/org/apache/spark/ui/static/streaming-page.css
deleted file mode 100644
index 19abe88..0000000
--- a/core/src/main/resources/org/apache/spark/ui/static/streaming-page.css
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-.graph {
- font: 10px sans-serif;
-}
-
-.axis path, .axis line {
- fill: none;
- stroke: gray;
- shape-rendering: crispEdges;
-}
-
-.axis text {
- fill: gray;
-}
-
-.tooltip-inner {
- max-width: 500px !important; // Make sure we only have one line tooltip
-}
-
-.line {
- fill: none;
- stroke: #0088cc;
- stroke-width: 1.5px;
-}
-
-.bar rect {
- fill: #0088cc;
- shape-rendering: crispEdges;
-}
-
-.bar rect:hover {
- fill: #00c2ff;
-}
-
-.timeline {
- width: 500px;
-}
-
-.histogram {
- width: auto;
-}
-
-span.expand-input-rate {
- cursor: pointer;
-}
http://git-wip-us.apache.org/repos/asf/spark/blob/cf842d42/core/src/main/resources/org/apache/spark/ui/static/streaming-page.js
----------------------------------------------------------------------
diff --git a/core/src/main/resources/org/apache/spark/ui/static/streaming-page.js b/core/src/main/resources/org/apache/spark/ui/static/streaming-page.js
deleted file mode 100644
index 0ee6752..0000000
--- a/core/src/main/resources/org/apache/spark/ui/static/streaming-page.js
+++ /dev/null
@@ -1,281 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-// timeFormat: StreamingPage.scala will generate a global "timeFormat" dictionary to store the time
-// and its formatted string. Because we cannot specify a timezone in JavaScript, to make sure the
-// server and client use the same timezone, we use the "timeFormat" dictionary to format all time
-// values used in the graphs.
-
-// A global margin left for all timeline graphs. It will be set in "registerTimeline". This will be
-// used to align all timeline graphs.
-var maxMarginLeftForTimeline = 0;
-
-// The max X values for all histograms. It will be set in "registerHistogram".
-var maxXForHistogram = 0;
-
-var histogramBinCount = 10;
-var yValueFormat = d3.format(",.2f");
-
-// Show a tooltip "text" for "node"
-function showBootstrapTooltip(node, text) {
- $(node).tooltip({title: text, trigger: "manual", container: "body"});
- $(node).tooltip("show");
-}
-
-// Hide the tooltip for "node"
-function hideBootstrapTooltip(node) {
- $(node).tooltip("destroy");
-}
-
-// Register a timeline graph. All timeline graphs should be register before calling any
-// "drawTimeline" so that we can determine the max margin left for all timeline graphs.
-function registerTimeline(minY, maxY) {
- var numOfChars = yValueFormat(maxY).length;
- // A least width for "maxY" in the graph
- var pxForMaxY = numOfChars * 8 + 10;
- // Make sure we have enough space to show the ticks in the y axis of timeline
- maxMarginLeftForTimeline = pxForMaxY > maxMarginLeftForTimeline? pxForMaxY : maxMarginLeftForTimeline;
-}
-
-// Register a histogram graph. All histogram graphs should be register before calling any
-// "drawHistogram" so that we can determine the max X value for histograms.
-function registerHistogram(values, minY, maxY) {
- var data = d3.layout.histogram().range([minY, maxY]).bins(histogramBinCount)(values);
- // d.x is the y values while d.y is the x values
- var maxX = d3.max(data, function(d) { return d.y; });
- maxXForHistogram = maxX > maxXForHistogram ? maxX : maxXForHistogram;
-}
-
-// Draw a line between (x1, y1) and (x2, y2)
-function drawLine(svg, xFunc, yFunc, x1, y1, x2, y2) {
- var line = d3.svg.line()
- .x(function(d) { return xFunc(d.x); })
- .y(function(d) { return yFunc(d.y); });
- var data = [{x: x1, y: y1}, {x: x2, y: y2}];
- svg.append("path")
- .datum(data)
- .style("stroke-dasharray", ("6, 6"))
- .style("stroke", "lightblue")
- .attr("class", "line")
- .attr("d", line);
-}
-
-/**
- * @param id the `id` used in the html `div` tag
- * @param data the data for the timeline graph
- * @param minX the min value of X axis
- * @param maxX the max value of X axis
- * @param minY the min value of Y axis
- * @param maxY the max value of Y axis
- * @param unitY the unit of Y axis
- * @param batchInterval if "batchInterval" is specified, we will draw a line for "batchInterval" in the graph
- */
-function drawTimeline(id, data, minX, maxX, minY, maxY, unitY, batchInterval) {
- // Hide the right border of "<td>". We cannot use "css" directly, or "sorttable.js" will override them.
- d3.select(d3.select(id).node().parentNode)
- .style("padding", "8px 0 8px 8px")
- .style("border-right", "0px solid white");
-
- var margin = {top: 20, right: 27, bottom: 30, left: maxMarginLeftForTimeline};
- var width = 500 - margin.left - margin.right;
- var height = 150 - margin.top - margin.bottom;
-
- var x = d3.scale.linear().domain([minX, maxX]).range([0, width]);
- var y = d3.scale.linear().domain([minY, maxY]).range([height, 0]);
-
- var xAxis = d3.svg.axis().scale(x).orient("bottom").tickFormat(function(d) {
- var formattedDate = timeFormat[d];
- var dotIndex = formattedDate.indexOf('.');
- if (dotIndex >= 0) {
- // Remove milliseconds
- return formattedDate.substring(0, dotIndex);
- } else {
- return formattedDate;
- }
- });
- var formatYValue = d3.format(",.2f");
- var yAxis = d3.svg.axis().scale(y).orient("left").ticks(5).tickFormat(formatYValue);
-
- var line = d3.svg.line()
- .x(function(d) { return x(d.x); })
- .y(function(d) { return y(d.y); });
-
- var svg = d3.select(id).append("svg")
- .attr("width", width + margin.left + margin.right)
- .attr("height", height + margin.top + margin.bottom)
- .append("g")
- .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
-
- // Only show the first and last time in the graph
- xAxis.tickValues(x.domain());
-
- svg.append("g")
- .attr("class", "x axis")
- .attr("transform", "translate(0," + height + ")")
- .call(xAxis)
-
- svg.append("g")
- .attr("class", "y axis")
- .call(yAxis)
- .append("text")
- .attr("transform", "translate(0," + (-3) + ")")
- .text(unitY);
-
-
- if (batchInterval && batchInterval <= maxY) {
- drawLine(svg, x, y, minX, batchInterval, maxX, batchInterval);
- }
-
- svg.append("path")
- .datum(data)
- .attr("class", "line")
- .attr("d", line);
-
- // Add points to the line. However, we make it invisible at first. But when the user moves mouse
- // over a point, it will be displayed with its detail.
- svg.selectAll(".point")
- .data(data)
- .enter().append("circle")
- .attr("stroke", "white") // white and opacity = 0 make it invisible
- .attr("fill", "white")
- .attr("opacity", "0")
- .attr("cx", function(d) { return x(d.x); })
- .attr("cy", function(d) { return y(d.y); })
- .attr("r", function(d) { return 3; })
- .on('mouseover', function(d) {
- var tip = formatYValue(d.y) + " " + unitY + " at " + timeFormat[d.x];
- showBootstrapTooltip(d3.select(this).node(), tip);
- // show the point
- d3.select(this)
- .attr("stroke", "steelblue")
- .attr("fill", "steelblue")
- .attr("opacity", "1");
- })
- .on('mouseout', function() {
- hideBootstrapTooltip(d3.select(this).node());
- // hide the point
- d3.select(this)
- .attr("stroke", "white")
- .attr("fill", "white")
- .attr("opacity", "0");
- })
- .on("click", function(d) {
- window.location.href = "batch/?id=" + d.x;
- });
-}
-
-/**
- * @param id the `id` used in the html `div` tag
- * @param values the data for the histogram graph
- * @param minY the min value of Y axis
- * @param maxY the max value of Y axis
- * @param unitY the unit of Y axis
- * @param batchInterval if "batchInterval" is specified, we will draw a line for "batchInterval" in the graph
- */
-function drawHistogram(id, values, minY, maxY, unitY, batchInterval) {
- // Hide the left border of "<td>". We cannot use "css" directly, or "sorttable.js" will override them.
- d3.select(d3.select(id).node().parentNode)
- .style("padding", "8px 8px 8px 0")
- .style("border-left", "0px solid white");
-
- var margin = {top: 20, right: 30, bottom: 30, left: 10};
- var width = 300 - margin.left - margin.right;
- var height = 150 - margin.top - margin.bottom;
-
- var x = d3.scale.linear().domain([0, maxXForHistogram]).range([0, width]);
- var y = d3.scale.linear().domain([minY, maxY]).range([height, 0]);
-
- var xAxis = d3.svg.axis().scale(x).orient("top").ticks(5);
- var yAxis = d3.svg.axis().scale(y).orient("left").ticks(0).tickFormat(function(d) { return ""; });
-
- var data = d3.layout.histogram().range([minY, maxY]).bins(histogramBinCount)(values);
-
- var svg = d3.select(id).append("svg")
- .attr("width", width + margin.left + margin.right)
- .attr("height", height + margin.top + margin.bottom)
- .append("g")
- .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
-
- if (batchInterval && batchInterval <= maxY) {
- drawLine(svg, x, y, 0, batchInterval, maxXForHistogram, batchInterval);
- }
-
- svg.append("g")
- .attr("class", "x axis")
- .call(xAxis)
-
- svg.append("g")
- .attr("class", "y axis")
- .call(yAxis)
-
- var bar = svg.selectAll(".bar")
- .data(data)
- .enter()
- .append("g")
- .attr("transform", function(d) { return "translate(0," + (y(d.x) - height + y(d.dx)) + ")";})
- .attr("class", "bar").append("rect")
- .attr("width", function(d) { return x(d.y); })
- .attr("height", function(d) { return height - y(d.dx); })
- .on('mouseover', function(d) {
- var percent = yValueFormat(d.y * 100.0 / values.length) + "%";
- var tip = d.y + " batches (" + percent + ") between " + yValueFormat(d.x) + " and " + yValueFormat(d.x + d.dx) + " " + unitY;
- showBootstrapTooltip(d3.select(this).node(), tip);
- })
- .on('mouseout', function() {
- hideBootstrapTooltip(d3.select(this).node());
- });
-
- if (batchInterval && batchInterval <= maxY) {
- // Add the "stable" text to the graph below the batch interval line.
- var stableXOffset = x(maxXForHistogram) - 20;
- var stableYOffset = y(batchInterval) + 15;
- svg.append("text")
- .style("fill", "lightblue")
- .attr("class", "stable-text")
- .attr("text-anchor", "middle")
- .attr("transform", "translate(" + stableXOffset + "," + stableYOffset + ")")
- .text("stable")
- .on('mouseover', function(d) {
- var tip = "Processing Time <= Batch Interval (" + yValueFormat(batchInterval) +" " + unitY +")";
- showBootstrapTooltip(d3.select(this).node(), tip);
- })
- .on('mouseout', function() {
- hideBootstrapTooltip(d3.select(this).node());
- });
- }
-}
-
-$(function() {
- var status = window.localStorage && window.localStorage.getItem("show-streams-detail") == "true";
-
- $("span.expand-input-rate").click(function() {
- status = !status;
- $("#inputs-table").toggle('collapsed');
- // Toggle the class of the arrow between open and closed
- $(this).find('.expand-input-rate-arrow').toggleClass('arrow-open').toggleClass('arrow-closed');
- if (window.localStorage) {
- window.localStorage.setItem("show-streams-detail", "" + status);
- }
- });
-
- if (status) {
- $("#inputs-table").toggle('collapsed');
- // Toggle the class of the arrow between open and closed
- $(this).find('.expand-input-rate-arrow').toggleClass('arrow-open').toggleClass('arrow-closed');
- }
-});
http://git-wip-us.apache.org/repos/asf/spark/blob/cf842d42/core/src/main/scala/org/apache/spark/ui/WebUI.scala
----------------------------------------------------------------------
diff --git a/core/src/main/scala/org/apache/spark/ui/WebUI.scala b/core/src/main/scala/org/apache/spark/ui/WebUI.scala
index 384f2ad..1df9cd0 100644
--- a/core/src/main/scala/org/apache/spark/ui/WebUI.scala
+++ b/core/src/main/scala/org/apache/spark/ui/WebUI.scala
@@ -94,7 +94,7 @@ private[spark] abstract class WebUI(
}
/** Detach a handler from this UI. */
- protected def detachHandler(handler: ServletContextHandler) {
+ def detachHandler(handler: ServletContextHandler) {
handlers -= handler
serverInfo.foreach { info =>
info.rootHandler.removeHandler(handler)
http://git-wip-us.apache.org/repos/asf/spark/blob/cf842d42/streaming/src/main/resources/org/apache/spark/streaming/ui/static/streaming-page.css
----------------------------------------------------------------------
diff --git a/streaming/src/main/resources/org/apache/spark/streaming/ui/static/streaming-page.css b/streaming/src/main/resources/org/apache/spark/streaming/ui/static/streaming-page.css
new file mode 100644
index 0000000..19abe88
--- /dev/null
+++ b/streaming/src/main/resources/org/apache/spark/streaming/ui/static/streaming-page.css
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+.graph {
+ font: 10px sans-serif;
+}
+
+.axis path, .axis line {
+ fill: none;
+ stroke: gray;
+ shape-rendering: crispEdges;
+}
+
+.axis text {
+ fill: gray;
+}
+
+.tooltip-inner {
+ max-width: 500px !important; // Make sure we only have one line tooltip
+}
+
+.line {
+ fill: none;
+ stroke: #0088cc;
+ stroke-width: 1.5px;
+}
+
+.bar rect {
+ fill: #0088cc;
+ shape-rendering: crispEdges;
+}
+
+.bar rect:hover {
+ fill: #00c2ff;
+}
+
+.timeline {
+ width: 500px;
+}
+
+.histogram {
+ width: auto;
+}
+
+span.expand-input-rate {
+ cursor: pointer;
+}
http://git-wip-us.apache.org/repos/asf/spark/blob/cf842d42/streaming/src/main/resources/org/apache/spark/streaming/ui/static/streaming-page.js
----------------------------------------------------------------------
diff --git a/streaming/src/main/resources/org/apache/spark/streaming/ui/static/streaming-page.js b/streaming/src/main/resources/org/apache/spark/streaming/ui/static/streaming-page.js
new file mode 100644
index 0000000..0ee6752
--- /dev/null
+++ b/streaming/src/main/resources/org/apache/spark/streaming/ui/static/streaming-page.js
@@ -0,0 +1,281 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+// timeFormat: StreamingPage.scala will generate a global "timeFormat" dictionary to store the time
+// and its formatted string. Because we cannot specify a timezone in JavaScript, to make sure the
+// server and client use the same timezone, we use the "timeFormat" dictionary to format all time
+// values used in the graphs.
+
+// A global margin left for all timeline graphs. It will be set in "registerTimeline". This will be
+// used to align all timeline graphs.
+var maxMarginLeftForTimeline = 0;
+
+// The max X values for all histograms. It will be set in "registerHistogram".
+var maxXForHistogram = 0;
+
+var histogramBinCount = 10;
+var yValueFormat = d3.format(",.2f");
+
+// Show a tooltip "text" for "node"
+function showBootstrapTooltip(node, text) {
+ $(node).tooltip({title: text, trigger: "manual", container: "body"});
+ $(node).tooltip("show");
+}
+
+// Hide the tooltip for "node"
+function hideBootstrapTooltip(node) {
+ $(node).tooltip("destroy");
+}
+
+// Register a timeline graph. All timeline graphs should be register before calling any
+// "drawTimeline" so that we can determine the max margin left for all timeline graphs.
+function registerTimeline(minY, maxY) {
+ var numOfChars = yValueFormat(maxY).length;
+ // A least width for "maxY" in the graph
+ var pxForMaxY = numOfChars * 8 + 10;
+ // Make sure we have enough space to show the ticks in the y axis of timeline
+ maxMarginLeftForTimeline = pxForMaxY > maxMarginLeftForTimeline? pxForMaxY : maxMarginLeftForTimeline;
+}
+
+// Register a histogram graph. All histogram graphs should be register before calling any
+// "drawHistogram" so that we can determine the max X value for histograms.
+function registerHistogram(values, minY, maxY) {
+ var data = d3.layout.histogram().range([minY, maxY]).bins(histogramBinCount)(values);
+ // d.x is the y values while d.y is the x values
+ var maxX = d3.max(data, function(d) { return d.y; });
+ maxXForHistogram = maxX > maxXForHistogram ? maxX : maxXForHistogram;
+}
+
+// Draw a line between (x1, y1) and (x2, y2)
+function drawLine(svg, xFunc, yFunc, x1, y1, x2, y2) {
+ var line = d3.svg.line()
+ .x(function(d) { return xFunc(d.x); })
+ .y(function(d) { return yFunc(d.y); });
+ var data = [{x: x1, y: y1}, {x: x2, y: y2}];
+ svg.append("path")
+ .datum(data)
+ .style("stroke-dasharray", ("6, 6"))
+ .style("stroke", "lightblue")
+ .attr("class", "line")
+ .attr("d", line);
+}
+
+/**
+ * @param id the `id` used in the html `div` tag
+ * @param data the data for the timeline graph
+ * @param minX the min value of X axis
+ * @param maxX the max value of X axis
+ * @param minY the min value of Y axis
+ * @param maxY the max value of Y axis
+ * @param unitY the unit of Y axis
+ * @param batchInterval if "batchInterval" is specified, we will draw a line for "batchInterval" in the graph
+ */
+function drawTimeline(id, data, minX, maxX, minY, maxY, unitY, batchInterval) {
+ // Hide the right border of "<td>". We cannot use "css" directly, or "sorttable.js" will override them.
+ d3.select(d3.select(id).node().parentNode)
+ .style("padding", "8px 0 8px 8px")
+ .style("border-right", "0px solid white");
+
+ var margin = {top: 20, right: 27, bottom: 30, left: maxMarginLeftForTimeline};
+ var width = 500 - margin.left - margin.right;
+ var height = 150 - margin.top - margin.bottom;
+
+ var x = d3.scale.linear().domain([minX, maxX]).range([0, width]);
+ var y = d3.scale.linear().domain([minY, maxY]).range([height, 0]);
+
+ var xAxis = d3.svg.axis().scale(x).orient("bottom").tickFormat(function(d) {
+ var formattedDate = timeFormat[d];
+ var dotIndex = formattedDate.indexOf('.');
+ if (dotIndex >= 0) {
+ // Remove milliseconds
+ return formattedDate.substring(0, dotIndex);
+ } else {
+ return formattedDate;
+ }
+ });
+ var formatYValue = d3.format(",.2f");
+ var yAxis = d3.svg.axis().scale(y).orient("left").ticks(5).tickFormat(formatYValue);
+
+ var line = d3.svg.line()
+ .x(function(d) { return x(d.x); })
+ .y(function(d) { return y(d.y); });
+
+ var svg = d3.select(id).append("svg")
+ .attr("width", width + margin.left + margin.right)
+ .attr("height", height + margin.top + margin.bottom)
+ .append("g")
+ .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
+
+ // Only show the first and last time in the graph
+ xAxis.tickValues(x.domain());
+
+ svg.append("g")
+ .attr("class", "x axis")
+ .attr("transform", "translate(0," + height + ")")
+ .call(xAxis)
+
+ svg.append("g")
+ .attr("class", "y axis")
+ .call(yAxis)
+ .append("text")
+ .attr("transform", "translate(0," + (-3) + ")")
+ .text(unitY);
+
+
+ if (batchInterval && batchInterval <= maxY) {
+ drawLine(svg, x, y, minX, batchInterval, maxX, batchInterval);
+ }
+
+ svg.append("path")
+ .datum(data)
+ .attr("class", "line")
+ .attr("d", line);
+
+ // Add points to the line. However, we make it invisible at first. But when the user moves mouse
+ // over a point, it will be displayed with its detail.
+ svg.selectAll(".point")
+ .data(data)
+ .enter().append("circle")
+ .attr("stroke", "white") // white and opacity = 0 make it invisible
+ .attr("fill", "white")
+ .attr("opacity", "0")
+ .attr("cx", function(d) { return x(d.x); })
+ .attr("cy", function(d) { return y(d.y); })
+ .attr("r", function(d) { return 3; })
+ .on('mouseover', function(d) {
+ var tip = formatYValue(d.y) + " " + unitY + " at " + timeFormat[d.x];
+ showBootstrapTooltip(d3.select(this).node(), tip);
+ // show the point
+ d3.select(this)
+ .attr("stroke", "steelblue")
+ .attr("fill", "steelblue")
+ .attr("opacity", "1");
+ })
+ .on('mouseout', function() {
+ hideBootstrapTooltip(d3.select(this).node());
+ // hide the point
+ d3.select(this)
+ .attr("stroke", "white")
+ .attr("fill", "white")
+ .attr("opacity", "0");
+ })
+ .on("click", function(d) {
+ window.location.href = "batch/?id=" + d.x;
+ });
+}
+
+/**
+ * @param id the `id` used in the html `div` tag
+ * @param values the data for the histogram graph
+ * @param minY the min value of Y axis
+ * @param maxY the max value of Y axis
+ * @param unitY the unit of Y axis
+ * @param batchInterval if "batchInterval" is specified, we will draw a line for "batchInterval" in the graph
+ */
+function drawHistogram(id, values, minY, maxY, unitY, batchInterval) {
+ // Hide the left border of "<td>". We cannot use "css" directly, or "sorttable.js" will override them.
+ d3.select(d3.select(id).node().parentNode)
+ .style("padding", "8px 8px 8px 0")
+ .style("border-left", "0px solid white");
+
+ var margin = {top: 20, right: 30, bottom: 30, left: 10};
+ var width = 300 - margin.left - margin.right;
+ var height = 150 - margin.top - margin.bottom;
+
+ var x = d3.scale.linear().domain([0, maxXForHistogram]).range([0, width]);
+ var y = d3.scale.linear().domain([minY, maxY]).range([height, 0]);
+
+ var xAxis = d3.svg.axis().scale(x).orient("top").ticks(5);
+ var yAxis = d3.svg.axis().scale(y).orient("left").ticks(0).tickFormat(function(d) { return ""; });
+
+ var data = d3.layout.histogram().range([minY, maxY]).bins(histogramBinCount)(values);
+
+ var svg = d3.select(id).append("svg")
+ .attr("width", width + margin.left + margin.right)
+ .attr("height", height + margin.top + margin.bottom)
+ .append("g")
+ .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
+
+ if (batchInterval && batchInterval <= maxY) {
+ drawLine(svg, x, y, 0, batchInterval, maxXForHistogram, batchInterval);
+ }
+
+ svg.append("g")
+ .attr("class", "x axis")
+ .call(xAxis)
+
+ svg.append("g")
+ .attr("class", "y axis")
+ .call(yAxis)
+
+ var bar = svg.selectAll(".bar")
+ .data(data)
+ .enter()
+ .append("g")
+ .attr("transform", function(d) { return "translate(0," + (y(d.x) - height + y(d.dx)) + ")";})
+ .attr("class", "bar").append("rect")
+ .attr("width", function(d) { return x(d.y); })
+ .attr("height", function(d) { return height - y(d.dx); })
+ .on('mouseover', function(d) {
+ var percent = yValueFormat(d.y * 100.0 / values.length) + "%";
+ var tip = d.y + " batches (" + percent + ") between " + yValueFormat(d.x) + " and " + yValueFormat(d.x + d.dx) + " " + unitY;
+ showBootstrapTooltip(d3.select(this).node(), tip);
+ })
+ .on('mouseout', function() {
+ hideBootstrapTooltip(d3.select(this).node());
+ });
+
+ if (batchInterval && batchInterval <= maxY) {
+ // Add the "stable" text to the graph below the batch interval line.
+ var stableXOffset = x(maxXForHistogram) - 20;
+ var stableYOffset = y(batchInterval) + 15;
+ svg.append("text")
+ .style("fill", "lightblue")
+ .attr("class", "stable-text")
+ .attr("text-anchor", "middle")
+ .attr("transform", "translate(" + stableXOffset + "," + stableYOffset + ")")
+ .text("stable")
+ .on('mouseover', function(d) {
+ var tip = "Processing Time <= Batch Interval (" + yValueFormat(batchInterval) +" " + unitY +")";
+ showBootstrapTooltip(d3.select(this).node(), tip);
+ })
+ .on('mouseout', function() {
+ hideBootstrapTooltip(d3.select(this).node());
+ });
+ }
+}
+
+$(function() {
+ var status = window.localStorage && window.localStorage.getItem("show-streams-detail") == "true";
+
+ $("span.expand-input-rate").click(function() {
+ status = !status;
+ $("#inputs-table").toggle('collapsed');
+ // Toggle the class of the arrow between open and closed
+ $(this).find('.expand-input-rate-arrow').toggleClass('arrow-open').toggleClass('arrow-closed');
+ if (window.localStorage) {
+ window.localStorage.setItem("show-streams-detail", "" + status);
+ }
+ });
+
+ if (status) {
+ $("#inputs-table").toggle('collapsed');
+ // Toggle the class of the arrow between open and closed
+ $(this).find('.expand-input-rate-arrow').toggleClass('arrow-open').toggleClass('arrow-closed');
+ }
+});
http://git-wip-us.apache.org/repos/asf/spark/blob/cf842d42/streaming/src/main/scala/org/apache/spark/streaming/ui/StreamingPage.scala
----------------------------------------------------------------------
diff --git a/streaming/src/main/scala/org/apache/spark/streaming/ui/StreamingPage.scala b/streaming/src/main/scala/org/apache/spark/streaming/ui/StreamingPage.scala
index 070564a..4ee7a48 100644
--- a/streaming/src/main/scala/org/apache/spark/streaming/ui/StreamingPage.scala
+++ b/streaming/src/main/scala/org/apache/spark/streaming/ui/StreamingPage.scala
@@ -166,8 +166,8 @@ private[ui] class StreamingPage(parent: StreamingTab)
private def generateLoadResources(): Seq[Node] = {
// scalastyle:off
<script src={SparkUIUtils.prependBaseUri("/static/d3.min.js")}></script>
- <link rel="stylesheet" href={SparkUIUtils.prependBaseUri("/static/streaming-page.css")} type="text/css"/>
- <script src={SparkUIUtils.prependBaseUri("/static/streaming-page.js")}></script>
+ <link rel="stylesheet" href={SparkUIUtils.prependBaseUri("/static/streaming/streaming-page.css")} type="text/css"/>
+ <script src={SparkUIUtils.prependBaseUri("/static/streaming/streaming-page.js")}></script>
// scalastyle:on
}
http://git-wip-us.apache.org/repos/asf/spark/blob/cf842d42/streaming/src/main/scala/org/apache/spark/streaming/ui/StreamingTab.scala
----------------------------------------------------------------------
diff --git a/streaming/src/main/scala/org/apache/spark/streaming/ui/StreamingTab.scala b/streaming/src/main/scala/org/apache/spark/streaming/ui/StreamingTab.scala
index f307b54..e0c0f57 100644
--- a/streaming/src/main/scala/org/apache/spark/streaming/ui/StreamingTab.scala
+++ b/streaming/src/main/scala/org/apache/spark/streaming/ui/StreamingTab.scala
@@ -17,9 +17,11 @@
package org.apache.spark.streaming.ui
+import org.eclipse.jetty.servlet.ServletContextHandler
+
import org.apache.spark.{Logging, SparkException}
import org.apache.spark.streaming.StreamingContext
-import org.apache.spark.ui.{SparkUI, SparkUITab}
+import org.apache.spark.ui.{JettyUtils, SparkUI, SparkUITab}
import StreamingTab._
@@ -30,6 +32,8 @@ import StreamingTab._
private[spark] class StreamingTab(val ssc: StreamingContext)
extends SparkUITab(getSparkUI(ssc), "streaming") with Logging {
+ private val STATIC_RESOURCE_DIR = "org/apache/spark/streaming/ui/static"
+
val parent = getSparkUI(ssc)
val listener = ssc.progressListener
@@ -38,12 +42,18 @@ private[spark] class StreamingTab(val ssc: StreamingContext)
attachPage(new StreamingPage(this))
attachPage(new BatchPage(this))
+ var staticHandler: ServletContextHandler = null
+
def attach() {
getSparkUI(ssc).attachTab(this)
+ staticHandler = JettyUtils.createStaticHandler(STATIC_RESOURCE_DIR, "/static/streaming")
+ getSparkUI(ssc).attachHandler(staticHandler)
}
def detach() {
getSparkUI(ssc).detachTab(this)
+ getSparkUI(ssc).detachHandler(staticHandler)
+ staticHandler = null
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org