|
@@ -179,11 +179,13 @@ public final class FSImageFormatPBINode {
|
|
private final FSDirectory dir;
|
|
private final FSDirectory dir;
|
|
private final FSNamesystem fsn;
|
|
private final FSNamesystem fsn;
|
|
private final FSImageFormatProtobuf.Loader parent;
|
|
private final FSImageFormatProtobuf.Loader parent;
|
|
|
|
+ private final List<INodeFile> ucFiles;
|
|
|
|
|
|
Loader(FSNamesystem fsn, final FSImageFormatProtobuf.Loader parent) {
|
|
Loader(FSNamesystem fsn, final FSImageFormatProtobuf.Loader parent) {
|
|
this.fsn = fsn;
|
|
this.fsn = fsn;
|
|
this.dir = fsn.dir;
|
|
this.dir = fsn.dir;
|
|
this.parent = parent;
|
|
this.parent = parent;
|
|
|
|
+ this.ucFiles = new ArrayList<INodeFile>();
|
|
}
|
|
}
|
|
|
|
|
|
void loadINodeDirectorySection(InputStream in) throws IOException {
|
|
void loadINodeDirectorySection(InputStream in) throws IOException {
|
|
@@ -227,17 +229,25 @@ public final class FSImageFormatPBINode {
|
|
* Load the under-construction files section, and update the lease map
|
|
* Load the under-construction files section, and update the lease map
|
|
*/
|
|
*/
|
|
void loadFilesUnderConstructionSection(InputStream in) throws IOException {
|
|
void loadFilesUnderConstructionSection(InputStream in) throws IOException {
|
|
|
|
+ // This section is consumed, but not actually used for restoring leases.
|
|
while (true) {
|
|
while (true) {
|
|
FileUnderConstructionEntry entry = FileUnderConstructionEntry
|
|
FileUnderConstructionEntry entry = FileUnderConstructionEntry
|
|
.parseDelimitedFrom(in);
|
|
.parseDelimitedFrom(in);
|
|
if (entry == null) {
|
|
if (entry == null) {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- // update the lease manager
|
|
|
|
- INodeFile file = dir.getInode(entry.getInodeId()).asFile();
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Add a lease for each and every file under construction.
|
|
|
|
+ for (INodeFile file : ucFiles) {
|
|
FileUnderConstructionFeature uc = file.getFileUnderConstructionFeature();
|
|
FileUnderConstructionFeature uc = file.getFileUnderConstructionFeature();
|
|
Preconditions.checkState(uc != null); // file must be under-construction
|
|
Preconditions.checkState(uc != null); // file must be under-construction
|
|
- fsn.leaseManager.addLease(uc.getClientName(), entry.getFullPath());
|
|
|
|
|
|
+ String path = file.getFullPathName();
|
|
|
|
+ // Skip the deleted files in snapshot. This leaks UC inodes that are
|
|
|
|
+ // deleted from the current view.
|
|
|
|
+ if (path.startsWith("/")) {
|
|
|
|
+ fsn.leaseManager.addLease(uc.getClientName(), path);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -304,6 +314,7 @@ public final class FSImageFormatPBINode {
|
|
|
|
|
|
// under-construction information
|
|
// under-construction information
|
|
if (f.hasFileUC()) {
|
|
if (f.hasFileUC()) {
|
|
|
|
+ ucFiles.add(file);
|
|
INodeSection.FileUnderConstructionFeature uc = f.getFileUC();
|
|
INodeSection.FileUnderConstructionFeature uc = f.getFileUC();
|
|
file.toUnderConstruction(uc.getClientName(), uc.getClientMachine());
|
|
file.toUnderConstruction(uc.getClientName(), uc.getClientMachine());
|
|
if (blocks.length > 0) {
|
|
if (blocks.length > 0) {
|