reddycharan commented on a change in pull request #1201: ISSUE #570: Entrylog 
per ledger
URL: https://github.com/apache/bookkeeper/pull/1201#discussion_r171123780
 
 

 ##########
 File path: 
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLogger.java
 ##########
 @@ -1435,4 +1859,40 @@ static long fileName2LogId(String fileName) {
     static String logId2HexString(long logId) {
         return Long.toHexString(logId);
     }
+
+    /**
+     * Datastructure which maintains the status of logchannels. When a
+     * logChannel is created entry of < entryLogId, false > will be made to 
this
+     * sortedmap and when logChannel is rotated and flushed then the entry is
+     * updated to < entryLogId, true > and all the lowest entries with
+     * < entryLogId, true > status will be removed from the sortedmap. So that 
way
+     * we could get least unflushed LogId.
+     *
+     */
+    class RecentEntryLogsStatus {
+        private SortedMap<Long, Boolean> entryLogsStatusMap;
+        private long leastUnflushedLogId;
+
+        RecentEntryLogsStatus(long leastUnflushedLogId) {
+            entryLogsStatusMap = new TreeMap<Long, Boolean>();
+            this.leastUnflushedLogId = leastUnflushedLogId;
+        }
+
+        synchronized void createdEntryLog(Long entryLogId) {
+            entryLogsStatusMap.put(entryLogId, false);
+        }
+
+        synchronized void flushRotatedEntryLog(Long entryLogId) {
+            entryLogsStatusMap.replace(entryLogId, true);
+            while ((!entryLogsStatusMap.isEmpty()) && 
(entryLogsStatusMap.get(entryLogsStatusMap.firstKey()))) {
 
 Review comment:
   here we are not removing all the entries whose value is true. We are 
removing just the entries which has true value untill the first false value. 
But yeah, probably we can use streams in some form, for simplicity sake lets 
keep as it is. May be I should add a comment describing what I'm intending to 
do here.

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