Search in sources :

Example 1 with SearchIndexUpdateService

use of com.github.hakko.musiccabinet.service.lastfm.SearchIndexUpdateService in project musiccabinet by hakko.

the class LibraryUpdateService method getSearchIndexUpdateProgress.

public List<SearchIndexUpdateProgress> getSearchIndexUpdateProgress() {
    List<SearchIndexUpdateProgress> updateProgress = new ArrayList<>();
    updateProgress.addAll(libraryScannerService.getUpdateProgress());
    for (SearchIndexUpdateService updateService : getUpdateServices()) {
        updateProgress.add(updateService.getProgress());
    }
    return updateProgress;
}
Also used : SearchIndexUpdateProgress(com.github.hakko.musiccabinet.domain.model.aggr.SearchIndexUpdateProgress) ArrayList(java.util.ArrayList) SearchIndexUpdateService(com.github.hakko.musiccabinet.service.lastfm.SearchIndexUpdateService)

Example 2 with SearchIndexUpdateService

use of com.github.hakko.musiccabinet.service.lastfm.SearchIndexUpdateService in project musiccabinet by hakko.

the class LibraryUpdateService method updateLastFmData.

private void updateLastFmData(boolean onlyUpdateNewArtists) {
    LOG.debug("Starting last.fm update.");
    settingsService.setOnlyUpdateNewArtists(onlyUpdateNewArtists);
    long millis = -System.currentTimeMillis();
    executorService.updateSearchIndex(onlyUpdateNewArtists ? getUpdateServicesForNewArtists() : getUpdateServices());
    executorService.updateSearchIndex(asList(tagInfoService, // re-run for new tags
    tagTopArtistsService));
    millis += System.currentTimeMillis();
    int total = 0;
    for (SearchIndexUpdateService updateService : getUpdateServices()) {
        total += max(0, updateService.getProgress().getTotalOperations());
        LOG.info(updateService.getProgress().getTotalOperations() + " " + updateService.getUpdateDescription() + ".");
    }
    LOG.info("In total, " + total + " last.fm operations done in " + (millis / 1000) + " sec.");
}
Also used : SearchIndexUpdateService(com.github.hakko.musiccabinet.service.lastfm.SearchIndexUpdateService)

Example 3 with SearchIndexUpdateService

use of com.github.hakko.musiccabinet.service.lastfm.SearchIndexUpdateService in project musiccabinet by hakko.

the class LibraryUpdateService method createSearchIndex.

public void createSearchIndex(Set<String> paths, boolean isRootPaths, boolean offlineScan, boolean onlyNewArtists) throws ApplicationException {
    if (isIndexBeingCreated()) {
        LOG.debug("Search index is being created. Additional update cancelled.");
        return;
    }
    isIndexBeingCreated = true;
    LOG.info("Starting library update. Scan " + paths + ", offline = " + offlineScan);
    for (SearchIndexUpdateService updateService : getUpdateServices()) {
        updateService.reset();
    }
    long millis = -System.currentTimeMillis();
    libraryScannerService.update(paths, isRootPaths);
    millis += System.currentTimeMillis();
    LOG.info("Library scanned in " + (millis / 1000) + " seconds.");
    if (!offlineScan) {
        if (canConnectToLastFm()) {
            updateLastFmData(onlyNewArtists);
            playlistGeneratorService.updateSearchIndex();
        } else {
            LOG.warn("Could not connect to last.fm, no data fetched.");
        }
    }
    LOG.info("Finishing library update.");
    isIndexBeingCreated = false;
}
Also used : SearchIndexUpdateService(com.github.hakko.musiccabinet.service.lastfm.SearchIndexUpdateService)

Example 4 with SearchIndexUpdateService

use of com.github.hakko.musiccabinet.service.lastfm.SearchIndexUpdateService in project musiccabinet by hakko.

the class SearchIndexUpdateExecutorServiceTest method parallellUpdatesGetThrottled.

@Test
public void parallellUpdatesGetThrottled() {
    List<SearchIndexUpdateService> updateServices = new ArrayList<>();
    for (int i = 0; i < 5; i++) {
        updateServices.add(new TestUpdateService());
    }
    executorService.updateSearchIndex(updateServices);
    int totalOperations = 0, finishedOperations = 0;
    for (SearchIndexUpdateService updateService : updateServices) {
        totalOperations += updateService.getProgress().getTotalOperations();
        finishedOperations += updateService.getProgress().getFinishedOperations();
    }
    Assert.assertEquals(5 + 4 + 3 + 2 + 1, totalOperations);
    Assert.assertEquals(totalOperations, finishedOperations);
//		TODO : validate actual blocking. testing was made harder when permits are handed out per minute		
//		Assert.assertTrue(ms / 1000 >= 3); // 5+4+3+2+1 operations = 15, 5/sec -> 3 sec
}
Also used : ArrayList(java.util.ArrayList) SearchIndexUpdateService(com.github.hakko.musiccabinet.service.lastfm.SearchIndexUpdateService) Test(org.junit.Test)

Aggregations

SearchIndexUpdateService (com.github.hakko.musiccabinet.service.lastfm.SearchIndexUpdateService)4 ArrayList (java.util.ArrayList)2 SearchIndexUpdateProgress (com.github.hakko.musiccabinet.domain.model.aggr.SearchIndexUpdateProgress)1 Test (org.junit.Test)1