@Test public void shouldCleanUpOrphanedAssociationWithObject() { RsyncRepositoryValidationRun orphanValidationRun = wtx(tx -> new RsyncRepositoryValidationRun()); wtx0(tx -> getValidationRuns().add(tx, orphanValidationRun)); RpkiObject associatedAndDeletedObject = new RpkiObject( new X509ResourceCertificateBuilder() .withResources(IpResourceSet.parse("10.0.0.0/8")) .withIssuerDN(testTA1.getCertificate().getSubject()) .withSubjectDN(new X500Principal("CN=orphan")) .withSerial(TrustAnchorsFactory.nextSerial()) .withPublicKey(KEY_PAIR_FACTORY.generate().getPublic()) .withSigningKeyPair(KEY_PAIR_FACTORY.generate()) .withValidityPeriod(new ValidityPeriod(DateTime.now(), DateTime.now().plusYears(1))) .build() ); wtx0(tx -> getRpkiObjects().put(tx, associatedAndDeletedObject)); wtx0(tx -> getValidationRuns().associate(tx, orphanValidationRun, associatedAndDeletedObject)); wtx0(tx -> getRpkiObjects().delete(tx, associatedAndDeletedObject)); 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();  }