mattisonchao commented on code in PR #19502:
URL: https://github.com/apache/pulsar/pull/19502#discussion_r1104729917
##########
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;
Review Comment:
It's a little distinction with `key_shared` subscription. The `key_shared`
subscription will call loop once when adding a new consumer.
But there will be `loop * consumers` times when adding a new consumer. It
means when we add a new consumer we should iterator all consumers. And this
number increases as the consumer increases. (Extremes)
--
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]