/// <summary>Constructor</summary>
 /// <param name="dir">The FSDirectory instance</param>
 /// <param name="fsn">The FSNamesystem instance</param>
 /// <param name="limitPerRun">
 /// allowed number of operations in one
 /// locking period. 0 or a negative number means
 /// no limit (i.e. no yielding)
 /// </param>
 public ContentSummaryComputationContext(FSDirectory dir, FSNamesystem fsn, long limitPerRun
                                         , long sleepMicroSec)
 {
     this.dir            = dir;
     this.fsn            = fsn;
     this.limitPerRun    = limitPerRun;
     this.nextCountLimit = limitPerRun;
     this.counts         = new ContentCounts.Builder().Build();
     this.sleepMilliSec  = sleepMicroSec / 1000;
     this.sleepNanoSec   = (int)((sleepMicroSec % 1000) * 1000);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Compute
        /// <see cref="Org.Apache.Hadoop.FS.ContentSummary"/>
        /// .
        /// </summary>
        public ContentSummary ComputeAndConvertContentSummary(ContentSummaryComputationContext
                                                              summary)
        {
            ContentCounts counts = ComputeContentSummary(summary).GetCounts();
            QuotaCounts   q      = GetQuotaCounts();

            return(new ContentSummary.Builder().Length(counts.GetLength()).FileCount(counts.GetFileCount
                                                                                         () + counts.GetSymlinkCount()).DirectoryCount(counts.GetDirectoryCount()).Quota(
                       q.GetNameSpace()).SpaceConsumed(counts.GetStoragespace()).SpaceQuota(q.GetStorageSpace
                                                                                                ()).TypeConsumed(counts.GetTypeSpaces()).TypeQuota(q.GetTypeSpaces().AsArray()).
                   Build());
        }
Ejemplo n.º 3
0
        public sealed override ContentSummaryComputationContext ComputeContentSummary(ContentSummaryComputationContext
                                                                                      summary)
        {
            ContentCounts           counts = summary.GetCounts();
            FileWithSnapshotFeature sf     = GetFileWithSnapshotFeature();
            long fileLen = 0;

            if (sf == null)
            {
                fileLen = ComputeFileSize();
                counts.AddContent(Content.File, 1);
            }
            else
            {
                FileDiffList diffs = sf.GetDiffs();
                int          n     = diffs.AsList().Count;
                counts.AddContent(Content.File, n);
                if (n > 0 && sf.IsCurrentFileDeleted())
                {
                    fileLen = diffs.GetLast().GetFileSize();
                }
                else
                {
                    fileLen = ComputeFileSize();
                }
            }
            counts.AddContent(Content.Length, fileLen);
            counts.AddContent(Content.Diskspace, StoragespaceConsumed());
            if (GetStoragePolicyID() != BlockStoragePolicySuite.IdUnspecified)
            {
                BlockStoragePolicy bsp = summary.GetBlockStoragePolicySuite().GetPolicy(GetStoragePolicyID
                                                                                            ());
                IList <StorageType> storageTypes = bsp.ChooseStorageTypes(GetFileReplication());
                foreach (StorageType t in storageTypes)
                {
                    if (!t.SupportTypeQuota())
                    {
                        continue;
                    }
                    counts.AddTypeSpace(t, fileLen);
                }
            }
            return(summary);
        }
Ejemplo n.º 4
0
 public virtual void AddContents(ContentCounts that)
 {
     contents.Add(that.contents);
     types.Add(that.types);
 }