mattisonchao commented on code in PR #19502:
URL: https://github.com/apache/pulsar/pull/19502#discussion_r1105194863


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractDispatcherSingleActiveConsumer.java:
##########
@@ -136,6 +139,24 @@ protected boolean pickAndScheduleActiveConsumer() {
         }
     }
 
+    private int peekConsumerIndexFromHashRing(NavigableMap<Integer, Integer> 
hashRing) {
+        int hash = Murmur3Hash32.getInstance().makeHash(topicName);
+        Map.Entry<Integer, Integer> ceilingEntry = hashRing.ceilingEntry(hash);
+        return ceilingEntry != null ? ceilingEntry.getValue() : 
hashRing.firstEntry().getValue();
+    }
+
+    private NavigableMap<Integer, Integer> makeHashRing(int consumerSize) {
+        NavigableMap<Integer, Integer> hashRing = new TreeMap<>();
+        for (int i = 0; i < consumerSize; i++) {
+            for (int j = 0; j < CONSUMER_CONSISTENT_HASH_REPLICAS; j++) {
+                String key = consumers.get(i).consumerName() + j;
+                int hash = 
Murmur3_32Hash.getInstance().makeHash(key.getBytes());
+                hashRing.put(hash, i);

Review Comment:
   I see.



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