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;
}
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));
}
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);
}
Aggregations