1
0
mirror of https://gitee.com/mirrors/Spring-Cloud-Alibaba.git synced 2021-06-26 13:25:11 +08:00

check ParamFlowRule

This commit is contained in:
fangjian0423 2018-12-14 18:14:32 +08:00
parent 8e0239dae1
commit 2bb73f4524

View File

@ -51,6 +51,8 @@ import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule;
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRuleManager;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRule;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager;
import com.alibaba.csp.sentinel.slots.block.flow.param.ParamFlowRule;
import com.alibaba.csp.sentinel.slots.block.flow.param.ParamFlowRuleManager;
import com.alibaba.csp.sentinel.slots.system.SystemRule;
import com.alibaba.csp.sentinel.slots.system.SystemRuleManager;
@ -71,7 +73,8 @@ public class SentinelDataSourceHandler {
private List<String> dataTypeList = Arrays.asList("json", "xml");
private List<Class<? extends AbstractRule>> rulesList = Arrays.asList(FlowRule.class,
DegradeRule.class, SystemRule.class, AuthorityRule.class);
DegradeRule.class, SystemRule.class, AuthorityRule.class,
ParamFlowRule.class);
private List<String> dataSourceBeanNameList = Collections
.synchronizedList(new ArrayList<String>());
@ -163,9 +166,12 @@ public class SentinelDataSourceHandler {
else if (ruleType == SystemRule.class) {
SystemRuleManager.register2Property(sentinelProperty);
}
else {
else if (ruleType == AuthorityRule.class) {
AuthorityRuleManager.register2Property(sentinelProperty);
}
else {
ParamFlowRuleManager.register2Property(sentinelProperty);
}
}
}
}
@ -337,14 +343,15 @@ public class SentinelDataSourceHandler {
}
private boolean checkAllRuleTypeSame(List convertedRuleList) {
int matchCount = 0;
for(Object rule : convertedRuleList) {
if(rulesList.contains(rule.getClass()) && rule.getClass() == convertedRuleList.get(0).getClass()) {
matchCount ++;
}
}
return matchCount == convertedRuleList.size();
}
int matchCount = 0;
for (Object rule : convertedRuleList) {
if (rulesList.contains(rule.getClass())
&& rule.getClass() == convertedRuleList.get(0).getClass()) {
matchCount++;
}
}
return matchCount == convertedRuleList.size();
}
public List<String> getDataSourceBeanNameList() {
return dataSourceBeanNameList;