Class ReadRequestThrottler
- java.lang.Object
-
- com.linkedin.venice.router.throttle.ReadRequestThrottler
-
- All Implemented Interfaces:
RoutersClusterManager.RouterCountChangedListener,StoreDataChangedListener,RouterThrottler
public class ReadRequestThrottler extends java.lang.Object implements RouterThrottler, StoreDataChangedListener, RoutersClusterManager.RouterCountChangedListener
This class define the throttler on reads request. Basically it will calculate the store quota per router based on the total store quota and the number of living routers. Then a StoreReadThrottler will be created to maintain the throttler for this store and all storage nodes which get the ONLINE replica for the current version of this store. For each read request throttler will ask the related StoreReadThrottler to check both store level quota and storage level quota then accept or reject it.
-
-
Field Summary
Fields Modifier and Type Field Description static longDEFAULT_STORE_QUOTA_TIME_WINDOW
-
Constructor Summary
Constructors Constructor Description ReadRequestThrottler(RoutersClusterManager zkRoutersManager, ReadOnlyStoreRepository storeRepository, long maxRouterReadCapacity, AggRouterHttpRequestStats stats, double perStoreRouterQuotaBuffer, long storeQuotaCheckTimeWindow)ReadRequestThrottler(RoutersClusterManager zkRoutersManager, ReadOnlyStoreRepository storeRepository, AggRouterHttpRequestStats stats, VeniceRouterConfig routerConfig)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected longcalculateIdealTotalQuotaPerRouter()protected longcalculateStoreQuotaPerRouter(long storeQuota)intgetReadCapacity()protected EventThrottlergetStoreReadThrottler(java.lang.String storeName)voidhandleRouterCountChanged(int newRouterCount)voidhandleStoreChanged(Store store)voidhandleStoreCreated(Store store)Do NOT try to acquire the lock of store repository again in the implementation, otherwise a dead lock issue will happen.voidhandleStoreDeleted(java.lang.String storeName)voidmayThrottleRead(java.lang.String storeName, double readCapacityUnit)Check the quota and reject the request if needed.protected voidrestoreAllThrottlers()voidsetIsNoopThrottlerEnabled(boolean isNoopThrottlerEnabled)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.linkedin.venice.meta.StoreDataChangedListener
handleStoreDeleted
-
-
-
-
Constructor Detail
-
ReadRequestThrottler
public ReadRequestThrottler(RoutersClusterManager zkRoutersManager, ReadOnlyStoreRepository storeRepository, AggRouterHttpRequestStats stats, VeniceRouterConfig routerConfig)
-
ReadRequestThrottler
public ReadRequestThrottler(RoutersClusterManager zkRoutersManager, ReadOnlyStoreRepository storeRepository, long maxRouterReadCapacity, AggRouterHttpRequestStats stats, double perStoreRouterQuotaBuffer, long storeQuotaCheckTimeWindow)
-
-
Method Detail
-
mayThrottleRead
public void mayThrottleRead(java.lang.String storeName, double readCapacityUnit) throws QuotaExceededExceptionCheck the quota and reject the request if needed.- Specified by:
mayThrottleReadin interfaceRouterThrottler- Parameters:
storeName- name of the store that request is trying to visit.readCapacityUnit- usage of this read request.- Throws:
QuotaExceededException- if the usage exceeded the quota throw this exception to reject the request.
-
getReadCapacity
public int getReadCapacity()
- Specified by:
getReadCapacityin interfaceRouterThrottler
-
setIsNoopThrottlerEnabled
public void setIsNoopThrottlerEnabled(boolean isNoopThrottlerEnabled)
- Specified by:
setIsNoopThrottlerEnabledin interfaceRouterThrottler
-
calculateStoreQuotaPerRouter
protected long calculateStoreQuotaPerRouter(long storeQuota)
-
calculateIdealTotalQuotaPerRouter
protected final long calculateIdealTotalQuotaPerRouter()
-
getStoreReadThrottler
protected EventThrottler getStoreReadThrottler(java.lang.String storeName)
-
handleRouterCountChanged
public void handleRouterCountChanged(int newRouterCount)
- Specified by:
handleRouterCountChangedin interfaceRoutersClusterManager.RouterCountChangedListener
-
handleStoreCreated
public void handleStoreCreated(Store store)
Description copied from interface:StoreDataChangedListenerDo NOT try to acquire the lock of store repository again in the implementation, otherwise a dead lock issue will happen.- Specified by:
handleStoreCreatedin interfaceStoreDataChangedListener
-
handleStoreDeleted
public void handleStoreDeleted(java.lang.String storeName)
- Specified by:
handleStoreDeletedin interfaceStoreDataChangedListener
-
handleStoreChanged
public void handleStoreChanged(Store store)
- Specified by:
handleStoreChangedin interfaceStoreDataChangedListener
-
restoreAllThrottlers
protected void restoreAllThrottlers()
-
-