use of org.sonatype.nexus.repository.r.RHostedFacet in project nexus-repository-r by sonatype-nexus-community.
the class RPackagesBuilderFacetImpl method on.
/**
* Listen for invalidation of the metadata, wait a configured time and then rebuild. The waiting allows throwing away
* of subsequent events to reduce the number of rebuilds if multiple archives are being uploaded. This method must NOT
* be allowed to process concurrent events as race conditions may result when rebuilding the data.
*/
@Subscribe
public void on(final RMetadataInvalidationEvent event) {
if (getRepository().getName().equals(event.getRepositoryName())) {
try {
waiting = true;
Thread.sleep(interval);
} catch (InterruptedException e) {
log.warn("R invalidation thread interrupted on repository {}, proceeding with invalidation", getRepository().getName());
Thread.currentThread().interrupt();
}
waiting = false;
log.info("Rebuilding R PACKAGES.gz metadata for repository {}", getRepository().getName());
UnitOfWork.begin(getRepository().facet(StorageFacet.class).txSupplier());
try {
RHostedFacet hostedFacet = getRepository().facet(RHostedFacet.class);
hostedFacet.buildAndPutPackagesGz(event.getBasePath());
} catch (IOException e) {
throw new UncheckedIOException(e);
} finally {
UnitOfWork.end();
}
}
}
Aggregations