XiaoZYang commented on a change in pull request #1219: Issue 1069: Provide a setting in consumer configuration to specify where to start consuming messages URL: https://github.com/apache/incubator-pulsar/pull/1219#discussion_r170821460
########## File path: managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java ########## @@ -2026,6 +2036,29 @@ PositionImpl getMarkDeletePositionOfSlowestConsumer() { return Pair.create(pos, count); } + /** + * Get the first position written in the managed ledger, alongside with the associated counter + */ + Pair<PositionImpl, Long> getFirstPositionAndCounter() { + PositionImpl pos; + long count; + long entries; + Pair<PositionImpl, Long> lastPositionAndCounter; + + do { + pos = getFirstPosition(); + + lastPositionAndCounter = getLastPositionAndCounter(); + entries = getNumberOfEntries(); + count = lastPositionAndCounter.second - entries; + + // Ensure no entry was written while reading the two values + } while (pos.compareTo(getFirstPosition()) != 0 + && lastPositionAndCounter.first.compareTo(getLastPosition()) != 0); + + return Pair.create(pos, count); Review comment: thanks for your comments, corresponding unit tests will be added soon. ---------------------------------------------------------------- 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