use of com.github.ambry.quota.QuotaAction in project ambry by linkedin.
the class StorageQuotaEnforcer method recommendBasedOnQuotaAndUsage.
/**
* Return a {@link QuotaRecommendation} based on the given pair of quota and current usage.
* @param pair The {@link Pair} of quota and current usage.
* @return A {@link QuotaRecommendation}.
*/
private QuotaRecommendation recommendBasedOnQuotaAndUsage(Pair<Long, Long> pair) {
long quotaValue = pair.getFirst();
long currentUsage = pair.getSecond();
if (quotaValue == -1L) {
// There is no quota set for the given account/container
return NO_QUOTA_VALUE_RECOMMENDATION;
}
QuotaAction quotaAction = (currentUsage >= quotaValue) ? QuotaAction.REJECT : QuotaAction.ALLOW;
float usagePercentage = currentUsage >= quotaValue ? 100f : ((float) currentUsage) / quotaValue * 100f;
return new QuotaRecommendation(quotaAction, usagePercentage, QuotaName.STORAGE_IN_GB, NO_RETRY);
}
Aggregations