use of org.apache.kafka.common.quota.ClientQuotaEntity 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);
}
use of org.apache.kafka.common.quota.ClientQuotaEntity in project kafka by apache.
the class KafkaAdminClient method alterClientQuotas.
@Override
public AlterClientQuotasResult alterClientQuotas(Collection<ClientQuotaAlteration> entries, AlterClientQuotasOptions options) {
Map<ClientQuotaEntity, KafkaFutureImpl<Void>> futures = new HashMap<>(entries.size());
for (ClientQuotaAlteration entry : entries) {
futures.put(entry.entity(), new KafkaFutureImpl<>());
}
final long now = time.milliseconds();
runnable.call(new Call("alterClientQuotas", calcDeadlineMs(now, options.timeoutMs()), new LeastLoadedNodeProvider()) {
@Override
AlterClientQuotasRequest.Builder createRequest(int timeoutMs) {
return new AlterClientQuotasRequest.Builder(entries, options.validateOnly());
}
@Override
void handleResponse(AbstractResponse abstractResponse) {
AlterClientQuotasResponse response = (AlterClientQuotasResponse) abstractResponse;
response.complete(futures);
}
@Override
void handleFailure(Throwable throwable) {
completeAllExceptionally(futures.values(), throwable);
}
}, now);
return new AlterClientQuotasResult(Collections.unmodifiableMap(futures));
}
Aggregations