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;
}
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.");
}
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;
}
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
}
Aggregations