public void rollOver() {
        calcMaxAndMinBackupIndex(this.fileName);

        if (this.qw != null) {
            long size = ((CountingQuietWriter) this.qw).getCount();
            LogLog.debug("rolling over count=" + size);

            this.nextRollover = (size + this.maxFileSize);
        }
        LogLog.debug("maxBackupIndex=" + this.currentBackupIndex);

        File file = null;
        boolean renameSucceeded = true;

        if (this.currentBackupIndex - this.minBackupIndex >= this.maxBackupIndex) {
            file = new File(this.fileName + '.' + this.minBackupIndex);
            if (file.exists()) {
                renameSucceeded = file.delete();
                this.minBackupIndex++;
            }
        }

        if (renameSucceeded) {
            File target = new File(getNextBackupFileName());

            closeFile();

            file = new File(this.fileName);
            LogLog.debug("Renaming file " + file + " to " + target);
            renameSucceeded = file.renameTo(target);

            if (!renameSucceeded) {
                try {
                    setFile(this.fileName, true, this.bufferedIO, this.bufferSize);
                } catch (IOException e) {
                    LogLog.error("setFile(" + this.fileName + ", true) call failed.", e);
                }
            } else {
                nextBackupIndex();
            }
        }

        if (renameSucceeded) {
            try {
                setFile(this.fileName, false, this.bufferedIO, this.bufferSize);
                this.nextRollover = 0L;
            } catch (IOException e) {
                LogLog.error("setFile(" + this.fileName + ", false) call failed.", e);
            }
        }
    }