You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/05/11 10:11:50 UTC
[GitHub] [pulsar] codelipenghui commented on a change in pull request #10326: support truncate topic
codelipenghui commented on a change in pull request #10326:
URL: https://github.com/apache/pulsar/pull/10326#discussion_r630034482
##########
File path: managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerTest.java
##########
@@ -2917,4 +2916,59 @@ public void testManagedLedgerRollOverIfFull() throws Exception {
Assert.assertEquals(ledger.getLedgersInfoAsList().size(), 1);
Assert.assertEquals(ledger.getTotalSize(), 0);
}
+
+ @Test(timeOut = 20000)
+ public void testAsyncTruncateLedgerRetention() throws Exception {
+
+ ManagedLedgerFactory factory = new ManagedLedgerFactoryImpl(bkc, bkc.getZkHandle());
+ ManagedLedgerConfig config = new ManagedLedgerConfig();
+ config.setRetentionSizeInMB(50);
+ config.setRetentionTime(1, TimeUnit.DAYS);
+
+ ManagedLedgerImpl ledger = (ManagedLedgerImpl)factory.open("truncate_ledger", config);
+ ManagedCursor cursor = ledger.openCursor("test-cursor");
+ ledger.addEntry("test-entry-1".getBytes(Encoding));
+ ledger.addEntry("test-entry-1".getBytes(Encoding));
+ ledger.addEntry("test-entry-1".getBytes(Encoding));
+ ledger.addEntry("test-entry-1".getBytes(Encoding));
+ ledger.addEntry("test-entry-1".getBytes(Encoding));
+
+ ledger.close();
+ ManagedLedgerImpl ledger2 = (ManagedLedgerImpl)factory.open("truncate_ledger", config);
+ ledger2.addEntry("test-entry-2".getBytes(Encoding));
+
+
+ CompletableFuture<Void> future = ledger2.asyncTruncate();
+ future.get();
+
+ assertTrue(ledger2.getLedgersInfoAsList().size() <= 1);
Review comment:
@MarvinCai We have a min rollover time limitation, the min value we are able to set is 1min. So I think maybe `setMaxEntriesPerLedger` can't work here.
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org