You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/05/06 09:43:48 UTC

[GitHub] [pulsar] gaozhangmin commented on a diff in pull request #15216: [PIP-74] Support consumer client memory limit

gaozhangmin commented on code in PR #15216:
URL: https://github.com/apache/pulsar/pull/15216#discussion_r866663655


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/MemoryLimitController.java:
##########
@@ -45,11 +60,18 @@ public boolean tryReserveMemory(long size) {
             }
 
             if (currentUsage.compareAndSet(current, newUsage)) {
+                checkTrigger(current, newUsage);
                 return true;
             }
         }
     }
 
+    private void checkTrigger(long prevUsage, long newUsage) {
+        if (newUsage >= triggerThreshold && prevUsage < triggerThreshold && trigger != null) {

Review Comment:
   Would this be better?
   `if (trigger != null && newUsage >= triggerThreshold && prevUsage < triggerThreshold) `



-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org