Exemplo n.º 1
0
 public _Processor_218(BlockStoragePolicySuite bsps, QuotaCounts counts, INode.BlocksMapUpdateInfo
                       collectedBlocks, IList <INode> removedINodes)
 {
     this.bsps            = bsps;
     this.counts          = counts;
     this.collectedBlocks = collectedBlocks;
     this.removedINodes   = removedINodes;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Remove the snapshot with the given name from
        /// <see cref="snapshotsByNames"/>
        /// ,
        /// and delete all the corresponding DirectoryDiff.
        /// </summary>
        /// <param name="snapshotRoot">The directory where we take snapshots</param>
        /// <param name="snapshotName">The name of the snapshot to be removed</param>
        /// <param name="collectedBlocks">Used to collect information to update blocksMap</param>
        /// <returns>
        /// The removed snapshot. Null if no snapshot with the given name
        /// exists.
        /// </returns>
        /// <exception cref="Org.Apache.Hadoop.Hdfs.Protocol.SnapshotException"/>
        public virtual Org.Apache.Hadoop.Hdfs.Server.Namenode.Snapshot.Snapshot RemoveSnapshot
            (BlockStoragePolicySuite bsps, INodeDirectory snapshotRoot, string snapshotName,
            INode.BlocksMapUpdateInfo collectedBlocks, IList <INode> removedINodes)
        {
            int i = SearchSnapshot(DFSUtil.String2Bytes(snapshotName));

            if (i < 0)
            {
                throw new SnapshotException("Cannot delete snapshot " + snapshotName + " from path "
                                            + snapshotRoot.GetFullPathName() + ": the snapshot does not exist.");
            }
            else
            {
                Org.Apache.Hadoop.Hdfs.Server.Namenode.Snapshot.Snapshot snapshot = snapshotsByNames
                                                                                    [i];
                int prior = Org.Apache.Hadoop.Hdfs.Server.Namenode.Snapshot.Snapshot.FindLatestSnapshot
                                (snapshotRoot, snapshot.GetId());
                try
                {
                    QuotaCounts counts = snapshotRoot.CleanSubtree(bsps, snapshot.GetId(), prior, collectedBlocks
                                                                   , removedINodes);
                    INodeDirectory parent = snapshotRoot.GetParent();
                    if (parent != null)
                    {
                        // there will not be any WithName node corresponding to the deleted
                        // snapshot, thus only update the quota usage in the current tree
                        parent.AddSpaceConsumed(counts.Negation(), true);
                    }
                }
                catch (QuotaExceededException e)
                {
                    INode.Log.Error("BUG: removeSnapshot increases namespace usage.", e);
                }
                // remove from snapshotsByNames after successfully cleaning the subtree
                snapshotsByNames.Remove(i);
                return(snapshot);
            }
        }
Exemplo n.º 3
0
 public virtual QuotaCounts ComputeQuotaUsage4CurrentDirectory(BlockStoragePolicySuite
                                                               bsps, byte storagePolicyId, QuotaCounts counts)
 {
     foreach (DirectoryWithSnapshotFeature.DirectoryDiff d in diffs)
     {
         foreach (INode deleted in d.GetChildrenDiff().GetList(Diff.ListType.Deleted))
         {
             byte childPolicyId = deleted.GetStoragePolicyIDForQuota(storagePolicyId);
             deleted.ComputeQuotaUsage(bsps, childPolicyId, counts, false, Org.Apache.Hadoop.Hdfs.Server.Namenode.Snapshot.Snapshot
                                       .CurrentStateId);
         }
     }
     return(counts);
 }