dajac commented on a change in pull request #10269:
URL: https://github.com/apache/kafka/pull/10269#discussion_r588094059
##########
File path: core/src/main/scala/kafka/server/KafkaApis.scala
##########
@@ -811,31 +821,40 @@ class KafkaApis(val requestChannel: RequestChannel,
.setRecords(data.records)
.setPreferredReadReplica(data.preferredReadReplica.getOrElse(FetchResponse.INVALID_PREFERRED_REPLICA_ID))
data.divergingEpoch.foreach(partitionData.setDivergingEpoch)
- partitions.put(tp, partitionData)
+ addPartition(tp.topic, partitionData)
}
- erroneous.foreach { case (tp, data) => partitions.put(tp, data) }
-
- var unconvertedFetchResponse: FetchResponse = null
+ erroneous.foreach { case (tp, data) => addPartition(tp.topic, data) }
- def createResponse(throttleTimeMs: Int): FetchResponse = {
+ def createResponse(unconvertedFetchResponse: FetchResponse,
throttleTimeMs: Int): FetchResponse = {
// Down-convert messages for each partition if required
- val convertedData = new util.LinkedHashMap[TopicPartition,
FetchResponseData.PartitionData]
- unconvertedFetchResponse.responseData.forEach { (tp,
unconvertedPartitionData) =>
- val error = Errors.forCode(unconvertedPartitionData.errorCode)
- if (error != Errors.NONE)
- debug(s"Fetch request with correlation id
${request.header.correlationId} from client $clientId " +
- s"on partition $tp failed due to ${error.exceptionName}")
- convertedData.put(tp, maybeConvertFetchedData(tp,
unconvertedPartitionData))
+ val convertedResponse = new FetchResponseData()
+ .setErrorCode(unconvertedFetchResponse.error.code)
+ .setThrottleTimeMs(throttleTimeMs)
+ .setSessionId(unconvertedFetchResponse.sessionId)
+ .setResponses(new
util.ArrayList[FetchResponseData.FetchableTopicResponse](unconvertedFetchResponse.data.responses.size))
+ unconvertedFetchResponse.data.responses.forEach { unconvertedTopicData
=>
+ val convertedTopicResponse = new
FetchResponseData.FetchableTopicResponse()
+ .setTopic(unconvertedTopicData.topic)
+ .setPartitions(new
util.ArrayList[FetchResponseData.PartitionData](unconvertedTopicData.partitions.size))
+ convertedResponse.responses.add(convertedTopicResponse)
+ unconvertedTopicData.partitions.forEach { unconvertedPartitionData =>
+ val tp = new TopicPartition(unconvertedTopicData.topic,
unconvertedPartitionData.partitionIndex)
+ val error = Errors.forCode(unconvertedPartitionData.errorCode)
+ if (error != Errors.NONE)
Review comment:
Right. I was thinking that we could convert it to Errors only if we need
it.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]