You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sirona.apache.org by ol...@apache.org on 2014/08/26 09:10:00 UTC
svn commit: r1620520 - in /incubator/sirona/trunk: ./
agent/performance/web/src/main/java/org/apache/sirona/web/discovery/
server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/gauge/
server/reporting/reporting-ui/src/main/webapp...
Author: olamy
Date: Tue Aug 26 07:10:00 2014
New Revision: 1620520
URL: http://svn.apache.org/r1620520
Log:
gauge details
Added:
incubator/sirona/trunk/reportingUiDebug.sh (with props)
incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/gauge/GaugeInfo.java (with props)
incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/gauge/GaugeResult.java (with props)
incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/gauge/GaugeValue.java (with props)
incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/gauge-detail.html
- copied, changed from r1620519, incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/gauges.html
Modified:
incubator/sirona/trunk/agent/performance/web/src/main/java/org/apache/sirona/web/discovery/GaugeDiscoveryListener.java
incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/gauge/GaugeService.java
incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/controllers/controllers-gauges.js
incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/services/services.js
incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/sirona.js
incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/gauges.html
Modified: incubator/sirona/trunk/agent/performance/web/src/main/java/org/apache/sirona/web/discovery/GaugeDiscoveryListener.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/performance/web/src/main/java/org/apache/sirona/web/discovery/GaugeDiscoveryListener.java?rev=1620520&r1=1620519&r2=1620520&view=diff
==============================================================================
--- incubator/sirona/trunk/agent/performance/web/src/main/java/org/apache/sirona/web/discovery/GaugeDiscoveryListener.java (original)
+++ incubator/sirona/trunk/agent/performance/web/src/main/java/org/apache/sirona/web/discovery/GaugeDiscoveryListener.java Tue Aug 26 07:10:00 2014
@@ -92,7 +92,9 @@ public class GaugeDiscoveryListener impl
} else {
prefixes = null;
}
- helper = new Gauge.LoaderHelper("true".equals(sce.getServletContext().getInitParameter("monitoring.discovery.exclude-parent")), gauges.values(), prefixes);
+ helper = new Gauge.LoaderHelper("true".equals(sce.getServletContext().getInitParameter("monitoring.discovery.exclude-parent")), //
+ gauges.values(), //
+ prefixes);
}
@Override
Added: incubator/sirona/trunk/reportingUiDebug.sh
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/reportingUiDebug.sh?rev=1620520&view=auto
==============================================================================
--- incubator/sirona/trunk/reportingUiDebug.sh (added)
+++ incubator/sirona/trunk/reportingUiDebug.sh Tue Aug 26 07:10:00 2014
@@ -0,0 +1 @@
+mvnDebug process-test-resources tomcat7:run -pl :sirona-reporting-ui -am
Propchange: incubator/sirona/trunk/reportingUiDebug.sh
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/sirona/trunk/reportingUiDebug.sh
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/gauge/GaugeInfo.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/gauge/GaugeInfo.java?rev=1620520&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/gauge/GaugeInfo.java (added)
+++ incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/gauge/GaugeInfo.java Tue Aug 26 07:10:00 2014
@@ -0,0 +1,40 @@
+package org.apache.sirona.reporting.web.gauge;
+
+import java.io.Serializable;
+
+/**
+ * @since 0.3
+ */
+public class GaugeInfo
+ implements Serializable
+{
+
+ private final String name;
+
+ private final String encodedName;
+
+ public GaugeInfo( String name, String encodedName )
+ {
+ this.name = name;
+ this.encodedName = encodedName;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getEncodedName()
+ {
+ return encodedName;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "GaugeInfo{" +
+ "name='" + name + '\'' +
+ ", encodedName='" + encodedName + '\'' +
+ '}';
+ }
+}
Propchange: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/gauge/GaugeInfo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/gauge/GaugeInfo.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/gauge/GaugeResult.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/gauge/GaugeResult.java?rev=1620520&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/gauge/GaugeResult.java (added)
+++ incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/gauge/GaugeResult.java Tue Aug 26 07:10:00 2014
@@ -0,0 +1,41 @@
+package org.apache.sirona.reporting.web.gauge;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @author Olivier Lamy
+ */
+public class GaugeResult
+ implements Serializable
+{
+
+ private final String gaugeName;
+
+ private final List<GaugeValue> gaugeValues;
+
+ public GaugeResult( String gaugeName, List<GaugeValue> gaugeValues )
+ {
+ this.gaugeName = gaugeName;
+ this.gaugeValues = gaugeValues;
+ }
+
+ public String getGaugeName()
+ {
+ return gaugeName;
+ }
+
+ public List<GaugeValue> getGaugeValues()
+ {
+ return gaugeValues;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "GaugeResult{" +
+ "gaugeName='" + gaugeName + '\'' +
+ ", gaugeValues=" + gaugeValues +
+ '}';
+ }
+}
Propchange: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/gauge/GaugeResult.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/gauge/GaugeResult.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/gauge/GaugeService.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/gauge/GaugeService.java?rev=1620520&r1=1620519&r2=1620520&view=diff
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/gauge/GaugeService.java (original)
+++ incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/gauge/GaugeService.java Tue Aug 26 07:10:00 2014
@@ -22,12 +22,17 @@ import org.apache.sirona.repositories.Re
import javax.ws.rs.GET;
import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
import java.net.URLEncoder;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
import java.util.Map;
+import java.util.SortedMap;
import java.util.TreeMap;
/**
@@ -40,15 +45,42 @@ public class GaugeService
@GET
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
- public Map<String, String> all()
+ public Collection<GaugeInfo> all()
{
return sortNames( Repository.INSTANCE.gauges() );
}
+ @GET
+ @Path( "/{gaugeName}/{start}/{end}" )
+ @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+ public GaugeResult find( @PathParam( "gaugeName" ) String encodedGaugeName, //
+ @PathParam( "start" ) final long start, //
+ @PathParam( "end" ) final long end )
+ {
+
+ String gaugeName = decode( encodedGaugeName );
+
+ Role role = Repository.INSTANCE.findGaugeRole( gaugeName );
+ if ( role == null )
+ {
+ return null;
+ }
+ SortedMap<Long, Double> values = Repository.INSTANCE.getGaugeValues( start, end, role );
+
+ List<GaugeValue> gaugeValues = new ArrayList<GaugeValue>( values.size() );
+
+ for ( Map.Entry<Long, Double> entry : values.entrySet() )
+ {
+ gaugeValues.add( new GaugeValue( entry.getKey(), entry.getValue() ) );
+ }
+
+ return new GaugeResult( gaugeName, gaugeValues );
+
+ }
- private static Map<String, String> sortNames( final Collection<Role> gauges )
+ private static Collection<GaugeInfo> sortNames( final Collection<Role> gauges )
{
final Map<String, String> names = new TreeMap<String, String>();
for ( final Role gauge : gauges )
@@ -56,7 +88,15 @@ public class GaugeService
final String name = gauge.getName();
names.put( name, encode( name ) );
}
- return names;
+
+ Collection<GaugeInfo> out = new ArrayList<GaugeInfo>( names.size() );
+
+ for ( Map.Entry<String, String> entry : names.entrySet() )
+ {
+ out.add( new GaugeInfo( entry.getKey(), entry.getValue() ) );
+ }
+
+ return out;
}
private static String encode( final String role )
@@ -68,7 +108,19 @@ public class GaugeService
}
catch ( final UnsupportedEncodingException e )
{
- return base64; // shouldn't occur
+ return role; // shouldn't occur
+ }
+ }
+
+ private static String decode( final String base64Role )
+ {
+ try
+ {
+ return new String( Base64.decodeBase64( URLDecoder.decode( base64Role, UTF8 ) ) );
+ }
+ catch ( final UnsupportedEncodingException e )
+ {
+ return base64Role; // shouldn't occur
}
}
Added: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/gauge/GaugeValue.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/gauge/GaugeValue.java?rev=1620520&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/gauge/GaugeValue.java (added)
+++ incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/gauge/GaugeValue.java Tue Aug 26 07:10:00 2014
@@ -0,0 +1,40 @@
+package org.apache.sirona.reporting.web.gauge;
+
+import java.io.Serializable;
+
+/**
+ * @author Olivier Lamy
+ */
+public class GaugeValue
+ implements Serializable
+{
+
+ private final long timestamp;
+
+ private final double value;
+
+ public GaugeValue( long timestamp, double value )
+ {
+ this.timestamp = timestamp;
+ this.value = value;
+ }
+
+ public long getTimestamp()
+ {
+ return timestamp;
+ }
+
+ public double getValue()
+ {
+ return value;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "GaugeValue{" +
+ "timestamp=" + timestamp +
+ ", value=" + value +
+ '}';
+ }
+}
Propchange: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/gauge/GaugeValue.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/gauge/GaugeValue.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/controllers/controllers-gauges.js
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/controllers/controllers-gauges.js?rev=1620520&r1=1620519&r2=1620520&view=diff
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/controllers/controllers-gauges.js (original)
+++ incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/controllers/controllers-gauges.js Tue Aug 26 07:10:00 2014
@@ -19,6 +19,7 @@
/* Controllers */
define(['jquery','angular','bootstrap','services','morris','ui-bootstrap','datetimepicker'], function (){
+ var dayDuration = 24 * 3600 * 1000;
var jvmControllers = angular.module('gaugesControllers', ['sironaJvmServices','ui.bootstrap','ui.bootstrap.datetimepicker']);
@@ -27,20 +28,73 @@ define(['jquery','angular','bootstrap','
$scope.data={};
- var threadName=$routeParams.threadName;
-
- console.log("ThreadsHomeCtrl:"+threadName);
-
gauges.query().$promise.then(function(result){
- $scope.data.gauges=result;
+ $scope.data.gaugesInfo=result;
});
+ }]);
+
+ jvmControllers.controller( 'gaugeDetailCtrl', ['$scope','$routeParams','gaugesResults',
+ function ($scope,$routeParams,gauges){
+
+ $scope.data={};
+ $scope.data.startDate = new Date();
+ $scope.data.startDate.setTime($scope.data.startDate.getTime() - dayDuration);
+
+
+ $scope.data.endDate = new Date();
+ $scope.data.format = 'dd/MM/yyyy HH:mm:ss';
+ var gaugeName=$routeParams.gaugeName;
+
+ console.log("gaugeName:"+gaugeName);
+
+ var drawGauge = function(){
+
+ gauges.query({gaugeName: gaugeName,start:$scope.data.startDate.getTime(),end:$scope.data.endDate.getTime()})
+ .$promise.then(function(result){
+ $scope.data.gaugeResult=result;
+ var morrisDatas=toMorrisFormat(result.gaugeValues);
+ console.log("morrisDatas.length:"+morrisDatas.length);
+ jQuery("#gaugeresult").empty();
+ Morris.Line({
+ element: 'gaugeresult',
+ data: morrisDatas,
+ xkey: 'x',
+ ykeys: 'y',
+ labels: [result.gaugeName],
+ xLabelFormat:function(ret){
+ var date = new Date();
+ date.setTime(morrisDatas[ret.x].x);
+ return date.toLocaleString();
+ },
+ parseTime: false,
+ hideHover: 'auto'
+ });
+ });
+
+ };
+ drawGauge();
}]);
+ var toMorrisFormat=function(reportResult){
+ if (reportResult==null){
+ console.log("reportResult==null");
+ return [];
+ }
+ var values = [];
+ angular.forEach(reportResult, function(key,value) {
+ this.push({x:key.timestamp,y: key.value});
+ }, values);
+
+
+ return values;
+ }
+
+
});
Modified: incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/services/services.js
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/services/services.js?rev=1620520&r1=1620519&r2=1620520&view=diff
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/services/services.js (original)
+++ incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/services/services.js Tue Aug 26 07:10:00 2014
@@ -93,4 +93,12 @@ define(['angular','angular-resource'], f
}
]);
+ sironaServices.factory('gaugesResults', ['$resource',
+ function($resource){
+ return $resource('restServices/sironaServices/gauges/:gaugeName/:start/:end',
+ {},
+ {query: {method:'GET', params:{gaugeName:'@gaugeName',start:'@start',end:'@end'},isArray:false}});
+ }
+ ]);
+
});
\ No newline at end of file
Modified: incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/sirona.js
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/sirona.js?rev=1620520&r1=1620519&r2=1620520&view=diff
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/sirona.js (original)
+++ incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/sirona.js Tue Aug 26 07:10:00 2014
@@ -70,6 +70,12 @@ define(['jquery','controllers','controll
controller: 'GaugesHomeCtrl'
}
).
+ when('/gauges/:gaugeName',
+ {
+ templateUrl: 'partials/gauge-detail.html',
+ controller: 'gaugeDetailCtrl'
+ }
+ ).
otherwise({
redirectTo: '/home'
});
Copied: incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/gauge-detail.html (from r1620519, incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/gauges.html)
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/gauge-detail.html?p2=incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/gauge-detail.html&p1=incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/gauges.html&r1=1620519&r2=1620520&rev=1620520&view=diff
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/gauges.html (original)
+++ incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/gauge-detail.html Tue Aug 26 07:10:00 2014
@@ -15,5 +15,19 @@
limitations under the License.
-->
<div class="row">
- gauges
+ <div class="col-lg-12">
+ <div class="panel panel-primary">
+ <div class="panel-heading">
+ <h3 class="panel-title">
+ <i class="icon-bar-chart"></i>Gauge: {{::data.gaugeResult.gaugeName}}
+ </h3>
+ </div>
+ <div class="panel-body">
+ <div class="row">
+ <div id="gaugeresult"><i class="fa fa-spinner fa-spin"></i></div>
+ </div>
+ </div>
+
+ </div>
+ </div>
</div>
\ No newline at end of file
Modified: incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/gauges.html
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/gauges.html?rev=1620520&r1=1620519&r2=1620520&view=diff
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/gauges.html (original)
+++ incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/gauges.html Tue Aug 26 07:10:00 2014
@@ -15,5 +15,11 @@
limitations under the License.
-->
<div class="row">
- gauges
+ <div class="col-lg-12">
+ <ul>
+ <li ng-repeat="gaugeInfo in data.gaugesInfo">
+ <a href="#gauges/{{::gaugeInfo.encodedName}}">{{::gaugeInfo.name}}</a>
+ </li>
+ </ul>
+ </div>
</div>
\ No newline at end of file