pulsar
pulsar copied to clipboard
Eliminate special process logic for ManagedLedgerImpl
Search before reporting
- [x] I searched in the issues and found nothing similar.
Motivation
See https://github.com/apache/pulsar/pull/25016#discussion_r2560288325
Since https://github.com/apache/pulsar/pull/24622, when a managed ledger does not inherit ManagedLedgerImpl, the expiration check will use a different method, which is hard to test without a custom implementation.
if (managedLedger instanceof ManagedLedgerImpl ml) {
checkMessageExpiryWithSharedPosition(ml, messageTtlInSeconds);
} else {
// Fallback to the slower solution if managed ledger is not an instance of ManagedLedgerImpl: each
// subscription find position and handle expiring itself.
checkMessageExpiryWithoutSharedPosition(messageTtlInSeconds);
}
However, in checkMessageExpiryWithSharedPosition, the only operation is getting the cursor with oldest position:
private void checkMessageExpiryWithSharedPosition(ManagedLedgerImpl ml, int messageTtlInSeconds) {
// Find the target position at one time, then expire all subscriptions and replicators.
final var cursorWithOldestPosition = ml.getCursors().getCursorWithOldestPosition();
This should be a general operation that if the ManagedLedger#getCursors returns a correct cursor container, it should also work even if it's not a ManagedLedgerImpl.
Solution
No response
Alternatives
No response
Anything else?
No response
Are you willing to submit a PR?
- [ ] I'm willing to submit a PR!