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/07/29 15:47:41 UTC

svn commit: r1508066 [2/2] - in /commons/sandbox/monitoring/trunk: ./ aop/src/main/java/org/apache/commons/monitoring/aop/ cdi/src/test/java/org/apache/commons/monitoring/cdi/ core/src/main/java/org/apache/commons/monitoring/ core/src/main/java/org/apa...

Modified: commons/sandbox/monitoring/trunk/reporting/src/main/resources/META-INF/NOTICE.txt
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/main/resources/META-INF/NOTICE.txt?rev=1508066&r1=1508065&r2=1508066&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/src/main/resources/META-INF/NOTICE.txt (original)
+++ commons/sandbox/monitoring/trunk/reporting/src/main/resources/META-INF/NOTICE.txt Mon Jul 29 13:47:39 2013
@@ -1,4 +1,11 @@
 Table sorter
 
 website: https://github.com/Mottie/tablesorter
-licence: MIT
\ No newline at end of file
+licence: MIT
+
+------------------------
+
+Bootswatch
+
+website: http://bootswatch.com/
+licence: Apache v2
\ No newline at end of file

Added: 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=1508066&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/home.vm (added)
+++ commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/home.vm Mon Jul 29 13:47:39 2013
@@ -0,0 +1,28 @@
+#*
+  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.
+*#
+<div class=""container>
+    <h1>Home</h1>
+
+    <div>
+        Welcome to the Commons Monitoring Webapp. here is the list of available pages:
+    </div>
+    <div>
+        <ul>
+            <li><a href="$mapping/report">Report</a></li>
+        </ul>
+    </div>
+</div>
\ No newline at end of file

Added: 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=1508066&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/page.vm (added)
+++ commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/page.vm Mon Jul 29 13:47:39 2013
@@ -0,0 +1,64 @@
+#*
+  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.
+*#
+<!DOCTYPE html>
+<html>
+  <head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+
+    <title>Monitoring HTML Report</title>
+
+    <link rel="stylesheet" href="$base/resources/css/bootstrap.min.css">
+    <link rel="stylesheet" href="$base/resources/css/monitoring.css">
+
+    <script type="text/javascript" src="$base/resources/js/jquery.min.js"></script>
+    <script type="text/javascript" src="$base/resources/js/jquery.tablesorter.js"></script>
+    <script type="text/javascript" src="$base/resources/js/jquery.tablesorter.widgets.js"></script>
+  </head>
+  <body>
+  <div class="navbar navbar-inverse">
+      <div class="navbar-inner">
+          <div class="container">
+              <a class="brand" href="http://commons.apache.org/sandbox/commons-monitoring/">Commons Monitoring</a>
+              <div class="nav-collapse">
+                  <ul class="nav">
+                      #if ( $currentTemplate == "home.vm")
+                        <li class="active">
+                      #else
+                        <li>
+                      #end
+                          <a href="$mapping/">Home</a>
+                      </li>
+                      #if ( $currentTemplate == "report.vm")
+                        <li class="active">
+                      #else
+                        <li>
+                      #end
+                          <a href="$mapping/report">Report</a>
+                      </li>
+                  </ul>
+                  <ul class="nav pull-right">
+                      <li><a href="http://www.apache.org/">ASF</a></li>
+                  </ul>
+              </div>
+          </div>
+      </div>
+  </div>
+
+      #parse( "/templates/$currentTemplate" )
+  </body>
+</html>

Added: commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/report.vm
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/report.vm?rev=1508066&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/report.vm (added)
+++ commons/sandbox/monitoring/trunk/reporting/src/main/resources/templates/report.vm Mon Jul 29 13:47:39 2013
@@ -0,0 +1,78 @@
+#*
+  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.
+*#
+<h1>Report</h1>
+
+<table id="report-table" class="table table-bordered table-striped table-hover">
+    <thead>
+        <tr>
+            #foreach( $header in $headers )
+                #if ( $header == "Monitor")
+                    <th>
+                        <div class="row-fluid">
+                            $header
+                            <div class="btn-group">
+                                <button type="button" class="btn btn-default"><a href="$mapping/clear">Clear</a></button>
+                                <button type="button" class="btn btn-default"><a href="$mapping/reset">Reset</a></button>
+                            </div>
+                        </div>
+                    </th>
+                #else
+                    <th>$header</th>
+                #end
+            #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">
+    $(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>

Modified: commons/sandbox/monitoring/trunk/reporting/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/main/webapp/WEB-INF/web.xml?rev=1508066&r1=1508065&r2=1508066&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/src/main/webapp/WEB-INF/web.xml (original)
+++ commons/sandbox/monitoring/trunk/reporting/src/main/webapp/WEB-INF/web.xml Mon Jul 29 13:47:39 2013
@@ -20,25 +20,13 @@
          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
          version="2.5">
 
-  <servlet>
-    <servlet-name>Monitoring</servlet-name>
-    <servlet-class>org.apache.commons.monitoring.reporting.web.MonitoringServlet</servlet-class>
-  </servlet>
+  <filter>
+    <filter-name>Monitoring</filter-name>
+    <filter-class>org.apache.commons.monitoring.reporting.web.MonitoringController</filter-class>
+  </filter>
 
-  <servlet-mapping>
-    <servlet-name>Monitoring</servlet-name>
-    <url-pattern>/report.csv</url-pattern>
-  </servlet-mapping>
-  <servlet-mapping>
-    <servlet-name>Monitoring</servlet-name>
-    <url-pattern>/report.html</url-pattern>
-  </servlet-mapping>
-  <servlet-mapping>
-    <servlet-name>Monitoring</servlet-name>
-    <url-pattern>/report.json</url-pattern>
-  </servlet-mapping>
-  <servlet-mapping>
-    <servlet-name>Monitoring</servlet-name>
-    <url-pattern>/report.xml</url-pattern>
-  </servlet-mapping>
+  <filter-mapping>
+    <filter-name>Monitoring</filter-name>
+    <url-pattern>/*</url-pattern>
+  </filter-mapping>
 </web-app>

Added: commons/sandbox/monitoring/trunk/reporting/src/main/webapp/resources/css/bootstrap.min.css
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/main/webapp/resources/css/bootstrap.min.css?rev=1508066&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/src/main/webapp/resources/css/bootstrap.min.css (added)
+++ commons/sandbox/monitoring/trunk/reporting/src/main/webapp/resources/css/bootstrap.min.css Mon Jul 29 13:47:39 2013
@@ -0,0 +1,10 @@
+@import url(//fonts.googleapis.com/css?family=Telex);/*!
+ * Bootstrap v2.3.2
+ *
+ * Copyright 2012 Twitter, Inc
+ * Licensed under the Apache License v2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Designed and built with all the love in the world @twitter by @mdo and @fat.
+ */

[... 3 lines stripped ...]
Added: commons/sandbox/monitoring/trunk/reporting/src/main/webapp/resources/css/monitoring.css
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/main/webapp/resources/css/monitoring.css?rev=1508066&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/src/main/webapp/resources/css/monitoring.css (added)
+++ commons/sandbox/monitoring/trunk/reporting/src/main/webapp/resources/css/monitoring.css Mon Jul 29 13:47:39 2013
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+table .blue {
+    color: #049cdb;
+    border-bottom-color: #049cdb;
+}
+th#report-table {
+    text-align: center;
+}
+.tablesorter-headerAsc {
+    background-image: url('$base/resources/images/asc.gif');
+    background-repeat: no-repeat;
+    background-position: right;
+}
+
+.tablesorter-headerDesc {
+    background-image: url('$base/resources/images/desc.gif');
+    background-repeat: no-repeat;
+    background-position: right;
+}

Added: commons/sandbox/monitoring/trunk/reporting/src/main/webapp/resources/images/asc.gif
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/main/webapp/resources/images/asc.gif?rev=1508066&view=auto
==============================================================================
Binary file - no diff available.

Propchange: commons/sandbox/monitoring/trunk/reporting/src/main/webapp/resources/images/asc.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: commons/sandbox/monitoring/trunk/reporting/src/main/webapp/resources/images/desc.gif
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/main/webapp/resources/images/desc.gif?rev=1508066&view=auto
==============================================================================
Binary file - no diff available.

Propchange: commons/sandbox/monitoring/trunk/reporting/src/main/webapp/resources/images/desc.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Copied: commons/sandbox/monitoring/trunk/reporting/src/test/java/org/apache/commons/monitoring/reporting/FormatsTest.java (from r1507950, commons/sandbox/monitoring/trunk/reporting/src/test/java/org/apache/commons/monitoring/reporting/FormattingVisitorTest.java)
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/reporting/src/test/java/org/apache/commons/monitoring/reporting/FormatsTest.java?p2=commons/sandbox/monitoring/trunk/reporting/src/test/java/org/apache/commons/monitoring/reporting/FormatsTest.java&p1=commons/sandbox/monitoring/trunk/reporting/src/test/java/org/apache/commons/monitoring/reporting/FormattingVisitorTest.java&r1=1507950&r2=1508066&rev=1508066&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/reporting/src/test/java/org/apache/commons/monitoring/reporting/FormattingVisitorTest.java (original)
+++ commons/sandbox/monitoring/trunk/reporting/src/test/java/org/apache/commons/monitoring/reporting/FormatsTest.java Mon Jul 29 13:47:39 2013
@@ -18,76 +18,67 @@
 package org.apache.commons.monitoring.reporting;
 
 import org.apache.commons.monitoring.Role;
-import org.apache.commons.monitoring.Visitor;
 import org.apache.commons.monitoring.monitors.Monitor;
 import org.apache.commons.monitoring.reporting.format.CSVFormat;
 import org.apache.commons.monitoring.reporting.format.Format;
-import org.apache.commons.monitoring.reporting.format.FormattingVisitor;
-import org.apache.commons.monitoring.reporting.format.RoleFilter;
-import org.apache.commons.monitoring.repositories.DefaultRepository;
 import org.apache.commons.monitoring.repositories.Repository;
-import org.custommonkey.xmlunit.XMLAssert;
+import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-import java.io.InputStreamReader;
 import java.io.PrintWriter;
-import java.io.Reader;
-import java.io.StringReader;
 import java.io.StringWriter;
+import java.util.Collections;
 
 import static org.junit.Assert.assertEquals;
 
-/**
- * @author <a href="mailto:nicolas@apache.org">Nicolas De Loof</a>
- */
-public class FormattingVisitorTest {
-    private static Repository repository;
-
+public class FormatsTest {
     @BeforeClass
     public static void setup() {
-        repository = new DefaultRepository();
+        Repository.INSTANCE.clear();
 
-        final Monitor monitor = repository.getMonitor(new Monitor.Key("RendererTest", "unit"));
+        final Monitor monitor = Repository.INSTANCE.getMonitor(new Monitor.Key("RendererTest", "unit"));
         monitor.updateConcurrency(1);
         monitor.getCounter(Role.FAILURES).add(1.);
     }
 
+    @AfterClass
+    public static void clear() {
+        Repository.INSTANCE.clear();
+    }
+
     @Test
-    public void renderToXML()
-        throws Exception {
+    public void renderToXML() throws Exception {
         final StringWriter out = new StringWriter();
-        final Visitor v = new FormattingVisitor(Format.Defaults.XML_PRETTY, new PrintWriter(out), RoleFilter.Defaults.FAILURES);
-        repository.accept(v);
+        Format.Defaults.XML.render(new PrintWriter(out), Collections.<String, Object>emptyMap());
 
-        final Reader expected = new InputStreamReader(getClass().getResourceAsStream("RendererTest.xml"));
-        XMLAssert.assertXMLEqual(expected, new StringReader(out.toString()));
+        assertEquals("<repository>" +
+            "<monitor name=\"RendererTest\" category=\"unit\">" +
+            "<counter 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\" MaxConcurrency=\"1.0\" />" +
+            "</monitor>" +
+            "</repository>".trim(), out.toString());
     }
 
     @Test
-    public void renderToJSON()
-        throws Exception {
+    public void renderToJSON() throws Exception {
         final StringWriter out = new StringWriter();
-        final Visitor v = new FormattingVisitor(Format.Defaults.JSON_PRETTY, new PrintWriter(out), RoleFilter.Defaults.FAILURES);
-        repository.accept(v);
+        Format.Defaults.JSON.render(new PrintWriter(out), Collections.<String, Object>emptyMap());
 
-        assertEquals("{\n" +
-            "  \"RendererTest\":{\n" +
-            "    \"category\": \"unit\",\n" +
-            "    \"failures\":{\"type\":\"counter\",\"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\",\"MaxConcurrency\":\"1.0\"}\n" +
-            "  }\n" +
-            "}", out.toString());
+        assertEquals("{\"monitors\":[" +
+            "{\"name\":\"RendererTest\",\"category\":\"unit\",\"counters\":[" +
+            "{\"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\",\"MaxConcurrency\":\"1.0\"}]}]}", out.toString());
     }
 
     @Test
-    public void renderToCSV()
-        throws Exception {
+    public void renderToCSV() throws Exception {
         final StringWriter out = new StringWriter();
-        final Visitor v = new FormattingVisitor(Format.Defaults.CSV, new PrintWriter(out), RoleFilter.Defaults.FAILURES);
-        repository.accept(v);
+        Format.Defaults.CSV.render(new PrintWriter(out), Collections.<String, Object>emptyMap());
 
         assertEquals(CSVFormat.HEADER +
-            "RendererTest;unit;failures;1.0;1.0;1.0;1.0;0.0;1.0;0.0;0.0;0.0;1.0;1.0;1.0\n",
+            "RendererTest;unit;failures (u);1.0;1.0;1.0;1.0;0.0;1.0;0.0;0.0;0.0;1.0;1.0;1.0\n",
             out.toString());
     }
 }