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


##########
server/src/main/java/org/apache/kafka/server/ClientMetricsManager.java:
##########
@@ -433,4 +459,26 @@ public Map<String, Pattern> matchPattern() {
             return matchPattern;
         }
     }
+
+    private final class ExpirationTimerTask extends TimerTask {
+
+        private final Uuid uuid;
+
+        private ExpirationTimerTask(Uuid uuid, long delayMs) {
+            super(delayMs);
+            this.uuid = uuid;
+        }
+
+        @Override
+        public void run() {
+            log.trace("Expiration timer task run for client instance id: {}, 
after delay ms: {}", uuid, delayMs);
+            if (!clientInstanceCache.remove(uuid)) {
+                // This can only happen if the client instance is removed from 
the cache by the LRU
+                // eviction policy before the expiration timer task is 
executed. Log a warning as broker
+                // cache is not able to hold all the client instances.
+                log.warn("Client metrics instance cache cannot find the client 
instance id: {}. The cache"

Review Comment:
   Do you suggest keeping an AtomicCounter which records this occurrence and 
logs say every 100th time when this issue triggers?
   
   Something like below, can use incrementAndGet:
   ```
   if (log.isWarnEnabled() && errorCounter % 100 == 0) {
      // log statement here ......
   }  



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