/// <summary>Update the length for the last block</summary> /// <param name="lastBlockLength">The length of the last block reported from client</param> /// <exception cref="System.IO.IOException"/> internal virtual void UpdateLengthOfLastBlock(INodeFile f, long lastBlockLength) { BlockInfoContiguous lastBlock = f.GetLastBlock(); System.Diagnostics.Debug.Assert((lastBlock != null), "The last block for path " + f.GetFullPathName() + " is null when updating its length"); System.Diagnostics.Debug.Assert((lastBlock is BlockInfoContiguousUnderConstruction ), "The last block for path " + f.GetFullPathName() + " is not a BlockInfoUnderConstruction when updating its length" ); lastBlock.SetNumBytes(lastBlockLength); }
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); }