public virtual short GetBlockReplication() { // BlockCollection short max = GetFileReplication(Org.Apache.Hadoop.Hdfs.Server.Namenode.Snapshot.Snapshot .CurrentStateId); FileWithSnapshotFeature sf = this.GetFileWithSnapshotFeature(); if (sf != null) { short maxInSnapshot = sf.GetMaxBlockRepInDiffs(); if (sf.IsCurrentFileDeleted()) { return(maxInSnapshot); } max = maxInSnapshot > max ? maxInSnapshot : max; } return(max); }
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); }