eolivelli commented on a change in pull request #1949: [bookie-gc] add option 
to cache entry-log metadata map into rocksDB
URL: https://github.com/apache/bookkeeper/pull/1949#discussion_r370489414
 
 

 ##########
 File path: 
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/GarbageCollectorThread.java
 ##########
 @@ -415,64 +436,69 @@ private void removeIfLedgerNotExists(EntryLogMetadata 
meta) {
                 return false;
             }
         });
+        // update entryMetadta to persistent-map
+        if (updateMetadata) {
+            entryLogMetaMap.put(entryLogId, meta);
+        }
     }
 
     /**
      * Compact entry logs if necessary.
      *
      * <p>
      * Compaction will be executed from low unused space to high unused space.
-     * Those entry log files whose remaining size percentage is higher than 
threshold
-     * would not be compacted.
+     * Those entry log files whose remaining size percentage is higher than
+     * threshold would not be compacted.
      * </p>
+     * 
+     * @throws IOException
      */
     @VisibleForTesting
-    void doCompactEntryLogs(double threshold) {
+    void doCompactEntryLogs(double threshold) throws IOException {
         LOG.info("Do compaction to compact those files lower than {}", 
threshold);
 
-        // sort the ledger meta by usage in ascending order.
-        List<EntryLogMetadata> logsToCompact = new 
ArrayList<EntryLogMetadata>();
-        logsToCompact.addAll(entryLogMetaMap.values());
-        logsToCompact.sort(Comparator.comparing(EntryLogMetadata::getUsage));
-
         final int numBuckets = 10;
         int entryLogUsageBuckets[] = new int[numBuckets];
 
-        for (EntryLogMetadata meta : logsToCompact) {
-            int bucketIndex = Math.min(
-                    numBuckets - 1,
-                    (int) Math.ceil(meta.getUsage() * numBuckets));
+        entryLogMetaMap.forEach((entryLogId, meta) -> {
+            int bucketIndex = Math.min(numBuckets - 1, (int) 
Math.ceil(meta.getUsage() * numBuckets));
             entryLogUsageBuckets[bucketIndex]++;
 
             if (meta.getUsage() >= threshold) {
-                continue;
+                return;
 
 Review comment:
   Oh yes, I see

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to