|
@@ -138,7 +138,7 @@ public class FSEditLogLoader {
|
|
|
|
|
|
long loadFSEdits(EditLogInputStream edits, long expectedStartingTxId)
|
|
|
throws IOException {
|
|
|
- return loadFSEdits(edits, expectedStartingTxId, null, null);
|
|
|
+ return loadFSEdits(edits, expectedStartingTxId, Long.MAX_VALUE, null, null);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -147,6 +147,7 @@ public class FSEditLogLoader {
|
|
|
* along.
|
|
|
*/
|
|
|
long loadFSEdits(EditLogInputStream edits, long expectedStartingTxId,
|
|
|
+ long maxTxnsToRead,
|
|
|
StartupOption startOpt, MetaRecoveryContext recovery) throws IOException {
|
|
|
StartupProgress prog = NameNode.getStartupProgress();
|
|
|
Step step = createStartupProgressStep(edits);
|
|
@@ -154,9 +155,10 @@ public class FSEditLogLoader {
|
|
|
fsNamesys.writeLock();
|
|
|
try {
|
|
|
long startTime = monotonicNow();
|
|
|
- FSImage.LOG.info("Start loading edits file " + edits.getName());
|
|
|
+ FSImage.LOG.info("Start loading edits file " + edits.getName()
|
|
|
+ + " maxTxnsToRead = " + maxTxnsToRead);
|
|
|
long numEdits = loadEditRecords(edits, false, expectedStartingTxId,
|
|
|
- startOpt, recovery);
|
|
|
+ maxTxnsToRead, startOpt, recovery);
|
|
|
FSImage.LOG.info("Edits file " + edits.getName()
|
|
|
+ " of size " + edits.length() + " edits # " + numEdits
|
|
|
+ " loaded in " + (monotonicNow()-startTime)/1000 + " seconds");
|
|
@@ -171,8 +173,13 @@ public class FSEditLogLoader {
|
|
|
long loadEditRecords(EditLogInputStream in, boolean closeOnExit,
|
|
|
long expectedStartingTxId, StartupOption startOpt,
|
|
|
MetaRecoveryContext recovery) throws IOException {
|
|
|
- FSDirectory fsDir = fsNamesys.dir;
|
|
|
+ return loadEditRecords(in, closeOnExit, expectedStartingTxId,
|
|
|
+ Long.MAX_VALUE, startOpt, recovery);
|
|
|
+ }
|
|
|
|
|
|
+ long loadEditRecords(EditLogInputStream in, boolean closeOnExit,
|
|
|
+ long expectedStartingTxId, long maxTxnsToRead, StartupOption startOpt,
|
|
|
+ MetaRecoveryContext recovery) throws IOException {
|
|
|
EnumMap<FSEditLogOpCodes, Holder<Integer>> opCounts =
|
|
|
new EnumMap<FSEditLogOpCodes, Holder<Integer>>(FSEditLogOpCodes.class);
|
|
|
|
|
@@ -181,6 +188,7 @@ public class FSEditLogLoader {
|
|
|
}
|
|
|
|
|
|
fsNamesys.writeLock();
|
|
|
+ FSDirectory fsDir = fsNamesys.dir;
|
|
|
fsDir.writeLock();
|
|
|
|
|
|
long recentOpcodeOffsets[] = new long[4];
|
|
@@ -285,6 +293,9 @@ public class FSEditLogLoader {
|
|
|
}
|
|
|
numEdits++;
|
|
|
totalEdits++;
|
|
|
+ if(numEdits >= maxTxnsToRead) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
} catch (RollingUpgradeOp.RollbackException e) {
|
|
|
LOG.info("Stopped at OP_START_ROLLING_UPGRADE for rollback.");
|
|
|
break;
|
|
@@ -308,7 +319,11 @@ public class FSEditLogLoader {
|
|
|
|
|
|
if (FSImage.LOG.isDebugEnabled()) {
|
|
|
dumpOpCounts(opCounts);
|
|
|
+ FSImage.LOG.debug("maxTxnsToRead = " + maxTxnsToRead
|
|
|
+ + " actual edits read = " + numEdits);
|
|
|
}
|
|
|
+ assert numEdits <= maxTxnsToRead || numEdits == 1 :
|
|
|
+ "should read at least one txn, but not more than the configured max";
|
|
|
}
|
|
|
return numEdits;
|
|
|
}
|