/// <summary>Load the under-construction files section, and update the lease map</summary> /// <exception cref="System.IO.IOException"/> internal void LoadFilesUnderConstructionSection(InputStream @in) { while (true) { FsImageProto.FilesUnderConstructionSection.FileUnderConstructionEntry entry = FsImageProto.FilesUnderConstructionSection.FileUnderConstructionEntry .ParseDelimitedFrom(@in); if (entry == null) { break; } // update the lease manager INodeFile file = dir.GetInode(entry.GetInodeId()).AsFile(); FileUnderConstructionFeature uc = file.GetFileUnderConstructionFeature(); Preconditions.CheckState(uc != null); // file must be under-construction fsn.leaseManager.AddLease(uc.GetClientName(), entry.GetFullPath()); } }
/// <exception cref="System.IO.IOException"/> internal void SerializeFilesUCSection(OutputStream @out) { IDictionary <string, INodeFile> ucMap = fsn.GetFilesUnderConstruction(); foreach (KeyValuePair <string, INodeFile> entry in ucMap) { string path = entry.Key; INodeFile file = entry.Value; FsImageProto.FilesUnderConstructionSection.FileUnderConstructionEntry.Builder b = FsImageProto.FilesUnderConstructionSection.FileUnderConstructionEntry.NewBuilder ().SetInodeId(file.GetId()).SetFullPath(path); FsImageProto.FilesUnderConstructionSection.FileUnderConstructionEntry e = ((FsImageProto.FilesUnderConstructionSection.FileUnderConstructionEntry )b.Build()); e.WriteDelimitedTo(@out); } parent.CommitSection(summary, FSImageFormatProtobuf.SectionName.FilesUnderconstruction ); }
/// <exception cref="System.IO.IOException"/> private void DumpFileUnderConstructionSection(InputStream @in) { @out.Write("<FileUnderConstructionSection>"); while (true) { FsImageProto.FilesUnderConstructionSection.FileUnderConstructionEntry e = FsImageProto.FilesUnderConstructionSection.FileUnderConstructionEntry .ParseDelimitedFrom(@in); if (e == null) { break; } @out.Write("<inode>"); O("id", e.GetInodeId()).O("path", e.GetFullPath()); @out.Write("</inode>\n"); } @out.Write("</FileUnderConstructionSection>\n"); }