Ejemplo n.º 1
0
            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);
            }