use of io.mycat.backend.mysql.xa.recovery.LogException in project Mycat-Server by MyCATApache.
the class LogFileLock method acquireLock.
public void acquireLock() throws LogException {
try {
File parent = new File(dir);
if (!parent.exists()) {
parent.mkdir();
}
lockfileToPreventDoubleStartup_ = new File(dir, fileName + ".lck");
lockfilestream_ = new FileOutputStream(lockfileToPreventDoubleStartup_);
lock_ = lockfilestream_.getChannel().tryLock();
lockfileToPreventDoubleStartup_.deleteOnExit();
} catch (OverlappingFileLockException failedToGetLock) {
// happens on windows
lock_ = null;
} catch (IOException failedToGetLock) {
// happens on windows
lock_ = null;
}
if (lock_ == null) {
logger.error("ERROR: the specified log seems to be in use already: " + fileName + " in " + dir + ". Make sure that no other instance is running, or kill any pending process if needed.");
throw new LogException("Log already in use? " + fileName + " in " + dir);
}
}
Aggregations