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/06/18 21:20:15 UTC

[GitHub] [pulsar] gaoran10 commented on a change in pull request #10966: [Broker] Fix get wrong backlog number.

gaoran10 commented on a change in pull request #10966:
URL: https://github.com/apache/pulsar/pull/10966#discussion_r654344017



##########
File path: managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorTest.java
##########
@@ -3526,5 +3528,26 @@ public void testCursorCheckReadPositionChanged() throws Exception {
         ledger.close();
     }
 
+
+    @Test // (timeOut = 20000)

Review comment:
       The param `timeOut` is need or not?

##########
File path: managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorTest.java
##########
@@ -3526,5 +3528,26 @@ public void testCursorCheckReadPositionChanged() throws Exception {
         ledger.close();
     }
 
+
+    @Test // (timeOut = 20000)
+    public void testCursorGetBacklog() throws Exception {
+        ManagedLedgerConfig managedLedgerConfig = new ManagedLedgerConfig();
+        managedLedgerConfig.setMaxEntriesPerLedger(1);

Review comment:
       Do we need test the scenario that one ledger maintain multiple entries?

##########
File path: managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorTest.java
##########
@@ -3526,5 +3528,26 @@ public void testCursorCheckReadPositionChanged() throws Exception {
         ledger.close();
     }
 
+
+    @Test // (timeOut = 20000)
+    public void testCursorGetBacklog() throws Exception {
+        ManagedLedgerConfig managedLedgerConfig = new ManagedLedgerConfig();
+        managedLedgerConfig.setMaxEntriesPerLedger(1);
+        managedLedgerConfig.setMinimumRolloverTime(0, TimeUnit.MILLISECONDS);
+        ManagedLedgerImpl ledger = (ManagedLedgerImpl) factory.open("get-backlog", managedLedgerConfig);
+        ManagedCursor managedCursor = ledger.openCursor("test");
+
+        Position position = ledger.addEntry("test".getBytes(Encoding));
+        ledger.addEntry("test".getBytes(Encoding));
+
+        Assert.assertEquals(managedCursor.getNumberOfEntriesInBacklog(true), 2);
+        Field field = ManagedLedgerImpl.class.getDeclaredField("ledgers");
+        field.setAccessible(true);
+
+        ((ConcurrentSkipListMap<Long, MLDataFormats.ManagedLedgerInfo.LedgerInfo>) field.get(ledger)).remove(position.getLedgerId());

Review comment:
       Maybe it's better to change the `markDeletePosition` at the same time, due to the range start position is `markDeletePosition`.




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