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 classTimeBasedArchiveRemover.ArhiveRemoverRunnable
-
Field Summary
Fields Modifier and Type Field Description (package private) intcallCount(package private) FileNamePatternfileNamePatternprotected static longINACTIVITY_TOLERANCE_IN_MILLIS(package private) longlastHeartBeat(package private) static intMAX_VALUE_FOR_INACTIVITY_PERIODSprivate intmaxHistory(package private) booleanparentClean(package private) RollingCalendarrcprivate longtotalSizeCapprotected static longUNINITIALIZED-
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) voidcapTotalSize(java.util.Date now)voidclean(java.util.Date now)java.util.concurrent.Future<?>cleanAsynchronously(java.util.Date now)voidcleanPeriod(java.util.Date dateOfPeriodToClean)(package private) intcomputeElapsedPeriodsSinceLastClean(long nowInMillis)(package private) booleancomputeParentCleaningFlag(FileNamePattern fileNamePattern)private voiddescendingSortByLastModified(java.io.File[] matchingFileArray)private booleanfileExistsAndIsFile(java.io.File file2Delete)protected java.io.File[]getFilesInPeriod(java.util.Date dateOfPeriodToClean)(package private) java.io.FilegetParentDir(java.io.File file)protected intgetPeriodOffsetForDeletionTarget()(package private) voidremoveFolderIfEmpty(java.io.File dir)private voidremoveFolderIfEmpty(java.io.File dir, int depth)Will remove the directory passed as parameter if empty.voidsetMaxHistory(int maxHistory)voidsetTotalSizeCap(long totalSizeCap)java.lang.StringtoString()-
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:
cleanin 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:
setMaxHistoryin interfaceArchiveRemover
-
getPeriodOffsetForDeletionTarget
protected int getPeriodOffsetForDeletionTarget()
-
setTotalSizeCap
public void setTotalSizeCap(long totalSizeCap)
- Specified by:
setTotalSizeCapin interfaceArchiveRemover
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
cleanAsynchronously
public java.util.concurrent.Future<?> cleanAsynchronously(java.util.Date now)
- Specified by:
cleanAsynchronouslyin interfaceArchiveRemover
-
-