Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -977,12 +977,16 @@ private void loadFSImage(File curFile, MD5Hash expectedMd5,
" but expecting " + expectedMd5);
}

long txId = loader.getLoadedImageTxId();
final long txId = setLastAppliedTxId(loader);
LOG.info("Loaded image for txid " + txId + " from " + curFile);
lastAppliedTxId = txId;
storage.setMostRecentCheckpointInfo(txId, curFile.lastModified());
}

synchronized long setLastAppliedTxId(FSImageFormat.LoaderDelegator loader) {
lastAppliedTxId = loader.getLoadedImageTxId();
return lastAppliedTxId;
}

/**
* Save the contents of the FS image to the file.
*/
Expand Down Expand Up @@ -1215,8 +1219,9 @@ public void removeFromCheckpointing(long txid) {
}

void save(FSNamesystem src, File dst) throws IOException {
final SaveNamespaceContext context = new SaveNamespaceContext(src,
getCorrectLastAppliedOrWrittenTxId(), new Canceler());
final long txid = getCorrectLastAppliedOrWrittenTxId();
LOG.info("save fsimage with txid={} to {}", txid, dst.getAbsolutePath());
final SaveNamespaceContext context = new SaveNamespaceContext(src, txid, new Canceler());
final Storage.StorageDirectory storageDirectory = new Storage.StorageDirectory(dst);
Files.createDirectories(storageDirectory.getCurrentDir().toPath());
new FSImageSaver(context, storageDirectory, NameNodeFile.IMAGE).run();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ int run(Configuration conf, AtomicInteger errorCount) throws Exception {
initConf(conf);

// check INodeReference
NameNode.initMetrics(conf, HdfsServerConstants.NamenodeRole.NAMENODE); // to avoid NPE
final FSNamesystem namesystem = checkINodeReference(conf, errorCount);

// check INodeMap
Expand Down Expand Up @@ -276,14 +277,16 @@ public void run() {
namesystem.getFSDirectory().writeLock();
try {
loader.load(fsImageFile, false);
fsImage.setLastAppliedTxId(loader);
} finally {
namesystem.getFSDirectory().writeUnlock();
namesystem.writeUnlock("loadImage");
}
}
t.cancel();
Cli.println("Loaded %s %s successfully in %s",
FS_IMAGE, fsImageFile, StringUtils.formatTime(now() - loadStart));
Cli.println("Loaded %s %s with txid %d successfully in %s",
FS_IMAGE, fsImageFile, namesystem.getFSImage().getLastAppliedTxId(),
StringUtils.formatTime(now() - loadStart));
return namesystem;
}

Expand Down