Selaa lähdekoodia

Rename ParamFlowRule.blockGrade to grade

master
Carpenter Lee 6 vuotta sitten
vanhempi
commit
aaf88b8a0a
7 muutettua tiedostoa jossa 14 lisäystä ja 14 poistoa
  1. +1
    -1
      sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/datasource/entity/rule/ParamFlowRuleEntity.java
  2. +1
    -1
      sentinel-dashboard/src/main/webapp/resources/app/views/param_flow.html
  3. +1
    -1
      sentinel-demo/sentinel-demo-parameter-flow-control/src/main/java/com/alibaba/csp/sentinel/demo/flow/param/ParamFlowQpsDemo.java
  4. +1
    -1
      sentinel-extension/sentinel-parameter-flow-control/README.md
  5. +1
    -1
      sentinel-extension/sentinel-parameter-flow-control/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/param/ParamFlowChecker.java
  6. +8
    -8
      sentinel-extension/sentinel-parameter-flow-control/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/param/ParamFlowRule.java
  7. +1
    -1
      sentinel-extension/sentinel-parameter-flow-control/src/test/java/com/alibaba/csp/sentinel/slots/block/flow/param/ParamFlowRuleManagerTest.java

+ 1
- 1
sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/datasource/entity/rule/ParamFlowRuleEntity.java Näytä tiedosto

@@ -56,7 +56,7 @@ public class ParamFlowRuleEntity extends AbstractRuleEntity<ParamFlowRule> {

@JsonIgnore
public int getBlockGrade() {
return rule.getBlockGrade();
return rule.getGrade();
}

@JsonIgnore


+ 1
- 1
sentinel-dashboard/src/main/webapp/resources/app/views/param_flow.html Näytä tiedosto

@@ -69,7 +69,7 @@
<td style="word-wrap:break-word;word-break:break-all;">{{ruleEntity.rule.resource}}</td>
<td style="word-wrap:break-word;word-break:break-all;">{{ruleEntity.rule.paramIdx}}</td>
<td>
{{ruleEntity.rule.blockGrade == 1 ? 'QPS' : '未知'}}
{{ruleEntity.rule.grade == 1 ? 'QPS' : '未知'}}
</td>
<td style="word-wrap:break-word;word-break:break-all;">
{{ruleEntity.rule.count}}


+ 1
- 1
sentinel-demo/sentinel-demo-parameter-flow-control/src/main/java/com/alibaba/csp/sentinel/demo/flow/param/ParamFlowQpsDemo.java Näytä tiedosto

@@ -55,7 +55,7 @@ public class ParamFlowQpsDemo {
// QPS mode, threshold is 5 for every frequent "hot spot" parameter in index 0 (the first arg).
ParamFlowRule rule = new ParamFlowRule(RESOURCE_KEY)
.setParamIdx(0)
.setBlockGrade(RuleConstant.FLOW_GRADE_QPS)
.setGrade(RuleConstant.FLOW_GRADE_QPS)
.setCount(5);
// We can set threshold count for specific parameter value individually.
// Here we add an exception item. That means: QPS threshold of entries with parameter `PARAM_B` (type: int)


+ 1
- 1
sentinel-extension/sentinel-parameter-flow-control/README.md Näytä tiedosto

@@ -52,7 +52,7 @@ The description for fields of `ParamFlowRule`:
| :----: | :----| :----|
| resource| resource name (**required**) ||
| count | flow control threshold (**required**) ||
| blockGrade | flow control mode (only QPS mode is supported) | QPS mode |
| grade | flow control mode (only QPS mode is supported) | QPS mode |
| paramIdx | the index of provided parameter in `SphU.entry(xxx, args)` (**required**) ||
| paramFlowItemList | the exception items of parameter; you can set threshold to a specific parameter value ||



+ 1
- 1
sentinel-extension/sentinel-parameter-flow-control/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/param/ParamFlowChecker.java Näytä tiedosto

@@ -78,7 +78,7 @@ final class ParamFlowChecker {

static boolean passSingleValueCheck(ResourceWrapper resourceWrapper, ParamFlowRule rule, int count, Object value) {
Set<Object> exclusionItems = rule.getParsedHotItems().keySet();
if (rule.getBlockGrade() == RuleConstant.FLOW_GRADE_QPS) {
if (rule.getGrade() == RuleConstant.FLOW_GRADE_QPS) {
double curCount = getHotParameters(resourceWrapper).getPassParamQps(rule.getParamIdx(), value);

if (exclusionItems.contains(value)) {


+ 8
- 8
sentinel-extension/sentinel-parameter-flow-control/src/main/java/com/alibaba/csp/sentinel/slots/block/flow/param/ParamFlowRule.java Näytä tiedosto

@@ -43,7 +43,7 @@ public class ParamFlowRule extends AbstractRule {
/**
* The threshold type of flow control (1: QPS).
*/
private int blockGrade = RuleConstant.FLOW_GRADE_QPS;
private int grade = RuleConstant.FLOW_GRADE_QPS;

/**
* Parameter index.
@@ -65,12 +65,12 @@ public class ParamFlowRule extends AbstractRule {
*/
private Map<Object, Integer> hotItems = new HashMap<Object, Integer>();

public int getBlockGrade() {
return blockGrade;
public int getGrade() {
return grade;
}

public ParamFlowRule setBlockGrade(int blockGrade) {
this.blockGrade = blockGrade;
public ParamFlowRule setGrade(int grade) {
this.grade = grade;
return this;
}

@@ -124,7 +124,7 @@ public class ParamFlowRule extends AbstractRule {

ParamFlowRule rule = (ParamFlowRule)o;

if (blockGrade != rule.blockGrade) { return false; }
if (grade != rule.grade) { return false; }
if (Double.compare(rule.count, count) != 0) { return false; }
if (paramIdx != null ? !paramIdx.equals(rule.paramIdx) : rule.paramIdx != null) { return false; }
return paramFlowItemList != null ? paramFlowItemList.equals(rule.paramFlowItemList) : rule.paramFlowItemList == null;
@@ -134,7 +134,7 @@ public class ParamFlowRule extends AbstractRule {
public int hashCode() {
int result = super.hashCode();
long temp;
result = 31 * result + blockGrade;
result = 31 * result + grade;
result = 31 * result + (paramIdx != null ? paramIdx.hashCode() : 0);
temp = Double.doubleToLongBits(count);
result = 31 * result + (int)(temp ^ (temp >>> 32));
@@ -147,7 +147,7 @@ public class ParamFlowRule extends AbstractRule {
return "ParamFlowRule{" +
"resource=" + getResource() +
", limitApp=" + getLimitApp() +
", blockGrade=" + blockGrade +
", grade=" + grade +
", paramIdx=" + paramIdx +
", count=" + count +
", paramFlowItemList=" + paramFlowItemList +


+ 1
- 1
sentinel-extension/sentinel-parameter-flow-control/src/test/java/com/alibaba/csp/sentinel/slots/block/flow/param/ParamFlowRuleManagerTest.java Näytä tiedosto

@@ -81,7 +81,7 @@ public class ParamFlowRuleManagerTest {
ParamFlowRule ruleC = new ParamFlowRule(resA)
.setCount(8)
.setParamIdx(1)
.setBlockGrade(RuleConstant.FLOW_GRADE_QPS);
.setGrade(RuleConstant.FLOW_GRADE_QPS);
// Rule D is for resource B.
ParamFlowRule ruleD = new ParamFlowRule(resB)
.setCount(9)


Loading…
Peruuta
Tallenna