[prev in list] [next in list] [prev in thread] [next in thread]
List: drill-commits
Subject: [06/16] git commit: DRILL-997: Basic metrics and threads UI.
From: jacques () apache ! org
Date: 2014-06-26 20:45:06
Message-ID: b016e9ae7ab641be95fccff8311addfd () git ! apache ! org
[Download RAW message or body]
DRILL-997: Basic metrics and threads UI.
Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/dbaec9dd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/dbaec9dd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/dbaec9dd
Branch: refs/heads/master
Commit: dbaec9dd54dbba65cb4eecb48bd1f063df13d2ec
Parents: 80c6ebb
Author: Sudheesh Katkam <skatkam@maprtech.com>
Authored: Wed Jun 18 16:03:33 2014 -0700
Committer: Jacques Nadeau <jacques@apache.org>
Committed: Wed Jun 25 17:51:27 2014 -0700
----------------------------------------------------------------------
.../drill/exec/server/rest/DrillRestServer.java | 6 +-
.../exec/server/rest/MetricsResources.java | 13 ++
.../exec/server/rest/ThreadsResources.java | 37 +++++
.../src/main/resources/rest/generic.ftl | 4 +-
.../src/main/resources/rest/metrics/metrics.ftl | 164 +++++++++++++++++++
.../src/main/resources/rest/threads/threads.ftl | 35 ++++
6 files changed, 253 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/dbaec9dd/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/DrillRestServer.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/DrillRestServer.java \
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/DrillRestServer.java \
index 11bb776..cdbaaaf 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/DrillRestServer.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/DrillRestServer.java
@@ -17,10 +17,6 @@
*/
package org.apache.drill.exec.server.rest;
-import org.apache.drill.common.config.DrillConfig;
-import org.apache.drill.exec.client.DrillClient;
-import org.apache.drill.exec.coord.ClusterCoordinator;
-import org.apache.drill.exec.memory.BufferAllocator;
import org.apache.drill.exec.store.StoragePluginRegistry;
import org.apache.drill.exec.store.sys.PStoreProvider;
import org.apache.drill.exec.work.WorkManager;
@@ -46,6 +42,8 @@ public class DrillRestServer extends ResourceConfig {
register(StorageResources.class);
register(ProfileResources.class);
register(QueryResources.class);
+ register(MetricsResources.class);
+ register(ThreadsResources.class);
register(FreemarkerMvcFeature.class);
property(ServerProperties.METAINF_SERVICES_LOOKUP_DISABLE, true);
register(MultiPartFeature.class);
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/dbaec9dd/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/MetricsResources.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/MetricsResources.java \
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/MetricsResources.java
index f7b6b7f..802b61f 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/MetricsResources.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/MetricsResources.java
@@ -17,8 +17,21 @@
*/
package org.apache.drill.exec.server.rest;
+import org.glassfish.jersey.server.mvc.Viewable;
+
+import javax.ws.rs.GET;
import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
@Path("/metrics")
public class MetricsResources {
+ static final org.slf4j.Logger logger = \
org.slf4j.LoggerFactory.getLogger(MetricsResources.class); +
+ @GET
+ @Produces(MediaType.TEXT_HTML)
+ public Viewable getMetrics() {
+ return new Viewable("/rest/metrics/metrics.ftl");
+ }
+
}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/dbaec9dd/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/ThreadsResources.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/ThreadsResources.java \
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/ThreadsResources.java
new file mode 100644
index 0000000..0fc8055
--- /dev/null
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/ThreadsResources.java
@@ -0,0 +1,37 @@
+/**
+ * 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.
+ */
+package org.apache.drill.exec.server.rest;
+
+import org.glassfish.jersey.server.mvc.Viewable;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+@Path("/threads")
+public class ThreadsResources {
+ static final org.slf4j.Logger logger = \
org.slf4j.LoggerFactory.getLogger(MetricsResources.class); +
+ @GET
+ @Produces(MediaType.TEXT_HTML)
+ public Viewable getMetrics() {
+ return new Viewable("/rest/threads/threads.ftl");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/dbaec9dd/exec/java-exec/src/main/resources/rest/generic.ftl
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/resources/rest/generic.ftl \
b/exec/java-exec/src/main/resources/rest/generic.ftl index c5ed400..256d582 100644
--- a/exec/java-exec/src/main/resources/rest/generic.ftl
+++ b/exec/java-exec/src/main/resources/rest/generic.ftl
@@ -57,8 +57,8 @@
<li><a href="/query">Query</a></li>
<li><a href="/profiles">Profiles</a></li>
<li><a href="/storage">Storage</a></li>
- <li><a href="/status/metrics">Metrics</a></li>
- <li><a href="/status/threads">Threads</a></li>
+ <li><a href="/metrics">Metrics</a></li>
+ <li><a href="/threads">Threads</a></li>
</ul>
</div>
</div>
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/dbaec9dd/exec/java-exec/src/main/resources/rest/metrics/metrics.ftl
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/resources/rest/metrics/metrics.ftl \
b/exec/java-exec/src/main/resources/rest/metrics/metrics.ftl new file mode 100644
index 0000000..b0ccde8
--- /dev/null
+++ b/exec/java-exec/src/main/resources/rest/metrics/metrics.ftl
@@ -0,0 +1,164 @@
+<#-- 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. -->
+
+<#include "*/generic.ftl">
+<#macro page_head>
+</#macro>
+
+<#macro page_body>
+ <a href="/queries">back</a><br/>
+ <div class="page-header">
+ </div>
+ <div class="row">
+
+ <div class="col-md-3 sidebar">
+ <ul id="sideDiv" class="nav nav-sidebar">
+ <li> <a href="#gauges">Gauges</a> </li>
+ <li> <a href="#counters">Counters</a> </li>
+ <li> <a href="#histograms">Histograms</a> </li>
+ <li> <a href="#meters">Meters</a> </li>
+ <li> <a href="#timers">Timers</a> </li>
+ </ul>
+ <br>
+ Heap
+ <div class="progress">
+ <div id="heapUsage" class="progress-bar" role="progressbar" \
aria-valuenow="50" aria-valuemin="0" aria-valuemax="100" style="width: 50%;"> + \
</div> + </div>
+ Non heap
+ <div class="progress">
+ <div id="non-heapUsage" class="progress-bar" role="progressbar" \
aria-valuenow="50" aria-valuemin="0" aria-valuemax="100" style="width: 50%;"> + \
</div> + </div>
+ Total
+ <div class="progress">
+ <div id="totalUsage" class="progress-bar" role="progressbar" \
aria-valuenow="50" aria-valuemin="0" aria-valuemax="100" style="width: 50%;"> + \
</div> + </div>
+ </div>
+
+ <div id="mainDiv" class="col-md-9" role="main">
+ <h3 id="gauges">Gauges</h3>
+ <div id="gaugesVal">
+ <table class="table table-striped" id="gaugesTable">
+ </table>
+ </div>
+ <h3 id="counters">Counters</h3>
+ <div id="countersVal">
+ <div class="alert alert-info">
+ <strong>No counters.</strong>
+ </div>
+ </div>
+ <h3 id="histograms">Histograms</h3>
+ <div id="histogramsVal">
+ <div class="alert alert-info">
+ <strong>No counters.</strong>
+ </div>
+ </div>
+ <h3 id="meters">Meters</h3>
+ <div id="metersVal">
+ <div class="alert alert-info">
+ <strong>No meters.</strong>
+ </div>
+ </div>
+ <h3 id="timers">Timers</h3>
+ <div id="timersVal">
+ <div class="alert alert-info">
+ <strong>No timers.</strong>
+ </div>
+ </div>
+ </div>
+
+ </div>
+
+ <script>
+ var round = function(val, n) {
+ return Math.round(val * Math.pow(10, n)) / Math.pow(10, n);
+ };
+
+ function updateGauges(gauges) {
+ $("#gaugesTable").html(function() {
+ var table = "<tbody>";
+ $.each(gauges, function(key, value) {
+ table += "<tr>";
+ table += "<td>" + key + "</td>";
+ table += "<td>" + round(value.value, 6) + "</td>";
+ table += "</tr>";
+ });
+ table += "</tbody>";
+ return table;
+ });
+ };
+
+ function updateBars(gauges) {
+ $.each(["heap","non-heap","total"], function(i, key) {
+ var used = gauges[key + ".used"].value;
+ var max = gauges[key + ".max"].value;
+ var usage = round((used / 1073741824), 2) + "GB";
+ var percent = round((used / max), 2);
+
+ var styleVal = "width: " + percent + "%;"
+ $("#" + key + "Usage").attr({
+ "aria-valuenow" : percent,
+ "style" : styleVal
+ });
+ $("#" + key + "Usage").html(usage);
+ });
+ };
+
+ function updateTimers(timers) {
+ console.log("yup");
+ $("#timersVal").html(function() {
+ var tables = "";
+ $.each(timers, function(name, stats) {
+
+ var table = "<strong>Reporting class:</strong> " + name + "<br>";
+ table += "<table class=\"table table-striped\"><tbody>";
+ $.each(stats, function(key, value) {
+ table += "<tr>";
+ table += "<td>" + key + "</td>";
+ if(typeof value === "number") {
+ value = round(value, 5);
+ }
+ table += "<td>" + value + "</td>";
+ table += "</tr>";
+ });
+ table += "</tbody></table>";
+
+ tables += table;
+ });
+ return tables;
+ });
+ };
+
+ function updateOthers(metrics) {
+ $.each(["counters", "histograms", "meters"], function(i, key) {
+ if(! $.isEmptyObject(metrics[key])) {
+ $("#" + key + "Val").html(JSON.stringify(metrics[key], null, 2));
+ }
+ });
+ };
+
+ var update = function() {
+ $.get("/status/metrics", function(metrics) {
+ updateGauges(metrics.gauges);
+ updateBars(metrics.gauges);
+ if(! $.isEmptyObject(metrics.timers)) updateTimers(metrics.timers);
+ updateOthers(metrics);
+ });
+ };
+
+ update();
+ setInterval(update, 2000);
+ </script>
+</#macro>
+
+<@page_html/>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/dbaec9dd/exec/java-exec/src/main/resources/rest/threads/threads.ftl
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/resources/rest/threads/threads.ftl \
b/exec/java-exec/src/main/resources/rest/threads/threads.ftl new file mode 100644
index 0000000..e393164
--- /dev/null
+++ b/exec/java-exec/src/main/resources/rest/threads/threads.ftl
@@ -0,0 +1,35 @@
+<#-- 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. -->
+
+<#include "*/generic.ftl">
+<#macro page_head>
+</#macro>
+
+<#macro page_body>
+ <a href="/queries">back</a><br/>
+ <div class="page-header">
+ </div>
+ <div id="mainDiv" role="main">
+ </div>
+ </div>
+ <script>
+ var update = function() {
+ $.get("/status/threads", function(data) {
+ $("#mainDiv").html("<pre>" + data + "</pre>");
+ });
+ };
+
+ update();
+ setInterval(update, 2000);
+ </script>
+</#macro>
+
+<@page_html/>
\ No newline at end of file
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic