lhotari commented on code in PR #23930:
URL: https://github.com/apache/pulsar/pull/23930#discussion_r1947557042
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/qos/AsyncTokenBucket.java:
##########
@@ -177,8 +186,13 @@ private long consumeTokensAndMaybeUpdateTokensBalance(long
consumeTokens, boolea
pendingConsumedTokens.add(consumeTokens);
}
- // return Long.MIN_VALUE if the current value of tokens is unknown
due to the eventual consistency
- return Long.MIN_VALUE;
+ if (forceUpdateTokens) {
+ // return the current tokens balance without updating the
tokens and resetting the pendingConsumedTokens
+ return tokens - pendingConsumedTokens.sum();
Review Comment:
@nodece This code is now eliminated. I refactored AsyncTokenBucket to make
the eventual consistency of it more understandable. There's javadoc in
AsyncTokenBucketBuilder for the options to tune consistency since by default
AsyncTokenBucket is by default eventually consistent so that the token balance
is updated at most once during one "increment" which is configured with the
resolutionNanos setting. By default it's 16 milliseconds.
--
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]