Search in sources :

Example 1 with DefaultRepositoryStatistics

use of org.apache.archiva.metadata.repository.stats.model.DefaultRepositoryStatistics 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)

Example 2 with DefaultRepositoryStatistics

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

the class RepositoryStatisticsManagerTest method addStats.

private void addStats(Date startTime, Date endTime) throws Exception {
    DefaultRepositoryStatistics stats = createTestStats(startTime, endTime);
    metadataRepository.addMetadataFacet(TEST_REPO_ID, stats);
    statsCreated.put(stats.getName(), stats);
}
Also used : DefaultRepositoryStatistics(org.apache.archiva.metadata.repository.stats.model.DefaultRepositoryStatistics)

Example 3 with DefaultRepositoryStatistics

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

the class TestRepositoryStatisticsManager method addStatisticsAfterScan.

@Override
public void addStatisticsAfterScan(MetadataRepository metadataRepository, String repositoryId, Date startTime, Date endTime, long totalFiles, long newFiles) {
    List<RepositoryStatistics> stats = getStatsList(repositoryId);
    DefaultRepositoryStatistics repositoryStatistics = new DefaultRepositoryStatistics();
    repositoryStatistics.setScanStartTime(startTime);
    repositoryStatistics.setScanEndTime(endTime);
    repositoryStatistics.setNewFileCount(newFiles);
    repositoryStatistics.setTotalFileCount(totalFiles);
    repositoryStatistics.setRepositoryId(repositoryId);
    stats.add(repositoryStatistics);
}
Also used : RepositoryStatistics(org.apache.archiva.metadata.repository.stats.model.RepositoryStatistics) DefaultRepositoryStatistics(org.apache.archiva.metadata.repository.stats.model.DefaultRepositoryStatistics) DefaultRepositoryStatistics(org.apache.archiva.metadata.repository.stats.model.DefaultRepositoryStatistics)

Example 4 with DefaultRepositoryStatistics

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

the class ArchivaRepositoryScanningTaskExecutorPhase2Test method createAndSaveTestStats.

private void createAndSaveTestStats() throws MetadataRepositoryException {
    Date date = Calendar.getInstance().getTime();
    DefaultRepositoryStatistics stats = new DefaultRepositoryStatistics();
    stats.setScanStartTime(new Date(date.getTime() - 1234567));
    stats.setScanEndTime(date);
    stats.setNewFileCount(31);
    stats.setTotalArtifactCount(8);
    stats.setTotalFileCount(31);
    stats.setTotalGroupCount(3);
    stats.setTotalProjectCount(5);
    stats.setTotalArtifactFileSize(38545);
    // 
    repositoryStatisticsManager.addStatisticsAfterScan(// 
    metadataRepository, // 
    TEST_REPO_ID, // 
    new Date(date.getTime() - 1234567), date, 31, 31);
}
Also used : Date(java.util.Date) DefaultRepositoryStatistics(org.apache.archiva.metadata.repository.stats.model.DefaultRepositoryStatistics)

Example 5 with DefaultRepositoryStatistics

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

the class JcrRepositoryStatisticsGatheringTest method testJcrStatisticsQuery.

@Test
public void testJcrStatisticsQuery() throws Exception {
    Calendar cal = Calendar.getInstance();
    Date endTime = cal.getTime();
    cal.add(Calendar.HOUR, -1);
    Date startTime = cal.getTime();
    loadContentIntoRepo(TEST_REPO);
    loadContentIntoRepo("another-repo");
    DefaultRepositoryStatistics testedStatistics = new DefaultRepositoryStatistics();
    testedStatistics.setNewFileCount(NEW_FILE_COUNT);
    testedStatistics.setTotalFileCount(TOTAL_FILE_COUNT);
    testedStatistics.setScanStartTime(startTime);
    testedStatistics.setScanEndTime(endTime);
    repository.populateStatistics(repository, TEST_REPO, testedStatistics);
    DefaultRepositoryStatistics expectedStatistics = new DefaultRepositoryStatistics();
    expectedStatistics.setNewFileCount(NEW_FILE_COUNT);
    expectedStatistics.setTotalFileCount(TOTAL_FILE_COUNT);
    expectedStatistics.setScanEndTime(endTime);
    expectedStatistics.setScanStartTime(startTime);
    expectedStatistics.setTotalArtifactFileSize(95954585);
    expectedStatistics.setTotalArtifactCount(269);
    expectedStatistics.setTotalGroupCount(1);
    expectedStatistics.setTotalProjectCount(43);
    expectedStatistics.setTotalCountForType("zip", 1);
    // FIXME: should be tar.gz
    expectedStatistics.setTotalCountForType("gz", 1);
    expectedStatistics.setTotalCountForType("java-source", 10);
    expectedStatistics.setTotalCountForType("jar", 108);
    expectedStatistics.setTotalCountForType("xml", 3);
    expectedStatistics.setTotalCountForType("war", 2);
    expectedStatistics.setTotalCountForType("pom", 144);
    expectedStatistics.setRepositoryId(TEST_REPO);
    logger.info("getTotalCountForType: {}", testedStatistics.getTotalCountForType());
    assertEquals(NEW_FILE_COUNT, testedStatistics.getNewFileCount());
    assertEquals(TOTAL_FILE_COUNT, testedStatistics.getTotalFileCount());
    assertEquals(endTime, testedStatistics.getScanEndTime());
    assertEquals(startTime, testedStatistics.getScanStartTime());
    assertEquals(95954585, testedStatistics.getTotalArtifactFileSize());
    assertEquals(269, testedStatistics.getTotalArtifactCount());
    assertEquals(1, testedStatistics.getTotalGroupCount());
    assertEquals(43, testedStatistics.getTotalProjectCount());
    assertEquals(1, testedStatistics.getTotalCountForType("zip"));
    assertEquals(1, testedStatistics.getTotalCountForType("gz"));
    assertEquals(10, testedStatistics.getTotalCountForType("java-source"));
    assertEquals(108, testedStatistics.getTotalCountForType("jar"));
    assertEquals(3, testedStatistics.getTotalCountForType("xml"));
    assertEquals(2, testedStatistics.getTotalCountForType("war"));
    assertEquals(144, testedStatistics.getTotalCountForType("pom"));
    assertEquals(10, testedStatistics.getTotalCountForType("java-source"));
}
Also used : Calendar(java.util.Calendar) Date(java.util.Date) DefaultRepositoryStatistics(org.apache.archiva.metadata.repository.stats.model.DefaultRepositoryStatistics) AbstractMetadataRepositoryTest(org.apache.archiva.metadata.repository.AbstractMetadataRepositoryTest) Test(org.junit.Test)

Aggregations

DefaultRepositoryStatistics (org.apache.archiva.metadata.repository.stats.model.DefaultRepositoryStatistics)8 Date (java.util.Date)4 Test (org.junit.Test)3 RepositoryStatistics (org.apache.archiva.metadata.repository.stats.model.RepositoryStatistics)2 Calendar (java.util.Calendar)1 AbstractMetadataRepositoryTest (org.apache.archiva.metadata.repository.AbstractMetadataRepositoryTest)1 RepositoryStatisticsProvider (org.apache.archiva.metadata.repository.stats.model.RepositoryStatisticsProvider)1