public void append(TransactionGuide guide) { if (!_nextTransactionInitialized) throw new IllegalStateException( "Journal.update() has to be called at least once before Journal.append()."); DurableOutputStream myOutputJournal; DurableOutputStream outputJournalToClose = null; guide.startTurn(); try { guide.checkSystemVersion(_nextTransaction); if (!isOutputJournalStillValid()) { outputJournalToClose = _outputJournal; _outputJournal = createOutputJournal(_nextTransaction); _journalAgeTimer = StopWatch.start(); } _nextTransaction++; myOutputJournal = _outputJournal; } finally { guide.endTurn(); } try { myOutputJournal.sync(guide); } catch (IOException iox) { handle(iox, _outputJournal.file(), "writing to"); } guide.startTurn(); try { try { if (outputJournalToClose != null) outputJournalToClose.close(); } catch (IOException iox) { handle(iox, outputJournalToClose.file(), "closing"); } } finally { guide.endTurn(); } }
private boolean isOutputJournalTooOld() { return _journalAgeThresholdInMillis != 0 && _journalAgeTimer.millisEllapsed() >= _journalAgeThresholdInMillis; }