]> source.dussan.org Git - archiva.git/commitdiff
[MRM-167] add the execution times to the report
authorBrett Porter <brett@apache.org>
Sat, 9 Sep 2006 15:19:42 +0000 (15:19 +0000)
committerBrett Porter <brett@apache.org>
Sat, 9 Sep 2006 15:19:42 +0000 (15:19 +0000)
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@441795 13f79535-47bb-0310-9956-ffa450edef68

archiva-core/src/main/java/org/apache/maven/archiva/scheduler/task/IndexerTask.java
archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/DefaultReportingStore.java
archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/ReportingDatabase.java
archiva-reports-standard/src/main/mdo/reporting.mdo
archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/reports.jsp
design/white-site/src/site/xdoc/reports.xml

index 7850ea4551274fb4196a45d918a2bfda1306ed7c..454a4dabb0d03a67f69854938b4eeedb8ffeeeb4 100644 (file)
@@ -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 );
                 }
             }
         }
index 8d033e2e0927a981665d21f7f478ea2b270f012a..2e10e5550c41b0187a1e450fbea5facc9a8b0309 100644 (file)
@@ -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 );
         }
     }
-
 }
index ba6ad5bf8b0839a915b04002a82309ed409bc0c2..f4ac8308173651e71cce258a099cc2cccb6826e1 100644 (file)
@@ -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 );
     }
 }
index a01032b947a5976a522a9182933b26fa3aafe67c..575f1329d94a6c839cd19bf6090ec90516cca86f 100644 (file)
             <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>
index b5372cd2bc98608f0c61dc38937151d0ab6ff173..7e96731a33b01997ca995449bc7d658bf38f76d2 100644 (file)
 
 <%@ 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">
     ${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 --%>
index 427e5832621d860609772828aa548c0352bb17c9..82dd9405c70e56bb5f08f8f45d86b473b019ea0e 100644 (file)
         </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>
           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>