blob: c0bf04e04e278a44ce7cf25300fea355676639c4 [file] [log] [blame]
khenaidood948f772021-08-11 17:49:24 -04001package sarama
2
3// DescribeLogDirsRequest is a describe request to get partitions' log size
4type DescribeLogDirsRequest struct {
5 // Version 0 and 1 are equal
6 // The version number is bumped to indicate that on quota violation brokers send out responses before throttling.
7 Version int16
8
9 // If this is an empty array, all topics will be queried
10 DescribeTopics []DescribeLogDirsRequestTopic
11}
12
13// DescribeLogDirsRequestTopic is a describe request about the log dir of one or more partitions within a Topic
14type DescribeLogDirsRequestTopic struct {
15 Topic string
16 PartitionIDs []int32
17}
18
19func (r *DescribeLogDirsRequest) encode(pe packetEncoder) error {
20 length := len(r.DescribeTopics)
21 if length == 0 {
22 // In order to query all topics we must send null
23 length = -1
24 }
25
26 if err := pe.putArrayLength(length); err != nil {
27 return err
28 }
29
30 for _, d := range r.DescribeTopics {
31 if err := pe.putString(d.Topic); err != nil {
32 return err
33 }
34
35 if err := pe.putInt32Array(d.PartitionIDs); err != nil {
36 return err
37 }
38 }
39
40 return nil
41}
42
43func (r *DescribeLogDirsRequest) decode(pd packetDecoder, version int16) error {
44 n, err := pd.getArrayLength()
45 if err != nil {
46 return err
47 }
48 if n == -1 {
49 n = 0
50 }
51
52 topics := make([]DescribeLogDirsRequestTopic, n)
53 for i := 0; i < n; i++ {
54 topics[i] = DescribeLogDirsRequestTopic{}
55
56 topic, err := pd.getString()
57 if err != nil {
58 return err
59 }
60 topics[i].Topic = topic
61
62 pIDs, err := pd.getInt32Array()
63 if err != nil {
64 return err
65 }
66 topics[i].PartitionIDs = pIDs
67 }
68 r.DescribeTopics = topics
69
70 return nil
71}
72
73func (r *DescribeLogDirsRequest) key() int16 {
74 return 35
75}
76
77func (r *DescribeLogDirsRequest) version() int16 {
78 return r.Version
79}
80
81func (r *DescribeLogDirsRequest) headerVersion() int16 {
82 return 1
83}
84
85func (r *DescribeLogDirsRequest) requiredVersion() KafkaVersion {
86 return V1_0_0_0
87}