@@ -97,10 +97,49 @@ enum class APIKey : int16_t {
9797 kAlterClientQuotas = 49 ,
9898 kDescribeUserScramCredentials = 50 ,
9999 kAlterUserScramCredentials = 51 ,
100+ kVote = 52 ,
101+ kBeginQuorumEpoch = 53 ,
102+ kEndQuorumEpoch = 54 ,
103+ kDescribeQuorum = 55 ,
104+ // Renamed from AlterIsr to AlterPartition in Kafka 3.x, but the api key is unchanged.
100105 kAlterIsr = 56 ,
101106 kUpdateFeatures = 57 ,
107+ kEnvelope = 58 ,
108+ kFetchSnapshot = 59 ,
102109 kDescribeCluster = 60 ,
103110 kDescribeProducers = 61 ,
111+ kBrokerRegistration = 62 ,
112+ kBrokerHeartbeat = 63 ,
113+ kUnregisterBroker = 64 ,
114+ kDescribeTransactions = 65 ,
115+ kListTransactions = 66 ,
116+ kAllocateProducerIds = 67 ,
117+ kConsumerGroupHeartbeat = 68 ,
118+ kConsumerGroupDescribe = 69 ,
119+ kControllerRegistration = 70 ,
120+ kGetTelemetrySubscriptions = 71 ,
121+ kPushTelemetry = 72 ,
122+ kAssignReplicasToDirs = 73 ,
123+ kListConfigResources = 74 ,
124+ kDescribeTopicPartitions = 75 ,
125+ kShareGroupHeartbeat = 76 ,
126+ kShareGroupDescribe = 77 ,
127+ kShareFetch = 78 ,
128+ kShareAcknowledge = 79 ,
129+ kAddRaftVoter = 80 ,
130+ kRemoveRaftVoter = 81 ,
131+ kUpdateRaftVoter = 82 ,
132+ kInitializeShareGroupState = 83 ,
133+ kReadShareGroupState = 84 ,
134+ kWriteShareGroupState = 85 ,
135+ kDeleteShareGroupState = 86 ,
136+ kReadShareGroupStateSummary = 87 ,
137+ kStreamsGroupHeartbeat = 88 ,
138+ kStreamsGroupDescribe = 89 ,
139+ kDescribeShareGroupOffsets = 90 ,
140+ kAlterShareGroupOffsets = 91 ,
141+ kDeleteShareGroupOffsets = 92 ,
142+ kStreamsGroupTopologyDescriptionUpdate = 93 ,
104143};
105144
106145// Error Codes
@@ -226,65 +265,106 @@ struct APIVersionData {
226265// https://cwiki.apache.org/confluence/display/KAFKA/KIP-482%3A+The+Kafka+Protocol+should+Support+Optional+Tagged+Fields#KIP482:TheKafkaProtocolshouldSupportOptionalTaggedFields-FlexibleVersions
227266// Detailed information on each API key:
228267// https://github.com/apache/kafka/tree/trunk/clients/src/main/resources/common/message
229- // TODO(chengruizhe): Needs updating for new opcodes.
268+ // Versions below are refreshed against Kafka trunk (4.4.0-SNAPSHOT), which is a superset of all
269+ // released Kafka protocol versions through 4.x. Min versions are intentionally kept low (0, or 1
270+ // for Produce) to make frame boundary detection more robust; only the max and flexible versions
271+ // need to track upstream to avoid rejecting modern clients.
230272inline const absl::flat_hash_map<APIKey, APIVersionData> APIVersionMap = {
231273 // Setting min supported version to 1 to help finding frame boundary.
232- {APIKey::kProduce , {1 , 9 , 9 }},
233- {APIKey::kFetch , {0 , 12 , 12 }},
234- {APIKey::kListOffsets , {0 , 7 , 6 }},
235- {APIKey::kMetadata , {0 , 12 , 9 }},
274+ {APIKey::kProduce , {1 , 13 , 9 }},
275+ {APIKey::kFetch , {0 , 18 , 12 }},
276+ {APIKey::kListOffsets , {0 , 11 , 6 }},
277+ {APIKey::kMetadata , {0 , 13 , 9 }},
236278 {APIKey::kLeaderAndIsr , {0 , 5 , 4 }},
237279 {APIKey::kStopReplica , {0 , 3 , 2 }},
238280 {APIKey::kUpdateMetadata , {0 , 7 , 6 }},
239281 {APIKey::kControlledShutdown , {0 , 3 , 3 }},
240- {APIKey::kOffsetCommit , {0 , 8 , 8 }},
241- {APIKey::kOffsetFetch , {0 , 8 , 6 }},
242- {APIKey::kFindCoordinator , {0 , 4 , 3 }},
243- {APIKey::kJoinGroup , {0 , 7 , 6 }},
282+ {APIKey::kOffsetCommit , {0 , 10 , 8 }},
283+ {APIKey::kOffsetFetch , {0 , 10 , 6 }},
284+ {APIKey::kFindCoordinator , {0 , 6 , 3 }},
285+ {APIKey::kJoinGroup , {0 , 9 , 6 }},
244286 {APIKey::kHeartbeat , {0 , 4 , 4 }},
245- {APIKey::kLeaveGroup , {0 , 4 , 4 }},
287+ {APIKey::kLeaveGroup , {0 , 5 , 4 }},
246288 {APIKey::kSyncGroup , {0 , 5 , 4 }},
247- {APIKey::kDescribeGroups , {0 , 5 , 5 }},
248- {APIKey::kListGroups , {0 , 4 , 3 }},
289+ {APIKey::kDescribeGroups , {0 , 6 , 5 }},
290+ {APIKey::kListGroups , {0 , 5 , 3 }},
249291 {APIKey::kSaslHandshake , {0 , 1 , -1 }},
250- {APIKey::kApiVersions , {0 , 3 , 3 }},
292+ {APIKey::kApiVersions , {0 , 5 , 3 }},
251293 {APIKey::kCreateTopics , {0 , 7 , 5 }},
252294 {APIKey::kDeleteTopics , {0 , 6 , 4 }},
253295 {APIKey::kDeleteRecords , {0 , 2 , 2 }},
254- {APIKey::kInitProducerId , {0 , 4 , 2 }},
296+ {APIKey::kInitProducerId , {0 , 6 , 2 }},
255297 {APIKey::kOffsetForLeaderEpoch , {0 , 4 , 4 }},
256- {APIKey::kAddPartitionsToTxn , {0 , 3 , 3 }},
257- {APIKey::kAddOffsetsToTxn , {0 , 3 , 3 }},
258- {APIKey::kEndTxn , {0 , 3 , 3 }},
259- {APIKey::kWriteTxnMarkers , {0 , 1 , 1 }},
260- {APIKey::kTxnOffsetCommit , {0 , 3 , 3 }},
261- {APIKey::kDescribeAcls , {0 , 2 , 2 }},
262- {APIKey::kCreateAcls , {0 , 2 , 2 }},
263- {APIKey::kDeleteAcls , {0 , 2 , 2 }},
298+ {APIKey::kAddPartitionsToTxn , {0 , 5 , 3 }},
299+ {APIKey::kAddOffsetsToTxn , {0 , 4 , 3 }},
300+ {APIKey::kEndTxn , {0 , 5 , 3 }},
301+ {APIKey::kWriteTxnMarkers , {0 , 2 , 1 }},
302+ {APIKey::kTxnOffsetCommit , {0 , 6 , 3 }},
303+ {APIKey::kDescribeAcls , {0 , 3 , 2 }},
304+ {APIKey::kCreateAcls , {0 , 3 , 2 }},
305+ {APIKey::kDeleteAcls , {0 , 3 , 2 }},
264306 {APIKey::kDescribeConfigs , {0 , 4 , 4 }},
265307 {APIKey::kAlterConfigs , {0 , 2 , 2 }},
266308 {APIKey::kAlterReplicaLogDirs , {0 , 2 , 2 }},
267- {APIKey::kDescribeLogDirs , {0 , 2 , 2 }},
309+ {APIKey::kDescribeLogDirs , {0 , 5 , 2 }},
268310 {APIKey::kSaslAuthenticate , {0 , 2 , 2 }},
269311 {APIKey::kCreatePartitions , {0 , 3 , 2 }},
270- {APIKey::kCreateDelegationToken , {0 , 2 , 2 }},
312+ {APIKey::kCreateDelegationToken , {0 , 3 , 2 }},
271313 {APIKey::kRenewDelegationToken , {0 , 2 , 2 }},
272314 {APIKey::kExpireDelegationToken , {0 , 2 , 2 }},
273- {APIKey::kDescribeDelegationToken , {0 , 2 , 2 }},
274- {APIKey::kDeleteGroups , {0 , 5 , 5 }},
315+ {APIKey::kDescribeDelegationToken , {0 , 3 , 2 }},
316+ {APIKey::kDeleteGroups , {0 , 3 , 2 }},
275317 {APIKey::kElectLeaders , {0 , 2 , 2 }},
276318 {APIKey::kIncrementalAlterConfigs , {0 , 1 , 1 }},
277- {APIKey::kAlterPartitionReassignments , {0 , 0 , 0 }},
319+ {APIKey::kAlterPartitionReassignments , {0 , 1 , 0 }},
278320 {APIKey::kListPartitionReassignments , {0 , 0 , 0 }},
279321 {APIKey::kOffsetDelete , {0 , 0 , -1 }},
280322 {APIKey::kDescribeClientQuotas , {0 , 1 , 1 }},
281323 {APIKey::kAlterClientQuotas , {0 , 1 , 1 }},
282324 {APIKey::kDescribeUserScramCredentials , {0 , 0 , 0 }},
283325 {APIKey::kAlterUserScramCredentials , {0 , 0 , 0 }},
284- {APIKey::kAlterIsr , {0 , 0 , 0 }},
285- {APIKey::kUpdateFeatures , {0 , 0 , 0 }},
286- {APIKey::kDescribeCluster , {0 , 0 , 0 }},
287- {APIKey::kDescribeProducers , {0 , 0 , 0 }}};
326+ {APIKey::kVote , {0 , 2 , 0 }},
327+ {APIKey::kBeginQuorumEpoch , {0 , 1 , 1 }},
328+ {APIKey::kEndQuorumEpoch , {0 , 1 , 1 }},
329+ {APIKey::kDescribeQuorum , {0 , 2 , 0 }},
330+ {APIKey::kAlterIsr , {0 , 3 , 0 }},
331+ {APIKey::kUpdateFeatures , {0 , 2 , 0 }},
332+ {APIKey::kEnvelope , {0 , 0 , 0 }},
333+ {APIKey::kFetchSnapshot , {0 , 1 , 0 }},
334+ {APIKey::kDescribeCluster , {0 , 2 , 0 }},
335+ {APIKey::kDescribeProducers , {0 , 0 , 0 }},
336+ {APIKey::kBrokerRegistration , {0 , 4 , 0 }},
337+ {APIKey::kBrokerHeartbeat , {0 , 2 , 0 }},
338+ {APIKey::kUnregisterBroker , {0 , 0 , 0 }},
339+ {APIKey::kDescribeTransactions , {0 , 0 , 0 }},
340+ {APIKey::kListTransactions , {0 , 2 , 0 }},
341+ {APIKey::kAllocateProducerIds , {0 , 0 , 0 }},
342+ {APIKey::kConsumerGroupHeartbeat , {0 , 1 , 0 }},
343+ {APIKey::kConsumerGroupDescribe , {0 , 1 , 0 }},
344+ {APIKey::kControllerRegistration , {0 , 0 , 0 }},
345+ {APIKey::kGetTelemetrySubscriptions , {0 , 0 , 0 }},
346+ {APIKey::kPushTelemetry , {0 , 0 , 0 }},
347+ {APIKey::kAssignReplicasToDirs , {0 , 0 , 0 }},
348+ {APIKey::kListConfigResources , {0 , 1 , 0 }},
349+ {APIKey::kDescribeTopicPartitions , {0 , 0 , 0 }},
350+ {APIKey::kShareGroupHeartbeat , {0 , 1 , 0 }},
351+ {APIKey::kShareGroupDescribe , {0 , 1 , 0 }},
352+ {APIKey::kShareFetch , {0 , 2 , 0 }},
353+ {APIKey::kShareAcknowledge , {0 , 2 , 0 }},
354+ {APIKey::kAddRaftVoter , {0 , 1 , 0 }},
355+ {APIKey::kRemoveRaftVoter , {0 , 0 , 0 }},
356+ {APIKey::kUpdateRaftVoter , {0 , 0 , 0 }},
357+ {APIKey::kInitializeShareGroupState , {0 , 0 , 0 }},
358+ {APIKey::kReadShareGroupState , {0 , 0 , 0 }},
359+ {APIKey::kWriteShareGroupState , {0 , 1 , 0 }},
360+ {APIKey::kDeleteShareGroupState , {0 , 0 , 0 }},
361+ {APIKey::kReadShareGroupStateSummary , {0 , 1 , 0 }},
362+ {APIKey::kStreamsGroupHeartbeat , {0 , 1 , 0 }},
363+ {APIKey::kStreamsGroupDescribe , {0 , 1 , 0 }},
364+ {APIKey::kDescribeShareGroupOffsets , {0 , 1 , 0 }},
365+ {APIKey::kAlterShareGroupOffsets , {0 , 0 , 0 }},
366+ {APIKey::kDeleteShareGroupOffsets , {0 , 0 , 0 }},
367+ {APIKey::kStreamsGroupTopologyDescriptionUpdate , {0 , 0 , 0 }}};
288368
289369inline bool IsFlexible (APIKey api_key, int16_t api_version) {
290370 auto it = APIVersionMap.find (api_key);
@@ -324,7 +404,7 @@ constexpr int kMinReqPacketLength =
324404 kMessageLengthBytes + kAPIKeyLength + kAPIVersionLength + kCorrelationIDLength ;
325405// length, correlation_id
326406constexpr int kMinRespPacketLength = kMessageLengthBytes + kCorrelationIDLength ;
327- constexpr int kMaxAPIVersion = 12 ;
407+ constexpr int kMaxAPIVersion = 18 ;
328408
329409struct Packet : public FrameBase {
330410 int32_t correlation_id;
0 commit comments