mumrah commented on a change in pull request #11677: URL: https://github.com/apache/kafka/pull/11677#discussion_r796852603
########## File path: core/src/main/scala/kafka/server/metadata/MetadataVersionManager.scala ########## @@ -0,0 +1,104 @@ +/** + * 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 kafka.server.metadata + +import kafka.utils.Logging +import org.apache.kafka.common.utils.LogContext +import org.apache.kafka.metadata.{MetadataVersionProvider, MetadataVersions} + +import scala.collection.mutable + + +/** + * This class holds the broker's view of the current metadata.version. Listeners can be registered with this class to + * get a synchronous callback when version has changed. + */ +class MetadataVersionManager extends MetadataVersionProvider with Logging { Review comment: ~If we used a callback thing, wouldn't each component then need to keep its own copy of the current metadata version? Also, would we need a volatile for this? We only have one thread doing writes, and it seems okay if reads are stale. If a component needs synchronization on metadata version updates, I think they would need to subscribe to updates and have their own lock (like ReplicaManager does).~ Edit: Actually, if we don't provide the data in the callback, but just notify listeners that a metadata version has changed, they can then get the latest value from MetadataImage. We just need to run the callbacks after building the new MetadataImage. Related to this, I have some uncommitted code that introduces an interface: ```java public interface ApiVersionResolver { short fetchRequestVersion(); short offsetForLeaderEpochVersion(); boolean isTruncationSupported(); boolean isOffsetForLeaderEpochSupport(); boolean isAlterIsrSupported(); } ``` This is intended to abstract the things provided by IBP/metadata.version. -- 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