use of org.apache.kafka.common.message.AlterClientQuotasResponseData.EntryData in project kafka by apache.
the class AlterClientQuotasResponse method complete.
public void complete(Map<ClientQuotaEntity, KafkaFutureImpl<Void>> futures) {
for (EntryData entryData : data.entries()) {
Map<String, String> entityEntries = new HashMap<>(entryData.entity().size());
for (EntityData entityData : entryData.entity()) {
entityEntries.put(entityData.entityType(), entityData.entityName());
}
ClientQuotaEntity entity = new ClientQuotaEntity(entityEntries);
KafkaFutureImpl<Void> future = futures.get(entity);
if (future == null) {
throw new IllegalArgumentException("Future map must contain entity " + entity);
}
Errors error = Errors.forCode(entryData.errorCode());
if (error == Errors.NONE) {
future.complete(null);
} else {
future.completeExceptionally(error.exception(entryData.errorMessage()));
}
}
}
use of org.apache.kafka.common.message.AlterClientQuotasResponseData.EntryData 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));
}
Aggregations