public final synchronized void commit(boolean release) throws IOException { if (phase != RUN) throw new IllegalStateException("Can not commit."); if (logmon.isLoggable(BasicLevel.DEBUG)) logmon.log(BasicLevel.DEBUG, "NTransaction, commit(" + release + ')'); Hashtable<Object, Operation> log = perThreadContext.get().getLog(); if (! log.isEmpty()) { logFile.commit(log); log.clear(); } setPhase(COMMIT); if (logmon.isLoggable(BasicLevel.DEBUG)) logmon.log(BasicLevel.DEBUG, "NTransaction, committed"); if (release) { setPhase(FREE); // wake-up an eventually user's thread in begin notify(); } }
public final synchronized void commit(boolean release) throws IOException { if (phase != RUN) throw new IllegalStateException("Can not commit."); if (logmon.isLoggable(BasicLevel.DEBUG)) logmon.log(BasicLevel.DEBUG, "NTransaction, commit(" + release + ')'); Hashtable log = ((Context) perThreadContext.get()).getLog(); if (! log.isEmpty()) { logFile.commit(log); log.clear(); } setPhase(COMMIT); if (logmon.isLoggable(BasicLevel.DEBUG)) logmon.log(BasicLevel.DEBUG, "NTransaction, committed"); if (release) { setPhase(FREE); // wake-up an eventually user's thread in begin notify(); } }
/** * Close the transaction module. * It waits all transactions termination, the module will be initialized * anew before reusing it. * The log file is garbaged then closed. */ public synchronized void close() { if (logmon.isLoggable(BasicLevel.DEBUG)) logmon.log(BasicLevel.DEBUG, "NTransaction, closes"); if (phase == INIT) return; while (phase != FREE) { // Wait for the transaction subsystem to be free try { wait(); } catch (InterruptedException exc) { } } setPhase(FINALIZE); logFile.stop(); setPhase(INIT); if (logmon.isLoggable(BasicLevel.INFO)) { logmon.log(BasicLevel.INFO, "NTransaction, closed: " + toString()); } }
/** * Stops the transaction module. * It waits all transactions termination, then the module is kept * in a FREE 'ready to use' state. * The log file is garbaged, all operations are reported to disk. */ public synchronized void stop() { if (logmon.isLoggable(BasicLevel.DEBUG)) logmon.log(BasicLevel.DEBUG, "NTransaction, stops"); while (phase != FREE) { // Wait for the transaction subsystem to be free try { wait(); } catch (InterruptedException exc) { } } setPhase(FINALIZE); try { logFile.garbage(); } catch (IOException exc) { logmon.log(BasicLevel.WARN, "NTransaction, can't garbage logfile", exc); } setPhase(FREE); if (logmon.isLoggable(BasicLevel.INFO)) { logmon.log(BasicLevel.INFO, "NTransaction, stopped: " + toString()); } }
/** * Garbage the log file. * It waits all transactions termination, then the log file is garbaged * and all operations are reported to disk. */ public final synchronized void garbage() { if (logmon.isLoggable(BasicLevel.DEBUG)) logmon.log(BasicLevel.DEBUG, "NTransaction, garbages"); while (phase != FREE) { // Wait for the transaction subsystem to be free try { wait(); } catch (InterruptedException exc) { } } setPhase(GARBAGE); try { logFile.garbage(); } catch (IOException exc) { logmon.log(BasicLevel.WARN, "NTransaction, can't garbage logfile", exc); } setPhase(FREE); if (logmon.isLoggable(BasicLevel.INFO)) { logmon.log(BasicLevel.INFO, "NTransaction, garbaged: " + toString()); } }
/** * Close the transaction module. * It waits all transactions termination, the module will be initialized * anew before reusing it. * The log file is garbaged then closed. */ public synchronized void close() { if (logmon.isLoggable(BasicLevel.DEBUG)) logmon.log(BasicLevel.DEBUG, "NTransaction, closes"); if (phase == INIT) return; while (phase != FREE) { // Wait for the transaction subsystem to be free try { wait(); } catch (InterruptedException exc) { } } setPhase(FINALIZE); logFile.stop(); setPhase(INIT); if (logmon.isLoggable(BasicLevel.INFO)) { logmon.log(BasicLevel.INFO, "NTransaction, closed: " + toString()); } }
/** * Garbage the log file. * It waits all transactions termination, then the log file is garbaged * and all operations are reported to disk. */ public final synchronized void garbage() { if (logmon.isLoggable(BasicLevel.DEBUG)) logmon.log(BasicLevel.DEBUG, "NTransaction, garbages"); while (phase != FREE) { // Wait for the transaction subsystem to be free try { wait(); } catch (InterruptedException exc) { } } setPhase(GARBAGE); try { logFile.garbage(); } catch (IOException exc) { logmon.log(BasicLevel.WARN, "NTransaction, can't garbage logfile", exc); } setPhase(FREE); if (logmon.isLoggable(BasicLevel.INFO)) { logmon.log(BasicLevel.INFO, "NTransaction, garbaged: " + toString()); } }
/** * Stops the transaction module. * It waits all transactions termination, then the module is kept * in a FREE 'ready to use' state. * The log file is garbaged, all operations are reported to disk. */ public synchronized void stop() { if (logmon.isLoggable(BasicLevel.DEBUG)) logmon.log(BasicLevel.DEBUG, "NTransaction, stops"); while (phase != FREE) { // Wait for the transaction subsystem to be free try { wait(); } catch (InterruptedException exc) { } } setPhase(FINALIZE); try { logFile.garbage(); } catch (IOException exc) { logmon.log(BasicLevel.WARN, "NTransaction, can't garbage logfile", exc); } setPhase(FREE); if (logmon.isLoggable(BasicLevel.INFO)) { logmon.log(BasicLevel.INFO, "NTransaction, stopped: " + toString()); } }