richardstartin commented on a change in pull request #6291:
URL: https://github.com/apache/pinot/pull/6291#discussion_r795462389



##########
File path: 
pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/RealtimeConsumptionRateManager.java
##########
@@ -42,25 +43,35 @@
  */
 public class RealtimeConsumptionRateManager {
   private static final Logger LOGGER = 
LoggerFactory.getLogger(RealtimeConsumptionRateManager.class);
-  private static final RealtimeConsumptionRateManager INSTANCE = new 
RealtimeConsumptionRateManager();
   private static final int CACHE_ENTRY_EXPIRATION_TIME_IN_MINUTES = 10;
 
+  private static volatile RealtimeConsumptionRateManager INSTANCE;
+
   // stream config object is required for fetching the partition count from 
the stream
-  private final LoadingCache<StreamConfig, Integer> 
_streamConfigToTopicPartitionCountMap = buildCache();
+  private final LoadingCache<StreamConfig, Integer> 
_streamConfigToTopicPartitionCountMap;
   private volatile boolean _isThrottlingAllowed = false;
 
-  private RealtimeConsumptionRateManager() {
+  @VisibleForTesting
+  RealtimeConsumptionRateManager(LoadingCache<StreamConfig, Integer> 
streamConfigToTopicPartitionCountMap) {
+    _streamConfigToTopicPartitionCountMap = 
streamConfigToTopicPartitionCountMap;
   }
 
   public static RealtimeConsumptionRateManager getInstance() {
+    if (INSTANCE == null) {

Review comment:
       Can you use a holder class with a static final 
RealtimeConsumptionRateManager instead - class initialisation is atomic and the 
holder singleton pattern is both more concise and more efficient on ARM because 
there’s no need for the reads to be volatile.




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

Reply via email to