ivankelly commented on a change in pull request #832: Issue 620: Close the 
fileChannels for read when they are idle
URL: https://github.com/apache/bookkeeper/pull/832#discussion_r170911624
 
 

 ##########
 File path: 
bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/EntryLogTest.java
 ##########
 @@ -322,6 +327,99 @@ public void testRecoverFromLedgersMapOnV0EntryLog() 
throws Exception {
         assertEquals(120, meta.getRemainingSize());
     }
 
+    /**
+     * Test Cache for logid2ReadChannel and FileChannelBackingCache for 
logid2FileChannel work correctly.
+     * Note that, when an entryLogger is initialized, the entry log id will 
increase one.
+     * when the preallocation is enabled, a new entrylogger will cost 2 logId.
+     */
+    @Test
+    public void testCacheInEntryLog() throws Exception {
+        File tmpDir = createTempDir("bkTest", ".dir");
+        File curDir = Bookie.getCurrentDirectory(tmpDir);
+        Bookie.checkDirectoryStructure(curDir);
+
+        int gcWaitTime = 1000;
+        int expireTime = 1000;
+        ServerConfiguration conf = 
TestBKConfiguration.newServerConfiguration();
+        conf.setGcWaitTime(gcWaitTime);
+        conf.setLedgerDirNames(new String[] {tmpDir.toString()});
+        //since last access, expire after 1s
+        conf.setReadChannelCacheExpireTimeMs(expireTime);
+        conf.setEntryLogFilePreAllocationEnabled(false);
+        // below one will cost logId 0
+        Bookie bookie = new Bookie(conf);
 
 Review comment:
   You don't need to create a full bookie. 

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