Esempio n. 1
0
 /// <returns>
 /// If there is no corresponding directory diff for the given
 /// snapshot, this means that the current children list should be
 /// returned for the snapshot. Otherwise we calculate the children list
 /// for the snapshot and return it.
 /// </returns>
 public virtual ReadOnlyList <INode> GetChildrenList(INodeDirectory currentINode, int
                                                     snapshotId)
 {
     DirectoryWithSnapshotFeature.DirectoryDiff diff = diffs.GetDiffById(snapshotId);
     return(diff != null?diff.GetChildrenList(currentINode) : currentINode.GetChildrenList
                    (Org.Apache.Hadoop.Hdfs.Server.Namenode.Snapshot.Snapshot.CurrentStateId));
 }
Esempio n. 2
0
 /// <summary>Destroy a subtree under a DstReference node.</summary>
 /// <exception cref="Org.Apache.Hadoop.Hdfs.Protocol.QuotaExceededException"/>
 public static void DestroyDstSubtree(BlockStoragePolicySuite bsps, INode inode, int
                                      snapshot, int prior, INode.BlocksMapUpdateInfo collectedBlocks, IList <INode> removedINodes
                                      )
 {
     Preconditions.CheckArgument(prior != Org.Apache.Hadoop.Hdfs.Server.Namenode.Snapshot.Snapshot
                                 .NoSnapshotId);
     if (inode.IsReference())
     {
         if (inode is INodeReference.WithName && snapshot != Org.Apache.Hadoop.Hdfs.Server.Namenode.Snapshot.Snapshot
             .CurrentStateId)
         {
             // this inode has been renamed before the deletion of the DstReference
             // subtree
             inode.CleanSubtree(bsps, snapshot, prior, collectedBlocks, removedINodes);
         }
         else
         {
             // for DstReference node, continue this process to its subtree
             DestroyDstSubtree(bsps, inode.AsReference().GetReferredINode(), snapshot, prior,
                               collectedBlocks, removedINodes);
         }
     }
     else
     {
         if (inode.IsFile())
         {
             inode.CleanSubtree(bsps, snapshot, prior, collectedBlocks, removedINodes);
         }
         else
         {
             if (inode.IsDirectory())
             {
                 IDictionary <INode, INode>   excludedNodes = null;
                 INodeDirectory               dir           = inode.AsDirectory();
                 DirectoryWithSnapshotFeature sf            = dir.GetDirectoryWithSnapshotFeature();
                 if (sf != null)
                 {
                     DirectoryWithSnapshotFeature.DirectoryDiffList diffList  = sf.GetDiffs();
                     DirectoryWithSnapshotFeature.DirectoryDiff     priorDiff = diffList.GetDiffById(prior
                                                                                                     );
                     if (priorDiff != null && priorDiff.GetSnapshotId() == prior)
                     {
                         IList <INode> dList = priorDiff.diff.GetList(Diff.ListType.Deleted);
                         excludedNodes = CloneDiffList(dList);
                     }
                     if (snapshot != Org.Apache.Hadoop.Hdfs.Server.Namenode.Snapshot.Snapshot.CurrentStateId)
                     {
                         diffList.DeleteSnapshotDiff(bsps, snapshot, prior, dir, collectedBlocks, removedINodes
                                                     );
                     }
                     priorDiff = diffList.GetDiffById(prior);
                     if (priorDiff != null && priorDiff.GetSnapshotId() == prior)
                     {
                         priorDiff.diff.DestroyCreatedList(bsps, dir, collectedBlocks, removedINodes);
                     }
                 }
                 foreach (INode child in inode.AsDirectory().GetChildrenList(prior))
                 {
                     if (excludedNodes != null && excludedNodes.Contains(child))
                     {
                         continue;
                     }
                     DestroyDstSubtree(bsps, child, snapshot, prior, collectedBlocks, removedINodes);
                 }
             }
         }
     }
 }