FrankYang0529 commented on code in PR #19426: URL: https://github.com/apache/kafka/pull/19426#discussion_r2039487932
########## core/src/main/scala/kafka/server/BrokerServer.scala: ########## @@ -252,7 +252,7 @@ class BrokerServer( forwardingManager = new ForwardingManagerImpl(clientToControllerChannelManager, metrics) clientMetricsManager = new ClientMetricsManager(clientMetricsReceiverPlugin, config.clientTelemetryMaxBytes, time, metrics) - val apiVersionManager = ApiVersionManager( + val apiVersionManager = DefaultApiVersionManager( Review Comment: nit: we can change this like following, so `DefaultApiVersionManager#apply` can be removed. ```scala val apiVersionManager = new DefaultApiVersionManager( ListenerType.BROKER, forwardingManager, brokerFeatures, metadataCache, config.unstableApiVersionsEnabled, Some(clientMetricsManager) ) ``` ########## server/src/main/java/org/apache/kafka/server/SimpleApiVersionManager.java: ########## @@ -0,0 +1,107 @@ +/* + * 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.server; + +import org.apache.kafka.common.feature.Features; +import org.apache.kafka.common.feature.SupportedVersionRange; +import org.apache.kafka.common.message.ApiMessageType; +import org.apache.kafka.common.message.ApiVersionsResponseData; +import org.apache.kafka.common.protocol.ApiKeys; +import org.apache.kafka.common.requests.ApiVersionsResponse; +import org.apache.kafka.server.common.FinalizedFeatures; + +import java.util.Set; +import java.util.function.Supplier; + +/** + * A simple ApiVersionManager used in controllers. It does not support forwarding and does not have metadata cache. + * Its enabled APIs are determined by the listener type, its finalized features are dynamically determined by the controller. + */ +public class SimpleApiVersionManager implements ApiVersionManager { + + private final ApiMessageType.ListenerType listenerType; + private final Set<ApiKeys> enabledApis; + private final Features<SupportedVersionRange> brokerFeatures; + private final boolean enableUnstableLastVersion; + private final Supplier<FinalizedFeatures> featuresProvider; + private final ApiVersionsResponseData.ApiVersionCollection apiVersions; + + /** + * SimpleApiVersionManager constructor + * @param listenerType the listener type + * @param enabledApis the enabled apis, which are computed by the listener type + * @param brokerFeatures the broker features + * @param enableUnstableLastVersion whether to enable unstable last version, see KafkaConfig.unstableApiVersionsEnabled Review Comment: nit: we cannot link to KafkaConfig. Probably, we can change this like following: ``` * @param enableUnstableLastVersion whether to enable unstable last version, see {@link org.apache.kafka.server.config.ServerConfigs#UNSTABLE_API_VERSIONS_ENABLE_CONFIG} ``` -- 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