Change default value of avgUsedTokens to zero to be more meaningful in DefaultController (#460)
This commit is contained in:
parent
5b260a9f75
commit
291742c171
|
|
@ -26,6 +26,8 @@ import com.alibaba.csp.sentinel.slots.block.flow.TrafficShapingController;
|
||||||
*/
|
*/
|
||||||
public class DefaultController implements TrafficShapingController {
|
public class DefaultController implements TrafficShapingController {
|
||||||
|
|
||||||
|
private static final int DEFAULT_AVG_USED_TOKENS = 0;
|
||||||
|
|
||||||
private double count;
|
private double count;
|
||||||
private int grade;
|
private int grade;
|
||||||
|
|
||||||
|
|
@ -51,9 +53,9 @@ public class DefaultController implements TrafficShapingController {
|
||||||
|
|
||||||
private int avgUsedTokens(Node node) {
|
private int avgUsedTokens(Node node) {
|
||||||
if (node == null) {
|
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) {
|
private void sleep(int timeMillis) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue