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;
}
Aggregations