/// <summary>Load FileDiff list for a file with snapshot feature</summary> /// <exception cref="System.IO.IOException"/> private void LoadFileDiffList(InputStream @in, INodeFile file, int size) { FileDiffList diffs = new FileDiffList(); FSImageFormatProtobuf.LoaderContext state = parent.GetLoaderContext(); for (int i = 0; i < size; i++) { FsImageProto.SnapshotDiffSection.FileDiff pbf = FsImageProto.SnapshotDiffSection.FileDiff .ParseDelimitedFrom(@in); INodeFileAttributes copy = null; if (pbf.HasSnapshotCopy()) { FsImageProto.INodeSection.INodeFile fileInPb = pbf.GetSnapshotCopy(); PermissionStatus permission = FSImageFormatPBINode.Loader.LoadPermission(fileInPb .GetPermission(), state.GetStringTable()); AclFeature acl = null; if (fileInPb.HasAcl()) { int[] entries = AclEntryStatusFormat.ToInt(FSImageFormatPBINode.Loader.LoadAclEntries (fileInPb.GetAcl(), state.GetStringTable())); acl = new AclFeature(entries); } XAttrFeature xAttrs = null; if (fileInPb.HasXAttrs()) { xAttrs = new XAttrFeature(FSImageFormatPBINode.Loader.LoadXAttrs(fileInPb.GetXAttrs (), state.GetStringTable())); } copy = new INodeFileAttributes.SnapshotCopy(pbf.GetName().ToByteArray(), permission , acl, fileInPb.GetModificationTime(), fileInPb.GetAccessTime(), (short)fileInPb .GetReplication(), fileInPb.GetPreferredBlockSize(), unchecked ((byte)fileInPb.GetStoragePolicyID ()), xAttrs); } FileDiff diff = new FileDiff(pbf.GetSnapshotId(), copy, null, pbf.GetFileSize()); IList <HdfsProtos.BlockProto> bpl = pbf.GetBlocksList(); BlockInfoContiguous[] blocks = new BlockInfoContiguous[bpl.Count]; for (int j = 0; j < e; ++j) { Block blk = PBHelper.Convert(bpl[j]); BlockInfoContiguous storedBlock = fsn.GetBlockManager().GetStoredBlock(blk); if (storedBlock == null) { storedBlock = fsn.GetBlockManager().AddBlockCollection(new BlockInfoContiguous(blk , copy.GetFileReplication()), file); } blocks[j] = storedBlock; } if (blocks.Length > 0) { diff.SetBlocks(blocks); } diffs.AddFirst(diff); } file.AddSnapshotFeature(diffs); }
/// <exception cref="System.IO.IOException"/> public static FileDiffList LoadFileDiffList(DataInput @in, FSImageFormat.Loader loader ) { int size = @in.ReadInt(); if (size == -1) { return(null); } else { FileDiffList diffs = new FileDiffList(); FileDiff posterior = null; for (int i = 0; i < size; i++) { FileDiff d = LoadFileDiff(posterior, @in, loader); diffs.AddFirst(d); posterior = d; } return(diffs); } }
public FileWithSnapshotFeature(FileDiffList diffs) { this.diffs = diffs != null ? diffs : new FileDiffList(); }