sijie commented on a change in pull request #1218: Support LacPiggyback, 
LongPoll and ExplicitLac in db ledger storage
URL: https://github.com/apache/bookkeeper/pull/1218#discussion_r171253194
 
 

 ##########
 File path: 
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/DbLedgerStorage.java
 ##########
 @@ -167,12 +287,41 @@ public void initialize(ServerConfiguration conf, 
LedgerManager ledgerManager, Le
         ledgerIndex = new LedgerMetadataIndex(conf, 
KeyValueStorageRocksDB.factory, baseDir, stats);
         entryLocationIndex = new EntryLocationIndex(conf, 
KeyValueStorageRocksDB.factory, baseDir, stats);
 
+        // build the ledger info cache
+        int concurrencyLevel = Math.max(1, 
Math.max(conf.getNumAddWorkerThreads(), conf.getNumReadWorkerThreads()));
+        RemovalListener<Long, TransientLedgerInfo> ledgerInfoRemovalListener = 
this::handleLedgerEviction;
+        CacheBuilder<Long, TransientLedgerInfo> builder = 
CacheBuilder.newBuilder()
+            .initialCapacity(conf.getFileInfoCacheInitialCapacity())
+            .maximumSize(conf.getOpenFileLimit())
+            .concurrencyLevel(concurrencyLevel)
+            .removalListener(ledgerInfoRemovalListener);
+        if (conf.getFileInfoMaxIdleTime() > 0) {
+            builder.expireAfterAccess(conf.getFileInfoMaxIdleTime(), 
TimeUnit.SECONDS);
+        }
+        transientLedgerInfoCache = builder.build(new CacheLoader<Long, 
TransientLedgerInfo>() {
 
 Review comment:
   this is not true.
   
   1) in FileInfoCache, FileInfo is not trasient, it deals with persistence. 
However in here, TransientLedgerInfo doesn't deal with persistence. that makes 
the difference. 
   2) I make it explicit "Transient", to make the difference with FileInfo and 
also `LedgerData` in LedgerMetadataIndex. Otherwise, "LedgerInfo" and 
"LedgerData" sound too close to each other.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to