Esempio n. 1
0
        /// <summary>Compute the difference between Snapshots.</summary>
        /// <param name="fromSnapshot">
        /// Start point of the diff computation. Null indicates
        /// current tree.
        /// </param>
        /// <param name="toSnapshot">
        /// End point of the diff computation. Null indicates current
        /// tree.
        /// </param>
        /// <param name="diff">
        /// Used to capture the changes happening to the children. Note
        /// that the diff still represents (later_snapshot - earlier_snapshot)
        /// although toSnapshot can be before fromSnapshot.
        /// </param>
        /// <param name="currentINode">
        /// The
        /// <see cref="Org.Apache.Hadoop.Hdfs.Server.Namenode.INodeDirectory"/>
        /// this feature belongs to.
        /// </param>
        /// <returns>Whether changes happened between the startSnapshot and endSnaphsot.</returns>
        internal virtual bool ComputeDiffBetweenSnapshots(Org.Apache.Hadoop.Hdfs.Server.Namenode.Snapshot.Snapshot
                                                          fromSnapshot, Org.Apache.Hadoop.Hdfs.Server.Namenode.Snapshot.Snapshot toSnapshot
                                                          , DirectoryWithSnapshotFeature.ChildrenDiff diff, INodeDirectory currentINode)
        {
            int[] diffIndexPair = diffs.ChangedBetweenSnapshots(fromSnapshot, toSnapshot);
            if (diffIndexPair == null)
            {
                return(false);
            }
            int  earlierDiffIndex            = diffIndexPair[0];
            int  laterDiffIndex              = diffIndexPair[1];
            bool dirMetadataChanged          = false;
            INodeDirectoryAttributes dirCopy = null;
            IList <DirectoryWithSnapshotFeature.DirectoryDiff> difflist = diffs.AsList();

            for (int i = earlierDiffIndex; i < laterDiffIndex; i++)
            {
                DirectoryWithSnapshotFeature.DirectoryDiff sdiff = difflist[i];
                diff.CombinePosterior(sdiff.diff, null);
                if (!dirMetadataChanged && sdiff.snapshotINode != null)
                {
                    if (dirCopy == null)
                    {
                        dirCopy = sdiff.snapshotINode;
                    }
                    else
                    {
                        if (!dirCopy.MetadataEquals(sdiff.snapshotINode))
                        {
                            dirMetadataChanged = true;
                        }
                    }
                }
            }
            if (!diff.IsEmpty() || dirMetadataChanged)
            {
                return(true);
            }
            else
            {
                if (dirCopy != null)
                {
                    for (int i_1 = laterDiffIndex; i_1 < difflist.Count; i_1++)
                    {
                        if (!dirCopy.MetadataEquals(difflist[i_1].snapshotINode))
                        {
                            return(true);
                        }
                    }
                    return(!dirCopy.MetadataEquals(currentINode));
                }
                else
                {
                    return(false);
                }
            }
        }
Esempio n. 2
0
            internal override QuotaCounts CombinePosteriorAndCollectBlocks(BlockStoragePolicySuite
                                                                           bsps, INodeDirectory currentDir, DirectoryWithSnapshotFeature.DirectoryDiff posterior
                                                                           , INode.BlocksMapUpdateInfo collectedBlocks, IList <INode> removedINodes)
            {
                QuotaCounts counts = new QuotaCounts.Builder().Build();

                diff.CombinePosterior(posterior.diff, new _Processor_218(bsps, counts, collectedBlocks
                                                                         , removedINodes));
                return(counts);
            }
Esempio n. 3
0
 private IList <INode> InitChildren()
 {
     if (this.children == null)
     {
         DirectoryWithSnapshotFeature.ChildrenDiff combined = new DirectoryWithSnapshotFeature.ChildrenDiff
                                                                  ();
         for (DirectoryWithSnapshotFeature.DirectoryDiff d = this._enclosing; d != null; d
                  = d.GetPosterior())
         {
             combined.CombinePosterior(d.diff, null);
         }
         this.children = combined.Apply2Current(ReadOnlyList.Util.AsList(currentDir.GetChildrenList
                                                                             (Org.Apache.Hadoop.Hdfs.Server.Namenode.Snapshot.Snapshot.CurrentStateId)));
     }
     return(this.children);
 }