Search in sources :

Example 1 with AlterClientQuotasResponse

use of org.apache.kafka.common.requests.AlterClientQuotasResponse 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));
}
Also used : ClientQuotaAlteration(org.apache.kafka.common.quota.ClientQuotaAlteration) HashMap(java.util.HashMap) AbstractResponse(org.apache.kafka.common.requests.AbstractResponse) ChannelBuilder(org.apache.kafka.common.network.ChannelBuilder) KafkaFutureImpl(org.apache.kafka.common.internals.KafkaFutureImpl) AlterClientQuotasResponse(org.apache.kafka.common.requests.AlterClientQuotasResponse) AlterClientQuotasRequest(org.apache.kafka.common.requests.AlterClientQuotasRequest) ClientQuotaEntity(org.apache.kafka.common.quota.ClientQuotaEntity)

Aggregations

HashMap (java.util.HashMap)1 KafkaFutureImpl (org.apache.kafka.common.internals.KafkaFutureImpl)1 ChannelBuilder (org.apache.kafka.common.network.ChannelBuilder)1 ClientQuotaAlteration (org.apache.kafka.common.quota.ClientQuotaAlteration)1 ClientQuotaEntity (org.apache.kafka.common.quota.ClientQuotaEntity)1 AbstractResponse (org.apache.kafka.common.requests.AbstractResponse)1 AlterClientQuotasRequest (org.apache.kafka.common.requests.AlterClientQuotasRequest)1 AlterClientQuotasResponse (org.apache.kafka.common.requests.AlterClientQuotasResponse)1