Search in sources :

Example 1 with RollingFileHandler

use of org.apache.geode.internal.io.RollingFileHandler in project geode by apache.

the class ManagerLogWriter method getLogNameForOldMainLog.

public static File getLogNameForOldMainLog(File log, boolean useOldFile) {
    /*
     * this is just searching for the existing logfile name we need to search for meta log file name
     * 
     */
    RollingFileHandler rollingFileHandler = new MainWithChildrenRollingFileHandler();
    File dir = rollingFileHandler.getParentFile(log.getAbsoluteFile());
    int previousMainId = rollingFileHandler.calcNextMainId(dir, true);
    if (useOldFile) {
        if (previousMainId > 0) {
            previousMainId--;
        }
    }
    if (previousMainId == 0) {
        previousMainId = 1;
    }
    File result = null;
    int childId = rollingFileHandler.calcNextChildId(log, previousMainId > 0 ? previousMainId : 0);
    StringBuffer buf = new StringBuffer(log.getPath());
    int insertIdx = buf.lastIndexOf(".");
    if (insertIdx == -1) {
        buf.append(rollingFileHandler.formatId(previousMainId)).append(rollingFileHandler.formatId(childId));
    } else {
        buf.insert(insertIdx, rollingFileHandler.formatId(childId));
        buf.insert(insertIdx, rollingFileHandler.formatId(previousMainId));
    }
    result = new File(buf.toString());
    return result;
}
Also used : RollingFileHandler(org.apache.geode.internal.io.RollingFileHandler) MainWithChildrenRollingFileHandler(org.apache.geode.internal.io.MainWithChildrenRollingFileHandler) MainWithChildrenRollingFileHandler(org.apache.geode.internal.io.MainWithChildrenRollingFileHandler) File(java.io.File)

Aggregations

File (java.io.File)1 MainWithChildrenRollingFileHandler (org.apache.geode.internal.io.MainWithChildrenRollingFileHandler)1 RollingFileHandler (org.apache.geode.internal.io.RollingFileHandler)1