@@ -40,7 +40,7 @@ import org.apache.kafka.common.metrics.stats.{Avg, CumulativeSum, Meter, Rate}
40
40
import org .apache .kafka .common .network .KafkaChannel .ChannelMuteEvent
41
41
import org .apache .kafka .common .network .{ChannelBuilder , ChannelBuilders , ClientInformation , KafkaChannel , ListenerName , ListenerReconfigurable , NetworkSend , Selectable , Send , ServerConnectionId , Selector => KSelector }
42
42
import org .apache .kafka .common .protocol .ApiKeys
43
- import org .apache .kafka .common .requests .{ApiVersionsRequest , RequestContext , RequestHeader }
43
+ import org .apache .kafka .common .requests .{ApiVersionsRequest , RequestAndSize , RequestContext , RequestHeader }
44
44
import org .apache .kafka .common .security .auth .SecurityProtocol
45
45
import org .apache .kafka .common .utils .{KafkaThread , LogContext , Time , Utils }
46
46
import org .apache .kafka .common .{Endpoint , KafkaException , MetricName , Reconfigurable }
@@ -1133,23 +1133,27 @@ private[kafka] class Processor(
1133
1133
expiredConnectionsKilledCount.record(null , 1 , 0 )
1134
1134
} else {
1135
1135
val connectionId = receive.source
1136
- val context = new RequestContext (header, connectionId, channel.socketAddress, Optional .of(channel.socketPort()),
1137
- channel.principal, listenerName, securityProtocol, channel.channelMetadataRegistry.clientInformation,
1138
- isPrivilegedListener, channel.principalSerde)
1139
-
1140
- val req = new RequestChannel .Request (processor = id, context = context,
1141
- startTimeNanos = nowNanos, memoryPool, receive.payload, requestChannel.metrics, None )
1142
-
1136
+ var requestAndSize : Option [RequestAndSize ] = None
1143
1137
// KIP-511: ApiVersionsRequest is intercepted here to catch the client software name
1144
1138
// and version. It is done here to avoid wiring things up to the api layer.
1145
1139
if (header.apiKey == ApiKeys .API_VERSIONS ) {
1146
- val apiVersionsRequest = req.body[ApiVersionsRequest ]
1140
+ val result = RequestContext .staticParseRequest(header, receive.payload, connectionId, listenerName, channel.principal)
1141
+ val apiVersionsRequest = result.request.asInstanceOf [ApiVersionsRequest ]
1147
1142
if (apiVersionsRequest.isValid) {
1148
1143
channel.channelMetadataRegistry.registerClientInformation(new ClientInformation (
1149
1144
apiVersionsRequest.data.clientSoftwareName,
1150
1145
apiVersionsRequest.data.clientSoftwareVersion))
1151
1146
}
1147
+ requestAndSize = Some (result)
1152
1148
}
1149
+
1150
+ val context = new RequestContext (header, connectionId, channel.socketAddress, Optional .of(channel.socketPort()),
1151
+ channel.principal, listenerName, securityProtocol, channel.channelMetadataRegistry.clientInformation,
1152
+ isPrivilegedListener, channel.principalSerde)
1153
+
1154
+ val req = new RequestChannel .Request (processor = id, context = context,
1155
+ startTimeNanos = nowNanos, memoryPool, receive.payload, requestChannel.metrics, None , requestAndSize)
1156
+
1153
1157
requestChannel.sendRequest(req)
1154
1158
selector.mute(connectionId)
1155
1159
handleChannelMuteEvent(connectionId, ChannelMuteEvent .REQUEST_RECEIVED )
0 commit comments