/** * Returns the name of the currently active underlying stream. The default * implementation returns the same value as getName unless overridden by the * subclass. * * @return String name of the currently active underlying stream */ public String getCurrentStreamName() { return getName(); }
@Override public String getName() { StringBuilder bld = new StringBuilder(); String prefix = ""; for (EditLogInputStream elis : streams) { bld.append(prefix); bld.append(elis.getName()); prefix = ", "; } return bld.toString(); }
try { if (prevTxId != HdfsServerConstants.INVALID_TXID) { LOG.info("Fast-forwarding stream '" + streams[curIdx].getName() + "' to transaction ID " + (prevTxId + 1)); streams[curIdx].skipUntil(prevTxId + 1); if (newLast < oldLast) { throw new IOException("We encountered an error reading " + streams[curIdx].getName() + ". During automatic edit log " + "failover, we noticed that all of the remaining edit log " + "streams are shorter than the current one! The best " + streams[curIdx].getName() + "; failing over to edit log " + streams[curIdx + 1].getName(), prevException); curIdx++; state = State.SKIP_UNTIL; streams[curIdx + 1].getName()); curIdx++; state = State.SKIP_UNTIL;
/** * Load an edit log, and apply the changes to the in-memory structure * This is where we apply edits that we've been writing to disk all * along. */ long loadFSEdits(EditLogInputStream edits, long expectedStartingTxId, long maxTxnsToRead, StartupOption startOpt, MetaRecoveryContext recovery) throws IOException { StartupProgress prog = NameNode.getStartupProgress(); Step step = createStartupProgressStep(edits); prog.beginStep(Phase.LOADING_EDITS, step); fsNamesys.writeLock(); try { long startTime = monotonicNow(); FSImage.LOG.info("Start loading edits file " + edits.getName() + " maxTxnsToRead = " + maxTxnsToRead); long numEdits = loadEditRecords(edits, false, expectedStartingTxId, maxTxnsToRead, startOpt, recovery); FSImage.LOG.info("Edits file " + edits.getName() + " of size " + edits.length() + " edits # " + numEdits + " loaded in " + (monotonicNow()-startTime)/1000 + " seconds"); return numEdits; } finally { edits.close(); fsNamesys.writeUnlock("loadFSEdits"); prog.endStep(Phase.LOADING_EDITS, step); } }
/** * Returns the name of the currently active underlying stream. The default * implementation returns the same value as getName unless overridden by the * subclass. * * @return String name of the currently active underlying stream */ public String getCurrentStreamName() { return getName(); }
/** * Returns the name of the currently active underlying stream. The default * implementation returns the same value as getName unless overridden by the * subclass. * * @return String name of the currently active underlying stream */ public String getCurrentStreamName() { return getName(); }
@Override public String getName() { StringBuilder bld = new StringBuilder(); String prefix = ""; for (EditLogInputStream elis : streams) { bld.append(prefix); bld.append(elis.getName()); prefix = ", "; } return bld.toString(); }
@Override public String getName() { StringBuilder bld = new StringBuilder(); String prefix = ""; for (EditLogInputStream elis : streams) { bld.append(prefix); bld.append(elis.getName()); prefix = ", "; } return bld.toString(); }
/** * Load an edit log, and apply the changes to the in-memory structure * This is where we apply edits that we've been writing to disk all * along. */ int loadFSEdits(EditLogInputStream edits, long expectedStartingTxId) throws IOException { long startTime = now(); currentTxId = expectedStartingTxId; int numEdits = loadFSEdits(edits, true); FSImage.LOG.info("Edits file " + edits.getName() + " of size " + edits.length() + " edits # " + numEdits + " loaded in " + (now()-startTime)/1000 + " seconds."); return numEdits; }
try { if (prevTxId != HdfsConstants.INVALID_TXID) { LOG.info("Fast-forwarding stream '" + streams[curIdx].getName() + "' to transaction ID " + (prevTxId + 1)); streams[curIdx].skipUntil(prevTxId + 1); if (newLast < oldLast) { throw new IOException("We encountered an error reading " + streams[curIdx].getName() + ". During automatic edit log " + "failover, we noticed that all of the remaining edit log " + "streams are shorter than the current one! The best " + streams[curIdx].getName() + "; failing over to edit log " + streams[curIdx + 1].getName(), prevException); curIdx++; state = State.SKIP_UNTIL; streams[curIdx + 1].getName()); curIdx++; state = State.SKIP_UNTIL;
try { if (prevTxId != HdfsConstants.INVALID_TXID) { LOG.info("Fast-forwarding stream '" + streams[curIdx].getName() + "' to transaction ID " + (prevTxId + 1)); streams[curIdx].skipUntil(prevTxId + 1); if (newLast < oldLast) { throw new IOException("We encountered an error reading " + streams[curIdx].getName() + ". During automatic edit log " + "failover, we noticed that all of the remaining edit log " + "streams are shorter than the current one! The best " + streams[curIdx].getName() + "; failing over to edit log " + streams[curIdx + 1].getName(), prevException); curIdx++; state = State.SKIP_UNTIL; streams[curIdx + 1].getName()); curIdx++; state = State.SKIP_UNTIL;
/** * Load an edit log, and apply the changes to the in-memory structure * This is where we apply edits that we've been writing to disk all * along. */ long loadFSEdits(EditLogInputStream edits, long expectedStartingTxId, StartupOption startOpt, MetaRecoveryContext recovery) throws IOException { StartupProgress prog = NameNode.getStartupProgress(); Step step = createStartupProgressStep(edits); prog.beginStep(Phase.LOADING_EDITS, step); fsNamesys.writeLock(); try { long startTime = monotonicNow(); FSImage.LOG.info("Start loading edits file " + edits.getName()); long numEdits = loadEditRecords(edits, false, expectedStartingTxId, startOpt, recovery); FSImage.LOG.info("Edits file " + edits.getName() + " of size " + edits.length() + " edits # " + numEdits + " loaded in " + (monotonicNow()-startTime)/1000 + " seconds"); return numEdits; } finally { edits.close(); fsNamesys.writeUnlock("loadFSEdits"); prog.endStep(Phase.LOADING_EDITS, step); } }
/** * Load an edit log, and apply the changes to the in-memory structure * This is where we apply edits that we've been writing to disk all * along. */ long loadFSEdits(EditLogInputStream edits, long expectedStartingTxId, StartupOption startOpt, MetaRecoveryContext recovery) throws IOException { StartupProgress prog = NameNode.getStartupProgress(); Step step = createStartupProgressStep(edits); prog.beginStep(Phase.LOADING_EDITS, step); fsNamesys.writeLock(); try { long startTime = monotonicNow(); FSImage.LOG.info("Start loading edits file " + edits.getName()); long numEdits = loadEditRecords(edits, false, expectedStartingTxId, startOpt, recovery); FSImage.LOG.info("Edits file " + edits.getName() + " of size " + edits.length() + " edits # " + numEdits + " loaded in " + (monotonicNow()-startTime)/1000 + " seconds"); return numEdits; } finally { edits.close(); fsNamesys.writeUnlock("loadFSEdits"); prog.endStep(Phase.LOADING_EDITS, step); } }
private static long readAllEdits(Collection<EditLogInputStream> streams, long startTxId) throws IOException { FSEditLogOp op; long nextTxId = startTxId; long numTx = 0; for (EditLogInputStream s : streams) { while (true) { op = s.readOp(); if (op == null) break; if (op.getTransactionId() != nextTxId) { throw new IOException("out of order transaction ID! expected " + nextTxId + " but got " + op.getTransactionId() + " when " + "reading " + s.getName()); } numTx++; nextTxId = op.getTransactionId() + 1; } } return numTx; }
in.close(); FSImage.LOG.info("Edits file " + edits.getName() + " of size " + edits.length() + " edits # " + numEdits + " loaded in " + (FSNamesystem.now()-startTime)/1000 + " seconds.");