-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor dispatcher's getting next consumer with consumer priority #367
Conversation
…teration on consumer-list
do { | ||
int priorityLevel = consumerList.get(currentConsumerRoundRobinIndex).getPriorityLevel() | ||
- consumerList.get(resultingAvailableConsumerIndex).getPriorityLevel(); | ||
int currentRoundRobinConsumerPriority = consumerList.get(currentConsumerRoundRobinIndex).getPriorityLevel(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we keep getNextConsumer() as private/protected method? This and other utility method assumes we are in synchronization block. Else array location could be invalid when it changes behind the scene
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, updated it with private
.
*/ | ||
private int getNextConsumerFromSameOrLowerLevel(int currentRoundRobinIndex) { | ||
|
||
int targetPriority = consumerList.get(currentConsumerRoundRobinIndex).getPriorityLevel(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currentRoundRobinIndex instead of currentConsumerRoundRobinIndex
ba78708
to
7f2d472
Compare
*/ | ||
private int getNextConsumerFromSameOrLowerLevel(int currentRoundRobinIndex) { | ||
|
||
int targetPriority = consumerList.get(currentRoundRobinIndex).getPriorityLevel(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we break this into a sub method to give a consumer for a specific priority? e.g: getConsumerForPriority(priority, currentRRIndex)?
It should wrap around for that priority(if in the middle of the priority list) and return the index for available consumer or -1.
We can add a for loop for each remaining priority from currentPriority till maxPriority known to us).
Something like below:
foreach(priority = consumerList.get(currentRoundRobinIndex).getPriorityLevel(); priority<consumerList.get(consumerList.size()-1).getPriorityLevel(); priority++) {
consumerIndex = getConsumerForPriority(priority, currentRRIndex);
if( consumerIndex != -1) {
return consumerIndex;
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as we discussed: getNextConsumerFromSameOrLowerLevel
checks consumer from current-level and saves the index of the next level in case we don't find consumer in the current-level and then does linear search in lower-level which is one loop so, as we discuss we will keep it in the same method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current logic should also work.
7f2d472
to
6dee55b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…s enabled (apache#372) Fixes apache#367 ### Motivation Send delay message individually even batching is enabled. ### Modifications 1. flush batching messages immediately when a new delay message is received 2. reset deliverAtTime metadata of `BatchBuilder`
Motivation
Refactoring #364 to have simplicity in finding next-available consumer at dispatcher by considering consumer-priority level.
Result
No functional change.