THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Code Block |
---|
/** * Describes a fully-qualified entity. */ public class QuotaEntity { /** * Type of an entity entry. */ public enum Type { USER, CLIENT_ID; } /** * Represents the default name for an entity, i.e. the entity that's matched * when an exact match isn't found. */ public final static String QUOTA_ENTITY_NAME_DEFAULT = // implementation defined /** * `entries` describes the fully-qualified entity. The key is a {@code Type} string, however * there may also exist keys that are not enumerated by {@code Type} that still apply, e.g. * the server may internally associate another type. It's necessary to return all quota types * because quota values for these types may influence the effective quota value. However, * altering a quota, any types that aren't specified should be able to be inferred by the * server, otherwise an error is returned. * * For example, {("CLIENT_ID" -> "test-client"), * ("USER" -> "test-user"), * ("GROUP" -> "internal-group")}. */ public QuotaEntity(Map<String, String> entries); } /** * Describes a quota key. */ public class QuotaKey { /** * The quota types. */ public enum Type { CONSUMER_BYTE_RATE, PRODUCER_BYTE_RATE, REQUEST_PERCENTAGE; } /** * The units for a quota value. Note there may be multiple units for a given quota type * that influences quota behavior. */ public enum Units { RATE_BPS; } /** * @param type the quota type * @param units the units for the quota type */ public QuotaKey(Type type, Units units); } /** * Describes a quota entity filter. */ public class QuotaFilter { public enum Rule { EXACT, // exact name match PREFIX; // matches all names with the given prefix } /** * A filtering rule to be applied. * * @param entityType the entity type the rule applies to * @param rule the rule to apply * @param match the non-null string that's applied by the rule */ public QuotaFilter(QuotaEntity.Type entityType, Rule rule, String match); } |
...
Code Block |
---|
public class DescribeQuotasOptions extends AbstractOptions<DescribeQuotasOptions> { // Empty. } /** * The result of the {@link Admin#describeQuotas(Collection<QuotaFilter>, DescribeQuotasOptions)} call. * * The API of this class is evolving, see {@link Admin} for details. */ public class DescribeQuotasResult { /** * Maps an entity to its configured quota value(s). Note if no value is defined for a quota * type for that entity's config, then it is not included in the resulting value map. * * @param entities the collection of entities that matched the filter */ DescribeQuotasResult(KafkaFuture<Map<QuotaEntity, Map<QuotaKey, Double>>>Long>>> entities); /** * Returns a map from quota entity to a future which can be used to check the status of the operation. */ public KafkaFuture<Map<QuotaEntity, Map<QuotaKey, Double>>>Long>>> entities(); } public interface Admin extends AutoCloseable { ... /** * Describes all entities matching all provided filters (logical AND) that have at least one * quota value defined. * * @param filters filtering rules to apply to matching entities * @param options the options to use * @return result containing all matching entities */ DescribeQuotasResult describeQuotas(Collection<QuotaFilter> filters, DescribeQuotasOptions options); } |
...
Code Block |
---|
public class DescribeEffectiveQuotasOptions extends AbstractOptions<DescribeEffectiveQuotasOptions> { /** * Whether to includeexclude the list of overridden values for every quota type in the result. */ DescribeEffectiveQuotasOptions setOmitOverriddenValues(boolean omitOverriddenValues); } /** * The result of the {@link Admin#describeEffectiveQuotas(Collection<QuotaEntity>, DescribeEffectiveQuotasOptions)} call. */ public *class TheDescribeEffectiveQuotasResult API{ of this class is evolving, see {@link Admin} for details. */ public class DescribeEffectiveQuotasResult { /** * Information /** * Information about a specific quota configuration entry. */ public class Entry { /** * @param source the entity source for the value * @param value the non-null value */ public Entry(QuotaEntity source, DoubleLong value); } /** * Information about the value for a quota type. */ public class Value { /** * @param entry the quota entry * @param overriddenEntries all values that are overridden due to being lower in * specificity, or null if not requested */ public Value(Entry entry, List<Entry> overriddenEntries); } /** * Maps a collection of entities to their effective quota values. * * @param config the quota configuration for the requested entities */ public DescribeEffectiveQuotasResult(Map<QuotaEntity, KafkaFuture<Map<QuotaKey, Value>>> config); /** * Returns a map from quota entity to a future which can be used to check the status of the operation. */ public Map<QuotaEntity, KafkaFuture<Map<QuotaKey, Value>>> config(); /** * Returns a future which succeeds only if all quota descriptions succeed. */ public KafkaFuture<Void> all(); } public interface Admin extends AutoCloseable { ... /** * Describes the effective quotas for the provided entities. * * @param entities the entities to describe the effective quotas for * @param options the options to use * @return the effective quotas for the entities */ DescribeEffectiveQuotasResult describeEffectiveQuotas(Collection<QuotaEntity> entities, DescribeEffectiveQuotasOptions options); } |
AlterQuotas
Code Block |
---|
public class AlterQuotasOptions extends AbstractOptions<AlterQuotasOptions>AlterQuotasEntry { public class Op { /** * Sets@param whetherkey the requestquota shouldtype be validated without altering the configs. and units to alter */ @param value if publicset then AlterQuotasOptionsthe validateOnly(boolean validateOnly); } /** * The result of the {@link Admin#alterQuotas(Collection<AlterQuotasEntry>, AlterQuotasOptions)} call. * * The API of this class is evolving, see {@link Admin} for details. */ public class AlterQuotasResult { existing value is updated, * otherwise if null, the existing value is cleared */ public AlterQuotasResultOp(Map<QuotaEntityQuotaKey key, KafkaFuture<Void>>Long futuresvalue); } /** * Returns@param aentity mapthe fromentity quotawhose entityconfig to a future which can be used to checkwill be modified * @param ops the statusalteration ofto theperform operation. - if value is set, */ then the existing value publicis Map<QuotaEntityupdated, KafkaFuture<Void>> values(); /** * Returns a future which succeeds onlyotherwise if all quota alterations succeed.null, the existing value is cleared */ public KafkaFuture<Void> all(AlterQuotasEntry(QuotaEntity entity, Collection<Op> ops); } public interfaceclass AdminAlterQuotasOptions extends AutoCloseableAbstractOptions<AlterQuotasOptions> { ... /** * AltersSets whether the request quotasshould be asvalidated specifiedwithout foraltering the entriesconfigs. */ public *AlterQuotasOptions @param alterations the alterations to perform * @return the result of the alterations */ AlterQuotasResult alterQuotas(Collection<AlterQuotasEntry> entries, AlterQuotasOptions options); } |
...
validateOnly(boolean validateOnly);
}
/**
* The result of the {@link Admin#alterQuotas(Collection<AlterQuotasEntry>, AlterQuotasOptions)} call.
*
* The API of this class is evolving, see {@link Admin} for details.
*/
public class AlterQuotasResult {
public AlterQuotasResult(Map<QuotaEntity, KafkaFuture<Void>> futures);
/**
* Returns a map from quota entity to a future which can be used to check the status of the operation.
*/
public Map<QuotaEntity, KafkaFuture<Void>> values();
/**
* Returns a future which succeeds only if all quota alterations succeed.
*/
public KafkaFuture<Void> all();
}
public interface Admin extends AutoCloseable {
...
/**
* Alters the quotas as specified for the entries.
*
* @param alterations the alterations to perform
* @return the result of the alterations
*/
AlterQuotasResult alterQuotas(Collection<AlterQuotasEntry> entries, AlterQuotasOptions options);
} |
Proposed Changes
TODO: Wire protocol.
Code Block |
---|
{
"apiKey": 48,
"type": "request",
"name": "DescribeQuotasRequest",
"validVersions": "0",
"flexibleVersions": "none",
"fields": [
{ "name": "Filter", "type": "[]QuotaFilterData", "versions": "0+",
"about": "Filters to apply to quota entities.", "fields": [
{ "name": "EntityType", "type": "string", "versions": "0+",
"about": "The entity type that the filter applies to." },
{ "name": "Rule", "type": "string", "versions": "0+",
"about": "The rule the filter performs." },
{ "name": "Match", "type": "string", "versions": "0+",
"about": "The string to apply the rule against." }
]}
]
}
|
TODO: Wire protocol.
Code Block |
---|
{ "apiKey": 48, "type": "requestresponse", "name": "DescribeQuotasRequestDescribeQuotasResponse", "validVersions": "0", "flexibleVersions": "none", "fields": [ { "name": "FilterEntry", "type": "[]QuotaFilterDataEntryData", "versions": "0+", "about": "FiltersA to apply to quota entitiesresult entry.", "fields": [ { "name": "EntityTypeEntity", "type": "string[]QuotaEntityData", "versions": "0+", "about": "The quota entity type that the filter applies to." }, description.", "fields": [ { "name": "RuleEntityType", "type": "string", "versions": "0+", "about": "The rule the filterentity performstype." }, { "name": "MatchEntityName", "type": "string", "versions": "0+", "about": "The string to apply the rule againstentity name." } ]}, ] } { "apiKey": 48, { "typename": "responseType", "nametype": "DescribeQuotasResponsestring", "validVersionsversions": "0+", "flexibleVersions "about": "none"The quota type." }, "fields": [ { "name": "EntryUnits", "type": "[]EntryDatastring", "versions": "0+", "about": "A result entryThe units for the value.", "fields": [ }, { "name": "EntityValue", "type": "[]QuotaEntityDataint64", "versions": "0+", "about": "The quota entity descriptionvalue.", "fields": [ { "name } ]} ] } |
Code Block |
---|
{ "apiKey": 49, "type": "EntityTyperequest", "typename": "stringDescribeEffectiveQuotasRequest", "versionsvalidVersions": "0+", "about"flexibleVersions": "The entity type." }none", "fields": [ { "name": "EntityNameEntity", "type": "string[]QuotaEntityData", "versions": "0+", "about": "The quota entity namedescription." } ]},, "fields": [ { "name": "TypeEntityType", "type": "string", "versions": "0+", "about": "The quotaentity type." }, { "name": "UnitsEntityName", "type": "string", "versions": "0+", "about": "The units for the valueentity name." }, ]}, { "name": "ValueOmitOverriddenValues", "type": "int64bool", "versions": "0+", "about": "The quota value." } ]Whether to exclude the list of overridden values for every quota type." } ] } |
Code Block |
TODO: ConfigCommand changes.
...