@Test public void shouldCleanUpOldValidationRunDontDeleteLastSuccessful() { final InstantWithoutNanos lastMonth = InstantWithoutNanos.now().minus(Duration.ofDays(30)); CertificateTreeValidationRun oldValidationRun = new CertificateTreeValidationRun(testTARef1); oldValidationRun.setCreatedAt(lastMonth); oldValidationRun.setCompletedAt(lastMonth); oldValidationRun.setSucceeded(); wtx0(tx -> getValidationRuns().add(tx, oldValidationRun)); AtomicInteger oldCount = subject.cleanupValidationRuns().getLeft(); assertThat(oldCount.get()).isEqualTo(0); }
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();  }