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


##########
pulsar-broker/src/main/java/org/apache/pulsar/common/naming/ConsistentHashingTopicBundleAssigner.java:
##########
@@ -18,23 +18,42 @@
  */
 package org.apache.pulsar.common.naming;
 
-import com.google.common.hash.Hashing;
+import com.google.common.hash.HashFunction;
 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 {
+    private PulsarService pulsar;
+
+    private volatile HashFunction hashFunction;
+
     @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(calculateBundleHashCode(topicName));
         if (topicName.getDomain().equals(TopicDomain.non_persistent)) {
             bundle.setHasNonPersistentTopic(true);
         }
         return bundle;
     }
 
+    @Override
+    public long calculateBundleHashCode(TopicName topicName) {
+        if (hashFunction == null) {

Review Comment:
   Change as suggested, thank you. @315157973 



-- 
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