Skip to content

Commit 159b721

Browse files
nodecenikhil-ctds
authored andcommitted
[fix][client] Fix LoadManagerReport not found (apache#23886)
(cherry picked from commit 223eea0) (cherry picked from commit da4db5e)
1 parent 3921742 commit 159b721

File tree

6 files changed

+24
-10
lines changed

6 files changed

+24
-10
lines changed

pulsar-client-admin-shaded/pom.xml

+7
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,13 @@
348348
<relocation>
349349
<pattern>org.apache.pulsar.policies</pattern>
350350
<shadedPattern>org.apache.pulsar.shade.org.apache.pulsar.policies</shadedPattern>
351+
<!-- exclude references to unshaded classes and interfaces in https://github.com/apache/pulsar/tree/master/pulsar-client-admin-api/src/main/java/org/apache/pulsar/policies/data/loadbalancer -->
352+
<excludes>
353+
<exclude>org.apache.pulsar.policies.data.loadbalancer.LoadManagerReport</exclude>
354+
<exclude>org.apache.pulsar.policies.data.loadbalancer.NamespaceBundleStats</exclude>
355+
<exclude>org.apache.pulsar.policies.data.loadbalancer.ResourceUsage</exclude>
356+
<exclude>org.apache.pulsar.policies.data.loadbalancer.ServiceLookupData</exclude>
357+
</excludes>
351358
</relocation>
352359
<relocation>
353360
<pattern>org.asynchttpclient</pattern>

pulsar-client-all/pom.xml

+7
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,13 @@
405405
<relocation>
406406
<pattern>org.apache.pulsar.policies</pattern>
407407
<shadedPattern>org.apache.pulsar.shade.org.apache.pulsar.policies</shadedPattern>
408+
<!-- exclude references to unshaded classes and interfaces in https://github.com/apache/pulsar/tree/master/pulsar-client-admin-api/src/main/java/org/apache/pulsar/policies/data/loadbalancer -->
409+
<excludes>
410+
<exclude>org.apache.pulsar.policies.data.loadbalancer.LoadManagerReport</exclude>
411+
<exclude>org.apache.pulsar.policies.data.loadbalancer.NamespaceBundleStats</exclude>
412+
<exclude>org.apache.pulsar.policies.data.loadbalancer.ResourceUsage</exclude>
413+
<exclude>org.apache.pulsar.policies.data.loadbalancer.ServiceLookupData</exclude>
414+
</excludes>
408415
</relocation>
409416
<relocation>
410417
<pattern>org.asynchttpclient</pattern>

pulsar-client-shaded/pom.xml

+7
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,13 @@
318318
<relocation>
319319
<pattern>org.apache.pulsar.policies</pattern>
320320
<shadedPattern>org.apache.pulsar.shade.org.apache.pulsar.policies</shadedPattern>
321+
<!-- exclude references to unshaded classes and interfaces in https://github.com/apache/pulsar/tree/master/pulsar-client-admin-api/src/main/java/org/apache/pulsar/policies/data/loadbalancer -->
322+
<excludes>
323+
<exclude>org.apache.pulsar.policies.data.loadbalancer.LoadManagerReport</exclude>
324+
<exclude>org.apache.pulsar.policies.data.loadbalancer.NamespaceBundleStats</exclude>
325+
<exclude>org.apache.pulsar.policies.data.loadbalancer.ResourceUsage</exclude>
326+
<exclude>org.apache.pulsar.policies.data.loadbalancer.ServiceLookupData</exclude>
327+
</excludes>
321328
</relocation>
322329
<relocation>
323330
<pattern>org.asynchttpclient</pattern>

pulsar-common/src/main/java/org/apache/pulsar/common/util/ObjectMapperFactory.java

+1-10
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
3333
import java.util.concurrent.atomic.AtomicReference;
3434
import lombok.extern.slf4j.Slf4j;
35-
import org.apache.commons.lang3.ClassUtils;
3635
import org.apache.pulsar.client.admin.internal.data.AuthPoliciesImpl;
3736
import org.apache.pulsar.common.functions.FunctionConfig;
3837
import org.apache.pulsar.common.functions.FunctionState;
@@ -260,15 +259,7 @@ private static void setAnnotationsModule(ObjectMapper mapper) {
260259
mapper.addMixIn(FunctionState.class, JsonIgnorePropertiesMixIn.class);
261260
mapper.addMixIn(Metrics.class, MetricsMixIn.class);
262261

263-
try {
264-
// We look for LoadManagerReport first, then add deserializer to the module
265-
// With shaded client, org.apache.pulsar.policies is relocated to
266-
// org.apache.pulsar.shade.org.apache.pulsar.policies
267-
ClassUtils.getClass("org.apache.pulsar.policies.data.loadbalancer.LoadManagerReport");
268-
module.addDeserializer(LoadManagerReport.class, new LoadReportDeserializer());
269-
} catch (ClassNotFoundException e) {
270-
log.debug("Add LoadManagerReport deserializer failed because LoadManagerReport.class has been shaded", e);
271-
}
262+
module.addDeserializer(LoadManagerReport.class, new LoadReportDeserializer());
272263

273264
module.setAbstractTypes(resolver);
274265

tests/pulsar-client-admin-shade-test/src/test/java/org/apache/pulsar/tests/integration/SmokeTest.java

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public void checkAdmin() throws PulsarClientException, PulsarAdminException {
8686
expectedNamespacesList.add("public/default");
8787
expectedNamespacesList.add("public/functions");
8888
Assert.assertEquals(admin.namespaces().getNamespaces("public"), expectedNamespacesList);
89+
admin.brokerStats().getLoadReport();
8990
}
9091

9192
@Override

tests/pulsar-client-all-shade-test/src/test/java/org/apache/pulsar/tests/integration/SmokeTest.java

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public void checkAdmin() throws PulsarClientException, PulsarAdminException {
8686
expectedNamespacesList.add("public/default");
8787
expectedNamespacesList.add("public/functions");
8888
Assert.assertEquals(admin.namespaces().getNamespaces("public"), expectedNamespacesList);
89+
admin.brokerStats().getLoadReport();
8990
}
9091

9192
@Override

0 commit comments

Comments
 (0)