Class HelixExternalViewBasedQueryQuotaManager
- java.lang.Object
-
- org.apache.pinot.broker.queryquota.HelixExternalViewBasedQueryQuotaManager
-
- All Implemented Interfaces:
ClusterChangeHandler,QueryQuotaManager
public class HelixExternalViewBasedQueryQuotaManager extends Object implements ClusterChangeHandler, QueryQuotaManager
This class is to support the qps quota feature. It depends on the broker source change to update the dynamic rate limit, which means it only gets updated when a new table added or a broker restarted.
-
-
Constructor Summary
Constructors Constructor Description HelixExternalViewBasedQueryQuotaManager(org.apache.pinot.common.metrics.BrokerMetrics brokerMetrics, String instanceId)
-
Method Summary
Modifier and Type Method Description booleanacquire(String tableName)Try to acquire a quota for the given table.voidcleanUpRateLimiterMap()voiddropTableQueryQuota(String tableNameWithType)Drop table query quota.QueryQuotaEntitygetRateLimiterForTable(String tableNameWithType)intgetRateLimiterMapSize()voidinit(org.apache.helix.HelixManager helixManager)Initializes the cluster change handler with the given connected Helix manager.voidinitOrUpdateTableQueryQuota(String tableNameWithType)voidinitOrUpdateTableQueryQuota(org.apache.pinot.spi.config.table.TableConfig tableConfig, org.apache.helix.model.ExternalView brokerResourceEV)Initialize or update dynamic rate limiter with table query quota.booleanisQueryRateLimitDisabled()voidprocessClusterChange(org.apache.helix.HelixConstants.ChangeType changeType)Processes the cluster change of the given type (e.g.voidprocessQueryRateLimitingExternalViewChange(org.apache.helix.model.ExternalView currentBrokerResourceEV)Process query quota change when number of online brokers has changed.voidprocessQueryRateLimitingInstanceConfigChange()Process query quota state change when instance config gets changed
-
-
-
Constructor Detail
-
HelixExternalViewBasedQueryQuotaManager
public HelixExternalViewBasedQueryQuotaManager(org.apache.pinot.common.metrics.BrokerMetrics brokerMetrics, String instanceId)
-
-
Method Detail
-
init
public void init(org.apache.helix.HelixManager helixManager)
Description copied from interface:ClusterChangeHandlerInitializes the cluster change handler with the given connected Helix manager.- Specified by:
initin interfaceClusterChangeHandler
-
processClusterChange
public void processClusterChange(org.apache.helix.HelixConstants.ChangeType changeType)
Description copied from interface:ClusterChangeHandlerProcesses the cluster change of the given type (e.g. EXTERNAL_VIEW, INSTANCE_CONFIG, LIVE_INSTANCE).- Specified by:
processClusterChangein interfaceClusterChangeHandler
-
initOrUpdateTableQueryQuota
public void initOrUpdateTableQueryQuota(String tableNameWithType)
-
initOrUpdateTableQueryQuota
public void initOrUpdateTableQueryQuota(org.apache.pinot.spi.config.table.TableConfig tableConfig, org.apache.helix.model.ExternalView brokerResourceEV)Initialize or update dynamic rate limiter with table query quota.- Parameters:
tableConfig- table config.brokerResourceEV- broker resource which stores all the broker states of each table.
-
dropTableQueryQuota
public void dropTableQueryQuota(String tableNameWithType)
Drop table query quota.- Parameters:
tableNameWithType- table name with type.
-
acquire
public boolean acquire(String tableName)
Try to acquire a quota for the given table.Acquires a token from rate limiter based on the table name.
- Specified by:
acquirein interfaceQueryQuotaManager- Parameters:
tableName- Table name with or without type suffix- Returns:
- true if there is no query quota specified for the table or a token can be acquired, otherwise return false.
-
getRateLimiterMapSize
public int getRateLimiterMapSize()
-
getRateLimiterForTable
public QueryQuotaEntity getRateLimiterForTable(String tableNameWithType)
-
cleanUpRateLimiterMap
public void cleanUpRateLimiterMap()
-
processQueryRateLimitingExternalViewChange
public void processQueryRateLimitingExternalViewChange(org.apache.helix.model.ExternalView currentBrokerResourceEV)
Process query quota change when number of online brokers has changed.
-
processQueryRateLimitingInstanceConfigChange
public void processQueryRateLimitingInstanceConfigChange()
Process query quota state change when instance config gets changed
-
isQueryRateLimitDisabled
public boolean isQueryRateLimitDisabled()
-
-