diff --git a/sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/flow/ClusterFlowChecker.java b/sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/flow/ClusterFlowChecker.java index df69bef9dc..36aa2f8648 100644 --- a/sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/flow/ClusterFlowChecker.java +++ b/sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/flow/ClusterFlowChecker.java @@ -64,9 +64,9 @@ static TokenResult acquireClusterToken(/*@Valid*/ FlowRule rule, int acquireCoun return new TokenResult(TokenResultStatus.FAIL); } - double latestQps = metric.getAvg(ClusterFlowEvent.PASS); + double latestSum = metric.getSum(ClusterFlowEvent.PASS); double globalThreshold = calcGlobalThreshold(rule) * ClusterServerConfigManager.getExceedCount(); - double nextRemaining = globalThreshold - latestQps - acquireCount; + double nextRemaining = globalThreshold - latestSum - acquireCount; if (nextRemaining >= 0) { // TODO: checking logic and metric operation should be separated. @@ -83,8 +83,8 @@ static TokenResult acquireClusterToken(/*@Valid*/ FlowRule rule, int acquireCoun } else { if (prioritized) { // Try to occupy incoming buckets. - double occupyAvg = metric.getAvg(ClusterFlowEvent.WAITING); - if (occupyAvg <= ClusterServerConfigManager.getMaxOccupyRatio() * globalThreshold) { + double occupySum = metric.getSum(ClusterFlowEvent.WAITING); + if (occupySum <= ClusterServerConfigManager.getMaxOccupyRatio() * globalThreshold) { int waitInMs = metric.tryOccupyNext(ClusterFlowEvent.PASS, acquireCount, globalThreshold); // waitInMs > 0 indicates pre-occupy incoming buckets successfully. if (waitInMs > 0) { diff --git a/sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/flow/ClusterParamFlowChecker.java b/sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/flow/ClusterParamFlowChecker.java index cd8ab8a324..9f1ecebeb0 100644 --- a/sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/flow/ClusterParamFlowChecker.java +++ b/sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/flow/ClusterParamFlowChecker.java @@ -59,9 +59,9 @@ static TokenResult acquireClusterToken(ParamFlowRule rule, int count, Collection boolean hasPassed = true; Object blockObject = null; for (Object value : values) { - double latestQps = metric.getAvg(value); + double latestSum = metric.getSum(value); double threshold = calcGlobalThreshold(rule, value); - double nextRemaining = threshold - latestQps - count; + double nextRemaining = threshold - latestSum - count; remaining = nextRemaining; if (nextRemaining < 0) { hasPassed = false;