dlg99 commented on code in PR #3432:
URL: https://github.com/apache/bookkeeper/pull/3432#discussion_r932534130


##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ServerConfiguration.java:
##########
@@ -3858,6 +3860,50 @@ public boolean isLocalConsistencyCheckOnStartup() {
         return this.getBoolean(LOCAL_CONSISTENCY_CHECK_ON_STARTUP, false);
     }
 
+    /**
+     * The configured pooling concurrency for the allocator, if user config 
it, we should consider the unpooled
+     * direct memory which readCache and writeCache occupy when use 
DbLedgerStorage.
+     */
+    public int getAllocatorPoolingConcurrency() {
+        Integer allocatorPoolingConcurrency = 
this.getInteger(ALLOCATOR_POOLING_CONCURRENCY, null);
+        if (allocatorPoolingConcurrency != null) {
+            return allocatorPoolingConcurrency;
+        }
+        String ledgerStorageClass = getLedgerStorageClass();
+        if (DbLedgerStorage.class.getName().equals(ledgerStorageClass)) {
+            long writeCacheMb;
+            Object writeCacheConf = 
this.getProperty(DbLedgerStorage.WRITE_CACHE_MAX_SIZE_MB);
+            if (writeCacheConf instanceof Number) {
+                writeCacheMb =  ((Number) writeCacheConf).longValue();
+            } else if (writeCacheConf == null) {
+                writeCacheMb =  
DbLedgerStorage.DEFAULT_WRITE_CACHE_MAX_SIZE_MB;
+            } else if 
(StringUtils.isEmpty(this.getString(DbLedgerStorage.WRITE_CACHE_MAX_SIZE_MB))) {
+                writeCacheMb =  
DbLedgerStorage.DEFAULT_WRITE_CACHE_MAX_SIZE_MB;
+            } else {
+                writeCacheMb =  
this.getLong(DbLedgerStorage.WRITE_CACHE_MAX_SIZE_MB);
+            }

Review Comment:
   I think all this can be done better by moving 
   ```
           long writeCacheMaxSize = getLongVariableOrDefault(conf, 
WRITE_CACHE_MAX_SIZE_MB,
                   DEFAULT_WRITE_CACHE_MAX_SIZE_MB) * MB;
           long readCacheMaxSize = getLongVariableOrDefault(conf, 
READ_AHEAD_CACHE_MAX_SIZE_MB,
                   DEFAULT_READ_CACHE_MAX_SIZE_MB) * MB;
           boolean directIOEntryLogger = getBooleanVariableOrDefault(conf, 
DIRECT_IO_ENTRYLOGGER, false);
   ```
   and related config magic out of DbLedgerStorage into the ServerConfig
   and then all you'd need to do is something like this.getWriteCacheMaxSize()
   



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