Class ReadRequestThrottler
java.lang.Object
com.linkedin.venice.router.throttle.ReadRequestThrottler
- All Implemented Interfaces:
RoutersClusterManager.RouterCountChangedListener,StoreDataChangedListener,RouterThrottler
public class ReadRequestThrottler
extends 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 -
Constructor Summary
ConstructorsConstructorDescriptionReadRequestThrottler(RoutersClusterManager zkRoutersManager, ReadOnlyStoreRepository storeRepository, long maxRouterReadCapacity, AggRouterHttpRequestStats stats, double perStoreRouterQuotaBuffer, long storeQuotaCheckTimeWindow) ReadRequestThrottler(RoutersClusterManager zkRoutersManager, ReadOnlyStoreRepository storeRepository, AggRouterHttpRequestStats stats, VeniceRouterConfig routerConfig) -
Method Summary
Modifier and TypeMethodDescriptionprotected final longprotected longcalculateStoreQuotaPerRouter(long storeQuota) intprotected EventThrottlergetStoreReadThrottler(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(String storeName) voidmayThrottleRead(String storeName, double readCapacityUnit) Check the quota and reject the request if needed.protected voidvoidsetIsNoopThrottlerEnabled(boolean isNoopThrottlerEnabled) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.linkedin.venice.meta.StoreDataChangedListener
handleStoreDeleted
-
Field Details
-
DEFAULT_STORE_QUOTA_TIME_WINDOW
public static final long DEFAULT_STORE_QUOTA_TIME_WINDOW
-
-
Constructor Details
-
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 Details
-
mayThrottleRead
public void mayThrottleRead(String storeName, double readCapacityUnit) throws QuotaExceededException Check 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
-
handleRouterCountChanged
public void handleRouterCountChanged(int newRouterCount) - Specified by:
handleRouterCountChangedin interfaceRoutersClusterManager.RouterCountChangedListener
-
handleStoreCreated
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
- Specified by:
handleStoreDeletedin interfaceStoreDataChangedListener
-
handleStoreChanged
- Specified by:
handleStoreChangedin interfaceStoreDataChangedListener
-
restoreAllThrottlers
protected void restoreAllThrottlers()
-