mirror of https://github.com/apache/archiva.git
[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
This commit is contained in:
parent
157f00698d
commit
ffded4338d
|
@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,6 +47,16 @@
|
|||
<multiplicity>*</multiplicity>
|
||||
</association>
|
||||
</field>
|
||||
<field xml.attribute="true">
|
||||
<name>lastModified</name>
|
||||
<version>1.0.0</version>
|
||||
<type>Date</type>
|
||||
</field>
|
||||
<field xml.attribute="true">
|
||||
<name>executionTime</name>
|
||||
<version>1.0.0</version>
|
||||
<type>long</type>
|
||||
</field>
|
||||
</fields>
|
||||
</class>
|
||||
<class>
|
||||
|
|
|
@ -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" %>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Repository Health</title>
|
||||
<%-- TODO! change the name --%>
|
||||
<title>Report: Repository Health</title>
|
||||
<ww:head/>
|
||||
</head>
|
||||
|
||||
|
@ -30,7 +32,7 @@
|
|||
|
||||
<div id="contentArea">
|
||||
|
||||
<ww:actionerror/>
|
||||
<%-- TODO!: select report, repository and filter --%>
|
||||
|
||||
<ww:set name="databases" value="databases"/>
|
||||
<c:forEach items="${databases}" var="database">
|
||||
|
@ -64,6 +66,13 @@
|
|||
${database.numFailures}
|
||||
<img src="<c:url value="/images/icon_warning_sml.gif"/>" width="15" height="15" alt=""/>
|
||||
${database.numWarnings}
|
||||
|
||||
<span style="font-size: x-small">
|
||||
<%-- TODO! use better formatting here --%>
|
||||
Last updated: ${database.reporting.lastModified},
|
||||
execution time: <fmt:formatNumber maxFractionDigits="0" value="${database.reporting.executionTime / 60000}"/> minutes
|
||||
<fmt:formatNumber maxFractionDigits="0" value="${(database.reporting.executionTime / 1000) % 60}"/> seconds
|
||||
</span>
|
||||
</p>
|
||||
|
||||
<%-- TODO need to protect iterations against concurrent modification exceptions by cloning the lists synchronously --%>
|
||||
|
|
|
@ -51,10 +51,6 @@
|
|||
</tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
<span style="font-size: x-small">Report finished: 12 Jun 2006 10:11:12, execution time: 10 minutes 15 seconds
|
||||
</span>
|
||||
</p>
|
||||
<div>
|
||||
<div style="float: right">
|
||||
<a href="#">Repair all</a>
|
||||
|
@ -69,6 +65,8 @@
|
|||
2
|
||||
<img src="images/icon_warning_sml.gif" width="15" height="15" alt=""/>
|
||||
1
|
||||
<span style="font-size: x-small">Report finished: 12 Jun 2006 10:11:12, execution time: 10 minutes 15 seconds
|
||||
</span>
|
||||
</p>
|
||||
|
||||
<h3>Artifacts</h3>
|
||||
|
@ -136,6 +134,8 @@
|
|||
2
|
||||
<img src="images/icon_warning_sml.gif" width="15" height="15" alt=""/>
|
||||
0
|
||||
<span style="font-size: x-small">Report finished: 12 Jun 2006 10:11:12, execution time: 10 minutes 15 seconds
|
||||
</span>
|
||||
</p>
|
||||
|
||||
<h3>Artifacts</h3>
|
||||
|
|
Loading…
Reference in New Issue