[MRM-1580] system status page current scanner stats. fix average value.

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1299907 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-03-12 22:26:12 +00:00
parent f425272a22
commit 56ed8dbfef
5 changed files with 28 additions and 10 deletions

View 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;
}
}

View 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;
}
}

View 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 );

View 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}));
}
});

View File

@ -418,7 +418,7 @@
<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>
@ -443,7 +443,7 @@
<th>Name</th>
<th>Total</th>
<th>Average</th>
<th>Invocations</th>
<th>Invocations time</th>
</tr>
</thead>
<tbody>
@ -451,7 +451,7 @@
<tr>
<td>${consumerScanningStatistics.consumerKey}</td>
<td>${consumerScanningStatistics.count}</td>
<td></td>
<td>${consumerScanningStatistics.average}</td>
<td>${consumerScanningStatistics.time}</td>
</tr>
{{/each}}