noob-se7en commented on code in PR #16339: URL: https://github.com/apache/pinot/pull/16339#discussion_r2208264715
########## pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/RealtimeConsumptionRateManager.java: ########## @@ -59,6 +64,7 @@ public class RealtimeConsumptionRateManager { private static final String SERVER_CONSUMPTION_RATE_METRIC_KEY_NAME = ServerMeter.REALTIME_ROWS_CONSUMED.getMeterName(); + private static final AtomicReference<AsyncMetricEmitter> ASYNC_METRIC_EMITTER_REF = new AtomicReference<>(); Review Comment: It's fine IMO. ``` @Override public void throttle(int numMsgs) { if (InstanceHolder.INSTANCE._isThrottlingAllowed) { // Only emit metrics when throttling is allowed. Throttling is not enabled. // until the server has passed startup checks. Otherwise, we will see // consumption well over 100% during startup. _metricEmitter.emitMetric(numMsgs); if (numMsgs > 0) { _rateLimiter.acquire(numMsgs); } } } ``` The above code is safe for concurrent use given that _rateLimiter is object of com.google.common.util.concurrent.RateLimiter and based on its javadoc: `RateLimiter is safe for concurrent use: It will restrict the total rate of calls from all threads. Note, however, that it does not guarantee fairness.` -- 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: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org