-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[fix][broker] Fix get owned service units NPE #20625
[fix][broker] Fix get owned service units NPE #20625
Conversation
@heesung-sn Please help review this PR |
...src/main/java/org/apache/pulsar/broker/loadbalance/extensions/ExtensibleLoadManagerImpl.java
Show resolved
Hide resolved
Codecov Report
@@ Coverage Diff @@
## master #20625 +/- ##
=============================================
+ Coverage 31.93% 73.04% +41.11%
- Complexity 11779 31998 +20219
=============================================
Files 1498 1867 +369
Lines 114595 138663 +24068
Branches 12428 15237 +2809
=============================================
+ Hits 36591 101290 +64699
+ Misses 73158 29354 -43804
- Partials 4846 8019 +3173
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
Looks good.
... while I wonder what the caller does after get an empty set from getOwnedServiceUnits
? Retry?
Merging... |
public void addNamespaceBundleOwnershipListener(NamespaceBundleOwnershipListener... listeners) {
Objects.requireNonNull(listeners);
for (NamespaceBundleOwnershipListener listener : listeners) {
if (listener != null) {
bundleOwnershipListeners.add(listener);
}
}
getOwnedServiceUnits().forEach(bundle -> notifyNamespaceBundleOwnershipListener(bundle, listeners)); // <-- caller
} If the load manager has not started yet, it means we don’t have any ownership in the current broker, so it is fine to get an empty set here. After the load manager starts and has owned the bundle, it will notify all the listeners when they have ownership acquired by the current broker. |
@Demogorgon314 Thanks for your explanation! |
Motivation
When using KoP protocol, the KoP will
NamespaceService#addNamespaceBundleOwnershipListener
before the broker start, however, at this time, theExtensibleLoadManagerImpl
not start yet. So it will cause NPE.We should return an empty set when
ExtensibleLoadManagerImpl
does not start.Modifications
getOwnedServiceUnits
.Documentation
doc
doc-required
doc-not-needed
doc-complete