From a44f12449b62333d83ecf09c56b10e83e055416d Mon Sep 17 00:00:00 2001 From: Rui Han Date: Wed, 26 Jun 2024 09:55:25 +0800 Subject: [PATCH] Add config for gcIntervalInMinutes (#88) --- .../service/storage/config/StorageServiceConfig.java | 5 +++++ .../commonjava/service/storage/core/FileManagerProducer.java | 4 +--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/commonjava/service/storage/config/StorageServiceConfig.java b/src/main/java/org/commonjava/service/storage/config/StorageServiceConfig.java index b97bc14..ef37a0b 100644 --- a/src/main/java/org/commonjava/service/storage/config/StorageServiceConfig.java +++ b/src/main/java/org/commonjava/service/storage/config/StorageServiceConfig.java @@ -49,6 +49,11 @@ public interface StorageServiceConfig @WithDefault("100") int gcBatchSize(); + // value <= 0 disables gc effectively + @WithName( "gcIntervalInMinutes" ) + @WithDefault("60") + int gcIntervalInMinutes(); + @WithName( "type" ) @WithDefault( STORAGE_NFS ) String type(); diff --git a/src/main/java/org/commonjava/service/storage/core/FileManagerProducer.java b/src/main/java/org/commonjava/service/storage/core/FileManagerProducer.java index 1f30c98..c992daf 100644 --- a/src/main/java/org/commonjava/service/storage/core/FileManagerProducer.java +++ b/src/main/java/org/commonjava/service/storage/core/FileManagerProducer.java @@ -37,8 +37,6 @@ @ApplicationScoped public class FileManagerProducer { - private static final int STORAGE_GC_BATCH_SIZE = 100; - @Inject CassandraConfig cassandraConfig; @@ -59,9 +57,9 @@ public PathMappedFileManager getFileManager() props.put( PROP_CASSANDRA_PASS, cassandraConfig.pass() ); DefaultPathMappedStorageConfig config = new DefaultPathMappedStorageConfig( props ); - config.setGcBatchSize( STORAGE_GC_BATCH_SIZE ); config.setPhysicalFileExistenceCheckEnabled( storageConfig.physicalFileExistenceCheck() ); config.setGcBatchSize( storageConfig.gcBatchSize() ); + config.setGcIntervalInMinutes( storageConfig.gcIntervalInMinutes() ); PathDB pathDB = new CassandraPathDB( config ); PhysicalStore physicalStore;