private void DumpINodeFile(FsImageProto.INodeSection.INodeFile f) { O("replication", f.GetReplication()).O("mtime", f.GetModificationTime()).O("atime" , f.GetAccessTime()).O("perferredBlockSize", f.GetPreferredBlockSize()).O("permission" , DumpPermission(f.GetPermission())); if (f.GetBlocksCount() > 0) { @out.Write("<blocks>"); foreach (HdfsProtos.BlockProto b in f.GetBlocksList()) { @out.Write("<block>"); O("id", b.GetBlockId()).O("genstamp", b.GetGenStamp()).O("numBytes", b.GetNumBytes ()); @out.Write("</block>\n"); } @out.Write("</blocks>\n"); } if (f.HasFileUC()) { FsImageProto.INodeSection.FileUnderConstructionFeature u = f.GetFileUC(); @out.Write("<file-under-construction>"); O("clientName", u.GetClientName()).O("clientMachine", u.GetClientMachine()); @out.Write("</file-under-construction>\n"); } }
private INodeFile LoadINodeFile(FsImageProto.INodeSection.INode n) { System.Diagnostics.Debug.Assert(n.GetType() == FsImageProto.INodeSection.INode.Type .File); FsImageProto.INodeSection.INodeFile f = n.GetFile(); IList <HdfsProtos.BlockProto> bp = f.GetBlocksList(); short replication = (short)f.GetReplication(); FSImageFormatProtobuf.LoaderContext state = parent.GetLoaderContext(); BlockInfoContiguous[] blocks = new BlockInfoContiguous[bp.Count]; for (int i = 0; i < e; ++i) { blocks[i] = new BlockInfoContiguous(PBHelper.Convert(bp[i]), replication); } PermissionStatus permissions = LoadPermission(f.GetPermission(), parent.GetLoaderContext ().GetStringTable()); INodeFile file = new INodeFile(n.GetId(), n.GetName().ToByteArray(), permissions, f.GetModificationTime(), f.GetAccessTime(), blocks, replication, f.GetPreferredBlockSize (), unchecked ((byte)f.GetStoragePolicyID())); if (f.HasAcl()) { int[] entries = AclEntryStatusFormat.ToInt(LoadAclEntries(f.GetAcl(), state.GetStringTable ())); file.AddAclFeature(new AclFeature(entries)); } if (f.HasXAttrs()) { file.AddXAttrFeature(new XAttrFeature(LoadXAttrs(f.GetXAttrs(), state.GetStringTable ()))); } // under-construction information if (f.HasFileUC()) { FsImageProto.INodeSection.FileUnderConstructionFeature uc = f.GetFileUC(); file.ToUnderConstruction(uc.GetClientName(), uc.GetClientMachine()); if (blocks.Length > 0) { BlockInfoContiguous lastBlk = file.GetLastBlock(); // replace the last block of file file.SetBlock(file.NumBlocks() - 1, new BlockInfoContiguousUnderConstruction(lastBlk , replication)); } } return(file); }