From a71fd78d33bfe51822cd35b283a7d53217d258c6 Mon Sep 17 00:00:00 2001 From: zhaoyuhan Date: Wed, 11 Sep 2024 14:22:16 +0800 Subject: [PATCH] feat make delete interval configuable --- .../io/openmessaging/storage/dledger/DLedgerConfig.java | 9 +++++++++ .../storage/dledger/store/file/DLedgerMmapFileStore.java | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/dledger/src/main/java/io/openmessaging/storage/dledger/DLedgerConfig.java b/dledger/src/main/java/io/openmessaging/storage/dledger/DLedgerConfig.java index 0bb539b6..006b99d9 100644 --- a/dledger/src/main/java/io/openmessaging/storage/dledger/DLedgerConfig.java +++ b/dledger/src/main/java/io/openmessaging/storage/dledger/DLedgerConfig.java @@ -130,6 +130,7 @@ public class DLedgerConfig { private int metricsPromExporterPort = 5557; private String metricsPromExporterHost = ""; + private int deleteFilesInterval = 100; public String getDefaultPath() { return storeBaseDir + File.separator + "dledger-" + selfId; @@ -635,4 +636,12 @@ public int getMetricsPromExporterPort() { public String getMetricsPromExporterHost() { return metricsPromExporterHost; } + + public int getDeleteFilesInterval() { + return deleteFilesInterval; + } + + public void setDeleteFilesInterval(int deleteFilesInterval) { + this.deleteFilesInterval = deleteFilesInterval; + } } diff --git a/dledger/src/main/java/io/openmessaging/storage/dledger/store/file/DLedgerMmapFileStore.java b/dledger/src/main/java/io/openmessaging/storage/dledger/store/file/DLedgerMmapFileStore.java index c776d157..63830143 100644 --- a/dledger/src/main/java/io/openmessaging/storage/dledger/store/file/DLedgerMmapFileStore.java +++ b/dledger/src/main/java/io/openmessaging/storage/dledger/store/file/DLedgerMmapFileStore.java @@ -777,8 +777,9 @@ public void doWork() { boolean forceClean = isNeedForceClean(); boolean enableForceClean = dLedgerConfig.isEnableDiskForceClean(); int intervalForcibly = 120 * 1000; + int deleteFilesInterval = dLedgerConfig.getDeleteFilesInterval(); if (timeUp || checkExpired) { - int count = getDataFileList().deleteExpiredFileByTime(fileReservedTimeMs, 100, intervalForcibly, forceClean && enableForceClean); + int count = getDataFileList().deleteExpiredFileByTime(fileReservedTimeMs, deleteFilesInterval, intervalForcibly, forceClean && enableForceClean); if (count > 0 || (forceClean && enableForceClean) || isDiskFull) { logger.info("Clean space count={} timeUp={} checkExpired={} forceClean={} enableForceClean={} diskFull={} storeBaseRatio={} dataRatio={}", count, timeUp, checkExpired, forceClean, enableForceClean, isDiskFull, storeBaseRatio, dataRatio);