-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[improve][misc] Replace dependencies on PositionImpl with Position interface #22891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… casts everywhere
a6baa92 to
5586660
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #22891 +/- ##
============================================
- Coverage 73.57% 73.27% -0.31%
- Complexity 32624 33028 +404
============================================
Files 1877 1896 +19
Lines 139502 142008 +2506
Branches 15299 15565 +266
============================================
+ Hits 102638 104050 +1412
- Misses 28908 29942 +1034
- Partials 7956 8016 +60
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
This change is so massive that I think docs are in fact required to explain all of the changes in a TL/DR manner. |
merlimat
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nicely done!
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/Position.java
Outdated
Show resolved
Hide resolved
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/Position.java
Outdated
Show resolved
Hide resolved
@dave2wave The reason why this change is massive is mainly due to the PositionImpl -> Position/PositionFactory changes. The PR description already contains the explanation in a TL/DR manner in "Modifications". |
Co-authored-by: Matteo Merli <mmerli@apache.org>
hangc0276
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job!
…terface (apache#22891) Co-authored-by: Matteo Merli <mmerli@apache.org>
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
PositionImplin 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
Positioninterface 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
PositionImplwithPositionand usingPositionFactoryfor the creation of Position instances.After this PR, I'm planning to continue cleaning Managed Ledger the
ManagedLedgerandManagedCursorinterfaces. 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
PositionImplwithPositionand removePositionImplcompletely to remove any confusion in the future.PositionFactoryfor creating new instances so that there's no need for coupling toPositionImplPositionwith a solution (AckSetState) that doesn't change the current architecture.Documentation
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository: lhotari#193