Skip to content

Commit

Permalink
[fix][client] Fix LoadManagerReport not found (#23886)
Browse files Browse the repository at this point in the history
(cherry picked from commit 223eea0)
  • Loading branch information
nodece committed Jan 25, 2025
1 parent 2609acd commit da4db5e
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 @@ -345,6 +345,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 @@ -405,6 +405,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 @@ -317,6 +317,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 @@ -260,15 +259,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 @@ -86,6 +86,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 @@ -86,6 +86,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 da4db5e

Please sign in to comment.