*** /cygdrive/e/tmp/FixedWindowRollingPolicy.java 2011-05-30 09:45:50.000000000 +0200 --- FixedWindowRollingPolicy.java 2011-09-02 08:59:38.672578400 +0200 *************** *** 15,20 **** --- 15,21 ---- import java.io.File; import java.util.Date; + import java.util.concurrent.Future; import ch.qos.logback.core.CoreConstants; import ch.qos.logback.core.rolling.helper.*; *************** *** 36,41 **** --- 37,43 ---- int minIndex; RenameUtil util = new RenameUtil(); Compressor compressor; + Future future; public static String ZIP_ENTRY_DATE_PATTERN = "yyyy-MM-dd_HHmm"; *************** *** 134,155 **** } } ! // move active file name to min ! switch (compressionMode) { ! case NONE: ! util.rename(getActiveFileName(), fileNamePattern ! .convertInt(minIndex)); ! break; ! case GZ: ! compressor.compress(getActiveFileName(), fileNamePattern.convertInt(minIndex), null); ! break; ! case ZIP: ! compressor.compress(getActiveFileName(), fileNamePattern.convertInt(minIndex), zipEntryFileNamePattern.convert(new Date())); ! break; ! } } } /** * Return the value of the parent's RawFile property. */ --- 136,175 ---- } } ! if (compressionMode == CompressionMode.NONE) { ! if (getParentsRawFileProperty() != null) { ! util.rename(getActiveFileName(), fileNamePattern.convertInt(minIndex)); ! } // else { nothing to do if CompressionMode == NONE and parentsRawFileProperty == null } ! } else { ! if (getParentsRawFileProperty() == null) { ! future = asyncCompress(getActiveFileName(), ! fileNamePattern.convertInt(minIndex), ! (compressionMode == CompressionMode.ZIP) ! ? zipEntryFileNamePattern.convert(new Date()) : null); ! } else { ! future = renamedRawAndAsyncCompress( ! fileNamePattern.convertInt(minIndex), ! (compressionMode == CompressionMode.ZIP) ! ? zipEntryFileNamePattern.convert(new Date()) : null); ! } ! } } } + Future asyncCompress(String nameOfFile2Compress, String nameOfCompressedFile, String innerEntryName) + throws RolloverFailure { + AsynchronousCompressor ac = new AsynchronousCompressor(compressor); + return ac.compressAsynchronously(nameOfFile2Compress, nameOfCompressedFile, innerEntryName); + } + + Future renamedRawAndAsyncCompress(String nameOfCompressedFile, String innerEntryName) + throws RolloverFailure { + String parentsRawFile = getParentsRawFileProperty(); + String tmpTarget = parentsRawFile + System.nanoTime() + ".tmp"; + util.rename(parentsRawFile, tmpTarget); + return asyncCompress(tmpTarget, nameOfCompressedFile, innerEntryName); + } + /** * Return the value of the parent's RawFile property. */