31
31
import org .apache .kafka .common .protocol .ApiKeys ;
32
32
import org .apache .kafka .common .protocol .ByteBufferAccessor ;
33
33
import org .apache .kafka .common .protocol .Errors ;
34
- import org .apache .kafka .common .record .RecordVersion ;
35
34
36
35
import java .nio .ByteBuffer ;
37
36
import java .util .Map ;
@@ -172,35 +171,30 @@ public static ApiVersionsResponse parse(ByteBuffer buffer, short version) {
172
171
}
173
172
174
173
public static ApiVersionCollection controllerApiVersions (
175
- RecordVersion minRecordVersion ,
176
174
NodeApiVersions controllerApiVersions ,
177
175
ListenerType listenerType ,
178
176
boolean enableUnstableLastVersion ,
179
177
boolean clientTelemetryEnabled
180
178
) {
181
179
return intersectForwardableApis (
182
180
listenerType ,
183
- minRecordVersion ,
184
181
controllerApiVersions .allSupportedApiVersions (),
185
182
enableUnstableLastVersion ,
186
183
clientTelemetryEnabled );
187
184
}
188
185
189
186
public static ApiVersionCollection brokerApiVersions (
190
- RecordVersion minRecordVersion ,
191
187
ListenerType listenerType ,
192
188
boolean enableUnstableLastVersion ,
193
189
boolean clientTelemetryEnabled
194
190
) {
195
191
return filterApis (
196
- minRecordVersion ,
197
192
listenerType ,
198
193
enableUnstableLastVersion ,
199
194
clientTelemetryEnabled );
200
195
}
201
196
202
197
public static ApiVersionCollection filterApis (
203
- RecordVersion minRecordVersion ,
204
198
ApiMessageType .ListenerType listenerType ,
205
199
boolean enableUnstableLastVersion ,
206
200
boolean clientTelemetryEnabled
@@ -210,10 +204,7 @@ public static ApiVersionCollection filterApis(
210
204
// Skip telemetry APIs if client telemetry is disabled.
211
205
if ((apiKey == ApiKeys .GET_TELEMETRY_SUBSCRIPTIONS || apiKey == ApiKeys .PUSH_TELEMETRY ) && !clientTelemetryEnabled )
212
206
continue ;
213
-
214
- if (apiKey .minRequiredInterBrokerMagic <= minRecordVersion .value ) {
215
- apiKey .toApiVersion (enableUnstableLastVersion ).ifPresent (apiKeys ::add );
216
- }
207
+ apiKey .toApiVersion (enableUnstableLastVersion ).ifPresent (apiKeys ::add );
217
208
}
218
209
return apiKeys ;
219
210
}
@@ -234,50 +225,46 @@ public static ApiVersionCollection collectApis(
234
225
* known range and that of another set.
235
226
*
236
227
* @param listenerType the listener type which constrains the set of exposed APIs
237
- * @param minRecordVersion min inter broker magic
238
228
* @param activeControllerApiVersions controller ApiVersions
239
229
* @param enableUnstableLastVersion whether unstable versions should be advertised or not
240
230
* @param clientTelemetryEnabled whether client telemetry is enabled or not
241
231
* @return commonly agreed ApiVersion collection
242
232
*/
243
233
public static ApiVersionCollection intersectForwardableApis (
244
234
final ApiMessageType .ListenerType listenerType ,
245
- final RecordVersion minRecordVersion ,
246
235
final Map <ApiKeys , ApiVersion > activeControllerApiVersions ,
247
236
boolean enableUnstableLastVersion ,
248
237
boolean clientTelemetryEnabled
249
238
) {
250
239
ApiVersionCollection apiKeys = new ApiVersionCollection ();
251
240
for (ApiKeys apiKey : ApiKeys .apisForListener (listenerType )) {
252
- if (apiKey .minRequiredInterBrokerMagic <= minRecordVersion .value ) {
253
- final Optional <ApiVersion > brokerApiVersion = apiKey .toApiVersion (enableUnstableLastVersion );
254
- if (brokerApiVersion .isEmpty ()) {
255
- // Broker does not support this API key.
256
- continue ;
257
- }
241
+ final Optional <ApiVersion > brokerApiVersion = apiKey .toApiVersion (enableUnstableLastVersion );
242
+ if (brokerApiVersion .isEmpty ()) {
243
+ // Broker does not support this API key.
244
+ continue ;
245
+ }
258
246
259
- // Skip telemetry APIs if client telemetry is disabled.
260
- if ((apiKey == ApiKeys .GET_TELEMETRY_SUBSCRIPTIONS || apiKey == ApiKeys .PUSH_TELEMETRY ) && !clientTelemetryEnabled )
261
- continue ;
247
+ // Skip telemetry APIs if client telemetry is disabled.
248
+ if ((apiKey == ApiKeys .GET_TELEMETRY_SUBSCRIPTIONS || apiKey == ApiKeys .PUSH_TELEMETRY ) && !clientTelemetryEnabled )
249
+ continue ;
262
250
263
- final ApiVersion finalApiVersion ;
264
- if (!apiKey .forwardable ) {
265
- finalApiVersion = brokerApiVersion .get ();
251
+ final ApiVersion finalApiVersion ;
252
+ if (!apiKey .forwardable ) {
253
+ finalApiVersion = brokerApiVersion .get ();
254
+ } else {
255
+ Optional <ApiVersion > intersectVersion = intersect (
256
+ brokerApiVersion .get (),
257
+ activeControllerApiVersions .getOrDefault (apiKey , null )
258
+ );
259
+ if (intersectVersion .isPresent ()) {
260
+ finalApiVersion = intersectVersion .get ();
266
261
} else {
267
- Optional <ApiVersion > intersectVersion = intersect (
268
- brokerApiVersion .get (),
269
- activeControllerApiVersions .getOrDefault (apiKey , null )
270
- );
271
- if (intersectVersion .isPresent ()) {
272
- finalApiVersion = intersectVersion .get ();
273
- } else {
274
- // Controller doesn't support this API key, or there is no intersection.
275
- continue ;
276
- }
262
+ // Controller doesn't support this API key, or there is no intersection.
263
+ continue ;
277
264
}
278
-
279
- apiKeys .add (finalApiVersion .duplicate ());
280
265
}
266
+
267
+ apiKeys .add (finalApiVersion .duplicate ());
281
268
}
282
269
return apiKeys ;
283
270
}
0 commit comments