reddycharan commented on a change in pull request #1391: Issue #570: 
EntryLogManagerForEntryLogPerLedger implementation
URL: https://github.com/apache/bookkeeper/pull/1391#discussion_r189413885
 
 

 ##########
 File path: 
bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/CreateNewLogTest.java
 ##########
 @@ -142,6 +151,237 @@ public void testCreateNewLogWithNoWritableLedgerDirs() 
throws Exception {
         assertTrue("Wrong log id", entryLogManager.getCurrentLogId() > 1);
     }
 
+    /*
+     * entryLogPerLedger is enabled and various scenarios of entrylogcreation 
are tested
+     */
+    @Test
+    public void testEntryLogPerLedgerCreationWithPreAllocation() throws 
Exception {
+        /*
+         * I wish I could shorten this testcase or split it into multiple 
testcases,
+         * but I want to cover a scenario and it requires multiple operations 
in
+         * sequence and validations along the way. Please bear with the length 
of this
+         * testcase, I added as many comments as I can to simplify it.
+         */
+
+        ServerConfiguration conf = 
TestBKConfiguration.newServerConfiguration();
+
+        // Creating a new configuration with a number of ledger directories.
+        conf.setLedgerDirNames(ledgerDirs);
+        conf.setIsForceGCAllowWhenNoSpace(true);
+        // preAllocation is Enabled
+        conf.setEntryLogFilePreAllocationEnabled(true);
+        conf.setEntryLogPerLedgerEnabled(true);
+        LedgerDirsManager ledgerDirsManager = new LedgerDirsManager(conf, 
conf.getLedgerDirs(),
+                new DiskChecker(conf.getDiskUsageThreshold(), 
conf.getDiskUsageWarnThreshold()));
+        EntryLogger entryLogger = new EntryLogger(conf, ledgerDirsManager);
+        EntryLoggerAllocator entryLoggerAllocator = 
entryLogger.entryLoggerAllocator;
+        EntryLogManagerForEntryLogPerLedger entryLogManager = 
(EntryLogManagerForEntryLogPerLedger) entryLogger
+                .getEntryLogManager();
+
+        /*
+         * no entrylog will be created during initialization
+         */
+        int expectedPreAllocatedLogID = -1;
+        Assert.assertEquals("PreallocatedlogId after initialization of 
Entrylogger",
+                expectedPreAllocatedLogID, 
entryLoggerAllocator.getPreallocatedLogId());
+
+        int numOfLedgers = 6;
+
+        for (long i = 0; i < numOfLedgers; i++) {
+            /* since we are starting creation of new ledgers, entrylogid will 
be ledgerid */
+            entryLogManager.createNewLog(i);
+        }
+
+        Thread.sleep(100);
 
 Review comment:
   guava to the rescue! removed these sleeps, for entryloggerallocator's 
allocatorexecutor using newDirectExecutorService()

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