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

  /**
    * Returns the quota limit associated with the provided metric tags. These tags were returned from
    * a previous call to [[ClientQuotaCallback.quota()]]. This method is invoked by quota managers to
    * obtain the current quota limit applied to a metric after a quota update. 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), None is returned.
    *
    * @param metricTags Metric tags for a quota metric of type `quotaType`
    * @param quotaType Type of quota requested
    * @return the quota limit for the provided 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.
    * 
    * @param partitions Partitions and their metadata including partition leader
    */
  def updatePartitionMetadata(partitions: Map[TopicPartition, PartitionMetadata]): Unit

  /**
    * 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.
    */
  def updateQuota(quotaEntity: ClientQuotaEntity, quotaType: ClientQuotaType, newValue: Option[Double]) : Unit

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

...