/** * Finalizes the current edit log and opens a new log segment. * * @param layoutVersion The layout version of the new edit log segment. * @return the transaction id of the BEGIN_LOG_SEGMENT transaction in the new * log. */ synchronized long rollEditLog(int layoutVersion) throws IOException { LOG.info("Rolling edit logs"); endCurrentLogSegment(true); long nextTxId = getLastWrittenTxId() + 1; startLogSegmentAndWriteHeaderTxn(nextTxId, layoutVersion); assert curSegmentTxId == nextTxId; return nextTxId; }
/** * Shutdown the file store. */ synchronized void close() { if (state == State.CLOSED) { LOG.debug("Closing log when already closed"); return; } try { if (state == State.IN_SEGMENT) { assert editLogStream != null; waitForSyncToFinish(); endCurrentLogSegment(true); } } finally { if (journalSet != null && !journalSet.isEmpty()) { try { synchronized(journalSetLock) { journalSet.close(); } } catch (IOException ioe) { LOG.warn("Error closing journalSet", ioe); } } state = State.CLOSED; } }
/** * Remote namenode just has started a log segment, start log segment locally. */ public synchronized void startLogSegment(long txid, boolean abortCurrentLogSegment, int layoutVersion) throws IOException { LOG.info("Started a new log segment at txid " + txid); if (isSegmentOpen()) { if (getLastWrittenTxId() == txid - 1) { //In sync with the NN, so end and finalize the current segment` endCurrentLogSegment(false); } else { //Missed some transactions: probably lost contact with NN temporarily. final String mess = "Cannot start a new log segment at txid " + txid + " since only up to txid " + getLastWrittenTxId() + " have been written in the log segment starting at " + getCurSegmentTxId() + "."; if (abortCurrentLogSegment) { //Mark the current segment as aborted. LOG.warn(mess); abortCurrentLogSegment(); } else { throw new IOException(mess); } } } setNextTxId(txid); startLogSegment(txid, layoutVersion); }
newSharedEditLog.endCurrentLogSegment(false); LOG.debug("ending log segment because of END_LOG_SEGMENT op in " + stream); LOG.debug("ending log segment because of end of stream in " + stream); newSharedEditLog.logSync(); newSharedEditLog.endCurrentLogSegment(false); segmentOpen = false;
editLog.endCurrentLogSegment(true);
/** * Finalizes the current edit log and opens a new log segment. * * @param layoutVersion The layout version of the new edit log segment. * @return the transaction id of the BEGIN_LOG_SEGMENT transaction in the new * log. */ synchronized long rollEditLog() throws IOException { LOG.info("Rolling edit logs"); endCurrentLogSegment(true); long nextTxId = getLastWrittenTxId() + 1; startLogSegment(nextTxId, true); assert curSegmentTxId == nextTxId; return nextTxId; }
/** * Shutdown the file store. */ synchronized void close() { if (state == State.CLOSED) { LOG.debug("Closing log when already closed"); return; } try { if (state == State.IN_SEGMENT) { assert editLogStream != null; waitForSyncToFinish(); endCurrentLogSegment(true); } } finally { if (journalSet != null && !journalSet.isEmpty()) { try { synchronized(journalSetLock) { journalSet.close(); } } catch (IOException ioe) { LOG.warn("Error closing journalSet", ioe); } } state = State.CLOSED; } }
/** * Finalizes the current edit log and opens a new log segment. * * @param layoutVersion The layout version of the new edit log segment. * @return the transaction id of the BEGIN_LOG_SEGMENT transaction in the new * log. */ synchronized long rollEditLog() throws IOException { LOG.info("Rolling edit logs"); endCurrentLogSegment(true); long nextTxId = getLastWrittenTxId() + 1; startLogSegment(nextTxId, true); assert curSegmentTxId == nextTxId; return nextTxId; }
newSharedEditLog.endCurrentLogSegment(false); LOG.debug("ending log segment because of END_LOG_SEGMENT op in " + stream); LOG.debug("ending log segment because of end of stream in " + stream); newSharedEditLog.logSync(); newSharedEditLog.endCurrentLogSegment(false); segmentOpen = false;
if (editLog.getLastWrittenTxId() == txid - 1) { editLog.endCurrentLogSegment(false); } else {
/** * Shutdown the file store. */ synchronized void close() { if (state == State.CLOSED) { LOG.debug("Closing log when already closed"); return; } try { if (state == State.IN_SEGMENT) { assert editLogStream != null; waitForSyncToFinish(); endCurrentLogSegment(true); } } finally { if (journalSet != null && !journalSet.isEmpty()) { try { synchronized(journalSetLock) { journalSet.close(); } } catch (IOException ioe) { LOG.warn("Error closing journalSet", ioe); } } state = State.CLOSED; } }
editLog.endCurrentLogSegment(true);
doNothing().when(spyLog).endCurrentLogSegment(true); spyLog.openForWrite(); assertTrue("should exist: " + inProgressFile, inProgressFile.exists());
newSharedEditLog.endCurrentLogSegment(false); LOG.debug("ending log segment because of END_LOG_SEGMENT op in " + stream); LOG.debug("ending log segment because of end of stream in " + stream); newSharedEditLog.logSync(); newSharedEditLog.endCurrentLogSegment(false); segmentOpen = false;
if (editLog.getLastWrittenTxId() == txid - 1) { editLog.endCurrentLogSegment(false); } else {
doNothing().when(spyLog).endCurrentLogSegment(Mockito.anyBoolean()); DFSTestUtil.setEditLogForTesting(cluster.getNamesystem(), spyLog);
doNothing().when(spyLog).endCurrentLogSegment(true); DFSTestUtil.setEditLogForTesting(cluster.getNamesystem(), spyLog);