-
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][client] Fix LoadManagerReport not found #23886
Conversation
pulsar-common/src/main/java/org/apache/pulsar/common/util/ObjectMapperFactory.java
Show resolved
Hide resolved
...sar-client-admin-shade-test/src/test/java/org/apache/pulsar/tests/integration/SmokeTest.java
Show resolved
Hide resolved
...ulsar-client-all-shade-test/src/test/java/org/apache/pulsar/tests/integration/SmokeTest.java
Show resolved
Hide resolved
b672fbf
to
6354232
Compare
6354232
to
a2aef7b
Compare
/pulsarbot rerun-failure-checks |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #23886 +/- ##
============================================
+ Coverage 73.57% 74.24% +0.67%
+ Complexity 32624 32241 -383
============================================
Files 1877 1853 -24
Lines 139502 143634 +4132
Branches 15299 16317 +1018
============================================
+ Hits 102638 106642 +4004
+ Misses 28908 28623 -285
- Partials 7956 8369 +413
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.
It looks like that shading changes should be reverted and there should be logic in LoadReportDeserializer to handle the unshaded classname that comes from the broker:
Line 39 in 798a014
if ((root.has("loadReportType") && root.get("loadReportType").asText().equals(LoadReport.loadReportType)) |
suggested fix
public LoadManagerReport deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
throws IOException, JsonProcessingException {
ObjectReader reader = ObjectMapperFactory.getMapper().reader();
ObjectNode root = reader.readTree(jsonParser);
String loadReportType = LoadReport.loadReportType;
// remove possible shading prefix
String loadReportTypeUnshaded = LoadReport.loadReportType
.replaceFirst("^.+\\." + Pattern.quote(LoadReport.class.getPackageName()),
LoadReport.class.getPackageName());
if ((root.has("loadReportType")
&& (root.get("loadReportType").asText().equals(loadReportType))
|| root.get("loadReportType").asText().equals(loadReportTypeUnshaded))
|| (root.has("underLoaded"))) {
return reader.treeToValue(root, LoadReport.class);
} else {
return reader.treeToValue(root, LocalBrokerData.class);
}
}
Both the interface ( To resolve this, we should ensure that the interface is also included in the shaded package, keeping it consistent with the implementation. Alternatively, as a simpler solution, we could consider removing that shading the @lhotari What's your opinion? |
BTW, it works fine in our private pulsar. We are using the |
@nodece I've suggested a fix in #23886 (review) . Have you checked that? |
Public interfaces shouldn't be shaded. Implementation classes should be shaded. That's the original intent. |
The interface classes present here should be excluded from shading: https://github.com/apache/pulsar/tree/master/pulsar-client-admin-api/src/main/java/org/apache/pulsar/policies/data/loadbalancer Something like <relocation>
<pattern>org.apache.pulsar.policies</pattern>
<shadedPattern>org.apache.pulsar.shade.org.apache.pulsar.policies</shadedPattern>
<excludes>
<exclude>org\.apache\.pulsar\.policies\.data\.loadbalancer\.(LoadManagerReport|NamespaceBundleStats|ResourceUsage|ServiceLookupData)($.*)?</exclude>
</excludes>
</relocation> |
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.
I added some more details about how to resolve the problem.
0951644
to
57ffab5
Compare
Signed-off-by: Zixuan Liu <[email protected]>
57ffab5
to
89e0d49
Compare
This is an error fix, I still got the same error.
I understand that this is the correct way. Your changes are correct.
The
It doesn't work, so I use the following code instead of that:
@lhotari Thank you! |
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.
LGTM
@nodece Oh yes, missed that detail. |
(cherry picked from commit 223eea0)
(cherry picked from commit 223eea0)
(cherry picked from commit 223eea0)
Motivation
When using the
pulsar-client-all
andpulsar-client-admin
libraries, theadmin.brokerStats().getLoadReport()
doesn't work:We got this error because the shade plugin relocates the
org.apache.pulsar.policies.data.loadbalancer.*
package, andorg.apache.pulsar.policies.data.loadbalancer.LoadManagerReport
didn't added to the shaded-jar.Modifications
org.apache.pulsar.policies
is meaningless, so remove that from the shade configuration.Documentation
doc
doc-required
doc-not-needed
doc-complete