|
17 | 17 | package org.apache.kafka.common.requests;
|
18 | 18 |
|
19 | 19 | import org.apache.kafka.common.TopicPartition;
|
| 20 | +import org.apache.kafka.common.Uuid; |
20 | 21 | import org.apache.kafka.common.errors.UnsupportedVersionException;
|
21 | 22 | import org.apache.kafka.common.message.OffsetFetchRequestData;
|
22 | 23 | import org.apache.kafka.common.message.OffsetFetchRequestData.OffsetFetchRequestGroup;
|
@@ -71,7 +72,8 @@ public Builder(String groupId,
|
71 | 72 | boolean requireStable,
|
72 | 73 | List<TopicPartition> partitions,
|
73 | 74 | boolean throwOnFetchStableOffsetsUnsupported) {
|
74 |
| - super(ApiKeys.OFFSET_FETCH); |
| 75 | + // It can only be used with topic names. |
| 76 | + super(ApiKeys.OFFSET_FETCH, ApiKeys.OFFSET_FETCH.oldestVersion(), (short) 9); |
75 | 77 |
|
76 | 78 | OffsetFetchRequestData.OffsetFetchRequestGroup group =
|
77 | 79 | new OffsetFetchRequestData.OffsetFetchRequestGroup()
|
@@ -103,7 +105,8 @@ public Builder(String groupId,
|
103 | 105 | public Builder(Map<String, List<TopicPartition>> groupIdToTopicPartitionMap,
|
104 | 106 | boolean requireStable,
|
105 | 107 | boolean throwOnFetchStableOffsetsUnsupported) {
|
106 |
| - super(ApiKeys.OFFSET_FETCH); |
| 108 | + // It can only be used with topic names. |
| 109 | + super(ApiKeys.OFFSET_FETCH, ApiKeys.OFFSET_FETCH.oldestVersion(), (short) 9); |
107 | 110 |
|
108 | 111 | List<OffsetFetchRequestGroup> groups = new ArrayList<>();
|
109 | 112 | for (Entry<String, List<TopicPartition>> entry : groupIdToTopicPartitionMap.entrySet()) {
|
@@ -134,6 +137,12 @@ public Builder(Map<String, List<TopicPartition>> groupIdToTopicPartitionMap,
|
134 | 137 | this.throwOnFetchStableOffsetsUnsupported = throwOnFetchStableOffsetsUnsupported;
|
135 | 138 | }
|
136 | 139 |
|
| 140 | + public Builder(OffsetFetchRequestData data, boolean throwOnFetchStableOffsetsUnsupported) { |
| 141 | + super(ApiKeys.OFFSET_FETCH); |
| 142 | + this.data = data; |
| 143 | + this.throwOnFetchStableOffsetsUnsupported = throwOnFetchStableOffsetsUnsupported; |
| 144 | + } |
| 145 | + |
137 | 146 | @Override
|
138 | 147 | public OffsetFetchRequest build(short version) {
|
139 | 148 | if (data.groups().size() > 1 && version < 8) {
|
|
0 commit comments