public final void initRepository() throws IOException { Operation.initPool(CLEANUP_THRESHOLD_OPERATION); // Search for log files: plog then clog, reads it, then apply all // committed operation, finally deletes it. lockFile = new File(dir, LOCK); if (! lockFile.createNewFile()) { logmon.log(BasicLevel.FATAL, "ATransaction.init(): Either the server is already running, " + "either you have to remove lock file: " + lockFile.getAbsolutePath()); throw new IOException("Transaction already running."); } lockFile.deleteOnExit(); logFilePN = new File(dir, LOG); plogFilePN = new File(dir, PLOG); Hashtable tempLog = new Hashtable(); restart(tempLog, logFilePN); restart(tempLog, plogFilePN); commit(tempLog); plogFilePN.delete(); logFilePN.delete(); clog = new Hashtable(CLEANUP_THRESHOLD_OPERATION / 2); plog = new Hashtable(CLEANUP_THRESHOLD_OPERATION / 2); baos = new ByteArrayOutputStream(10 * Kb); dos = new DataOutputStream(baos); newLogFile(); lock = new Object(); garbage = false; gThread = new Thread(this, "TGarbage"); gThread.start(); }
public final void initRepository() throws IOException { Operation.initPool(CLEANUP_THRESHOLD_OPERATION); // Search for log files: plog then clog, reads it, then apply all // committed operation, finally deletes it. lockFile = new File(dir, LOCK); if (! lockFile.createNewFile()) { logmon.log(BasicLevel.FATAL, "ATransaction.init(): Either the server is already running, " + "either you have to remove lock file: " + lockFile.getAbsolutePath()); throw new IOException("Transaction already running."); } lockFile.deleteOnExit(); logFilePN = new File(dir, LOG); plogFilePN = new File(dir, PLOG); Hashtable tempLog = new Hashtable(); restart(tempLog, logFilePN); restart(tempLog, plogFilePN); commit(tempLog); plogFilePN.delete(); logFilePN.delete(); clog = new Hashtable(CLEANUP_THRESHOLD_OPERATION / 2); plog = new Hashtable(CLEANUP_THRESHOLD_OPERATION / 2); baos = new ByteArrayOutputStream(10 * Kb); dos = new DataOutputStream(baos); newLogFile(); lock = new Object(); garbage = false; gThread = new Thread(this, "TGarbage"); gThread.start(); }