Search in sources :

Example 1 with EntryData

use of org.apache.kafka.common.message.DescribeClientQuotasResponseData.EntryData in project kafka by apache.

the class ClientQuotasImage method toDescribeEntry.

private static EntryData toDescribeEntry(ClientQuotaEntity entity, ClientQuotaImage quotaImage) {
    EntryData data = new EntryData();
    for (Entry<String, String> entry : entity.entries().entrySet()) {
        data.entity().add(new EntityData().setEntityType(entry.getKey()).setEntityName(entry.getValue()));
    }
    data.setValues(quotaImage.toDescribeValues());
    return data;
}
Also used : EntryData(org.apache.kafka.common.message.DescribeClientQuotasResponseData.EntryData) EntityData(org.apache.kafka.common.message.DescribeClientQuotasResponseData.EntityData)

Example 2 with EntryData

use of org.apache.kafka.common.message.DescribeClientQuotasResponseData.EntryData in project kafka by apache.

the class DescribeClientQuotasResponse method fromQuotaEntities.

public static DescribeClientQuotasResponse fromQuotaEntities(Map<ClientQuotaEntity, Map<String, Double>> entities, int throttleTimeMs) {
    List<EntryData> entries = new ArrayList<>(entities.size());
    for (Map.Entry<ClientQuotaEntity, Map<String, Double>> entry : entities.entrySet()) {
        ClientQuotaEntity quotaEntity = entry.getKey();
        List<EntityData> entityData = new ArrayList<>(quotaEntity.entries().size());
        for (Map.Entry<String, String> entityEntry : quotaEntity.entries().entrySet()) {
            entityData.add(new EntityData().setEntityType(entityEntry.getKey()).setEntityName(entityEntry.getValue()));
        }
        Map<String, Double> quotaValues = entry.getValue();
        List<ValueData> valueData = new ArrayList<>(quotaValues.size());
        for (Map.Entry<String, Double> valuesEntry : entry.getValue().entrySet()) {
            valueData.add(new ValueData().setKey(valuesEntry.getKey()).setValue(valuesEntry.getValue()));
        }
        entries.add(new EntryData().setEntity(entityData).setValues(valueData));
    }
    return new DescribeClientQuotasResponse(new DescribeClientQuotasResponseData().setThrottleTimeMs(throttleTimeMs).setErrorCode((short) 0).setErrorMessage(null).setEntries(entries));
}
Also used : EntryData(org.apache.kafka.common.message.DescribeClientQuotasResponseData.EntryData) ArrayList(java.util.ArrayList) EntityData(org.apache.kafka.common.message.DescribeClientQuotasResponseData.EntityData) ClientQuotaEntity(org.apache.kafka.common.quota.ClientQuotaEntity) HashMap(java.util.HashMap) Map(java.util.Map) ValueData(org.apache.kafka.common.message.DescribeClientQuotasResponseData.ValueData) DescribeClientQuotasResponseData(org.apache.kafka.common.message.DescribeClientQuotasResponseData)

Example 3 with EntryData

use of org.apache.kafka.common.message.DescribeClientQuotasResponseData.EntryData in project kafka by apache.

the class DescribeClientQuotasResponse method complete.

public void complete(KafkaFutureImpl<Map<ClientQuotaEntity, Map<String, Double>>> future) {
    Errors error = Errors.forCode(data.errorCode());
    if (error != Errors.NONE) {
        future.completeExceptionally(error.exception(data.errorMessage()));
        return;
    }
    Map<ClientQuotaEntity, Map<String, Double>> result = new HashMap<>(data.entries().size());
    for (EntryData entries : data.entries()) {
        Map<String, String> entity = new HashMap<>(entries.entity().size());
        for (EntityData entityData : entries.entity()) {
            entity.put(entityData.entityType(), entityData.entityName());
        }
        Map<String, Double> values = new HashMap<>(entries.values().size());
        for (ValueData valueData : entries.values()) {
            values.put(valueData.key(), valueData.value());
        }
        result.put(new ClientQuotaEntity(entity), values);
    }
    future.complete(result);
}
Also used : Errors(org.apache.kafka.common.protocol.Errors) EntryData(org.apache.kafka.common.message.DescribeClientQuotasResponseData.EntryData) HashMap(java.util.HashMap) EntityData(org.apache.kafka.common.message.DescribeClientQuotasResponseData.EntityData) ClientQuotaEntity(org.apache.kafka.common.quota.ClientQuotaEntity) HashMap(java.util.HashMap) Map(java.util.Map) ValueData(org.apache.kafka.common.message.DescribeClientQuotasResponseData.ValueData)

Aggregations

EntityData (org.apache.kafka.common.message.DescribeClientQuotasResponseData.EntityData)3 EntryData (org.apache.kafka.common.message.DescribeClientQuotasResponseData.EntryData)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ValueData (org.apache.kafka.common.message.DescribeClientQuotasResponseData.ValueData)2 ClientQuotaEntity (org.apache.kafka.common.quota.ClientQuotaEntity)2 ArrayList (java.util.ArrayList)1 DescribeClientQuotasResponseData (org.apache.kafka.common.message.DescribeClientQuotasResponseData)1 Errors (org.apache.kafka.common.protocol.Errors)1