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 long
DEFAULT_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 long
calculateIdealTotalQuotaPerRouter()
protected long
calculateStoreQuotaPerRouter(long storeQuota)
int
getReadCapacity()
protected EventThrottler
getStoreReadThrottler(java.lang.String storeName)
void
handleRouterCountChanged(int newRouterCount)
void
handleStoreChanged(Store store)
void
handleStoreCreated(Store store)
Do NOT try to acquire the lock of store repository again in the implementation, otherwise a dead lock issue will happen.void
handleStoreDeleted(java.lang.String storeName)
void
mayThrottleRead(java.lang.String storeName, double readCapacityUnit)
Check the quota and reject the request if needed.protected void
restoreAllThrottlers()
void
setIsNoopThrottlerEnabled(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 QuotaExceededException
Check the quota and reject the request if needed.- Specified by:
mayThrottleRead
in 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:
getReadCapacity
in interfaceRouterThrottler
-
setIsNoopThrottlerEnabled
public void setIsNoopThrottlerEnabled(boolean isNoopThrottlerEnabled)
- Specified by:
setIsNoopThrottlerEnabled
in 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:
handleRouterCountChanged
in interfaceRoutersClusterManager.RouterCountChangedListener
-
handleStoreCreated
public void handleStoreCreated(Store store)
Description copied from interface:StoreDataChangedListener
Do NOT try to acquire the lock of store repository again in the implementation, otherwise a dead lock issue will happen.- Specified by:
handleStoreCreated
in interfaceStoreDataChangedListener
-
handleStoreDeleted
public void handleStoreDeleted(java.lang.String storeName)
- Specified by:
handleStoreDeleted
in interfaceStoreDataChangedListener
-
handleStoreChanged
public void handleStoreChanged(Store store)
- Specified by:
handleStoreChanged
in interfaceStoreDataChangedListener
-
restoreAllThrottlers
protected void restoreAllThrottlers()
-
-