コード例 #1
0
        /// <exception cref="System.IO.IOException"/>
        private static IDictionary <long, long[]> LoadINodeDirectorySection(InputStream @in
                                                                            , IList <long> refIdList)
        {
            Log.Info("Loading inode directory section");
            IDictionary <long, long[]> dirs = Maps.NewHashMap();
            long counter = 0;

            while (true)
            {
                FsImageProto.INodeDirectorySection.DirEntry e = FsImageProto.INodeDirectorySection.DirEntry
                                                                .ParseDelimitedFrom(@in);
                // note that in is a LimitedInputStream
                if (e == null)
                {
                    break;
                }
                ++counter;
                long[] l = new long[e.GetChildrenCount() + e.GetRefChildrenCount()];
                for (int i = 0; i < e.GetChildrenCount(); ++i)
                {
                    l[i] = e.GetChildren(i);
                }
                for (int i_1 = e.GetChildrenCount(); i_1 < l.Length; i_1++)
                {
                    int refId = e.GetRefChildren(i_1 - e.GetChildrenCount());
                    l[i_1] = refIdList[refId];
                }
                dirs[e.GetParent()] = l;
            }
            Log.Info("Loaded " + counter + " directories");
            return(dirs);
        }
コード例 #2
0
        /// <summary>Scan the INodeDirectory section to construct the namespace.</summary>
        /// <exception cref="System.IO.IOException"/>
        private void BuildNamespace(InputStream @in)
        {
            int count = 0;

            while (true)
            {
                FsImageProto.INodeDirectorySection.DirEntry e = FsImageProto.INodeDirectorySection.DirEntry
                                                                .ParseDelimitedFrom(@in);
                if (e == null)
                {
                    break;
                }
                count++;
                if (Log.IsDebugEnabled() && count % 10000 == 0)
                {
                    Log.Debug("Scanned {} directories.", count);
                }
                long parentId = e.GetParent();
                // Referred INode is not support for now.
                for (int i = 0; i < e.GetChildrenCount(); i++)
                {
                    long childId = e.GetChildren(i);
                    metadataMap.PutDirChild(parentId, childId);
                }
                Preconditions.CheckState(e.GetRefChildrenCount() == 0);
            }
            Log.Info("Scanned {} INode directories to build namespace.", count);
        }