Package com.github.ambry.quota
Interface QuotaManager
-
public interface QuotaManager
Interface for the class that acts as the manager of all the quotas in Ambry. Implementations of this interface should take care of initializing all the various type of quota enforcements and getting the overall quota recommendation for each request.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ThrottlingRecommendation
charge(RestRequest restRequest, BlobInfo blobInfo, java.util.Map<QuotaName,java.lang.Double> requestCostMap)
Charges the requestCost against the quota for the specified restRequest and blobInfo.QuotaConfig
getQuotaConfig()
ThrottlingRecommendation
getThrottleRecommendation(RestRequest restRequest)
Computes the overall boolean recommendation to throttle a request or not for all the types of request quotas supported.void
init()
Method to initialize theQuotaManager
.void
shutdown()
Method to shutdown theQuotaManager
and cleanup if required.
-
-
-
Method Detail
-
init
void init()
Method to initialize theQuotaManager
.
-
getThrottleRecommendation
ThrottlingRecommendation getThrottleRecommendation(RestRequest restRequest)
Computes the overall boolean recommendation to throttle a request or not for all the types of request quotas supported. This method does not charge the requestCost against the quota.- Parameters:
restRequest
-RestRequest
object.- Returns:
- ThrottlingRecommendation object that captures the overall recommendation.
-
charge
ThrottlingRecommendation charge(RestRequest restRequest, BlobInfo blobInfo, java.util.Map<QuotaName,java.lang.Double> requestCostMap)
Charges the requestCost against the quota for the specified restRequest and blobInfo.- Parameters:
restRequest
-RestRequest
object.blobInfo
-BlobInfo
object representing the blob characteristics using which request cost can be determined by enforcers.requestCostMap
-Map
ofQuotaName
to the cost incurred to handle the request.- Returns:
- ThrottlingRecommendation object that captures the overall recommendation.
-
getQuotaConfig
QuotaConfig getQuotaConfig()
- Returns:
- QuotaConfig object.
-
shutdown
void shutdown()
Method to shutdown theQuotaManager
and cleanup if required.
-
-