diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/authority/AuthorityRuleManager.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/authority/AuthorityRuleManager.java index 2c762282..eb7e889d 100755 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/authority/AuthorityRuleManager.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/authority/AuthorityRuleManager.java @@ -124,7 +124,7 @@ public class AuthorityRuleManager { Map> newRuleMap = new ConcurrentHashMap>(); for (AuthorityRule rule : list) { if (StringUtil.isBlank(rule.getLimitApp())) { - rule.setLimitApp(FlowRule.DEFAULT); + rule.setLimitApp(FlowRule.LIMIT_APP_DEFAULT); } String identity = rule.getResource(); diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/degrade/DegradeRuleManager.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/degrade/DegradeRuleManager.java index fbc43fff..581b3116 100755 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/degrade/DegradeRuleManager.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/degrade/DegradeRuleManager.java @@ -143,7 +143,7 @@ public class DegradeRuleManager { for (DegradeRule rule : list) { if (StringUtil.isBlank(rule.getLimitApp())) { - rule.setLimitApp(FlowRule.DEFAULT); + rule.setLimitApp(FlowRule.LIMIT_APP_DEFAULT); } String identity = rule.getResource(); diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/FlowRule.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/FlowRule.java index 87977251..3d13fb3b 100755 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/FlowRule.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/FlowRule.java @@ -40,20 +40,25 @@ import com.alibaba.csp.sentinel.slots.clusterbuilder.ClusterBuilderSlot; */ public class FlowRule extends AbstractRule { - public static final String DEFAULT = "default"; - public static final String OTHER = "other"; + public static final String LIMIT_APP_DEFAULT = "default"; + 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). */ - private int grade; + private int grade = RuleConstant.FLOW_GRADE_QPS; private double count; /** * 0为直接限流;1为关联限流;2为链路限流 */ - private int strategy; + private int strategy = RuleConstant.STRATEGY_DIRECT; private String refResource; @@ -181,7 +186,7 @@ public class FlowRule extends AbstractRule { return node; } - } else if (limitApp.equals(DEFAULT)) { + } else if (LIMIT_APP_DEFAULT.equals(limitApp)) { if (strategy == RuleConstant.STRATEGY_DIRECT) { return node.getClusterNode(); } @@ -201,7 +206,7 @@ public class FlowRule extends AbstractRule { 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) { return context.getOriginNode(); } diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/FlowRuleComparator.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/FlowRuleComparator.java index 2af7378a..b5d091c1 100755 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/FlowRuleComparator.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/FlowRuleComparator.java @@ -30,9 +30,9 @@ public class FlowRuleComparator implements Comparator { return 0; } - if (FlowRule.DEFAULT.equals(o1.getLimitApp())) { + if (FlowRule.LIMIT_APP_DEFAULT.equals(o1.getLimitApp())) { return 1; - } else if (FlowRule.DEFAULT.equals(o2.getLimitApp())) { + } else if (FlowRule.LIMIT_APP_DEFAULT.equals(o2.getLimitApp())) { return -1; } else { return 0; diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/FlowRuleManager.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/FlowRuleManager.java index b734fa91..decc6c2e 100755 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/FlowRuleManager.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/FlowRuleManager.java @@ -111,7 +111,7 @@ public class FlowRuleManager { for (FlowRule rule : list) { if (StringUtil.isBlank(rule.getLimitApp())) { - rule.setLimitApp(FlowRule.DEFAULT); + rule.setLimitApp(FlowRule.LIMIT_APP_DEFAULT); } Controller rater = new DefaultController(rule.getCount(), rule.getGrade());