Vote
This page encodes the smallest legal instance of the request and the response: numeric fields are zero, strings and byte arrays are empty, every array carries exactly one sample element, and any records field holds one empty 61-byte RecordBatch v2. Version 2 is a flexible version, so every struct is terminated by a uvarint tagged-field count and strings and arrays carry compact length-plus-one prefixes. Sizes below include the leading int32 size prefix.
- API key
- 52
- Encoded at
- v2
- Flexible versions
- 0+
- Headers
- req v2, resp v1
- Request versions
- 0-2
- Response versions
- 0-2
- Request size
- 83 bytes
- Response size
- 32 bytes
framerpc headerrequest bodyRecordBatchRecordresponse bodytagged_fields
Request
VoteRequest v2, request header v2, 83 bytes on the wire
byte layout (83 bytes, 16 bytes per row)
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
0000
0010
0020
0030
0040
0050
object tree
VoteRequest message v2 [0x0000, 83B] +-- Frame [0x0000, 4B] length-delimited framing | +-- size int32 = 79 [0x0000, 4B] number of bytes that follow, patched after encoding +-- RequestHeader v2 [0x0004, 11B] common request header | +-- request_api_key int16 = 52 (Vote) [0x0004, 2B] numeric id of the API being invoked | +-- request_api_version int16 = 2 [0x0006, 2B] version of the API being invoked | +-- correlation_id int32 = 0 [0x0008, 4B] echoed back by the broker in the response | +-- client_id nullable_string = "" (int16 len=0) [0x000c, 2B] always a non-flexible int16-prefixed string | +-- tagged_fields uvarint = 0 [0x000e, 1B] number of tagged fields in the header +-- VoteRequest struct [0x000f, 68B] message body, version 2 +-- ClusterId string = "" (compact, len+1=1) [0x000f, 1B] The cluster id. +-- VoterId int32 = 0 [0x0010, 4B] The replica id of the voter receiving the request. +-- Topics []TopicData = 1 element [0x0014, 62B] The topic data. | +-- length uvarint = 2 (compact, n+1) [0x0014, 1B] one sample element follows | +-- TopicData[0] TopicData = struct [0x0015, 61B] | +-- TopicName string = "" (compact, len+1=1) [0x0015, 1B] The topic name. | +-- Partitions []PartitionData = 1 element [0x0016, 59B] The partition data. | | +-- length uvarint = 2 (compact, n+1) [0x0016, 1B] one sample element follows | | +-- PartitionData[0] PartitionData = struct [0x0017, 58B] | | +-- PartitionIndex int32 = 0 [0x0017, 4B] The partition index. | | +-- ReplicaEpoch int32 = 0 [0x001b, 4B] The epoch of the voter sending the request | | +-- ReplicaId int32 = 0 [0x001f, 4B] The replica id of the voter sending the request | | +-- ReplicaDirectoryId uuid = 00000000-0000-0000-0000-000000000000 [0x0023, 16B] The directory id of the voter sending the request | | +-- VoterDirectoryId uuid = 00000000-0000-0000-0000-000000000000 [0x0033, 16B] The directory id of the voter receiving the request | | +-- LastOffsetEpoch int32 = 0 [0x0043, 4B] The epoch of the last record written to the metadata log. | | +-- LastOffset int64 = 0 [0x0047, 8B] The log end offset of the metadata log of the voter sending the request. | | +-- PreVote bool = false [0x004f, 1B] Whether the request is a PreVote request (not persisted) or not. | | +-- tagged_fields uvarint = 0 [0x0050, 1B] number of tagged fields in this struct | +-- tagged_fields uvarint = 0 [0x0051, 1B] number of tagged fields in this struct +-- tagged_fields uvarint = 0 [0x0052, 1B] number of tagged fields in this struct
kafka message schema (.json)
{ "apiKey": 52, "type": "request", "listeners": ["controller"], "name": "VoteRequest", // Version 1 adds voter key and directory id (KIP-853) // Version 2 adds PreVote field and renames candidate to replica "validVersions": "0-2", "flexibleVersions": "0+", "fields": [ { "name": "ClusterId", "type": "string", "versions": "0+", "nullableVersions": "0+", "default": "null", "about": "The cluster id."}, { "name": "VoterId", "type": "int32", "versions": "1+", "ignorable": true, "default": "-1", "entityType": "brokerId", "about": "The replica id of the voter receiving the request." }, { "name": "Topics", "type": "[]TopicData", "versions": "0+", "about": "The topic data.", "fields": [ { "name": "TopicName", "type": "string", "versions": "0+", "entityType": "topicName", "about": "The topic name." }, { "name": "Partitions", "type": "[]PartitionData", "versions": "0+", "about": "The partition data.", "fields": [ { "name": "PartitionIndex", "type": "int32", "versions": "0+", "about": "The partition index." }, { "name": "ReplicaEpoch", "type": "int32", "versions": "0+", "about": "The epoch of the voter sending the request"}, { "name": "ReplicaId", "type": "int32", "versions": "0+", "entityType": "brokerId", "about": "The replica id of the voter sending the request"}, { "name": "ReplicaDirectoryId", "type": "uuid", "versions": "1+", "ignorable": true, "about": "The directory id of the voter sending the request" }, { "name": "VoterDirectoryId", "type": "uuid", "versions": "1+", "ignorable": true, "about": "The directory id of the voter receiving the request"}, { "name": "LastOffsetEpoch", "type": "int32", "versions": "0+", "about": "The epoch of the last record written to the metadata log."}, { "name": "LastOffset", "type": "int64", "versions": "0+", "about": "The log end offset of the metadata log of the voter sending the request."}, { "name": "PreVote", "type": "bool", "versions": "2+", "about": "Whether the request is a PreVote request (not persisted) or not."} ] } ] } ] }
Response
VoteResponse v2, response header v1, 32 bytes on the wire
byte layout (32 bytes, 16 bytes per row)
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
0000
0010
object tree
VoteResponse message v2 [0x0000, 32B] +-- Frame [0x0000, 4B] length-delimited framing | +-- size int32 = 28 [0x0000, 4B] number of bytes that follow, patched after encoding +-- ResponseHeader v1 [0x0004, 5B] common response header | +-- correlation_id int32 = 0 [0x0004, 4B] matches the correlation_id of the request | +-- tagged_fields uvarint = 0 [0x0008, 1B] number of tagged fields in the header +-- VoteResponse struct [0x0009, 23B] message body, version 2 +-- ErrorCode int16 = 0 [0x0009, 2B] The top level error code. +-- Topics []TopicData = 1 element [0x000b, 20B] The results for each topic. | +-- length uvarint = 2 (compact, n+1) [0x000b, 1B] one sample element follows | +-- TopicData[0] TopicData = struct [0x000c, 19B] | +-- TopicName string = "" (compact, len+1=1) [0x000c, 1B] The topic name. | +-- Partitions []PartitionData = 1 element [0x000d, 17B] The results for each partition. | | +-- length uvarint = 2 (compact, n+1) [0x000d, 1B] one sample element follows | | +-- PartitionData[0] PartitionData = struct [0x000e, 16B] | | +-- PartitionIndex int32 = 0 [0x000e, 4B] The partition index. | | +-- ErrorCode int16 = 0 [0x0012, 2B] The partition level error code. | | +-- LeaderId int32 = 0 [0x0014, 4B] The ID of the current leader or -1 if the leader is unknown. | | +-- LeaderEpoch int32 = 0 [0x0018, 4B] The latest known leader epoch. | | +-- VoteGranted bool = false [0x001c, 1B] True if the vote was granted and false otherwise. | | +-- tagged_fields uvarint = 0 [0x001d, 1B] number of tagged fields in this struct | +-- tagged_fields uvarint = 0 [0x001e, 1B] number of tagged fields in this struct +-- tagged_fields uvarint = 0 [0x001f, 1B] number of tagged fields in this struct
kafka message schema (.json)
{ "apiKey": 52, "type": "response", "name": "VoteResponse", // Version 1 adds leader endpoint (KIP-853) // Version 2 handles PreVote requests "validVersions": "0-2", "flexibleVersions": "0+", "fields": [ { "name": "ErrorCode", "type": "int16", "versions": "0+", "about": "The top level error code."}, { "name": "Topics", "type": "[]TopicData", "versions": "0+", "about": "The results for each topic.", "fields": [ { "name": "TopicName", "type": "string", "versions": "0+", "entityType": "topicName", "about": "The topic name." }, { "name": "Partitions", "type": "[]PartitionData", "versions": "0+", "about": "The results for each partition.", "fields": [ { "name": "PartitionIndex", "type": "int32", "versions": "0+", "about": "The partition index." }, { "name": "ErrorCode", "type": "int16", "versions": "0+", "about": "The partition level error code."}, { "name": "LeaderId", "type": "int32", "versions": "0+", "entityType": "brokerId", "about": "The ID of the current leader or -1 if the leader is unknown."}, { "name": "LeaderEpoch", "type": "int32", "versions": "0+", "about": "The latest known leader epoch."}, { "name": "VoteGranted", "type": "bool", "versions": "0+", "about": "True if the vote was granted and false otherwise."} ] } ] }, { "name": "NodeEndpoints", "type": "[]NodeEndpoint", "versions": "1+", "taggedVersions": "1+", "tag": 0, "about": "Endpoints for all current-leaders enumerated in PartitionData.", "fields": [ { "name": "NodeId", "type": "int32", "versions": "1+", "mapKey": true, "entityType": "brokerId", "about": "The ID of the associated node."}, { "name": "Host", "type": "string", "versions": "1+", "about": "The node's hostname." }, { "name": "Port", "type": "uint16", "versions": "1+", "about": "The node's port." } ] } ] }