Set default FlowRule.grade to RuleConstant.FLOW_GRADE_QPS
This commit is contained in:
parent
d727f1cfb0
commit
5d5b19e9d7
|
|
@ -124,7 +124,7 @@ public class AuthorityRuleManager {
|
||||||
Map<String, List<AuthorityRule>> newRuleMap = new ConcurrentHashMap<String, List<AuthorityRule>>();
|
Map<String, List<AuthorityRule>> newRuleMap = new ConcurrentHashMap<String, List<AuthorityRule>>();
|
||||||
for (AuthorityRule rule : list) {
|
for (AuthorityRule rule : list) {
|
||||||
if (StringUtil.isBlank(rule.getLimitApp())) {
|
if (StringUtil.isBlank(rule.getLimitApp())) {
|
||||||
rule.setLimitApp(FlowRule.DEFAULT);
|
rule.setLimitApp(FlowRule.LIMIT_APP_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
String identity = rule.getResource();
|
String identity = rule.getResource();
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ public class DegradeRuleManager {
|
||||||
|
|
||||||
for (DegradeRule rule : list) {
|
for (DegradeRule rule : list) {
|
||||||
if (StringUtil.isBlank(rule.getLimitApp())) {
|
if (StringUtil.isBlank(rule.getLimitApp())) {
|
||||||
rule.setLimitApp(FlowRule.DEFAULT);
|
rule.setLimitApp(FlowRule.LIMIT_APP_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
String identity = rule.getResource();
|
String identity = rule.getResource();
|
||||||
|
|
|
||||||
|
|
@ -40,20 +40,25 @@ import com.alibaba.csp.sentinel.slots.clusterbuilder.ClusterBuilderSlot;
|
||||||
*/
|
*/
|
||||||
public class FlowRule extends AbstractRule {
|
public class FlowRule extends AbstractRule {
|
||||||
|
|
||||||
public static final String DEFAULT = "default";
|
public static final String LIMIT_APP_DEFAULT = "default";
|
||||||
public static final String OTHER = "other";
|
public static final String LIMIT_APP_OTHER = "other";
|
||||||
|
|
||||||
|
public FlowRule(){
|
||||||
|
super();
|
||||||
|
setLimitApp(LIMIT_APP_DEFAULT);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The threshold type of flow control (0: thread count, 1: QPS).
|
* The threshold type of flow control (0: thread count, 1: QPS).
|
||||||
*/
|
*/
|
||||||
private int grade;
|
private int grade = RuleConstant.FLOW_GRADE_QPS;
|
||||||
|
|
||||||
private double count;
|
private double count;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 0为直接限流;1为关联限流;2为链路限流
|
* 0为直接限流;1为关联限流;2为链路限流
|
||||||
*/
|
*/
|
||||||
private int strategy;
|
private int strategy = RuleConstant.STRATEGY_DIRECT;
|
||||||
|
|
||||||
private String refResource;
|
private String refResource;
|
||||||
|
|
||||||
|
|
@ -181,7 +186,7 @@ public class FlowRule extends AbstractRule {
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (limitApp.equals(DEFAULT)) {
|
} else if (LIMIT_APP_DEFAULT.equals(limitApp)) {
|
||||||
if (strategy == RuleConstant.STRATEGY_DIRECT) {
|
if (strategy == RuleConstant.STRATEGY_DIRECT) {
|
||||||
return node.getClusterNode();
|
return node.getClusterNode();
|
||||||
}
|
}
|
||||||
|
|
@ -201,7 +206,7 @@ public class FlowRule extends AbstractRule {
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (limitApp.equals(OTHER) && FlowRuleManager.isOtherOrigin(origin, getResource())) {
|
} else if (LIMIT_APP_OTHER.equals(limitApp) && FlowRuleManager.isOtherOrigin(origin, getResource())) {
|
||||||
if (strategy == RuleConstant.STRATEGY_DIRECT) {
|
if (strategy == RuleConstant.STRATEGY_DIRECT) {
|
||||||
return context.getOriginNode();
|
return context.getOriginNode();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,9 @@ public class FlowRuleComparator implements Comparator<FlowRule> {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FlowRule.DEFAULT.equals(o1.getLimitApp())) {
|
if (FlowRule.LIMIT_APP_DEFAULT.equals(o1.getLimitApp())) {
|
||||||
return 1;
|
return 1;
|
||||||
} else if (FlowRule.DEFAULT.equals(o2.getLimitApp())) {
|
} else if (FlowRule.LIMIT_APP_DEFAULT.equals(o2.getLimitApp())) {
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ public class FlowRuleManager {
|
||||||
|
|
||||||
for (FlowRule rule : list) {
|
for (FlowRule rule : list) {
|
||||||
if (StringUtil.isBlank(rule.getLimitApp())) {
|
if (StringUtil.isBlank(rule.getLimitApp())) {
|
||||||
rule.setLimitApp(FlowRule.DEFAULT);
|
rule.setLimitApp(FlowRule.LIMIT_APP_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
Controller rater = new DefaultController(rule.getCount(), rule.getGrade());
|
Controller rater = new DefaultController(rule.getCount(), rule.getGrade());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue