You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by rm...@apache.org on 2013/08/05 10:48:05 UTC
svn commit: r1510386 [2/2] - in /commons/sandbox/monitoring/trunk:
core/src/main/java/org/apache/commons/monitoring/
reporting/src/main/java/org/apache/commons/monitoring/reporting/web/
reporting/src/main/java/org/apache/commons/monitoring/reporting/we...
Modified: commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/home.vm
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/home.vm?rev=1510386&r1=1510385&r2=1510386&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/home.vm (original)
+++ commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/home.vm Mon Aug 5 08:48:04 2013
@@ -22,7 +22,7 @@
<div>
<ul>
#foreach ( $plugin in $plugins )
- <li><a href="$mapping/$plugin.rootUrl">$plugin.name</a></li>
+ <li><a href="$mapping$plugin.url">$plugin.name</a></li>
#end
</ul>
</div>
\ No newline at end of file
Modified: commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/jvm/jvm.vm
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/jvm/jvm.vm?rev=1510386&r1=1510385&r2=1510386&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/jvm/jvm.vm (original)
+++ commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/jvm/jvm.vm Mon Aug 5 08:48:04 2013
@@ -80,7 +80,7 @@
$('#cpu-datetimepicker-start').datetimepicker();
$('#cpu-datetimepicker-end').datetimepicker();
- var memoryOptions = {
+ var cpuOptions = {
canvas: true,
series: { lines: { show: true }, points: { show: true } },
grid: { hoverable: true, clickable: true },
@@ -92,7 +92,7 @@
}
} ]
};
- var cpuOptions = {
+ var memoryOptions = {
canvas: true,
series: { lines: { show: true }, points: { show: true } },
grid: { hoverable: true, clickable: true },
@@ -122,13 +122,13 @@
]
};
- var updateGraph = function (graph, start, end) {
+ var updateGraph = function (graph, start, end, options) {
$.ajax({
url: "$mapping/jvm/" + graph + "/" + start + "/" + end,
type: "GET",
dataType: "json",
success: function (data) {
- $.plot("#" + graph + "-graph", [ data ], memoryOptions);
+ $.plot("#" + graph + "-graph", [ data ], options);
}
});
};
@@ -145,17 +145,17 @@
var start = yesterday.getTime();
var end = now.getTime();
- updateGraph('cpu', start, end);
- updateGraph('memory', start, end);
+ updateGraph('cpu', start, end, cpuOptions);
+ updateGraph('memory', start, end, memoryOptions);
})();
// update diagram when clicking on update buttons
$('#update-cpu').submit(function () {
- updateGraph('cpu', extractTime($('#cpu-datetimepicker-start')), extractTime($('#cpu-datetimepicker-end')));
+ updateGraph('cpu', extractTime($('#cpu-datetimepicker-start')), extractTime($('#cpu-datetimepicker-end')), cpuOptions);
return false;
});
$('#update-memory').submit(function () {
- updateGraph('memory', extractTime($('#memory-datetimepicker-start')), extractTime($('#memory-datetimepicker-end')));
+ updateGraph('memory', extractTime($('#memory-datetimepicker-start')), extractTime($('#memory-datetimepicker-end')), memoryOptions);
return false;
});
});
Modified: commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/page.vm
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/page.vm?rev=1510386&r1=1510385&r2=1510386&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/page.vm (original)
+++ commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/page.vm Mon Aug 5 08:48:04 2013
@@ -46,7 +46,7 @@
#else
<li>
#end
- <a href="$mapping/$plugin.rootUrl">$plugin.name</a>
+ <a href="$mapping$plugin.url">$plugin.name</a>
</li>
#end
</ul>
Added: commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/report/report-csv.vm
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/report/report-csv.vm?rev=1510386&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/report/report-csv.vm (added)
+++ commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/report/report-csv.vm Mon Aug 5 08:48:04 2013
@@ -0,0 +1,17 @@
+#*
+ 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.
+*#$headers#foreach ( $line in $lines )#foreach ( $item in $line )$item#if( $foreach.hasNext )$separator#end#end#end
+
Added: commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/report/report-json.vm
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/report/report-json.vm?rev=1510386&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/report/report-json.vm (added)
+++ commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/report/report-json.vm Mon Aug 5 08:48:04 2013
@@ -0,0 +1,20 @@
+#*
+ 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.
+*#{"counters":[
+#foreach ( $counter in $counters )
+ {"name":"$counter.key.name", "role":"$counter.key.role.name","unit":"$counter.key.role.unit.name",#foreach ( $md in $MetricData.values())"$md.name()":"$md.value($counter)"#if( $foreach.hasNext ),#end#end}
+#end
+]}
Copied: commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/report/report-xml.vm (from r1510370, commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/report/report.vm)
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/report/report-xml.vm?p2=commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/report/report-xml.vm&p1=commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/report/report.vm&r1=1510370&r2=1510386&rev=1510386&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/report/report.vm (original)
+++ commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/report/report-xml.vm Mon Aug 5 08:48:04 2013
@@ -13,88 +13,15 @@
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.
-*#
-<h1>Report</h1>
-
-<ul class="nav nav-pills">
- <li class="dropdown">
- <a class="dropdown-toggle" data-toggle="dropdown" href="#">
- Actions <b class="caret"></b>
- </a>
- <ul class="dropdown-menu">
- <li><a href="$mapping/report/clear">Clear</a></li>
- </ul>
- </li>
- <li class="dropdown">
- <a class="dropdown-toggle" data-toggle="dropdown" href="#">
- Formats <b class="caret"></b>
- </a>
- <ul class="dropdown-menu">
- <li><a href="$mapping/report.xml">xml</a></li>
- <li><a href="$mapping/report.csv">csv</a></li>
- <li><a href="$mapping/report.json">json</a></li>
- </ul>
- </li>
- <li class="dropdown">
- <a class="dropdown-toggle" data-toggle="dropdown" href="#">
- Time Unit <b class="caret"></b>
- </a>
- <ul class="dropdown-menu">
- <li><a href="$mapping/report?unit=s">s</a></li>
- <li><a href="$mapping/report?unit=ms">ms</a></li>
- <li><a href="$mapping/report?unit=ns">ns</a></li>
- </ul>
- </li>
-</ul>
-
-<table id="report-table" class="table table-bordered table-striped table-hover">
- <thead>
- <tr>
- #foreach( $header in $headers )
- <th>$header</th>
- #end
- </tr>
- </thead>
- <tbody>
- #foreach( $line in $data )
- <tr>
- #foreach( $item in $line )
- <td>$item</td>
- #end
- </tr>
- #end
- </tbody>
-</table>
-
-<script type="text/javascript" src="$mapping/resources/js/bootstrap-dropdown.js"></script>
-<script type="text/javascript" src="$mapping/resources/js/jquery.tablesorter.js"></script>
-<script type="text/javascript" src="$mapping/resources/js/jquery.tablesorter.widgets.js"></script>
-<script type="text/javascript">
- $(function() {
- $("table#report-table").tablesorter({
- widthFixed : false,
- widgets: [ "filter" ],
- widgetOptions : {
- filter_childRows : false,
- filter_columnFilters : true,
- filter_cssFilter : 'tablesorter-filter',
- filter_filteredRow : 'filtered',
- filter_formatter : null,
- filter_functions : null,
- filter_hideFilters : false,
- filter_ignoreCase : true,
- filter_liveSearch : true,
- filter_reset : 'button.reset',
- filter_searchDelay : 300,
- filter_serversideFiltering: false,
- filter_startsWith : false,
- filter_useParsedData : false,
- cssAsc: 'headerSortUp',
- cssDesc: 'headerSortDown',
- sortList: [[4, 1]] // sort by mean in descending order
- }
- });
-
- $("table#report-table tr th div").addClass("blue");
- });
-</script>
+*#<?xml version="1.0"?>
+<repository>
+ #foreach ( $counter in $counters )
+ <counter name="$counter.key.name"
+ role="$counter.key.role.name"
+ unit="$counter.key.role.unit.name"
+ #foreach ( $md in $MetricData.values())
+ $md.name()="$md.value($counter)"
+ #end
+ />
+ #end
+</repository>
Modified: commons/sandbox/monitoring/trunk/reporting/src/test/java/org/apache/commons/monitoring/reporting/FormatsTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/test/java/org/apache/commons/monitoring/reporting/FormatsTest.java?rev=1510386&r1=1510385&r2=1510386&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/src/test/java/org/apache/commons/monitoring/reporting/FormatsTest.java (original)
+++ commons/sandbox/monitoring/trunk/reporting/src/test/java/org/apache/commons/monitoring/reporting/FormatsTest.java Mon Aug 5 08:48:04 2013
@@ -19,8 +19,11 @@ package org.apache.commons.monitoring.re
import org.apache.commons.monitoring.Role;
import org.apache.commons.monitoring.counters.Counter;
+import org.apache.commons.monitoring.reporting.web.handler.api.Template;
+import org.apache.commons.monitoring.reporting.web.handler.api.TemplateHelper;
import org.apache.commons.monitoring.reporting.web.plugin.report.format.CSVFormat;
import org.apache.commons.monitoring.reporting.web.plugin.report.format.Format;
+import org.apache.commons.monitoring.reporting.web.template.Templates;
import org.apache.commons.monitoring.repositories.Repository;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -36,6 +39,7 @@ public class FormatsTest {
@BeforeClass
public static void setup() {
Repository.INSTANCE.clear();
+ Templates.init("", "");
final Counter counter = Repository.INSTANCE.getCounter(new Counter.Key(Role.FAILURES, "RendererTest"));
counter.updateConcurrency(1);
@@ -50,32 +54,42 @@ public class FormatsTest {
@Test
public void renderToXML() throws Exception {
final StringWriter out = new StringWriter();
- Format.Defaults.XML.render(new PrintWriter(out), Collections.<String, Object>emptyMap());
+ final TemplateHelper helper = new TemplateHelper(new PrintWriter(out), Collections.<String, Object>emptyMap());
+ final Template template = Format.Defaults.XML.render(Collections.<String, Object>emptyMap());
+ helper.renderPlain(template.getTemplate(), template.getUserParams());
- assertEquals("<repository>" +
+ assertEquals("<?xml version=\"1.0\"?> <repository> " +
"<counter name=\"RendererTest\" role=\"failures\" unit=\"u\" Hits=\"1.0\" Max=\"1.0\" Mean=\"1.0\" Min=\"1.0\" StandardDeviation=\"0.0\" Sum=\"1.0\" " +
"SumOfLogs=\"0.0\" SumOfSquares=\"0.0\" Variance=\"0.0\" GeometricMean=\"1.0\" Value=\"1.0\" Concurrency=\"0.0\" MaxConcurrency=\"1.0\" />" +
- "</repository>".trim(), out.toString());
+ " </repository>", inline(out));
}
@Test
public void renderToJSON() throws Exception {
final StringWriter out = new StringWriter();
- Format.Defaults.JSON.render(new PrintWriter(out), Collections.<String, Object>emptyMap());
+ final TemplateHelper helper = new TemplateHelper(new PrintWriter(out), Collections.<String, Object>emptyMap());
+ final Template template = Format.Defaults.JSON.render(Collections.<String, Object>emptyMap());
+ helper.renderPlain(template.getTemplate(), template.getUserParams());
assertEquals("{\"counters\":[" +
- "{\"name\":\"RendererTest\",\"role\":\"failures\",\"unit\":\"u\",\"Hits\":\"1.0\",\"Max\":\"1.0\",\"Mean\":\"1.0\",\"Min\":\"1.0\"," +
+ " {\"name\":\"RendererTest\", \"role\":\"failures\",\"unit\":\"u\",\"Hits\":\"1.0\",\"Max\":\"1.0\",\"Mean\":\"1.0\",\"Min\":\"1.0\"," +
"\"StandardDeviation\":\"0.0\",\"Sum\":\"1.0\",\"SumOfLogs\":\"0.0\",\"SumOfSquares\":\"0.0\",\"Variance\":\"0.0\"," +
- "\"GeometricMean\":\"1.0\",\"Value\":\"1.0\",\"Concurrency\":\"0.0\",\"MaxConcurrency\":\"1.0\"}]}", out.toString());
+ "\"GeometricMean\":\"1.0\",\"Value\":\"1.0\",\"Concurrency\":\"0.0\",\"MaxConcurrency\":\"1.0\"} ]}", inline(out));
}
@Test
public void renderToCSV() throws Exception {
final StringWriter out = new StringWriter();
- Format.Defaults.CSV.render(new PrintWriter(out), Collections.<String, Object>emptyMap());
+ final TemplateHelper helper = new TemplateHelper(new PrintWriter(out), Collections.<String, Object>emptyMap());
+ final Template template = Format.Defaults.CSV.render(Collections.<String, Object>emptyMap());
+ helper.renderPlain(template.getTemplate(), template.getUserParams());
assertEquals(CSVFormat.HEADER +
"RendererTest;failures (u);1.0;1.0;1.0;1.0;0.0;1.0;0.0;0.0;0.0;1.0;1.0;0.0;1.0\n",
out.toString());
}
+
+ private static String inline(StringWriter out) {
+ return out.toString().replace("\r\n", " ").replace("\n", " ").replaceAll(" +", " ").replace("\t", "").trim();
+ }
}