You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by ho...@apache.org on 2022/12/10 13:29:22 UTC
[pulsar] branch master updated: [improve][broker] Fast return if validalbe when getNextConsumerFromSameOrLowerLevel (#18800)
This is an automated email from the ASF dual-hosted git repository.
houxiaoyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new b6da6cfd4ee [improve][broker] Fast return if validalbe when getNextConsumerFromSameOrLowerLevel (#18800)
b6da6cfd4ee is described below
commit b6da6cfd4ee00dc37da928fdad9a8a874fe01924
Author: houxiaoyu <ho...@apache.org>
AuthorDate: Sat Dec 10 21:29:15 2022 +0800
[improve][broker] Fast return if validalbe when getNextConsumerFromSameOrLowerLevel (#18800)
---
.../broker/service/AbstractDispatcherMultipleConsumers.java | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractDispatcherMultipleConsumers.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractDispatcherMultipleConsumers.java
index 90e20790fae..9fc6b9581a3 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractDispatcherMultipleConsumers.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractDispatcherMultipleConsumers.java
@@ -189,10 +189,14 @@ public abstract class AbstractDispatcherMultipleConsumers extends AbstractBaseDi
* @return
*/
private int getNextConsumerFromSameOrLowerLevel(int currentRoundRobinIndex) {
+ Consumer currentRRConsumer = consumerList.get(currentRoundRobinIndex);
+ if (isConsumerAvailable(currentRRConsumer)) {
+ return currentRoundRobinIndex;
+ }
- int targetPriority = consumerList.get(currentRoundRobinIndex).getPriorityLevel();
- // use to do round-robin if can't find consumer from currentRR to last-consumer in list
- int scanIndex = currentRoundRobinIndex;
+ // scan the consumerList, if consumer in currentRoundRobinIndex is unavailable
+ int targetPriority = currentRRConsumer.getPriorityLevel();
+ int scanIndex = currentRoundRobinIndex + 1;
int endPriorityLevelIndex = currentRoundRobinIndex;
do {
Consumer scanConsumer = scanIndex < consumerList.size() ? consumerList.get(scanIndex)