You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: stage_descriptions/listing-partitions-02-vt6.md
+98-11Lines changed: 98 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,98 @@
1
1
In this stage, you'll implement the `DescribeTopicPartitions` response for an unknown topic.
2
2
3
+
### The `DescribeTopicPartitions` API (Recap)
4
+
5
+
As a recap, the [`DescribeTopicPartitions`](https://kafka.apache.org/protocol.html#The_Messages_DescribeTopicPartitions) API returns metadata about [topics](https://kafka.apache.org/documentation/#intro_concepts_and_terms) and their [partitions](https://kafka.apache.org/documentation/#:~:text=partitioned). For this stage, you'll handle cases where a client requests a topic that doesn't exist.
6
+
3
7
We've created an interactive protocol inspector for the `DescribeTopicPartitions` request & response:
🚧 **We're still working on instructions for this stage**. You can find notes on how the tester works below.
12
+
### Parsing the Request
13
+
14
+
To respond correctly, you'll need to parse the `DescribeTopicPartitions` request to extract the topic name. The [`DescribeTopicPartitions` request (v0)](https://kafka.apache.org/protocol.html#The_Messages_DescribeTopicPartitions) contains:
For this stage, the tester will send a request with a single topic name. You'll need to extract this name and echo it back in your response.
29
+
30
+
### Response Header v1
31
+
32
+
In previous stages, you used response header v0, which only contained the `correlation_id` field. For this stage, you'll use [response header v1](https://kafka.apache.org/protocol.html#protocol_messages), which has the following structure:
- Set `error_code` to `3` (`UNKNOWN_TOPIC_OR_PARTITION`).
68
+
- Echo back the `topic_name` from the request.
69
+
- Set `topic_id` to `00000000-0000-0000-0000-000000000000` (all zeros).
70
+
- Set `is_internal` to `false`.
71
+
- Leave the `partitions` array empty.
72
+
- Set `next_cursor` to `-1` (null).
73
+
74
+
Here's an example of what your response might look like for a topic named `"foo"`:
75
+
76
+
```java
77
+
0000002f// message_size: 47 bytes
78
+
ab cd ef 12// correlation_id: (matches request)
79
+
00// TAG_BUFFER: empty (response header v1)
80
+
00000000// throttle_time_ms: 0
81
+
02// topics array: 1 element
82
+
0003// error_code: 3 (UNKNOWN_TOPIC_OR_PARTITION)
83
+
04// name length: 3 (compact string)
84
+
666f6f// topic_name: "foo"
85
+
00000000// topic_id: 00000000-0000-0000-
86
+
00000000// 0000-000000000000
87
+
00000000// (16 bytes total)
88
+
00000000//
89
+
00// is_internal: false
90
+
01// partitions array: 0 elements (empty)
91
+
00000000// topic_authorized_operations: 0
92
+
00// TAG_BUFFER: empty
93
+
ff // next_cursor: -1 (null)
94
+
00// TAG_BUFFER: empty
95
+
```
13
96
14
97
### Tests
15
98
@@ -19,21 +102,25 @@ The tester will execute your program like this:
19
102
$ ./your_program.sh /tmp/server.properties
20
103
```
21
104
22
-
It'll then connect to your server on port 9092 and send a `DescribeTopicPartitions` (v0) request. The request will contain a single topic with 1 partition.
105
+
It will then connect to your server on port `9092` and send a `DescribeTopicPartitions` (v0) request containing a single topic name.
- The first 4 bytes of your response (the "message length") are valid.
113
+
- The `message_size` field correctly represents the size of the header and body.
27
114
- The correlation ID in the response header matches the correlation ID in the request header.
28
-
- The error code in the response body is 3 (`UNKNOWN_TOPIC_OR_PARTITION`).
29
-
- The response body should be valid DescribeTopicPartitions (v0) Response.
115
+
- The response uses response header v1 (with `TAG_BUFFER`).
116
+
- The `error_code` in the response body is `3` (`UNKNOWN_TOPIC_OR_PARTITION`).
117
+
- The response body should be a valid DescribeTopicPartitions (v0) Response.
30
118
- The `topic_name` field in the response should be equal to the topic name sent in the request.
31
119
- The `topic_id` field in the response should be equal to `00000000-0000-0000-0000-000000000000`.
32
-
- The `partitions` field in the response should be empty. (As there are no partitions assigned to this non-existent topic.)
33
-
- The value of `cursor` is -1, indicating that the cursor is null.
120
+
- The `partitions` field in the response should be empty.
121
+
- The value of `next_cursor` is `-1`, indicating that the cursor is null.
34
122
35
123
### Notes
36
124
37
125
- You'll need to parse the `DescribeTopicPartitions` request in this stage to get the topic name to send in the response.
38
126
- For now, you can assume that all topics are "unknown". We'll work on identifying actual vs. unknown topics in later stages.
39
-
- The official docs for the `DescribeTopicPartitions` request can be found [here](https://kafka.apache.org/protocol.html#The_Messages_DescribeTopicPartitions).
0 commit comments