josefk31 commented on code in PR #19664:
URL: https://github.com/apache/kafka/pull/19664#discussion_r2127221628
##########
core/src/main/scala/kafka/server/KafkaApis.scala:
##########
@@ -265,33 +265,52 @@ class KafkaApis(val requestChannel: RequestChannel,
}
def handleGetReplicaLogInfo(request: RequestChannel.Request): Unit = {
- authHelper.authorizeClusterOperation(request, CLUSTER_ACTION)
+ var partitionCount = 0
+ def processPartitions(topicLogInfo:
GetReplicaLogInfoResponseData.TopicPartitionLogInfo,
+ partitionIter: util.Iterator[Integer],
+ action: Integer =>
GetReplicaLogInfoResponseData.PartitionLogInfo): Unit = {
+ while (partitionIter.hasNext && partitionCount <
GetReplicaLogInfoRequest.MAX_PARTITIONS_PER_REQUEST) {
+ topicLogInfo.partitionLogInfo().add(action(partitionIter.next()))
+ partitionCount += 1
+ }
+ }
+
+ val isClusterAction = authorizeClusterOperation(request, CLUSTER_ACTION)
+ def isAuthorized(topicName: String): Boolean =
+ isClusterAction || authHelper.authorize(request.context, DESCRIBE,
TOPIC, topicName)
+
val getReplicaLogInfoRequest = request.body[GetReplicaLogInfoRequest]
val data = getReplicaLogInfoRequest.data()
- var partitionCount = 0
- val topicPartitionIter = data.topicPartitions().iterator()
+
+ val topicIter = data.topicPartitions().iterator()
+ var maybePartitionIter: Option[util.Iterator[Integer]] = None
val responseData = new GetReplicaLogInfoResponseData()
.setBrokerEpoch(brokerEpochSupplier.get())
- while (topicPartitionIter.hasNext && partitionCount <
GetReplicaLogInfoRequest.MAX_PARTITIONS_PER_REQUEST) {
- val topic = topicPartitionIter.next()
- val maybeTopicName = metadataCache.getTopicName(topic.topicId())
- val topicPartitionLogInfo = new
GetReplicaLogInfoResponseData.TopicPartitionLogInfo()
- .setTopicId(topic.topicId())
+
+ while (topicIter.hasNext && partitionCount <
GetReplicaLogInfoRequest.MAX_PARTITIONS_PER_REQUEST) {
+ val topic = topicIter.next()
val partitionIter = topic.partitions().iterator()
+ maybePartitionIter = Some(partitionIter)
Review Comment:
Yeah; that makes this a lot more clear. Will update the PR.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]