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

 ##########
 File path: 
bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/EntryLogTest.java
 ##########
 @@ -315,6 +316,104 @@ public void testRecoverFromLedgersMapOnV0EntryLog() 
throws Exception {
         assertEquals(120, meta.getRemainingSize());
     }
 
+    /**
+     * Test Cache for logid2Channel and concurrentMap 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;
+        ServerConfiguration conf = 
TestBKConfiguration.newServerConfiguration();
+        conf.setGcWaitTime(gcWaitTime);
+        conf.setLedgerDirNames(new String[] {tmpDir.toString()});
+        //since last access, expire after 1s
+        conf.setExpireReadChannelCache(1000);
+        conf.setEntryLogFilePreAllocationEnabled(false);
+        // below one will cost logId 0
+        Bookie bookie = new Bookie(conf);
+        // create some entries
+        int numLogs = 4;
+        int numEntries = 10;
+        long[][] positions = new long[numLogs][];
+        for (int i = 0; i < numLogs; i++) {
+            positions[i] = new long[numEntries];
+            EntryLogger logger = new EntryLogger(conf,
 
 Review comment:
   that would be good.

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