Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagescala
titleClient Quota Callback
trait ClientQuotaCallback extends Configurable {

  /**
    * Quota callback invoked to determine the quota limit to be applied for a request.
    * 
    * @param session The session for which quota is requested
    * @param clientId The client id associated with the request
    * @param quotaType Type of quota requested
    *                  
    * @return the quota including the limit and metric tags that indicate which other entities share this quota
    */
  def quota(session: Session, clientId: String, quotaType: ClientQuotaType): ClientQuota

   /**
    * ReturnsMetadata theupdate quotacallback limitthat associatedis withinvoked thewhenever providedUpdateMetadata metricrequest tags.is These tags were returned received from
    * a previous call to [[ClientQuotaCallback.quota()]].the controller. This method is invokeduseful byif quota managerscomputation to
is takes partitions  * obtain the current quota limit applied to a metric after a quota update. If the tags are no longerinto account.
     * inDeleted usepartitions afterwill thenot update, (e.g. this is a {user, client-id) quota metric and the quota now in usebe included in `partitions`.
    * is a (user) quota), None is returned.
    *
    * @param metricTagspartitions MetricPartitions tagsand fortheir ametadata quotaincluding metricpartition of typeleader `quotaType`
    * @param quotaType Type of quota requested
    * @return theQuotas quotathat limithave forbeen theupdated providedincluding metric tags or None if the metric tags are no longer in use
    */
  def quotaLimit(metricTags: Map[String, String], quotaType: ClientQuotaType): Option[Double]

  /**
    * Metadata update callback that is invoked whenever UpdateMetadata request is received from
    * the controller. This is useful if quota computation is takes partitions into account. These are used to update quota config of existing metrics.
    * 
    * @param partitions Partitions and their metadata including partition leader
    */
  def updatePartitionMetadata(partitions: Map[TopicPartition, PartitionMetadata]): UnitSet[ClientQuota]

  /**
    * Quota configuration update callback that is invoked whenever quota configuration in ZooKeeper
    * is updated. This is useful to track configured quotas if the built-in quota configuration tools
    * are used.
    * 
    * @param quotaEntity The quota entity for which quota is being updated.
    * @param quotaType Type of quota being updated.
    * @param newValue The new quota value. If None, the quota configuration for `quotaEntity` is deleted.
    * @return Quotas that have been updated including metric tags. These are used to update quota config of existing metrics.
    */
  def updateQuota(quotaEntity: ClientQuotaEntity, quotaType: ClientQuotaType, newValue: Option[Double]) : UnitSet[ClientQuota]

  /**
    * Closes this instance.
    */
  def close(): Unit
}

...