commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nico...@apache.org
Subject svn commit: r645785 - in /commons/sandbox/monitoring/trunk/src: main/java/org/apache/commons/monitoring/reporting/ test/resources/org/apache/commons/monitoring/reporting/
Date Tue, 08 Apr 2008 08:01:43 GMT
Author: nicolas
Date: Tue Apr  8 01:01:38 2008
New Revision: 645785

URL: http://svn.apache.org/viewvc?rev=645785&view=rev
Log:
fix rendering (JSON)

Modified:
    commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/reporting/AbstractPeriodicLogger.java
    commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/reporting/AbstractRenderer.java
    commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/reporting/JsonRenderer.java
    commons/sandbox/monitoring/trunk/src/test/resources/org/apache/commons/monitoring/reporting/RendererTest.js

Modified: commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/reporting/AbstractPeriodicLogger.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/reporting/AbstractPeriodicLogger.java?rev=645785&r1=645784&r2=645785&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/reporting/AbstractPeriodicLogger.java
(original)
+++ commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/reporting/AbstractPeriodicLogger.java
Tue Apr  8 01:01:38 2008
@@ -97,9 +97,17 @@
         }
     }
 
+    /**
+     * Warn when logging the repository failed.
+     * <p>
+     * This method is expected to be override by user to avoid System.err outputs
+     * and use the application logging strategy.
+     *
+     * @param t error during logging
+     */
     protected void handleError( Throwable t )
     {
-        // ignored
+        System.err.println( "Failure to log observed repository : " + t.getMessage() );
     }
 
     /**

Modified: commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/reporting/AbstractRenderer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/reporting/AbstractRenderer.java?rev=645785&r1=645784&r2=645785&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/reporting/AbstractRenderer.java
(original)
+++ commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/reporting/AbstractRenderer.java
Tue Apr  8 01:01:38 2008
@@ -33,7 +33,6 @@
 import org.apache.commons.monitoring.Unit;
 import org.apache.commons.monitoring.Monitor.Key;
 import org.apache.commons.monitoring.listeners.Detachable;
-import org.apache.commons.monitoring.listeners.SecondaryMonitor;
 
 /**
  * Render a collection of monitor for reporting
@@ -100,15 +99,15 @@
 
     protected abstract void renderDetached( Context ctx, Detachable detached, Options options
);
 
-    protected void renderStatValues( Context ctx, Monitor monitor, Options options, List<String>
roles )
-    {
-        renderStatValues( ctx, monitor, options );
-    }
-
     @SuppressWarnings( "unchecked" )
     protected void renderStatValues( Context ctx, Monitor monitor, Options options )
     {
         List<String> roles = (List<String>) ctx.get( "roles" );
+        renderStatValues( ctx, monitor, options, roles );
+    }
+
+    protected void renderStatValues( Context ctx, Monitor monitor, Options options, List<String>
roles )
+    {
         for ( Iterator<String> iterator = roles.iterator(); iterator.hasNext(); )
         {
             String role = iterator.next();

Modified: commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/reporting/JsonRenderer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/reporting/JsonRenderer.java?rev=645785&r1=645784&r2=645785&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/reporting/JsonRenderer.java
(original)
+++ commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/reporting/JsonRenderer.java
Tue Apr  8 01:01:38 2008
@@ -25,7 +25,6 @@
 import org.apache.commons.monitoring.StatValue;
 import org.apache.commons.monitoring.Monitor.Key;
 import org.apache.commons.monitoring.listeners.Detachable;
-import org.apache.commons.monitoring.listeners.SecondaryMonitor;
 
 public class JsonRenderer
     extends AbstractRenderer
@@ -39,7 +38,7 @@
     }
 
     @Override
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     protected void hasNext( Context ctx, Class type )
     {
         ctx.print( "," );
@@ -51,39 +50,31 @@
         render( ctx, monitor, options );
     }
 
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     @Override
     public void render( Context ctx, Monitor monitor, Options options )
     {
         ctx.print( "{" );
-        renderStatValues( ctx, monitor, options );
-        Collection<String> roles = (Collection<String>) ctx.get( "roles" );
-        if ( roles.size() > 0 )
-        {
-            ctx.print( "," );
-        }
-        if ( isDetatched( monitor ) )
-        {
-            renderDetached( ctx, (Detachable) monitor, options );
-            ctx.print( "," );
-        }
-        render( ctx, monitor.getKey() );
+        super.render( ctx, monitor, options );
         ctx.print( "}" );
     }
 
     /**
      * {@inheritDoc}
-     * @see org.apache.commons.monitoring.reporting.AbstractRenderer#renderDetached(org.apache.commons.monitoring.reporting.Context,
org.apache.commons.monitoring.listeners.SecondaryMonitor, org.apache.commons.monitoring.reporting.Renderer.Options)
+     *
+     * @see org.apache.commons.monitoring.reporting.AbstractRenderer#renderDetached(org.apache.commons.monitoring.reporting.Context,
+     * org.apache.commons.monitoring.listeners.SecondaryMonitor,
+     * org.apache.commons.monitoring.reporting.Renderer.Options)
      */
     @Override
     protected void renderDetached( Context ctx, Detachable detached, Options options )
     {
         ctx.print( "period:{from:" );
-        ctx.print( options.getDateFormat().format( new Date( detached.getAttachedAt()) )
);
+        ctx.print( options.getDateFormat().format( new Date( detached.getAttachedAt() ) )
);
         ctx.print( "," );
         ctx.print( "to:" );
-        ctx.print( options.getDateFormat().format( new Date( detached.getDetachedAt()) )
);
-        ctx.print( "}" );
+        ctx.print( options.getDateFormat().format( new Date( detached.getDetachedAt() ) )
);
+        ctx.print( "}," );
     }
 
     @Override
@@ -104,6 +95,23 @@
         ctx.print( "\"}" );
     }
 
+    /**
+     * {@inheritDoc}
+     *
+     * @see org.apache.commons.monitoring.reporting.AbstractRenderer#renderStatValues(org.apache.commons.monitoring.reporting.Context,
+     * org.apache.commons.monitoring.Monitor,
+     * org.apache.commons.monitoring.reporting.Renderer.Options)
+     */
+    @Override
+    protected void renderStatValues( Context ctx, Monitor monitor, Options options, List<String>
roles  )
+    {
+        if ( roles.size() > 0 )
+        {
+            ctx.print( "," );
+        }
+        super.renderStatValues( ctx, monitor, options, roles );
+    }
+
     @Override
     public void render( Context ctx, StatValue value, Options options )
     {
@@ -117,13 +125,13 @@
     protected void render( Context ctx, StatValue value, String attribute, Number number,
Options options, int ratio )
     {
         StatValue currentValue = (StatValue) ctx.get( "currentValue" );
-        if (currentValue != value)
+        if ( currentValue != value )
         {
             ctx.put( "currentValue", value );
             ctx.put( "firstAttribute", Boolean.TRUE );
         }
         Boolean firstAttribute = (Boolean) ctx.get( "firstAttribute" );
-        if (!firstAttribute.booleanValue())
+        if ( !firstAttribute.booleanValue() )
         {
             ctx.print( "," );
         }

Modified: commons/sandbox/monitoring/trunk/src/test/resources/org/apache/commons/monitoring/reporting/RendererTest.js
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/src/test/resources/org/apache/commons/monitoring/reporting/RendererTest.js?rev=645785&r1=645784&r2=645785&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/src/test/resources/org/apache/commons/monitoring/reporting/RendererTest.js
(original)
+++ commons/sandbox/monitoring/trunk/src/test/resources/org/apache/commons/monitoring/reporting/RendererTest.js
Tue Apr  8 01:01:38 2008
@@ -1,15 +1,15 @@
 [
 
 {
+key:{name:"JsonRendererTest.setUp",category:"test",subsystem:"reporting"},
 concurrency:{min:"0",max:"0",mean:"-",deviation:"-",value:"0"},
-performances:{hits:"1",sum:"10",min:"10",max:"10",mean:"10.00",deviation:"-",value:"10"},
-key:{name:"JsonRendererTest.setUp",category:"test",subsystem:"reporting"}
+performances:{hits:"1",sum:"10",min:"10",max:"10",mean:"10.00",deviation:"-",value:"10"}
 },
 
 {
+key:{name:"TestCase",category:"test",subsystem:"junit"},
 concurrency:{min:"1",max:"1",mean:"0.00",deviation:"-",value:"1"},
-performances:{hits:"0",sum:"0",min:"0",max:"0",mean:"-",deviation:"-",value:"0"},
-key:{name:"TestCase",category:"test",subsystem:"junit"}
+performances:{hits:"0",sum:"0",min:"0",max:"0",mean:"-",deviation:"-",value:"0"}
 }
 
 ]



Mime
View raw message