Search in sources :

Example 1 with RepositoryStatisticsProvider

use of org.apache.archiva.metadata.repository.stats.model.RepositoryStatisticsProvider in project archiva by apache.

the class DefaultRepositoryStatisticsManager method addStatisticsAfterScan.

@Override
public void addStatisticsAfterScan(MetadataRepository metadataRepository, String repositoryId, Date startTime, Date endTime, long totalFiles, long newFiles) throws MetadataRepositoryException {
    DefaultRepositoryStatistics repositoryStatistics = new DefaultRepositoryStatistics();
    repositoryStatistics.setRepositoryId(repositoryId);
    repositoryStatistics.setScanStartTime(startTime);
    repositoryStatistics.setScanEndTime(endTime);
    repositoryStatistics.setTotalFileCount(totalFiles);
    repositoryStatistics.setNewFileCount(newFiles);
    // TODO
    // In the future, instead of being tied to a scan we might want to record information in the fly based on
    // events that are occurring. Even without these totals we could query much of the information on demand based
    // on information from the metadata content repository. In the mean time, we lock information in at scan time.
    // Note that if new types are later discoverable due to a code change or new plugin, historical stats will not
    // be updated and the repository will need to be rescanned.
    long startGather = System.currentTimeMillis();
    if (metadataRepository instanceof RepositoryStatisticsProvider) {
        ((RepositoryStatisticsProvider) metadataRepository).populateStatistics(metadataRepository, repositoryId, repositoryStatistics);
    } else {
        walkingProvider.populateStatistics(metadataRepository, repositoryId, repositoryStatistics);
    }
    log.info("Gathering statistics executed in {} ms", (System.currentTimeMillis() - startGather));
    metadataRepository.addMetadataFacet(repositoryId, repositoryStatistics);
}
Also used : RepositoryStatisticsProvider(org.apache.archiva.metadata.repository.stats.model.RepositoryStatisticsProvider) DefaultRepositoryStatistics(org.apache.archiva.metadata.repository.stats.model.DefaultRepositoryStatistics)

Aggregations

DefaultRepositoryStatistics (org.apache.archiva.metadata.repository.stats.model.DefaultRepositoryStatistics)1 RepositoryStatisticsProvider (org.apache.archiva.metadata.repository.stats.model.RepositoryStatisticsProvider)1