KAFKA-10027: Implement read path for feature versioning system (KIP-584)#8680
Merged
junrao merged 20 commits intoapache:trunkfrom Jun 11, 2020
Merged
KAFKA-10027: Implement read path for feature versioning system (KIP-584)#8680junrao merged 20 commits intoapache:trunkfrom
junrao merged 20 commits intoapache:trunkfrom
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR:
In this PR, I have implemented various classes and integration for the read path of the feature versioning system (KIP-584). The ultimate plan is that the cluster-wide finalized features information is going to be stored in ZK under the node
/feature. The read path implemented in this PR is centered around reading this finalized features information from ZK, and, processing it inside the Broker.Here is a summary of what's in this PR (a lot of it is new classes):
BrokerIdZNodeunder afeatureskey.ApiVersionsResponseis now served containing supported and finalized feature information (using the newly added tagged fields).More details below.
New IBP config value:
The feature versioning system is implemented such that it is activated only if the IBP >=
KAFKA_2_7_IV0(newly defined value in this PR). That is because, we would like to keep the feature version system disabled (almost as if it is non-existent) until the user upgrades the cluster to or beyond IBPKAFKA_2_7_IV0.New common libraries (Java):
A set of common libraries abstracting features have been introduced. Features are a map with key being
String(feature name) and value being aVersionRangeType(the range of supported or finalized versions for the feature). These common libraries are defined as 4 new classes in:org.apache.kafka.common.feature.{Features, BaseVersionRange, SupportedVersionRange, FinalizedVersionRange}.The reason why it is kept in this common package is that future client and tooling development could reuse some/all of these abstractions.
New broker libraries (Scala):
The above common libraries are used within the Broker code to implement the read path for feature information, as explained below.
FinalizedFeatureCache: Implemented a cache of cluster-wide finalized features (see companion object:FinalizedFeatureCache). This cache stores the latest finalized features and epoch read from the/featurenode in ZK. Currently the main reader of this cache is the read path that serves anApiVersionsRequestreturning the features information in the response. In the future, as we start using the versioning system more, the cache could be read by future read paths intending to learn the finalized feature information. Note: this is defined as a companion object (a singleton), because, this way it will be easy to share read access with any code path in the Broker.FinalizedFeatureChangeListener: Implemented a feature ZK node change listener, that, listens to changes in the/featurenode in ZK, and, invalidates the cache defined inFinalizedFeatureCache(see above point). See class:FinalizedFeatureChangeListener. An instance of this class is maintained inKafkaServer, and initialized only if the IBP is set toKAFKA_2_7_IV0or higher.SupportedFeatures: Implemented a facility to define supported features within the Broker (these are specific to a broker binary). See companion object:SupportedFeatures. Currently the list of supported features is empty, because, we have not identified features (yet). In the future this class can be populated as we begin to define supported features. Also, the public interface of this class provides a way to compare supported vs finalized features to detect incompatibilities. Note: this is a companion object (a singleton), because, it makes it easy to define supported features at a common point and also share read access with any code path in the Broker.New Zookeeper node:
/feature:The finalized feature information is going to be stored in ZK under the node
/feature.FeatureZNode. It provides required state and encode/decode APIs that abstract the structure of the new feature ZK node.KafkaZkClient.scalato read/update/delete the/featureZK node.Broker advertisements:
A facility is provided in the broker to declare it's supported features (via the
SupportedFeaturesclass), and advertise it's supported features via it's ownBrokerIdZNodeunder afeatureskey (only if IBP >=KAFKA_2_7_IV0). The encode/decode logic for the newfeatureskey is provided in this PR in the classBrokerIdZNode.Updated ApiVersionsResponse:
Defined new tagged fields in existing
ApiVersionsResponseschema. In the request serving path (inKafkaApis.scala), these fields are populated in the response with the latest supported features (fromSupportedFeatures) and latest finalized features (fromFinalizedFeatureCache).Tests:
Added test suites for all of the new classes, and changes made in this PR.