public interface ClientQuotaCallback extends Configurable
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this instance.
|
default void |
enableDynamicQuota(boolean enableDynamicQuota)
Enable or Disable returning dynamic quotas as configured by updateDynamicQuotas().
|
default Map<String,String> |
parentQuotaMetricTags(ClientQuotaType quotaType,
Map<String,String> metricTags)
Quota callback invoked to determine parent metric tags to be applied for an original set of metric tags.
|
Double |
quotaLimit(ClientQuotaType quotaType,
Map<String,String> metricTags)
Returns the quota limit associated with the provided metric tags.
|
Map<String,String> |
quotaMetricTags(ClientQuotaType quotaType,
KafkaPrincipal principal,
String clientId)
Quota callback invoked to determine the quota metric tags to be applied for a request.
|
default Map<String,String> |
quotaMetricTagsFromTopic(ClientQuotaType quotaType,
String topic)
Quota callback invoked to determine the quota metric tags to be applied for a topic.
|
boolean |
quotaResetRequired(ClientQuotaType quotaType)
Returns true if any of the existing quota configs may have been updated since the last call
to this method for the provided quota type.
|
void |
removeQuota(ClientQuotaType quotaType,
ClientQuotaEntity quotaEntity)
Quota configuration removal callback that is invoked when quota configuration for an entity is
removed in the quorum.
|
boolean |
updateClusterMetadata(Cluster cluster)
Metadata update callback that is invoked whenever UpdateMetadata request is received from
the controller.
|
default boolean |
updateDynamicQuotas(Map<Map<String,String>,Map<String,Long>> dynamicQuotas)
Dynamic tenant quota update callback that is invoked when a PublishTenantBandwidthQuota request is received
from the controller.
|
void |
updateQuota(ClientQuotaType quotaType,
ClientQuotaEntity quotaEntity,
double newValue)
Quota configuration update callback that is invoked when quota configuration for an entity is
updated in the quorum.
|
configure
Map<String,String> quotaMetricTags(ClientQuotaType quotaType, KafkaPrincipal principal, String clientId)
quotaType
- Type of quota requestedprincipal
- The user principal of the connection for which quota is requestedclientId
- The client id associated with the requestdefault Map<String,String> quotaMetricTagsFromTopic(ClientQuotaType quotaType, String topic)
quotaType
- Type of quota requestedtopic
- Name of the topic the tenant name is extracted fromdefault Map<String,String> parentQuotaMetricTags(ClientQuotaType quotaType, Map<String,String> metricTags)
quotaType
- Type of quota requestedmetricTags
- Original metric tagsDouble quotaLimit(ClientQuotaType quotaType, Map<String,String> metricTags)
quotaMetricTags(ClientQuotaType, KafkaPrincipal, String)
. This method is
invoked by quota managers to obtain the current quota limit applied to a metric when the first request
using these tags is processed. It is also invoked after a quota update or cluster metadata change.
If the tags are no longer in use after the update, (e.g. this is a {user, client-id} quota metric
and the quota now in use is a {user} quota), null is returned.quotaType
- Type of quota requestedmetricTags
- Metric tags for a quota metric of type `quotaType`void updateQuota(ClientQuotaType quotaType, ClientQuotaEntity quotaEntity, double newValue)
quotaType
- Type of quota being updatedquotaEntity
- The quota entity for which quota is being updatednewValue
- The new quota valuedefault boolean updateDynamicQuotas(Map<Map<String,String>,Map<String,Long>> dynamicQuotas)
dynamicQuotas
- The map of tenants to a map of client quota type to the quota valuedefault void enableDynamicQuota(boolean enableDynamicQuota)
enableDynamicQuota
- true if dynamicQuota is effective.void removeQuota(ClientQuotaType quotaType, ClientQuotaEntity quotaEntity)
quotaType
- Type of quota being updatedquotaEntity
- The quota entity for which quota is being updatedboolean quotaResetRequired(ClientQuotaType quotaType)
updateClusterMetadata(Cluster)
, updateQuota(ClientQuotaType, ClientQuotaEntity, double)
and removeQuota(ClientQuotaType, ClientQuotaEntity)
are automatically processed.
So callbacks that rely only on built-in quota configuration tools always return false. Quota callbacks
with external quota configuration or custom reconfigurable quota configs that affect quota limits must
return true if existing metric configs may need to be updated. This method is invoked on every request
and hence is expected to be handled by callbacks as a simple flag that is updated when quotas change.quotaType
- Type of quotaboolean updateClusterMetadata(Cluster cluster)
cluster
- Cluster metadata including partitions and their leaders if knownvoid close()