FetchSnapshot
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 1 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
- 59
- Encoded at
- v1
- Flexible versions
- 0+
- Headers
- req v2, resp v1
- Request versions
- 0-1
- Response versions
- 0-1
- Request size
- 58 bytes
- Response size
- 118 bytes
framerpc headerrequest bodyRecordBatchRecordresponse bodytagged_fields
Request
FetchSnapshotRequest v1, request header v2, 58 bytes on the wire
byte layout (58 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
object tree
FetchSnapshotRequest message v1 [0x0000, 58B] +-- Frame [0x0000, 4B] length-delimited framing | +-- size int32 = 54 [0x0000, 4B] number of bytes that follow, patched after encoding +-- RequestHeader v2 [0x0004, 11B] common request header | +-- request_api_key int16 = 59 (FetchSnapshot) [0x0004, 2B] numeric id of the API being invoked | +-- request_api_version int16 = 1 [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 +-- FetchSnapshotRequest struct [0x000f, 43B] message body, version 1 +-- ReplicaId int32 = 0 [0x000f, 4B] The broker ID of the follower. +-- MaxBytes int32 = 0 [0x0013, 4B] The maximum bytes to fetch from all of the snapshots. +-- Topics []TopicSnapshot = 1 element [0x0017, 34B] The topics to fetch. | +-- length uvarint = 2 (compact, n+1) [0x0017, 1B] one sample element follows | +-- TopicSnapshot[0] TopicSnapshot = struct [0x0018, 33B] | +-- Name string = "" (compact, len+1=1) [0x0018, 1B] The name of the topic to fetch. | +-- Partitions []PartitionSnapshot = 1 element [0x0019, 31B] The partitions to fetch. | | +-- length uvarint = 2 (compact, n+1) [0x0019, 1B] one sample element follows | | +-- PartitionSnapshot[0] PartitionSnapshot = struct [0x001a, 30B] | | +-- Partition int32 = 0 [0x001a, 4B] The partition index. | | +-- CurrentLeaderEpoch int32 = 0 [0x001e, 4B] The current leader epoch of the partition, -1 for unknown leader epoch. | | +-- SnapshotId SnapshotId = struct [0x0022, 13B] The snapshot endOffset and epoch to fetch. | | | +-- EndOffset int64 = 0 [0x0022, 8B] The end offset of the snapshot. | | | +-- Epoch int32 = 0 [0x002a, 4B] The epoch of the snapshot. | | | +-- tagged_fields uvarint = 0 [0x002e, 1B] number of tagged fields in this struct | | +-- Position int64 = 0 [0x002f, 8B] The byte position within the snapshot to start fetching from. | | +-- tagged_fields uvarint = 0 [0x0037, 1B] number of tagged fields in this struct | +-- tagged_fields uvarint = 0 [0x0038, 1B] number of tagged fields in this struct +-- tagged_fields uvarint = 0 [0x0039, 1B] number of tagged fields in this struct
kafka message schema (.json)
{ "apiKey": 59, "type": "request", "listeners": ["controller"], "name": "FetchSnapshotRequest", // Version 1 adds replica directory id (KIP-853) "validVersions": "0-1", "flexibleVersions": "0+", "fields": [ { "name": "ClusterId", "type": "string", "versions": "0+", "nullableVersions": "0+", "default": "null", "taggedVersions": "0+", "tag": 0, "about": "The clusterId if known, this is used to validate metadata fetches prior to broker registration." }, { "name": "ReplicaId", "type": "int32", "versions": "0+", "default": "-1", "entityType": "brokerId", "about": "The broker ID of the follower." }, { "name": "MaxBytes", "type": "int32", "versions": "0+", "default": "0x7fffffff", "about": "The maximum bytes to fetch from all of the snapshots." }, { "name": "Topics", "type": "[]TopicSnapshot", "versions": "0+", "about": "The topics to fetch.", "fields": [ { "name": "Name", "type": "string", "versions": "0+", "entityType": "topicName", "about": "The name of the topic to fetch." }, { "name": "Partitions", "type": "[]PartitionSnapshot", "versions": "0+", "about": "The partitions to fetch.", "fields": [ { "name": "Partition", "type": "int32", "versions": "0+", "about": "The partition index." }, { "name": "CurrentLeaderEpoch", "type": "int32", "versions": "0+", "about": "The current leader epoch of the partition, -1 for unknown leader epoch." }, { "name": "SnapshotId", "type": "SnapshotId", "versions": "0+", "about": "The snapshot endOffset and epoch to fetch.", "fields": [ { "name": "EndOffset", "type": "int64", "versions": "0+", "about": "The end offset of the snapshot."}, { "name": "Epoch", "type": "int32", "versions": "0+", "about": "The epoch of the snapshot."} ] }, { "name": "Position", "type": "int64", "versions": "0+", "about": "The byte position within the snapshot to start fetching from." }, { "name": "ReplicaDirectoryId", "type": "uuid", "versions": "1+", "taggedVersions": "1+", "tag": 0, "ignorable": true, "about": "The directory id of the follower fetching." } ] } ] } ] }
Response
FetchSnapshotResponse v1, response header v1, 118 bytes on the wire
byte layout (118 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
0060
0070
object tree
FetchSnapshotResponse message v1 [0x0000, 118B] +-- Frame [0x0000, 4B] length-delimited framing | +-- size int32 = 114 [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 +-- FetchSnapshotResponse struct [0x0009, 109B] message body, version 1 +-- 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. +-- Topics []TopicSnapshot = 1 element [0x000f, 102B] The topics to fetch. | +-- length uvarint = 2 (compact, n+1) [0x000f, 1B] one sample element follows | +-- TopicSnapshot[0] TopicSnapshot = struct [0x0010, 101B] | +-- Name string = "" (compact, len+1=1) [0x0010, 1B] The name of the topic to fetch. | +-- Partitions []PartitionSnapshot = 1 element [0x0011, 99B] The partitions to fetch. | | +-- length uvarint = 2 (compact, n+1) [0x0011, 1B] one sample element follows | | +-- PartitionSnapshot[0] PartitionSnapshot = struct [0x0012, 98B] | | +-- Index int32 = 0 [0x0012, 4B] The partition index. | | +-- ErrorCode int16 = 0 [0x0016, 2B] The error code, or 0 if there was no fetch error. | | +-- SnapshotId SnapshotId = struct [0x0018, 13B] The snapshot endOffset and epoch fetched. | | | +-- EndOffset int64 = 0 [0x0018, 8B] The snapshot end offset. | | | +-- Epoch int32 = 0 [0x0020, 4B] The snapshot epoch. | | | +-- tagged_fields uvarint = 0 [0x0024, 1B] number of tagged fields in this struct | | +-- Size int64 = 0 [0x0025, 8B] The total size of the snapshot. | | +-- Position int64 = 0 [0x002d, 8B] The starting byte position within the snapshot included in the Bytes field. | | +-- UnalignedRecords records = 1 RecordBatch [0x0035, 62B] Snapshot data in records format which may not be aligned on an offset bound... | | | +-- length uvarint = 62 (compact, n+1) [0x0035, 1B] size of the record set in bytes | | | +-- RecordBatch v2 = empty [0x0036, 61B] fixed 61-byte RecordBatch v2 header, zero records | | | +-- baseOffset int64 = 0 [0x0036, 8B] offset of the first record in the batch | | | +-- batchLength int32 = 49 [0x003e, 4B] bytes after this field to the end of the batch | | | +-- partitionLeaderEpoch int32 = -1 [0x0042, 4B] leader epoch, -1 when produced by a client | | | +-- magic int8 = 2 [0x0046, 1B] record format version, 2 | | | +-- crc uint32 = crc32c of the bytes that follow [0x0047, 4B] CRC-32C over attributes .. end of batch | | | +-- attributes int16 = 0 [0x004b, 2B] compression, timestamp type, txn and control flags | | | +-- lastOffsetDelta int32 = -1 [0x004d, 4B] offset delta of the last record, -1 when empty | | | +-- baseTimestamp int64 = -1 [0x0051, 8B] timestamp of the first record | | | +-- maxTimestamp int64 = -1 [0x0059, 8B] largest timestamp in the batch | | | +-- producerId int64 = -1 [0x0061, 8B] producer id, -1 when non-idempotent | | | +-- producerEpoch int16 = -1 [0x0069, 2B] producer epoch, -1 when non-idempotent | | | +-- baseSequence int32 = -1 [0x006b, 4B] sequence of the first record, -1 when non-idempotent | | | +-- recordsCount int32 = 0 [0x006f, 4B] number of records that follow, 0 here | | +-- tagged_fields uvarint = 0 [0x0073, 1B] number of tagged fields in this struct | +-- tagged_fields uvarint = 0 [0x0074, 1B] number of tagged fields in this struct +-- tagged_fields uvarint = 0 [0x0075, 1B] number of tagged fields in this struct
kafka message schema (.json)
{ "apiKey": 59, "type": "response", "name": "FetchSnapshotResponse", "validVersions": "0-1", // Version 1 adds leader endpoint (KIP-853) "flexibleVersions": "0+", "fields": [ { "name": "ThrottleTimeMs", "type": "int32", "versions": "0+", "ignorable": true, "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": "0+", "ignorable": false, "about": "The top level response error code." }, { "name": "Topics", "type": "[]TopicSnapshot", "versions": "0+", "about": "The topics to fetch.", "fields": [ { "name": "Name", "type": "string", "versions": "0+", "entityType": "topicName", "about": "The name of the topic to fetch." }, { "name": "Partitions", "type": "[]PartitionSnapshot", "versions": "0+", "about": "The partitions to fetch.", "fields": [ { "name": "Index", "type": "int32", "versions": "0+", "about": "The partition index." }, { "name": "ErrorCode", "type": "int16", "versions": "0+", "about": "The error code, or 0 if there was no fetch error." }, { "name": "SnapshotId", "type": "SnapshotId", "versions": "0+", "about": "The snapshot endOffset and epoch fetched.", "fields": [ { "name": "EndOffset", "type": "int64", "versions": "0+", "about": "The snapshot end offset."}, { "name": "Epoch", "type": "int32", "versions": "0+", "about": "The snapshot epoch."} ] }, { "name": "CurrentLeader", "type": "LeaderIdAndEpoch", "versions": "0+", "taggedVersions": "0+", "tag": 0, "about": "The leader of the partition at the time of the snapshot.", "fields": [ { "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": "Size", "type": "int64", "versions": "0+", "about": "The total size of the snapshot." }, { "name": "Position", "type": "int64", "versions": "0+", "about": "The starting byte position within the snapshot included in the Bytes field." }, { "name": "UnalignedRecords", "type": "records", "versions": "0+", "about": "Snapshot data in records format which may not be aligned on an offset boundary." } ] } ] }, { "name": "NodeEndpoints", "type": "[]NodeEndpoint", "versions": "1+", "taggedVersions": "1+", "tag": 0, "about": "Endpoints for all current-leaders enumerated in PartitionSnapshot.", "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." } ] } ] }