@Test public void shouldCleanUpOrphanedAssociationWithRepo() { RsyncRepositoryValidationRun orphanValidationRun = wtx(tx -> new RsyncRepositoryValidationRun()); wtx0(tx -> getValidationRuns().add(tx, orphanValidationRun)); RpkiRepository associatedAndThenDeletedRepo = new RpkiRepository(testTARef1, testTA1.getLocations().get(0), RpkiRepository.Type.RSYNC); wtx0(tx -> associatedAndThenDeletedRepo.setId(Key.of(getSequences().next(tx, ":pk")))); wtx0(tx -> getRpkiRepositories().register(tx, testTARef1, associatedAndThenDeletedRepo.getLocationUri(), associatedAndThenDeletedRepo.getType())); wtx0(tx -> getValidationRuns().associate(tx, orphanValidationRun, associatedAndThenDeletedRepo)); wtx0(tx -> getRpkiRepositories().remove(tx, associatedAndThenDeletedRepo.key())); AtomicInteger orphanCount = subject.cleanupValidationRuns().getRight(); assertThat(orphanCount.get()).isEqualTo(1); }
public Pair<AtomicInteger, AtomicInteger> cleanupValidationRuns() { AtomicInteger oldCount = new AtomicInteger(); AtomicInteger orphanCount = new AtomicInteger(); InstantWithoutNanos completedBefore = InstantWithoutNanos.now().minus(cleanupGraceDuration); Long t = Time.timed(() -> { oldCount.set(storage.writeTx(tx -> validationRuns.removeOldValidationRuns(tx, completedBefore))); orphanCount.set(storage.writeTx(tx -> validationRuns.removeOrphanValidationRunAssociations(tx))); }); log.info("Removed {} old validation runs and {} orphans in {}ms", oldCount.get(), orphanCount.get(), t); storage.gc(); return Pair.of(oldCount, orphanCount); }
ValidationRunCleanupService { public Pair<AtomicInteger, AtomicInteger> cleanupValidationRuns() { AtomicInteger oldCount = new AtomicInteger(); AtomicInteger orphanCount = new AtomicInteger(); InstantWithoutNanos completedBefore = InstantWithoutNanos.now().minus(cleanupGraceDuration); Long t = Time.timed(() -> { oldCount.set(storage.writeTx(tx -> validationRuns.removeOldValidationRuns(tx, completedBefore))); orphanCount.set(storage.writeTx(tx -> validationRuns.removeOrphanValidationRunAssociations(tx))); }); log.info("Removed {} old validation runs and {} orphans in {}ms", oldCount.get(), orphanCount.get(), t); storage.gc(); return Pair.of(oldCount, orphanCount); } }
ValidationRunCleanupService { public Pair<AtomicInteger, AtomicInteger> cleanupValidationRuns() { AtomicInteger oldCount = new AtomicInteger(); AtomicInteger orphanCount = new AtomicInteger(); InstantWithoutNanos completedBefore = InstantWithoutNanos.now().minus(cleanupGraceDuration); Long t = Time.timed(() -> { oldCount.set(storage.writeTx(tx -> validationRuns.removeOldValidationRuns(tx, completedBefore))); orphanCount.set(storage.writeTx(tx -> validationRuns.removeOrphanValidationRunAssociations(tx))); }); log.info("Removed {} old validation runs and {} orphans in {}ms", oldCount.get(), orphanCount.get(), t); storage.gc(); return Pair.of(oldCount, orphanCount); } ValidationRunCleanupService(@Value("${rpki.validator.validation.run.cleanup.grace.duration}") String cleanupGraceDuration,
                                       Storage storage); }
ValidationRunCleanupService { public Pair<AtomicInteger, AtomicInteger> cleanupValidationRuns() { AtomicInteger oldCount = new AtomicInteger(); AtomicInteger orphanCount = new AtomicInteger(); InstantWithoutNanos completedBefore = InstantWithoutNanos.now().minus(cleanupGraceDuration); Long t = Time.timed(() -> { oldCount.set(storage.writeTx(tx -> validationRuns.removeOldValidationRuns(tx, completedBefore))); orphanCount.set(storage.writeTx(tx -> validationRuns.removeOrphanValidationRunAssociations(tx))); }); log.info("Removed {} old validation runs and {} orphans in {}ms", oldCount.get(), orphanCount.get(), t); storage.gc(); return Pair.of(oldCount, orphanCount); } ValidationRunCleanupService(@Value("${rpki.validator.validation.run.cleanup.grace.duration}") String cleanupGraceDuration,
                                       Storage storage); Pair<AtomicInteger, AtomicInteger> cleanupValidationRuns(); }
ValidationRunCleanupService { public Pair<AtomicInteger, AtomicInteger> cleanupValidationRuns() { AtomicInteger oldCount = new AtomicInteger(); AtomicInteger orphanCount = new AtomicInteger(); InstantWithoutNanos completedBefore = InstantWithoutNanos.now().minus(cleanupGraceDuration); Long t = Time.timed(() -> { oldCount.set(storage.writeTx(tx -> validationRuns.removeOldValidationRuns(tx, completedBefore))); orphanCount.set(storage.writeTx(tx -> validationRuns.removeOrphanValidationRunAssociations(tx))); }); log.info("Removed {} old validation runs and {} orphans in {}ms", oldCount.get(), orphanCount.get(), t); storage.gc(); return Pair.of(oldCount, orphanCount); } ValidationRunCleanupService(@Value("${rpki.validator.validation.run.cleanup.grace.duration}") String cleanupGraceDuration,
                                       Storage storage); Pair<AtomicInteger, AtomicInteger> cleanupValidationRuns();  }