OmniaGM commented on code in PR #15968:
URL: https://github.com/apache/kafka/pull/15968#discussion_r1639052751
##########
clients/src/main/java/org/apache/kafka/clients/ApiVersions.java:
##########
@@ -34,10 +34,21 @@ public class ApiVersions {
private final Map<String, NodeApiVersions> nodeApiVersions = new
HashMap<>();
private byte maxUsableProduceMagic = RecordBatch.CURRENT_MAGIC_VALUE;
+ private short maxProduceSupportedVersion = ApiKeys.PRODUCE.latestVersion();
public synchronized void update(String nodeId, NodeApiVersions
nodeApiVersions) {
this.nodeApiVersions.put(nodeId, nodeApiVersions);
this.maxUsableProduceMagic = computeMaxUsableProduceMagic();
+ this.maxProduceSupportedVersion = computeMaxProduceSupportedVersion();
+ }
+
+ private short computeMaxProduceSupportedVersion() {
+ Optional<Short> knownBrokerNodesMinSupportedVersionForProduce =
this.nodeApiVersions.values().stream()
Review Comment:
We only check ids for topics included in the batch, and we map these from
the metadata which at this point the producer already fetched them or cached
them.
By the time we build the `ProduceRequest` the `ProducerMetadata` would
already get updated if there is a need to do so as usual (I didn't change this
logic) . Then if I found out that `ProducerMetadata` doesn't contain the topic
id then the request will be send out with version 11 using the topic name only
and broker will figure the id out when it receive it. So the client doesn't
need to refetch topic ids every time we build a request.
On broker side when broker receive the request if the request is < 12 then
we use MetadataCache on the broker to map the topic id to topic name and don't
try to rebuild the `MetadataCache`. If we can't find topic id in MetadataCache
for this topic then the request would fail with `UNKNOWN_TOPIC_ID`.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]