From 3d57043c9b1e1c5dd19505fd07044708bc4c7c82 Mon Sep 17 00:00:00 2001 From: rayluoluo Date: Mon, 13 Jan 2025 21:22:40 +0800 Subject: [PATCH] [improve][broker] Improve the extensibility of the TopicBundleAssignmentStrategy interface class (#23773) --- .../naming/ConsistentHashingTopicBundleAssigner.java | 1 - .../pulsar/common/naming/NamespaceBundleFactory.java | 1 - .../common/naming/TopicBundleAssignmentStrategy.java | 2 +- .../common/naming/TopicBundleAssignmentStrategyTest.java | 8 -------- 4 files changed, 1 insertion(+), 11 deletions(-) diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/common/naming/ConsistentHashingTopicBundleAssigner.java b/pulsar-broker/src/main/java/org/apache/pulsar/common/naming/ConsistentHashingTopicBundleAssigner.java index 8126fa5b3ba5a..04f85a56efaed 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/common/naming/ConsistentHashingTopicBundleAssigner.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/common/naming/ConsistentHashingTopicBundleAssigner.java @@ -22,7 +22,6 @@ import java.nio.charset.StandardCharsets; import java.util.Optional; import org.apache.pulsar.broker.PulsarService; -import org.apache.pulsar.broker.ServiceConfiguration; import org.apache.pulsar.broker.namespace.NamespaceService; public class ConsistentHashingTopicBundleAssigner implements TopicBundleAssignmentStrategy { diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/common/naming/NamespaceBundleFactory.java b/pulsar-broker/src/main/java/org/apache/pulsar/common/naming/NamespaceBundleFactory.java index c4f0ada491236..bbace4e16ba43 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/common/naming/NamespaceBundleFactory.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/common/naming/NamespaceBundleFactory.java @@ -29,7 +29,6 @@ import com.google.common.collect.Range; import com.google.common.hash.HashFunction; import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.time.Duration; import java.util.Collections; import java.util.HashMap; diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/common/naming/TopicBundleAssignmentStrategy.java b/pulsar-broker/src/main/java/org/apache/pulsar/common/naming/TopicBundleAssignmentStrategy.java index e5e0e5bd857a8..07dd63f73536a 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/common/naming/TopicBundleAssignmentStrategy.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/common/naming/TopicBundleAssignmentStrategy.java @@ -23,7 +23,7 @@ import org.apache.pulsar.broker.PulsarService; public interface TopicBundleAssignmentStrategy { - NamespaceBundle findBundle(TopicName topicName, NamespaceBundles namespaceBundles); + NamespaceBundle findBundle(TopicName topicName, NamespaceBundles namespaceBundles); default long calculateBundleHashCode(TopicName topicName) { return Hashing.crc32().hashString(topicName.toString(), StandardCharsets.UTF_8).padToLong(); diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/common/naming/TopicBundleAssignmentStrategyTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/common/naming/TopicBundleAssignmentStrategyTest.java index d03be7a7c4e5a..7738a7396642c 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/common/naming/TopicBundleAssignmentStrategyTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/common/naming/TopicBundleAssignmentStrategyTest.java @@ -23,16 +23,11 @@ import static org.mockito.Mockito.when; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; - import com.google.common.base.Charsets; import com.google.common.collect.BoundType; import com.google.common.collect.Range; - import com.google.common.hash.Hashing; import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.nio.charset.StandardCharsets; import java.util.HashSet; import java.util.Optional; import java.util.Set; @@ -44,10 +39,7 @@ import org.apache.pulsar.common.policies.data.LocalPolicies; import org.apache.pulsar.common.policies.data.PoliciesUtil; import org.apache.pulsar.metadata.api.extended.MetadataStoreExtended; -import org.mockito.Mockito; -import org.mockito.internal.util.MockUtil; import org.testng.Assert; -import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test;