Search in sources :

Example 1 with ClientQuotaFilterComponent

use of org.apache.kafka.common.quota.ClientQuotaFilterComponent in project kafka by apache.

the class DescribeClientQuotasRequest method filter.

public ClientQuotaFilter filter() {
    List<ClientQuotaFilterComponent> components = new ArrayList<>(data.components().size());
    for (ComponentData componentData : data.components()) {
        ClientQuotaFilterComponent component;
        switch(componentData.matchType()) {
            case MATCH_TYPE_EXACT:
                component = ClientQuotaFilterComponent.ofEntity(componentData.entityType(), componentData.match());
                break;
            case MATCH_TYPE_DEFAULT:
                component = ClientQuotaFilterComponent.ofDefaultEntity(componentData.entityType());
                break;
            case MATCH_TYPE_SPECIFIED:
                component = ClientQuotaFilterComponent.ofEntityType(componentData.entityType());
                break;
            default:
                throw new IllegalArgumentException("Unexpected match type: " + componentData.matchType());
        }
        components.add(component);
    }
    if (data.strict()) {
        return ClientQuotaFilter.containsOnly(components);
    } else {
        return ClientQuotaFilter.contains(components);
    }
}
Also used : ClientQuotaFilterComponent(org.apache.kafka.common.quota.ClientQuotaFilterComponent) ArrayList(java.util.ArrayList) ComponentData(org.apache.kafka.common.message.DescribeClientQuotasRequestData.ComponentData)

Aggregations

ArrayList (java.util.ArrayList)1 ComponentData (org.apache.kafka.common.message.DescribeClientQuotasRequestData.ComponentData)1 ClientQuotaFilterComponent (org.apache.kafka.common.quota.ClientQuotaFilterComponent)1