315157973 commented on code in PR #23774:
URL: https://github.com/apache/pulsar/pull/23774#discussion_r1901804803


##########
pulsar-broker/src/main/java/org/apache/pulsar/common/naming/ConsistentHashingTopicBundleAssigner.java:
##########
@@ -23,18 +23,26 @@
 import org.apache.pulsar.broker.PulsarService;
 
 public class ConsistentHashingTopicBundleAssigner implements 
TopicBundleAssignmentStrategy {
+    private PulsarService pulsar;
     @Override
     public NamespaceBundle findBundle(TopicName topicName, NamespaceBundles 
namespaceBundles) {
-        long hashCode = Hashing.crc32().hashString(topicName.toString(), 
StandardCharsets.UTF_8).padToLong();
-        NamespaceBundle bundle = namespaceBundles.getBundle(hashCode);
+        NamespaceBundle bundle = 
namespaceBundles.getBundle(getHashCode(topicName.toString()));
         if (topicName.getDomain().equals(TopicDomain.non_persistent)) {
             bundle.setHasNonPersistentTopic(true);
         }
         return bundle;
     }
 
+    @Override
+    public long getHashCode(String name) {
+        return 
pulsar.getNamespaceService().getNamespaceBundleFactory().getHashFunc()
+                .hashString(name, StandardCharsets.UTF_8)
+                .padToLong();
+    }
+
     @Override
     public void init(PulsarService pulsarService) {
+        this.pulsar = pulsarService;

Review Comment:
   We can hold a reference to HashFunc here



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to