Search in sources :

Example 1 with AlterClientQuotasResponseData

use of org.apache.kafka.common.message.AlterClientQuotasResponseData 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 AlterClientQuotasResponseData

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

the class AlterClientQuotasResponse method fromQuotaEntities.

public static AlterClientQuotasResponse fromQuotaEntities(Map<ClientQuotaEntity, ApiError> result, int throttleTimeMs) {
    List<EntryData> entries = new ArrayList<>(result.size());
    for (Map.Entry<ClientQuotaEntity, ApiError> entry : result.entrySet()) {
        ApiError e = entry.getValue();
        entries.add(new EntryData().setErrorCode(e.error().code()).setErrorMessage(e.message()).setEntity(toEntityData(entry.getKey())));
    }
    return new AlterClientQuotasResponse(new AlterClientQuotasResponseData().setThrottleTimeMs(throttleTimeMs).setEntries(entries));
}
Also used : EntryData(org.apache.kafka.common.message.AlterClientQuotasResponseData.EntryData) AlterClientQuotasResponseData(org.apache.kafka.common.message.AlterClientQuotasResponseData) ArrayList(java.util.ArrayList) ClientQuotaEntity(org.apache.kafka.common.quota.ClientQuotaEntity) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

ArrayList (java.util.ArrayList)2 AlterClientQuotasResponseData (org.apache.kafka.common.message.AlterClientQuotasResponseData)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 EntityData (org.apache.kafka.common.message.AlterClientQuotasRequestData.EntityData)1 EntryData (org.apache.kafka.common.message.AlterClientQuotasRequestData.EntryData)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