/// <exception cref="Org.Apache.Hadoop.Hdfs.Protocol.QuotaByStorageTypeExceededException /// "/> private void VerifyQuotaByStorageType(EnumCounters <StorageType> typeDelta) { if (!IsQuotaByStorageTypeSet()) { return; } foreach (StorageType t in StorageType.GetTypesSupportingQuota()) { if (!IsQuotaByStorageTypeSet(t)) { continue; } if (Quota.IsViolated(quota.GetTypeSpace(t), usage.GetTypeSpace(t), typeDelta.Get( t))) { throw new QuotaByStorageTypeExceededException(quota.GetTypeSpace(t), usage.GetTypeSpace (t) + typeDelta.Get(t), t); } } }
/// <summary> /// See /// <see cref="Org.Apache.Hadoop.Hdfs.Protocol.ClientProtocol.SetQuota(string, long, long, Org.Apache.Hadoop.FS.StorageType) /// "/> /// for the contract. /// Sets quota for for a directory. /// </summary> /// <returns>INodeDirectory if any of the quotas have changed. null otherwise.</returns> /// <exception cref="System.IO.FileNotFoundException">if the path does not exist.</exception> /// <exception cref="Org.Apache.Hadoop.FS.PathIsNotDirectoryException">if the path is not a directory. /// </exception> /// <exception cref="Org.Apache.Hadoop.Hdfs.Protocol.QuotaExceededException"> /// if the directory tree size is /// greater than the given quota /// </exception> /// <exception cref="Org.Apache.Hadoop.FS.UnresolvedLinkException">if a symlink is encountered in src. /// </exception> /// <exception cref="Org.Apache.Hadoop.Hdfs.Protocol.SnapshotAccessControlException">if path is in RO snapshot /// </exception> /// <exception cref="Org.Apache.Hadoop.Hdfs.Server.Namenode.UnsupportedActionException /// "/> internal static INodeDirectory UnprotectedSetQuota(FSDirectory fsd, string src, long nsQuota, long ssQuota, StorageType type) { System.Diagnostics.Debug.Assert(fsd.HasWriteLock()); // sanity check if ((nsQuota < 0 && nsQuota != HdfsConstants.QuotaDontSet && nsQuota != HdfsConstants .QuotaReset) || (ssQuota < 0 && ssQuota != HdfsConstants.QuotaDontSet && ssQuota != HdfsConstants.QuotaReset)) { throw new ArgumentException("Illegal value for nsQuota or " + "ssQuota : " + nsQuota + " and " + ssQuota); } // sanity check for quota by storage type if ((type != null) && (!fsd.IsQuotaByStorageTypeEnabled() || nsQuota != HdfsConstants .QuotaDontSet)) { throw new UnsupportedActionException("Failed to set quota by storage type because either" + DFSConfigKeys.DfsQuotaByStoragetypeEnabledKey + " is set to " + fsd.IsQuotaByStorageTypeEnabled () + " or nsQuota value is illegal " + nsQuota); } string srcs = FSDirectory.NormalizePath(src); INodesInPath iip = fsd.GetINodesInPath4Write(srcs, true); INodeDirectory dirNode = INodeDirectory.ValueOf(iip.GetLastINode(), srcs); if (dirNode.IsRoot() && nsQuota == HdfsConstants.QuotaReset) { throw new ArgumentException("Cannot clear namespace quota on root."); } else { // a directory inode QuotaCounts oldQuota = dirNode.GetQuotaCounts(); long oldNsQuota = oldQuota.GetNameSpace(); long oldSsQuota = oldQuota.GetStorageSpace(); if (nsQuota == HdfsConstants.QuotaDontSet) { nsQuota = oldNsQuota; } if (ssQuota == HdfsConstants.QuotaDontSet) { ssQuota = oldSsQuota; } // unchanged space/namespace quota if (type == null && oldNsQuota == nsQuota && oldSsQuota == ssQuota) { return(null); } // unchanged type quota if (type != null) { EnumCounters <StorageType> oldTypeQuotas = oldQuota.GetTypeSpaces(); if (oldTypeQuotas != null && oldTypeQuotas.Get(type) == ssQuota) { return(null); } } int latest = iip.GetLatestSnapshotId(); dirNode.RecordModification(latest); dirNode.SetQuota(fsd.GetBlockStoragePolicySuite(), nsQuota, ssQuota, type); return(dirNode); } }
public virtual long GetNameSpace() { return(nsSsCounts.Get(Quota.Namespace)); }
// Get the number of files. public virtual long GetFileCount() { return(contents.Get(Content.File)); }
public virtual long GetTypeSpace(StorageType t) { return(types.Get(t)); }
/// <returns> /// Approximate number of blocks currently scheduled to be written /// to the given storage type of this datanode. /// </returns> public virtual int GetBlocksScheduled(StorageType t) { return((int)(currApproxBlocksScheduled.Get(t) + prevApproxBlocksScheduled.Get(t))); }