Skip to content

Eliminate special process logic for ManagedLedgerImpl #25019

Description

@BewareMyPower

Search before reporting

  • I searched in the issues and found nothing similar.

Motivation

See #25016 (comment)

Since #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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/enhancementThe enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions