@Override public String getCurrentPeriodsFileNameWithoutCompressionSuffix() { return tbrp.fileNamePatternWCS.convertMultipleArguments( dateInCurrentPeriod, currentPeriodsCounter); }
static public int findHighestCounter(File[] matchingFileArray, final String stemRegex) { int max = Integer.MIN_VALUE; for (File aFile : matchingFileArray) { int aCounter = FileFilterUtil.extractCounter(aFile, stemRegex); if (max < aCounter) max = aCounter; } return max; }
Future asyncCompress(String nameOfFile2Compress, String nameOfCompressedFile, String innerEntryName) throws RolloverFailure { AsynchronousCompressor ac = new AsynchronousCompressor(compressor); return ac.compressAsynchronously(nameOfFile2Compress, nameOfCompressedFile, innerEntryName); }
public void cleanByPeriodOffset(Date now, int periodOffset) { Date dateOfPeriodToClean = rc.getRelativeDate(now, periodOffset); String regex = fileNamePattern.toRegexForFixedDate(dateOfPeriodToClean); String stemRegex = FileFilterUtil.afterLastSlash(regex); File archive0 = new File(fileNamePattern.convertMultipleArguments( dateOfPeriodToClean, 0)); // in case the file has no directory part, i.e. if it's written into the // user's current directory. archive0 = archive0.getAbsoluteFile(); File parentDir = archive0.getAbsoluteFile().getParentFile(); File[] matchingFileArray = FileFilterUtil.filesInFolderMatchingStemRegex( parentDir, stemRegex); for (File f : matchingFileArray) { f.delete(); } if (parentClean) { removeFolderIfEmpty(parentDir); } }
public FileNamePattern(String patternArg, Context contextArg) { // the pattern is slashified setPattern(FileFilterUtil.slashify(patternArg)); setContext(contextArg); parse(); ConverterUtil.startConverters(this.headTokenConverter); }
protected void cleanByPeriodOffset(Date now, int periodOffset) { Date date2delete = rc.getRelativeDate(now, periodOffset); String filename = fileNamePattern.convert(date2delete); File file2Delete = new File(filename); if (file2Delete.exists() && file2Delete.isFile()) { file2Delete.delete(); addInfo("deleting " + file2Delete); if (parentClean) { removeFolderIfEmpty(file2Delete.getParentFile()); } } }
@Override public void start() { // we depend on certain fields having been initialized // in super.start() super.start(); archiveRemover = createArchiveRemover(); archiveRemover.setContext(context); // we need to get the correct value of currentPeriodsCounter. // usually the value is 0, unless the appender or the application // is stopped and restarted within the same period String regex = tbrp.fileNamePattern.toRegexForFixedDate(dateInCurrentPeriod); String stemRegex = FileFilterUtil.afterLastSlash(regex); computeCurrentPeriodsHighestCounterValue(stemRegex); started = true; }
private String transformFileNamePattern2ZipEntry(String fileNamePatternStr) { String slashified = FileFilterUtil.slashify(fileNamePatternStr); return FileFilterUtil.afterLastSlash(slashified); }
@Override public void start() { super.start(); archiveRemover = new TimeBasedArchiveRemover(tbrp.fileNamePattern, rc); archiveRemover.setContext(context); started = true; }
int computeElapsedPeriodsSinceLastClean(long nowInMillis) { long periodsElapsed = 0; if (lastHeartBeat == UNINITIALIZED) { addInfo("first clean up after appender initialization"); periodsElapsed = rc.periodsElapsed(nowInMillis, nowInMillis + INACTIVITY_TOLERANCE_IN_MILLIS); if (periodsElapsed > MAX_VALUE_FOR_INACTIVITY_PERIODS) periodsElapsed = MAX_VALUE_FOR_INACTIVITY_PERIODS; } else { periodsElapsed = rc.periodsElapsed(lastHeartBeat, nowInMillis); if (periodsElapsed < 1) { addWarn("Unexpected periodsElapsed value " + periodsElapsed); periodsElapsed = 1; } } return (int) periodsElapsed; }
public String getCurrentPeriodsFileNameWithoutCompressionSuffix() { return tbrp.fileNamePatternWCS.convert(dateInCurrentPeriod); }
public void run() { compressor.compress(nameOfFile2Compress, nameOfCompressedFile, innerEntryName); } }
protected ArchiveRemover createArchiveRemover() { return new SizeAndTimeBasedArchiveRemover(tbrp.fileNamePattern, rc); }
public void init(String datePattern) { periodicityType = computePeriodicityType(datePattern); }
public DefaultArchiveRemover(FileNamePattern fileNamePattern, RollingCalendar rc) { this.fileNamePattern = fileNamePattern; this.rc = rc; this.parentClean = computeParentCleaningFlag(fileNamePattern); }
public Date getNextTriggeringDate(Date now) { return getRelativeDate(now, 1); } }
protected void computeNextCheck() { nextCheck = rc.getNextTriggeringMillis(dateInCurrentPeriod); }
void removeFolderIfEmpty(File dir) { removeFolderIfEmpty(dir, 0); }
public String convertInt(int i) { return convert(i); }
private String getFileNameIncludingCompressionSuffix(Date date, int counter) { return tbrp.fileNamePattern.convertMultipleArguments( dateInCurrentPeriod, counter); }