lordcheng10 commented on code in PR #3680:
URL: https://github.com/apache/bookkeeper/pull/3680#discussion_r1053906132
##########
bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/storage/TestEntryLogIds.java:
##########
@@ -127,6 +128,52 @@ public void testNoStompingDirectStartsFirst() throws
Exception {
highestSoFar = logId4;
}
+ @Test
+ public void testIdGenerator() throws Exception {
+ File base = tmpDirs.createNew("entryLogIds", "ledgers");
+ File ledgerDir1 = new File(base, "l1");
+ File ledgerDir2 = new File(base, "l2");
+ File ledgerDir3 = new File(base, "l3");
+ File ledgerDir4 = new File(base, "l4");
+ ledgerDir1.mkdir();
+ ledgerDir2.mkdir();
+ ledgerDir3.mkdir();
+ ledgerDir4.mkdir();
+
+ //case 1: use root ledgerDirsManager
+ LedgerDirsManager ledgerDirsManager = newDirsManager(ledgerDir1,
ledgerDir2);
+ EntryLogIds ids1 = new EntryLogIdsImpl(ledgerDirsManager, slog);
+ for (int i = 0; i < 10; i++) {
+ int logId = ids1.nextId();
+ File log1 = new File(ledgerDir1 + "/current", logId + ".log");
Review Comment:
EntryLogIds generates the next id based on the existing file ids in the
directory. In order to simulate the impact of multiple directories on the id,
some temporary files need to be created here:
<img width="741" alt="image"
src="https://user-images.githubusercontent.com/19296967/208802582-3854ab68-288e-4e6f-ac50-df4852733dda.png">
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]