mumrah commented on code in PR #14612:
URL: https://github.com/apache/kafka/pull/14612#discussion_r1399368685


##########
clients/src/main/resources/common/message/DescribeTopicPartitionsRequest.json:
##########
@@ -0,0 +1,38 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//    http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+{
+  "apiKey": 74,
+  "type": "request",
+  "listeners": ["broker"],
+  "name": "DescribeTopicPartitionsRequest",
+  "validVersions": "0",
+  "flexibleVersions": "0+",
+  "fields": [
+    { "name": "Topics", "type": "[]TopicRequest", "versions": "0+",
+      "about": "The topics to fetch details for.", "versions": "0+",
+      "fields": [
+        { "name": "Name", "type": "string", "versions": "0+",
+          "about": "The topic name", "versions": "0+", "entityType": 
"topicName"}
+      ]
+    },
+    { "name": "Cursor", "type": "Cursor", "versions": "0+", 
"nullableVersions": "0+", "default": "null",
+      "about": "The first topic and partition index to fetch details for.", 
"fields": [
+      { "name": "TopicName", "type": "string", "versions": "0+",
+        "about": "The name for the first topic to process", "versions": "0+", 
"entityType": "topicName"},
+      { "name": "PartitionIndex", "type": "int32", "versions": "0+", "about": 
"The partition index to start with"}
+    ]}
+  ]
+}

Review Comment:
   nit: newline



##########
clients/src/main/resources/common/message/DescribeTopicPartitionsRequest.json:
##########
@@ -0,0 +1,38 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//    http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+{
+  "apiKey": 74,
+  "type": "request",
+  "listeners": ["broker"],
+  "name": "DescribeTopicPartitionsRequest",
+  "validVersions": "0",
+  "flexibleVersions": "0+",
+  "fields": [
+    { "name": "Topics", "type": "[]TopicRequest", "versions": "0+",
+      "about": "The topics to fetch details for.", "versions": "0+",
+      "fields": [
+        { "name": "Name", "type": "string", "versions": "0+",
+          "about": "The topic name", "versions": "0+", "entityType": 
"topicName"}
+      ]
+    },
+    { "name": "Cursor", "type": "Cursor", "versions": "0+", 
"nullableVersions": "0+", "default": "null",

Review Comment:
   Is the type `Cursor` defined somewhere?



##########
core/src/main/scala/kafka/server/metadata/KRaftMetadataCache.scala:
##########
@@ -186,6 +250,85 @@ class KRaftMetadataCache(val brokerId: Int) extends 
MetadataCache with Logging w
     }
   }
 
+  /**
+   * Get the topic metadata for the given topics.
+   *
+   * The quota is used to limit the number of partitions to return. The 
NextTopicPartition field points to the first
+   * partition can't be returned due the limit.
+   * If a topic can't return any partition due to quota limit reached, this 
topic will not be included in the response.
+   *
+   * Note, the topics should be sorted in alphabetical order. The topics in 
the DescribeTopicPartitionsResponseData
+   * will also be sorted in alphabetical order.
+   *
+   * @param topics                        The set of topics and their 
corresponding first partition id to fetch.
+   * @param listenerName                  The listener name.
+   * @param firstTopicPartitionStartIndex The start partition index for the 
first topic
+   * @param quota                         The max number of partitions to 
return.

Review Comment:
   Let's not call this "quota" as that's already a very overloaded term on the 
broker :)



##########
clients/src/main/resources/common/message/DescribeTopicPartitionsResponse.json:
##########
@@ -0,0 +1,66 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//    http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+{
+  "apiKey": 74,
+  "type": "response",
+  "name": "DescribeTopicPartitionsResponse",
+  "validVersions": "0",
+  "flexibleVersions": "0+",
+  "fields": [
+    { "name": "ThrottleTimeMs", "type": "int32", "versions": "0+", 
"ignorable": true,
+      "about": "The duration in milliseconds for which the request was 
throttled due to a quota violation, or zero if the request did not violate any 
quota." },
+    { "name": "Topics", "type": "[]DescribeTopicPartitionsResponseTopic", 
"versions": "0+",
+      "about": "Each topic in the response.", "fields": [
+      { "name": "ErrorCode", "type": "int16", "versions": "0+",
+        "about": "The topic error, or 0 if there was no error." },
+      { "name": "Name", "type": "string", "versions": "0+", "mapKey": true, 
"entityType": "topicName", "nullableVersions": "0+",
+        "about": "The topic name." },
+      { "name": "TopicId", "type": "uuid", "versions": "0+", "ignorable": 
true, "about": "The topic id." },
+      { "name": "IsInternal", "type": "bool", "versions": "0+", "default": 
"false", "ignorable": true,
+        "about": "True if the topic is internal." },
+      { "name": "Partitions", "type": 
"[]DescribeTopicPartitionsResponsePartition", "versions": "0+",
+        "about": "Each partition in the topic.", "fields": [
+        { "name": "ErrorCode", "type": "int16", "versions": "0+",
+          "about": "The partition error, or 0 if there was no error." },
+        { "name": "PartitionIndex", "type": "int32", "versions": "0+",
+          "about": "The partition index." },
+        { "name": "LeaderId", "type": "int32", "versions": "0+", "entityType": 
"brokerId",
+          "about": "The ID of the leader broker." },
+        { "name": "LeaderEpoch", "type": "int32", "versions": "0+", "default": 
"-1", "ignorable": true,
+          "about": "The leader epoch of this partition." },
+        { "name": "ReplicaNodes", "type": "[]int32", "versions": "0+", 
"entityType": "brokerId",
+          "about": "The set of all nodes that host this partition." },
+        { "name": "IsrNodes", "type": "[]int32", "versions": "0+", 
"entityType": "brokerId",
+          "about": "The set of nodes that are in sync with the leader for this 
partition." },
+        { "name": "EligibleLeaderReplicas", "type": "[]int32", "default": 
"null", "entityType": "brokerId",
+          "versions": "0+", "nullableVersions": "0+",
+          "about": "The new eligible leader replicas otherwise." },
+        { "name": "LastKnownELR", "type": "[]int32", "default": "null", 
"entityType": "brokerId",
+          "versions": "0+", "nullableVersions": "0+",
+          "about": "The last known ELR." },
+        { "name": "OfflineReplicas", "type": "[]int32", "versions": "0+", 
"ignorable": true, "entityType": "brokerId",
+          "about": "The set of offline replicas of this partition." }]},
+      { "name": "TopicAuthorizedOperations", "type": "int32", "versions": 
"0+", "default": "-2147483648",
+        "about": "32-bit bitfield to represent authorized operations for this 
topic." }]
+    },
+    { "name": "NextTopicPartition", "type": "Cursor", "versions": "0+", 
"nullableVersions": "0+", "default": "null",
+      "about": "The next topic and partition index to fetch details for.", 
"fields": [
+      { "name": "TopicName", "type": "string", "versions": "0+",
+        "about": "The name for the first topic to process", "versions": "0+", 
"entityType": "topicName"},
+      { "name": "PartitionIndex", "type": "int32", "versions": "0+", "about": 
"The partition index to start with"}
+    ]}
+  ]
+}

Review Comment:
   nit: newline



##########
core/src/main/scala/kafka/server/KafkaApis.scala:
##########
@@ -1184,6 +1186,19 @@ class KafkaApis(val requestChannel: RequestChannel,
       .setPartitions(partitionData)
   }
 
+  private def DescribeTopicPartitionsResponseTopic(error: Errors,

Review Comment:
   Can you format this like:
   
   ```
   def foo(
     arg1: T,
     arg2: T
   ): R = {
     ...
   }
   ```
   
   



##########
core/src/main/scala/kafka/server/KafkaApis.scala:
##########
@@ -116,6 +117,7 @@ class KafkaApis(val requestChannel: RequestChannel,
   val requestHelper = new RequestHandlerHelper(requestChannel, quotas, time)
   val aclApis = new AclApis(authHelper, authorizer, requestHelper, "broker", 
config)
   val configManager = new ConfigAdminManager(brokerId, config, 
configRepository)
+  val partitionRequestLimit = 2000

Review Comment:
   Usually pagination is controlled by the client (limit + offset). It's a good 
idea to have a hard limit on the server to prevent blowing up the heap (and 
protecting against DDOS). It should be configurable though.



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to