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