Skip to content

Commit

Permalink
[fix][client] Fix LoadManagerReport not found (#23886)
Browse files Browse the repository at this point in the history
  • Loading branch information
nodece authored Jan 24, 2025
1 parent 798a014 commit 223eea0
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 10 deletions.
7 changes: 7 additions & 0 deletions pulsar-client-admin-shaded/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,13 @@
<relocation>
<pattern>org.apache.pulsar.policies</pattern>
<shadedPattern>org.apache.pulsar.shade.org.apache.pulsar.policies</shadedPattern>
<!-- 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 -->
<excludes>
<exclude>org.apache.pulsar.policies.data.loadbalancer.LoadManagerReport</exclude>
<exclude>org.apache.pulsar.policies.data.loadbalancer.NamespaceBundleStats</exclude>
<exclude>org.apache.pulsar.policies.data.loadbalancer.ResourceUsage</exclude>
<exclude>org.apache.pulsar.policies.data.loadbalancer.ServiceLookupData</exclude>
</excludes>
</relocation>
<relocation>
<pattern>org.asynchttpclient</pattern>
Expand Down
7 changes: 7 additions & 0 deletions pulsar-client-all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,13 @@
<relocation>
<pattern>org.apache.pulsar.policies</pattern>
<shadedPattern>org.apache.pulsar.shade.org.apache.pulsar.policies</shadedPattern>
<!-- 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 -->
<excludes>
<exclude>org.apache.pulsar.policies.data.loadbalancer.LoadManagerReport</exclude>
<exclude>org.apache.pulsar.policies.data.loadbalancer.NamespaceBundleStats</exclude>
<exclude>org.apache.pulsar.policies.data.loadbalancer.ResourceUsage</exclude>
<exclude>org.apache.pulsar.policies.data.loadbalancer.ServiceLookupData</exclude>
</excludes>
</relocation>
<relocation>
<pattern>org.asynchttpclient</pattern>
Expand Down
7 changes: 7 additions & 0 deletions pulsar-client-shaded/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,13 @@
<relocation>
<pattern>org.apache.pulsar.policies</pattern>
<shadedPattern>org.apache.pulsar.shade.org.apache.pulsar.policies</shadedPattern>
<!-- 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 -->
<excludes>
<exclude>org.apache.pulsar.policies.data.loadbalancer.LoadManagerReport</exclude>
<exclude>org.apache.pulsar.policies.data.loadbalancer.NamespaceBundleStats</exclude>
<exclude>org.apache.pulsar.policies.data.loadbalancer.ResourceUsage</exclude>
<exclude>org.apache.pulsar.policies.data.loadbalancer.ServiceLookupData</exclude>
</excludes>
</relocation>
<relocation>
<pattern>org.asynchttpclient</pattern>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
import java.util.concurrent.atomic.AtomicReference;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ClassUtils;
import org.apache.pulsar.client.admin.internal.data.AuthPoliciesImpl;
import org.apache.pulsar.common.functions.FunctionConfig;
import org.apache.pulsar.common.functions.FunctionState;
Expand Down Expand Up @@ -263,15 +262,7 @@ private static void setAnnotationsModule(ObjectMapper mapper) {
mapper.addMixIn(FunctionState.class, JsonIgnorePropertiesMixIn.class);
mapper.addMixIn(Metrics.class, MetricsMixIn.class);

try {
// We look for LoadManagerReport first, then add deserializer to the module
// With shaded client, org.apache.pulsar.policies is relocated to
// org.apache.pulsar.shade.org.apache.pulsar.policies
ClassUtils.getClass("org.apache.pulsar.policies.data.loadbalancer.LoadManagerReport");
module.addDeserializer(LoadManagerReport.class, new LoadReportDeserializer());
} catch (ClassNotFoundException e) {
log.debug("Add LoadManagerReport deserializer failed because LoadManagerReport.class has been shaded", e);
}
module.addDeserializer(LoadManagerReport.class, new LoadReportDeserializer());

module.setAbstractTypes(resolver);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public void checkAdmin() throws PulsarClientException, PulsarAdminException {
expectedNamespacesList.add("public/default");
expectedNamespacesList.add("public/functions");
Assert.assertEquals(admin.namespaces().getNamespaces("public"), expectedNamespacesList);
admin.brokerStats().getLoadReport();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public void checkAdmin() throws PulsarClientException, PulsarAdminException {
expectedNamespacesList.add("public/default");
expectedNamespacesList.add("public/functions");
Assert.assertEquals(admin.namespaces().getNamespaces("public"), expectedNamespacesList);
admin.brokerStats().getLoadReport();
}

@Override
Expand Down

0 comments on commit 223eea0

Please sign in to comment.