|
@@ -977,12 +977,16 @@ public class FSImage implements Closeable {
|
|
|
" 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.
|
|
|
*/
|
|
@@ -1215,8 +1219,9 @@ public class FSImage implements Closeable {
|
|
|
}
|
|
|
|
|
|
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();
|