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
-
Constructor Summary
ConstructorDescriptionReadRequestThrottler
(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 long
protected long
calculateStoreQuotaPerRouter
(long storeQuota) int
protected EventThrottler
getStoreReadThrottler
(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
(String storeName) void
mayThrottleRead
(String storeName, double readCapacityUnit) Check the quota and reject the request if needed.protected void
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
-
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:
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
-
handleRouterCountChanged
public void handleRouterCountChanged(int newRouterCount) - Specified by:
handleRouterCountChanged
in interfaceRoutersClusterManager.RouterCountChangedListener
-
handleStoreCreated
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
- Specified by:
handleStoreDeleted
in interfaceStoreDataChangedListener
-
handleStoreChanged
- Specified by:
handleStoreChanged
in interfaceStoreDataChangedListener
-
restoreAllThrottlers
protected void restoreAllThrottlers()
-