Search in sources :

Example 1 with EntityData

use of org.apache.kafka.common.message.AlterClientQuotasRequestData.EntityData in project kafka by apache.

the class AlterClientQuotasRequest method getErrorResponse.

@Override
public AlterClientQuotasResponse getErrorResponse(int throttleTimeMs, Throwable e) {
    Errors error = Errors.forException(e);
    List<AlterClientQuotasResponseData.EntryData> responseEntries = new ArrayList<>();
    for (EntryData entryData : data.entries()) {
        List<AlterClientQuotasResponseData.EntityData> responseEntities = new ArrayList<>();
        for (EntityData entityData : entryData.entity()) {
            responseEntities.add(new AlterClientQuotasResponseData.EntityData().setEntityType(entityData.entityType()).setEntityName(entityData.entityName()));
        }
        responseEntries.add(new AlterClientQuotasResponseData.EntryData().setEntity(responseEntities).setErrorCode(error.code()).setErrorMessage(error.message()));
    }
    AlterClientQuotasResponseData responseData = new AlterClientQuotasResponseData().setThrottleTimeMs(throttleTimeMs).setEntries(responseEntries);
    return new AlterClientQuotasResponse(responseData);
}
Also used : Errors(org.apache.kafka.common.protocol.Errors) EntryData(org.apache.kafka.common.message.AlterClientQuotasRequestData.EntryData) AlterClientQuotasResponseData(org.apache.kafka.common.message.AlterClientQuotasResponseData) ArrayList(java.util.ArrayList) EntityData(org.apache.kafka.common.message.AlterClientQuotasRequestData.EntityData)

Example 2 with EntityData

use of org.apache.kafka.common.message.AlterClientQuotasRequestData.EntityData in project kafka by apache.

the class AlterClientQuotasRequest method entries.

public List<ClientQuotaAlteration> entries() {
    List<ClientQuotaAlteration> entries = new ArrayList<>(data.entries().size());
    for (EntryData entryData : data.entries()) {
        Map<String, String> entity = new HashMap<>(entryData.entity().size());
        for (EntityData entityData : entryData.entity()) {
            entity.put(entityData.entityType(), entityData.entityName());
        }
        List<ClientQuotaAlteration.Op> ops = new ArrayList<>(entryData.ops().size());
        for (OpData opData : entryData.ops()) {
            Double value = opData.remove() ? null : opData.value();
            ops.add(new ClientQuotaAlteration.Op(opData.key(), value));
        }
        entries.add(new ClientQuotaAlteration(new ClientQuotaEntity(entity), ops));
    }
    return entries;
}
Also used : ClientQuotaAlteration(org.apache.kafka.common.quota.ClientQuotaAlteration) EntryData(org.apache.kafka.common.message.AlterClientQuotasRequestData.EntryData) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) EntityData(org.apache.kafka.common.message.AlterClientQuotasRequestData.EntityData) OpData(org.apache.kafka.common.message.AlterClientQuotasRequestData.OpData) ClientQuotaEntity(org.apache.kafka.common.quota.ClientQuotaEntity)

Aggregations

ArrayList (java.util.ArrayList)2 EntityData (org.apache.kafka.common.message.AlterClientQuotasRequestData.EntityData)2 EntryData (org.apache.kafka.common.message.AlterClientQuotasRequestData.EntryData)2 HashMap (java.util.HashMap)1 OpData (org.apache.kafka.common.message.AlterClientQuotasRequestData.OpData)1 AlterClientQuotasResponseData (org.apache.kafka.common.message.AlterClientQuotasResponseData)1 Errors (org.apache.kafka.common.protocol.Errors)1 ClientQuotaAlteration (org.apache.kafka.common.quota.ClientQuotaAlteration)1 ClientQuotaEntity (org.apache.kafka.common.quota.ClientQuotaEntity)1