Просмотр исходного кода

Set default FlowRule.grade to RuleConstant.FLOW_GRADE_QPS

master
Carpenter Lee 6 лет назад
Родитель
Сommit
5d5b19e9d7
5 измененных файлов: 16 добавлений и 11 удалений
  1. +1
    -1
      sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/authority/AuthorityRuleManager.java
  2. +1
    -1
      sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/degrade/DegradeRuleManager.java
  3. +11
    -6
      sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/FlowRule.java
  4. +2
    -2
      sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/FlowRuleComparator.java
  5. +1
    -1
      sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/FlowRuleManager.java

+ 1
- 1
sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/authority/AuthorityRuleManager.java Просмотреть файл

@@ -124,7 +124,7 @@ public class AuthorityRuleManager {
Map<String, List<AuthorityRule>> newRuleMap = new ConcurrentHashMap<String, List<AuthorityRule>>();
for (AuthorityRule rule : list) {
if (StringUtil.isBlank(rule.getLimitApp())) {
rule.setLimitApp(FlowRule.DEFAULT);
rule.setLimitApp(FlowRule.LIMIT_APP_DEFAULT);
}

String identity = rule.getResource();


+ 1
- 1
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();


+ 11
- 6
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();
}


+ 2
- 2
sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/FlowRuleComparator.java Просмотреть файл

@@ -30,9 +30,9 @@ public class FlowRuleComparator implements Comparator<FlowRule> {
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;


+ 1
- 1
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());


Загрузка…
Отмена
Сохранить