Esempio n. 1
0
        /// <exception cref="System.IO.IOException"/>
        private static FileDiff LoadFileDiff(FileDiff posterior, DataInput @in, FSImageFormat.Loader
                                             loader)
        {
            // 1. Read the id of the Snapshot root to identify the Snapshot
            Org.Apache.Hadoop.Hdfs.Server.Namenode.Snapshot.Snapshot snapshot = loader.GetSnapshot
                                                                                    (@in);
            // 2. Load file size
            long fileSize = @in.ReadLong();
            // 3. Load snapshotINode
            INodeFileAttributes snapshotINode = @in.ReadBoolean() ? loader.LoadINodeFileAttributes
                                                    (@in) : null;

            return(new FileDiff(snapshot.GetId(), snapshotINode, posterior, fileSize));
        }
Esempio n. 2
0
        /// <summary>Load snapshots and snapshotQuota for a Snapshottable directory.</summary>
        /// <param name="snapshottableParent">The snapshottable directory for loading.</param>
        /// <param name="numSnapshots">The number of snapshots that the directory has.</param>
        /// <param name="loader">The loader</param>
        /// <exception cref="System.IO.IOException"/>
        public static void LoadSnapshotList(INodeDirectory snapshottableParent, int numSnapshots
                                            , DataInput @in, FSImageFormat.Loader loader)
        {
            DirectorySnapshottableFeature sf = snapshottableParent.GetDirectorySnapshottableFeature
                                                   ();

            Preconditions.CheckArgument(sf != null);
            for (int i = 0; i < numSnapshots; i++)
            {
                // read snapshots
                Org.Apache.Hadoop.Hdfs.Server.Namenode.Snapshot.Snapshot s = loader.GetSnapshot(@in
                                                                                                );
                s.GetRoot().SetParent(snapshottableParent);
                sf.AddSnapshot(s);
            }
            int snapshotQuota = @in.ReadInt();

            snapshottableParent.SetSnapshotQuota(snapshotQuota);
        }
Esempio n. 3
0
        /// <summary>
        /// Load
        /// <see cref="DirectoryDiff"/>
        /// from fsimage.
        /// </summary>
        /// <param name="parent">The directory that the SnapshotDiff belongs to.</param>
        /// <param name="in">
        /// The
        /// <see cref="System.IO.DataInput"/>
        /// instance to read.
        /// </param>
        /// <param name="loader">
        /// The
        /// <see cref="Loader"/>
        /// instance that this loading procedure is
        /// using.
        /// </param>
        /// <returns>
        /// A
        /// <see cref="DirectoryDiff"/>
        /// .
        /// </returns>
        /// <exception cref="System.IO.IOException"/>
        private static DirectoryWithSnapshotFeature.DirectoryDiff LoadDirectoryDiff(INodeDirectory
                                                                                    parent, DataInput @in, FSImageFormat.Loader loader)
        {
            // 1. Read the full path of the Snapshot root to identify the Snapshot
            Org.Apache.Hadoop.Hdfs.Server.Namenode.Snapshot.Snapshot snapshot = loader.GetSnapshot
                                                                                    (@in);
            // 2. Load DirectoryDiff#childrenSize
            int childrenSize = @in.ReadInt();
            // 3. Load DirectoryDiff#snapshotINode
            INodeDirectoryAttributes snapshotINode = LoadSnapshotINodeInDirectoryDiff(snapshot
                                                                                      , @in, loader);
            // 4. Load the created list in SnapshotDiff#Diff
            IList <INode> createdList = LoadCreatedList(parent, @in);
            // 5. Load the deleted list in SnapshotDiff#Diff
            IList <INode> deletedList = LoadDeletedList(parent, createdList, @in, loader);
            // 6. Compose the SnapshotDiff
            IList <DirectoryWithSnapshotFeature.DirectoryDiff> diffs = parent.GetDiffs().AsList
                                                                           ();

            DirectoryWithSnapshotFeature.DirectoryDiff sdiff = new DirectoryWithSnapshotFeature.DirectoryDiff
                                                                   (snapshot.GetId(), snapshotINode, diffs.IsEmpty() ? null : diffs[0], childrenSize
                                                                   , createdList, deletedList, snapshotINode == snapshot.GetRoot());
            return(sdiff);
        }