junrao commented on code in PR #14811:
URL: https://github.com/apache/kafka/pull/14811#discussion_r1401339000


##########
clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientTest.java:
##########
@@ -7090,6 +7093,51 @@ private static MemberDescription 
convertToMemberDescriptions(DescribedGroupMembe
                                      assignment);
     }
 
+    @Test
+    public void testListClientMetricsResources() throws Exception {
+        try (AdminClientUnitTestEnv env = mockClientEnv()) {
+            List<ClientMetricsResourceListing> expected = Arrays.asList(
+                new ClientMetricsResourceListing("one"),
+                new ClientMetricsResourceListing("two")
+            );
+
+            ListClientMetricsResourcesResponseData responseData =
+                new 
ListClientMetricsResourcesResponseData().setErrorCode(Errors.NONE.code());
+
+            responseData.clientMetricsResources()
+                .add(new 
ListClientMetricsResourcesResponseData.ClientMetricsResource().setName("one"));
+            responseData.clientMetricsResources()
+                .add((new 
ListClientMetricsResourcesResponseData.ClientMetricsResource()).setName("two"));
+
+            env.kafkaClient().prepareResponse(
+                request -> request instanceof 
ListClientMetricsResourcesRequest,
+                new ListClientMetricsResourcesResponse(responseData));
+
+            ListClientMetricsResourcesResult result = 
env.adminClient().listClientMetricsResources();
+            assertEquals(new HashSet<>(expected), new 
HashSet<>(result.all().get()));
+        }
+    }
+
+    @Test
+    public void testListClientMetricsResourcesNotSupported() throws Exception {

Review Comment:
   This method doesn't seem to throw.



##########
core/src/main/scala/kafka/server/KafkaApis.scala:
##########
@@ -3759,6 +3760,21 @@ class KafkaApis(val requestChannel: RequestChannel,
     CompletableFuture.completedFuture[Unit](())
   }
 
+  // Just a placeholder for now.
+  def handleListClientMetricsResources(request: RequestChannel.Request): 
CompletableFuture[Unit] = {

Review Comment:
   Why does this return `CompletableFuture[Unit]` instead of `Unit`?



##########
clients/src/main/java/org/apache/kafka/clients/admin/ListClientMetricsResourcesResult.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.
+ */
+
+package org.apache.kafka.clients.admin;
+
+import org.apache.kafka.common.KafkaFuture;
+import org.apache.kafka.common.annotation.InterfaceStability;
+import org.apache.kafka.common.internals.KafkaFutureImpl;
+
+import java.util.Collection;
+
+/**
+ * The result of the {@link Admin#listClientMetricsResources()} call.
+ * <p>
+ * The API of this class is evolving, see {@link Admin} for details.
+ */
+@InterfaceStability.Evolving
+public class ListClientMetricsResourcesResult {
+    private final KafkaFuture<Collection<ClientMetricsResourceListing>> future;
+
+    
ListClientMetricsResourcesResult(KafkaFuture<Collection<ClientMetricsResourceListing>>
 future) {
+        this.future = future;
+    }
+
+    /**
+     * Returns a future that yields either an exception, or the full set of 
client metrics
+     * listings.
+     *
+     * In the event of a failure, the future yields nothing but the first 
exception which
+     * occurred.
+     */
+    public KafkaFuture<Collection<ClientMetricsResourceListing>> all() {
+        final KafkaFutureImpl<Collection<ClientMetricsResourceListing>> result 
= new KafkaFutureImpl<>();
+        this.future.whenComplete((listings, throwable) -> {

Review Comment:
   Do we need `this`?



-- 
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