sijie commented on a change in pull request #1125: Issue #1124: Lower memory
usage in GarbageCollectionThread while extracting all ledger meta data
URL: https://github.com/apache/bookkeeper/pull/1125#discussion_r167884231
##
File path:
bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/CompactionTest.java
##
@@ -835,6 +837,69 @@ public void checkpointComplete(Checkpoint checkpoint,
storage.gcThread.doCompactEntryLogs(threshold);
}
+/**
+ * Test extractMetaFromEntryLogs optimized method to avoid excess memory
usage.
+ */
+@Test(timeout = 6)
+public void testExtractMetaFromEntryLogs() throws Exception {
+ServerConfiguration conf =
TestBKConfiguration.newServerConfiguration();
+File tmpDir = createTempDir("bkTest", ".dir");
+File curDir = Bookie.getCurrentDirectory(tmpDir);
+Bookie.checkDirectoryStructure(curDir);
+conf.setLedgerDirNames(new String[] { tmpDir.toString() });
+
+LedgerDirsManager dirs = new LedgerDirsManager(conf,
conf.getLedgerDirs(),
+new DiskChecker(conf.getDiskUsageThreshold(),
conf.getDiskUsageWarnThreshold()));
+final Set ledgers = Collections
+.newSetFromMap(new ConcurrentHashMap());
+
+LedgerManager manager = getLedgerManager(ledgers);
+
+CheckpointSource checkpointSource = new CheckpointSource() {
+
+@Override
+public Checkpoint newCheckpoint() {
+return null;
+}
+
+@Override
+public void checkpointComplete(Checkpoint checkpoint,
+ boolean compact) throws IOException
{
+}
+};
+InterleavedLedgerStorage storage = new InterleavedLedgerStorage();
+storage.initialize(conf, manager, dirs, dirs, null, checkpointSource,
Checkpointer.NULL, NullStatsLogger.INSTANCE);
+final byte[] KEY = "foobar".getBytes();
+
+for (long ledger = 0; ledger <= 10; ledger++) {
+ledgers.add(ledger);
+for(int entry = 1; entry <= 50; entry++) {
+try {
+storage.addEntry(genEntry(ledger, entry, ENTRY_SIZE));
+} catch (IOException e) {
+//ignore exception on failure to add entry.
+}
+}
+}
+
+storage.flush();
+storage.shutdown();
+
+storage = new InterleavedLedgerStorage();
Review comment:
@eolivelli the test logic here is more on EntryLogger not ledger storage. We
don't need to run same test for two different ledger storage.
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:
us...@infra.apache.org
With regards,
Apache Git Services