[fix][broker]Make LedgerOffloaderFactory can load the old nar. - #19913
Conversation
| Map<String, String> userMetadata, | ||
| OrderedScheduler scheduler) | ||
| throws IOException { | ||
| return create(offloadPolicies, userMetadata, scheduler, null); |
There was a problem hiding this comment.
After this change, Is it possible to throw a NullPointerEx using the variable offloaderStats?
Such as line-227 above or other places.
There was a problem hiding this comment.
Thanks for your reminder. Here we shouldn't make the method default. This method won't invoke in pulsar directly. In the pulsar master branch, it only invokes the method with the param offloaderStats. This method is compatible with the nar package, let the user implements by themselves.
|
@poorbarcode Could you help to review it again, thanks! |
| Map<String, String> userMetadata, | ||
| OrderedScheduler scheduler, | ||
| LedgerOffloaderStats offloaderStats) | ||
| throws IOException; |
There was a problem hiding this comment.
Since this method T create(offloadPolicies, userMetadata, scheduler, offloaderStats), the changes in #13833 can not guarantee forward compatibility, right?
There was a problem hiding this comment.
There are four scenarios:
old nar & old broker: I think it will work.old nar & new broker: It will not work, and we do not guarantee forward compatibility. So it is okay.new nar & old broker: The broker will call the method without@param offloaderStats.I think it will work.- we should make the method without
@param offloaderStatsnon-default.
- we should make the method without
new nar & new brokerI think it will work.
All things are good.
| Map<String, String> userMetadata, | ||
| OrderedScheduler scheduler, | ||
| LedgerOffloaderStats offloaderStats) | ||
| throws IOException; |
There was a problem hiding this comment.
There are four scenarios:
old nar & old broker: I think it will work.old nar & new broker: It will not work, and we do not guarantee forward compatibility. So it is okay.new nar & old broker: The broker will call the method without@param offloaderStats.I think it will work.- we should make the method without
@param offloaderStatsnon-default.
- we should make the method without
new nar & new brokerI think it will work.
All things are good.
|
@codelipenghui @Technoboy- @poorbarcode I think this PR needs to be cherry-picked to branch-2.11 because it's for backporting the old interface. |
After #13833, we change the signature of LedgerOffloaderFactory#create. But some users may use the old version LedgerOffloaderFactory in the offloader nar, when pulsar load the offloader nar, it will use the LedgerOffloaderFactory in the offloader nar, the LedgerOffloaderFactory#create has no param offloaderStats. Modifications: Make LedgerOffloaderFactory can load the old nar.
Done |
The fork pr: horizonzy#12
Motivation
After #13833, we change the signature of LedgerOffloaderFactory#create.
Before: no offloaderStats.
After: add offloaderStats.
And in PulsarService#createManagedLedgerOffloader line_1402, it changes the way to create an offloader.
Before: no offloaderStats
After: add offloaderStats
But some users may use the old version LedgerOffloaderFactory in the offloader nar, when pulsar load the offloader nar, it will use the LedgerOffloaderFactory in the offloader nar, the LedgerOffloaderFactory#create has no param
offloaderStats. Then it will throw an exception as follows:So we should make LedgerOffloaderFactory#create compatible with the previous version, and revert the origin signature to LedgerOffloaderFactory for compatibility.
After this PR, the user upgrades the
managed-ledgerdependency(LedgerOffloaderFactory is defined inmanaged-ledger). So the user offloader nar LedgerOffloaderFactory has both methods. One is with offloaderStats, another one is without offloaderStats.If the pulsar is the old version, it loads the offloader nar, and using LedgerOffloaderFactory#create without offloadStats to create offloader. It works.
If the pulsar is the new version, it loads the offloader nar, and using LedgerOffloaderFactory#create with offloadStats to create the offloader. It also works.
Modifications
Verifying this change
(Please pick either of the following options)
This change is a trivial rework / code cleanup without any test coverage.
(or)
This change is already covered by existing tests, such as (please describe tests).
(or)
This change added tests and can be verified as follows:
(example:)
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository: