Browse Source

Change default value of avgUsedTokens to zero to be more meaningful in DefaultController (#460)

master
mjaow Eric Zhao 5 years ago
parent
commit
291742c171
1 changed files with 4 additions and 2 deletions
  1. +4
    -2
      sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/controller/DefaultController.java

+ 4
- 2
sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/controller/DefaultController.java View File

@@ -26,6 +26,8 @@ import com.alibaba.csp.sentinel.slots.block.flow.TrafficShapingController;
*/
public class DefaultController implements TrafficShapingController {

private static final int DEFAULT_AVG_USED_TOKENS = 0;

private double count;
private int grade;

@@ -51,9 +53,9 @@ public class DefaultController implements TrafficShapingController {

private int avgUsedTokens(Node node) {
if (node == null) {
return -1;
return DEFAULT_AVG_USED_TOKENS;
}
return grade == RuleConstant.FLOW_GRADE_THREAD ? node.curThreadNum() : (int)node.passQps();
return grade == RuleConstant.FLOW_GRADE_THREAD ? node.curThreadNum() : (int) node.passQps();
}

private void sleep(int timeMillis) {


Loading…
Cancel
Save