Search in sources :

Example 1 with EntityData

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

the class AlterClientQuotasResponse method complete.

public void complete(Map<ClientQuotaEntity, KafkaFutureImpl<Void>> futures) {
    for (EntryData entryData : data.entries()) {
        Map<String, String> entityEntries = new HashMap<>(entryData.entity().size());
        for (EntityData entityData : entryData.entity()) {
            entityEntries.put(entityData.entityType(), entityData.entityName());
        }
        ClientQuotaEntity entity = new ClientQuotaEntity(entityEntries);
        KafkaFutureImpl<Void> future = futures.get(entity);
        if (future == null) {
            throw new IllegalArgumentException("Future map must contain entity " + entity);
        }
        Errors error = Errors.forCode(entryData.errorCode());
        if (error == Errors.NONE) {
            future.complete(null);
        } else {
            future.completeExceptionally(error.exception(entryData.errorMessage()));
        }
    }
}
Also used : Errors(org.apache.kafka.common.protocol.Errors) EntryData(org.apache.kafka.common.message.AlterClientQuotasResponseData.EntryData) HashMap(java.util.HashMap) EntityData(org.apache.kafka.common.message.AlterClientQuotasResponseData.EntityData) ClientQuotaEntity(org.apache.kafka.common.quota.ClientQuotaEntity)

Aggregations

HashMap (java.util.HashMap)1 EntityData (org.apache.kafka.common.message.AlterClientQuotasResponseData.EntityData)1 EntryData (org.apache.kafka.common.message.AlterClientQuotasResponseData.EntryData)1 Errors (org.apache.kafka.common.protocol.Errors)1 ClientQuotaEntity (org.apache.kafka.common.quota.ClientQuotaEntity)1