Class TimeBasedCleanupPolicy
- java.lang.Object
-
- net.morimekta.providence.logging.rolling.TimeBasedCleanupPolicy
-
- All Implemented Interfaces:
RollingFileMessageWriter.CleanupPolicy
public class TimeBasedCleanupPolicy extends java.lang.Object implements RollingFileMessageWriter.CleanupPolicy
A cleanup policy that removes files older than a certain date. Uses a date-based file pattern in order to determine the date on the file. the actual file mtime is not checked.
-
-
Constructor Summary
Constructors Constructor Description TimeBasedCleanupPolicy(int units, java.util.concurrent.TimeUnit resolution, java.lang.String rollingFilePattern)
Create a time based cleanup policy using the system clock for parsing timestampts.TimeBasedCleanupPolicy(int units, java.util.concurrent.TimeUnit resolution, java.lang.String rollingFilePattern, java.time.Clock clock)
Create a time based cleanup policy.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<java.lang.String>
getFilesToDelete(java.util.List<java.lang.String> candidateFiles, java.lang.String currentFileName)
Get a list of files that needs to be deleted because of the cleanup policy.
-
-
-
Constructor Detail
-
TimeBasedCleanupPolicy
public TimeBasedCleanupPolicy(int units, java.util.concurrent.TimeUnit resolution, java.lang.String rollingFilePattern)
Create a time based cleanup policy using the system clock for parsing timestampts.- Parameters:
units
- The amount of time back to keep files for.resolution
- The unit of time to keep files for.rollingFilePattern
- Pattern matching the files, seeTimeBasedRollingPolicy
.
-
TimeBasedCleanupPolicy
public TimeBasedCleanupPolicy(int units, java.util.concurrent.TimeUnit resolution, java.lang.String rollingFilePattern, java.time.Clock clock)
Create a time based cleanup policy.- Parameters:
units
- The amount of time back to keep files for.resolution
- The unit of time to keep files for.rollingFilePattern
- Pattern matching the files, seeTimeBasedRollingPolicy
.clock
- The clock to use.
-
-
Method Detail
-
getFilesToDelete
@Nonnull public java.util.List<java.lang.String> getFilesToDelete(@Nonnull java.util.List<java.lang.String> candidateFiles, @Nonnull java.lang.String currentFileName)
Description copied from interface:RollingFileMessageWriter.CleanupPolicy
Get a list of files that needs to be deleted because of the cleanup policy.- Specified by:
getFilesToDelete
in interfaceRollingFileMessageWriter.CleanupPolicy
- Parameters:
candidateFiles
- List of the files that can be cleaned up. This does NOT include the currently written files (current file and symlink).currentFileName
- The current file name.- Returns:
- List of files that needs to be deleted.
-
-