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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
acquire(String tableName)
Try to acquire a quota for the given table.void
cleanUpRateLimiterMap()
void
dropTableQueryQuota(String tableNameWithType)
Drop table query quota.QueryQuotaEntity
getRateLimiterForTable(String tableNameWithType)
int
getRateLimiterMapSize()
void
init(org.apache.helix.HelixManager helixManager)
Initializes the cluster change handler with the given connected Helix manager.void
initOrUpdateTableQueryQuota(String tableNameWithType)
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.boolean
isQueryRateLimitDisabled()
void
processClusterChange(org.apache.helix.HelixConstants.ChangeType changeType)
Processes the cluster change of the given type (e.g.void
processQueryRateLimitingExternalViewChange(org.apache.helix.model.ExternalView currentBrokerResourceEV)
Process query quota change when number of online brokers has changed.void
processQueryRateLimitingInstanceConfigChange()
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:ClusterChangeHandler
Initializes the cluster change handler with the given connected Helix manager.- Specified by:
init
in interfaceClusterChangeHandler
-
processClusterChange
public void processClusterChange(org.apache.helix.HelixConstants.ChangeType changeType)
Description copied from interface:ClusterChangeHandler
Processes the cluster change of the given type (e.g. EXTERNAL_VIEW, INSTANCE_CONFIG, LIVE_INSTANCE).- Specified by:
processClusterChange
in 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:
acquire
in 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()
-
-