ElectLeaders
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
- 43
- Encoded at
- v2
- Flexible versions
- 2+
- Headers
- req v2, resp v1
- Request versions
- 0-2
- Response versions
- 0-2
- Request size
- 29 bytes
- Response size
- 28 bytes
framerpc headerrequest bodyRecordBatchRecordresponse bodytagged_fields
Request
ElectLeadersRequest v2, request header v2, 29 bytes on the wire
byte layout (29 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
ElectLeadersRequest message v2 [0x0000, 29B] +-- Frame [0x0000, 4B] length-delimited framing | +-- size int32 = 25 [0x0000, 4B] number of bytes that follow, patched after encoding +-- RequestHeader v2 [0x0004, 11B] common request header | +-- request_api_key int16 = 43 (ElectLeaders) [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 +-- ElectLeadersRequest struct [0x000f, 14B] message body, version 2 +-- ElectionType int8 = 0 [0x000f, 1B] Type of elections to conduct for the partition. A value of '0' elects the p... +-- TopicPartitions []TopicPartitions = 1 element [0x0010, 8B] The topic partitions to elect leaders. | +-- length uvarint = 2 (compact, n+1) [0x0010, 1B] one sample element follows | +-- TopicPartitions[0] TopicPartitions = struct [0x0011, 7B] | +-- Topic string = "" (compact, len+1=1) [0x0011, 1B] The name of a topic. | +-- Partitions []int32 = 1 element [0x0012, 5B] The partitions of this topic whose leader should be elected. | | +-- length uvarint = 2 (compact, n+1) [0x0012, 1B] one sample element follows | | +-- int32[0] int32 = 0 [0x0013, 4B] | +-- tagged_fields uvarint = 0 [0x0017, 1B] number of tagged fields in this struct +-- TimeoutMs int32 = 0 [0x0018, 4B] The time in ms to wait for the election to complete. +-- tagged_fields uvarint = 0 [0x001c, 1B] number of tagged fields in this struct
kafka message schema (.json)
{ "apiKey": 43, "type": "request", "listeners": ["broker", "controller"], "name": "ElectLeadersRequest", // Version 1 implements multiple leader election types, as described by KIP-460. // // Version 2 is the first flexible version. "validVersions": "0-2", "flexibleVersions": "2+", "fields": [ { "name": "ElectionType", "type": "int8", "versions": "1+", "about": "Type of elections to conduct for the partition. A value of '0' elects the preferred replica. A value of '1' elects the first live replica if there are no in-sync replica." }, { "name": "TopicPartitions", "type": "[]TopicPartitions", "versions": "0+", "nullableVersions": "0+", "about": "The topic partitions to elect leaders.", "fields": [ { "name": "Topic", "type": "string", "versions": "0+", "entityType": "topicName", "mapKey": true, "about": "The name of a topic." }, { "name": "Partitions", "type": "[]int32", "versions": "0+", "about": "The partitions of this topic whose leader should be elected." } ] }, { "name": "TimeoutMs", "type": "int32", "versions": "0+", "default": "60000", "about": "The time in ms to wait for the election to complete." } ] }
Response
ElectLeadersResponse v2, response header v1, 28 bytes on the wire
byte layout (28 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
ElectLeadersResponse message v2 [0x0000, 28B] +-- Frame [0x0000, 4B] length-delimited framing | +-- size int32 = 24 [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 +-- ElectLeadersResponse struct [0x0009, 19B] message body, version 2 +-- ThrottleTimeMs int32 = 0 [0x0009, 4B] The duration in milliseconds for which the request was throttled due to a q... +-- ErrorCode int16 = 0 [0x000d, 2B] The top level response error code. +-- ReplicaElectionResults []ReplicaElectionResult = 1 element [0x000f, 12B] The election results, or an empty array if the requester did not have permi... | +-- length uvarint = 2 (compact, n+1) [0x000f, 1B] one sample element follows | +-- ReplicaElectionResult[0] ReplicaElectionResult = struct [0x0010, 11B] | +-- Topic string = "" (compact, len+1=1) [0x0010, 1B] The topic name. | +-- PartitionResult []PartitionResult = 1 element [0x0011, 9B] The results for each partition. | | +-- length uvarint = 2 (compact, n+1) [0x0011, 1B] one sample element follows | | +-- PartitionResult[0] PartitionResult = struct [0x0012, 8B] | | +-- PartitionId int32 = 0 [0x0012, 4B] The partition id. | | +-- ErrorCode int16 = 0 [0x0016, 2B] The result error, or zero if there was no error. | | +-- ErrorMessage string = "" (compact, len+1=1) [0x0018, 1B] The result message, or null if there was no error. | | +-- tagged_fields uvarint = 0 [0x0019, 1B] number of tagged fields in this struct | +-- tagged_fields uvarint = 0 [0x001a, 1B] number of tagged fields in this struct +-- tagged_fields uvarint = 0 [0x001b, 1B] number of tagged fields in this struct
kafka message schema (.json)
{ "apiKey": 43, "type": "response", "name": "ElectLeadersResponse", // Version 1 adds a top-level error code. // // Version 2 is the first flexible version. "validVersions": "0-2", "flexibleVersions": "2+", "fields": [ { "name": "ThrottleTimeMs", "type": "int32", "versions": "0+", "about": "The duration in milliseconds for which the request was throttled due to a quota violation, or zero if the request did not violate any quota." }, { "name": "ErrorCode", "type": "int16", "versions": "1+", "ignorable": false, "about": "The top level response error code." }, { "name": "ReplicaElectionResults", "type": "[]ReplicaElectionResult", "versions": "0+", "about": "The election results, or an empty array if the requester did not have permission and the request asks for all partitions.", "fields": [ { "name": "Topic", "type": "string", "versions": "0+", "entityType": "topicName", "about": "The topic name." }, { "name": "PartitionResult", "type": "[]PartitionResult", "versions": "0+", "about": "The results for each partition.", "fields": [ { "name": "PartitionId", "type": "int32", "versions": "0+", "about": "The partition id." }, { "name": "ErrorCode", "type": "int16", "versions": "0+", "about": "The result error, or zero if there was no error."}, { "name": "ErrorMessage", "type": "string", "versions": "0+", "nullableVersions": "0+", "about": "The result message, or null if there was no error."} ]} ]} ] }