From 223eea027beb1a7e95ff4519db181268b4636829 Mon Sep 17 00:00:00 2001 From: Zixuan Liu Date: Sat, 25 Jan 2025 02:44:16 +0800 Subject: [PATCH] [fix][client] Fix LoadManagerReport not found (#23886) --- pulsar-client-admin-shaded/pom.xml | 7 +++++++ pulsar-client-all/pom.xml | 7 +++++++ pulsar-client-shaded/pom.xml | 7 +++++++ .../pulsar/common/util/ObjectMapperFactory.java | 11 +---------- .../apache/pulsar/tests/integration/SmokeTest.java | 1 + .../apache/pulsar/tests/integration/SmokeTest.java | 1 + 6 files changed, 24 insertions(+), 10 deletions(-) diff --git a/pulsar-client-admin-shaded/pom.xml b/pulsar-client-admin-shaded/pom.xml index de54c3d049639..790691878f69c 100644 --- a/pulsar-client-admin-shaded/pom.xml +++ b/pulsar-client-admin-shaded/pom.xml @@ -367,6 +367,13 @@ org.apache.pulsar.policies org.apache.pulsar.shade.org.apache.pulsar.policies + + + org.apache.pulsar.policies.data.loadbalancer.LoadManagerReport + org.apache.pulsar.policies.data.loadbalancer.NamespaceBundleStats + org.apache.pulsar.policies.data.loadbalancer.ResourceUsage + org.apache.pulsar.policies.data.loadbalancer.ServiceLookupData + org.asynchttpclient diff --git a/pulsar-client-all/pom.xml b/pulsar-client-all/pom.xml index 4fec9ff51b894..322885892a5f4 100644 --- a/pulsar-client-all/pom.xml +++ b/pulsar-client-all/pom.xml @@ -427,6 +427,13 @@ org.apache.pulsar.policies org.apache.pulsar.shade.org.apache.pulsar.policies + + + org.apache.pulsar.policies.data.loadbalancer.LoadManagerReport + org.apache.pulsar.policies.data.loadbalancer.NamespaceBundleStats + org.apache.pulsar.policies.data.loadbalancer.ResourceUsage + org.apache.pulsar.policies.data.loadbalancer.ServiceLookupData + org.asynchttpclient diff --git a/pulsar-client-shaded/pom.xml b/pulsar-client-shaded/pom.xml index d8adacbe8a0bb..66032b19fbce4 100644 --- a/pulsar-client-shaded/pom.xml +++ b/pulsar-client-shaded/pom.xml @@ -339,6 +339,13 @@ org.apache.pulsar.policies org.apache.pulsar.shade.org.apache.pulsar.policies + + + org.apache.pulsar.policies.data.loadbalancer.LoadManagerReport + org.apache.pulsar.policies.data.loadbalancer.NamespaceBundleStats + org.apache.pulsar.policies.data.loadbalancer.ResourceUsage + org.apache.pulsar.policies.data.loadbalancer.ServiceLookupData + org.asynchttpclient diff --git a/pulsar-common/src/main/java/org/apache/pulsar/common/util/ObjectMapperFactory.java b/pulsar-common/src/main/java/org/apache/pulsar/common/util/ObjectMapperFactory.java index b737d68d5ea9f..33bc09725f62f 100644 --- a/pulsar-common/src/main/java/org/apache/pulsar/common/util/ObjectMapperFactory.java +++ b/pulsar-common/src/main/java/org/apache/pulsar/common/util/ObjectMapperFactory.java @@ -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; @@ -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); diff --git a/tests/pulsar-client-admin-shade-test/src/test/java/org/apache/pulsar/tests/integration/SmokeTest.java b/tests/pulsar-client-admin-shade-test/src/test/java/org/apache/pulsar/tests/integration/SmokeTest.java index b5c615b743cf7..0c4ffb283f5e7 100644 --- a/tests/pulsar-client-admin-shade-test/src/test/java/org/apache/pulsar/tests/integration/SmokeTest.java +++ b/tests/pulsar-client-admin-shade-test/src/test/java/org/apache/pulsar/tests/integration/SmokeTest.java @@ -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 diff --git a/tests/pulsar-client-all-shade-test/src/test/java/org/apache/pulsar/tests/integration/SmokeTest.java b/tests/pulsar-client-all-shade-test/src/test/java/org/apache/pulsar/tests/integration/SmokeTest.java index c5075118f08e3..bd2282703d804 100644 --- a/tests/pulsar-client-all-shade-test/src/test/java/org/apache/pulsar/tests/integration/SmokeTest.java +++ b/tests/pulsar-client-all-shade-test/src/test/java/org/apache/pulsar/tests/integration/SmokeTest.java @@ -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