diff options
author | Olivier Lamy <olamy@apache.org> | 2012-03-12 22:26:12 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2012-03-12 22:26:12 +0000 |
commit | 56ed8dbfef4607cd48a8087c271dbca313aaea65 (patch) | |
tree | ebfbd335fe64b5822be3b1514781042c0ef30257 /archiva-modules/archiva-web/archiva-rest | |
parent | f425272a22407892ab38a8f1e53b4b84b5160d7c (diff) | |
download | archiva-56ed8dbfef4607cd48a8087c271dbca313aaea65.tar.gz archiva-56ed8dbfef4607cd48a8087c271dbca313aaea65.zip |
[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
Diffstat (limited to 'archiva-modules/archiva-web/archiva-rest')
3 files changed, 22 insertions, 1 deletions
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ConsumerScanningStatistics.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ConsumerScanningStatistics.java index 1df24589b..73e94135d 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ConsumerScanningStatistics.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ConsumerScanningStatistics.java @@ -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; + } } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSystemStatusService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSystemStatusService.java index a8cca6993..404f3434c 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSystemStatusService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSystemStatusService.java @@ -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; } } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ManagedRepositoriesServiceTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ManagedRepositoriesServiceTest.java index b4530af8a..684b8529b 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ManagedRepositoriesServiceTest.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ManagedRepositoriesServiceTest.java @@ -140,7 +140,8 @@ public class ManagedRepositoriesServiceTest ManagedRepositoriesService service = getManagedRepositoriesService( authorizationHeader ); - ArchivaRepositoryStatistics archivaRepositoryStatistics = service.getManagedRepositoryStatistics( testRepoId ); + ArchivaRepositoryStatistics archivaRepositoryStatistics = + service.getManagedRepositoryStatistics( testRepoId, "en" ); assertNotNull( archivaRepositoryStatistics ); |