kevin-wu24 commented on code in PR #20422:
URL: https://github.com/apache/kafka/pull/20422#discussion_r2310715836


##########
metadata/src/main/java/org/apache/kafka/controller/metrics/QuorumControllerMetrics.java:
##########
@@ -75,13 +82,15 @@ public class QuorumControllerMetrics implements 
AutoCloseable {
     private final AtomicLong lastAppliedRecordTimestamp = new AtomicLong(0);
     private final Consumer<Long> eventQueueTimeUpdater;
     private final Consumer<Long> eventQueueProcessingTimeUpdater;
+    public final TimeRatio avgIdleTimeRatio;
 
     private final AtomicLong timedOutHeartbeats = new AtomicLong(0);
     private final AtomicLong operationsStarted = new AtomicLong(0);
     private final AtomicLong operationsTimedOut = new AtomicLong(0);
     private final AtomicLong newActiveControllers = new AtomicLong(0);
     private final Map<Integer, Long> brokerContactTimesMs = new 
ConcurrentHashMap<>();
     private final int sessionTimeoutMs;
+    private volatile OptionalLong idleStartTime = OptionalLong.empty();

Review Comment:
   I think we should use an `AtomicLong` here and `compareAndSet` in our update 
methods, since we could be calling `updateIdleEndTime()` from the 
`deferredEventQueue` and `updateIdleStartTime()` from the controller event 
thread concurrently.



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

Reply via email to