apoorvmittal10 commented on code in PR #14843:
URL: https://github.com/apache/kafka/pull/14843#discussion_r1410198452


##########
clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:
##########
@@ -4387,7 +4398,52 @@ public FenceProducersResult 
fenceProducers(Collection<String> transactionalIds,
 
     @Override
     public Uuid clientInstanceId(Duration timeout) {
-        throw new UnsupportedOperationException();
+        if (timeout.isNegative()) {
+            throw new IllegalArgumentException("The timeout cannot be 
negative.");
+        }
+
+        if (!clientTelemetryEnabled) {
+            throw new IllegalStateException("Telemetry is not enabled. Set 
config `enable.metrics.push` to `true`.");
+        }
+
+        if (clientInstanceId != null) {
+            return clientInstanceId;
+        }
+
+        final long now = time.milliseconds();
+        final KafkaFutureImpl<Uuid> future = new KafkaFutureImpl<>();
+        runnable.call(new Call("getTelemetrySubscriptions", 
calcDeadlineMs(now, (int) timeout.toMillis()),
+            new LeastLoadedNodeProvider()) {
+
+            @Override
+            GetTelemetrySubscriptionsRequest.Builder createRequest(int 
timeoutMs) {
+                return new GetTelemetrySubscriptionsRequest.Builder(new 
GetTelemetrySubscriptionsRequestData(), true);
+            }
+
+            @Override
+            void handleResponse(AbstractResponse abstractResponse) {
+                GetTelemetrySubscriptionsResponse response = 
(GetTelemetrySubscriptionsResponse) abstractResponse;
+                if (response.error() != Errors.NONE) {
+                    future.completeExceptionally(response.error().exception());
+                } else {
+                    future.complete(response.data().clientInstanceId());
+                }
+            }
+
+            @Override
+            void handleFailure(Throwable throwable) {
+                future.completeExceptionally(throwable);
+            }
+        }, now);
+
+        try {
+            clientInstanceId = future.get();
+        } catch (Exception e) {
+            log.error("Error occurred while fetching client instance id", e);
+            throw new KafkaException("Error occurred while fetching client 
instance id", e);
+        }

Review Comment:
   The other 2 classes loads the subscription as part of 
GetTelemetrySubscriptions API call and as well runs the continuous poll loop to 
see any change in state to re-fetch subscription, which can work with 
signalling of loaded subscription.



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