From 902777e74f5b53e922cce38f57fa4c834cf1aab7 Mon Sep 17 00:00:00 2001 From: David Young Date: Tue, 2 Jun 2026 15:16:15 -0400 Subject: [PATCH] NIFI-15989: Improve purge threshold time formatting Update the purge threshold output to be more human readable. Existing output will show the value in milliseconds which can be difficult to read quickly. Use Apache Commons lang3 to get the threhold in a format like "30 days", "7 days 4 hours", etc. --- .../nifi-persistent-provenance-repository/pom.xml | 4 ++++ .../nifi/provenance/store/WriteAheadStorePartition.java | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/nifi-framework-bundle/nifi-framework-extensions/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/pom.xml b/nifi-framework-bundle/nifi-framework-extensions/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/pom.xml index bb7feecbbf6f..3441edf1bb4a 100644 --- a/nifi-framework-bundle/nifi-framework-extensions/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/pom.xml +++ b/nifi-framework-bundle/nifi-framework-extensions/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/pom.xml @@ -51,5 +51,9 @@ lucene-backward-codecs runtime + + org.apache.commons + commons-lang3 + diff --git a/nifi-framework-bundle/nifi-framework-extensions/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/store/WriteAheadStorePartition.java b/nifi-framework-bundle/nifi-framework-extensions/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/store/WriteAheadStorePartition.java index 1ccc25beb289..0e2a2d1c7a98 100644 --- a/nifi-framework-bundle/nifi-framework-extensions/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/store/WriteAheadStorePartition.java +++ b/nifi-framework-bundle/nifi-framework-extensions/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/store/WriteAheadStorePartition.java @@ -17,6 +17,7 @@ package org.apache.nifi.provenance.store; +import org.apache.commons.lang3.time.DurationFormatUtils; import org.apache.nifi.events.EventReporter; import org.apache.nifi.provenance.ProvenanceEventRecord; import org.apache.nifi.provenance.RepositoryConfiguration; @@ -498,10 +499,12 @@ public void purgeOldEvents(final long olderThan, final TimeUnit unit) { .filter(this::delete) .collect(Collectors.toList()); + String thresholdWords = DurationFormatUtils.formatDurationWords(olderThan, true, true); + if (removed.isEmpty()) { - logger.debug("No Provenance Event files that exceed time-based threshold of {} {}", olderThan, unit); + logger.debug("No Provenance Event files that exceed time-based threshold of {}", thresholdWords); } else { - logger.info("Purged {} Provenance Event files from Provenance Repository because the events were older than {} {}: {}", removed.size(), olderThan, unit, removed); + logger.info("Purged {} Provenance Event files from Provenance Repository because the events were older than {} : {}", removed.size(), thresholdWords, removed); } }