cmccabe commented on a change in pull request #10931: URL: https://github.com/apache/kafka/pull/10931#discussion_r661665310
########## File path: metadata/src/main/java/org/apache/kafka/image/ClientQuotasImage.java ########## @@ -0,0 +1,178 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.kafka.image; + +import org.apache.kafka.common.message.DescribeClientQuotasRequestData; +import org.apache.kafka.common.message.DescribeClientQuotasResponseData; +import org.apache.kafka.common.message.DescribeClientQuotasResponseData.EntityData; +import org.apache.kafka.common.message.DescribeClientQuotasResponseData.EntryData; +import org.apache.kafka.common.quota.ClientQuotaEntity; +import org.apache.kafka.server.common.ApiMessageAndVersion; + +import java.io.IOException; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map.Entry; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; + +import static org.apache.kafka.common.protocol.Errors.INVALID_REQUEST; +import static org.apache.kafka.common.protocol.Errors.UNSUPPORTED_VERSION; +import static org.apache.kafka.common.requests.DescribeClientQuotasRequest.MATCH_TYPE_EXACT; +import static org.apache.kafka.common.requests.DescribeClientQuotasRequest.MATCH_TYPE_DEFAULT; +import static org.apache.kafka.common.requests.DescribeClientQuotasRequest.MATCH_TYPE_SPECIFIED; + + +/** + * Represents the client quotas in the metadata image. + * + * This class is thread-safe. + */ +public final class ClientQuotasImage { + public final static ClientQuotasImage EMPTY = new ClientQuotasImage(Collections.emptyMap()); + + private final Map<ClientQuotaEntity, ClientQuotaImage> entities; + + public ClientQuotasImage(Map<ClientQuotaEntity, ClientQuotaImage> entities) { + this.entities = entities; + } + + public boolean isEmpty() { + return entities.isEmpty(); + } + + Map<ClientQuotaEntity, ClientQuotaImage> entities() { + return entities; + } + + public void write(Consumer<List<ApiMessageAndVersion>> out) throws IOException { + for (Entry<ClientQuotaEntity, ClientQuotaImage> entry : entities.entrySet()) { + ClientQuotaEntity entity = entry.getKey(); + ClientQuotaImage clientQuotaImage = entry.getValue(); + clientQuotaImage.write(entity, out); + } + } + + public DescribeClientQuotasResponseData describe(DescribeClientQuotasRequestData request) { + DescribeClientQuotasResponseData response = new DescribeClientQuotasResponseData(); + Map<String, String> exact = new HashMap<>(); + Set<String> any = new HashSet<>(); Review comment: OK -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org