Class TimeBasedArchiveRemover
- java.lang.Object
-
- ch.qos.logback.core.spi.ContextAwareBase
-
- ch.qos.logback.core.rolling.helper.TimeBasedArchiveRemover
-
- All Implemented Interfaces:
ArchiveRemover
,ContextAware
- Direct Known Subclasses:
SizeAndTimeBasedArchiveRemover
public class TimeBasedArchiveRemover extends ContextAwareBase implements ArchiveRemover
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
TimeBasedArchiveRemover.ArhiveRemoverRunnable
-
Field Summary
Fields Modifier and Type Field Description (package private) int
callCount
(package private) FileNamePattern
fileNamePattern
protected static long
INACTIVITY_TOLERANCE_IN_MILLIS
(package private) long
lastHeartBeat
(package private) static int
MAX_VALUE_FOR_INACTIVITY_PERIODS
private int
maxHistory
(package private) boolean
parentClean
(package private) RollingCalendar
rc
private long
totalSizeCap
protected static long
UNINITIALIZED
-
Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase
context
-
-
Constructor Summary
Constructors Constructor Description TimeBasedArchiveRemover(FileNamePattern fileNamePattern, RollingCalendar rc)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
capTotalSize(java.util.Date now)
void
clean(java.util.Date now)
java.util.concurrent.Future<?>
cleanAsynchronously(java.util.Date now)
void
cleanPeriod(java.util.Date dateOfPeriodToClean)
(package private) int
computeElapsedPeriodsSinceLastClean(long nowInMillis)
(package private) boolean
computeParentCleaningFlag(FileNamePattern fileNamePattern)
private void
descendingSortByLastModified(java.io.File[] matchingFileArray)
private boolean
fileExistsAndIsFile(java.io.File file2Delete)
protected java.io.File[]
getFilesInPeriod(java.util.Date dateOfPeriodToClean)
(package private) java.io.File
getParentDir(java.io.File file)
protected int
getPeriodOffsetForDeletionTarget()
(package private) void
removeFolderIfEmpty(java.io.File dir)
private void
removeFolderIfEmpty(java.io.File dir, int depth)
Will remove the directory passed as parameter if empty.void
setMaxHistory(int maxHistory)
void
setTotalSizeCap(long totalSizeCap)
java.lang.String
toString()
-
Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ch.qos.logback.core.spi.ContextAware
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, setContext
-
-
-
-
Field Detail
-
UNINITIALIZED
protected static final long UNINITIALIZED
- See Also:
- Constant Field Values
-
INACTIVITY_TOLERANCE_IN_MILLIS
protected static final long INACTIVITY_TOLERANCE_IN_MILLIS
- See Also:
- Constant Field Values
-
MAX_VALUE_FOR_INACTIVITY_PERIODS
static final int MAX_VALUE_FOR_INACTIVITY_PERIODS
- See Also:
- Constant Field Values
-
fileNamePattern
final FileNamePattern fileNamePattern
-
rc
final RollingCalendar rc
-
maxHistory
private int maxHistory
-
totalSizeCap
private long totalSizeCap
-
parentClean
final boolean parentClean
-
lastHeartBeat
long lastHeartBeat
-
callCount
int callCount
-
-
Constructor Detail
-
TimeBasedArchiveRemover
public TimeBasedArchiveRemover(FileNamePattern fileNamePattern, RollingCalendar rc)
-
-
Method Detail
-
clean
public void clean(java.util.Date now)
- Specified by:
clean
in interfaceArchiveRemover
-
getFilesInPeriod
protected java.io.File[] getFilesInPeriod(java.util.Date dateOfPeriodToClean)
-
fileExistsAndIsFile
private boolean fileExistsAndIsFile(java.io.File file2Delete)
-
cleanPeriod
public void cleanPeriod(java.util.Date dateOfPeriodToClean)
-
capTotalSize
void capTotalSize(java.util.Date now)
-
descendingSortByLastModified
private void descendingSortByLastModified(java.io.File[] matchingFileArray)
-
getParentDir
java.io.File getParentDir(java.io.File file)
-
computeElapsedPeriodsSinceLastClean
int computeElapsedPeriodsSinceLastClean(long nowInMillis)
-
computeParentCleaningFlag
boolean computeParentCleaningFlag(FileNamePattern fileNamePattern)
-
removeFolderIfEmpty
void removeFolderIfEmpty(java.io.File dir)
-
removeFolderIfEmpty
private void removeFolderIfEmpty(java.io.File dir, int depth)
Will remove the directory passed as parameter if empty. After that, if the parent is also becomes empty, remove the parent dir as well but at most 3 times.- Parameters:
dir
-depth
-
-
setMaxHistory
public void setMaxHistory(int maxHistory)
- Specified by:
setMaxHistory
in interfaceArchiveRemover
-
getPeriodOffsetForDeletionTarget
protected int getPeriodOffsetForDeletionTarget()
-
setTotalSizeCap
public void setTotalSizeCap(long totalSizeCap)
- Specified by:
setTotalSizeCap
in interfaceArchiveRemover
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
cleanAsynchronously
public java.util.concurrent.Future<?> cleanAsynchronously(java.util.Date now)
- Specified by:
cleanAsynchronously
in interfaceArchiveRemover
-
-