From ffded4338d5b787db49677d99cfae6dc8357d437 Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Sat, 9 Sep 2006 15:19:42 +0000 Subject: [PATCH] [MRM-167] add the execution times to the report git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@441795 13f79535-47bb-0310-9956-ffa450edef68 --- .../archiva/scheduler/task/IndexerTask.java | 11 ++++-- .../reporting/DefaultReportingStore.java | 3 +- .../archiva/reporting/ReportingDatabase.java | 35 +++++++++++++++++++ .../src/main/mdo/reporting.mdo | 10 ++++++ .../webapp/WEB-INF/jsp/reports/reports.jsp | 13 +++++-- design/white-site/src/site/xdoc/reports.xml | 8 ++--- 6 files changed, 71 insertions(+), 9 deletions(-) diff --git a/archiva-core/src/main/java/org/apache/maven/archiva/scheduler/task/IndexerTask.java b/archiva-core/src/main/java/org/apache/maven/archiva/scheduler/task/IndexerTask.java index 7850ea455..454a4dabb 100644 --- a/archiva-core/src/main/java/org/apache/maven/archiva/scheduler/task/IndexerTask.java +++ b/archiva-core/src/main/java/org/apache/maven/archiva/scheduler/task/IndexerTask.java @@ -32,6 +32,7 @@ import org.apache.maven.archiva.indexer.RepositoryIndexException; import org.apache.maven.archiva.indexer.record.IndexRecordExistsArtifactFilter; import org.apache.maven.archiva.indexer.record.RepositoryIndexRecordFactory; import org.apache.maven.archiva.reporting.ReportExecutor; +import org.apache.maven.archiva.reporting.ReportingDatabase; import org.apache.maven.archiva.reporting.ReportingMetadataFilter; import org.apache.maven.archiva.reporting.ReportingStoreException; import org.apache.maven.archiva.scheduler.TaskExecutionException; @@ -153,6 +154,11 @@ public class IndexerTask boolean includeSnapshots = repositoryConfiguration.isIncludeSnapshots(); ArtifactRepository repository = repoFactory.createRepository( repositoryConfiguration ); + ReportingDatabase reporter = reportExecutor.getReportDatabase( repository ); + + // keep original value in case there is another process under way + long origStartTime = reporter.getStartTime(); + reporter.setStartTime( System.currentTimeMillis() ); // Discovery process String layoutProperty = repositoryConfiguration.getLayout(); @@ -196,8 +202,7 @@ public class IndexerTask } } - MetadataFilter metadataFilter = - new ReportingMetadataFilter( reportExecutor.getReportDatabase( repository ) ); + MetadataFilter metadataFilter = new ReportingMetadataFilter( reporter ); MetadataDiscoverer metadataDiscoverer = (MetadataDiscoverer) metadataDiscoverers.get( layoutProperty ); @@ -211,6 +216,8 @@ public class IndexerTask // run the reports reportExecutor.runMetadataReports( metadata, repository ); } + + reporter.setStartTime( origStartTime ); } } } diff --git a/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/DefaultReportingStore.java b/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/DefaultReportingStore.java index 8d033e2e0..2e10e5550 100644 --- a/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/DefaultReportingStore.java +++ b/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/DefaultReportingStore.java @@ -99,6 +99,8 @@ public class DefaultReportingStore public void storeReports( ReportingDatabase database, ArtifactRepository repository ) throws ReportingStoreException { + database.updateTimings(); + ReportingXpp3Writer writer = new ReportingXpp3Writer(); File file = new File( repository.getBasedir(), "report-database.xml" ); @@ -120,5 +122,4 @@ public class DefaultReportingStore IOUtil.close( fileWriter ); } } - } diff --git a/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/ReportingDatabase.java b/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/ReportingDatabase.java index ba6ad5bf8..f4ac83081 100644 --- a/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/ReportingDatabase.java +++ b/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/ReportingDatabase.java @@ -24,6 +24,7 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.metadata.RepositoryMetadata; +import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -47,6 +48,8 @@ public class ReportingDatabase private boolean inProgress; + private long startTime; + public ReportingDatabase() { this( new Reporting(), null ); @@ -78,6 +81,7 @@ public class ReportingDatabase ArtifactResults results = getArtifactResults( artifact ); results.addFailure( createResults( reason ) ); numFailures++; + updateTimings(); } public void addWarning( Artifact artifact, String reason ) @@ -85,6 +89,7 @@ public class ReportingDatabase ArtifactResults results = getArtifactResults( artifact ); results.addWarning( createResults( reason ) ); numWarnings++; + updateTimings(); } private ArtifactResults getArtifactResults( Artifact artifact ) @@ -145,6 +150,7 @@ public class ReportingDatabase MetadataResults results = getMetadataResults( metadata, System.currentTimeMillis() ); results.addFailure( createResults( reason ) ); numFailures++; + updateTimings(); } public void addWarning( RepositoryMetadata metadata, String reason ) @@ -152,6 +158,7 @@ public class ReportingDatabase MetadataResults results = getMetadataResults( metadata, System.currentTimeMillis() ); results.addWarning( createResults( reason ) ); numWarnings++; + updateTimings(); } private void initMetadataMap() @@ -289,6 +296,11 @@ public class ReportingDatabase public void setInProgress( boolean inProgress ) { this.inProgress = inProgress; + + if ( inProgress ) + { + startTime = System.currentTimeMillis(); + } } public void clear() @@ -302,5 +314,28 @@ public class ReportingDatabase reporting.getArtifacts().clear(); reporting.getMetadata().clear(); + + updateTimings(); + } + + public void setStartTime( long startTime ) + { + this.startTime = startTime; + } + + public long getStartTime() + { + return startTime; + } + + public void updateTimings() + { + long startTime = getStartTime(); + Date endTime = new Date(); + if ( startTime > 0 ) + { + getReporting().setExecutionTime( endTime.getTime() - startTime ); + } + getReporting().setLastModified( endTime ); } } diff --git a/archiva-reports-standard/src/main/mdo/reporting.mdo b/archiva-reports-standard/src/main/mdo/reporting.mdo index a01032b94..575f1329d 100644 --- a/archiva-reports-standard/src/main/mdo/reporting.mdo +++ b/archiva-reports-standard/src/main/mdo/reporting.mdo @@ -47,6 +47,16 @@ * + + lastModified + 1.0.0 + Date + + + executionTime + 1.0.0 + long + diff --git a/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/reports.jsp b/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/reports.jsp index b5372cd2b..7e96731a3 100644 --- a/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/reports.jsp +++ b/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/reports.jsp @@ -16,11 +16,13 @@ <%@ taglib prefix="ww" uri="/webwork" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> - Repository Health + <%-- TODO! change the name --%> + Report: Repository Health @@ -30,7 +32,7 @@
- +<%-- TODO!: select report, repository and filter --%> @@ -64,6 +66,13 @@ ${database.numFailures} " width="15" height="15" alt=""/> ${database.numWarnings} + + + <%-- TODO! use better formatting here --%> + Last updated: ${database.reporting.lastModified}, + execution time: minutes + seconds +

<%-- TODO need to protect iterations against concurrent modification exceptions by cloning the lists synchronously --%> diff --git a/design/white-site/src/site/xdoc/reports.xml b/design/white-site/src/site/xdoc/reports.xml index 427e58326..82dd9405c 100644 --- a/design/white-site/src/site/xdoc/reports.xml +++ b/design/white-site/src/site/xdoc/reports.xml @@ -51,10 +51,6 @@ -

- Report finished: 12 Jun 2006 10:11:12, execution time: 10 minutes 15 seconds - -

Repair all @@ -69,6 +65,8 @@ 2 1 + Report finished: 12 Jun 2006 10:11:12, execution time: 10 minutes 15 seconds +

Artifacts

@@ -136,6 +134,8 @@ 2 0 + Report finished: 12 Jun 2006 10:11:12, execution time: 10 minutes 15 seconds +

Artifacts

-- 2.39.5