コード例 #1
0
ファイル: INodeDirectory.cs プロジェクト: orf53975/hadoop.net
        public override QuotaCounts ComputeQuotaUsage(BlockStoragePolicySuite bsps, byte
                                                      blockStoragePolicyId, QuotaCounts counts, bool useCache, int lastSnapshotId)
        {
            DirectoryWithSnapshotFeature sf = GetDirectoryWithSnapshotFeature();

            // we are computing the quota usage for a specific snapshot here, i.e., the
            // computation only includes files/directories that exist at the time of the
            // given snapshot
            if (sf != null && lastSnapshotId != Org.Apache.Hadoop.Hdfs.Server.Namenode.Snapshot.Snapshot
                .CurrentStateId && !(useCache && IsQuotaSet()))
            {
                ReadOnlyList <INode> childrenList = GetChildrenList(lastSnapshotId);
                foreach (INode child in childrenList)
                {
                    byte childPolicyId = child.GetStoragePolicyIDForQuota(blockStoragePolicyId);
                    child.ComputeQuotaUsage(bsps, childPolicyId, counts, useCache, lastSnapshotId);
                }
                counts.AddNameSpace(1);
                return(counts);
            }
            // compute the quota usage in the scope of the current directory tree
            DirectoryWithQuotaFeature q = GetDirectoryWithQuotaFeature();

            if (useCache && q != null && q.IsQuotaSet())
            {
                // use the cached quota
                return(q.AddCurrentSpaceUsage(counts));
            }
            else
            {
                useCache = q != null && !q.IsQuotaSet() ? false : useCache;
                return(ComputeDirectoryQuotaUsage(bsps, blockStoragePolicyId, counts, useCache, lastSnapshotId
                                                  ));
            }
        }
コード例 #2
0
        // This is the only place that needs to use the BlockStoragePolicySuite to
        // derive the intended storage type usage for quota by storage type
        public sealed override QuotaCounts ComputeQuotaUsage(BlockStoragePolicySuite bsps
                                                             , byte blockStoragePolicyId, QuotaCounts counts, bool useCache, int lastSnapshotId
                                                             )
        {
            long  nsDelta = 1;
            long  ssDeltaNoReplication;
            short replication;
            FileWithSnapshotFeature sf = GetFileWithSnapshotFeature();

            if (sf != null)
            {
                FileDiffList fileDiffList = sf.GetDiffs();
                int          last         = fileDiffList.GetLastSnapshotId();
                if (lastSnapshotId == Org.Apache.Hadoop.Hdfs.Server.Namenode.Snapshot.Snapshot.CurrentStateId ||
                    last == Org.Apache.Hadoop.Hdfs.Server.Namenode.Snapshot.Snapshot.CurrentStateId)
                {
                    ssDeltaNoReplication = StoragespaceConsumedNoReplication();
                    replication          = GetBlockReplication();
                }
                else
                {
                    if (last < lastSnapshotId)
                    {
                        ssDeltaNoReplication = ComputeFileSize(true, false);
                        replication          = GetFileReplication();
                    }
                    else
                    {
                        int sid = fileDiffList.GetSnapshotById(lastSnapshotId);
                        ssDeltaNoReplication = StoragespaceConsumedNoReplication(sid);
                        replication          = GetReplication(sid);
                    }
                }
            }
            else
            {
                ssDeltaNoReplication = StoragespaceConsumedNoReplication();
                replication          = GetBlockReplication();
            }
            counts.AddNameSpace(nsDelta);
            counts.AddStorageSpace(ssDeltaNoReplication * replication);
            if (blockStoragePolicyId != BlockStoragePolicySuite.IdUnspecified)
            {
                BlockStoragePolicy  bsp          = bsps.GetPolicy(blockStoragePolicyId);
                IList <StorageType> storageTypes = bsp.ChooseStorageTypes(replication);
                foreach (StorageType t in storageTypes)
                {
                    if (!t.SupportTypeQuota())
                    {
                        continue;
                    }
                    counts.AddTypeSpace(t, ssDeltaNoReplication);
                }
            }
            return(counts);
        }
コード例 #3
0
ファイル: INodeDirectory.cs プロジェクト: orf53975/hadoop.net
        /// <summary>Add quota usage for this inode excluding children.</summary>
        public virtual QuotaCounts ComputeQuotaUsage4CurrentDirectory(BlockStoragePolicySuite
                                                                      bsps, byte storagePolicyId, QuotaCounts counts)
        {
            counts.AddNameSpace(1);
            // include the diff list
            DirectoryWithSnapshotFeature sf = GetDirectoryWithSnapshotFeature();

            if (sf != null)
            {
                sf.ComputeQuotaUsage4CurrentDirectory(bsps, storagePolicyId, counts);
            }
            return(counts);
        }
コード例 #4
0
 public override QuotaCounts ComputeQuotaUsage(BlockStoragePolicySuite bsps, byte
                                               blockStoragePolicyId, QuotaCounts counts, bool useCache, int lastSnapshotId)
 {
     counts.AddNameSpace(1);
     return(counts);
 }