@Test public void deleteUnusedSnapshotComponents() throws Exception { mockPagesOfComponents(); purgeUnusedSnapshotsFacet.deleteUnusedSnapshotComponents(taskOlderThan); assertComponentDeletions(); assertQueries(); assertAllMetadataDeletedOrFlaggedToRebuild(); }
@TransactionalDeleteBlob protected void deleteUnusedSnapshotComponents(LocalDate olderThan) { StorageTx tx = UnitOfWork.currentTx(); Repository repo = getRepository(); long totalComponents = tx.countComponents(builder().build(), singletonList(repo)); log.info("Found {} total components in repository {} to evaluate for unused snapshots", totalComponents, repo.getName()); ORID bucketId = id(tx.findBucket(getRepository())); String unusedWhereTemplate = getUnusedWhere(bucketId); long skipCount = 0; lastComponent = new ORecordId(-1, -1); while (skipCount < totalComponents && !isCanceled()) { log.info(PROGRESS, format("Processing components [%.2f%%] complete", ((double) skipCount / totalComponents) * 100)); for (Component component : findNextPageOfUnusedSnapshots(tx, olderThan, bucketId, unusedWhereTemplate)) { if (isCanceled()) { return; } deleteComponent(component); } tx.commit(); tx.begin(); skipCount += findUnusedLimit; } }
PurgeUnusedSnapshotsFacetImpl extends FacetSupport implements PurgeUnusedSnapshotsFacet { @TransactionalDeleteBlob protected void deleteUnusedSnapshotComponents(LocalDate olderThan) { StorageTx tx = UnitOfWork.currentTx(); Repository repo = getRepository(); long totalComponents = tx.countComponents(builder().build(), singletonList(repo)); log.info("Found {} total components in repository {} to evaluate for unused snapshots", totalComponents, repo.getName()); ORID bucketId = id(tx.findBucket(getRepository())); String unusedWhereTemplate = getUnusedWhere(bucketId); long skipCount = 0; lastComponent = new ORecordId(-1, -1); while (skipCount < totalComponents && !isCanceled()) { log.info(PROGRESS, format("Processing components [%.2f%%] complete", ((double) skipCount / totalComponents) * 100)); for (Component component : findNextPageOfUnusedSnapshots(tx, olderThan, bucketId, unusedWhereTemplate)) { if (isCanceled()) { return; } deleteComponent(component); } tx.commit(); tx.begin(); skipCount += findUnusedLimit; } } }
PurgeUnusedSnapshotsFacetImpl extends FacetSupport implements PurgeUnusedSnapshotsFacet { @TransactionalDeleteBlob protected void deleteUnusedSnapshotComponents(LocalDate olderThan) { StorageTx tx = UnitOfWork.currentTx(); Repository repo = getRepository(); long totalComponents = tx.countComponents(builder().build(), singletonList(repo)); log.info("Found {} total components in repository {} to evaluate for unused snapshots", totalComponents, repo.getName()); ORID bucketId = id(tx.findBucket(getRepository())); String unusedWhereTemplate = getUnusedWhere(bucketId); long skipCount = 0; lastComponent = new ORecordId(-1, -1); while (skipCount < totalComponents && !isCanceled()) { log.info(PROGRESS, format("Processing components [%.2f%%] complete", ((double) skipCount / totalComponents) * 100)); for (Component component : findNextPageOfUnusedSnapshots(tx, olderThan, bucketId, unusedWhereTemplate)) { if (isCanceled()) { return; } deleteComponent(component); } tx.commit(); tx.begin(); skipCount += findUnusedLimit; } } @Inject  PurgeUnusedSnapshotsFacetImpl(
      final ComponentEntityAdapter componentEntityAdapter,
      @Named(GroupType.NAME) final Type groupType,
      @Named(HostedType.NAME) final Type hostedType,
      @Named("${nexus.tasks.purgeUnusedSnapshots.findUnusedLimit:-50}") int findUnusedLimit); }
PurgeUnusedSnapshotsFacetImpl extends FacetSupport implements PurgeUnusedSnapshotsFacet { @TransactionalDeleteBlob protected void deleteUnusedSnapshotComponents(LocalDate olderThan) { StorageTx tx = UnitOfWork.currentTx(); Repository repo = getRepository(); long totalComponents = tx.countComponents(builder().build(), singletonList(repo)); log.info("Found {} total components in repository {} to evaluate for unused snapshots", totalComponents, repo.getName()); ORID bucketId = id(tx.findBucket(getRepository())); String unusedWhereTemplate = getUnusedWhere(bucketId); long skipCount = 0; lastComponent = new ORecordId(-1, -1); while (skipCount < totalComponents && !isCanceled()) { log.info(PROGRESS, format("Processing components [%.2f%%] complete", ((double) skipCount / totalComponents) * 100)); for (Component component : findNextPageOfUnusedSnapshots(tx, olderThan, bucketId, unusedWhereTemplate)) { if (isCanceled()) { return; } deleteComponent(component); } tx.commit(); tx.begin(); skipCount += findUnusedLimit; } } @Inject  PurgeUnusedSnapshotsFacetImpl(
      final ComponentEntityAdapter componentEntityAdapter,
      @Named(GroupType.NAME) final Type groupType,
      @Named(HostedType.NAME) final Type hostedType,
      @Named("${nexus.tasks.purgeUnusedSnapshots.findUnusedLimit:-50}") int findUnusedLimit); @Override @Guarded(by = STARTED) void purgeUnusedSnapshots(final int numberOfDays); }
PurgeUnusedSnapshotsFacetImpl extends FacetSupport implements PurgeUnusedSnapshotsFacet { @TransactionalDeleteBlob protected void deleteUnusedSnapshotComponents(LocalDate olderThan) { StorageTx tx = UnitOfWork.currentTx(); Repository repo = getRepository(); long totalComponents = tx.countComponents(builder().build(), singletonList(repo)); log.info("Found {} total components in repository {} to evaluate for unused snapshots", totalComponents, repo.getName()); ORID bucketId = id(tx.findBucket(getRepository())); String unusedWhereTemplate = getUnusedWhere(bucketId); long skipCount = 0; lastComponent = new ORecordId(-1, -1); while (skipCount < totalComponents && !isCanceled()) { log.info(PROGRESS, format("Processing components [%.2f%%] complete", ((double) skipCount / totalComponents) * 100)); for (Component component : findNextPageOfUnusedSnapshots(tx, olderThan, bucketId, unusedWhereTemplate)) { if (isCanceled()) { return; } deleteComponent(component); } tx.commit(); tx.begin(); skipCount += findUnusedLimit; } } @Inject  PurgeUnusedSnapshotsFacetImpl(
      final ComponentEntityAdapter componentEntityAdapter,
      @Named(GroupType.NAME) final Type groupType,
      @Named(HostedType.NAME) final Type hostedType,
      @Named("${nexus.tasks.purgeUnusedSnapshots.findUnusedLimit:-50}") int findUnusedLimit); @Override @Guarded(by = STARTED) void purgeUnusedSnapshots(final int numberOfDays);  }