[improve][broker] Fast Return the method computeLocalQuota in ResourceQuotaCalculatorImpl
@@ -31,12 +31,6 @@ public class ResourceQuotaCalculatorImpl implements ResourceQuotaCalculator {
// ToDo: work out the initial conditions: we may allow a small number of "first few iterations" to go
// unchecked as we get some history of usage, or follow some other "TBD" method.
- long totalUsage = 0;
-
- for (long usage : allUsages) {
- totalUsage += usage;
- }
-
if (confUsage < 0) {
// This can happen if the RG is not configured with this particular limit (message or byte count) yet.
val retVal = -1;
@@ -47,6 +41,11 @@ public class ResourceQuotaCalculatorImpl implements ResourceQuotaCalculator {
return retVal;
}
+ long totalUsage = 0;
+ for (long usage : allUsages) {
+ totalUsage += usage;
+ }
+
if (myUsage < 0 || totalUsage < 0) {
String errMesg = String.format("Local usage (%d) or total usage (%d) is negative",
myUsage, totalUsage);
