lhotari opened a new pull request, #22891:
URL: https://github.com/apache/pulsar/pull/22891
### Motivation
The Pulsar Managed Ledger module contains an interface
`org.apache.bookkeeper.mledger.Position`.
The general recommendation of using interfaces is to depend on the interface
and not on implementation details.
However, this principle isn't followed in the code and there are a lot of
casting to `PositionImpl` in the code and tight coupling to the implementation.
Another problem with the current code base is that batch index
acknowledgement state ("ack set") is also coupled to the Position
implementation. This PR provides a solution where "ack set" handling is
decoupled from the `Position` interface without changing the architecture. It
will continue to be possible to create a Position instance that carries and
holds the "ack set" state for those execution paths that depend on this.
The motivation of this PR is to cleanup code before Pulsar 4.0 which is
scheduled for October. The current master branch will most likely become 4.0.
Since 4.0 will be the next LTS release, we would like to complete larger
changes in the code base before the release.
The Position interface isn't exposed in Pulsar end user applications.
Therefore this change can be considered as internal cleanup and refactoring
which doesn't necessary require a PIP decision before proceeding. I'll bring
this PR up to discussion on the mailing list regardless so this change doesn't
come as a surprise to other contributors.
Third party Pulsar broker plugins depending on managed ledger interfaces
will need to be adapted. However, this is a simple process. It's a simple
replacement of `PositionImpl` with `Position` and using `PositionFactory` for
the creation of Position instances.
After this PR, I'm planning to continue cleaning Managed Ledger the
`ManagedLedger` and `ManagedCursor` interfaces. This PR is a pre-requisite for
that work. Decoupling Pulsar core from Managed Ledger implementations will open
up ways to add new Managed Ledger implementations in the future and make it
pluggable.
### Modifications
- replace all usages of `PositionImpl` with `Position` and remove
`PositionImpl` completely to remove any confusion in the future.
- add `PositionFactory` for creating new instances so that there's no need
for coupling to `PositionImpl`
- decouple the "ack set" batch index acknowledgement state from `Position`
with a solution (`AckSetState`) that doesn't change the current architecture.
- it will continue to be possible to create a Position instance that
carries and holds the "ack set" state for those execution paths that depend on
this.
- make the default implementation of Position immutable so that thread
safety issues are avoided with the instance state
- there are separate implementations to support object recycling and
carrying "ack set" state
### Documentation
<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
- [ ] `doc` <!-- Your PR contains doc changes. -->
- [ ] `doc-required` <!-- Your PR changes impact docs and you will update
later -->
- [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
- [ ] `doc-complete` <!-- Docs have been already added -->
### Matching PR in forked repository
PR in forked repository: https://github.com/lhotari/pulsar/pull/193
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]