]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1580] system status page current scanner stats. fix average value.
authorOlivier Lamy <olamy@apache.org>
Mon, 12 Mar 2012 22:26:12 +0000 (22:26 +0000)
committerOlivier Lamy <olamy@apache.org>
Mon, 12 Mar 2012 22:26:12 +0000 (22:26 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1299907 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ConsumerScanningStatistics.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSystemStatusService.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ManagedRepositoriesServiceTest.java
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/general-admin.html

index 1df24589b0dbf4790071c3d6f5b096a8a27baf53..73e94135d90f8b70238bac1e1300a2022015de11 100644 (file)
@@ -34,6 +34,8 @@ public class ConsumerScanningStatistics
 
     private long time;
 
+    private String average;
+
     public ConsumerScanningStatistics()
     {
         // no op
@@ -68,4 +70,14 @@ public class ConsumerScanningStatistics
     {
         this.time = time;
     }
+
+    public String getAverage()
+    {
+        return average;
+    }
+
+    public void setAverage( String average )
+    {
+        this.average = average;
+    }
 }
index a8cca6993fb5b42b195a28667202eed5bd15c81f..404f3434cc52d897860de7906a800f7ca756db8f 100644 (file)
@@ -26,6 +26,7 @@ import org.apache.archiva.rest.api.model.QueueEntry;
 import org.apache.archiva.rest.api.model.RepositoryScannerStatistics;
 import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
 import org.apache.archiva.rest.api.services.SystemStatusService;
+import org.apache.archiva.rest.services.utils.ConsumerScanningStatisticsComparator;
 import org.codehaus.plexus.cache.Cache;
 import org.codehaus.plexus.cache.CacheStatistics;
 import org.codehaus.plexus.taskqueue.TaskQueue;
@@ -184,6 +185,7 @@ public class DefaultSystemStatusService
 
     private List<ConsumerScanningStatistics> mapConsumerScanningStatistics( RepositoryScannerInstance instance )
     {
+        DecimalFormat decimalFormat = new DecimalFormat( "###.##" );
         // FIXME take care of NPE here !!!
         List<ConsumerScanningStatistics> ret =
             new ArrayList<ConsumerScanningStatistics>( instance.getConsumerCounts().size() );
@@ -193,8 +195,14 @@ public class DefaultSystemStatusService
             consumerScanningStatistics.setConsumerKey( entry.getKey() );
             consumerScanningStatistics.setCount( entry.getValue() );
             consumerScanningStatistics.setTime( instance.getConsumerTimings().get( entry.getKey() ) );
+            if ( consumerScanningStatistics.getCount() > 0 )
+            {
+                consumerScanningStatistics.setAverage( decimalFormat.format(
+                    consumerScanningStatistics.getTime() / consumerScanningStatistics.getCount() ) );
+            }
             ret.add( consumerScanningStatistics );
         }
+        Collections.sort( ret, ConsumerScanningStatisticsComparator.INSTANCE );
         return ret;
     }
 }
index b4530af8ae1d7bc3b9fb64b6027f3598b3fc587e..684b8529bd5cf4226fbd957abbce22cfefa7ca34 100644 (file)
@@ -140,7 +140,8 @@ public class ManagedRepositoriesServiceTest
 
         ManagedRepositoriesService service = getManagedRepositoriesService( authorizationHeader );
 
-        ArchivaRepositoryStatistics archivaRepositoryStatistics = service.getManagedRepositoryStatistics( testRepoId );
+        ArchivaRepositoryStatistics archivaRepositoryStatistics =
+            service.getManagedRepositoryStatistics( testRepoId, "en" );
 
         assertNotNull( archivaRepositoryStatistics );
 
index 9eea3062217a1d09d666b86a2ec4974fa958d60e..96818a33b752acc29f1e8e8df0683d38de224b4a 100644 (file)
@@ -691,15 +691,12 @@ $(function() {
         }
     });
 
-    var dataStr='[{"managedRepository":{"id":"snapshots","name":"Archiva Managed Snapshot Repository","layout":"default","indexDirectory":null,"location":"/Users/olamy/dev/tests/archiva-appserver-base-test/data/repositories/snapshots","snapshots":true,"releases":false,"blockRedeployments":false,"cronExpression":"0 0,30 * * * ?","stagingRepository":null,"scanned":true,"daysOlder":30,"retentionCount":2,"deleteReleasedSnapshots":false,"stageRepoNeeded":false,"resetStats":false},"consumerScanningStatistics":[{"consumerKey":"create-missing-checksums","count":83,"time":137},{"consumerKey":"metadata-updater","count":83,"time":192},{"consumerKey":"duplicate-artifacts","count":10,"time":2788},{"consumerKey":"index-content","count":134,"time":10},{"consumerKey":"create-archiva-metadata","count":82,"time":9399}],"totalFileCount":403,"newFileCount":403},{"managedRepository":{"id":"internal","name":"the Archiva Managed Internal Repository","layout":"default","indexDirectory":null,"location":"/Users/olamy/dev/tests/archiva-appserver-base-test/data/repositories/internal","snapshots":false,"releases":true,"blockRedeployments":true,"cronExpression":"0 */5 * * * ?","stagingRepository":null,"scanned":true,"daysOlder":30,"retentionCount":2,"deleteReleasedSnapshots":false,"stageRepoNeeded":false,"resetStats":false},"consumerScanningStatistics":[{"consumerKey":"create-missing-checksums","count":12,"time":2206},{"consumerKey":"metadata-updater","count":12,"time":1261},{"consumerKey":"duplicate-artifacts","count":12,"time":3461},{"consumerKey":"index-content","count":19,"time":0},{"consumerKey":"create-archiva-metadata","count":11,"time":3615}],"totalFileCount":58,"newFileCount":58}]';
-    var data= mapRepositoryScannerStatisticsList( $.parseJSON(dataStr));
-    $.log("size:"+data.length);
-    mainContent.find("#status_scanning" ).html($("#status_scanning_tmpl").tmpl({repositoryScannerStatisticsList:data}));
-
     $.ajax("restServices/archivaServices/systemStatusService/repositoryScannerStatistics", {
         type: "GET",
         success: function(data){
-          //mainContent.find("#status_scanning" ).html("#status_scanning_tmpl" ).tmpl(data);
+          var stats= mapRepositoryScannerStatisticsList(data);
+          $.log("size:"+data.length);
+          mainContent.find("#status_scanning" ).html($("#status_scanning_tmpl").tmpl({repositoryScannerStatisticsList:stats}));
         }
     });
 
index 833b157d8f712492379b6a458890bb786d7fd9b1..6ce314f4bb5b670d6d00b1f81697d213d42ae24a 100644 (file)
 
 <script id="status_scanning_tmpl" type="text/html">
   {{if repositoryScannerStatisticsList.length == 0}}
-    <p>No scans in progress.</p>
+    <h5>No scans in progress.</h5>
   {{else}}
     <table class="table table-condensed">
       <thead>
                   <th>Name</th>
                   <th>Total</th>
                   <th>Average</th>
-                  <th>Invocations</th>
+                  <th>Invocations time</th>
                 </tr>
               </thead>
               <tbody>
                 <tr>
                   <td>${consumerScanningStatistics.consumerKey}</td>
                   <td>${consumerScanningStatistics.count}</td>
-                  <td></td>
+                  <td>${consumerScanningStatistics.average}</td>
                   <td>${consumerScanningStatistics.time}</td>
                 </tr>
                 {{/each}}